-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HMC random walks #38
HMC random walks #38
Conversation
…o compute the first point of the CDHR and not to test in every step if this is the first point. We initialize min_plus to max double value and max_min to min double value to avoid checking in every iteration if they are seted for the first time. We add comments in Polytope class and we remove useles comments from samplers.h header file.
… type in volume.h header file and in vol.cpp file. We have to use template number type in nikolic implementation in order to use different number type than double. Pass all the test locally.
… irrespective of the number type we use for the implementaion. We can use float or long double. We made adjustments in tests cpp files in order to use the template number type. We pass all the tests for both double and float.
… declared in volume.h. Now we can use float or long double in Rcpp interface as well.
Use eigen matrix for the H-polytope representation. Able to use float or long double.
… in order to sample the first point for the coordinate directions HnR. Make adjustments in get_annealing_schedule() and in volume_gaussian_annealing() for the first point coordinate case.
…he ratios in gaussian_annealing_volume. Use const bool for the computation of the first coord point.
…e class point_on_Dsphere. We move functions point_in_Dsphere, point_on_Dsphere from gaussian_samplers.h to samplers.h and implement function get_direction() to avoid duplicated code. We use these functions for RDHR and Gausian Ball Walk and first random point in convex polytope.
…r max nuber of iterations and tolerance in gaussian_samplers.h and gaussian_annealing.h header files.
…an(), we have moved the output arguments at the end of the argument list. We change all not returning functions to void in gaussian_annealing.h and in gaussian_samplers.h. We add comments for the variable k in get_next_gaussian and iterators for the fn vector. We have renamed its to iterators. We change rand_exp_range_coord() to return a double.
…positions and values of the window W.
… Add to Rcpp interface the choice to run CV algo.
…for the CV algo. The new pdf is in doc folder.
…for CV algo in volumeCV_test.cpp. We have passed succesfully the test locally
…t_coord_point() to compute first gaussian point, overriding is not needed.
… set error=0.2 and number of experiments=20 in the CV volume test. We passed the test succesfully locally.
…ith eigen matrix in Vpolytope class. Use template number type in VPolytope class.
…tope by a point c. Create function linear_transformIt() for both H and V polytopes, to apply a linear transformation to the polytope. We use these functions to the main rounding functionin order to use the latter for Vpolytopes as well. We replace all the shiftings in CV algorithm with the function shift().
…turns the distances between the chebychev center and the facets. In Vpolytope it computes an upper bound for the number of facets (number of d-1-faces of the cyclic polytope) and for each facet returns the radius of the chebychev ball as lower bound for the distance, so we can compute an upper bound for the a_0 of the first gaussian. CV algo can now be used for the volume approximation of v polytopes.We add boolean deltaset to var_g to be able to set the radius of the ball walk when the a_i changes (that was a bug that is fixed).
…olytope returns false and V polytope returns its vertices if num_of_vertices<20*dimension. We modified rotating() function to use linear_transformIt() polytope's function, now we can rotate a V polytope as well.
…lytope classes. We remove Init(int d) and constructor with argument int d in V polytope. We create upper_bound_of_hyperplanes in V polytope class. We change input and output number type to NT in factorial function, because of overflow.
…g double. In main file we have to incluse the disearable header file. Fix some bugs for the template number types in vol.cpp and in struct var_g in volume.h. We define const boolean using_float because we use it in get_first_gaussian() function, to guarantee convergence: If float is used we set tol=1e-06 otherwise we set it 1e-07.
… with long double.
…end of solve_LP() function that computes the chebychev center of a H-polytope. We add some comments in samplers.h and use NT number type where it is not able to use a tamplate.
…ve to give the path to the ext file and a flag Vpoly=TRUE.
…rtices of a V-polytope as an input. Remove variable telescopic product from volesti and set initial volume equl to the volume of the chebychev ball to avoid overflow in some cases (in each iteration we multiply vol with the current ratio).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR, it seems that (at least some versions of) the new random walks are very promising. However, the code needs more work, so looking forward to your feedback. Please explain for which walks you add an R interface and why. Also you say the new volume algorithm is faster, please include here few simple runs for illustration. Finally, tests and docs and comments on the code regarding references of the implemented algorithms.
@@ -10,6 +10,7 @@ | |||
#include <Rcpp.h> | |||
#include <RcppEigen.h> | |||
#include <chrono> | |||
#define VOLESTI_DEBUG |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be removed?
@@ -101,7 +104,8 @@ Rcpp::NumericMatrix sample_points(Rcpp::Nullable<Rcpp::Reference> P = R_NilValue | |||
|
|||
int type, dim, numpoints; | |||
NT radius = 1.0, delta = -1.0; | |||
bool set_mean_point = false, cdhr = true, rdhr = false, ball_walk = false, gaussian = false; | |||
bool set_mean_point = false, cdhr = false, rdhr = false, ball_walk = false, gaussian = false, gibbs = false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to other PR's please change this to use enums
instead of many bool
vars.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see e.g. #39
rdhr = true; | ||
ball_walk = false; | ||
} else if (Rcpp::as<std::string>(WalkType).compare(std::string("HMC"))==0) { | ||
if (type != 1) throw Rcpp::exception("HMC can be applies only to H-polytopes!"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"can be applied ..."
@@ -239,6 +248,7 @@ Rcpp::NumericMatrix sample_points(Rcpp::Nullable<Rcpp::Reference> P = R_NilValue | |||
InnerBall = HP.ComputeInnerBall(); | |||
if (!set_mean_point) MeanPoint = InnerBall.first; | |||
} | |||
//if (hmc_barrier && !gaussian) a = 1.0/NT(Rcpp::as<MT>(Rcpp::as<Rcpp::Reference>(P).field("A")).rows()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this needed?
include/convex_bodies/polytopes.h
Outdated
@@ -419,6 +419,7 @@ class HPolytope{ | |||
bool get_points_for_rounding (T &randPoints) { | |||
return false; | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are those new lines needed or made by mistake by some IDE?
include/samplers/gaussian_samplers.h
Outdated
@@ -327,4 +346,47 @@ void gaussian_ball_walk(Point &p, | |||
} | |||
} | |||
|
|||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this needed?
include/samplers/hmc_heur_sam.h
Outdated
@@ -0,0 +1,112 @@ | |||
// VolEsti (volume computation and sampling library) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose to use a less cryptic name for the file i.e. sampler instead of sam, what is heur stands for?
include/samplers/hmc_refl.h
Outdated
@@ -0,0 +1,164 @@ | |||
// VolEsti (volume computation and sampling library) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filename, hmc_reflections.h
?
include/samplers/hmc_refl.h
Outdated
|
||
// Licensed under GNU LGPL.3, see LICENCE file | ||
|
||
#ifndef HMC_REFL_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also please update those wrt the filename
include/samplers/hmc_rk4.h
Outdated
@@ -0,0 +1,167 @@ | |||
// VolEsti (volume computation and sampling library) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filename. rk4
?!
e4ac563
to
ca784f5
Compare
This PR contains:
Implementations of HMC random walk when the hamiltonian is the logbarrier function of the polytope. We have 4 different implementation of the same random walk.
Implementation of the HMC random walk with reflections when the hamiltonian is the spherical Gaussian distribution. We use this walk to CG volume computation method yielding a faster method for H-polytopes