From 2b876b256a919446e08ccda260a68dfc5dbc26be Mon Sep 17 00:00:00 2001 From: Vissarion Fisikopoulos Date: Sat, 11 Feb 2023 20:19:19 +0100 Subject: [PATCH 1/3] Enable github actions to build examples. Avoid passing a polytope as a const reference. --- .github/workflows/cmake-clang.yml | 4 +- .github/workflows/cmake-examples.yml | 40 +++++++++++++ examples/hpolytope-volume/hpolytopeVolume.cpp | 2 +- examples/mmcs_method/CMakeLists.txt | 2 +- examples/multithread_sampling/CMakeLists.txt | 6 +- .../sampling_multithread_walks.cpp | 11 ++-- .../optimization_spectrahedra/CMakeLists.txt | 9 +-- .../sampler.cpp | 6 +- examples/vpolytope-volume/CMakeLists.txt | 4 +- examples/vpolytope-volume/vpolytopevolume.cpp | 2 +- include/convex_bodies/ballintersectconvex.h | 2 +- include/random_walks/boundary_cdhr_walk.hpp | 2 +- include/random_walks/boundary_rdhr_walk.hpp | 2 +- include/random_walks/compute_diameter.hpp | 4 +- ...ial_hamiltonian_monte_carlo_exact_walk.hpp | 26 ++++----- .../gaussian_accelerated_billiard_walk.hpp | 8 +-- include/random_walks/gaussian_ball_walk.hpp | 6 +- include/random_walks/gaussian_cdhr_walk.hpp | 4 +- ...ian_hamiltonian_monte_carlo_exact_walk.hpp | 26 ++++----- include/random_walks/gaussian_rdhr_walk.hpp | 4 +- include/random_walks/multithread_walks.hpp | 58 +++++++++---------- include/random_walks/uniform_ball_walk.hpp | 6 +- include/random_walks/uniform_cdhr_walk.hpp | 4 +- include/random_walks/uniform_rdhr_walk.hpp | 8 +-- include/sampling/random_point_generators.hpp | 10 ++-- include/volume/volume_cooling_balls.hpp | 2 +- include/volume/volume_cooling_gaussians.hpp | 10 ++-- include/volume/volume_cooling_hpoly.hpp | 4 +- include/volume/volume_sequence_of_balls.hpp | 4 +- 29 files changed, 158 insertions(+), 118 deletions(-) create mode 100644 .github/workflows/cmake-examples.yml diff --git a/.github/workflows/cmake-clang.yml b/.github/workflows/cmake-clang.yml index 5386c3963..caa22fff2 100644 --- a/.github/workflows/cmake-clang.yml +++ b/.github/workflows/cmake-clang.yml @@ -1,5 +1,5 @@ ############################################################################## -# GitHub Actions Workflow for volesti to build tests with GCC +# GitHub Actions Workflow for volesti to build tests with Clang # # Copyright (c) 2020-2022 Vissarion Fisikopoulos # @@ -36,4 +36,4 @@ jobs: cd build; cmake -D CMAKE_CXX_COMPILER=${{ matrix.config.compiler }} -D CMAKE_CXX_FLAGS=-fsanitize=memory -D CMAKE_CXX_FLAGS=-fsanitize=undefined -D CMAKE_CXX_FLAGS=-g -D DISABLE_NLP_ORACLES=ON -D USE_MKL=OFF ../test; make; - ctest --verbose; + ctest --verbose; \ No newline at end of file diff --git a/.github/workflows/cmake-examples.yml b/.github/workflows/cmake-examples.yml new file mode 100644 index 000000000..b7784fa30 --- /dev/null +++ b/.github/workflows/cmake-examples.yml @@ -0,0 +1,40 @@ +############################################################################## +# GitHub Actions Workflow for volesti to build tests with GCC +# +# Copyright (c) 2020-2022 Vissarion Fisikopoulos +# +# Licensed under GNU LGPL.3, see LICENCE file +############################################################################## +name: cmake-examples + +on: [push, pull_request] + +jobs: + build: + name: ${{ matrix.config.os }} - ${{ matrix.config.compiler }} + strategy: + fail-fast: false + matrix: + config: + - {os: ubuntu-22.04, compiler_pkg: clang-11, compiler: clang++-11} + - {os: ubuntu-22.04, compiler_pkg: g++-11, compiler: g++-11} + runs-on: ${{ matrix.config.os }} + steps: + - uses: actions/checkout@v1 + - run: sudo apt-get update || true; + sudo apt-get install ${{ matrix.config.compiler_pkg }} lp-solve libomp-dev libopenblas-dev libarpack2-dev; + - name: Build examples + run: | + cd examples + for dir in */; do + if [ "$dir" != "EnvelopeProblemSOS/" ] && [ "$dir" != "python_utilities/" ]; then + echo + echo "Building examples in $dir ....................." + cd "$dir" + mkdir build && cd build + cmake -DCMAKE_CXX_COMPILER=${{ matrix.config.compiler }} -DUSE_MKL=OFF .. + make + cd ../.. + fi + done + diff --git a/examples/hpolytope-volume/hpolytopeVolume.cpp b/examples/hpolytope-volume/hpolytopeVolume.cpp index 487ce98f4..b61190de9 100644 --- a/examples/hpolytope-volume/hpolytopeVolume.cpp +++ b/examples/hpolytope-volume/hpolytopeVolume.cpp @@ -29,7 +29,7 @@ typedef typename Kernel::Point Point; typedef BoostRandomNumberGenerator RNGType; typedef HPolytope HPOLYTOPE; -void calculateVolumes(const HPOLYTOPE &HP) { +void calculateVolumes(HPOLYTOPE &HP) { // Setup parameters for calculating volume int walk_len = 10 + HP.dimension()/10; NT e=0.1; diff --git a/examples/mmcs_method/CMakeLists.txt b/examples/mmcs_method/CMakeLists.txt index 1ee6ce0a5..01b8a040c 100644 --- a/examples/mmcs_method/CMakeLists.txt +++ b/examples/mmcs_method/CMakeLists.txt @@ -105,7 +105,7 @@ else () add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-DBOOST_NO_AUTO_PTR") #add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-lgslcblas") #add_definitions( "-O3 -lgsl -lm -ldl -lgslcblas" ) - + find_package(OpenMP REQUIRED) add_executable (skinny_cube_10_dim skinny_cube_10_dim.cpp) diff --git a/examples/multithread_sampling/CMakeLists.txt b/examples/multithread_sampling/CMakeLists.txt index fe4d5ee75..ded4b4dbb 100644 --- a/examples/multithread_sampling/CMakeLists.txt +++ b/examples/multithread_sampling/CMakeLists.txt @@ -97,7 +97,7 @@ else () endif () - add_definitions(${CMAKE_CXX_FLAGS} "-std=c++11") # enable C++11 standard + #add_definitions(${CMAKE_CXX_FLAGS} "-std=c++11") # enable C++11 standard add_definitions(${CMAKE_CXX_FLAGS} "-O3") # optimization of the compiler #add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-lgsl") add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-lm") @@ -105,11 +105,11 @@ else () add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-DBOOST_NO_AUTO_PTR") #add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-lgslcblas") #add_definitions( "-O3 -lgsl -lm -ldl -lgslcblas" ) - + find_package(OpenMP REQUIRED) add_executable (sampling_multithread_walks sampling_multithread_walks.cpp) - + TARGET_LINK_LIBRARIES(sampling_multithread_walks ${LP_SOLVE} OpenMP::OpenMP_CXX) diff --git a/examples/multithread_sampling/sampling_multithread_walks.cpp b/examples/multithread_sampling/sampling_multithread_walks.cpp index 191b8e6c5..cb416c72c 100644 --- a/examples/multithread_sampling/sampling_multithread_walks.cpp +++ b/examples/multithread_sampling/sampling_multithread_walks.cpp @@ -48,12 +48,12 @@ MT get_uniform_samples(Polytope &P, std::list randPoints; typedef RandomPointGeneratorMultiThread _RandomPointGeneratorMultiThread; - + _RandomPointGeneratorMultiThread::apply(P, p, N, walk_len, num_threads, randPoints, push_back_policy, rng); unsigned int d = P.dimension(); - + MT samples(d, N); unsigned int jj = 0; @@ -92,7 +92,7 @@ MT get_gaussian_samples(Polytope &P, std::list randPoints; typedef GaussianPointGeneratorMultiThread _GaussianPointGeneratorMultiThread; - + _GaussianPointGeneratorMultiThread::apply(P, p, a_i, N, walk_len, num_threads, randPoints, push_back_policy, rng); @@ -118,11 +118,10 @@ void test_uniform_random_walk(std::string random_walk, unsigned int const& num_t typedef Eigen::Matrix MT; typedef Eigen::Matrix VT; typedef BoostRandomNumberGenerator RNGType; - Hpolytope P; unsigned int d = 10, walk_len = 5, N = 5000; std::cout << "--- Sampling with " + random_walk + " walk from H-cube10" << std::endl; - P = generate_cube(d, false); + Hpolytope P = generate_cube(d, false); RNGType rng(P.dimension()); MT samples = get_uniform_samples(P, rng, walk_len, N, num_threads); @@ -155,7 +154,7 @@ void test_gaussian_random_walk(std::string random_walk, unsigned int const& num_ int main() { - + unsigned int num_threads = 2; test_uniform_random_walk("BRDHR", num_threads); diff --git a/examples/optimization_spectrahedra/CMakeLists.txt b/examples/optimization_spectrahedra/CMakeLists.txt index 356a3e6ac..a35aee4c7 100644 --- a/examples/optimization_spectrahedra/CMakeLists.txt +++ b/examples/optimization_spectrahedra/CMakeLists.txt @@ -78,11 +78,12 @@ IF (OPENBLAS_LIB) IF (GFORTRAN_LIB) message( STATUS "GFORTRAN_LIB found: ${GFORTRAN_LIB}" ) - add_executable (boltzmann_hmc_walk boltzmann_hmc_walk.cpp) - TARGET_LINK_LIBRARIES(boltzmann_hmc_walk ${ARPACK_LIB} ${LAPACK_LIBRARIES} ${GFORTRAN_LIB}) + # These are not compiling, see issue https://github.com/GeomScale/volesti/issues/264 + #add_executable (boltzmann_hmc_walk boltzmann_hmc_walk.cpp) + #TARGET_LINK_LIBRARIES(boltzmann_hmc_walk ${ARPACK_LIB} ${LAPACK_LIBRARIES} ${GFORTRAN_LIB}) - add_executable (solve_sdp solve_sdp.cpp) - TARGET_LINK_LIBRARIES(solve_sdp ${GFORTRAN_LIB} ${LAPACK_LIBRARIES} ${ARPACK_LIB}) + #add_executable (solve_sdp solve_sdp.cpp) + #TARGET_LINK_LIBRARIES(solve_sdp ${GFORTRAN_LIB} ${LAPACK_LIBRARIES} ${ARPACK_LIB}) ELSE() MESSAGE(STATUS "gfortran is required but it could not be found") diff --git a/examples/sampling-hpolytope-with-billiard-walks/sampler.cpp b/examples/sampling-hpolytope-with-billiard-walks/sampler.cpp index 16b6f2367..22dd6d9e5 100644 --- a/examples/sampling-hpolytope-with-billiard-walks/sampler.cpp +++ b/examples/sampling-hpolytope-with-billiard-walks/sampler.cpp @@ -37,7 +37,7 @@ void write_to_file(std::string filename, std::vector const& randPoints) { } -void sample_using_uniform_billiard_walk(HPOLYTOPE const& HP, RNGType& rng, unsigned int walk_len, unsigned int num_points) { +void sample_using_uniform_billiard_walk(HPOLYTOPE& HP, RNGType& rng, unsigned int walk_len, unsigned int num_points) { std::string filename = "uniform_billiard_walk.txt"; typedef RandomPointGenerator Generator; @@ -49,7 +49,7 @@ void sample_using_uniform_billiard_walk(HPOLYTOPE const& HP, RNGType& rng, unsig } -void sample_using_uniform_accelerated_billiard_walk(HPOLYTOPE const& HP, RNGType& rng, unsigned int walk_len, unsigned int num_points) { +void sample_using_uniform_accelerated_billiard_walk(HPOLYTOPE& HP, RNGType& rng, unsigned int walk_len, unsigned int num_points) { std::string filename = "uniform_accelerated_billiard_walk.txt"; typedef RandomPointGenerator Generator; @@ -61,7 +61,7 @@ void sample_using_uniform_accelerated_billiard_walk(HPOLYTOPE const& HP, RNGType } -void sample_using_gaussian_billiard_walk(HPOLYTOPE const& HP, RNGType& rng, unsigned int walk_len, unsigned int num_points) { +void sample_using_gaussian_billiard_walk(HPOLYTOPE& HP, RNGType& rng, unsigned int walk_len, unsigned int num_points) { std::string filename = "gaussian_billiard_walk.txt"; typedef MultivariateGaussianRandomPointGenerator Generator; diff --git a/examples/vpolytope-volume/CMakeLists.txt b/examples/vpolytope-volume/CMakeLists.txt index fdcb3095f..5ffd4784b 100644 --- a/examples/vpolytope-volume/CMakeLists.txt +++ b/examples/vpolytope-volume/CMakeLists.txt @@ -106,7 +106,7 @@ else () add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-ldl") add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-DBOOST_NO_AUTO_PTR") - add_executable (vpolytopeVolume vpolytopeVolume.cpp) - TARGET_LINK_LIBRARIES(vpolytopeVolume ${LP_SOLVE}) + add_executable (vpolytopevolume vpolytopevolume.cpp) + TARGET_LINK_LIBRARIES(vpolytopevolume ${LP_SOLVE}) endif() diff --git a/examples/vpolytope-volume/vpolytopevolume.cpp b/examples/vpolytope-volume/vpolytopevolume.cpp index e814b5875..007964232 100644 --- a/examples/vpolytope-volume/vpolytopevolume.cpp +++ b/examples/vpolytope-volume/vpolytopevolume.cpp @@ -28,7 +28,7 @@ typedef typename Kernel::Point Point; typedef BoostRandomNumberGenerator RNGType; typedef VPolytope VPOLYTOPE; -void calculateVolumes(const VPOLYTOPE &VP) { +void calculateVolumes(VPOLYTOPE &VP) { // Setup parameters for calculating volume int walk_len = 10 + VP.dimension()/10; NT e=0.1; diff --git a/include/convex_bodies/ballintersectconvex.h b/include/convex_bodies/ballintersectconvex.h index 12965d08c..b61ae5324 100644 --- a/include/convex_bodies/ballintersectconvex.h +++ b/include/convex_bodies/ballintersectconvex.h @@ -28,7 +28,7 @@ class BallIntersectPolytope { BallIntersectPolytope() {} - BallIntersectPolytope(Polytope const& PP, CBall &BB) : P(PP), B(BB) {}; + BallIntersectPolytope(Polytope& PP, CBall &BB) : P(PP), B(BB) {}; Polytope first() const { return P; } CBall second() const { return B; } diff --git a/include/random_walks/boundary_cdhr_walk.hpp b/include/random_walks/boundary_cdhr_walk.hpp index 40d35df2d..5e6b5224c 100644 --- a/include/random_walks/boundary_cdhr_walk.hpp +++ b/include/random_walks/boundary_cdhr_walk.hpp @@ -26,7 +26,7 @@ struct BCDHRWalk typedef typename Point::FT NT; template - Walk(GenericPolytope const& P, Point const& p, RandomNumberGenerator& rng) + Walk(GenericPolytope& P, Point const& p, RandomNumberGenerator& rng) { initialize(P, p, rng); } diff --git a/include/random_walks/boundary_rdhr_walk.hpp b/include/random_walks/boundary_rdhr_walk.hpp index 0cf582957..29d500b6c 100644 --- a/include/random_walks/boundary_rdhr_walk.hpp +++ b/include/random_walks/boundary_rdhr_walk.hpp @@ -27,7 +27,7 @@ struct BRDHRWalk typedef typename Point::FT NT; template - Walk(GenericPolytope const& P, Point const& p, RandomNumberGenerator& rng) + Walk(GenericPolytope& P, Point const& p, RandomNumberGenerator& rng) { initialize(P, p, rng); } diff --git a/include/random_walks/compute_diameter.hpp b/include/random_walks/compute_diameter.hpp index e3ec0f441..b20aa839a 100644 --- a/include/random_walks/compute_diameter.hpp +++ b/include/random_walks/compute_diameter.hpp @@ -205,7 +205,7 @@ template struct compute_diameter> { template - static NT compute(OrderPolytope const& P) + static NT compute(OrderPolytope& P) { return std::sqrt(NT(P.dimension())); } @@ -215,7 +215,7 @@ template struct compute_diameter, Ellipsoid > > { template - static NT compute(BallIntersectPolytope, Ellipsoid> const& P) + static NT compute(BallIntersectPolytope, Ellipsoid>& P) { NT polytope_diameter = std::sqrt(NT(P.dimension())); return std::min(polytope_diameter, (NT(2) * P.radius())); diff --git a/include/random_walks/exponential_hamiltonian_monte_carlo_exact_walk.hpp b/include/random_walks/exponential_hamiltonian_monte_carlo_exact_walk.hpp index 0d1199410..6e5d2e000 100644 --- a/include/random_walks/exponential_hamiltonian_monte_carlo_exact_walk.hpp +++ b/include/random_walks/exponential_hamiltonian_monte_carlo_exact_walk.hpp @@ -84,7 +84,7 @@ struct Walk < typename GenericPolytope > - inline bool apply(GenericPolytope const& P, + inline bool apply(GenericPolytope& P, Point& p, // a point to start unsigned int const& walk_length, RandomNumberGenerator &rng) @@ -104,7 +104,7 @@ struct Walk } T = rng.sample_urdist() * _Len; _v = GetDirection::apply(n, rng, false); - + it = 0; while (it < _rho) { @@ -122,7 +122,7 @@ struct Walk P.compute_reflection(_v, _p, pbpair.second); it++; } - + } while (P.is_in(_p, INSIDE_BODY_TOLLERANCE) == 0); if (it == _rho) { _p = p0; @@ -137,7 +137,7 @@ struct Walk < typename GenericPolytope > - inline void get_starting_point(GenericPolytope const& P, + inline void get_starting_point(GenericPolytope& P, Point const& center, Point &q, unsigned int const& walk_length, @@ -158,7 +158,7 @@ struct Walk < typename GenericPolytope > - inline void parameters_burnin(GenericPolytope const& P, + inline void parameters_burnin(GenericPolytope& P, Point const& center, unsigned int const& num_points, unsigned int const& walk_length, @@ -171,7 +171,7 @@ struct Walk pointset.push_back(_p); NT rad = NT(0), max_dist, Lmax = NT(0), radius = P.InnerBall().second; - for (int i = 0; i < num_points; i++) + for (int i = 0; i < num_points; i++) { p = GetPointInDsphere::apply(n, radius, rng); p += center; @@ -179,18 +179,18 @@ struct Walk apply(P, p, walk_length, rng); max_dist = get_max_distance(pointset, p, rad); - if (max_dist > Lmax) + if (max_dist > Lmax) { Lmax = max_dist; } - if (2.0 * rad > Lmax) + if (2.0 * rad > Lmax) { Lmax = 2.0 * rad; } pointset.push_back(p); } - if (Lmax > _Len) + if (Lmax > _Len) { update_delta(Lmax); } @@ -210,7 +210,7 @@ private : < typename GenericPolytope > - inline void initialize(GenericPolytope const& P, + inline void initialize(GenericPolytope& P, Point const& p, RandomNumberGenerator &rng) { @@ -219,7 +219,7 @@ private : _lambdas.setZero(P.num_of_hyperplanes()); _Av.setZero(P.num_of_hyperplanes()); _v = GetDirection::apply(n, rng, false); - + do { _p = p; T = rng.sample_urdist() * _Len; @@ -262,11 +262,11 @@ private : } - inline double get_max_distance(std::vector &pointset, Point const& q, double &rad) + inline double get_max_distance(std::vector &pointset, Point const& q, double &rad) { double dis = -1.0, temp_dis; int jj = 0; - for (auto vecit = pointset.begin(); vecit!=pointset.end(); vecit++, jj++) + for (auto vecit = pointset.begin(); vecit!=pointset.end(); vecit++, jj++) { temp_dis = (q.getCoefficients() - (*vecit).getCoefficients()).norm(); if (temp_dis > dis) { diff --git a/include/random_walks/gaussian_accelerated_billiard_walk.hpp b/include/random_walks/gaussian_accelerated_billiard_walk.hpp index a44608fb2..fbf43f443 100644 --- a/include/random_walks/gaussian_accelerated_billiard_walk.hpp +++ b/include/random_walks/gaussian_accelerated_billiard_walk.hpp @@ -68,7 +68,7 @@ struct GaussianAcceleratedBilliardWalk typedef typename Point::FT NT; template - Walk(GenericPolytope const& P, + Walk(GenericPolytope& P, Point const& p, Ellipsoid const& E, // ellipsoid representing the Gaussian distribution RandomNumberGenerator &rng) @@ -83,7 +83,7 @@ struct GaussianAcceleratedBilliardWalk } template - Walk(GenericPolytope const& P, + Walk(GenericPolytope& P, Point const& p, Ellipsoid const& E, // ellipsoid representing the Gaussian distribution RandomNumberGenerator &rng, @@ -104,7 +104,7 @@ struct GaussianAcceleratedBilliardWalk typename GenericPolytope, typename Ellipsoid > - inline void apply(GenericPolytope const& P, + inline void apply(GenericPolytope& P, Point &p, // a point to return the result Ellipsoid const& E, // ellipsoid representing the Gaussian distribution unsigned int const& walk_length, @@ -181,7 +181,7 @@ struct GaussianAcceleratedBilliardWalk typename GenericPolytope, typename Ellipsoid > - inline void initialize(GenericPolytope const& P, + inline void initialize(GenericPolytope& P, Point const& p, // a point to start Ellipsoid const& E, // ellipsoid representing the Gaussian distribution RandomNumberGenerator &rng) diff --git a/include/random_walks/gaussian_ball_walk.hpp b/include/random_walks/gaussian_ball_walk.hpp index c641b7344..8c267e0f9 100644 --- a/include/random_walks/gaussian_ball_walk.hpp +++ b/include/random_walks/gaussian_ball_walk.hpp @@ -46,19 +46,19 @@ struct Walk typedef typename Point::FT NT; template - static inline NT compute_delta(GenericPolytope const& P, NT const& a) + static inline NT compute_delta(GenericPolytope& P, NT const& a) { //return ((P.InnerBall()).second * NT(4)) / NT(P.dimension()); return (NT(4) * (P.InnerBall()).second) / std::sqrt(std::max(NT(1), a) * NT(P.dimension())); } - Walk (Polytope const& P, Point const& p, NT const& a, + Walk (Polytope& P, Point const& p, NT const& a, RandomNumberGenerator &rng) { _delta = compute_delta(P, a); } - Walk (Polytope const& P, + Walk (Polytope& P, Point const& p, NT const& a, RandomNumberGenerator &rng, diff --git a/include/random_walks/gaussian_cdhr_walk.hpp b/include/random_walks/gaussian_cdhr_walk.hpp index 8962ce413..04ebedbc4 100644 --- a/include/random_walks/gaussian_cdhr_walk.hpp +++ b/include/random_walks/gaussian_cdhr_walk.hpp @@ -75,7 +75,7 @@ struct Walk typedef typename Polytope::PointType Point; typedef typename Point::FT NT; - Walk(Polytope const& P, + Walk(Polytope& P, Point const& p, NT const& a_i, RandomNumberGenerator &rng) @@ -83,7 +83,7 @@ struct Walk initialize(P, p, a_i, rng); } - Walk(Polytope const& P, + Walk(Polytope& P, Point const& p, NT const& a_i, RandomNumberGenerator& rng, diff --git a/include/random_walks/gaussian_hamiltonian_monte_carlo_exact_walk.hpp b/include/random_walks/gaussian_hamiltonian_monte_carlo_exact_walk.hpp index 954fda731..8b83b053b 100644 --- a/include/random_walks/gaussian_hamiltonian_monte_carlo_exact_walk.hpp +++ b/include/random_walks/gaussian_hamiltonian_monte_carlo_exact_walk.hpp @@ -19,7 +19,7 @@ struct GaussianHamiltonianMonteCarloExactWalk GaussianHamiltonianMonteCarloExactWalk(double L, unsigned int _rho) : param(L, true, _rho, true) {} - + GaussianHamiltonianMonteCarloExactWalk(double L) : param(L, true, 0, false) {} @@ -28,7 +28,7 @@ struct GaussianHamiltonianMonteCarloExactWalk : param(0, false, 0, false) {} - + struct parameters { parameters(double L, bool set, unsigned int _rho, bool _set_rho) @@ -80,7 +80,7 @@ struct Walk < typename GenericPolytope > - inline void apply(GenericPolytope const& P, + inline void apply(GenericPolytope& P, Point& p, NT const& a_i, unsigned int const& walk_length, @@ -120,7 +120,7 @@ struct Walk < typename GenericPolytope > - inline void get_starting_point(GenericPolytope const& P, + inline void get_starting_point(GenericPolytope& P, Point const& center, Point &q, unsigned int const& walk_length, @@ -141,7 +141,7 @@ struct Walk < typename GenericPolytope > - inline void parameters_burnin(GenericPolytope const& P, + inline void parameters_burnin(GenericPolytope& P, Point const& center, unsigned int const& num_points, unsigned int const& walk_length, @@ -154,7 +154,7 @@ struct Walk pointset.push_back(_p); NT rad = NT(0), max_dist, Lmax = NT(0), radius = P.InnerBall().second; - for (int i = 0; i < num_points; i++) + for (int i = 0; i < num_points; i++) { p = GetPointInDsphere::apply(n, radius, rng); p += center; @@ -162,18 +162,18 @@ struct Walk apply(P, p, walk_length, rng); max_dist = get_max_distance(pointset, p, rad); - if (max_dist > Lmax) + if (max_dist > Lmax) { Lmax = max_dist; } - if (2.0*rad > Lmax) + if (2.0*rad > Lmax) { Lmax = 2.0 * rad; } pointset.push_back(p); } - if (Lmax > _Len) + if (Lmax > _Len) { update_delta(Lmax); } @@ -191,7 +191,7 @@ private : < typename GenericPolytope > - inline void initialize(GenericPolytope const& P, + inline void initialize(GenericPolytope& P, Point const& p, NT const& a_i, RandomNumberGenerator &rng) @@ -239,14 +239,14 @@ private : p.set_coord(i, C * std::cos(omega * T + Phi)); v.set_coord(i, -C * omega * std::sin(omega * T + Phi)); } - + } - inline double get_max_distance(std::vector &pointset, Point const& q, double &rad) + inline double get_max_distance(std::vector &pointset, Point const& q, double &rad) { double dis = -1.0, temp_dis; int jj = 0; - for (auto vecit = pointset.begin(); vecit!=pointset.end(); vecit++, jj++) + for (auto vecit = pointset.begin(); vecit!=pointset.end(); vecit++, jj++) { temp_dis = (q.getCoefficients() - (*vecit).getCoefficients()).norm(); if (temp_dis > dis) { diff --git a/include/random_walks/gaussian_rdhr_walk.hpp b/include/random_walks/gaussian_rdhr_walk.hpp index de7fd7bf9..b7a53abe7 100644 --- a/include/random_walks/gaussian_rdhr_walk.hpp +++ b/include/random_walks/gaussian_rdhr_walk.hpp @@ -80,10 +80,10 @@ struct Walk typedef typename Polytope::PointType Point; typedef typename Point::FT NT; - Walk(Polytope const&, Point const&, NT const&, RandomNumberGenerator&) + Walk(Polytope&, Point const&, NT const&, RandomNumberGenerator&) {} - Walk(Polytope const&, Point const&, NT const&, RandomNumberGenerator&, + Walk(Polytope&, Point const&, NT const&, RandomNumberGenerator&, parameters&) {} diff --git a/include/random_walks/multithread_walks.hpp b/include/random_walks/multithread_walks.hpp index 45b2b67cb..c42fba1fa 100644 --- a/include/random_walks/multithread_walks.hpp +++ b/include/random_walks/multithread_walks.hpp @@ -58,7 +58,7 @@ struct BCDHRWalk_multithread //typedef thread_params thread_parameters_; template - Walk(GenericPolytope const& P, thread_parameters_ ¶meters, RandomNumberGenerator& rng) + Walk(GenericPolytope& P, thread_parameters_ ¶meters, RandomNumberGenerator& rng) { initialize(P, parameters, rng); } @@ -68,7 +68,7 @@ struct BCDHRWalk_multithread typename BallPolytope > inline void apply(BallPolytope const& P, - thread_parameters_ ¶ms, // parameters + thread_parameters_ ¶ms, // parameters unsigned int const& walk_length, RandomNumberGenerator& rng) { @@ -97,13 +97,13 @@ struct BCDHRWalk_multithread template inline void initialize(GenericBody const& P, - thread_parameters_ ¶ms, // parameters + thread_parameters_ ¶ms, // parameters RandomNumberGenerator& rng) { params.lambdas.setZero(P.num_of_hyperplanes()); params.rand_coord = rng.sample_uidist(); NT kapa = rng.sample_urdist(); - + std::pair bpair = P.line_intersect_coord(params.p, params.rand_coord, params.lambdas); params.p_prev = params.p; @@ -158,7 +158,7 @@ struct BRDHRWalk_multithread //typedef thread_params thread_parameters_; template - Walk(GenericPolytope const& P, thread_parameters_ ¶meters, RandomNumberGenerator& rng) + Walk(GenericPolytope& P, thread_parameters_ ¶meters, RandomNumberGenerator& rng) { initialize(P, parameters, rng); } @@ -168,7 +168,7 @@ struct BRDHRWalk_multithread typename BallPolytope > inline void apply(BallPolytope const& P, - thread_parameters_ ¶ms, // parameters + thread_parameters_ ¶ms, // parameters unsigned int const& walk_length, RandomNumberGenerator& rng) { @@ -191,7 +191,7 @@ struct BRDHRWalk_multithread template inline void initialize(GenericBody const& P, - thread_parameters_ ¶ms, // parameters + thread_parameters_ ¶ms, // parameters RandomNumberGenerator& rng) { params.lambdas.setZero(P.num_of_hyperplanes()); @@ -243,7 +243,7 @@ struct Walk typedef thread_parameters thread_parameters_; //typedef thread_params thread_parameters_; - Walk(Polytope const& P, + Walk(Polytope& P, thread_parameters_ ¶ms, NT const& a_i, RandomNumberGenerator &rng) @@ -252,7 +252,7 @@ struct Walk } template - Walk(Polytope const& P, + Walk(Polytope& P, thread_parameters_ ¶ms, NT const& a_i, RandomNumberGenerator &rng, @@ -260,14 +260,14 @@ struct Walk { initialize(P, params, a_i, rng); } - + template < typename BallPolytope > inline void apply(BallPolytope const& P, - thread_parameters_ ¶ms, // parameters + thread_parameters_ ¶ms, // parameters NT const& a_i, unsigned int const& walk_length, RandomNumberGenerator &rng) @@ -293,7 +293,7 @@ private : template inline void initialize(BallPolytope const& P, - thread_parameters_ ¶ms, // parameters + thread_parameters_ ¶ms, // parameters NT const& a_i, RandomNumberGenerator &rng) { @@ -345,11 +345,11 @@ struct Walk typedef thread_parameters thread_parameters_; //typedef thread_params thread_parameters_; - Walk(Polytope const&, thread_parameters_ &, NT const&, RandomNumberGenerator&) + Walk(Polytope&, thread_parameters_ &, NT const&, RandomNumberGenerator&) {} template - Walk(Polytope const&, thread_parameters_ &, NT const&, RandomNumberGenerator&, + Walk(Polytope&, thread_parameters_ &, NT const&, RandomNumberGenerator&, parameters&) {} @@ -358,7 +358,7 @@ struct Walk typename BallPolytope > inline void apply(BallPolytope const& P, - thread_parameters_ ¶ms, // parameters + thread_parameters_ ¶ms, // parameters NT const& a_i, unsigned int const& walk_length, RandomNumberGenerator &rng) @@ -440,7 +440,7 @@ struct Walk //typedef thread_params thread_parameters_; template - Walk(GenericPolytope const& P, thread_parameters_ ¶meters, RandomNumberGenerator &rng) + Walk(GenericPolytope& P, thread_parameters_ ¶meters, RandomNumberGenerator &rng) { _Len = compute_diameter ::template compute(P); @@ -448,7 +448,7 @@ struct Walk } template - Walk(GenericPolytope const& P, thread_parameters_ ¶meters, RandomNumberGenerator &rng, + Walk(GenericPolytope& P, thread_parameters_ ¶meters, RandomNumberGenerator &rng, parameters_ const& params) { _Len = params.set_L ? params.m_L @@ -461,7 +461,7 @@ struct Walk < typename GenericPolytope > - inline void apply(GenericPolytope const& P, + inline void apply(GenericPolytope& P, thread_parameters_ ¶meters, unsigned int const& walk_length, RandomNumberGenerator &rng) @@ -491,7 +491,7 @@ struct Walk P.compute_reflection(parameters.v, parameters.p, pbpair.second); it++; } - if (it == 50*n) + if (it == 50*n) { parameters.p = parameters.p0; } @@ -509,7 +509,7 @@ private : < typename GenericPolytope > - inline void initialize(GenericPolytope const& P, + inline void initialize(GenericPolytope& P, thread_parameters_ ¶meters, RandomNumberGenerator &rng) { @@ -524,7 +524,7 @@ private : std::pair pbpair = P.line_positive_intersect(parameters.p, parameters.v, parameters.lambdas, parameters.Av); - if (T <= pbpair.first) + if (T <= pbpair.first) { parameters.p += (T * parameters.v); parameters.lambda_prev = T; @@ -538,9 +538,9 @@ private : while (it <= 50*n) { std::pair pbpair - = P.line_positive_intersect(parameters.p, parameters.v, parameters.lambdas, + = P.line_positive_intersect(parameters.p, parameters.v, parameters.lambdas, parameters.Av, parameters.lambda_prev); - if (T <= pbpair.first) + if (T <= pbpair.first) { parameters.p += (T * parameters.v); parameters.lambda_prev = T; @@ -599,7 +599,7 @@ struct Walk //typedef thread_params thread_parameters_; template - Walk(GenericPolytope const& P, thread_parameters_ ¶meters, RandomNumberGenerator& rng) + Walk(GenericPolytope& P, thread_parameters_ ¶meters, RandomNumberGenerator& rng) { initialize(P, parameters, rng); } @@ -610,7 +610,7 @@ struct Walk typename BallPolytope > inline void apply(BallPolytope const& P, - thread_parameters_ ¶ms, // parameters + thread_parameters_ ¶ms, // parameters unsigned int const& walk_length, RandomNumberGenerator &rng) { @@ -634,7 +634,7 @@ private : template inline void initialize(BallPolytope const& P, - thread_parameters_ ¶ms, // parameters + thread_parameters_ ¶ms, // parameters RandomNumberGenerator &rng) { params.lambdas.setZero(P.num_of_hyperplanes()); @@ -690,7 +690,7 @@ struct Walk //typedef thread_params thread_parameters_; template - Walk(GenericPolytope const& P, thread_parameters_ ¶meters, RandomNumberGenerator& rng) + Walk(GenericPolytope& P, thread_parameters_ ¶meters, RandomNumberGenerator& rng) { initialize(P, parameters, rng); } @@ -700,7 +700,7 @@ struct Walk typename BallPolytope > inline void apply(BallPolytope const& P, - thread_parameters_ ¶ms, // parameters + thread_parameters_ ¶ms, // parameters unsigned int const& walk_length, RandomNumberGenerator& rng) { @@ -719,7 +719,7 @@ private : template inline void initialize(BallPolytope const& P, - thread_parameters_ ¶ms, // parameters + thread_parameters_ ¶ms, // parameters RandomNumberGenerator &rng) { params.lambdas.setZero(P.num_of_hyperplanes()); diff --git a/include/random_walks/uniform_ball_walk.hpp b/include/random_walks/uniform_ball_walk.hpp index aeee06537..77c608b72 100644 --- a/include/random_walks/uniform_ball_walk.hpp +++ b/include/random_walks/uniform_ball_walk.hpp @@ -46,14 +46,14 @@ struct BallWalk typedef typename Point::FT NT; template - Walk(GenericPolytope const& P, Point const& /*p*/, + Walk(GenericPolytope& P, Point const& /*p*/, RandomNumberGenerator& /*rng*/) { _delta = compute_delta(P); } template - Walk(GenericPolytope const& P, Point const& /*p*/, + Walk(GenericPolytope& P, Point const& /*p*/, RandomNumberGenerator& /*rng*/, parameters const& params) { _delta = params.set_delta ? params.m_L @@ -61,7 +61,7 @@ struct BallWalk } template - static inline NT compute_delta(GenericPolytope const& P) + static inline NT compute_delta(GenericPolytope& P) { //return ((P.InnerBall()).second * NT(4)) / NT(P.dimension()); return (NT(4) * (P.InnerBall()).second) / std::sqrt(NT(P.dimension())); diff --git a/include/random_walks/uniform_cdhr_walk.hpp b/include/random_walks/uniform_cdhr_walk.hpp index b1a1a5386..12d2ff78e 100644 --- a/include/random_walks/uniform_cdhr_walk.hpp +++ b/include/random_walks/uniform_cdhr_walk.hpp @@ -30,13 +30,13 @@ struct Walk typedef typename Point::FT NT; template - Walk(GenericPolytope const& P, Point const& p, RandomNumberGenerator& rng) + Walk(GenericPolytope& P, Point const& p, RandomNumberGenerator& rng) { initialize(P, p, rng); } template - Walk(GenericPolytope const& P, Point const& p, + Walk(GenericPolytope& P, Point const& p, RandomNumberGenerator& rng, parameters const& params) { initialize(P, p, rng); diff --git a/include/random_walks/uniform_rdhr_walk.hpp b/include/random_walks/uniform_rdhr_walk.hpp index a322fe12c..5e0eb4750 100644 --- a/include/random_walks/uniform_rdhr_walk.hpp +++ b/include/random_walks/uniform_rdhr_walk.hpp @@ -31,13 +31,13 @@ struct Walk typedef typename Point::FT NT; template - Walk(GenericPolytope const& P, Point const& p, RandomNumberGenerator& rng) + Walk(GenericPolytope& P, Point const& p, RandomNumberGenerator& rng) { initialize(P, p, rng); } template - Walk(GenericPolytope const& P, Point const& p, + Walk(GenericPolytope& P, Point const& p, RandomNumberGenerator& rng, parameters const& params) { initialize(P, p, rng); @@ -47,7 +47,7 @@ struct Walk < typename BallPolytope > - inline void apply(BallPolytope const& P, + inline void apply(BallPolytope& P, Point& p, // a point to start unsigned int const& walk_length, RandomNumberGenerator& rng) @@ -67,7 +67,7 @@ struct Walk private : template - inline void initialize(BallPolytope const& P, + inline void initialize(BallPolytope& P, Point const& p, RandomNumberGenerator &rng) { diff --git a/include/sampling/random_point_generators.hpp b/include/sampling/random_point_generators.hpp index abc7677e7..86b10666c 100644 --- a/include/sampling/random_point_generators.hpp +++ b/include/sampling/random_point_generators.hpp @@ -143,7 +143,7 @@ struct GaussianRandomPointGenerator typename WalkPolicy, typename RandomNumberGenerator > - static void apply(Polytope const& P, + static void apply(Polytope& P, Point &p, // a point to start NT const& a_i, unsigned int const& rnum, @@ -170,7 +170,7 @@ struct GaussianRandomPointGenerator typename RandomNumberGenerator, typename Parameters > - static void apply(Polytope const& P, + static void apply(Polytope& P, Point &p, // a point to start NT const& a_i, unsigned int const& rnum, @@ -203,7 +203,7 @@ struct BoundaryRandomPointGenerator typename WalkPolicy, typename RandomNumberGenerator > - static void apply(Polytope const& P, + static void apply(Polytope& P, Point &p, // a point to start unsigned int const& rnum, unsigned int const& walk_length, @@ -282,7 +282,7 @@ struct ExponentialRandomPointGenerator typename WalkPolicy, typename RandomNumberGenerator > - static void apply(Polytope const& P, + static void apply(Polytope& P, Point &p, // a point to start Point const& c, // bias function NT const& T, // temperature/variance @@ -315,7 +315,7 @@ struct ExponentialRandomPointGenerator typename RandomNumberGenerator, typename Parameters > - static void apply(Polytope const& P, + static void apply(Polytope& P, Point &p, // a point to start Point const& c, // bias function NT const& T, // temperature/variance diff --git a/include/volume/volume_cooling_balls.hpp b/include/volume/volume_cooling_balls.hpp index 29731a2e9..d90604fa4 100644 --- a/include/volume/volume_cooling_balls.hpp +++ b/include/volume/volume_cooling_balls.hpp @@ -694,7 +694,7 @@ template typename RandomNumberGenerator = BoostRandomNumberGenerator > -std::pair volume_cooling_balls(Polytope const& Pin, +std::pair volume_cooling_balls(Polytope& Pin, RandomNumberGenerator &rng, double const& error = 0.1, unsigned int const& walk_length = 1, diff --git a/include/volume/volume_cooling_gaussians.hpp b/include/volume/volume_cooling_gaussians.hpp index ef7ab0f70..ca06ce315 100644 --- a/include/volume/volume_cooling_gaussians.hpp +++ b/include/volume/volume_cooling_gaussians.hpp @@ -57,7 +57,7 @@ struct update_delta> // Compute the first variance a_0 for the starting gaussian template -void get_first_gaussian(Polytope const& P, +void get_first_gaussian(Polytope& P, NT const& frac, NT const& chebychev_radius, NT const& error, @@ -125,7 +125,7 @@ template typename NT, typename RandomNumberGenerator > -NT get_next_gaussian(Polytope const& P, +NT get_next_gaussian(Polytope& P, Point &p, NT const& a, const unsigned int &N, @@ -186,7 +186,7 @@ template typename NT, typename RandomNumberGenerator > -void compute_annealing_schedule(Polytope const& P, +void compute_annealing_schedule(Polytope& P, NT const& ratio, NT const& C, NT const& frac, @@ -289,7 +289,7 @@ template typename RandomNumberGenerator > -double volume_cooling_gaussians(Polytope const& Pin, +double volume_cooling_gaussians(Polytope& Pin, RandomNumberGenerator& rng, double const& error = 0.1, unsigned int const& walk_length = 1) @@ -483,7 +483,7 @@ double volume_cooling_gaussians(Polytope &Pin, { RandomNumberGenerator rng(Pin.dimension()); Pin.set_interior_point(interior_point); - + return volume_cooling_gaussians(Pin, rng, error, walk_length); } diff --git a/include/volume/volume_cooling_hpoly.hpp b/include/volume/volume_cooling_hpoly.hpp index 1175d9b64..c8183384c 100644 --- a/include/volume/volume_cooling_hpoly.hpp +++ b/include/volume/volume_cooling_hpoly.hpp @@ -135,7 +135,7 @@ bool get_next_zonoball(std::vector &HPolySet, return false; } -template +template < typename RandomPointGenerator, typename ZonoHP, @@ -374,7 +374,7 @@ template typename HPolytope, typename Polytope > -double volume_cooling_hpoly(Polytope const& Pin, +double volume_cooling_hpoly(Polytope& Pin, double const& error = 0.1, unsigned int const& walk_length = 1) { diff --git a/include/volume/volume_sequence_of_balls.hpp b/include/volume/volume_sequence_of_balls.hpp index fc1342cee..b79358a6e 100644 --- a/include/volume/volume_sequence_of_balls.hpp +++ b/include/volume/volume_sequence_of_balls.hpp @@ -44,7 +44,7 @@ template typename RandomNumberGenerator > -double volume_sequence_of_balls(Polytope const& Pin, +double volume_sequence_of_balls(Polytope& Pin, RandomNumberGenerator &rng, double const& error = 1.0, unsigned int const& walk_length = 1, @@ -258,7 +258,7 @@ double volume_sequence_of_balls(Polytope &Pin, { RandomNumberGenerator rng(Pin.dimension()); Pin.set_interior_point(interior_point); - + return volume_sequence_of_balls(Pin, rng, error, walk_length, n_threads); } From 553cf553a1f3e313aee315bf4e5d347c4bf469df Mon Sep 17 00:00:00 2001 From: Vissarion Fisikopoulos Date: Mon, 13 Feb 2023 15:05:55 +0200 Subject: [PATCH 2/3] Fix ambiguous call to fix function by renaming volesti's diagnostic function. (#263) --- include/diagnostics/raftery.hpp | 13 ++++++------- .../diagnostics/raftery_subroutines/empquant.hpp | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/include/diagnostics/raftery.hpp b/include/diagnostics/raftery.hpp index de7928202..1fa087a5d 100644 --- a/include/diagnostics/raftery.hpp +++ b/include/diagnostics/raftery.hpp @@ -29,10 +29,9 @@ #define DIAGNOSTICS_RAFTERY_HPP template -NT fix(NT x) +NT round_to_zero(NT x) { - if (x > 0.0) return std::floor(x); - return std::ceil(x); + return (x > 0.0) ? std::floor(x) : std::ceil(x); } #include "raftery_subroutines/empquant.hpp" @@ -121,13 +120,13 @@ MT perform_raftery(MT const& samples, NT const& q, NT const& r, NT const& s) NT psum = alpha + beta; NT tmp1 = std::log(psum * epss / std::max(alpha, beta)) / std::log(std::abs(1.0 - psum)); - NT nburn = fix((tmp1 + 1.0) * NT(kthin)); + NT nburn = round_to_zero((tmp1 + 1.0) * NT(kthin)); NT phi = ppnd((s + 1.0) / 2.0); NT tmp2 = (2.0 - psum) * alpha * beta * (phi * phi) / (psum * psum * psum * (r * r)); - NT nprec = fix(tmp2 + 1.0) * kthin; - NT nmin = fix(((1.0 - q) * q * (phi * phi) / (r * r)) + 1.0); + NT nprec = round_to_zero(tmp2 + 1.0) * kthin; + NT nmin = round_to_zero(((1.0 - q) * q * (phi * phi) / (r * r)) + 1.0); NT irl = (nburn + nprec) / nmin; - NT kind = std::max(fix(irl + 1.0), NT(kmind)); + NT kind = std::max(round_to_zero(irl + 1.0), NT(kmind)); results(i, 0) = NT(kthin); results(i, 1) = NT(nburn); diff --git a/include/diagnostics/raftery_subroutines/empquant.hpp b/include/diagnostics/raftery_subroutines/empquant.hpp index cd305372e..6604f0ad7 100644 --- a/include/diagnostics/raftery_subroutines/empquant.hpp +++ b/include/diagnostics/raftery_subroutines/empquant.hpp @@ -17,10 +17,10 @@ template NT empquant(VT const& sorted_samples, NT const& q) { unsigned int n = sorted_samples.rows(); - + NT order = (n - 1) * q + 1.0; NT fract = order - NT(int(order)); - int low = std::max(fix(order), 1.0); + int low = std::max(round_to_zero(order), 1.0); int high = std::min(low + 1.0, NT(n)); NT y = (1.0 - fract) * sorted_samples(low - 1) + fract * sorted_samples(high - 1); From 9d495d6768de9b0f5ddc24698bc99b29f8da1b78 Mon Sep 17 00:00:00 2001 From: Soumya Tarafder <63846042+Soumya624@users.noreply.github.com> Date: Mon, 20 Feb 2023 19:25:16 +0530 Subject: [PATCH 3/3] Updating documentation (#261) Adding WSL and MKL build instructions. --- CONTRIBUTING.md | 103 ++++++++++++++++---------------- docs/getting_started/install.md | 15 +++++ 2 files changed, 68 insertions(+), 50 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5d2414da9..3af68ab7b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,42 +2,42 @@ :+1::tada: First off, thanks for taking the time to contribute! :tada::+1: -The following is a set of guidelines for contributing to volesti, -which are hosted in the [GeomScale Organization](https://github.com/GeomScale) on GitHub. -These are mostly guidelines, not rules. +The following is a set of guidelines for contributing to volesti, +which are hosted in the [GeomScale Organization](https://github.com/GeomScale) on GitHub. +These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request. ## Table of Contents - * [Prerequisites (how to start)](#prerequisites--how-to-start-) - * [Testing the development branch of volesti (get the tools ready)](#testing-the-development-branch-of-volesti--get-the-tools-ready-) - * [Fork volesti repository (this is your repo now!)](#fork--volesti-repository--this-is-your-repo-now--) - + [Verify if your fork works (optional)](#verify-if-your-fork-works--optional-) - * [Working with volesti (get ready to contribute)](#working-with-volesti--get-ready-to-contribute-) - + [GitFlow workflow](#gitflow-workflow) - + [Create new branch for your work](#create-new-branch-for-your-work) - + [Verify your new branch (optional)](#verify-your-new-branch--optional-) - * [Modify the branch (implement, implement, implement)](#modify-the-branch--implement--implement--implement-) - + [Tests](#tests) - + [Push](#push) - * [Pull request (the joy of sharing)](#pull-request--the-joy-of-sharing-) - * [Review (ok this is not an exam)](#review--ok-this-is-not-an-exam-) - +- [Prerequisites (how to start)](#prerequisites--how-to-start-) +- [Testing the development branch of volesti (get the tools ready)](#testing-the-development-branch-of-volesti--get-the-tools-ready-) +- [Fork volesti repository (this is your repo now!)](#fork--volesti-repository--this-is-your-repo-now--) + - [Verify if your fork works (optional)](#verify-if-your-fork-works--optional-) +- [Working with volesti (get ready to contribute)](#working-with-volesti--get-ready-to-contribute-) + - [GitFlow workflow](#gitflow-workflow) + - [Create new branch for your work](#create-new-branch-for-your-work) + - [Verify your new branch (optional)](#verify-your-new-branch--optional-) +- [Modify the branch (implement, implement, implement)](#modify-the-branch--implement--implement--implement-) + - [Tests](#tests) + - [Push](#push) +- [Pull request (the joy of sharing)](#pull-request--the-joy-of-sharing-) +- [Review (ok this is not an exam)](#review--ok-this-is-not-an-exam-) + ## Prerequisites (how to start) -* git (see [Getting Started with Git](https://help.github.com/en/github/using-git/getting-started-with-git-and-github)) -* a compiler to run tests - gcc, clang, etc. -* configured GitHub account - +- git (see [Getting Started with Git](https://help.github.com/en/github/using-git/getting-started-with-git-and-github)) +- a compiler to run tests - gcc, clang, etc. +- configured GitHub account + Other helpful links: -* http://git-scm.com/documentation -* https://help.github.com/articles/set-up-git -* https://opensource.com/article/18/1/step-step-guide-git +- http://git-scm.com/documentation +- https://help.github.com/articles/set-up-git +- https://opensource.com/article/18/1/step-step-guide-git ## Testing the development branch of volesti (get the tools ready) -Clone the repository, +Clone the repository, git clone git@github.com:GeomScale/volume_approximation.git volesti cd volesti @@ -52,12 +52,14 @@ To compile the `C++` code you have to specify the path to external library `libl # e.g. on linux: cmake -DLP_SOLVE=/usr/lib/lp_solve/liblpsolve55.so .. make -Run the tests, +You can check [here](/docs/getting_started/install.md) to see more installation guide. - ctest -jK +Run the tests, -where `K` is the number of CPU threads. By adding the option `--verbose` to `ctest` you get more information about the tests, -*e.g.* time per test, volume computed and the name of the polytope or convex body. + ctest -jK + +where `K` is the number of CPU threads. By adding the option `--verbose` to `ctest` you get more information about the tests, +_e.g._ time per test, volume computed and the name of the polytope or convex body. ![test_cube](https://user-images.githubusercontent.com/3660366/72348403-0524df00-36e3-11ea-9b6d-288a2bddc22c.png) @@ -65,8 +67,8 @@ If everything works for you, you may move forward. ## Fork volesti repository (this is your repo now!) -You can't work directly in the original volesti repository, therefore you should create your fork of this library. -This way you can modify the code and when the job is done send a pull request to merge your changes with the original +You can't work directly in the original volesti repository, therefore you should create your fork of this library. +This way you can modify the code and when the job is done send a pull request to merge your changes with the original repository. ![fork](https://user-images.githubusercontent.com/3660366/72348562-57fe9680-36e3-11ea-9746-385ff61c752a.png) @@ -90,9 +92,10 @@ clone your repository and checkout develop branch git clone git@github.com:vissarion/volume_approximation.git volesti_fork cd volesti_fork - git checkout develop + git remote add upstream git@github.com:GeomScale/volesti.git + git fetch upstream + git checkout upstream/develop git branch -vv - git pull see commits @@ -105,17 +108,17 @@ For now you should see exactly the same commits as in `volesti` repository. ### GitFlow workflow -Volesit is using the [GitFlow](http://nvie.com/posts/a-successful-git-branching-model/) workflow. -It's because it is very well suited to collaboration and scaling the development team. +Volesit is using the [GitFlow](http://nvie.com/posts/a-successful-git-branching-model/) workflow. +It's because it is very well suited to collaboration and scaling the development team. Each repository using this model should contain two main branches: -* master - release-ready version of the library -* develop - development version of the library - -and could contain various supporting branches for new features and hotfixes. +- master - release-ready version of the library +- develop - development version of the library + +and could contain various supporting branches for new features and hotfixes. -As a contributor you'll most likely be adding new features or fixing bugs in the development version of the library. -This means that for each contribution you should create a new branch originating from the develop branch, +As a contributor you'll most likely be adding new features or fixing bugs in the development version of the library. +This means that for each contribution you should create a new branch originating from the develop branch, modify it and send a pull request in order to merge it, again with the develop branch. ### Create new branch for your work @@ -128,7 +131,7 @@ you should see ![branch -vv](https://user-images.githubusercontent.com/3660366/72348696-a1e77c80-36e3-11ea-93ec-70f5622c0675.png) -Now you should pick a name for your new branch that doesn't already exist. +Now you should pick a name for your new branch that doesn't already exist. The following checks for existing remote branches git branch -a @@ -136,7 +139,7 @@ The following checks for existing remote branches ![List of branches](https://user-images.githubusercontent.com/3660366/72348763-c5aac280-36e3-11ea-8f2c-c66e2c107929.png) Alternatively, you can check them on `GitHub`. -Assume you want to add some new functionality (i.e. a new feature) for example a new sampling algorithm. Then you have +Assume you want to add some new functionality (i.e. a new feature) for example a new sampling algorithm. Then you have to create a new branch e.g. `feature/the_fastest_sampling_algo_ever` Create new local branch @@ -168,12 +171,12 @@ Alternatively, your newly created remote branch is also available on GitHub ## Modify the branch (implement, implement, implement) -Before contributiong to a library by adding a new feature, or a bugfix, or improving documentation, +Before contributiong to a library by adding a new feature, or a bugfix, or improving documentation, it is always wise to interact with the community of developers, for example by opening an issue. ### Tests -Tests are placed in the `test` directory and use the [doctest](https://github.com/onqtam/doctest) library. +Tests are placed in the `test` directory and use the [doctest](https://github.com/onqtam/doctest) library. It is recommended to add new test whenever you contribute a new functionality/feature. Also if your contribution is a bugfix then consider adding this case to the test-suite. @@ -202,16 +205,16 @@ and click the "Create pull request" button. ## Review (ok this is not an exam) -After creating a pull request your code will be reviewed. You can propose one or more reviewers +After creating a pull request your code will be reviewed. You can propose one or more reviewers by clicking on the "Reviewers" button ![reviewer](https://user-images.githubusercontent.com/3660366/72349476-44ecc600-36e5-11ea-81cd-d0938d923529.png) -If there are no objections your changes will be merged. +If there are no objections your changes will be merged. Otherwise you'll see some comments under the pull request and/or under specific lines of your code. -Then you have to make the required changes, commit them and push to your branch. -Those changes will automatically be a part of the same pull request. This procedure will be repeated until the code +Then you have to make the required changes, commit them and push to your branch. +Those changes will automatically be a part of the same pull request. This procedure will be repeated until the code is ready for merging. -If you're curious how it looks like you may see one of the open or closed +If you're curious how it looks like you may see one of the open or closed [pull requests](https://github.com/GeomScale/volume_approximation/pulls). diff --git a/docs/getting_started/install.md b/docs/getting_started/install.md index 57962f8ff..cfdb773e7 100644 --- a/docs/getting_started/install.md +++ b/docs/getting_started/install.md @@ -17,6 +17,21 @@ make ``` For example: `-DLP_SOLVE=/usr/lib/lpsolve/liblpsolve55.so` +In WSL (Windows Subsystem Linux), you can run the following command to install libc6-dev-i386. This will be required for `ieeefp.h` which is used by `qd` library, + + sudo apt-get install libc6-dev-i386 + +Also to install `mkl` related dependencies, run the following, + + wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB + sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB + sudo sh -c 'echo deb https://apt.repos.intel.com/mkl all main > /etc/apt/sources.list.d/intel-mkl.list' + sudo apt-get update + sudo apt-get install intel-mkl-2020.4-912 + sudo sh -c "echo /opt/intel/mkl/lib/intel64 > /etc/ld.so.conf.d/intel-mkl.conf" + sudo ldconfig + export CPLUS_INCLUDE_PATH="/opt/intel/mkl/include:$CPLUS_INCLUDE_PATH" + You can run the tests by `cmake test` or `ctest -jK` where `K` the number of `CPU` threads. By adding the option `--verbose` to `ctest` you get more information about the tests, *e.g.* time per test, volume computed and the name of the polytope or convex body. ### Development environment from Docker container