Skip to content

Commit

Permalink
Move mmcs functionality to include from examples
Browse files Browse the repository at this point in the history
  • Loading branch information
akisschinas committed Oct 15, 2024
1 parent ef43e0d commit 7c96708
Show file tree
Hide file tree
Showing 6 changed files with 217 additions and 346 deletions.
12 changes: 5 additions & 7 deletions examples/mmcs_method/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,11 @@ else ()

find_package(OpenMP REQUIRED)

add_executable (skinny_cube_10_dim skinny_cube_10_dim.cpp)
add_executable (random_hpoly_50_dim random_hpoly_50_dim.cpp)
add_executable (random_hpoly_50_dim_parallel random_hpoly_50_dim_parallel.cpp)

TARGET_LINK_LIBRARIES(skinny_cube_10_dim ${LP_SOLVE})
TARGET_LINK_LIBRARIES(random_hpoly_50_dim ${LP_SOLVE})
TARGET_LINK_LIBRARIES(random_hpoly_50_dim_parallel ${LP_SOLVE} OpenMP::OpenMP_CXX)
add_executable (simple simple.cpp)
add_executable (parallel parallel.cpp)

TARGET_LINK_LIBRARIES(simple ${LP_SOLVE})
TARGET_LINK_LIBRARIES(parallel ${LP_SOLVE})
TARGET_LINK_LIBRARIES(parallel ${LP_SOLVE} OpenMP::OpenMP_CXX)

endif()
File renamed without changes.
170 changes: 0 additions & 170 deletions examples/mmcs_method/random_hpoly_50_dim.cpp

This file was deleted.

63 changes: 63 additions & 0 deletions examples/mmcs_method/simple.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// VolEsti (volume computation and sampling library)

// Copyright (c) 2012-2021 Vissarion Fisikopoulos
// Copyright (c) 2018-2021 Apostolos Chalkis

#include "Eigen/Eigen"

#include <chrono>
#include <boost/random.hpp>
#include <boost/random/uniform_int.hpp>
#include <boost/random/normal_distribution.hpp>
#include <boost/random/uniform_real_distribution.hpp>
#include "random_walks/random_walks.hpp"
#include "volume/volume_sequence_of_balls.hpp"
#include "volume/volume_cooling_gaussians.hpp"
#include "sampling/mmcs.hpp"
#include "generators/h_polytopes_generator.h"
#include "generators/known_polytope_generators.h"
#include "diagnostics/multivariate_psrf.hpp"
#include "diagnostics/univariate_psrf.hpp"
#include "diagnostics/ess_window_updater.hpp"


template <typename NT>
void run_main()
{
typedef Cartesian<NT> Kernel;
typedef boost::mt19937 PolyRNGType;
typedef typename Kernel::Point Point;
typedef HPolytope <Point> Hpolytope;
typedef Eigen::Matrix<NT,Eigen::Dynamic,1> VT;
typedef Eigen::Matrix<NT,Eigen::Dynamic,Eigen::Dynamic> MT;

{
int n = 50;
Hpolytope P = random_hpoly<Hpolytope, PolyRNGType>(n, 4*n, 127); // we fix the example polytope, seed = 127

MT S;
int total_neff;
mmcs(P, 400, S, total_neff);

std::cerr << "sum of effective sample sizes: " << total_neff << std::endl;
std::cerr << "multivariate PSRF: " << multivariate_psrf<NT, VT>(S) << std::endl;
std::cerr << "maximum marginal PSRF: " << univariate_psrf<NT, VT>(S).maxCoeff() << std::endl;
}
{
int n = 10;
Hpolytope P = generate_skinny_cube<Hpolytope>(n, false);

MT S;
int total_neff;
mmcs(P, 1000, S, total_neff);

std::cerr << "sum of effective sample sizes: " << total_neff << std::endl;
std::cerr << "multivariate PSRF: " << multivariate_psrf<NT, VT>(S) << std::endl;
std::cerr << "maximum marginal PSRF: " << univariate_psrf<NT, VT>(S).maxCoeff() << std::endl;
}
}

int main() {
run_main<double>();
return 0;
}
Loading

0 comments on commit 7c96708

Please sign in to comment.