diff --git a/test/new_rounding_test.cpp b/test/new_rounding_test.cpp deleted file mode 100644 index b3f6a2adf..000000000 --- a/test/new_rounding_test.cpp +++ /dev/null @@ -1,214 +0,0 @@ -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2020 Vissarion Fisikopoulos -// Copyright (c) 2018 Apostolos Chalkis - -// Licensed under GNU LGPL.3, see LICENCE file - -#include "doctest.h" -#include -#include -#include "misc.h" -#include "random.hpp" -#include "random/uniform_int.hpp" -#include "random/normal_distribution.hpp" -#include "random/uniform_real_distribution.hpp" - -#include "random_walks/random_walks.hpp" - -#include "volume/volume_sequence_of_balls.hpp" -#include "volume/volume_cooling_gaussians.hpp" -#include "volume/volume_cooling_balls.hpp" - -#include "preprocess/min_sampling_covering_ellipsoid_rounding.hpp" -#include "preprocess/max_inscribed_ellipsoid_rounding.hpp" -#include "preprocess/svd_rounding.hpp" - -#include "known_polytope_generators.h" - -template -NT factorial(NT n) -{ - return (n == 1 || n == 0) ? 1 : factorial(n - 1) * n; -} - -template -void test_values(NT volume, NT expected, NT exact) -{ - std::cout << "Computed volume " << volume << std::endl; - std::cout << "Expected volume = " << expected << std::endl; - std::cout << "Relative error (expected) = " - << std::abs((volume-expected)/expected) << std::endl; - std::cout << "Relative error (exact) = " - << std::abs((volume-exact)/exact) << std::endl; - CHECK((std::abs((volume - exact)/exact) < 0.2 || - std::abs((volume - expected)/expected) < 0.00001)); -} - -template -void rounding_min_ellipsoid_test(Polytope &HP, - double const& expectedBall, - double const& expectedCDHR, - double const& expectedRDHR, - double const& expectedBilliard, - double const& exact) -{ - typedef typename Polytope::PointType Point; - typedef typename Point::FT NT; - typedef typename Polytope::MT MT; - typedef typename Polytope::VT VT; - - int d = HP.dimension(); - - typedef BoostRandomNumberGenerator RNGType; - RNGType rng(d); - - std::pair InnerBall = HP.ComputeInnerBall(); - std::tuple res = min_sampling_covering_ellipsoid_rounding(HP, InnerBall, - 10 + 10 * d, rng); - - // Setup the parameters - int walk_len = 1; - NT e = 0.1; - - // Estimate the volume - std::cout << "Number type: " << typeid(NT).name() << std::endl; - - - //TODO: low accuracy in high dimensions - //NT volume = res.second * volume_cooling_balls(HP, e, walk_len); - //test_values(volume, expectedBall, exact); - - NT volume = std::get<2>(res) * volume_cooling_balls(HP, e, walk_len).second; - test_values(volume, expectedCDHR, exact); - - volume = std::get<2>(res) * volume_cooling_balls(HP, e, 2*walk_len).second; - test_values(volume, expectedRDHR, exact); - - volume = std::get<2>(res) * volume_cooling_balls(HP, e, walk_len).second; - test_values(volume, expectedBilliard, exact); -} - - -template -void rounding_max_ellipsoid_test(Polytope &HP, - double const& expectedBall, - double const& expectedCDHR, - double const& expectedRDHR, - double const& expectedBilliard, - double const& exact) -{ - typedef typename Polytope::PointType Point; - typedef typename Point::FT NT; - typedef typename Polytope::MT MT; - typedef typename Polytope::VT VT; - - int d = HP.dimension(); - - typedef BoostRandomNumberGenerator RNGType; - RNGType rng(d); - - std::pair InnerBall = HP.ComputeInnerBall(); - std::tuple res = max_inscribed_ellipsoid_rounding(HP, InnerBall.first); - - // Setup the parameters - int walk_len = 1; - NT e = 0.1; - - // Estimate the volume - std::cout << "Number type: " << typeid(NT).name() << std::endl; - - NT volume = std::get<2>(res) * volume_cooling_balls(HP, e, walk_len).second; - test_values(volume, expectedBilliard, exact); -} - - -template -void rounding_svd_test(Polytope &HP, - double const& expectedBall, - double const& expectedCDHR, - double const& expectedRDHR, - double const& expectedBilliard, - double const& exact) -{ - typedef typename Polytope::PointType Point; - typedef typename Point::FT NT; - typedef typename Polytope::MT MT; - typedef typename Polytope::VT VT; - - int d = HP.dimension(); - - typedef BoostRandomNumberGenerator RNGType; - RNGType rng(d); - - std::pair InnerBall = HP.ComputeInnerBall(); - std::tuple res = svd_rounding(HP, InnerBall, 10 + 10 * d, rng); - - // Setup the parameters - int walk_len = 1; - NT e = 0.1; - - // Estimate the volume - std::cout << "Number type: " << typeid(NT).name() << std::endl; - - NT volume = std::get<2>(res) * volume_cooling_balls(HP, e, walk_len).second; - test_values(volume, expectedBilliard, exact); -} - - -template -void call_test_min_ellipsoid() { - typedef Cartesian Kernel; - typedef typename Kernel::Point Point; - typedef HPolytope Hpolytope; - Hpolytope P; - - std::cout << "\n--- Testing rounding of H-skinny_cube5" << std::endl; - P = generate_skinny_cube(5); - rounding_min_ellipsoid_test(P, 0, 3070.64, 3188.25, 3140.6, 3200.0); - - std::cout << "\n--- Testing rounding of H-skinny_cube10" << std::endl; - - P = generate_skinny_cube(10); - rounding_min_ellipsoid_test(P, 0, 122550, 108426, 105003.0, 102400.0); -} - - -template -void call_test_max_ellipsoid() { - typedef Cartesian Kernel; - typedef typename Kernel::Point Point; - typedef HPolytope Hpolytope; - Hpolytope P; - - std::cout << "\n--- Testing rounding of H-skinny_cube5" << std::endl; - P = generate_skinny_cube(5); - rounding_max_ellipsoid_test(P, 0, 3070.64, 3188.25, 3140.6, 3200.0); -} - - -template -void call_test_svd() { - typedef Cartesian Kernel; - typedef typename Kernel::Point Point; - typedef HPolytope Hpolytope; - Hpolytope P; - - std::cout << "\n--- Testing rounding of H-skinny_cube5" << std::endl; - P = generate_skinny_cube(5); - rounding_svd_test(P, 0, 3070.64, 3188.25, 3140.6, 3200.0); -} - - -TEST_CASE("round_min_ellipsoid") { - call_test_min_ellipsoid(); -} - -TEST_CASE("round_max_ellipsoid") { - call_test_max_ellipsoid(); -} - -TEST_CASE("round_svd") { - call_test_svd(); -} -