Fixed most of the old benchmarks

This commit is contained in:
m.overtheil 2014-12-05 14:36:46 +01:00
parent 2a71befeaa
commit 7fe5f7c9ae
8 changed files with 42 additions and 28 deletions

View File

@ -11,11 +11,13 @@
#include <CGAL/K_neighbor_search.h> #include <CGAL/K_neighbor_search.h>
#include <CGAL/Search_traits_3.h> #include <CGAL/Search_traits_3.h>
#include<sfcnn.hpp>
#include <ANN/ANN.h> #include <ANN/ANN.h>
#include <ANN/ANNperf.h> #include <ANN/ANNperf.h>
#include<sfcnn.hpp>
typedef CGAL::Simple_cartesian<double> Kernel; typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_3 Point_3; typedef Kernel::Point_3 Point_3;
typedef CGAL::Random_points_in_cube_3<Point_3> Random_points_iterator; typedef CGAL::Random_points_in_cube_3<Point_3> Random_points_iterator;

View File

@ -32,7 +32,7 @@ int main() {
std::cout << "Enter input file name containing data points: \n" ; std::cout << "Enter input file name containing data points: \n" ;
std::cin >> filename_data_points; std::cin >> filename_data_points;
ifstream in_data_points, in_query_points; std::ifstream in_data_points, in_query_points;
int data_point_number; int data_point_number;
int query_point_number; int query_point_number;
int N, N_data_points, N_query_points; // dimension of input data int N, N_data_points, N_query_points; // dimension of input data
@ -59,20 +59,20 @@ int main() {
point_list query_points, data_points; point_list query_points, data_points;
for (int i = 0; i < query_point_number; i++) { for (int i = 0; i < query_point_number; i++) {
double p[N]; std::vector<double> p(N);
for (int j = 0; j < N; j++) { for (int j = 0; j < N; j++) {
in_query_points >> p[j]; in_query_points >> p[j];
} }
Point_d Pnt(N,p,p+N); Point_d Pnt(N,p.begin(),p.end());
query_points.push_back(Pnt); query_points.push_back(Pnt);
}; };
for (int i = 0; i < data_point_number; i++) { for (int i = 0; i < data_point_number; i++) {
double p[N]; std::vector<double> p(N);
for (int j = 0; j < N; j++) { for (int j = 0; j < N; j++) {
in_data_points >> p[j]; in_data_points >> p[j];
} }
Point_d Pnt(N,p,p+N); Point_d Pnt(N,p.begin(),p.end());
data_points.push_back(Pnt); data_points.push_back(Pnt);
}; };

View File

@ -35,7 +35,7 @@ int main() {
std::cout << "Enter input file name containing data points: \n" ; std::cout << "Enter input file name containing data points: \n" ;
std::cin >> filename_data_points; std::cin >> filename_data_points;
ifstream in_data_points, in_query_points; std::ifstream in_data_points, in_query_points;
int data_point_number; int data_point_number;
int query_point_number; int query_point_number;
int N, N_data_points, N_query_points; // dimension of input data int N, N_data_points, N_query_points; // dimension of input data
@ -62,7 +62,7 @@ int main() {
point_list query_points, data_points; point_list query_points, data_points;
for (int i = 0; i < query_point_number; i++) { for (int i = 0; i < query_point_number; i++) {
double p[N]; std::vector<double> p(N);
for (int j = 0; j < N; j++) { for (int j = 0; j < N; j++) {
in_query_points >> p[j]; in_query_points >> p[j];
} }
@ -71,7 +71,7 @@ int main() {
}; };
for (int i = 0; i < data_point_number; i++) { for (int i = 0; i < data_point_number; i++) {
double p[N]; std::vector<double> p(N);
for (int j = 0; j < N; j++) { for (int j = 0; j < N; j++) {
in_data_points >> p[j]; in_data_points >> p[j];
} }

View File

@ -40,7 +40,7 @@ int main() {
std::cout << "Enter input file name containing data points: \n" ; std::cout << "Enter input file name containing data points: \n" ;
std::cin >> filename_data_points; std::cin >> filename_data_points;
ifstream in_data_points, in_query_points; std::ifstream in_data_points, in_query_points;
int data_point_number; int data_point_number;
int query_point_number; int query_point_number;
int N, N_data_points, N_query_points; // dimension of input data int N, N_data_points, N_query_points; // dimension of input data
@ -67,7 +67,7 @@ int main() {
point_list query_points, data_points; point_list query_points, data_points;
for (int i = 0; i < query_point_number; i++) { for (int i = 0; i < query_point_number; i++) {
double p[N]; std::vector<double> p(N);
for (int j = 0; j < N; j++) { for (int j = 0; j < N; j++) {
in_query_points >> p[j]; in_query_points >> p[j];
} }
@ -76,7 +76,7 @@ int main() {
}; };
for (int i = 0; i < data_point_number; i++) { for (int i = 0; i < data_point_number; i++) {
double p[N]; std::vector<double> p(N);
for (int j = 0; j < N; j++) { for (int j = 0; j < N; j++) {
in_data_points >> p[j]; in_data_points >> p[j];
} }
@ -90,7 +90,6 @@ int main() {
Tree tree(data_points.begin(), data_points.end(), sliding_midpoint); Tree tree(data_points.begin(), data_points.end(), sliding_midpoint);
t.stop(); t.stop();
std::cout << "bucket size is " << tree.bucket_size() << std::endl;
data_points.clear(); data_points.clear();
std::cout << "created binary search tree containing" << std::endl std::cout << "created binary search tree containing" << std::endl

View File

@ -29,8 +29,8 @@ int main() {
std::cout << "Enter output file name containing data points: \n" ; std::cout << "Enter output file name containing data points: \n" ;
std::cin >> filename_out_data_points; std::cin >> filename_out_data_points;
ifstream in; std::ifstream in;
ofstream out_query, out_data; std::ofstream out_query, out_data;
int data_point_number, query_point_number; int data_point_number, query_point_number;
@ -52,7 +52,7 @@ int main() {
std::cout << "data point number = " << data_point_number << std::endl; std::cout << "data point number = " << data_point_number << std::endl;
std::cout << "query point number = " << query_point_number << std::endl; std::cout << "query point number = " << query_point_number << std::endl;
int query_point[point_number]; std::vector<int> query_point(point_number);
for (int ii = 0; ii < point_number; ii++) query_point[ii]=0; for (int ii = 0; ii < point_number; ii++) query_point[ii]=0;
@ -68,11 +68,11 @@ int main() {
for (int i = 0; i < point_number; i++) { for (int i = 0; i < point_number; i++) {
double p[N]; std::vector<double> p(N);
for (int j = 0; j < N; j++) { for (int j = 0; j < N; j++) {
in >> p[j]; in >> p[j];
} }
Point_d Pnt(N,p,p+N); Point_d Pnt(N,p.begin(),p.end());
all_points.push_back(Pnt); all_points.push_back(Pnt);
}; };

View File

@ -156,15 +156,10 @@ void kdtree_demo(int argc, char** argv)
if(dump) if(dump)
std::cerr <<cloud.pts[ret_index[k]] << std::endl; std::cerr <<cloud.pts[ret_index[k]] << std::endl;
} }
if(dump){
std::cerr << "Tree has:\n"<<index.items<< " items\n"<<index.internals <<" internals\n"<< index.leafs<<" leafs\n"<<index.depth()<<" depth\n";
index.print_mem_usage();
}
dump=false; dump=false;
} }
timer.stop(); timer.stop();
std::cout << sum << " done in " << timer.time() << " sec."<< std::endl; std::cout << sum << " done in " << timer.time() << " sec."<< std::endl;
std::cerr << index.count_items <<" items "<<index.count_internals<< " internals "<<index.count_leafs<< " leafs visited\n";
} }
int main(int argc, char** argv) int main(int argc, char** argv)

View File

@ -10,6 +10,9 @@ namespace CGAL {
\section Spatial_searchingIntroduction Introduction \section Spatial_searchingIntroduction Introduction
\cgalModifBegin
Pointed out worst cases for splitters and added example
\cgalModifEnd
The spatial searching package implements exact and approximate The spatial searching package implements exact and approximate
distance browsing by providing implementations of algorithms distance browsing by providing implementations of algorithms
supporting supporting
@ -145,7 +148,9 @@ because in general the query time will be less then using the default value.
Instead of using the default splitting rule `Sliding_midpoint` described below, Instead of using the default splitting rule `Sliding_midpoint` described below,
a user may, depending upon the data, select a user may, depending upon the data, select
one from the following splitting rules, one from the following splitting rules,
which determine how a separating hyperplane is computed: which determine how a separating hyperplane is computed. Every splitter has
degenerated worst cases, which may lead to a linear tree and a stack overflow.
Switching the splitting rule to one of a different kind will solve the problem.
<DL> <DL>
@ -219,14 +224,15 @@ generate empty cells.
\section Spatial_searchingExample Example Programs \section Spatial_searchingExample Example Programs
We give six examples. The first example illustrates k nearest neighbor We give seven examples. The first example illustrates k nearest neighbor
searching, and the second example incremental neighbor searching. searching, and the second example incremental neighbor searching.
The third is an example of approximate furthest neighbor searching The third is an example of approximate furthest neighbor searching
using a `d`-dimensional iso-rectangle as an query object. Approximate using a `d`-dimensional iso-rectangle as an query object. Approximate
range searching is illustrated by the fourth example. The fifth range searching is illustrated by the fourth example. The fifth
example illustrates k neighbor searching for a user defined point example illustrates k neighbor searching for a user defined point
class. The last example shows how to choose another splitting rule in the class. The sixth example shows how to choose another splitting rule in the
`k-d` tree that is used as search tree. `k-d` tree that is used as search tree. The last example shows two worst-case
scenarios for different splitter types.
\subsection Spatial_searchingExampleforKNeighborSearching Example for K Neighbor Searching \subsection Spatial_searchingExampleforKNeighborSearching Example for K Neighbor Searching
@ -333,6 +339,17 @@ splitting rule, needed to set the maximal allowed bucket size.
\cgalExample{Spatial_searching/using_fair_splitting_rule.cpp} \cgalExample{Spatial_searching/using_fair_splitting_rule.cpp}
\subsection Spatial_searchingExampleforWorstCaseScenarios Example for worst-case scenarios for different splitters
This example program has two 2-dimensional data sets: The first one containing
colinear points with exponential increasing distances and the second
one with colinear points in dimension 1 and one point with a distance
exceeding the spread of the other points in distance 2. These are
the worst cases for the midpoint/median rules and can also occur in
higher dimensions.
\cgalExample{Spatial_searching/splitter_worst_cases.cpp}
\section Spatial_searchingSoftware Software Design \section Spatial_searchingSoftware Software Design
\subsection Kd_tree_subsection The k-d tree \subsection Kd_tree_subsection The k-d tree

View File

@ -14,4 +14,5 @@
\example Spatial_searching/user_defined_point_and_distance.cpp \example Spatial_searching/user_defined_point_and_distance.cpp
\example Spatial_searching/using_fair_splitting_rule.cpp \example Spatial_searching/using_fair_splitting_rule.cpp
\example Spatial_searching/weighted_Minkowski_distance.cpp \example Spatial_searching/weighted_Minkowski_distance.cpp
\example Spatial_searching/splitter_worst_cases.cpp
*/ */