Skip to content
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

Exact Hamiltonian Monte Carlo for spherical Gaussian sampling #144

Merged
merged 57 commits into from
Oct 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
3ef71df
implmentation of exact hmc walk
TolisChal Mar 6, 2021
932e2ae
implementation of boundary oracles for the hpolytope
TolisChal Mar 6, 2021
be84adc
add fake boundary oracles for the other polytope representations
TolisChal Mar 6, 2021
855f2af
implement c++ interface for exponential sampling
TolisChal Mar 6, 2021
462d132
improve boundary oracles and fix bugs
TolisChal Mar 6, 2021
da09805
add root finder for the degree two polynomial
TolisChal Mar 7, 2021
040efa6
complete the root computation and the failure check
TolisChal Mar 7, 2021
127d371
initial implementation of the random walk
TolisChal Mar 7, 2021
279d99c
Merge branch 'hmc_exponential' into exponential_leapfrog
TolisChal Mar 7, 2021
8e36064
improve R documentation and resolve gcc compile error
TolisChal Mar 7, 2021
436a780
improve R documentation
TolisChal Mar 7, 2021
91d0235
Merge branch 'hmc_exponential' into exponential_leapfrog
TolisChal Mar 7, 2021
1ba240e
initial implementation of hmc-leapfrog
TolisChal Mar 7, 2021
89b6fbb
add the new walk to the R interface
TolisChal Mar 8, 2021
ca6db1b
implement the C++ interface for the new walk
TolisChal Mar 8, 2021
cdc6572
fix compile and algorithmic errors
TolisChal Mar 8, 2021
e93270b
improve R documentation
TolisChal Mar 8, 2021
e9e2e08
improve comments and R interface
TolisChal Mar 8, 2021
1ab3362
initial implementation of the Exact HMC for gaussian dist.
TolisChal Mar 8, 2021
b9cf981
add the new walk to C++ and R interfaces
TolisChal Mar 8, 2021
2f01b3d
implement boundary oracle
TolisChal Mar 8, 2021
3140e11
improve boundary oracle for exact hmc for gaussian sampling
TolisChal Mar 8, 2021
3e3345a
remove test R script
TolisChal Mar 8, 2021
983a715
Merge branch 'exponential_leapfrog' into gaussian_exact_hmc
TolisChal Mar 8, 2021
eb9dab8
resolve PR reviews
TolisChal Mar 9, 2021
d1e9acf
fix compile errors
TolisChal Mar 9, 2021
f1e362a
Merge branch 'develop' into hmc_exponential
TolisChal Mar 11, 2021
b982f13
merge develop branch
TolisChal Mar 11, 2021
9c7735a
add burn in methods in exact hmc
TolisChal Mar 11, 2021
0b9f8ad
merge exponential exact hmc and update with burn in methods
TolisChal Mar 11, 2021
0de37ee
delete white space in new gaussian hmc hpp file
TolisChal Mar 11, 2021
434de2f
resolve the reviews on the root computation
TolisChal Mar 12, 2021
ed4a92b
resolve review on the header names
TolisChal Mar 12, 2021
3d15a1c
Merge branch 'hmc_exponential' into gaussian_exact_hmc
TolisChal Mar 12, 2021
1ac29c9
improve definition of macro RVOLESTI
TolisChal Mar 13, 2021
de8b3e0
add an example to sample from exponential exact HMC
TolisChal Mar 13, 2021
2a20238
merge exponential_exact_hmc
TolisChal Mar 13, 2021
6d3c481
add a c++ example from the gaussian exact HMC
TolisChal Mar 13, 2021
3442f5a
remove RVOLESTI macro
TolisChal Mar 19, 2021
60ed2bd
declare tol variable as static
TolisChal Mar 19, 2021
167b88c
Merge branch 'hmc_exponential' into gaussian_exact_hmc
TolisChal Mar 19, 2021
dff0c43
fix bug in variable declaration
TolisChal Mar 19, 2021
0b91d9e
Merge branch 'hmc_exponential' into gaussian_exact_hmc
TolisChal Mar 19, 2021
93d0658
change tolerance variable declaration
TolisChal Mar 19, 2021
df86aa5
Merge branch 'hmc_exponential' into gaussian_exact_hmc
TolisChal Mar 19, 2021
29dfc59
Merge branch 'develop' into hmc_exponential
TolisChal Mar 21, 2021
a64542c
Merge branch 'hmc_exponential' into gaussian_exact_hmc
TolisChal Mar 21, 2021
dc1a67d
set upper bound for the number of relfections
TolisChal Mar 23, 2021
4669199
Merge branch 'hmc_exponential' into gaussian_exact_hmc
TolisChal Mar 23, 2021
582acef
set upper bound for the number of relfections
TolisChal Mar 23, 2021
7bb8617
change the name of TOL to IN_INSIDE_BODY_TOLLERANCE
TolisChal Mar 23, 2021
d7a7495
Merge branch 'hmc_exponential' into gaussian_exact_hmc
TolisChal Mar 23, 2021
0b6a612
merge develop
TolisChal Oct 1, 2021
b63d6db
remove VOLESTIPY macro
TolisChal Oct 1, 2021
0aa906b
resolve PR comments
TolisChal Oct 1, 2021
e98ab8b
fix c++ bugs
TolisChal Oct 1, 2021
dc28129
resolve PR's comments
TolisChal Oct 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions R-proj/R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -313,24 +313,25 @@ rounding <- function(P, method = NULL, seed = NULL) {
#' @param n The number of points that the function is going to sample from the convex polytope.
#' @param random_walk Optional. A list that declares the random walk and some related parameters as follows:
#' \itemize{
#' \item{\code{walk} }{ A string to declare the random walk: i) \code{'CDHR'} for Coordinate Directions Hit-and-Run, ii) \code{'RDHR'} for Random Directions Hit-and-Run, iii) \code{'BaW'} for Ball Walk, iv) \code{'BiW'} for Billiard walk, v) \code{'dikin'} for dikin walk, vi) \code{'vaidya'} for vaidya walk, vii) \code{'john'} for john walk, viii) \code{'BCDHR'} boundary sampling by keeping the extreme points of CDHR or ix) \code{'BRDHR'} boundary sampling by keeping the extreme points of RDHR x) \code{'HMC'} for Hamiltonian Monte Carlo (logconcave) xi) \code{'ULD'} for Underdamped Langevin Dynamics using the Randomized Midpoint Method. The default walk is \code{'aBiW'} for the uniform distribution or \code{'CDHR'} for the Gaussian distribution and H-polytopes and \code{'BiW'} or \code{'RDHR'} for the same distributions and V-polytopes and zonotopes.}
#' \item{\code{walk} }{ A string to declare the random walk: i) \code{'CDHR'} for Coordinate Directions Hit-and-Run, ii) \code{'RDHR'} for Random Directions Hit-and-Run, iii) \code{'BaW'} for Ball Walk, iv) \code{'BiW'} for Billiard walk, v) \code{'dikin'} for dikin walk, vi) \code{'vaidya'} for vaidya walk, vii) \code{'john'} for john walk, viii) \code{'BCDHR'} boundary sampling by keeping the extreme points of CDHR or ix) \code{'BRDHR'} boundary sampling by keeping the extreme points of RDHR x) \code{'HMC'} for Hamiltonian Monte Carlo (logconcave densities) xi) \code{'ULD'} for Underdamped Langevin Dynamics using the Randomized Midpoint Method xii) \code{'ExactHMC'} for exact Hamiltonian Monte Carlo with reflections (spherical Gaussian or exponential distribution). The default walk is \code{'aBiW'} for the uniform distribution or \code{'CDHR'} for the Gaussian distribution and H-polytopes and \code{'BiW'} or \code{'RDHR'} for the same distributions and V-polytopes and zonotopes.}
#' \item{\code{walk_length} }{ The number of the steps per generated point for the random walk. The default value is \eqn{1}.}
#' \item{\code{nburns} }{ The number of points to burn before start sampling. The default value is \eqn{1}.}
#' \item{\code{starting_point} }{ A \eqn{d}-dimensional numerical vector that declares a starting point in the interior of the polytope for the random walk. The default choice is the center of the ball as that one computed by the function \code{inner_ball()}.}
#' \item{\code{BaW_rad} }{ The radius for the ball walk.}
#' \item{\code{L} }{ The maximum length of the billiard trajectory or the radius for the step of dikin, vaidya or john walk.}
#' \item{\code{solver}} {Specify ODE solver for logconcave sampling. Options are i) leapfrog, ii) euler iii) runge-kutta iv) richardson}
#' \item{\code{step_size} {Optionally chosen step size for logconcave sampling. Defaults to a theoretical value if not provided.}}
#' \item{\code{solver} }{ Specify ODE solver for logconcave sampling. Options are i) leapfrog, ii) euler iii) runge-kutta iv) richardson}
#' \item{\code{step_size }{ Optionally chosen step size for logconcave sampling. Defaults to a theoretical value if not provided.}
#' }
#' @param distribution Optional. A list that declares the target density and some related parameters as follows:
#' \itemize{
#' \item{\code{density} }{ A string: (a) \code{'uniform'} for the uniform distribution or b) \code{'gaussian'} for the multidimensional spherical distribution. The default target distribution is uniform. c) Logconcave with form proportional to exp(-f(x)) where f(x) is L-smooth and m-strongly-convex. }
#' \item{\code{variance} }{ The variance of the multidimensional spherical gaussian. The default value is 1.}
#' \item{\code{density} }{ A string: (a) \code{'uniform'} for the uniform distribution or b) \code{'gaussian'} for the multidimensional spherical distribution c) \code{logconcave} with form proportional to exp(-f(x)) where f(x) is L-smooth and m-strongly-convex d) \code{'exponential'} for the exponential distribution. The default target distribution is the uniform distribution.}
#' \item{\code{variance} }{ The variance of the multidimensional spherical gaussian or the exponential distribution. The default value is 1.}
#' \item{\code{mode} }{ A \eqn{d}-dimensional numerical vector that declares the mode of the Gaussian distribution. The default choice is the center of the as that one computed by the function \code{inner_ball()}.}
#' \item{\code{L_}} { Smoothness constant (for logconcave). }
#' \item{\code{m}} { Strong-convexity constant (for logconcave). }
#' \item{\code{negative_logprob}} { Negative log-probability (for logconcave). }
#' \item{\code{negative_logprob_gradient}} { Negative log-probability gradient (for logconcave). }
#' \item{\code{bias} }{ The bias vector for the exponential distribution. The default vector is \eqn{c_1 = 1} and \eqn{c_i = 0} for \eqn{i \neq 1}.}
#' \item{\code{L_} }{ Smoothness constant (for logconcave). }
#' \item{\code{m} }{ Strong-convexity constant (for logconcave). }
#' \item{\code{negative_logprob} }{ Negative log-probability (for logconcave). }
#' \item{\code{negative_logprob_gradient} }{ Negative log-probability gradient (for logconcave). }
#' }
#' @param seed Optional. A fixed seed for the number generator.
#'
Expand All @@ -349,6 +350,9 @@ rounding <- function(P, method = NULL, seed = NULL) {
#' @references \cite{Shen, Ruoqi, and Yin Tat Lee,
#' \dQuote{"The randomized midpoint method for log-concave sampling.",} \emph{Advances in Neural Information Processing Systems}, 2019.}
#'
#' @references \cite{Augustin Chevallier, Sylvain Pion, Frederic Cazals,
#' \dQuote{"Hamiltonian Monte Carlo with boundary reflections, and application to polytope volume calculations,"} \emph{Research Report preprint hal-01919855}, 2018.}
#'
#' @return A \eqn{d\times n} matrix that contains, column-wise, the sampled points from the convex polytope P.
#' @examples
#' # uniform distribution from the 3d unit cube in H-representation using ball walk
Expand Down
1 change: 1 addition & 0 deletions R-proj/src/copula.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

//Contributed and/or modified by Apostolos Chalkis, as part of Google Summer of Code 2018 program.


#include <Rcpp.h>
#include <RcppEigen.h>
#include <chrono>
Expand Down
1 change: 1 addition & 0 deletions R-proj/src/direct_sampling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

//Contributed and/or modified by Apostolos Chalkis, as part of Google Summer of Code 2018 and 2019 program.


#include <Rcpp.h>
#include <RcppEigen.h>
#include <chrono>
Expand Down
1 change: 1 addition & 0 deletions R-proj/src/exact_vol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Copyright (c) 2012-2019 Vissarion Fisikopoulos
// Copyright (c) 2018-2019 Apostolos Chalkis


#include <Rcpp.h>
#include <RcppEigen.h>
#include <chrono>
Expand Down
1 change: 1 addition & 0 deletions R-proj/src/get_full_dimensional_polytope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

//Contributed and/or modified by Alexandros Manochis, as part of Google Summer of Code 2020 program.


#include <Rcpp.h>
#include <RcppEigen.h>
#include <chrono>
Expand Down
1 change: 1 addition & 0 deletions R-proj/src/geweke.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

//Contributed and/or modified by Alexandros Manochis, as part of Google Summer of Code 2020 program.


#include <Rcpp.h>
#include <RcppEigen.h>
#include <chrono>
Expand Down
1 change: 1 addition & 0 deletions R-proj/src/ode_solve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

//Contributed and/or modified by Marios Papachristou, as part of Google Summer of Code 2018 and 2019 program.


#include <Rcpp.h>
#include <RcppEigen.h>
#include <chrono>
Expand Down
1 change: 1 addition & 0 deletions R-proj/src/poly_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

//Contributed and/or modified by Apostolos Chalkis, as part of Google Summer of Code 2018 program.


#include <Rcpp.h>
#include <RcppEigen.h>
#include <chrono>
Expand Down
1 change: 1 addition & 0 deletions R-proj/src/polytopes_modules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Copyright (c) 2012-2019 Vissarion Fisikopoulos
// Copyright (c) 2018-2019 Apostolos Chalkis


#include <Rcpp.h>


Expand Down
1 change: 1 addition & 0 deletions R-proj/src/psrf_multivariate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

//Contributed and/or modified by Alexandros Manochis, as part of Google Summer of Code 2020 program.


#include <Rcpp.h>
#include <RcppEigen.h>
#include <chrono>
Expand Down
1 change: 1 addition & 0 deletions R-proj/src/psrf_univariate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

//Contributed and/or modified by Alexandros Manochis, as part of Google Summer of Code 2020 program.


#include <Rcpp.h>
#include <RcppEigen.h>
#include <chrono>
Expand Down
1 change: 1 addition & 0 deletions R-proj/src/raftery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

//Contributed and/or modified by Alexandros Manochis, as part of Google Summer of Code 2020 program.


#include <Rcpp.h>
#include <RcppEigen.h>
#include <chrono>
Expand Down
1 change: 1 addition & 0 deletions R-proj/src/rotating.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

//Contributed and/or modified by Apostolos Chalkis, as part of Google Summer of Code 2018 program.


#include <Rcpp.h>
#include <RcppEigen.h>
#include <chrono>
Expand Down
1 change: 1 addition & 0 deletions R-proj/src/rounding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//Contributed and/or modified by Apostolos Chalkis, as part of Google Summer of Code 2018 program.
//Contributed and/or modified by Alexandros Manochis, as part of Google Summer of Code 2020 program.


#include <Rcpp.h>
#include <RcppEigen.h>
#include <chrono>
Expand Down
Loading