From 288e42231240c280a100a3c5aecbd3ff74888916 Mon Sep 17 00:00:00 2001 From: lucaperju Date: Fri, 19 Jul 2024 20:00:29 +0200 Subject: [PATCH] fix outdated example --- .../sampler.cpp | 16 ++++++---------- .../gaussian_accelerated_billiard_walk.hpp | 6 +++--- include/sampling/random_point_generators.hpp | 2 +- test/sampling_test.cpp | 4 ++-- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/examples/sampling-hpolytope-with-billiard-walks/sampler.cpp b/examples/sampling-hpolytope-with-billiard-walks/sampler.cpp index 803d38dc3..efdc4a664 100644 --- a/examples/sampling-hpolytope-with-billiard-walks/sampler.cpp +++ b/examples/sampling-hpolytope-with-billiard-walks/sampler.cpp @@ -7,6 +7,7 @@ #include "sampling/random_point_generators.hpp" #include "random_walks/random_walks.hpp" #include "preprocess/max_inscribed_ellipsoid.hpp" +#include "preprocess/inscribed_ellipsoid_rounding.hpp" #include "convex_bodies/ellipsoid.h" #include "convex_bodies/hpolytope.h" @@ -69,23 +70,18 @@ void sample_using_gaussian_billiard_walk(HPOLYTOPE& HP, RNGType& rng, unsigned i Point q(HP.dimension()); // origin // ----------- Get inscribed ellipsoid -------------------------------- - typedef Ellipsoid EllipsoidType; unsigned int max_iter = 150; NT tol = std::pow(10, -6.0), reg = std::pow(10, -4.0); VT x0 = q.getCoefficients(); - MT E; VT center; bool converged; - std::tie(E, center, converged) = max_inscribed_ellipsoid(HP.get_mat(), - HP.get_vec(), x0, max_iter, tol, reg); - - if (!converged) // not converged - throw std::runtime_error("max_inscribed_ellipsoid not converged"); - - EllipsoidType inscribed_ellipsoid(E); + std::tuple ellipsoid = compute_inscribed_ellipsoid + (HP.get_mat(), HP.get_vec(), x0, max_iter, tol, reg); + + const MT E = get<0>(ellipsoid); // -------------------------------------------------------------------- - Generator::apply(HP, q, inscribed_ellipsoid, num_points, walk_len, + Generator::apply(HP, q, E, num_points, walk_len, randPoints, push_back_policy, rng); write_to_file(filename, randPoints); } diff --git a/include/random_walks/gaussian_accelerated_billiard_walk.hpp b/include/random_walks/gaussian_accelerated_billiard_walk.hpp index d50cb7e5f..ea059305a 100644 --- a/include/random_walks/gaussian_accelerated_billiard_walk.hpp +++ b/include/random_walks/gaussian_accelerated_billiard_walk.hpp @@ -25,13 +25,13 @@ #include "random_walks/compute_diameter.hpp" -struct GABW +struct GaussianAcceleratedBilliardWalk { - GABW(double L) + GaussianAcceleratedBilliardWalk(double L) : param(L, true) {} - GABW() + GaussianAcceleratedBilliardWalk() : param(0, false) {} diff --git a/include/sampling/random_point_generators.hpp b/include/sampling/random_point_generators.hpp index e38f50cac..e60181969 100644 --- a/include/sampling/random_point_generators.hpp +++ b/include/sampling/random_point_generators.hpp @@ -95,7 +95,7 @@ struct MultivariateGaussianRandomPointGenerator Walk walk(P, p, E, rng, parameters); for (unsigned int i=0; i +template void call_test_gabw(){ typedef Cartesian Kernel; typedef typename Kernel::Point Point; @@ -325,7 +325,7 @@ void call_test_gabw(){ Point p = P.ComputeInnerBall().first; - typedef typename GABW::template Walk + typedef typename GaussianAcceleratedBilliardWalk::template Walk < Hpolytope, RNGType