#include #include // to construct a simplex_tree from alpha complex #include #include #include #include #include #include #include // for numeric limits #include #include #include #include std::ofstream results_csv("results.csv"); template void benchmark_points_on_torus_dD(const std::string& msg) { std::cout << "+ " << msg << std::endl; results_csv << "\"" << msg << "\";" << std::endl; results_csv << "\"nb_points\";" << "\"nb_simplices\";" << "\"alpha_creation_time(sec.)\";" << "\"complex_creation_time(sec.)\";" << std::endl; using K = CGAL::Epick_d>; for (int nb_points = 1000; nb_points <= 125000; nb_points *= 5) { std::cout << " Alpha complex dD on torus with " << nb_points << " points." << std::endl; std::vector points_on_torus = Gudhi::generate_points_on_torus_3D(nb_points, 1.0, 0.5); std::vector points; for (auto p : points_on_torus) { points.push_back(typename Kernel::Point_d(p.begin(), p.end())); } Gudhi::Clock ac_create_clock(" benchmark_points_on_torus_dD - Alpha complex 3d creation"); ac_create_clock.begin(); Gudhi::alpha_complex::Alpha_complex alpha_complex_from_points(points); ac_create_clock.end(); std::cout << ac_create_clock; Gudhi::Simplex_tree<> complex; Gudhi::Clock st_create_clock(" benchmark_points_on_torus_dD - complex creation"); st_create_clock.begin(); alpha_complex_from_points.create_complex(complex); st_create_clock.end(); std::cout << st_create_clock; results_csv << nb_points << ";" << complex.num_simplices() << ";" << ac_create_clock.num_seconds() << ";" << st_create_clock.num_seconds() << ";" << std::endl; std::cout << " benchmark_points_on_torus_dD - nb simplices = " << complex.num_simplices() << std::endl; } } template void benchmark_points_on_torus_3D(const std::string& msg) { using K = CGAL::Epick_d>; std::cout << "+ " << msg << std::endl; results_csv << "\"" << msg << "\";" << std::endl; results_csv << "\"nb_points\";" << "\"nb_simplices\";" << "\"alpha_creation_time(sec.)\";" << "\"complex_creation_time(sec.)\";" << std::endl; for (int nb_points = 1000; nb_points <= 125000; nb_points *= 5) { std::cout << " Alpha complex 3d on torus with " << nb_points << " points." << std::endl; std::vector points_on_torus = Gudhi::generate_points_on_torus_3D(nb_points, 1.0, 0.5); std::vector points; for (auto p : points_on_torus) { points.push_back(typename Alpha_complex_3d::Point_3(p[0], p[1], p[2])); } Gudhi::Clock ac_create_clock(" benchmark_points_on_torus_3D - Alpha complex 3d creation"); ac_create_clock.begin(); Alpha_complex_3d alpha_complex_from_points(points); ac_create_clock.end(); std::cout << ac_create_clock; Gudhi::Simplex_tree<> complex; Gudhi::Clock st_create_clock(" benchmark_points_on_torus_3D - complex creation"); st_create_clock.begin(); alpha_complex_from_points.create_complex(complex); st_create_clock.end(); std::cout << st_create_clock; results_csv << nb_points << ";" << complex.num_simplices() << ";" << ac_create_clock.num_seconds() << ";" << st_create_clock.num_seconds() << ";" << std::endl; std::cout << " benchmark_points_on_torus_3D - nb simplices = " << complex.num_simplices() << std::endl; } } template void benchmark_weighted_points_on_torus_3D(const std::string& msg) { using K = CGAL::Epick_d>; std::cout << "+ " << msg << std::endl; results_csv << "\"" << msg << "\";" << std::endl; results_csv << "\"nb_points\";" << "\"nb_simplices\";" << "\"alpha_creation_time(sec.)\";" << "\"complex_creation_time(sec.)\";" << std::endl; CGAL::Random random(8); for (int nb_points = 1000; nb_points <= 125000; nb_points *= 5) { std::cout << " Alpha complex 3d on torus with " << nb_points << " points." << std::endl; std::vector points_on_torus = Gudhi::generate_points_on_torus_3D(nb_points, 1.0, 0.5); using Point = typename Weighted_alpha_complex_3d::Bare_point_3; using Weighted_point = typename Weighted_alpha_complex_3d::Weighted_point_3; std::vector points; for (auto p : points_on_torus) { points.push_back(Weighted_point(Point(p[0], p[1], p[2]), 0.9 + random.get_double(0., 0.01))); } Gudhi::Clock ac_create_clock(" benchmark_weighted_points_on_torus_3D - Alpha complex 3d creation"); ac_create_clock.begin(); Weighted_alpha_complex_3d alpha_complex_from_points(points); ac_create_clock.end(); std::cout << ac_create_clock; Gudhi::Simplex_tree<> complex; Gudhi::Clock st_create_clock(" benchmark_weighted_points_on_torus_3D - complex creation"); st_create_clock.begin(); alpha_complex_from_points.create_complex(complex); st_create_clock.end(); std::cout << st_create_clock; results_csv << nb_points << ";" << complex.num_simplices() << ";" << ac_create_clock.num_seconds() << ";" << st_create_clock.num_seconds() << ";" << std::endl; std::cout << " benchmark_weighted_points_on_torus_3D - nb simplices = " << complex.num_simplices() << std::endl; } } template void benchmark_periodic_points(const std::string& msg) { std::cout << "+ " << msg << std::endl; results_csv << "\"" << msg << "\";" << std::endl; results_csv << "\"nb_points\";" << "\"nb_simplices\";" << "\"alpha_creation_time(sec.)\";" << "\"complex_creation_time(sec.)\";" << std::endl; CGAL::Random random(8); for (double nb_points = 10.; nb_points <= 40.; nb_points += 10.) { std::cout << " Periodic alpha complex 3d with " << nb_points * nb_points * nb_points << " points." << std::endl; using Point = typename Periodic_alpha_complex_3d::Point_3; std::vector points; for (double i = 0; i < nb_points; i++) { for (double j = 0; j < nb_points; j++) { for (double k = 0; k < nb_points; k++) { points.push_back( Point(i + random.get_double(0., 0.1), j + random.get_double(0., 0.1), k + random.get_double(0., 0.1))); } } } Gudhi::Clock ac_create_clock(" benchmark_periodic_points - Alpha complex 3d creation"); ac_create_clock.begin(); Periodic_alpha_complex_3d alpha_complex_from_points(points, 0., 0., 0., nb_points, nb_points, nb_points); ac_create_clock.end(); std::cout << ac_create_clock; Gudhi::Simplex_tree<> complex; Gudhi::Clock st_create_clock(" benchmark_periodic_points - complex creation"); st_create_clock.begin(); alpha_complex_from_points.create_complex(complex); st_create_clock.end(); std::cout << st_create_clock; results_csv << nb_points * nb_points * nb_points << ";" << complex.num_simplices() << ";" << ac_create_clock.num_seconds() << ";" << st_create_clock.num_seconds() << ";" << std::endl; std::cout << " benchmark_periodic_points - nb simplices = " << complex.num_simplices() << std::endl; } } template void benchmark_weighted_periodic_points(const std::string& msg) { std::cout << "+ " << msg << std::endl; results_csv << "\"" << msg << "\";" << std::endl; results_csv << "\"nb_points\";" << "\"nb_simplices\";" << "\"alpha_creation_time(sec.)\";" << "\"complex_creation_time(sec.)\";" << std::endl; CGAL::Random random(8); for (double nb_points = 10.; nb_points <= 40.; nb_points += 10.) { std::cout << " Weighted periodic alpha complex 3d with " << nb_points * nb_points * nb_points << " points." << std::endl; using Point = typename Weighted_periodic_alpha_complex_3d::Bare_point_3; using Weighted_point = typename Weighted_periodic_alpha_complex_3d::Weighted_point_3; std::vector points; for (double i = 0; i < nb_points; i++) { for (double j = 0; j < nb_points; j++) { for (double k = 0; k < nb_points; k++) { points.push_back(Weighted_point( Point(i + random.get_double(0., 0.1), j + random.get_double(0., 0.1), k + random.get_double(0., 0.1)), random.get_double(0., (nb_points * nb_points) / 64.))); } } } Gudhi::Clock ac_create_clock(" benchmark_weighted_periodic_points - Alpha complex 3d creation"); ac_create_clock.begin(); Weighted_periodic_alpha_complex_3d alpha_complex_from_points(points, 0., 0., 0., nb_points, nb_points, nb_points); ac_create_clock.end(); std::cout << ac_create_clock; Gudhi::Simplex_tree<> complex; Gudhi::Clock st_create_clock(" benchmark_weighted_periodic_points - complex creation"); st_create_clock.begin(); alpha_complex_from_points.create_complex(complex); st_create_clock.end(); std::cout << st_create_clock; results_csv << nb_points * nb_points * nb_points << ";" << complex.num_simplices() << ";" << ac_create_clock.num_seconds() << ";" << st_create_clock.num_seconds() << ";" << std::endl; std::cout << " benchmark_weighted_periodic_points - nb simplices = " << complex.num_simplices() << std::endl; } } int main(int argc, char** argv) { benchmark_points_on_torus_dD>>("Fast static dimension version"); benchmark_points_on_torus_dD>("Fast dynamic dimension version"); benchmark_points_on_torus_dD>>("Exact static dimension version"); benchmark_points_on_torus_dD>("Exact dynamic dimension version"); benchmark_points_on_torus_3D< Gudhi::alpha_complex::Alpha_complex_3d>("Fast version"); benchmark_points_on_torus_3D< Gudhi::alpha_complex::Alpha_complex_3d>("Safe version"); benchmark_points_on_torus_3D< Gudhi::alpha_complex::Alpha_complex_3d>("Exact version"); benchmark_weighted_points_on_torus_3D< Gudhi::alpha_complex::Alpha_complex_3d>("Fast version"); benchmark_weighted_points_on_torus_3D< Gudhi::alpha_complex::Alpha_complex_3d>("Safe version"); benchmark_weighted_points_on_torus_3D< Gudhi::alpha_complex::Alpha_complex_3d>("Exact version"); benchmark_periodic_points< Gudhi::alpha_complex::Alpha_complex_3d>("Fast version"); benchmark_periodic_points< Gudhi::alpha_complex::Alpha_complex_3d>("Safe version"); benchmark_periodic_points< Gudhi::alpha_complex::Alpha_complex_3d>("Exact version"); benchmark_weighted_periodic_points< Gudhi::alpha_complex::Alpha_complex_3d>("Fast version"); benchmark_weighted_periodic_points< Gudhi::alpha_complex::Alpha_complex_3d>("Safe version"); benchmark_weighted_periodic_points< Gudhi::alpha_complex::Alpha_complex_3d>("Exact version"); return 0; }