This is the official Matlab code for the paper "Unbiased constrained sampling with Self-Concordant Barrier Hamiltonian Monte Carlo", based on the implementation of CRHMC [1] available at https://github.com/ConstrainedSampler/PolytopeSamplerMatlab.
[1] "Sampling with riemannian hamiltonian monte carlo in a constrained space", Kook et al., NEURIPS 2022
Instances
: this folder includes constrained-based models from systems biology and LP test sets in0raw
folder. RunningpreparePolytope.m
prepares instances for each algorithm -- it preprocesses constrained-based models by a presolver in the CRHMC package, transforms them into full-dimensional instances, and then round the full-dimensional ones by the maximum volume ellipsoid (MVE) algorithm.BHMC-test
:testpaper_bhmc.m
andtestpaper_rhmc.m
run BHMC and CRHMC respectively on the instances and stores result mat files inbhmc_test
andrhmc_test
subfolders.CHRR-test
: this folder contains CHRR files downloaded from Bounciness/Volume-and-Sampling repository. It is needed for some auxiliary functions.PolytopeSamplerMatlab-develop
: this folder contains the implementation of BHMC and CRHMC. There are two strategies to choose the step size. The one that target an acceptance ratio of 0.5. The functions in the subfoldercode
implementing this strategy aresample_modif.m
andsample_GL.m
. The second one is based on the module in the orignal code. The functions implementing this strategy aresample.m
andsample_GL_v2.m
.Benchmark
:main_run_benchmark.m
runs BHMC and CRHMC on the examples of target distributions described in the paper. The results are stored mat files in subfolders. To plot the boxplots use the scriptplot_bias_boxplot.m
.testpaper_plot.m
: based on sampling results from the bio and LP dataset, it draws plots for sampling time and mixing rate versus dimension and the number of nonzeros. It also displays the sampling time per effective sample.
Run main_run_benchmark.m
in the folder Benchmark
The results are stored mat files in the subfolder bias_analysis_local
that you should create if it does not exist. To plot the boxplots use the script plot_bias_boxplot.m
in the same folder.
You should first create two empty subfolders 1chrr
and 2cdhr
under Instances
folder. Then simply run preparePolytope.m
to prepare rounded instances for CHRR and CDHR.
All algorithms are limited in their implementation to one core for fair comparison.
Run testpaper_rhmc.m
and testpaper_bhmc.m
in the folder BHMC-test
Plot the result using the function testpaper_plot.m
If you use this code, please cite the following (BibTex format):
@article{noble2024unbiased,
title={Unbiased constrained sampling with Self-Concordant Barrier Hamiltonian Monte Carlo},
author={Noble, Maxence and De Bortoli, Valentin and Durmus, Alain},
journal={Advances in Neural Information Processing Systems},
volume={36},
year={2024}
}