Skip to content

Commit

Permalink
Now the methods in hmc_sampling.h take the Point starting_point directly
Browse files Browse the repository at this point in the history
  • Loading branch information
guillexm committed Aug 28, 2023
1 parent 9f08924 commit 28a1de6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 29 deletions.
4 changes: 2 additions & 2 deletions dingo/bindings/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ double HPolytopeCPP::apply_sampling(int walk_len,
exponential_sampling<ExponentialHamiltonianMonteCarloExactWalk>(rand_points, HP, rng, walk_len, number_of_points, bias_vector, variance,
starting_point, number_of_points_to_burn);
} else if (method == 10) { // HMC with Gaussian distribution
rand_points = hmc_leapfrog_gaussian<Hpolytope>(walk_len, number_of_points, number_of_points_to_burn, samples, variance, bias_vector_, inner_point, radius, HP);
rand_points = hmc_leapfrog_gaussian<Hpolytope>(walk_len, number_of_points, number_of_points_to_burn, samples, variance, bias_vector_, starting_point, HP);
} else if (method == 11) { // HMC with exponential distribution
rand_points = hmc_leapfrog_exponential<Hpolytope>(walk_len, number_of_points, number_of_points_to_burn, samples, variance, bias_vector_, inner_point, radius, HP);
rand_points = hmc_leapfrog_exponential<Hpolytope>(walk_len, number_of_points, number_of_points_to_burn, samples, variance, bias_vector_, starting_point, HP);
}
else {
throw std::runtime_error("This function must not be called.");
Expand Down
29 changes: 2 additions & 27 deletions dingo/bindings/hmc_sampling.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,9 @@ template<class Polytope> list<Point> hmc_leapfrog_gaussian(int walk_len,
double* samples,
double variance,
double* bias_vector_,
double* inner_point,
double radius,
Point starting_point,
Polytope HP) {

int d = HP.dimension();
Point starting_point;
VT inner_vec(d);

for (int i = 0; i < d; i++){
inner_vec(i) = inner_point[i];
}

Point inner_point2(inner_vec);
CheBall = std::pair<Point, NT>(inner_point2, radius);
HP.set_InnerBall(CheBall);
starting_point = inner_point2;

std::list<Point> rand_points;
typedef GaussianFunctor::GradientFunctor<Point> NegativeGradientFunctor;
Expand Down Expand Up @@ -65,21 +52,9 @@ template<class Polytope> list<Point> hmc_leapfrog_exponential(int walk_len,
double* samples,
double variance,
double* bias_vector_,
double* inner_point,
double radius,
Point starting_point,
Polytope HP) {

Point starting_point;
VT inner_vec(d);

for (int i = 0; i < d; i++){
inner_vec(i) = inner_point[i];
}

Point inner_point2(inner_vec);
CheBall = std::pair<Point, NT>(inner_point2, radius);
HP.set_InnerBall(CheBall);
starting_point = inner_point2;
std::list<Point> rand_points;
typedef ExponentialFunctor::GradientFunctor<Point> NegativeGradientFunctor;
typedef ExponentialFunctor::FunctionFunctor<Point> NegativeLogprobFunctor;
Expand Down

0 comments on commit 28a1de6

Please sign in to comment.