Skip to content

Commit

Permalink
sampling test for sparse polytope
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaperju committed Jul 27, 2024
1 parent 08c0f66 commit fe8f92c
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ add_test(NAME test_grdhr COMMAND sampling_test -tc=grdhr)
add_test(NAME test_gbaw COMMAND sampling_test -tc=gbaw)
add_test(NAME test_ghmc COMMAND sampling_test -tc=ghmc)
add_test(NAME test_gabw COMMAND sampling_test -tc=gabw)
add_test(NAME test_sparse COMMAND sampling_test -tc=sparse)

add_executable (mmcs_test mmcs_test.cpp $<TARGET_OBJECTS:test_main>)
add_test(NAME test_mmcs COMMAND mmcs_test -tc=mmcs)
Expand Down
51 changes: 51 additions & 0 deletions test/sampling_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,53 @@ void call_test_gabw(){

}

template <typename NT>
void call_test_sparse(){
typedef Cartesian<NT> Kernel;
typedef typename Kernel::Point Point;
typedef HPolytope<Point, Eigen::SparseMatrix<NT>> Hpolytope;
typedef typename Hpolytope::MT MT;
typedef typename Hpolytope::DenseMT DenseMT;
typedef Eigen::Matrix<NT,Eigen::Dynamic,1> VT;
Hpolytope P;
unsigned int d = 10;

std::cout << "--- Testing ABW for sparse H-cube10" << std::endl;
P = generate_cube<Hpolytope>(d, false);
P.ComputeInnerBall();

DenseMT samples = get_samples<DenseMT, AcceleratedBilliardWalk>(P);

VT score = univariate_psrf<NT, VT>(samples);
std::cout << "psrf = " << score.maxCoeff() << std::endl;

CHECK(score.maxCoeff() < 1.1);


std::cout << "--- Testing CDHR for sparse H-cube10" << std::endl;
P = generate_cube<Hpolytope>(d, false);
P.ComputeInnerBall();

samples = get_samples<DenseMT, CDHRWalk>(P);

score = univariate_psrf<NT, VT>(samples);
std::cout << "psrf = " << score.maxCoeff() << std::endl;

CHECK(score.maxCoeff() < 1.1);


std::cout << "--- Testing RDHR for sparse H-cube10" << std::endl;
P = generate_cube<Hpolytope>(d, false);
P.ComputeInnerBall();

samples = get_samples<DenseMT, RDHRWalk>(P);

score = univariate_psrf<NT, VT>(samples);
std::cout << "psrf = " << score.maxCoeff() << std::endl;

CHECK(score.maxCoeff() < 1.1);
}

TEST_CASE("dikin") {
call_test_dikin<double>();
}
Expand Down Expand Up @@ -430,3 +477,7 @@ TEST_CASE("ghmc") {
TEST_CASE("gabw") {
call_test_gabw<double>();
}

TEST_CASE("sparse") {
call_test_sparse<double>();
}

0 comments on commit fe8f92c

Please sign in to comment.