From dbb65c3f3eb82d080e47b40b52deb03814d8da31 Mon Sep 17 00:00:00 2001 From: Hind-M Date: Mon, 25 Apr 2022 13:18:11 +0200 Subject: Remove proximity_graph computation benchmark Add Dynamic_dimension_tag case --- .../benchmark/cech_complex_benchmark.cpp | 97 ++-------------------- 1 file changed, 8 insertions(+), 89 deletions(-) (limited to 'src/Cech_complex') diff --git a/src/Cech_complex/benchmark/cech_complex_benchmark.cpp b/src/Cech_complex/benchmark/cech_complex_benchmark.cpp index 9cf24542..d2a71879 100644 --- a/src/Cech_complex/benchmark/cech_complex_benchmark.cpp +++ b/src/Cech_complex/benchmark/cech_complex_benchmark.cpp @@ -10,12 +10,10 @@ #include #include -#include #include #include #include #include -#include #include #include @@ -29,86 +27,11 @@ using Simplex_tree = Gudhi::Simplex_tree<>; using Filtration_value = Simplex_tree::Filtration_value; using Point = std::vector; -using Point_cloud = std::vector; using Points_off_reader = Gudhi::Points_off_reader; -using Proximity_graph = Gudhi::Proximity_graph; using Rips_complex = Gudhi::rips_complex::Rips_complex; -class Minimal_enclosing_ball_radius { - public: - // boost::range_value is not SFINAE-friendly so we cannot use it in the return type - template - typename std::iterator_traits::type>::value_type operator()( - const Point& p1, const Point& p2) const { - // Type def - using Point_cloud = std::vector; - using Point_iterator = typename Point_cloud::const_iterator; - using Coordinate_iterator = typename Point::const_iterator; - using Min_sphere = - typename Gudhi::Miniball::Miniball>; - - Point_cloud point_cloud; - point_cloud.push_back(p1); - point_cloud.push_back(p2); - - GUDHI_CHECK((p1.end() - p1.begin()) == (p2.end() - p2.begin()), "inconsistent point dimensions"); - Min_sphere min_sphere(p1.end() - p1.begin(), point_cloud.begin(), point_cloud.end()); - - return std::sqrt(min_sphere.squared_radius()); - } -}; - -enum distance_type { Euclidean_dist, Minimal_enclosing_ball_dist, CGAL_dist }; - -template> -void benchmark_prox_graph(const std::string& off_file_points, const Filtration_value& threshold, const std::string& msg, distance_type dist = CGAL_dist) { - if (dist != CGAL_dist) { - std::cerr << "Error: when CGAL is used, the distance should be CGAL_dist" << std::endl; - exit(-1); - } - if (!use_cgal) { - std::cerr << "Warning: if kernel is given, CGAL will be used" << std::endl; - } - using Point_cgal = typename Kernel::Point_d; - using Points_off_reader_cgal = Gudhi::Points_off_reader; - - // Extract the points from the file filepoints - Points_off_reader_cgal off_reader_cgal(off_file_points); - - Gudhi::Clock cgal_circumsphere_clock("Gudhi::cech_complex::Sphere_circumradius_cgal()"); - // Compute the proximity graph of the points - Proximity_graph cgal_circumsphere_prox_graph = Gudhi::compute_proximity_graph(off_reader_cgal.get_point_cloud(), threshold, - Gudhi::cech_complex::Sphere_circumradius()); - std::clog << msg << " - " << cgal_circumsphere_clock << std::endl; -} - -template -void benchmark_prox_graph(const std::string& off_file_points, const Filtration_value& threshold, const std::string& msg, distance_type dist) { - // Extract the points from the file filepoints - Points_off_reader off_reader(off_file_points); - - if (dist == Euclidean_dist) { - Gudhi::Clock euclidean_clock("Gudhi::Euclidean_distance"); - // Compute the proximity graph of the points - Proximity_graph euclidean_prox_graph = Gudhi::compute_proximity_graph(off_reader.get_point_cloud(), threshold, - Gudhi::Euclidean_distance()); - std::clog << msg << " - " << euclidean_clock << std::endl; - } - else if (dist == Minimal_enclosing_ball_dist) { - Gudhi::Clock miniball_clock("Minimal_enclosing_ball_radius"); - // Compute the proximity graph of the points - Proximity_graph miniball_prox_graph = Gudhi::compute_proximity_graph(off_reader.get_point_cloud(), threshold, - Minimal_enclosing_ball_radius()); - std::clog << msg << " - " << miniball_clock << std::endl; - } - else { - std::cerr << "Error: when CGAL is not used, the distance should be either Euclidean_dist or Minimal_enclosing_ball_dist" << std::endl; - exit(-1); - } -} - template -void benchmark_cech(const std::string& off_file_points, const Filtration_value& radius, const int& dim_max) { +Simplex_tree benchmark_cech(const std::string& off_file_points, const Filtration_value& radius, const int& dim_max) { using Point_cgal = typename Kernel::Point_d; using Points_off_reader_cgal = Gudhi::Points_off_reader; using Cech_complex = Gudhi::cech_complex::Cech_complex; @@ -126,23 +49,16 @@ void benchmark_cech(const std::string& off_file_points, const Filtration_value& // ------------------------------------------ double cech_sec = cech_clock.num_seconds(); std::clog << cech_sec << " ; "; - std::clog << cech_stree.num_simplices() << " ; "; + return cech_stree; } int main(int argc, char* argv[]) { - std::string off_file_points = "tore3D_1307.off"; - Filtration_value threshold = 1e20; - - benchmark_prox_graph(off_file_points, threshold, "Euclidean distance", Euclidean_dist); - benchmark_prox_graph(off_file_points, threshold, "Minimal_enclosing_ball", Minimal_enclosing_ball_dist); - benchmark_prox_graph>>(off_file_points, threshold, "Epick"); - benchmark_prox_graph>>(off_file_points, threshold, "Epeck"); - boost::filesystem::path full_path(boost::filesystem::current_path()); std::clog << "Current path is : " << full_path << std::endl; - std::clog << "File name ; Radius ; Rips time ; Epick Cech time ; Epick Cech nb simplices ; Epeck Cech time ; Epeck Cech nb simplices ; Rips nb simplices;" - << std::endl; + std::clog << "File name ; Radius ; Rips time ; Dim-3 Epick Cech time ; Dynamic_dim Epick Cech time ; " + "Dim-3 Epeck Cech time ; Dynamic_dim Epeck Cech time ; Cech nb simplices ; Rips nb simplices;" + << std::endl; boost::filesystem::directory_iterator end_itr; // default construction yields past-the-end for (boost::filesystem::directory_iterator itr(boost::filesystem::current_path()); itr != end_itr; ++itr) { if (!boost::filesystem::is_directory(itr->status())) { @@ -168,8 +84,11 @@ int main(int argc, char* argv[]) { // Cech complex // -------------- benchmark_cech>>(itr->path().string(), radius, p0.size() - 1); + benchmark_cech>(itr->path().string(), radius, p0.size() - 1); benchmark_cech>>(itr->path().string(), radius, p0.size() - 1); + auto cech_stree = benchmark_cech>(itr->path().string(), radius, p0.size() - 1); + std::clog << cech_stree.num_simplices() << " ; "; std::clog << rips_stree.num_simplices() << ";" << std::endl; } } -- cgit v1.2.3