|
| 1 | +// VolEsti (volume computation and sampling library) |
| 2 | + |
| 3 | +// Copyright (c) 2012-2021 Vissarion Fisikopoulos |
| 4 | +// Copyright (c) 2018-2021 Apostolos Chalkis |
| 5 | + |
| 6 | +#include "Eigen/Eigen" |
| 7 | + |
| 8 | +#include <chrono> |
| 9 | +#include <boost/random.hpp> |
| 10 | +#include <boost/random/uniform_int.hpp> |
| 11 | +#include <boost/random/normal_distribution.hpp> |
| 12 | +#include <boost/random/uniform_real_distribution.hpp> |
| 13 | +#include "random_walks/random_walks.hpp" |
| 14 | +#include "volume/volume_sequence_of_balls.hpp" |
| 15 | +#include "volume/volume_cooling_gaussians.hpp" |
| 16 | +#include "sampling/mmcs.hpp" |
| 17 | +#include "generators/h_polytopes_generator.h" |
| 18 | +#include "generators/known_polytope_generators.h" |
| 19 | +#include "diagnostics/multivariate_psrf.hpp" |
| 20 | +#include "diagnostics/univariate_psrf.hpp" |
| 21 | +#include "diagnostics/ess_window_updater.hpp" |
| 22 | + |
| 23 | + |
| 24 | +template <typename NT> |
| 25 | +void run_main() |
| 26 | +{ |
| 27 | + typedef Cartesian<NT> Kernel; |
| 28 | + typedef boost::mt19937 PolyRNGType; |
| 29 | + typedef typename Kernel::Point Point; |
| 30 | + typedef HPolytope <Point> Hpolytope; |
| 31 | + typedef Eigen::Matrix<NT,Eigen::Dynamic,1> VT; |
| 32 | + typedef Eigen::Matrix<NT,Eigen::Dynamic,Eigen::Dynamic> MT; |
| 33 | + |
| 34 | + { |
| 35 | + int n = 50; |
| 36 | + Hpolytope P = random_hpoly<Hpolytope, PolyRNGType>(n, 4*n, 127); // we fix the example polytope, seed = 127 |
| 37 | + |
| 38 | + MT S; |
| 39 | + int total_neff; |
| 40 | + mmcs(P, 400, S, total_neff); |
| 41 | + |
| 42 | + std::cerr << "sum of effective sample sizes: " << total_neff << std::endl; |
| 43 | + std::cerr << "multivariate PSRF: " << multivariate_psrf<NT, VT>(S) << std::endl; |
| 44 | + std::cerr << "maximum marginal PSRF: " << univariate_psrf<NT, VT>(S).maxCoeff() << std::endl; |
| 45 | + } |
| 46 | + { |
| 47 | + int n = 10; |
| 48 | + Hpolytope P = generate_skinny_cube<Hpolytope>(n, false); |
| 49 | + |
| 50 | + MT S; |
| 51 | + int total_neff; |
| 52 | + mmcs(P, 1000, S, total_neff); |
| 53 | + |
| 54 | + std::cerr << "sum of effective sample sizes: " << total_neff << std::endl; |
| 55 | + std::cerr << "multivariate PSRF: " << multivariate_psrf<NT, VT>(S) << std::endl; |
| 56 | + std::cerr << "maximum marginal PSRF: " << univariate_psrf<NT, VT>(S).maxCoeff() << std::endl; |
| 57 | + } |
| 58 | +} |
| 59 | + |
| 60 | +int main() { |
| 61 | + run_main<double>(); |
| 62 | + return 0; |
| 63 | +} |
0 commit comments