Skip to content

Commit 7c96708

Browse files
committed
Move mmcs functionality to include from examples
1 parent ef43e0d commit 7c96708

File tree

6 files changed

+217
-346
lines changed

6 files changed

+217
-346
lines changed

examples/mmcs_method/CMakeLists.txt

+5-7
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,11 @@ else ()
108108

109109
find_package(OpenMP REQUIRED)
110110

111-
add_executable (skinny_cube_10_dim skinny_cube_10_dim.cpp)
112-
add_executable (random_hpoly_50_dim random_hpoly_50_dim.cpp)
113-
add_executable (random_hpoly_50_dim_parallel random_hpoly_50_dim_parallel.cpp)
114-
115-
TARGET_LINK_LIBRARIES(skinny_cube_10_dim ${LP_SOLVE})
116-
TARGET_LINK_LIBRARIES(random_hpoly_50_dim ${LP_SOLVE})
117-
TARGET_LINK_LIBRARIES(random_hpoly_50_dim_parallel ${LP_SOLVE} OpenMP::OpenMP_CXX)
111+
add_executable (simple simple.cpp)
112+
add_executable (parallel parallel.cpp)
118113

114+
TARGET_LINK_LIBRARIES(simple ${LP_SOLVE})
115+
TARGET_LINK_LIBRARIES(parallel ${LP_SOLVE})
116+
TARGET_LINK_LIBRARIES(parallel ${LP_SOLVE} OpenMP::OpenMP_CXX)
119117

120118
endif()

examples/mmcs_method/random_hpoly_50_dim.cpp

-170
This file was deleted.

examples/mmcs_method/simple.cpp

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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

Comments
 (0)