diff --git a/examples/crhmc_cooling_gaussians/volume_example.cpp b/examples/crhmc_cooling_gaussians/volume_example.cpp index 22e1ccd56..d28fba051 100644 --- a/examples/crhmc_cooling_gaussians/volume_example.cpp +++ b/examples/crhmc_cooling_gaussians/volume_example.cpp @@ -16,25 +16,41 @@ typedef double NT; typedef Cartesian Kernel; typedef typename Kernel::Point Point; -typedef BoostRandomNumberGenerator RNGType; +typedef BoostRandomNumberGenerator RandomNumberGenerator; typedef HPolytope HPOLYTOPE; -template void calculateAndVerifyVolume(HPOLYTOPE& polytope) { int walk_len = 100; NT e = 0.1; - NT volume = volume_cooling_gaussians(polytope, e, walk_len); + RandomNumberGenerator rng(polytope.dimension()); + + NT volume = volume_cooling_gaussians(polytope, rng, e, walk_len); std::cout << "Volume " << volume << std::endl; } int main() { - HPOLYTOPE HP = generate_simplex(2,false); - std::cout << "HPoly: " << std::endl; - HP.print(); - calculateAndVerifyVolume<4>(HP); - + HPOLYTOPE simplex = generate_simplex(2, false); + std::cout << std::endl << "Simplex: " << std::endl; + simplex.print(); + calculateAndVerifyVolume(simplex); + + HPOLYTOPE cube = generate_cube(3, false); + std::cout << std::endl << "Cube: " << std::endl; + cube.print(); + calculateAndVerifyVolume(cube); + + HPOLYTOPE cross = generate_cross(3, false); + std::cout << std::endl << "Cross: " << std::endl; + cross.print(); + calculateAndVerifyVolume(cross); + + HPOLYTOPE birkhoff = generate_birkhoff(3); + std::cout << std::endl << "Birkhoff: " << std::endl; + birkhoff.print(); + calculateAndVerifyVolume(birkhoff); + return 0; } \ No newline at end of file diff --git a/include/volume/volume_cooling_gaussians_crhmc.hpp b/include/volume/volume_cooling_gaussians_crhmc.hpp index 6a48f49fa..7c0984a48 100644 --- a/include/volume/volume_cooling_gaussians_crhmc.hpp +++ b/include/volume/volume_cooling_gaussians_crhmc.hpp @@ -15,6 +15,7 @@ #include "random_walks/gaussian_cdhr_walk.hpp" #include "sampling/random_point_generators.hpp" #include "volume/math_helpers.hpp" +#include "random_walks/random_walks.hpp" //new include for crhmc #include "Eigen/Eigen" @@ -53,28 +54,6 @@ using RNG = BoostRandomNumberGenerator; using Input = crhmc_input; using CrhmcProblem = crhmc_problem; - -/////////////////// Helpers for random walks - -template -struct update_delta -{ - template - static void apply(WalkType& walk, NT delta) {} -}; - -template -struct update_delta> -{ - template - static void apply(GaussianBallWalk::Walk walk, - NT delta) - { - walk.update_delta(delta); - } -}; - - ////////////////////////////// Algorithms // Gaussian Anealling @@ -298,11 +277,6 @@ void compute_annealing_schedule(Polytope& P, //create the walk object for this problem WalkType walk = WalkType(problem, p, input.df, input.f, params); - //TODO: test update delta here? - update_delta - ::apply(walk, 4.0 * chebychev_radius - / std::sqrt(std::max(NT(1.0), a_vals[it]) * NT(n))); - // Compute the next gaussian NT next_a = get_next_gaussian (P, p, a_vals[it], N, ratio, C, walk_length, rng, g, f, params, problem, walk); @@ -369,10 +343,10 @@ struct gaussian_annealing_parameters template < - typename WalkTypePolicy, typename Polytope, typename RandomNumberGenerator, - int simdLen + typename WalkTypePolicy = CRHMCWalk, + int simdLen = 8 > double volume_cooling_gaussians(Polytope& Pin, RandomNumberGenerator& rng, @@ -515,11 +489,6 @@ double volume_cooling_gaussians(Polytope& Pin, WalkType walk = WalkType(problem, p, input.df, input.f, params); - - update_delta - ::apply(walk, 4.0 * radius - / std::sqrt(std::max(NT(1.0), *avalsIt) * NT(n))); - while (!done || (*itsIt), - typename Polytope, - int simdLen -> -double volume_cooling_gaussians(Polytope &Pin, - double const& error = 0.1, - unsigned int const& walk_length = 1) -{ - RandomNumberGenerator rng(Pin.dimension()); - return volume_cooling_gaussians(Pin, rng, error, walk_length); -} - - -template -< - typename WalkTypePolicy = GaussianCDHRWalk, - typename RandomNumberGenerator = BoostRandomNumberGenerator, - typename Polytope, - int simdLen -> -double volume_cooling_gaussians(Polytope &Pin, - Cartesian::Point const& interior_point, - unsigned int const& walk_length = 1, - double const& error = 0.1) -{ - RandomNumberGenerator rng(Pin.dimension()); - Pin.set_interior_point(interior_point); - - return volume_cooling_gaussians(Pin, rng, error, walk_length); -} - #endif // VOLUME_COOLING_GAUSSIANS_HPP \ No newline at end of file