Skip to content

Commit

Permalink
fix outdated example
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaperju committed Jul 19, 2024
1 parent c9e41d5 commit 288e422
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
16 changes: 6 additions & 10 deletions examples/sampling-hpolytope-with-billiard-walks/sampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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<Point> 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<MT>(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<MT, VT, NT> ellipsoid = compute_inscribed_ellipsoid<MT, EllipsoidType::VOLUMETRIC_BARRIER>
(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);
}
Expand Down
6 changes: 3 additions & 3 deletions include/random_walks/gaussian_accelerated_billiard_walk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{}

Expand Down
2 changes: 1 addition & 1 deletion include/sampling/random_point_generators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ struct MultivariateGaussianRandomPointGenerator
Walk walk(P, p, E, rng, parameters);
for (unsigned int i=0; i<rnum; ++i)
{
walk.template apply(P, p, E, walk_length, rng);
walk.template apply(P, p, walk_length, rng);
policy.apply(randPoints, p);
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/sampling_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ void call_test_ghmc(){
CHECK(score.maxCoeff() < 2.2);
}

template <typename NT, typename WalkType = GABW>
template <typename NT, typename WalkType = GaussianAcceleratedBilliardWalk>
void call_test_gabw(){
typedef Cartesian<NT> Kernel;
typedef typename Kernel::Point Point;
Expand All @@ -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
Expand Down

0 comments on commit 288e422

Please sign in to comment.