Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReHMC support for spectrahedra and general convex bodies with refactored Spectrahedra classes #194

Merged
merged 69 commits into from
Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
f2040cd
Squash commits into one
papachristoumarios Feb 26, 2021
37d54dd
Minor changes
papachristoumarios Feb 26, 2021
1bfc766
Remove merge blocks
papachristoumarios Feb 26, 2021
7b84432
Disable MKL in github actions
papachristoumarios Feb 26, 2021
619e1e3
Fix CircleCI tests
papachristoumarios Feb 26, 2021
70498e0
Fix step() method in R bindings
papachristoumarios Feb 26, 2021
eea6f69
Disactivate sdp test
papachristoumarios Feb 27, 2021
8ddb5ef
Rebuild documentation with roxygen
papachristoumarios Feb 27, 2021
a7fe93e
Rebuild documentation with roxygen
papachristoumarios Feb 27, 2021
6177f56
Add ess docs
papachristoumarios Feb 27, 2021
9ada49f
Fix ess docs
papachristoumarios Feb 27, 2021
128bcce
Fix ess docs
papachristoumarios Feb 27, 2021
7df13c2
Fix random polytope generator
papachristoumarios Mar 4, 2021
1e8eff3
Reorder class fields
papachristoumarios Mar 4, 2021
46f97b9
Remove ESS computation via stan
papachristoumarios Mar 12, 2021
eda5ff0
Add volesti implementation of ESS and test correctness
papachristoumarios Mar 12, 2021
edb06cb
Add const& to effective_sample_size
papachristoumarios Mar 12, 2021
a4f910b
Refactor and move mat_convert script
papachristoumarios Mar 15, 2021
23a1ad2
Refactoring
papachristoumarios Mar 15, 2021
20f0714
Remove removed header
papachristoumarios Mar 17, 2021
38fca74
Move R examples to separate folder
papachristoumarios Mar 17, 2021
aec692d
Add R documentation entries
papachristoumarios Mar 17, 2021
f3c0ea3
Add missing .Rd files
papachristoumarios Mar 18, 2021
d869141
Complete R documentation entries
papachristoumarios Mar 19, 2021
61a6eec
Complete R documentation entries
papachristoumarios Mar 19, 2021
c96ebb9
Complete R documentation entries
papachristoumarios Mar 19, 2021
6ac5e63
Rename R files to have ext .R and removed binary
papachristoumarios Mar 19, 2021
aa4fa38
Find libraries in OSx systems
papachristoumarios Mar 21, 2021
641cded
Merge branch 'develop' of https://github.com/GeomScale/volume_approxi…
papachristoumarios Mar 21, 2021
294b149
Move Rcpp oracle functors to R project dir
papachristoumarios Apr 3, 2021
9cf0cd7
Merge branch 'icml-2021' of github.com:papachristoumarios/volume_appr…
papachristoumarios Apr 3, 2021
3fa3572
Change .hpp extension to .h
papachristoumarios Apr 5, 2021
10637c1
Add support for OSX for cmake
papachristoumarios Apr 21, 2021
a14e418
Fixes
papachristoumarios Apr 21, 2021
ef3a0ae
Minor modifications
papachristoumarios May 17, 2021
53221d8
Add generic convex body implementation
papachristoumarios May 18, 2021
dfc725f
Add generic convex body implementation
papachristoumarios May 18, 2021
9dfe36c
add new spectrahedron class
TolisChal May 18, 2021
aeb6685
Add instances
papachristoumarios May 18, 2021
3da0517
spectrahedra implmentation, tests, and R interface
TolisChal May 24, 2021
a948bca
Minor modifications
papachristoumarios May 24, 2021
dd23163
Resolve merge conflicts
papachristoumarios May 24, 2021
915e348
Merge branch 'hmc_spectra' of github.com:TolisChal/volume_approximati…
papachristoumarios May 24, 2021
caf3d98
Merge branch 'hmc_spectra' into icml-2021
papachristoumarios May 24, 2021
491d088
Fix makefile
papachristoumarios May 24, 2021
9e43263
Add missing file
papachristoumarios Jun 19, 2021
0ee73a6
fix conflicts frm develop
TolisChal Dec 5, 2021
62c760f
update spectrahedron class
TolisChal Dec 6, 2021
0685ec8
delete unused files
TolisChal Dec 6, 2021
27a3d29
merge spectrahedron files and update examples and R interface
TolisChal Dec 10, 2021
262d590
remove unused comments
TolisChal Dec 10, 2021
410c843
Merge pull request #2 from TolisChal/spectra
papachristoumarios Dec 12, 2021
b13a939
Minor fix
papachristoumarios Dec 20, 2021
6cff201
Minor changes
papachristoumarios Dec 20, 2021
cf89f81
Linear optimization with log-concave sampling
papachristoumarios Dec 20, 2021
6cb84df
OSX Fix
papachristoumarios Dec 20, 2021
da113d0
Merge branch 'toms' of github.com:papachristoumarios/volume_approxima…
papachristoumarios Dec 20, 2021
a90b9e8
Add diagnostics
papachristoumarios Dec 21, 2021
6c3483e
Fix makefile
papachristoumarios Dec 21, 2021
1063d15
Merge branch 'toms' of github.com:papachristoumarios/volume_approxima…
papachristoumarios Dec 21, 2021
e281ff5
Add grid search to optimization
papachristoumarios Dec 21, 2021
37963b1
merge develop
TolisChal Dec 21, 2021
ea3a6ef
resolve pr comments
TolisChal Dec 21, 2021
3fd78b8
Add one more diagnostic
papachristoumarios Dec 21, 2021
6bea5df
Merge branch 'toms' of https://github.com/papachristoumarios/volume_a…
TolisChal Dec 22, 2021
50f49b0
update the c++ tests
TolisChal Dec 22, 2021
aed2fe2
Merge pull request #3 from TolisChal/spectra
papachristoumarios Dec 23, 2021
174cc73
resolve cran errors
TolisChal Dec 24, 2021
b7f7c3a
Merge pull request #4 from TolisChal/spectra
papachristoumarios Dec 26, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions R-proj/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export(gen_rand_vpoly)
export(gen_rand_zonotope)
export(gen_simplex)
export(gen_skinny_cube)
export(get_full_dimensional_polytope)
export(geweke)
export(inner_ball)
export(loadSdpaFormatFile)
Expand All @@ -40,4 +39,4 @@ importFrom("stats","cov")
importFrom("utils","read.csv")
importFrom(Rcpp,evalCpp)
importFrom(Rcpp,loadModule)
useDynLib(volesti, .registration=TRUE)
useDynLib(volesti, .registration=TRUE)
21 changes: 5 additions & 16 deletions R-proj/R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ direct_sampling <- function(body, n, seed = NULL) {
#' Gelman-Rubin and Brooks-Gelman Potential Scale Reduction Factor (PSRF) for each marginal
#'
#' @param samples A matrix that contans column-wise the sampled points from a geometric random walk.
#' @param method A string to reauest diagnostic: (i) \code{'normal'} for psrf of Gelman-Rubin and (ii) \code{'interval'} for psrf of Brooks-Gelman.
#'
#' @references \cite{Gelman, A. and Rubin, D. B.,
#' \dQuote{Inference from iterative simulation using multiple sequences,} \emph{Statistical Science,} 1992.}
Expand Down Expand Up @@ -138,21 +137,6 @@ frustum_of_simplex <- function(a, z0) {
.Call(`_volesti_frustum_of_simplex`, a, z0)
}

#' Internal rcpp function to compute the full dimensional polytope when a low dimensional is given
#'
#' @param P A low dimensional convex polytope in H-representation.
#'
#' @keywords internal
#'
#' @return A numerical matrix that describes the full dimensional polytope, a numerical matrix of the inverse
#' linear transformation that is applied on the input polytope, the numerical vector - point that the
#' input polytope is shifted and the product of the singular values of the matrix of the linear map
#' applied on the input polytope.
#'
full_dimensional_polytope <- function(P) {
.Call(`_volesti_full_dimensional_polytope`, P)
}

#' Geweke's MCMC diagnostic
#'
#' @param samples A matrix that contans column-wise the sampled points from a geometric random walk.
Expand Down Expand Up @@ -377,6 +361,11 @@ sample_points <- function(P, n, random_walk = NULL, distribution = NULL, seed =
.Call(`_volesti_sample_points`, P, n, random_walk, distribution, seed)
}

#' @export
sample_spectra <- function(file = NULL, N = NULL, walk_length = NULL) {
.Call(`_volesti_sample_spectra`, file, N, walk_length)
}

#' Write a SDPA format file
#'
#' Outputs a spectrahedron (the matrices defining a linear matrix inequality) and a vector (the objective function)
Expand Down
29 changes: 0 additions & 29 deletions R-proj/R/get_full_dimensional_polytope.R

This file was deleted.

21 changes: 0 additions & 21 deletions R-proj/man/full_dimensional_polytope.Rd

This file was deleted.

23 changes: 0 additions & 23 deletions R-proj/man/get_full_dimensional_polytope.Rd

This file was deleted.

62 changes: 0 additions & 62 deletions R-proj/src/get_full_dimensional_polytope.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion R-proj/src/ode_solve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "volume/volume_cooling_gaussians.hpp"
#include "sampling/sampling.hpp"
#include "ode_solvers/ode_solvers.hpp"
#include "ode_solvers/oracle_functors_rcpp.hpp"
#include "oracle_functors_rcpp.h"

template <
typename Solver,
Expand Down
2 changes: 1 addition & 1 deletion R-proj/src/rounding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Rcpp::List rounding (Rcpp::Reference P,
// Hpolytope

if (Rcpp::as<MT>(P.field("Aeq")).rows() > 0) {
throw Rcpp::exception("volesti supports rounding for full dimensional polytopes. Maybe call function get_full_dimensional_polytope()");
throw Rcpp::exception("volesti supports rounding for full dimensional polytopes");
}
Hpolytope HP(n, Rcpp::as<MT>(P.field("A")), Rcpp::as<VT>(P.field("b")));
InnerBall = HP.ComputeInnerBall();
Expand Down
2 changes: 1 addition & 1 deletion R-proj/src/sample_points.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "volume/volume_cooling_gaussians.hpp"
#include "sampling/sampling.hpp"
#include "ode_solvers/ode_solvers.hpp"
#include "ode_solvers/oracle_functors_rcpp.hpp"
#include "oracle_functors_rcpp.h"

enum random_walks {
ball_walk,
Expand Down
4 changes: 2 additions & 2 deletions R-proj/src/spectrahedron.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void writeSdpaFormatFile(Rcpp::Nullable<Rcpp::Reference> spectrahedron = R_NilVa
typedef typename Kernel::Point Point;
typedef boost::mt19937 RNGType;
typedef LMI<NT, MT, VT> LMI;
typedef Spectrahedron<NT, MT, VT> Spectrahedron;
typedef Spectrahedron<Point> Spectrahedron;

std::vector<MT> matrices = Rcpp::as<std::vector<MT> > (Rcpp::as<Rcpp::Reference> (spectrahedron).field("matrices"));
LMI lmi(matrices);
Expand Down Expand Up @@ -91,7 +91,7 @@ Rcpp::List loadSdpaFormatFile(Rcpp::Nullable<std::string> inputFile = R_NilValue
typedef typename Kernel::Point Point;
typedef boost::mt19937 RNGType;
typedef LMI<NT, MT, VT> LMI;
typedef Spectrahedron<NT, MT, VT> Spectrahedron;
typedef Spectrahedron<Point> Spectrahedron;

Spectrahedron _spectrahedron;
Point c;
Expand Down
35 changes: 35 additions & 0 deletions examples/spectrahedra/Boost.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
function(GetBoost)

find_path(BOOST_DIR NAMES boost PATHS ../external/)

if (NOT BOOST_DIR)

set(BOOST_URL "https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.tar.bz2" CACHE STRING "Boost download URL")
set(BOOST_URL_SHA256 "f0397ba6e982c4450f27bf32a2a83292aba035b827a5623a14636ea583318c41" CACHE STRING "Boost download URL SHA256 checksum")

include(FetchContent)
FetchContent_Declare(
Boost
URL ${BOOST_URL}
URL_HASH SHA256=${BOOST_URL_SHA256}
)
FetchContent_GetProperties(Boost)

if(NOT Boost_POPULATED)
message(STATUS "Fetching Boost")
FetchContent_Populate(Boost)
message(STATUS "Fetching Boost - done")
set(BOOST_DIR ${boost_SOURCE_DIR})
endif()

message(STATUS "Using downloaded Boost library at ${BOOST_DIR}")

else ()
message(STATUS "Boost Library found: ${BOOST_DIR}")

endif()

include_directories(${BOOST_DIR})
include_directories(${BOOST_DIR}/boost)

endfunction()
25 changes: 23 additions & 2 deletions examples/spectrahedra/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,30 @@
# Contributed and/or modified by Repouskos Panagiotis, as part of Google Summer of Code 2019 program.
# Licensed under GNU LGPL.3, see LICENCE file

cmake_minimum_required(VERSION 3.16)

if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)


add_executable (read_write_sdpa_file read_write_sdpa_file.cpp)

include("Eigen.cmake")
GetEigen()

include("Boost.cmake")
GetBoost()

include_directories (BEFORE ../../external)
include_directories (BEFORE ../../include/generators)
include_directories (BEFORE ../../include/volume)
include_directories (BEFORE ../../include)
include_directories (BEFORE ../../include/convex_bodies)
include_directories (BEFORE ../../include/convex_bodies/spectrahedra)
include_directories (BEFORE ../../include/annealing)
include_directories (BEFORE ../../include/samplers)
include_directories (BEFORE ../../include/misc)

# Find LAPACK and BLAS
# OPENBLAS or ( ( SystemOpenblas or BLAS) and LAPACK)
Expand All @@ -26,7 +47,7 @@ IF (OPENBLAS_LIB)
message( STATUS "ARPACK_LIB found: ${ARPACK_LIB}" )

# Query gfortran to get the libgfortran path
FIND_LIBRARY(GFORTRAN_LIB NAMES libgfortran.so PATHS /usr/lib/gcc/x86_64-linux-gnu/8/)
FIND_LIBRARY(GFORTRAN_LIB NAMES libgfortran.so PATHS /usr/lib/gcc/x86_64-linux-gnu/9/)

# Find libgfortran (static preferred)
# Query gfortran to get the libgfortran path
Expand Down Expand Up @@ -61,7 +82,7 @@ IF (OPENBLAS_LIB)
TARGET_LINK_LIBRARIES(boltzmann_hmc_walk ${ARPACK_LIB} ${LAPACK_LIBRARIES} ${GFORTRAN_LIB})

add_executable (solve_sdp solve_sdp.cpp)
TARGET_LINK_LIBRARIES(solve_sdp ${ARPACK_LIB} ${LAPACK_LIBRARIES} ${GFORTRAN_LIB})
TARGET_LINK_LIBRARIES(solve_sdp ${GFORTRAN_LIB} ${LAPACK_LIBRARIES} ${ARPACK_LIB})

ELSE()
MESSAGE(STATUS "gfortran is required but it could not be found")
Expand Down
30 changes: 30 additions & 0 deletions examples/spectrahedra/Eigen.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
function(GetEigen)
find_path(EIGEN_DIR NAMES Eigen PATHS ../../external)

if (NOT EIGEN_DIR)
include(FetchContent)
FetchContent_Declare(
eigen
GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
GIT_TAG 3.4.0
)

FetchContent_GetProperties(eigen)

if(NOT eigen_POPULATED)
message(STATUS "Eigen library not found locally, downloading it.")
FetchContent_Populate(eigen)
endif()

set(EIGEN_DIR ${eigen_SOURCE_DIR})
message(STATUS "Using downloaded Eigen library at: ${EIGEN_DIR}")

else ()

message(STATUS "Eigen Library found: ${EIGEN_DIR}")

endif()

include_directories(${EIGEN_DIR})

endfunction()
4 changes: 2 additions & 2 deletions examples/spectrahedra/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ In the folder "examples", clone this repo:

```bash
git clone https://github.com/m-reuter/arpackpp
cd arpackcpp
cd arpackpp
```

It has two scripts that should easily install the libraries:
Expand Down Expand Up @@ -88,7 +88,7 @@ The contents of the file are:
1 -0 -0
```


It represents a spectrahedron in 2 dimensions, described by a linear matrix inequality with
3x3 matrices, and a linear objective function.

Expand Down
2 changes: 1 addition & 1 deletion examples/spectrahedra/boltzmann_hmc_walk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ typedef Eigen::Matrix<NT, Eigen::Dynamic, 1> VT;
typedef Eigen::Matrix <NT, Eigen::Dynamic, Eigen::Dynamic> MT;
typedef Cartesian <NT> Kernel;
typedef typename Kernel::Point Point;
typedef Spectrahedron <NT, MT, VT> SPECTRAHEDRON;
typedef Spectrahedron <Point> SPECTRAHEDRON;
typedef BoostRandomNumberGenerator<boost::mt19937, NT> RNGType;
typedef BoltzmannHMCWalk::Walk<SPECTRAHEDRON, RNGType> HmcWalk;
typedef BoltzmannHMCWalk::Walk<SPECTRAHEDRON, RNGType>::Settings HmcWalkSettings;
Expand Down
2 changes: 1 addition & 1 deletion examples/spectrahedra/read_write_sdpa_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ typedef Eigen::Matrix<NT, Eigen::Dynamic, 1> VT;
typedef Eigen::Matrix <NT, Eigen::Dynamic, Eigen::Dynamic> MT;
typedef Cartesian <NT> Kernel;
typedef typename Kernel::Point Point;
typedef Spectrahedron <NT, MT, VT> SPECTRAHEDRON;
typedef Spectrahedron <Point> SPECTRAHEDRON;


int main(int argc, char* argv[]) {
Expand Down
Loading