diff --git a/.github/workflows/R-CMD-check-macOS.yml b/.github/workflows/R-CMD-check-macOS.yml index 23ac6d616..b1ac281c3 100644 --- a/.github/workflows/R-CMD-check-macOS.yml +++ b/.github/workflows/R-CMD-check-macOS.yml @@ -41,12 +41,17 @@ jobs: - name: Install dependencies run: Rscript -e "install.packages(c('devtools', dependencies=TRUE))" -e "install.packages(c('rcmdcheck', 'devtools', 'Rcpp', 'RcppEigen', 'BH', 'testthat', 'downloader', 'xfun'))"; + - name: Checkout Rvolesti repository + run: git clone https://github.com/GeomScale/Rvolesti.git; + + - name: Upgrade with current develop of volesti + run: cp -rf include Rvolesti/src/volesti; + cp -rf external Rvolesti/src; + - name: Check env: _R_CHECK_CRAN_INCOMING_REMOTE_: false - run: cd cran_gen/; - Rscript genCRANpkg.R; - cd cran_package; + run: cd Rvolesti/; Rscript -e "library(rcmdcheck)" -e "rcmdcheck::rcmdcheck(args = c('--no-manual'), error_on = 'warning', check_dir = 'check')" - name: Upload check results diff --git a/.github/workflows/R-CMD-check-ubuntu.yml b/.github/workflows/R-CMD-check-ubuntu.yml index 9fe81de99..753ee114a 100644 --- a/.github/workflows/R-CMD-check-ubuntu.yml +++ b/.github/workflows/R-CMD-check-ubuntu.yml @@ -44,12 +44,17 @@ jobs: - name: Install dependencies run: Rscript -e "install.packages(c('testthat', 'pkgload', 'rcmdcheck', 'devtools', 'Rcpp', 'RcppEigen', 'BH', 'downloader', 'xfun', dependencies=TRUE))"; + - name: Checkout Rvolesti repository + run: git clone https://github.com/GeomScale/Rvolesti.git; + + - name: Upgrade with current develop of volesti + run: cp -rf include Rvolesti/src/volesti; + cp -rf external Rvolesti/src; + - name: Check env: _R_CHECK_CRAN_INCOMING_REMOTE_: false - run: cd cran_gen/; - Rscript genCRANpkg.R; - cd cran_package; + run: cd Rvolesti/; Rscript -e "library(rcmdcheck)" -e "rcmdcheck::rcmdcheck(args = c('--no-manual'), error_on = 'warning', check_dir = 'check')" - name: Upload check results diff --git a/.github/workflows/R-CMD-check-windows.yml b/.github/workflows/R-CMD-check-windows.yml index ad56a7170..97e725aa0 100644 --- a/.github/workflows/R-CMD-check-windows.yml +++ b/.github/workflows/R-CMD-check-windows.yml @@ -40,12 +40,17 @@ jobs: - name: Install dependencies run: Rscript -e "install.packages(c('devtools', dependencies=TRUE))" -e "install.packages(c('rcmdcheck', 'devtools', 'Rcpp', 'RcppEigen', 'BH', 'testthat', 'downloader', 'xfun'))" + - name: Checkout Rvolesti repository + run: git clone https://github.com/GeomScale/Rvolesti.git; + + - name: Upgrade with current develop of volesti + run: cp -r -fo include Rvolesti/src/volesti; + cp -r -fo external Rvolesti/src; + - name: Check env: _R_CHECK_CRAN_INCOMING_REMOTE_: false - run: cd cran_gen/; - Rscript genCRANpkg.R; - cd cran_package; + run: cd Rvolesti/; Rscript -e "library(rcmdcheck)" -e "rcmdcheck::rcmdcheck(args = c('--no-manual'), error_on = 'warning', check_dir = 'check')" - name: Upload check results diff --git a/R-proj/DESCRIPTION b/R-proj/DESCRIPTION deleted file mode 100644 index ce188ad22..000000000 --- a/R-proj/DESCRIPTION +++ /dev/null @@ -1,23 +0,0 @@ -Package: volesti -Type: Package -License: LGPL-3 -Title: Volume Approximation and Sampling of Convex Polytopes -Author: Vissarion Fisikopoulos [aut, cph, cre], - Apostolos Chalkis [cph, aut], - contributors in file inst/AUTHORS -Copyright: file inst/COPYRIGHTS -Description: Provides an R interface for 'volesti' C++ package. 'volesti' computes estimations of volume - of polytopes given by (i) a set of points, (ii) linear inequalities or (iii) Minkowski sum of segments - (a.k.a. zonotopes). There are three algorithms for volume estimation as well as algorithms - for sampling, rounding and rotating polytopes. Moreover, 'volesti' provides algorithms for - estimating copulas useful in computational finance. -Version: 1.1.2 -Date: 2020-10-24 -Maintainer: Vissarion Fisikopoulos -Depends: Rcpp (>= 0.12.17) -Imports: methods, stats -LinkingTo: Rcpp, RcppEigen, BH -Suggests: testthat -Encoding: UTF-8 -RoxygenNote: 7.1.1 -BugReports: https://github.com/GeomScale/volume_approximation/issues diff --git a/R-proj/NAMESPACE b/R-proj/NAMESPACE deleted file mode 100644 index 085d9ed9f..000000000 --- a/R-proj/NAMESPACE +++ /dev/null @@ -1,42 +0,0 @@ -# Generated by roxygen2: do not edit by hand - -export(compute_indicators) -export(copula) -export(dinvweibull_with_loc) -export(direct_sampling) -export(ess) -export(estimtate_lipschitz_constant) -export(exact_vol) -export(file_to_polytope) -export(frustum_of_simplex) -export(gen_birkhoff) -export(gen_cross) -export(gen_cube) -export(gen_prod_simplex) -export(gen_rand_hpoly) -export(gen_rand_vpoly) -export(gen_rand_zonotope) -export(gen_simplex) -export(gen_skinny_cube) -export(geweke) -export(inner_ball) -export(loadSdpaFormatFile) -export(ode_solve) -export(pinvweibull_with_loc) -export(psrf_multivariate) -export(psrf_univariate) -export(raftery) -export(readSdpaFormatFile) -export(rotate_polytope) -export(round_polytope) -export(sample_points) -export(volume) -export(writeSdpaFormatFile) -export(zonotope_approximation) -exportPattern("^[[:alpha:]]+") -importFrom("methods","new") -importFrom("stats","cov") -importFrom("utils","read.csv") -importFrom(Rcpp,evalCpp) -importFrom(Rcpp,loadModule) -useDynLib(volesti, .registration=TRUE) diff --git a/R-proj/R/RcppExports.R b/R-proj/R/RcppExports.R deleted file mode 100644 index c3f192aee..000000000 --- a/R-proj/R/RcppExports.R +++ /dev/null @@ -1,459 +0,0 @@ -# Generated by using Rcpp::compileAttributes() -> do not edit by hand -# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 - -#' Construct a copula using uniform sampling from the unit simplex -#' -#' Given two families of parallel hyperplanes or a family of parallel hyperplanes and a family of concentric ellispoids centered at the origin intersecting the canonical simplex, this function uniformly samples from the canonical simplex and construct an approximation of the bivariate probability distribution, called copula (see \url{https://en.wikipedia.org/wiki/Copula_(probability_theory)}). -#' At least two families of hyperplanes or one family of hyperplanes and one family of ellipsoids have to be given as input. -#' -#' @param r1 The \eqn{d}-dimensional normal vector of the first family of parallel hyperplanes. -#' @param r2 Optional. The \eqn{d}-dimensional normal vector of the second family of parallel hyperplanes. -#' @param sigma Optional. The \eqn{d\times d} symmetric positive semidefine matrix that describes the family of concentric ellipsoids centered at the origin. -#' @param m The number of the slices for the copula. The default value is 100. -#' @param n The number of points to sample. The default value is \eqn{5\cdot 10^5}. -#' @param seed Optional. A fixed seed for the number generator. -#' -#' @references \cite{L. Cales, A. Chalkis, I.Z. Emiris, V. Fisikopoulos, -#' \dQuote{Practical volume computation of structured convex bodies, and an application to modeling portfolio dependencies and financial crises,} \emph{Proc. of Symposium on Computational Geometry, Budapest, Hungary,} 2018.} -#' -#' @return A \eqn{m\times m} numerical matrix that corresponds to a copula. -#' @examples -#' # compute a copula for two random families of parallel hyperplanes -#' h1 = runif(n = 10, min = 1, max = 1000) -#' h1 = h1 / 1000 -#' h2=runif(n = 10, min = 1, max = 1000) -#' h2 = h2 / 1000 -#' cop = copula(r1 = h1, r2 = h2, m = 10, n = 100000) -#' -#' # compute a copula for a family of parallel hyperplanes and a family of conentric ellipsoids -#' h = runif(n = 10, min = 1, max = 1000) -#' h = h / 1000 -#' E = replicate(10, rnorm(20)) -#' E = cov(E) -#' cop = copula(r1 = h, sigma = E, m = 10, n = 100000) -#' -#' @export -copula <- function(r1, r2 = NULL, sigma = NULL, m = NULL, n = NULL, seed = NULL) { - .Call(`_volesti_copula`, r1, r2, sigma, m, n, seed) -} - -#' Sample perfect uniformly distributed points from well known convex bodies: (a) the unit simplex, (b) the canonical simplex, (c) the boundary of a hypersphere or (d) the interior of a hypersphere. -#' -#' The \eqn{d}-dimensional unit simplex is the set of points \eqn{\vec{x}\in \R^d}, s.t.: \eqn{\sum_i x_i\leq 1}, \eqn{x_i\geq 0}. The \eqn{d}-dimensional canonical simplex is the set of points \eqn{\vec{x}\in \R^d}, s.t.: \eqn{\sum_i x_i = 1}, \eqn{x_i\geq 0}. -#' -#' @param body A list to request exact uniform sampling from special well known convex bodies through the following input parameters: -#' \itemize{ -#' \item{\code{type} }{ A string that declares the type of the body for the exact sampling: a) \code{'unit_simplex'} for the unit simplex, b) \code{'canonical_simplex'} for the canonical simplex, c) \code{'hypersphere'} for the boundary of a hypersphere centered at the origin, d) \code{'ball'} for the interior of a hypersphere centered at the origin.} -#' \item{\code{dimension} }{ An integer that declares the dimension when exact sampling is enabled for a simplex or a hypersphere.} -#' \item{\code{radius} }{ The radius of the \eqn{d}-dimensional hypersphere. The default value is \eqn{1}.} -#' } -#' @param n The number of points that the function is going to sample. -#' @param seed Optional. A fixed seed for the number generator. -#' -#' @references \cite{R.Y. Rubinstein and B. Melamed, -#' \dQuote{Modern simulation and modeling} \emph{ Wiley Series in Probability and Statistics,} 1998.} -#' @references \cite{A Smith, Noah and W Tromble, Roy, -#' \dQuote{Sampling Uniformly from the Unit Simplex,} \emph{ Center for Language and Speech Processing Johns Hopkins University,} 2004.} -#' -#' @return A \eqn{d\times n} matrix that contains, column-wise, the sampled points from the convex polytope P. -#' @examples -#' # 100 uniform points from the 2-d unit ball -#' points = direct_sampling(n = 100, body = list("type" = "ball", "dimension" = 2)) -#' @export -direct_sampling <- function(body, n, seed = NULL) { - .Call(`_volesti_direct_sampling`, body, n, seed) -} - -#' 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. -#' -#' @references \cite{Gelman, A. and Rubin, D. B., -#' \dQuote{Inference from iterative simulation using multiple sequences,} \emph{Statistical Science,} 1992.} -#' -#' @references \cite{Brooks, S. and Gelman, A., -#' \dQuote{General Methods for Monitoring Convergence of Iterative Simulations,} \emph{Journal of Computational and Graphical Statistics,} 1998.} -#' -#' @return A vector that contains the values of PSRF for each coordinate -#' -#' @export -ess <- function(samples) { - .Call(`_volesti_ess`, samples) -} - -#' Compute the exact volume of (a) a zonotope (b) an arbitrary simplex in V-representation or (c) if the volume is known and declared by the input object. -#' -#' Given a zonotope (as an object of class Zonotope), this function computes the sum of the absolute values of the determinants of all the \eqn{d \times d} submatrices of the \eqn{m\times d} matrix \eqn{G} that contains row-wise the \eqn{m} \eqn{d}-dimensional segments that define the zonotope. -#' For an arbitrary simplex that is given in V-representation this function computes the absolute value of the determinant formed by the simplex's points assuming it is shifted to the origin. -#' -#' @param P A polytope -#' -#' @references \cite{E. Gover and N. Krikorian, -#' \dQuote{Determinants and the Volumes of Parallelotopes and Zonotopes,} \emph{Linear Algebra and its Applications, 433(1), 28 - 40,} 2010.} -#' -#' @return The exact volume of the input polytope, for zonotopes, simplices in V-representation and polytopes with known exact volume -#' @examples -#' -#' # compute the exact volume of a 5-dimensional zonotope defined by the Minkowski sum of 10 segments -#' Z = gen_rand_zonotope(2, 5) -#' vol = exact_vol(Z) -#' -#' \donttest{# compute the exact volume of a 2-d arbitrary simplex -#' V = matrix(c(2,3,-1,7,0,0),ncol = 2, nrow = 3, byrow = TRUE) -#' P = Vpolytope$new(V) -#' vol = exact_vol(P) -#' } -#' -#' # compute the exact volume the 10-dimensional cross polytope -#' P = gen_cross(10,'V') -#' vol = exact_vol(P) -#' @export -exact_vol <- function(P) { - .Call(`_volesti_exact_vol`, P) -} - -#' Compute the percentage of the volume of the simplex that is contained in the intersection of a half-space and the simplex. -#' -#' A half-space \eqn{H} is given as a pair of a vector \eqn{a\in R^d} and a scalar \eqn{z0\in R} s.t.: \eqn{a^Tx\leq z0}. This function calls the Ali's version of the Varsi formula to compute a frustum of the simplex. -#' -#' @param a A \eqn{d}-dimensional vector that defines the direction of the hyperplane. -#' @param z0 The scalar that defines the half-space. -#' -#' @references \cite{Varsi, Giulio, -#' \dQuote{The multidimensional content of the frustum of the simplex,} \emph{Pacific J. Math. 46, no. 1, 303--314,} 1973.} -#' -#' @references \cite{Ali, Mir M., -#' \dQuote{Content of the frustum of a simplex,} \emph{ Pacific J. Math. 48, no. 2, 313--322,} 1973.} -#' -#' @return The percentage of the volume of the simplex that is contained in the intersection of a given half-space and the simplex. -#' -#' @examples -#' # compute the frustum of H: -x1+x2<=0 -#' a=c(-1,1) -#' z0=0 -#' frustum = frustum_of_simplex(a, z0) -#' @export -frustum_of_simplex <- function(a, z0) { - .Call(`_volesti_frustum_of_simplex`, a, z0) -} - -#' Geweke's MCMC diagnostic -#' -#' @param samples A matrix that contans column-wise the sampled points from a geometric random walk. -#' @param frac_first Optional. The portion of the first in order points in matrix samples. -#' @param frac_last Optional. The portion of the last in order points in matrix samples. -#' -#' @references \cite{Geweke, J., -#' \dQuote{Evaluating the accuracy of sampling-based approaches to the calculation of posterior moments,} \emph{ In Bayesian Statistics 4. Proceedings of the Fourth Valencia International Meeting,} 1992.} -#' -#' @return A boolean to denote if the result of Geweke diagnostic: (i) false if the null hypothesis is rejected, (ii) true if the null hypothesis is not rejected. -#' -#' @export -geweke <- function(samples, frac_first = NULL, frac_last = NULL) { - .Call(`_volesti_geweke`, samples, frac_first, frac_last) -} - -#' Compute an inscribed ball of a convex polytope -#' -#' For a H-polytope described by a \eqn{m\times d} matrix \eqn{A} and a \eqn{m}-dimensional vector \eqn{b}, s.t.: \eqn{P=\{x\ |\ Ax\leq b\} }, this function computes the largest inscribed ball (Chebychev ball) by solving the corresponding linear program. -#' For both zonotopes and V-polytopes the function computes the minimum \eqn{r} s.t.: \eqn{ r e_i \in P} for all \eqn{i=1, \dots ,d}. Then the ball centered at the origin with radius \eqn{r/ \sqrt{d}} is an inscribed ball. -#' -#' @param P A convex polytope. It is an object from class (a) Hpolytope or (b) Vpolytope or (c) Zonotope or (d) VpolytopeIntersection. -#' @param lpsolve Optional. A boolean variable to compute the Chebychev ball of an H-polytope using the lpsolve library. -#' -#' @return A \eqn{(d+1)}-dimensional vector that describes the inscribed ball. The first \eqn{d} coordinates corresponds to the center of the ball and the last one to the radius. -#' -#' @examples -#' # compute the Chebychev ball of the 2d unit simplex -#' P = gen_cube(10,'H') -#' ball_vec = inner_ball(P) -#' -#' # compute an inscribed ball of the 3-dimensional unit cube in V-representation -#' P = gen_cube(3, 'V') -#' ball_vec = inner_ball(P, lpsolve = TRUE) -#' @export -inner_ball <- function(P, lpsolve = NULL) { - .Call(`_volesti_inner_ball`, P, lpsolve) -} - -#' Solve an ODE of the form dx^n / dt^n = F(x, t) -#' -#' @param n The number of steps. -#' @param step_size The step size. -#' @param order The ODE order (default is n = 1) -#' @param dimension The dimension of each derivative -#' @param initial_time The initial time -#' @param F The function oracle F(x, t) in the ODE. -#' @param method The method to be used -#' @param initial_conditions The initial conditions provided to the solver. Must be provided in a list with keys "x_1", ..., "x_n" and column vectors as values. The state "x_n" represents the (n-1)-th order derivative with respect to time -#' @param domains A list of n H-polytopes with keys "P_1", "P_2", ..., "P_n" that correspond to each derivative's domain -#' -#' @return A list which contains elements "x_1", ..., "x_n" representing each derivative results. Each "x_i" corresponds to a d x n matrix where each column represents a certain timestep of the solver. -#' -#' @examples -#' # Please visit the examples directory on examples demonstrating usage of the ODE solvers. -#' -#' @export -ode_solve <- function(n, step_size, order, dimension, initial_time, F, method, domains = NULL, initial_conditions = NULL) { - .Call(`_volesti_ode_solve`, n, step_size, order, dimension, initial_time, F, method, domains, initial_conditions) -} - -#' An internal Rccp function as a polytope generator -#' -#' @param kind_gen An integer to declare the type of the polytope. -#' @param Vpoly_gen A boolean parameter to declare if the requested polytope has to be in V-representation. -#' @param Zono_gen A boolean parameter to declare if the requested polytope has to be a zonotope. -#' @param dim_gen An integer to declare the dimension of the requested polytope. -#' @param m_gen An integer to declare the number of generators for the requested random zonotope or the number of vertices for a V-polytope. -#' @param seed Optional. A fixed seed for the random polytope generator. -#' -#' @keywords internal -#' -#' @return A numerical matrix describing the requested polytope -poly_gen <- function(kind_gen, Vpoly_gen, Zono_gen, dim_gen, m_gen, seed = NULL) { - .Call(`_volesti_poly_gen`, kind_gen, Vpoly_gen, Zono_gen, dim_gen, m_gen, seed) -} - -#' Gelman-Rubin Potential Scale Reduction Factor (PSRF) -#' -#' @param samples A matrix that contans column-wise the sampled points from a geometric random walk. -#' -#' @references \cite{Gelman, A. and Rubin, D. B., -#' \dQuote{Inference from iterative simulation using multiple sequences,} \emph{Statistical Science,} 1992.} -#' -#' @references \cite{Brooks, S. and Gelman, A., -#' \dQuote{General Methods for Monitoring Convergence of Iterative Simulations,} \emph{Journal of Computational and Graphical Statistics,} 1998.} -#' -#' @return The value of multivariate PSRF by S. Brooks and A. Gelman. -#' -#' @export -psrf_multivariate <- function(samples) { - .Call(`_volesti_psrf_multivariate`, samples) -} - -#' 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.} -#' -#' @references \cite{Brooks, S. and Gelman, A., -#' \dQuote{General Methods for Monitoring Convergence of Iterative Simulations,} \emph{Journal of Computational and Graphical Statistics,} 1998.} -#' -#' @return A vector that contains the values of PSRF for each coordinate -#' -#' @export -psrf_univariate <- function(samples, method = NULL) { - .Call(`_volesti_psrf_univariate`, samples, method) -} - -#' Raftery and Lewis MCMC diagnostic -#' -#' @param samples A matrix that contans column-wise the sampled points from a geometric random walk. -#' @param q Optional. The quantile of the quantity of interest. The default value is 0.025. -#' @param r Optional. The level of precision desired. The default value is 0.01. -#' @param s Optional. The probability associated with r. The default value is 0.95. -#' -#' @references \cite{Raftery, A. E. and Lewis, S. M., -#' \dQuote{How many iterations in the Gibbs sampler?,} \emph{Bayesian Statistics 4. Proceedings of the Fourth Valencia International Meeting,} 1992.} -#' -#' @return (i) The number of draws required for burn-in, (ii) the skip parameter for 1st-order Markov chain, (iii) the skip parameter sufficient to get independence chain, (iv) the number of draws required to achieve r precision, (v) the number of draws if the chain is white noise, (vi) the I-statistic from Raftery and Lewis (1992). -#' -#' @export -raftery <- function(samples, q = NULL, r = NULL, s = NULL) { - .Call(`_volesti_raftery`, samples, q, r, s) -} - -#' An internal Rccp function for the random rotation of a convex polytope -#' -#' @param P A convex polytope (H-, V-polytope or a zonotope). -#' @param T Optional. A rotation matrix. -#' @param seed Optional. A fixed seed for the random linear map generator. -#' -#' @keywords internal -#' -#' @return A matrix that describes the rotated polytope -rotating <- function(P, T = NULL, seed = NULL) { - .Call(`_volesti_rotating`, P, T, seed) -} - -#' Internal rcpp function for the rounding of a convex polytope -#' -#' @param P A convex polytope (H- or V-representation or zonotope). -#' @param method Optional. The method to use for rounding, a) \code{'min_ellipsoid'} for the method based on mimimmum volume enclosing ellipsoid of a uniform sample from P, b) \code{'max_ellipsoid'} for the method based on maximum volume enclosed ellipsoid in P, (c) \code{'isotropy'} for the method based on isotropy. The default method is \code{'min_ellipsoid'} for all the representations. -#' @param seed Optional. A fixed seed for the number generator. -#' -#' @keywords internal -#' -#' @return A numerical matrix that describes the rounded polytope, a numerical matrix of the inverse linear transofmation that is applied on the input polytope, the numerical vector the the input polytope is shifted and the determinant of the matrix of the linear transformation that is applied on the input polytope. -rounding <- function(P, method = NULL, seed = NULL) { - .Call(`_volesti_rounding`, P, method, seed) -} - -#' Sample uniformly, normally distributed, or logconcave distributed points from a convex Polytope (H-polytope, V-polytope, zonotope or intersection of two V-polytopes). -#' -#' @param P A convex polytope. It is an object from class (a) Hpolytope or (b) Vpolytope or (c) Zonotope or (d) VpolytopeIntersection. -#' @param n The number of points that the function is going to sample from the convex polytope. -#' @param random_walk Optional. A list that declares the random walk and some related parameters as follows: -#' \itemize{ -#' \item{\code{walk} }{ A string to declare the random walk: i) \code{'CDHR'} for Coordinate Directions Hit-and-Run, ii) \code{'RDHR'} for Random Directions Hit-and-Run, iii) \code{'BaW'} for Ball Walk, iv) \code{'BiW'} for Billiard walk, v) \code{'dikin'} for dikin walk, vi) \code{'vaidya'} for vaidya walk, vii) \code{'john'} for john walk, viii) \code{'BCDHR'} boundary sampling by keeping the extreme points of CDHR or ix) \code{'BRDHR'} boundary sampling by keeping the extreme points of RDHR x) \code{'HMC'} for Hamiltonian Monte Carlo (logconcave densities) xi) \code{'ULD'} for Underdamped Langevin Dynamics using the Randomized Midpoint Method xii) \code{'ExactHMC'} for exact Hamiltonian Monte Carlo with reflections (spherical Gaussian or exponential distribution). The default walk is \code{'aBiW'} for the uniform distribution or \code{'CDHR'} for the Gaussian distribution and H-polytopes and \code{'BiW'} or \code{'RDHR'} for the same distributions and V-polytopes and zonotopes.} -#' \item{\code{walk_length} }{ The number of the steps per generated point for the random walk. The default value is \eqn{1}.} -#' \item{\code{nburns} }{ The number of points to burn before start sampling. The default value is \eqn{1}.} -#' \item{\code{starting_point} }{ A \eqn{d}-dimensional numerical vector that declares a starting point in the interior of the polytope for the random walk. The default choice is the center of the ball as that one computed by the function \code{inner_ball()}.} -#' \item{\code{BaW_rad} }{ The radius for the ball walk.} -#' \item{\code{L} }{ The maximum length of the billiard trajectory or the radius for the step of dikin, vaidya or john walk.} -#' \item{\code{solver} }{ Specify ODE solver for logconcave sampling. Options are i) leapfrog, ii) euler iii) runge-kutta iv) richardson} -#' \item{\code{step_size }{ Optionally chosen step size for logconcave sampling. Defaults to a theoretical value if not provided.} -#' } -#' @param distribution Optional. A list that declares the target density and some related parameters as follows: -#' \itemize{ -#' \item{\code{density} }{ A string: (a) \code{'uniform'} for the uniform distribution or b) \code{'gaussian'} for the multidimensional spherical distribution c) \code{logconcave} with form proportional to exp(-f(x)) where f(x) is L-smooth and m-strongly-convex d) \code{'exponential'} for the exponential distribution. The default target distribution is the uniform distribution.} -#' \item{\code{variance} }{ The variance of the multidimensional spherical gaussian or the exponential distribution. The default value is 1.} -#' \item{\code{mode} }{ A \eqn{d}-dimensional numerical vector that declares the mode of the Gaussian distribution. The default choice is the center of the as that one computed by the function \code{inner_ball()}.} -#' \item{\code{bias} }{ The bias vector for the exponential distribution. The default vector is \eqn{c_1 = 1} and \eqn{c_i = 0} for \eqn{i \neq 1}.} -#' \item{\code{L_} }{ Smoothness constant (for logconcave). } -#' \item{\code{m} }{ Strong-convexity constant (for logconcave). } -#' \item{\code{negative_logprob} }{ Negative log-probability (for logconcave). } -#' \item{\code{negative_logprob_gradient} }{ Negative log-probability gradient (for logconcave). } -#' } -#' @param seed Optional. A fixed seed for the number generator. -#' -#' @references \cite{Robert L. Smith, -#' \dQuote{Efficient Monte Carlo Procedures for Generating Points Uniformly Distributed Over Bounded Regions,} \emph{Operations Research,} 1984.}, -#' -#' @references \cite{B.T. Polyak, E.N. Gryazina, -#' \dQuote{Billiard walk - a new sampling algorithm for control and optimization,} \emph{IFAC Proceedings Volumes,} 2014.}, -#' -#' @references \cite{Y. Chen, R. Dwivedi, M. J. Wainwright and B. Yu, -#' \dQuote{Fast MCMC Sampling Algorithms on Polytopes,} \emph{Journal of Machine Learning Research,} 2018.} -#' -#' @references \cite{Lee, Yin Tat, Ruoqi Shen, and Kevin Tian, -#' \dQuote{"Logsmooth Gradient Concentration and Tighter Runtimes for Metropolized Hamiltonian Monte Carlo,"} \emph{arXiv preprint arXiv:2002.04121}, 2020.} -#' -#' @references \cite{Shen, Ruoqi, and Yin Tat Lee, -#' \dQuote{"The randomized midpoint method for log-concave sampling.",} \emph{Advances in Neural Information Processing Systems}, 2019.} -#' -#' @references \cite{Augustin Chevallier, Sylvain Pion, Frederic Cazals, -#' \dQuote{"Hamiltonian Monte Carlo with boundary reflections, and application to polytope volume calculations,"} \emph{Research Report preprint hal-01919855}, 2018.} -#' -#' @return A \eqn{d\times n} matrix that contains, column-wise, the sampled points from the convex polytope P. -#' @examples -#' # uniform distribution from the 3d unit cube in H-representation using ball walk -#' P = gen_cube(3, 'H') -#' points = sample_points(P, n = 100, random_walk = list("walk" = "BaW", "walk_length" = 5)) -#' -#' # gaussian distribution from the 2d unit simplex in H-representation with variance = 2 -#' A = matrix(c(-1,0,0,-1,1,1), ncol=2, nrow=3, byrow=TRUE) -#' b = c(0,0,1) -#' P = Hpolytope$new(A,b) -#' points = sample_points(P, n = 100, distribution = list("density" = "gaussian", "variance" = 2)) -#' -#' # uniform points from the boundary of a 2-dimensional random H-polytope -#' P = gen_rand_hpoly(2,20) -#' points = sample_points(P, n = 100, random_walk = list("walk" = "BRDHR")) -#' -#' # For sampling from logconcave densities see the examples directory -#' -#' @export -sample_points <- function(P, n, random_walk = NULL, distribution = NULL, seed = NULL) { - .Call(`_volesti_sample_points`, P, n, random_walk, distribution, seed) -} - -#' Write a SDPA format file -#' -#' Outputs a spectrahedron (the matrices defining a linear matrix inequality) and a vector (the objective function) -#' to a SDPA format file. -#' -#' @param spectrahedron A spectrahedron in n dimensions; must be an object of class Spectrahedron -#' @param objectiveFunction A numerical vector of length n -#' @param outputFile Name of the output file -#' -#' @examples -#' \dontrun{ -#' A0 = matrix(c(-1,0,0,0,-2,1,0,1,-2), nrow=3, ncol=3, byrow = TRUE) -#' A1 = matrix(c(-1,0,0,0,0,1,0,1,0), nrow=3, ncol=3, byrow = TRUE) -#' A2 = matrix(c(0,0,-1,0,0,0,-1,0,0), nrow=3, ncol=3, byrow = TRUE) -#' lmi = list(A0, A1, A2) -#' S = Spectrahedron$new(lmi); -#' objFunction = c(1,1) -#' writeSdpaFormatFile(S, objFunction, "output.txt") -#' } -#' @export -writeSdpaFormatFile <- function(spectrahedron = NULL, objectiveFunction = NULL, outputFile = NULL) { - invisible(.Call(`_volesti_writeSdpaFormatFile`, spectrahedron, objectiveFunction, outputFile)) -} - -#' Read a SDPA format file -#' -#' @param inputFile Name of the input file -#' -#' @return A list with two named items: an item "matrices" which is a list of the matrices and an vector "objFunction" -#' -#' @examples -#' path = system.file('extdata', package = 'volesti') -#' l = loadSdpaFormatFile(paste0(path,'/sdpa_n2m3.txt')) -#' @export -loadSdpaFormatFile <- function(inputFile = NULL) { - .Call(`_volesti_loadSdpaFormatFile`, inputFile) -} - -#' The main function for volume approximation of a convex Polytope (H-polytope, V-polytope, zonotope or intersection of two V-polytopes). It returns a list with two elements: (a) the logarithm of the estimated volume and (b) the estimated volume -#' -#' For the volume approximation can be used three algorithms. Either CoolingBodies (CB) or SequenceOfBalls (SOB) or CoolingGaussian (CG). An H-polytope with \eqn{m} facets is described by a \eqn{m\times d} matrix \eqn{A} and a \eqn{m}-dimensional vector \eqn{b}, s.t.: \eqn{P=\{x\ |\ Ax\leq b\} }. A V-polytope is defined as the convex hull of \eqn{m} \eqn{d}-dimensional points which correspond to the vertices of P. A zonotope is desrcibed by the Minkowski sum of \eqn{m} \eqn{d}-dimensional segments. -#' -#' @param P A convex polytope. It is an object from class a) Hpolytope or b) Vpolytope or c) Zonotope or d) VpolytopeIntersection. -#' @param settings Optional. A list that declares which algorithm, random walk and values of parameters to use, as follows: -#' \itemize{ -#' \item{\code{algorithm} }{ A string to set the algorithm to use: a) \code{'CB'} for CB algorithm, b) \code{'SoB'} for SOB algorithm or b) \code{'CG'} for CG algorithm. The defalut algorithm is \code{'CB'}.} -#' \item{\code{error} }{ A numeric value to set the upper bound for the approximation error. The default value is \eqn{1} for SOB algorithm and \eqn{0.1} otherwise.} -#' \item{\code{random_walk} }{ A string that declares the random walk method: a) \code{'CDHR'} for Coordinate Directions Hit-and-Run, b) \code{'RDHR'} for Random Directions Hit-and-Run, c) \code{'BaW'} for Ball Walk, or \code{'BiW'} for Billiard walk. For CB algorithm the default walk is \code{'BiW'}. For CG and SOB algorithms the default walk is \code{'CDHR'} for H-polytopes and \code{'RDHR'} for the other representations.} -#' \item{\code{walk_length} }{ An integer to set the number of the steps for the random walk. The default value is \eqn{\lfloor 10 + d/10\rfloor} for \code{'SOB'} and \eqn{1} otherwise.} -#' \item{\code{win_len} }{ The length of the sliding window for CB or CG algorithm. The default value is \eqn{250} for CB with BiW and \eqn{400+3d^2} for CB and any other random walk and \eqn{500+4d^2} for CG.} -#' \item{\code{hpoly} }{ A boolean parameter to use H-polytopes in MMC of CB algorithm when the input polytope is a zonotope. The default value is \code{TRUE} when the order of the zonotope is \eqn{<5}, otherwise it is \code{FALSE}.} -#' } -#' @param rounding Optional. A string parameter to request a rounding method to be applied in the input polytope before volume computation: a) \code{'min_ellipsoid'}, b) \code{'svd'}, c) \code{'max_ellipsoid'} and d) \code{'none'} for no rounding. -#' @param seed Optional. A fixed seed for the number generator. -#' -#' @references \cite{I.Z.Emiris and V. Fisikopoulos, -#' \dQuote{Practical polytope volume approximation,} \emph{ACM Trans. Math. Soft.,} 2018.}, -#' @references \cite{A. Chalkis and I.Z.Emiris and V. Fisikopoulos, -#' \dQuote{Practical Volume Estimation by a New Annealing Schedule for Cooling Convex Bodies,} \emph{CoRR, abs/1905.05494,} 2019.}, -#' @references \cite{B. Cousins and S. Vempala, \dQuote{A practical volume algorithm,} \emph{Springer-Verlag Berlin Heidelberg and The Mathematical Programming Society,} 2015.} -#' -#' -#' @return The approximation of the volume of a convex polytope. -#' @examples -#' -#' # calling SOB algorithm for a H-polytope (5d unit simplex) -#' HP = gen_cube(5,'H') -#' pair_vol = volume(HP) -#' -#' # calling CG algorithm for a V-polytope (3d simplex) -#' VP = gen_simplex(3,'V') -#' pair_vol = volume(VP, settings = list("algorithm" = "CG")) -#' -#' # calling CG algorithm for a 2-dimensional zonotope defined as the Minkowski sum of 4 segments -#' Z = gen_rand_zonotope(2, 4) -#' pair_vol = volume(Z, settings = list("random_walk" = "RDHR", "walk_length" = 2)) -#' -#' @export -volume <- function(P, settings = NULL, rounding = NULL, seed = NULL) { - .Call(`_volesti_volume`, P, settings, rounding, seed) -} - -#' An internal Rccp function for the over-approximation of a zonotope -#' -#' @param Z A zonotope. -#' @param fit_ratio Optional. A boolean parameter to request the computation of the ratio of fitness. -#' @param settings Optional. A list that declares the values of the parameters of CB algorithm. -#' @param seed Optional. A fixed seed for the number generator. -#' -#' @keywords internal -#' -#' @return A List that contains a numerical matrix that describes the PCA approximation as a H-polytope and the ratio of fitness. -zono_approx <- function(Z, fit_ratio = NULL, settings = NULL, seed = NULL) { - .Call(`_volesti_zono_approx`, Z, fit_ratio, settings, seed) -} - diff --git a/R-proj/R/compute_indicators.R b/R-proj/R/compute_indicators.R deleted file mode 100644 index fe82cdee3..000000000 --- a/R-proj/R/compute_indicators.R +++ /dev/null @@ -1,104 +0,0 @@ -#' Compute an indicator for each time period that describes the state of a market. -#' -#' Given a matrix that contains row-wise the assets' returns and a sliding window \code{win_length}, this function computes an approximation of the joint distribution (copula, e.g. see \url{https://en.wikipedia.org/wiki/Copula_(probability_theory)}) between portfolios' return and volatility in each time period defined by \code{win_len}. -#' For each copula it computes an indicator: If the indicator is large it corresponds to a crisis period and if it is small it corresponds to a normal period. -#' In particular, the periods over which the indicator is greater than 1 for more than 60 consecutive sliding windows are warnings and for more than 100 are crisis. The sliding window is shifted by one day. -#' -#' @param returns A \eqn{d}-dimensional vector that describes the direction of the first family of parallel hyperplanes. -#' @param win_length Optional. The length of the sliding window. The default value is 60. -#' @param m Optional. The number of slices for the copula. The default value is 100. -#' @param n Optional. The number of points to sample. The default value is \eqn{5\cdot 10^5}. -#' @param nwarning Optional. The number of consecutive indicators larger than 1 required to declare a warning period. The default value is 60. -#' @param ncrisis Optional. The number of consecutive indicators larger than 1 required to declare a crisis period. The default value is 100. -#' @param seed Optional. A fixed seed for the number generator. -#' -#' @references \cite{L. Cales, A. Chalkis, I.Z. Emiris, V. Fisikopoulos, -#' \dQuote{Practical volume computation of structured convex bodies, and an application to modeling portfolio dependencies and financial crises,} \emph{Proc. of Symposium on Computational Geometry, Budapest, Hungary,} 2018.} -#' -#' @return A list that contains the indicators and the corresponding vector that label each time period with respect to the market state: a) normal, b) crisis, c) warning. -#' -#' @examples -#' # simple example on random asset returns -#' asset_returns = replicate(10, rnorm(14)) -#' market_states_and_indicators = compute_indicators(asset_returns, 10, 10, 10000, 2, 3) -#' -#' @export -compute_indicators <- function(returns, win_length = NULL, m = NULL, n = NULL, nwarning = NULL, ncrisis = NULL, seed = NULL) { - - if (is.null(win_length)) win_length = 60 - if (is.null(m)) m = 100 - if (is.null(n)) n = 500000 - if (is.null(nwarning)) nwarning = 60 - if (is.null(ncrisis)) ncrisis = 100 - - nrows = dim(returns)[1] - nassets = dim(returns)[2] - wl = win_length-1 - - indicators = c() - for (i in 1:(nrows-wl)) { - - Win=i:(i+wl) - E = cov(returns[Win,]) - - compRet = rep(1,nassets) - for (j in 1:nassets) { - for (k in Win) { - compRet[j] = compRet[j] * (1 + returns[k, j]) - } - compRet[j] = compRet[j] - 1 - } - - cop = copula(r1 = compRet, sigma = E, m = m, n = n, seed = seed) - blue_mass = 0 - red_mass = 0 - - for (row in 1:m) { - for (col in 1:m) { - if (row-col<=0.2*m && row-col>=-0.2*m) { - if (row+col<0.8*m || row+col>1.2*m) { - red_mass = red_mass + cop[row,col] - } - } else { - if (row+col>=0.8*m+1 && row+col<=1.2*m+1) { - blue_mass = blue_mass + cop[row,col] - } - } - } - } - indicators = c(indicators, blue_mass / red_mass) - } - - N = length(indicators) - - index = 0 - set_index = FALSE - col = rep("normal", N) - - for (i in 1:N) { - - if(indicators[i]>1 && !set_index){ - index = i - set_index = TRUE - } else if (indicators[i]<1) { - if(set_index){ - if(i-index > nwarning-1 && i-index <= ncrisis-1){ - col[index:(i-1)] = "warning" - } else if(i-index > ncrisis-1) { - col[index:(i-1)] = "crisis" - } - } - set_index = FALSE - } - } - if(set_index){ - if(N-index+1 > nwarning-1 && N-index+1 <= ncrisis-1){ - col[index:i] = "warning" - } else if(N-index+1 > ncrisis-1) { - col[index:i] = "crisis" - } - } - - return(list("indicators" = indicators, market_states = col)) - -} diff --git a/R-proj/R/estimate_lipschitz_constant.R b/R-proj/R/estimate_lipschitz_constant.R deleted file mode 100644 index c1fac15e0..000000000 --- a/R-proj/R/estimate_lipschitz_constant.R +++ /dev/null @@ -1,53 +0,0 @@ -#' Inverse weibull distribution PDF with location parameter -#' @param x The argument of the PDF -#' @param k The shape parameter -#' @param lambda The scale parameter -#' @param theta The location parameter -#' -#' @return The value of the PDF of an Inverse Weibull distribution with parameters k, lambda, theta evaluated at x -#' @export -dinvweibull_with_loc <- function (x, k, lambda, theta) { - return ((k / lambda) * ((x - theta) / lambda)^(k - 1) * exp(- ((x - theta) / lambda)^k) * as.double(x >= 0)) -} - -#' Inverse weibull distribution CDF with location parameter -#' @param q The argument of the CDF -#' @param k The shape parameter -#' @param lambda The scale parameter -#' @param theta The location parameter -#' -#' @return The value of the CDF of an Inverse Weibull distribution with parameters k, lambda, theta evaluated at q -#' @export -pinvweibull_with_loc <- function (q, k, lambda, theta) { - return ((1 - exp(-((q - theta) / lambda)^k)) * as.double(q >= 0)) -} - - -#' Estimate the Lipschitz Constant of a function f -#' -#' @param f Function whose Lipschitz constant is to be estimated -#' @param P Domain of f (a convex polytope) -#' @param n Number of samples to take -#' -#' The procedure draws n uniform samples from P and evaluates the Lipschitz -#' constant at subsequent samples (where the sampler moves to a new point), -#' It then returns the maximum observation -#' -#' @return An estimate of the Lipschitz constant -#' -#' @export -estimtate_lipschitz_constant <- function (f, P, n) { - points = volesti::sample_points(P, n = 1000, random_walk = list("walk" = "BaW", "walk_length" = 1)) - l = matrix(0, 1, n-1) - - for (i in seq(n-1)) { - l[1, i] <- norm(as.matrix(f(points[,i+1])) - as.matrix(f(points[,i])), type='F') / norm(as.matrix(points[,i+1]) - as.matrix(points[,i]), type='F') - } - - na_cols <- is.nan(l[1,]) - - l <- as.matrix(l[1, !na_cols]) - - # TODO Implement weibull distribution fitting method to estimate the Lipschitz constant - return(max(l)) -} \ No newline at end of file diff --git a/R-proj/R/file_to_polytope.R b/R-proj/R/file_to_polytope.R deleted file mode 100644 index 19dd61acf..000000000 --- a/R-proj/R/file_to_polytope.R +++ /dev/null @@ -1,113 +0,0 @@ -#' function to get an ine or an ext file and returns the corresponding polytope -#' -#' For an ".ine" file it generates the corresponding H-polytope. For an ".ext" file it generates the corresponding V-polytope or zonotope. -#' For more details on those file formats see \url{https://github.com/GeomScale/volume_approximation/blob/develop/doc/cpp_interface.md#polytope-input}. -#' -#' @param path A string that containes the path to an ine or a ext file. The ine file desrcibes a H-polytope and ext file describes a V-polytope or a zonotope. -#' @param zonotope A boolean parameter. It has to be TRUE when the path leads to an .ext file that describes a zonotope. -#' -#' @return A polytope class. If the path corresponds to an ine file then the return value represents a H-polytope. If it corresponds to an ext file the return value represents a V-polytope (default choice) or a zonotope if the second argument is TRUE. -#' -#' @export -#' @useDynLib volesti, .registration=TRUE -#' @importFrom Rcpp evalCpp -#' @importFrom Rcpp loadModule -#' @importFrom "utils" "read.csv" -#' @importFrom "stats" "cov" -#' @importFrom "methods" "new" -#' @exportPattern "^[[:alpha:]]+" -file_to_polytope <- function(path, zonotope = FALSE){ - - ineorext=substr(path, start = nchar(path) - 2, stop = nchar(path)) - if(ineorext!="ine" && ineorext!="ext") { - stop("Only ine or ext files can be handled by this function!") - } - P = read.csv(path) - r = as.character(P[3,1]) - count_sp = 1 - str = "" - beg = 0 - for (j in 1:nchar(r)) { - if (substr(r, start=j, stop=j) == " ") { - beg = beg + 1 - } else { - break - } - } - for (i in seq(from= beg + 1, to=nchar(r), by=1)) { - if (substr(r, start=i, stop=i) == " ") { - if (count_sp == 1) { - m = as.numeric(str) - str = "" - count_sp = count_sp + 1 - } else { - d = as.numeric(str) - str = "" - break - } - } else { - str = paste0(str, substr(r, start=i, stop=i)) - } - } - A = rep(0,d) - A[1] = m - A[2] = d - newrow = rep(0,d) - for (i in 4:(dim(P)[1] - 2)) { - r = P[i,1] - r = as.character(r) - str = "" - count = 1 - beg = 0 - for (j in 1:nchar(r)) { - if(substr(r, start=j, stop=j)==" "){ - beg = beg + 1 - } else { - break - } - } - sp_bef = FALSE - for (j in seq(from=beg + 1, to=nchar(r), by=1)) { - if (substr(r, start=j, stop=j) == " "){ - if (sp_bef) { - next - } - sp_bef = TRUE - newrow[count] = as.numeric(str) - str = "" - count = count + 1 - } else { - str = paste0(str, substr(r, start=j, stop=j)) - sp_bef = FALSE - if (j == nchar(r)) { - newrow[count] = as.numeric(str) - } - } - } - A = rbind(A,newrow) - newrow = rep(0,d) - } - A = matrix(A, ncol=dim(A)[2]) # now matrix A is in ine or ext format - - # remove first row - A = A[-c(1),] - - # first column is the vector b - b = A[,1] - - # remove first column - A2 = A[,-c(1)] - - if(ineorext=="ine") { - P = Hpolytope$new(-A2,b) - } else { - if(!missing(zonotope)){ - if(zonotope) { - P = Zonotope$new(A2) - return(P) - } - } - P = Vpolytope$new(A2) - } - return(P) -} diff --git a/R-proj/R/gen_birkhoff.R b/R-proj/R/gen_birkhoff.R deleted file mode 100644 index 935f637e2..000000000 --- a/R-proj/R/gen_birkhoff.R +++ /dev/null @@ -1,28 +0,0 @@ -#' Generator function for Birkhoff polytope -#' -#' This function can be used to generate the full dimensional \eqn{n}-Birkhoff polytope in H-representation. -#' The dimension of the generated polytope is \eqn{(n-1)^2}. -#' -#' @param n The order of the Birkhoff polytope -#' -#' @return A polytope class representing the full dimensional \eqn{n}-Birkhoff polytope in H-representation. -#' @examples -#' # generate the Birkhoff polytope of order 5 -#' P = gen_birkhoff(5) -#' @export -gen_birkhoff <- function(n) { - - kind_gen = 7 - m_gen = 0 - - Mat = poly_gen(kind_gen, FALSE, FALSE, n, m_gen) - - # first column is the vector b - b = Mat[,1] - Mat = Mat[,-c(1)] - - P = Hpolytope$new(Mat, b) - - return(P) - -} diff --git a/R-proj/R/gen_cross.R b/R-proj/R/gen_cross.R deleted file mode 100644 index d782f3991..000000000 --- a/R-proj/R/gen_cross.R +++ /dev/null @@ -1,41 +0,0 @@ -#' Generator function for cross polytopes -#' -#' This function generates the \eqn{d}-dimensional cross polytope in H- or V-representation. -#' -#' @param dimension The dimension of the cross polytope. -#' @param representation A string to declare the representation. It has to be \code{'H'} for H-representation or \code{'V'} for V-representation. -#' -#' @return A polytope class representing a cross polytope in H- or V-representation. -#' @examples -#' # generate a 10-dimensional cross polytope in H-representation -#' P = gen_cross(5, 'H') -#' -#' # generate a 15-dimension cross polytope in V-representation -#' P = gen_cross(15, 'V') -#' @export -gen_cross <- function(dimension, representation) { - - kind_gen = 2 - m_gen = 0 - if (representation == "V") { - Vpoly_gen = TRUE - } else if (representation == "H") { - Vpoly_gen = FALSE - } else { - stop('Not a known representation.') - } - - Mat = poly_gen(kind_gen, Vpoly_gen, FALSE, dimension, m_gen) - - # first column is the vector b - b = Mat[,1] - Mat = Mat[,-c(1)] - - if (Vpoly_gen) { - P = Vpolytope$new(Mat, 2^dimension / prod(1:dimension)) - } else { - P = Hpolytope$new(-Mat, b, 2^dimension / prod(1:dimension)) - } - - return(P) -} diff --git a/R-proj/R/gen_cube.R b/R-proj/R/gen_cube.R deleted file mode 100644 index bcbf1f025..000000000 --- a/R-proj/R/gen_cube.R +++ /dev/null @@ -1,41 +0,0 @@ -#' Generator function for hypercubes -#' -#' This function generates the \eqn{d}-dimensional unit hypercube \eqn{[-1,1]^d} in H- or V-representation. -#' -#' @param dimension The dimension of the hypercube -#' @param representation A string to declare the representation. It has to be \code{'H'} for H-representation or \code{'V'} for V-representation. -#' -#' @return A polytope class representing the unit \eqn{d}-dimensional hypercube in H- or V-representation. -#' @examples -#' # generate a 10-dimensional hypercube in H-representation -#' P = gen_cube(10, 'H') -#' -#' # generate a 15-dimension hypercube in V-representation -#' P = gen_cube(5, 'V') -#' @export -gen_cube <- function(dimension, representation) { - - kind_gen = 1 - m_gen = 0 - if (representation == "V") { - Vpoly_gen = TRUE - } else if (representation == "H") { - Vpoly_gen = FALSE - } else { - stop('Not a known representation.') - } - - Mat = poly_gen(kind_gen, Vpoly_gen, FALSE, dimension, m_gen) - - # first column is the vector b - b = Mat[,1] - Mat = Mat[,-c(1)] - if (Vpoly_gen) { - P = Vpolytope$new(Mat, 2^dimension) - } else { - P = Hpolytope$new(-Mat, b, 2^dimension) - } - - return(P) - -} diff --git a/R-proj/R/gen_prod_simplex.R b/R-proj/R/gen_prod_simplex.R deleted file mode 100644 index a0505880c..000000000 --- a/R-proj/R/gen_prod_simplex.R +++ /dev/null @@ -1,29 +0,0 @@ -#' Generator function for product of simplices -#' -#' This function generates a \eqn{2d}-dimensional polytope that is defined as the product of two \eqn{d}-dimensional unit simplices in H-representation. -#' -#' @param dimension The dimension of the simplices. -#' -#' @return A polytope class representing the product of the two \eqn{d}-dimensional unit simplices in H-representation. -#' -#' @examples -#' # generate a product of two 5-dimensional simplices. -#' P = gen_prod_simplex(5) -#' @export -gen_prod_simplex <- function(dimension) { - - kind_gen = 4 - m_gen = 0 - Vpoly_gen = FALSE - - Mat = poly_gen(kind_gen, Vpoly_gen, FALSE, dimension, m_gen) - - # first column is the vector b - b = Mat[,1] - Mat = Mat[,-c(1)] - - P = Hpolytope$new(-Mat, b, (1/prod(1:dimension))^2) - - return(P) - -} diff --git a/R-proj/R/gen_rand_hpoly.R b/R-proj/R/gen_rand_hpoly.R deleted file mode 100644 index 2785a28b4..000000000 --- a/R-proj/R/gen_rand_hpoly.R +++ /dev/null @@ -1,28 +0,0 @@ -#' Generator function for random H-polytopes -#' -#' This function generates a \eqn{d}-dimensional polytope in H-representation with \eqn{m} facets. We pick \eqn{m} random hyperplanes tangent on the \eqn{d}-dimensional unit hypersphere as facets. -#' -#' @param dimension The dimension of the convex polytope. -#' @param nfacets The number of the facets. -#' @param seed Optional. A fixed seed for the generator. -#' -#' @return A polytope class representing a H-polytope. -#' @examples -#' # generate a 10-dimensional polytope with 50 facets -#' P = gen_rand_hpoly(10, 50) -#' @export -gen_rand_hpoly <- function(dimension, nfacets, seed = NULL) { - - kind_gen = 6 - Vpoly_gen = FALSE - - Mat = poly_gen(kind_gen, Vpoly_gen, FALSE, dimension, nfacets, seed) - - # first column is the vector b - b = Mat[,1] - Mat = Mat[,-c(1)] - - P = Hpolytope$new(Mat, b) - - return(P) -} diff --git a/R-proj/R/gen_rand_vpoly.R b/R-proj/R/gen_rand_vpoly.R deleted file mode 100644 index 31cc561c0..000000000 --- a/R-proj/R/gen_rand_vpoly.R +++ /dev/null @@ -1,36 +0,0 @@ -#' Generator function for random V-polytopes -#' -#' This function generates a \eqn{d}-dimensional polytope in V-representation with \eqn{m} vertices. We pick \eqn{m} random points from the boundary of the \eqn{d}-dimensional unit hypersphere as vertices. -#' -#' @param dimension The dimension of the convex polytope. -#' @param nvertices The number of the vertices. -#' @param generator The body that the generator samples uniformly the vertices from: (a) 'cube' or (b) 'sphere'. -#' @param seed Optional. A fixed seed for the generator. -#' -#' @return A polytope class representing a V-polytope. -#' @examples -#' # generate a 10-dimensional polytope defined as the convex hull of 25 random vertices -#' P = gen_rand_vpoly(10, 25) -#' @export -gen_rand_vpoly <- function(dimension, nvertices, generator = NULL, seed = NULL) { - - kind_gen = 4 - - if(!is.null(generator)){ - if (generator == 'cube'){ - kind_gen = 5 - } else if (generator != 'sphere') { - stop("Wrong generator!") - } - } - - Mat = poly_gen(kind_gen, TRUE, FALSE, dimension, nvertices, seed) - - # first column is the vector b - b = Mat[,1] - Mat = Mat[,-c(1)] - - P = Vpolytope$new(Mat) - - return(P) -} diff --git a/R-proj/R/gen_rand_zonotope.R b/R-proj/R/gen_rand_zonotope.R deleted file mode 100644 index 3a2c8c1b2..000000000 --- a/R-proj/R/gen_rand_zonotope.R +++ /dev/null @@ -1,40 +0,0 @@ -#' Generator function for zonotopes -#' -#' This function generates a random \eqn{d}-dimensional zonotope defined by the Minkowski sum of \eqn{m} \eqn{d}-dimensional segments. -#' The function considers \eqn{m} random directions in \eqn{R^d}. There are three strategies to pick the length of each segment: a) it is uniformly sampled from \eqn{[0,100]}, b) it is random from \eqn{\mathcal{N}(50,(50/3)^2)} truncated to \eqn{[0,100]}, c) it is random from \eqn{Exp(1/30)} truncated to \eqn{[0,100]}. -#' -#' @param dimension The dimension of the zonotope. -#' @param nsegments The number of segments that generate the zonotope. -#' @param generator The distribution to pick the length of each segment from \eqn{[0,100]}: (a) 'uniform', (b) 'gaussian' or (c) 'exponential'. -#' @param seed Optional. A fixed seed for the generator. -#' -#' @return A polytope class representing a zonotope. -#' -#' @examples -#' # generate a 10-dimensional zonotope defined by the Minkowski sum of 20 segments -#' P = gen_rand_zonotope(10, 20) -#' @export -gen_rand_zonotope <- function(dimension, nsegments, generator = NULL, seed = NULL) { - - kind_gen = 1 - - if (!is.null(generator)) { - if (generator == 'gaussian') { - kind_gen = 2 - } else if (generator == 'exponential') { - kind_gen = 3 - } else if (generator != 'uniform'){ - stop("Wrong generator!") - } - } - - Mat = poly_gen(kind_gen, FALSE, TRUE, dimension, nsegments, seed) - - # first column is the vector b - b = Mat[,1] - Mat = Mat[,-c(1)] - - P = Zonotope$new(Mat) - - return(P) -} diff --git a/R-proj/R/gen_simplex.R b/R-proj/R/gen_simplex.R deleted file mode 100644 index aa2ca4a6a..000000000 --- a/R-proj/R/gen_simplex.R +++ /dev/null @@ -1,41 +0,0 @@ -#' Generator function for simplices -#' -#' This function generates the \eqn{d}-dimensional unit simplex in H- or V-representation. -#' -#' @param dimension The dimension of the unit simplex. -#' @param representation A string to declare the representation. It has to be \code{'H'} for H-representation or \code{'V'} for V-representation. -#' -#' @return A polytope class representing the \eqn{d}-dimensional unit simplex in H- or V-representation. -#' @examples -#' # generate a 10-dimensional simplex in H-representation -#' PolyList = gen_simplex(10, 'H') -#' -#' # generate a 20-dimensional simplex in V-representation -#' P = gen_simplex(20, 'V') -#' @export -gen_simplex <- function(dimension, representation) { - - kind_gen = 3 - m_gen = 0 - if (representation == "V") { - Vpoly_gen = TRUE - } else if (representation == "H") { - Vpoly_gen = FALSE - } else { - stop('Not a known representation.') - } - - Mat = poly_gen(kind_gen, Vpoly_gen, FALSE, dimension, m_gen) - - # first column is the vector b - b = Mat[,1] - Mat = Mat[,-c(1)] - - if (Vpoly_gen) { - P = Vpolytope$new(Mat, 1/prod(1:dimension)) - } else { - P = Hpolytope$new(-Mat, b, 1/prod(1:dimension)) - } - - return(P) -} diff --git a/R-proj/R/gen_skinny_cube.R b/R-proj/R/gen_skinny_cube.R deleted file mode 100644 index 0a1df0eb0..000000000 --- a/R-proj/R/gen_skinny_cube.R +++ /dev/null @@ -1,28 +0,0 @@ -#' Generator function for skinny hypercubes -#' -#' This function generates a \eqn{d}-dimensional skinny hypercube \eqn{[-1,1]^{d-1}\times [-100,100]}. -#' -#' @param dimension The dimension of the skinny hypercube. -#' -#' @return A polytope class representing the \eqn{d}-dimensional skinny hypercube in H-representation. -#' -#' @examples -#' # generate a 10-dimensional skinny hypercube. -#' P = gen_skinny_cube(10) -#' @export -gen_skinny_cube <- function(dimension) { - - kind_gen = 5 - m_gen = 0 - Vpoly_gen = FALSE - - Mat = poly_gen(kind_gen, Vpoly_gen, FALSE, dimension, m_gen) - - # first column is the vector b - b = Mat[,1] - Mat = Mat[,-c(1)] - - P = Hpolytope$new(-Mat, b, 2^(dimension -1)*200) - - return(P) -} diff --git a/R-proj/R/read_sdpa_file.R b/R-proj/R/read_sdpa_file.R deleted file mode 100644 index 83c10c528..000000000 --- a/R-proj/R/read_sdpa_file.R +++ /dev/null @@ -1,26 +0,0 @@ -#' Read a SDPA format file -#' -#' Read a SDPA format file and return a spectrahedron (an object of class Spectrahedron) which is defined by -#' the linear matrix inequality in the input file, and the objective function. -#' -#' @param path Name of the input file -#' -#' @return A list with two named items: an item "matrices" which is an object of class Spectrahedron and an vector "objFunction" -#' -#' @examples -#' path = system.file('extdata', package = 'volesti') -#' l = readSdpaFormatFile(paste0(path,'/sdpa_n2m3.txt')) -#' Spectrahedron = l$spectrahedron -#' objFunction = l$objFunction -#' @export -#' @useDynLib volesti, .registration=TRUE -#' @importFrom Rcpp evalCpp -#' @importFrom Rcpp loadModule -#' @importFrom "methods" "new" -#' @exportPattern "^[[:alpha:]]+" -readSdpaFormatFile <- function(path){ - l = loadSdpaFormatFile(path) - S = Spectrahedron$new(l$matrices) - - return(list("spectrahedron"=S, "objFunction"= l$objFunction)) -} diff --git a/R-proj/R/rotate_polytope.R b/R-proj/R/rotate_polytope.R deleted file mode 100644 index 12ce246b8..000000000 --- a/R-proj/R/rotate_polytope.R +++ /dev/null @@ -1,57 +0,0 @@ -#' Apply a random rotation to a convex polytope (H-polytope, V-polytope, zonotope or intersection of two V-polytopes) -#' -#' Given a convex H- or V- polytope or a zonotope or an intersection of two V-polytopes as input, this function applies (a) a random rotation or (b) a given rotation by an input matrix \eqn{T}. -#' -#' @param P A convex polytope. It is an object from class (a) Hpolytope, (b) Vpolytope, (c) Zonotope, (d) intersection of two V-polytopes. -#' @param T Optional. A \eqn{d\times d} rotation matrix. -#' @param seed Optional. A fixed seed for the random linear map generator. -#' -#' @return A list that contains the rotated polytope and the matrix \eqn{T} of the linear transformation. -#' -#' @details Let \eqn{P} be the given polytope and \eqn{Q} the rotated one and \eqn{T} be the matrix of the linear transformation. -#' \itemize{ -#' \item{If \eqn{P} is in H-representation and \eqn{A} is the matrix that contains the normal vectors of the facets of \eqn{Q} then \eqn{AT} contains the normal vactors of the facets of \eqn{P}.} -#' \item{If \eqn{P} is in V-representation and \eqn{V} is the matrix that contains column-wise the vertices of \eqn{Q} then \eqn{T^TV} contains the vertices of \eqn{P}.} -#' \item{If \eqn{P} is a zonotope and \eqn{G} is the matrix that contains column-wise the generators of \eqn{Q} then \eqn{T^TG} contains the generators of \eqn{P}.} -#' \item{If \eqn{M} is a matrix that contains column-wise points in \eqn{Q} then \eqn{T^TM} contains points in \eqn{P}.} -#' } -#' @examples -#' # rotate a H-polytope (2d unit simplex) -#' P = gen_simplex(2,'H') -#' poly_matrix_list = rotate_polytope(P) -#' -#' # rotate a V-polytope (3d cube) -#' P = gen_cube(3, 'V') -#' poly_matrix_list = rotate_polytope(P) -#' -#' # rotate a 5-dimensional zonotope defined by the Minkowski sum of 15 segments -#' Z = gen_rand_zonotope(3,6) -#' poly_matrix_list = rotate_polytope(Z) -#' @export -rotate_polytope <- function(P, T = NULL, seed = NULL){ - - #call rcpp rotating function - Mat = rotating(P, T, seed) - - n = P$dimension - m=dim(Mat)[2]-n - Tr = Mat[,-c(1:(dim(Mat)[2]-n))] - Tr = Tr[1:n, 1:n] - Mat = t(Mat[,1:m]) - - # first column is the vector b - b = Mat[,1] - - # remove first column - A = Mat[,-c(1)] - - type = P$type - if (type == 2) { - PP = Vpolytope$new(A) - }else if (type == 3) { - PP = Zonotope$new(A) - } else { - PP = Hpolytope$new(A, b) - } - return(list("P" = PP, "T" = Tr)) -} diff --git a/R-proj/R/round_polytope.R b/R-proj/R/round_polytope.R deleted file mode 100644 index f95649c66..000000000 --- a/R-proj/R/round_polytope.R +++ /dev/null @@ -1,60 +0,0 @@ -#' Apply rounding to a convex polytope (H-polytope, V-polytope or a zonotope) -#' -#' Given a convex H or V polytope or a zonotope as input this function brings the polytope in rounded position based on minimum volume enclosing ellipsoid of a pointset. -#' -#' @param P A convex polytope. It is an object from class (a) Hpolytope or (b) Vpolytope or (c) Zonotope. -#' @param method Optional. The method to use for rounding, a) \code{'min_ellipsoid'} for the method based on mimimmum volume enclosing ellipsoid of a dataset, b) \code{'max_ellipsoid'} for the method based on maximum volume enclosed ellipsoid, (c) \code{'isotropy'} for the method based on svd decomposition. The default method is \code{'mee'} for all the representations. -#' @param seed Optional. A fixed seed for the number generator. -#' -#' @return A list with 4 elements: (a) a polytope of the same class as the input polytope class and (b) the element "T" which is the matrix of the inverse linear transformation that is applied on the input polytope, (c) the element "shift" which is the opposite vector of that which has shifted the input polytope, (d) the element "round_value" which is the determinant of the square matrix of the linear transformation that is applied on the input polytope. -#' -#' @references \cite{I.Z.Emiris and V. Fisikopoulos, -#' \dQuote{Practical polytope volume approximation,} \emph{ACM Trans. Math. Soft.,} 2018.}, -#' @references \cite{Michael J. Todd and E. Alper Yildirim, -#' \dQuote{On Khachiyan’s Algorithm for the Computation of Minimum Volume Enclosing Ellipsoids,} \emph{Discrete Applied Mathematics,} 2007.} -#' @references \cite{B. Cousins and S. Vempala, -#' \dQuote{A practical volume algorithm,} \emph{Math. Prog. Comp.,} 2016.}, -#' @references \cite{Yin Zhang and Liyan Gao, -#' \dQuote{On Numerical Solution of the Maximum Volume Ellipsoid Problem,} \emph{SIAM Journal on Optimization,} 2003.}, -#' -#' -#' @examples -#' # round a 5d skinny cube -#' P = gen_skinny_cube(5) -#' listHpoly = round_polytope(P) -#' -#' # round a V-polytope (3d unit cube) -#' P = gen_cube(3, 'V') -#' ListVpoly = round_polytope(P) -#' -#' # round a 2-dimensional zonotope defined by 6 generators -#' Z = gen_rand_zonotope(2,6) -#' ListZono = round_polytope(Z) -#' @export -round_polytope <- function(P, method = NULL, seed = NULL){ - - ret_list = rounding(P, method, seed) - - #get the matrix that describes the polytope - Mat = ret_list$Mat - - # first column is the vector b - b = Mat[,1] - - # remove first column - A = Mat[,-c(1)] - - type = P$type - if (type == 2) { - PP = list("P" = Vpolytope$new(A), "T" = ret_list$T, "shift" = ret_list$shift, "round_value" = ret_list$round_value) - }else if (type == 3) { - PP = list("P" = Zonotope$new(A), "T" = ret_list$T, "shift" = ret_list$shift, "round_value" = ret_list$round_value) - } else { - if (dim(P$Aeq)[1] > 0){ - PP = list("P" = Hpolytope$new(A,b), "T" = ret_list$T, "shift" = ret_list$shift, "round_value" = ret_list$round_value, "N" = ret_list$N, "N_shift" = ret_list$N_shift, "svd_prod" = ret_list$svd_prod) - } else { - PP = list("P" = Hpolytope$new(A,b), "T" = ret_list$T, "shift" = ret_list$shift, "round_value" = ret_list$round_value) - } - } - return(PP) -} diff --git a/R-proj/R/zonotope_approximation.R b/R-proj/R/zonotope_approximation.R deleted file mode 100644 index 8c56f6d23..000000000 --- a/R-proj/R/zonotope_approximation.R +++ /dev/null @@ -1,42 +0,0 @@ -#' A function to over-approximate a zonotope with PCA method and to evaluate the approximation by computing a ratio of fitness. -#' -#' For the evaluation of the PCA method the exact volume of the approximation body is computed and the volume of the input zonotope is computed by CoolingBodies algorithm. The ratio of fitness is \eqn{R=vol(P) / vol(P_{red})}, where \eqn{P_{red}} is the approximate polytope. -#' -#' @param Z A zonotope. -#' @param fit_ratio Optional. A boolean parameter to request the computation of the ratio of fitness. -#' @param settings Optional. A list that declares the values of the parameters of CB algorithm as follows: -#' \itemize{ -#' \item{\code{error} }{ A numeric value to set the upper bound for the approximation error. The default value is \eqn{0.1}.} -#' \item{\code{walk_length} }{ An integer to set the number of the steps for the random walk. The default value is \eqn{1}.} -#' \item{\code{win_len} }{ The length of the sliding window for CB algorithm. The default value is \eqn{200}.} -#' \item{\code{hpoly} }{ A boolean parameter to use H-polytopes in MMC of CB algorithm. The default value is \code{TRUE} when the order of the zonotope is \eqn{<5}, otherwise it is \code{FALSE}.} -#' } -#' @param seed Optional. A fixed seed for the number generator. -#' -#' @return A list that contains the approximation body in H-representation and the ratio of fitness -#' -#' @references \cite{A.K. Kopetzki and B. Schurmann and M. Althoff, -#' \dQuote{Methods for Order Reduction of Zonotopes,} \emph{IEEE Conference on Decision and Control,} 2017.} -#' -#' @examples -#' # over-approximate a 2-dimensional zonotope with 10 generators and compute the ratio of fitness -#' Z = gen_rand_zonotope(2,12) -#' retList = zonotope_approximation(Z = Z) -#' -#' @export -zonotope_approximation <- function(Z, fit_ratio = NULL, settings = NULL, seed = NULL){ - - ret_list = zono_approx(Z, fit_ratio, settings, seed) - - Mat = ret_list$Mat - - # first column is the vector b - b = Mat[,1] - - # remove first column - A = Mat[,-c(1)] - PP = list("P" = Hpolytope$new(A,b), "fit_ratio" = ret_list$fit_ratio) - - return(PP) - -} diff --git a/R-proj/R/zzz.R b/R-proj/R/zzz.R deleted file mode 100644 index 564a20b9c..000000000 --- a/R-proj/R/zzz.R +++ /dev/null @@ -1,11 +0,0 @@ -## Up until R 2.15.0, the require("methods") is needed but (now) -## triggers an warning from R CMD check -#.onLoad <- function(libname, pkgname){ -# #require("methods") ## needed with R <= 2.15.0 -# loadRcppModules() - -## For R 2.15.1 and later this also works. Note that calling loadModule() triggers -## a load action, so this does not have to be placed in .onLoad() or evalqOnLoad(). - -loadModule("polytopes", TRUE) -loadModule("spectrahedron", TRUE) diff --git a/R-proj/examples/logconcave/data/polytope_e_coli.mat b/R-proj/examples/logconcave/data/polytope_e_coli.mat deleted file mode 100644 index cc0dee3ef..000000000 Binary files a/R-proj/examples/logconcave/data/polytope_e_coli.mat and /dev/null differ diff --git a/R-proj/examples/logconcave/generalized_hyperbolic.R b/R-proj/examples/logconcave/generalized_hyperbolic.R deleted file mode 100644 index e0f9b90ce..000000000 --- a/R-proj/examples/logconcave/generalized_hyperbolic.R +++ /dev/null @@ -1,65 +0,0 @@ -# VolEsti (volume computation and sampling library) - -# Copyright (c) 2012-2020 Vissarion Fisikopoulos -# Copyright (c) 2018-2020 Apostolos Chalkis -# Copyright (c) 2020-2020 Marios Papachristou - -# Contributed and/or modified by Marios Papachristou, as part of Google Summer of Code 2020 program. - -# Licensed under GNU LGPL.3, see LICENCE file - -# Example script for sampling from a Generalized Hyperbolic density - -# Import required libraries -library(ggplot2) -library(volesti) -library(numDeriv) -library(GeneralizedHyperbolic) - -A = matrix(c(1, -1), ncol=1, nrow=2, byrow=TRUE) -b = c(4,4) - -f <- function(x) (-log(dghyp(x))) -grad_f <- function(x) (-ddghyp(x)/dghyp(x)) - -x_min = matrix(0, 1, 1) - -# Create domain of truncation -P <- volesti::Hpolytope$new(A, b) - -# Smoothness and strong-convexity -L <- estimtate_lipschitz_constant(grad_f, P, 1000) -m <- L - -# Warm start point from truncated Gaussian -warm_start <- sample_points(P, n = 1, random_walk = list("nburns" = 5000), distribution = list("density" = "gaussian", "variance" = 1/L, "mode" = x_min)) - -# Sample points -n_samples <- 10000 -n_burns <- n_samples / 2 - -pts <- sample_points(P, n = n_samples, random_walk = list("walk" = "HMC", "step_size" = 0.5, "nburns" = n_burns, "walk_length" = 1, "solver" = "leapfrog", "starting_point" = warm_start[,1]), distribution = list("density" = "logconcave", "negative_logprob" = f, "negative_logprob_gradient" = grad_f, "L_" = L, "m" = m)) - -# Plot histogram -hist(pts, - probability=TRUE, - breaks = 100, - border="blue", - main="Genrealized Hyperbolic Density with lambda = 1, alpha = 1, beta = 0, delta = 1, mu = 0", - xlab="Samples", - ylab="Density" -) - -cat("Sample mean is: ") -sample_mean <- mean(pts) -cat(sample_mean) -cat("\n") -cat("Sample variance is: ") -sample_variance <- mean((pts - sample_mean)^2) -cat(sample_variance) - -n_ess = min(ess(pts)) -psrf = max(psrf_univariate(pts)) - -cat("\nEffective sample size: ", n_ess, append=TRUE) -cat("\nPSRF: ", psrf, append=TRUE) diff --git a/R-proj/examples/logconcave/metabolic.R b/R-proj/examples/logconcave/metabolic.R deleted file mode 100644 index 7785de0d7..000000000 --- a/R-proj/examples/logconcave/metabolic.R +++ /dev/null @@ -1,111 +0,0 @@ -# VolEsti (volume computation and sampling library) - -# Copyright (c) 2012-2020 Vissarion Fisikopoulos -# Copyright (c) 2018-2020 Apostolos Chalkis -# Copyright (c) 2020-2020 Marios Papachristou - -# Contributed and/or modified by Marios Papachristou, as part of Google Summer of Code 2020 program. - -# Licensed under GNU LGPL.3, see LICENCE file - -# Example script for using the logconcave sampling methods - -# Import required libraries -library(ggplot2) -library(volesti) -library(R.matlab) - -# Sampling from logconcave density example - -# Helper function -norm_vec <- function(x) sqrt(sum(x^2)) - - -# Load polytopes from mat file -metabolic_polytope_mat <- readMat('./data/polytope_e_coli.mat') -A <- as.matrix(metabolic_polytope_mat$polytope[[1]]) -b <- as.matrix(metabolic_polytope_mat$polytope[[2]]) -center <- as.matrix(metabolic_polytope_mat$polytope[[3]]) -radius <- as.numeric(metabolic_polytope_mat$polytope[[4]]) -sigma <- 1 -dimension <- dim(A)[2] - - -# Negative log-probability oracle -f <- function(x) (norm_vec(x)^2 / (2 * sigma^2)) - -# Negative log-probability gradient oracle -grad_f <- function(x) (x / sigma^2) - - -# Smoothness and strong-convexity -L <- 1 / sigma^2 -m <- 1 / sigma^2 - -# Center polytope -b_new <- b - A %*% center - -# Create volesti polytope -P <- Hpolytope$new(A = A, b = c(b_new)) - -# Rounding -#Tr <- rounding(H) - -#P <- Hpolytope$new(A = Tr$Mat[1:nrow(Tr$Mat), 2:ncol(Tr$Mat)], b = Tr$Mat[,1]) - -# Center is origin (after shift) -x_min = matrix(0, dimension, 1) - -# Generate samples with HNR -start_time <- Sys.time() -rdhr_samples <- sample_points(P, n = 10, random_walk = list("walk" = "RDHR", "nburns" = 10, "walk_length" = 1), distribution = list("density" = "gaussian", "variance" = 1/L, "mode" = x_min)) -end_time <- Sys.time() - -# Calculate Effective Sample size -rdhr_ess = ess(rdhr_samples) -min_ess <- min(rdhr_ess) - -# Calculate PSRF -rdhr_psrfs = psrf_univariate(rdhr_samples) -max_psrf = max(rdhr_psrfs) -elapsed_time <- end_time - start_time - -# Print results -cat('Min Effective Sample Size: ') -cat(min_ess) -cat('\n') -cat('Maximum PSRF: ') -cat(max_psrf) -cat('\n') -cat('Time per independent sample: ') -cat(elapsed_time / min_ess) -cat('sec') - -outfile <- '/home/marios/samples_hnr_iAB_PLT_283.txt' - -write.table(rdhr_samples, file=outfile, row.names=FALSE, col.names=FALSE) - -start_time <- Sys.time() -hmc_samples <- sample_points(P, n = 10, random_walk = list("walk" = "HMC", "step_size" = 0.07, "nburns" = 10, "walk_length" = 30, "solver" = "leapfrog", "starting_point" = rdhr_samples[, ncol(rdhr_samples)]), distribution = list("density" = "logconcave", "negative_logprob" = f, "negative_logprob_gradient" = grad_f, "L_" = L, "m" = m)) -end_time <- Sys.time() - -# Calculate Effective Sample size -hmc_ess = ess(hmc_samples) -min_ess <- min(hmc_ess) - -# Calculate PSRF -hmc_psrfs = psrf_univariate(hmc_samples) -max_psrf = max(hmc_psrfs) -elapsed_time <- end_time - start_time - -# Print results -cat('HMC\n') -cat('Min Effective Sample Size: ') -cat(min_ess) -cat('\n') -cat('Maximum PSRF: ') -cat(max_psrf) -cat('\n') -cat('Time per independent sample: ') -cat(elapsed_time / min_ess) -cat('sec') diff --git a/R-proj/examples/logconcave/nuts_rand_poly.R b/R-proj/examples/logconcave/nuts_rand_poly.R deleted file mode 100644 index 00400ba72..000000000 --- a/R-proj/examples/logconcave/nuts_rand_poly.R +++ /dev/null @@ -1,55 +0,0 @@ -# VolEsti (volume computation and sampling library) - -# Copyright (c) 2012-2020 Vissarion Fisikopoulos -# Copyright (c) 2018-2020 Apostolos Chalkis -# Copyright (c) 2020-2020 Marios Papachristou - -# Contributed and/or modified by Marios Papachristou, as part of Google Summer of Code 2020 program. - -# Licensed under GNU LGPL.3, see LICENCE file - -# Example script for using the logconcave sampling methods - -# Import required libraries -library(ggplot2) -library(volesti) - -# Sampling from logconcave density example - -# Helper function -norm_vec <- function(x) sqrt(sum(x^2)) - -# Negative log-probability oracle -f <- function(x) (norm_vec(x)^2 + sum(x)) - -# Negative log-probability gradient oracle -grad_f <- function(x) (2 * x + 1) - -dimension <- 50 -facets <- 200 - -# Create domain of truncation -H <- gen_rand_hpoly(dimension, facets, seed = 15) - -# Rounding -Tr <- rounding(H, seed = 127) - -P <- Hpolytope$new(A = Tr$Mat[1:nrow(Tr$Mat), 2:ncol(Tr$Mat)], b = Tr$Mat[,1]) - -x_min = matrix(0, dimension, 1) - -# Warm start point from truncated Gaussian -warm_start <- sample_points(P, n = 1, random_walk = list("nburns" = 5000), distribution = list("density" = "gaussian", "variance" = 1/2, "mode" = x_min)) - -# Sample points -n_samples <- 20000 - -samples <- sample_points(P, n = n_samples, random_walk = list("walk" = "NUTS", "solver" = "leapfrog", "starting_point" = warm_start[,1]), - distribution = list("density" = "logconcave", "negative_logprob" = f, "negative_logprob_gradient" = grad_f)) - -# Plot histogram -hist(samples[1,], probability=TRUE, breaks = 100) - -psrfs <- psrf_univariate(samples) -n_ess <- ess(samples) - diff --git a/R-proj/examples/logconcave/simple_crhmc.R b/R-proj/examples/logconcave/simple_crhmc.R deleted file mode 100644 index 5fee2b8b8..000000000 --- a/R-proj/examples/logconcave/simple_crhmc.R +++ /dev/null @@ -1,49 +0,0 @@ -# VolEsti (volume computation and sampling library) - -# Copyright (c) 2012-2020 Vissarion Fisikopoulos -# Copyright (c) 2018-2020 Apostolos Chalkis -# Copyright (c) 2020-2020 Marios Papachristou -# Copyright (c) 2022-2022 Ioannis Iakovidis - -# Contributed and/or modified by Ioannis Iakovidis, as part of Google Summer of Code 2022 program. - -# Licensed under GNU LGPL.3, see LICENCE file - -# Example script for using the logconcave sampling methods - -# Import required libraries -library(volesti) - -# Sampling from uniform density example - -logconcave_sample<- function(P,distribution, n_samples ,n_burns){ - if (distribution == "uniform"){ - f <- function(x) (0) - grad_f <- function(x) (0) - L=1 - m=1 - pts <- sample_points(P, n = n_samples, random_walk = list("walk" = "CRHMC", "nburns" = n_burns, "walk_length" = 1, "solver" = "implicit_midpoint"), distribution = list("density" = "logconcave", "negative_logprob" = f, "negative_logprob_gradient" = grad_f, "L_" = L, "m" = m)) - return(max(psrf_univariate(pts, "interval"))) - } - else if(distribution == "gaussian"){ - pts <- sample_points(P, n = n_samples, random_walk = list("walk" = "CRHMC", "nburns" = n_burns, "walk_length" = 1, "solver" = "implicit_midpoint"), distribution = list("density" = "logconcave", "variance"=8)) - return(max(psrf_univariate(pts, "interval"))) - } -} - -for (i in 1:2) { - - if (i==1) { - distribution = 'gaussian' - cat("Gaussian ") - } else { - distribution = 'uniform' - cat("Uniform ") - } - - P = gen_simplex(10, 'H') - psrf = logconcave_sample(P,distribution,5000,2000) - cat("psrf = ") - cat(psrf) - cat("\n") -} diff --git a/R-proj/examples/logconcave/simple_hmc.R b/R-proj/examples/logconcave/simple_hmc.R deleted file mode 100644 index 860677468..000000000 --- a/R-proj/examples/logconcave/simple_hmc.R +++ /dev/null @@ -1,61 +0,0 @@ -# VolEsti (volume computation and sampling library) - -# Copyright (c) 2012-2020 Vissarion Fisikopoulos -# Copyright (c) 2018-2020 Apostolos Chalkis -# Copyright (c) 2020-2020 Marios Papachristou - -# Contributed and/or modified by Marios Papachristou, as part of Google Summer of Code 2020 program. - -# Licensed under GNU LGPL.3, see LICENCE file - -# Example script for using the logconcave sampling methods - -# Import required libraries -library(ggplot2) -library(volesti) - -# Sampling from logconcave density example - -# Helper function -norm_vec <- function(x) sqrt(sum(x^2)) - -# Negative log-probability oracle -f <- function(x) (norm_vec(x)^2 + sum(x)) - -# Negative log-probability gradient oracle -grad_f <- function(x) (2 * x + 1) - -# Interval [-1, 1] -A = matrix(c(1, -1), ncol=1, nrow=2, byrow=TRUE) -b = c(2,1) - -# Create domain of truncation -P <- volesti::Hpolytope$new(A, b) - -# Mode of logconcave density -x_min <- c(-0.5) - -# Smoothness and strong-convexity -L <- 2 -m <- 2 - -# Warm start point from truncated Gaussian -warm_start <- sample_points(P, n = 1, random_walk = list("nburns" = 5000), distribution = list("density" = "gaussian", "variance" = 1/L, "mode" = x_min)) - -# Sample points -n_samples <- 20000 -n_burns <- n_samples / 2 - -pts <- sample_points(P, n = n_samples, random_walk = list("walk" = "HMC", "step_size" = 0.3, "nburns" = n_burns, "walk_length" = 3, "solver" = "leapfrog", "starting_point" = warm_start[,1]), distribution = list("density" = "logconcave", "negative_logprob" = f, "negative_logprob_gradient" = grad_f, "L_" = L, "m" = m)) -# pts <- sample_points(P, n = n_samples, random_walk = list("walk" = "HMC", "step_size" = 0.3, "nburns" = n_burns, "walk_length" = 3, "solver" = "leapfrog", "starting_point" = warm_start[,1]), distribution = list("density" = "logconcave", "mode" = x_min, "variance" = 1)) - -# Plot histogram -hist(pts, probability=TRUE, breaks = 100) - -cat("Sample mean is: ") -sample_mean <- mean(pts) -cat(sample_mean) -cat("\n") -cat("Sample variance is: ") -sample_variance <- mean((pts - sample_mean)^2) -cat(sample_variance) diff --git a/R-proj/examples/logconcave/simple_hmc_rand_poly.R b/R-proj/examples/logconcave/simple_hmc_rand_poly.R deleted file mode 100644 index b352c9a16..000000000 --- a/R-proj/examples/logconcave/simple_hmc_rand_poly.R +++ /dev/null @@ -1,58 +0,0 @@ -# VolEsti (volume computation and sampling library) - -# Copyright (c) 2012-2020 Vissarion Fisikopoulos -# Copyright (c) 2018-2020 Apostolos Chalkis -# Copyright (c) 2020-2020 Marios Papachristou - -# Contributed and/or modified by Marios Papachristou, as part of Google Summer of Code 2020 program. - -# Licensed under GNU LGPL.3, see LICENCE file - -# Example script for using the logconcave sampling methods - -# Import required libraries -library(ggplot2) -library(volesti) - -# Sampling from logconcave density example - -# Helper function -norm_vec <- function(x) sqrt(sum(x^2)) - -# Negative log-probability oracle -f <- function(x) (norm_vec(x)^2 + sum(x)) - -# Negative log-probability gradient oracle -grad_f <- function(x) (2 * x + 1) - -dimension <- 50 -facets <- 200 - -# Create domain of truncation -H <- gen_rand_hpoly(dimension, facets, seed = 15) - -# Rounding -Tr <- rounding(H, seed = 127) - -P <- Hpolytope$new(A = Tr$Mat[1:nrow(Tr$Mat), 2:ncol(Tr$Mat)], b = Tr$Mat[,1]) - -x_min = matrix(0, dimension, 1) - -# Smoothness and strong-convexity -L <- 2 -m <- 2 - -# Warm start point from truncated Gaussian -warm_start <- sample_points(P, n = 1, random_walk = list("nburns" = 5000), distribution = list("density" = "gaussian", "variance" = 1/L, "mode" = x_min)) - -# Sample points -n_samples <- 20000 -n_burns <- n_samples / 2 - -samples <- sample_points(P, n = n_samples, random_walk = list("walk" = "HMC", "step_size" = 0.03, "nburns" = n_burns, "walk_length" = 3, "solver" = "leapfrog", "starting_point" = warm_start[,1]), distribution = list("density" = "logconcave", "negative_logprob" = f, "negative_logprob_gradient" = grad_f, "L_" = L, "m" = m)) - -# Plot histogram -hist(samples[1,], probability=TRUE, breaks = 100) - -psrfs <- psrf_univariate(samples) -n_ess <- ess(samples) \ No newline at end of file diff --git a/R-proj/examples/logconcave/simple_ode.R b/R-proj/examples/logconcave/simple_ode.R deleted file mode 100644 index 10d0c6d88..000000000 --- a/R-proj/examples/logconcave/simple_ode.R +++ /dev/null @@ -1,31 +0,0 @@ -# VolEsti (volume computation and sampling library) - -# Copyright (c) 2012-2020 Vissarion Fisikopoulos -# Copyright (c) 2018-2020 Apostolos Chalkis -# Copyright (c) 2020-2020 Marios Papachristou - -# Contributed and/or modified by Marios Papachristou, as part of Google Summer of Code 2020 program. - -# Licensed under GNU LGPL.3, see LICENCE file - -# Example script for ODE solvers -library(volesti) - -F <- function (x) (-x) -order <- 2 -step_size <- 0.01 -n <- 1000 -initial_conditions <- list("x_1" = c(0), "x_2" = c(1)) -initial_time <- 0 - -# Do not impose constraints -domains <- list() - -# Call the ode solver -states <- volesti::ode_solve(dimension=1, n=n, F=F, initial_time=initial_time, step_size=step_size, order=order, method="leapfrog", initial_conditions=initial_conditions, domains = list()) - -x <- states[["x_1"]] -v <- states[["x_2"]] - -plot(x, v) - diff --git a/R-proj/examples/logconcave/simple_ode_truncated.R b/R-proj/examples/logconcave/simple_ode_truncated.R deleted file mode 100644 index be2706c46..000000000 --- a/R-proj/examples/logconcave/simple_ode_truncated.R +++ /dev/null @@ -1,34 +0,0 @@ -# VolEsti (volume computation and sampling library) - -# Copyright (c) 2012-2020 Vissarion Fisikopoulos -# Copyright (c) 2018-2020 Apostolos Chalkis -# Copyright (c) 2020-2020 Marios Papachristou - -# Contributed and/or modified by Marios Papachristou, as part of Google Summer of Code 2020 program. - -# Licensed under GNU LGPL.3, see LICENCE file - -# Example script for truncated ODE solvers -library(volesti) - -F <- function (x) (x) -order <- 1 -step_size <- 0.01 -n <- 1000 -initial_conditions <- list("x_1" = c(0.1)) -initial_time <- 0 - -A <- matrix(c(1, -1), ncol=1, nrow=2, byrow=TRUE) -b <- c(1, 0) - -# Create domain of truncation -P_1 <- volesti::Hpolytope$new(A, b) -domains <- list("P_1" = P_1) - -# Call the ode solver -states <- volesti::ode_solve(dimension=1, n=n, F=F, initial_time=initial_time, step_size=step_size, order=order, method="euler", initial_conditions=initial_conditions, domains = domains) - -x <- states[["x_1"]] -t <- step_size * seq(0, n - 1) - -plot(t, x) diff --git a/R-proj/examples/logconcave/sparse_crhmc.R b/R-proj/examples/logconcave/sparse_crhmc.R deleted file mode 100644 index 373371986..000000000 --- a/R-proj/examples/logconcave/sparse_crhmc.R +++ /dev/null @@ -1,98 +0,0 @@ -# VolEsti (volume computation and sampling library) - -# Copyright (c) 2012-2020 Vissarion Fisikopoulos -# Copyright (c) 2018-2020 Apostolos Chalkis -# Copyright (c) 2020-2020 Marios Papachristou -# Copyright (c) 2022-2022 Ioannis Iakovidis - -# Contributed and/or modified by Ioannis Iakovidis, as part of Google Summer of Code 2022 program. - -# Licensed under GNU LGPL.3, see LICENCE file - -# Example script for using the logconcave sampling methods - -# Import required libraries -library(ggplot2) -library(volesti) - -# Sampling from logconcave density example - -# Helper function -norm_vec <- function(x) sqrt(sum(x^2)) - -# Negative log-probability oracle -f <- function(x) (norm_vec(x)^2 + sum(x)) - -# Negative log-probability gradient oracle -grad_f <- function(x) (2 * x + 1) - -# Interval [-1, 1] -A = matrix(c(1, -1), ncol=1, nrow=2, byrow=TRUE) -b = c(2,1) - -# Create domain of truncation -P <- volesti::Hpolytope$new(A, b) - -# Mode of logconcave density -x_min <- c(-0.5) - -# Smoothness and strong-convexity -L <- 2 -m <- 2 - -# Sample points -n_samples <- 80000 -n_burns <- n_samples / 2 -cat("---Sampling without hessian\n") -pts <- sample_points(P, n = n_samples, random_walk = list("walk" = "CRHMC", "step_size" = 0.3, "nburns" = n_burns, "walk_length" = 1, "solver" = "implicit_midpoint"), distribution = list("density" = "logconcave", "negative_logprob" = f, "negative_logprob_gradient" = grad_f, "L_" = L, "m" = m)) -jpeg("histogram_without_hessian.jpg") -# Plot histogram -hist(pts, probability=TRUE, breaks = 100) - -cat("Sample mean is: ") -sample_mean <- mean(pts) -cat(sample_mean) -cat("\n") -cat("Sample variance is: ") -sample_variance <- mean((pts - sample_mean)^2) -cat(sample_variance) -cat("\n") -invisible(capture.output(dev.off())) - -# Negative log-probability hessian oracle -hess_f <- function(x) (2) -cat("---Sampling with hessian\n") -pts <- sample_points(P, n = n_samples, random_walk = list("walk" = "CRHMC", "step_size" = 0.3, "nburns" = n_burns, "walk_length" = 1, "solver" = "implicit_midpoint"), distribution = list("density" = "logconcave", "negative_logprob" = f, "negative_logprob_gradient" = grad_f,"negative_logprob_hessian" = hess_f, "L_" = L, "m" = m)) -jpeg("histogram_with_hessian.jpg") -# Plot histogram -hist(pts, probability=TRUE, breaks = 100) - -cat("Sample mean is: ") -sample_mean <- mean(pts) -cat(sample_mean) -cat("\n") -cat("Sample variance is: ") -sample_variance <- mean((pts - sample_mean)^2) -cat(sample_variance) -cat("\n") -invisible(capture.output(dev.off())) - -walk="CRHMC" -library(Matrix) -bineq=matrix(c(10,10,10,10,10), nrow=5, ncol=1, byrow=TRUE) -Aineq = matrix(c(1,0,-0.25,-1,2.5,1,0.4,-1,-0.9,0.5), nrow=5, ncol=2, byrow = TRUE) -Aineq = as( Aineq, 'dgCMatrix' ) -beq=matrix(,nrow=0, ncol=1, byrow=TRUE) -Aeq = matrix(, nrow=0, ncol=2, byrow = TRUE) -Aeq=as( Aeq, 'dgCMatrix' ) -lb=-100000*c(1,1); -ub=100000*c(1,1); -cat("---Sampling the normal distribution in a pentagon\n") -P <- volesti::sparse_constraint_problem$new(Aineq, bineq,Aeq, beq, lb, ub) -points <- sample_points(P, n = n_samples, random_walk = list("walk" = "CRHMC", "step_size" = 0.3, "nburns" = n_burns, "walk_length" = 1, "solver" = "implicit_midpoint"), distribution = list("density" = "logconcave", "variance" = 8)) -jpeg("pentagon.jpg") -plot(ggplot(data.frame( x=points[1,], y=points[2,] )) + -geom_point( aes(x=x, y=y, color=walk)) + coord_fixed(xlim = c(-15,15), -ylim = c(-15,15)) + ggtitle(sprintf("Sampling a random pentagon with walk %s", walk))) -invisible(capture.output(dev.off())) -write.table(points, file="pentagon.txt", row.names=FALSE, col.names=FALSE) diff --git a/R-proj/inst/AUTHORS b/R-proj/inst/AUTHORS deleted file mode 100644 index 956eb3255..000000000 --- a/R-proj/inst/AUTHORS +++ /dev/null @@ -1,4 +0,0 @@ -1. Bojan Nikolic . We have modified the implementations of Khachiyan's Algorithm by B. Nikolic from bnmin1-1.11 package for the Computation of Minimum Volume Enclosing Ellipsoids in /src/external/minimum_ellipsoid. - -2. Kjell Konis , Stefan I. Larimore and Timothy A. Davis , Kjell Eikland, Michel Berkelaar, Richard Stallman, Authors of lpsolve package , in /src/external/lpsolve. - diff --git a/R-proj/inst/COPYRIGHTS b/R-proj/inst/COPYRIGHTS deleted file mode 100644 index 39cabd5a7..000000000 --- a/R-proj/inst/COPYRIGHTS +++ /dev/null @@ -1,6 +0,0 @@ -All files in src/external are taken from -(i) lpsolve (https://cran.r-project.org/src/contrib/Archive/lpSolveAPI) version 5.5.2.0, -(ii) bnmin1 (https://www.mrao.cam.ac.uk/~bn204/oof/bnmin1.html) version 1.11 - -Copyrights and modification details are explicitly described at the beginning of each of those files. - diff --git a/R-proj/inst/checks/README.md b/R-proj/inst/checks/README.md deleted file mode 100644 index a21b374b9..000000000 --- a/R-proj/inst/checks/README.md +++ /dev/null @@ -1,31 +0,0 @@ -| Check | cran-name | ERRORS | WARNINGS | NOTES | URL | -| ----------------------- |-------------|:-------------:| :-------: | :---: | -- | -| `macOS 10.9 Mavericks, R-oldrel (experimental)` | `r-oldrel-osx-x86_64` | 0 | 0 | 0 | [PREPERROR](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-4561558b7b96f9d9ab4662b565f1b871)* | -| `macOS 10.11 El Capitan, R-release (experimental)` | `r-release-osx-x86_64` | 0 | 0 | 0 | [OK](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-b02c328852acddb3fcd3048f9f327055) | -| `Windows Server 2008 R2 SP1, R-oldrel, 32/64 bit` | `r-oldrel-windows-ix86+x86_64` | 0 | 0 | 0 | [OK](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-f43945e177bd0a39f2a4effa8f6e9c88) | -| `Windows Server 2008 R2 SP1, R-release, 32/64 bit` | `r-release-windows-ix86+x86_64` | 0 | 0 | 0 | [OK](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-707ffbeaa5fb7f3b00a1cff357e63c7f) | -| `Windows Server 2008 R2 SP1, R-patched, 32/64 bit` | `N/A` | 0 | 0 | 0 | [OK](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-3376f9b5f6a17ba0a2c30b0cbf0bf917) | -| `Windows Server 2008 R2 SP1, R-devel, 32/64 bit` | `r-devel-windows-ix86+x86_64` | 0 | 0 | 0 | [OK](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-901e108dfc1802c6f8726f162c95e597) | -| `Windows Server 2012, R-devel, Rtools4.0, 32/64 bit (experimental)` | `N/A` | 0 | 0 | 1 | [NOTE](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-c48dc0fa6839ef8b509c73c48f0ca887) | -| `Oracle Solaris 10, x86, 32 bit, R-patched (experimental)` | `r-patched-solaris-x86` | 0 | 0 | 0 | [OK](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-39bda3d243591a660eb3a4d2cdb4ac3f) | -| `Debian Linux, R-devel, GCC` | `r-devel-linux-x86_64-debian-gcc` | 0 | 0 | 1 | [NOTE](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-907c4d873965c64d435bc672335063eb) | -| `Debian Linux, R-devel, GCC, no long double` | `N/A` | 0 | 0 | 1 | [NOTE](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-cb5a82d9e3112bb706e6c767e778e3a5) | -| `Debian Linux, R-release, GCC` | `r-release-linux-x86_64` | 0 | 0 | 1 | [NOTE](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-4c142b0323d2f174d53a761564e0b498) | -| `Debian Linux, R-patched, GCC` | `r-patched-linux-x86_64` | 0 | 0 | 1 | [NOTE](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-031047558bf41664b387180f558adfd1) | -| `Debian Linux, R-devel, clang, ISO-8859-15 locale` | `r-devel-linux-x86_64-debian-clang` | 0 | 0 | 1 | [NOTE](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-eecaf29af2fd88fdf148667c5463e141) | -| `Fedora Linux, R-devel, GCC` | `r-devel-linux-x86_64-fedora-gcc` | 0 | 0 | 1 | [NOTE](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-f919c24153e9afd09ef0654d4799fb12) | -| `Fedora Linux, R-devel, clang, gfortran` | `r-devel-linux-x86_64-fedora-clang` | 0 | 0 | 1 | [NOTE](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-0efbc2539568b86e2fa716db1a1231d6) | -| `Ubuntu Linux 16.04 LTS, R-devel, GCC` | `N/A` | 0 | 0 | 1 | [NOTE](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-7d47fbd13a90cb4c3712232cfa320fc3) | -| `Ubuntu Linux 16.04 LTS, R-release, GCC` |`N/A` | 0 | 0 | 1 | [NOTE](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-6911a48496c075be151e7ba5d6326fbb) | -| `CentOS 6, stock R from EPEL` |`N/A` | 1 | 0 | 0 | [ERROR](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-6f5d27f5b548d46da8fcafab677b86e4)** | -| `CentOS 6 with Redhat Developer Toolset, R from EPEL` | `N/A` | 0 | 0 | 1 | [NOTE](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-efce07b30b0a73c6c4f39db5fed70efa) | -| `Debian Linux, R-devel, GCC ASAN/UBSAN` *** | `N/A` | | | | [SUCCESS](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-1d695055bc3e2facdc252827c5d27f1b) | -| `Ubuntu Linux 16.04 LTS, R-devel with rchk` *** | `N/A` | | | | [SUCCESS](https://builder.r-hub.io/status/volesti_1.0.2.tar.gz-a35e57a5f29f45f2e74e07fd3b72c9e5) | - -All the checks above have performed via [rhub](https://cran.r-project.org/web/packages/rhub/index.html) package. For more details on system characteristics see [rhub's vignettes](https://cran.r-project.org/web/packages/rhub/vignettes/rhub.html). **cran-name** column shows the correspondance to [CRAN package check flavors](https://cran.r-project.org/web/checks/check_flavors.html) - -*The check on `macOS 10.9 Mavericks, R-oldrel (experimental)` fails because the system fails to install `RcppEigen`. You can see our [issue](https://github.com/r-hub/rhub/issues/280) at [rhub's github page](https://github.com/r-hub/rhub). - -** This is expected since our C++ code needs C++11 standard at least while this systems uses gcc4.4.X which does not support C++11 - -*** Checks for compiled code diff --git a/R-proj/inst/extdata/birk4.ine b/R-proj/inst/extdata/birk4.ine deleted file mode 100644 index f7515b94d..000000000 --- a/R-proj/inst/extdata/birk4.ine +++ /dev/null @@ -1,22 +0,0 @@ -birk4.ine -H-representation -begin - 16 10 integer --2 1 1 1 1 1 1 1 1 1 - 1 -1 0 0 -1 0 0 -1 0 0 - 1 0 -1 0 0 -1 0 0 -1 0 - 1 0 0 -1 0 0 -1 0 0 -1 - 1 -1 -1 -1 0 0 0 0 0 0 - 1 0 0 0 -1 -1 -1 0 0 0 - 1 0 0 0 0 0 0 -1 -1 -1 - 0 1 0 0 0 0 0 0 0 0 - 0 0 1 0 0 0 0 0 0 0 - 0 0 0 1 0 0 0 0 0 0 - 0 0 0 0 1 0 0 0 0 0 - 0 0 0 0 0 1 0 0 0 0 - 0 0 0 0 0 0 1 0 0 0 - 0 0 0 0 0 0 0 1 0 0 - 0 0 0 0 0 0 0 0 1 0 - 0 0 0 0 0 0 0 0 0 1 -end -input_incidence diff --git a/R-proj/inst/extdata/birk5.ine b/R-proj/inst/extdata/birk5.ine deleted file mode 100644 index 7a59b3f11..000000000 --- a/R-proj/inst/extdata/birk5.ine +++ /dev/null @@ -1,31 +0,0 @@ -birk5.ine -H-representation -begin - 25 17 integer --3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 -1 0 0 0 -1 0 0 0 -1 0 0 0 -1 0 0 0 -1 0 -1 0 0 0 -1 0 0 0 -1 0 0 0 -1 0 0 -1 0 0 -1 0 0 0 -1 0 0 0 -1 0 0 0 -1 0 -1 0 0 0 -1 0 0 0 -1 0 0 0 -1 0 0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 -1 -1 -1 -1 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 -1 -1 -1 -1 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 -1 -1 -1 -1 -0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 -end -input_incidence diff --git a/R-proj/inst/extdata/cross_10.ext b/R-proj/inst/extdata/cross_10.ext deleted file mode 100644 index c14ee63c5..000000000 --- a/R-proj/inst/extdata/cross_10.ext +++ /dev/null @@ -1,27 +0,0 @@ -cross_10.ext -V-representation -begin - 20 11 integer - 1 0 0 0 0 0 0 0 0 0 1 - 1 1 0 0 0 0 0 0 0 0 0 - 1 0 1 0 0 0 0 0 0 0 0 - 1 0 0 1 0 0 0 0 0 0 0 - 1 0 0 0 1 0 0 0 0 0 0 - 1 0 0 0 0 1 0 0 0 0 0 - 1 0 0 0 0 0 1 0 0 0 0 - 1 0 0 0 0 0 0 1 0 0 0 - 1 0 0 0 0 0 0 0 1 0 0 - 1 0 0 0 0 0 0 0 0 1 0 - 1 0 0 0 0 0 0 0 0 0 -1 - 1 0 0 0 0 0 0 0 0 -1 0 - 1 0 0 0 0 0 0 0 -1 0 0 - 1 0 0 0 0 0 0 -1 0 0 0 - 1 0 0 0 0 0 -1 0 0 0 0 - 1 0 0 0 0 -1 0 0 0 0 0 - 1 0 0 0 -1 0 0 0 0 0 0 - 1 0 0 -1 0 0 0 0 0 0 0 - 1 0 -1 0 0 0 0 0 0 0 0 - 1 -1 0 0 0 0 0 0 0 0 0 -end -hull -incidence diff --git a/R-proj/inst/extdata/cross_10.ine b/R-proj/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1 1 1 1 1 - 1 -1 -1 1 1 1 1 1 1 1 1 - 1 1 -1 1 1 1 1 1 1 1 1 - 1 -1 1 1 1 1 1 1 1 1 1 - 1 1 1 1 1 1 1 1 1 1 1 -end -input_incidence diff --git a/R-proj/inst/extdata/cube10.ine b/R-proj/inst/extdata/cube10.ine deleted file mode 100644 index 1f035f33c..000000000 --- a/R-proj/inst/extdata/cube10.ine +++ /dev/null @@ -1,26 +0,0 @@ -cube10.ine -H-representation -begin - 20 11 real - 1 1 0 0 0 0 0 0 0 0 0 - 1 0 1 0 0 0 0 0 0 0 0 - 1 0 0 1 0 0 0 0 0 0 0 - 1 0 0 0 1 0 0 0 0 0 0 - 1 0 0 0 0 1 0 0 0 0 0 - 1 0 0 0 0 0 1 0 0 0 0 - 1 0 0 0 0 0 0 1 0 0 0 - 1 0 0 0 0 0 0 0 1 0 0 - 1 0 0 0 0 0 0 0 0 1 0 - 1 0 0 0 0 0 0 0 0 0 1 - 1 -1 0 0 0 0 0 0 0 0 0 - 1 0 -1 0 0 0 0 0 0 0 0 - 1 0 0 -1 0 0 0 0 0 0 0 - 1 0 0 0 -1 0 0 0 0 0 0 - 1 0 0 0 0 -1 0 0 0 0 0 - 1 0 0 0 0 0 -1 0 0 0 0 - 1 0 0 0 0 0 0 -1 0 0 0 - 1 0 0 0 0 0 0 0 -1 0 0 - 1 0 0 0 0 0 0 0 0 -1 0 - 1 0 0 0 0 0 0 0 0 0 -1 -end -input_incidence diff --git a/R-proj/inst/extdata/cube_10.ext b/R-proj/inst/extdata/cube_10.ext deleted file mode 100644 index ed4dd559e..000000000 --- a/R-proj/inst/extdata/cube_10.ext +++ /dev/null @@ -1,1031 +0,0 @@ -cube_10.ext -V-representation -begin -1024 11 integer -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 -1 -1 -1 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-1 -1 1 1 1 1 1 1 1 1 1 -1 -1 1 1 1 1 1 1 1 1 1 1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 1 -1 -1 -1 -1 -1 -1 1 -1 -1 1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 1 1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 1 -1 -1 1 -1 -1 -1 -1 -1 -1 1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -end -hull -incidence diff --git a/R-proj/inst/extdata/linear_extensions/simple.txt b/R-proj/inst/extdata/linear_extensions/simple.txt deleted file mode 100644 index b50a96df4..000000000 --- a/R-proj/inst/extdata/linear_extensions/simple.txt +++ /dev/null @@ -1,2 +0,0 @@ -50 20 -[[1,2],[1,3],[1,5],[1,7],[2,3],[2,5],[2,8],[3,4],[3,9],[4,5],[4,7],[4,10],[5,6],[5,8],[6,7],[6,8],[6,9],[7,8],[7,9],[9,10]] diff --git a/R-proj/inst/extdata/linear_extensions/simple_poset.txt b/R-proj/inst/extdata/linear_extensions/simple_poset.txt deleted file mode 100644 index 8998e738c..000000000 --- a/R-proj/inst/extdata/linear_extensions/simple_poset.txt +++ /dev/null @@ -1,2 +0,0 @@ -4 3 -[[1,2],[1,3],[3,4]] diff --git a/R-proj/inst/extdata/prod_simplex_10_10.ine b/R-proj/inst/extdata/prod_simplex_10_10.ine deleted file mode 100644 index 0eca1b7d1..000000000 --- a/R-proj/inst/extdata/prod_simplex_10_10.ine +++ /dev/null @@ -1,28 +0,0 @@ -prod_simplex_10.ine -H-representation -begin - 21 21 integer -0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 -end -input_incidence diff --git a/R-proj/inst/extdata/sdpa_n2m3.txt b/R-proj/inst/extdata/sdpa_n2m3.txt deleted file mode 100644 index 0459374cf..000000000 --- a/R-proj/inst/extdata/sdpa_n2m3.txt +++ /dev/null @@ -1,13 +0,0 @@ -2 -1 -3 -1 1 --1 0 0 - 0 -2 1 - 0 1 -2 - 1 -0 -0 --0 -0 -1 --0 -1 -0 --0 -0 1 --0 -0 -0 - 1 -0 -0 diff --git a/R-proj/inst/extdata/simplex10.ext b/R-proj/inst/extdata/simplex10.ext deleted file mode 100644 index c40976554..000000000 --- a/R-proj/inst/extdata/simplex10.ext +++ /dev/null @@ -1,18 +0,0 @@ -simplex_10.ext -V-representation -begin - 11 11 integer -1 1 0 0 0 0 0 0 0 0 0 -1 0 1 0 0 0 0 0 0 0 0 -1 0 0 1 0 0 0 0 0 0 0 -1 0 0 0 1 0 0 0 0 0 0 -1 0 0 0 0 1 0 0 0 0 0 -1 0 0 0 0 0 1 0 0 0 0 -1 0 0 0 0 0 0 1 0 0 0 -1 0 0 0 0 0 0 0 1 0 0 -1 0 0 0 0 0 0 0 0 1 0 -1 0 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 0 0 -end -hull -incidence diff --git a/R-proj/inst/extdata/simplex10.ine b/R-proj/inst/extdata/simplex10.ine deleted file mode 100644 index 0e3cb59ac..000000000 --- a/R-proj/inst/extdata/simplex10.ine +++ /dev/null @@ -1,17 +0,0 @@ -simplex_10.ine -H-representation -begin - 11 11 integer -0 1 0 0 0 0 0 0 0 0 0 -0 0 1 0 0 0 0 0 0 0 0 -0 0 0 1 0 0 0 0 0 0 0 -0 0 0 0 1 0 0 0 0 0 0 -0 0 0 0 0 1 0 0 0 0 0 -0 0 0 0 0 0 1 0 0 0 0 -0 0 0 0 0 0 0 1 0 0 0 -0 0 0 0 0 0 0 0 1 0 0 -0 0 0 0 0 0 0 0 0 1 0 -0 0 0 0 0 0 0 0 0 0 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -end -input_incidence diff --git a/R-proj/inst/extdata/skinny_cube10.ine b/R-proj/inst/extdata/skinny_cube10.ine deleted file mode 100644 index aba4f0524..000000000 --- a/R-proj/inst/extdata/skinny_cube10.ine +++ /dev/null @@ -1,26 +0,0 @@ -cube_10.ine -H-representation -begin - 20 11 integer - 100 1 0 0 0 0 0 0 0 0 0 - 1 0 1 0 0 0 0 0 0 0 0 - 1 0 0 1 0 0 0 0 0 0 0 - 1 0 0 0 1 0 0 0 0 0 0 - 1 0 0 0 0 1 0 0 0 0 0 - 1 0 0 0 0 0 1 0 0 0 0 - 1 0 0 0 0 0 0 1 0 0 0 - 1 0 0 0 0 0 0 0 1 0 0 - 1 0 0 0 0 0 0 0 0 1 0 - 1 0 0 0 0 0 0 0 0 0 1 - 100 -1 0 0 0 0 0 0 0 0 0 - 1 0 -1 0 0 0 0 0 0 0 0 - 1 0 0 -1 0 0 0 0 0 0 0 - 1 0 0 0 -1 0 0 0 0 0 0 - 1 0 0 0 0 -1 0 0 0 0 0 - 1 0 0 0 0 0 -1 0 0 0 0 - 1 0 0 0 0 0 0 -1 0 0 0 - 1 0 0 0 0 0 0 0 -1 0 0 - 1 0 0 0 0 0 0 0 0 -1 0 - 1 0 0 0 0 0 0 0 0 0 -1 -end -input_incidence diff --git a/R-proj/man/Hpolytope.Rd b/R-proj/man/Hpolytope.Rd deleted file mode 100644 index c0b826747..000000000 --- a/R-proj/man/Hpolytope.Rd +++ /dev/null @@ -1,19 +0,0 @@ -\name{Hpolytope} -\alias{Hpolytope} -\title{An \code{R} class to represent H-polytopes.} - -\description{ -A H-polytope is a convex polytope defined by a set of linear inequalities or equivalently a \eqn{d}-dimensional H-polytope with \eqn{m} facets is defined by a \eqn{m\times d} matrix A and a \eqn{m}-dimensional vector b, s.t.: \eqn{P=\{x\ |\ Ax\leq b\} }. -} -\section{Fields}{ -\itemize{ -\item{\code{A} }{ A \eqn{m\times d} numerical matrix A} - -\item{\code{b} }{ \eqn{m}-dimensional vector b} - -\item{\code{type} }{ An integer that declares the representation of the polytope. For H-representation the default value is 1.} - -\item{\code{dimension} }{ The dimension of the polytope.} - -\item{\code{volume} }{ The volume of the polytope, if it is known.} -}} diff --git a/R-proj/man/Rcpp_Hpolytope.Rd b/R-proj/man/Rcpp_Hpolytope.Rd deleted file mode 100644 index 88fa5b766..000000000 --- a/R-proj/man/Rcpp_Hpolytope.Rd +++ /dev/null @@ -1,28 +0,0 @@ -\docType{class} -\name{Rcpp_Hpolytope} -\alias{Rcpp_Hpolytope-class} -\alias{[,Rcpp_Hpolytope-method} -\alias{[,Rcpp_Hpolytope,ANY,ANY,ANY-method} -\alias{$<-,Rcpp_Hpolytope-method} -\alias{$,Rcpp_Hpolytope-method} -\alias{filepaths<-,Rcpp_Hpolytope-method} -\title{ -An \code{Rcpp} class to represent H-polytopes, exposed to \code{R} via modules. -} -\description{ -A H-polytope is a convex polytope defined by a set of linear inequalities or equivalently a \eqn{d}-dimensional H-polytope with \eqn{m} facets is defined by a \eqn{m\times d} matrix A and a \eqn{m}-dimensional vector b, s.t.: \eqn{P=\{ Ax\leq b \} }. -} -\details{ -\describe{ -\item{\code{A} }{ A \eqn{m\times d} numerical matrix A} - -\item{\code{b} }{ \eqn{m}-dimensional vector b} - -\item{\code{type} }{ An integer that declares the representation of the polytope. For H-representation the default value is 1.} - -\item{\code{dimension} }{ The dimension of the polytope.} - -\item{\code{volume} }{ The volume of the polytope, if it is known.} - } -} -\keyword{internal} diff --git a/R-proj/man/Rcpp_Spectrahedron.Rd b/R-proj/man/Rcpp_Spectrahedron.Rd deleted file mode 100644 index 3ac432e59..000000000 --- a/R-proj/man/Rcpp_Spectrahedron.Rd +++ /dev/null @@ -1,21 +0,0 @@ -\docType{class} -\name{Rcpp_Spectrahedron} -\alias{Rcpp_Spectrahedron-class} -\alias{[,Rcpp_Spectrahedron-method} -\alias{[,Rcpp_Spectrahedron,ANY,ANY,ANY-method} -\alias{$<-,Rcpp_Spectrahedron-method} -\alias{$,Rcpp_Spectrahedron-method} -\alias{filepaths<-,Rcpp_Spectrahedron-method} -\title{ -An \code{Rcpp} class to represent spectrahedra, exposed to \code{R} via modules. -} -\description{ -A spectrahedron is a convex body defined by a linear matrix inequality of the form \eqn{A_0 + x_1 A_1 + ... + x_n A_n \preceq 0}. -The matrices \eqn{A_i} are symmetric \eqn{m \times m} real matrices and \eqn{\preceq 0} denoted negative semidefiniteness. -} -\details{ -\describe{ -\item{\code{matrices} }{A list with the matrices \eqn{A_0, A_1, ..., A_n}} - } -} - diff --git a/R-proj/man/Rcpp_Vpolytope.Rd b/R-proj/man/Rcpp_Vpolytope.Rd deleted file mode 100644 index 95c46c099..000000000 --- a/R-proj/man/Rcpp_Vpolytope.Rd +++ /dev/null @@ -1,26 +0,0 @@ -\docType{class} -\name{Rcpp_Vpolytope} -\alias{Rcpp_Vpolytope-class} -\alias{[,Rcpp_Vpolytope-method} -\alias{[,Rcpp_Vpolytope,ANY,ANY,ANY-method} -\alias{$<-,Rcpp_Vpolytope-method} -\alias{$,Rcpp_Vpolytope-method} -\alias{filepaths<-,Rcpp_Vpolytope-method} -\title{ -An \code{Rcpp} class to represent V-polytopes, exposed to \code{R} via modules. -} -\description{ -A V-polytope is defined as the convex hull of \eqn{m} \eqn{d}-dimensional points which corresponds to its vertices. -} -\details{ -\describe{ - \item{\code{V} }{ A \eqn{m\times d} numerical matrix that contains the vertices row-wise} - - \item{\code{type} }{ An integer that declares the representation of the polytope. For V-representation the default value is 2.} - - \item{\code{dimension} }{ The dimension of the polytope.} - - \item{\code{volume} }{ The volume of the polytope, if it is known.} - } -} -\keyword{internal} diff --git a/R-proj/man/Rcpp_VpolytopeIntersection.Rd b/R-proj/man/Rcpp_VpolytopeIntersection.Rd deleted file mode 100644 index ec308c3be..000000000 --- a/R-proj/man/Rcpp_VpolytopeIntersection.Rd +++ /dev/null @@ -1,28 +0,0 @@ -\docType{class} -\name{Rcpp_VpolytopeIntersection} -\alias{Rcpp_VpolytopeIntersection-class} -\alias{[,Rcpp_VpolytopeIntersection-method} -\alias{[,Rcpp_VpolytopeIntersection,ANY,ANY,ANY-method} -\alias{$<-,Rcpp_VpolytopeIntersection-method} -\alias{$,Rcpp_VpolytopeIntersection-method} -\alias{filepaths<-,Rcpp_VpolytopeIntersection-method} -\title{ -An \code{Rcpp} class to represent the intersection of two V-polytope, exposed to \code{R} via modules. -} -\description{ -An intersection of two V-polytopes, \eqn{P_1}, \eqn{P_2}, is defined by the intersection of the two coresponding convex hulls. -} -\details{ -\describe{ -\item{\code{V1} }{ The numerical matrix that contains the vertices of \eqn{P_1} row-wise.} - -\item{\code{V2} }{ The numerical matrix that contains the vertices of \eqn{P_2} row-wise.} - -\item{\code{type} }{ An integer that declares the representation of the polytope. For these kinf of polytopes the default value is 4.} - -\item{\code{dimension} }{ The dimension of the polytope.} - -\item{\code{volume} }{ The volume of the polytope, if it is known.} - } -} -\keyword{internal} diff --git a/R-proj/man/Rcpp_Zonotope.Rd b/R-proj/man/Rcpp_Zonotope.Rd deleted file mode 100644 index 8c010851e..000000000 --- a/R-proj/man/Rcpp_Zonotope.Rd +++ /dev/null @@ -1,26 +0,0 @@ -\docType{class} -\name{Rcpp_Zonotope} -\alias{Rcpp_Zonotope-class} -\alias{[,Rcpp_Zonotope-method} -\alias{[,Rcpp_Zonotope,ANY,ANY,ANY-method} -\alias{$<-,Rcpp_Zonotope-method} -\alias{$,Rcpp_Zonotope-method} -\alias{filepaths<-,Rcpp_Zonotope-method} -\title{ -An \code{Rcpp} class to represent zonotopes, exposed to \code{R} via modules. -} -\description{ -A zonotope is a convex polytope defined by the Minkowski sum of \eqn{m} \eqn{d}-dimensional segments. -} -\details{ -\describe{ - \item{\code{G} }{ A \eqn{m\times d} numerical matrix that contains the segments (or generators) row-wise} - -\item{\code{type} }{ An integer that declares the representation of the polytope. For zonotopes the default value is 3.} - -\item{\code{dimension} }{ The dimension of the polytope.} - -\item{\code{volume} }{ The volume of the polytope, if it is known.} - } -} -\keyword{internal} diff --git a/R-proj/man/Rcpp_sparse_constraint_problem.Rd b/R-proj/man/Rcpp_sparse_constraint_problem.Rd deleted file mode 100644 index 82f81f6c9..000000000 --- a/R-proj/man/Rcpp_sparse_constraint_problem.Rd +++ /dev/null @@ -1,34 +0,0 @@ -\docType{class} -\name{Rcpp_sparse_constraint_problem} -\alias{Rcpp_sparse_constraint_problem-class} -\alias{[,Rcpp_sparse_constraint_problem-method} -\alias{[,Rcpp_sparse_constraint_problem,ANY,ANY,ANY-method} -\alias{$<-,Rcpp_sparse_constraint_problem-method} -\alias{$,Rcpp_sparse_constraint_problem-method} -\alias{filepaths<-,Rcpp_sparse_constraint_problem-method} -\title{ -An \code{Rcpp} class to represent sparse_constraint_problems, exposed to \code{R} via modules. -} -\description{ -A constraint problem is defined by a set of linear inequalities and equalities or equivalently a \eqn{d}-dimensional constraint problem is defined by a \eqn{mineq\times d} matrix Aineq and a \eqn{mineq}-dimensional vector bineq, s.t.: \eqn{Aineqx\leq bineq}, a \eqn{meq\times d} matrix Aeq and a \eqn{meq}-dimensional vector beq, s.t.: \eqn{Aeqx= beq} and two \eqn{d} vectors lb, ub such that \eqn{lb\leq x \leq ub}.} -\details{ -\describe{ -\item{\code{Aineq} }{\eqn{mineq\times d} sparse matrix Aineq} - -\item{\code{bineq} }{\eqn{mineq}-dimensional vector bineq} - -\item{\code{Aeq} }{\eqn{meq\times d} sparse matrix Aeq} - -\item{\code{beq} }{\eqn{meq}-dimensional vector beq} - -\item{\code{lb} }{\eqn{d}-dimensional vector bineq} - -\item{\code{ub} }{\eqn{d}-dimensional vector bineq} - -\item{\code{type} }{An integer that declares the representation of the polytope. For sparse_constraint_problem the default value is 5.} - -\item{\code{dimension} }{The dimension of the polytope.} - - } -} -\keyword{internal} diff --git a/R-proj/man/Spectrahedron.Rd b/R-proj/man/Spectrahedron.Rd deleted file mode 100644 index 6c6df1d8a..000000000 --- a/R-proj/man/Spectrahedron.Rd +++ /dev/null @@ -1,12 +0,0 @@ -\name{Spectrahedron} -\alias{Spectrahedron} -\title{An \code{R} class to represent spectrahedra.} - -\description{ -A spectrahedron is a convex body defined by a linear matrix inequality of the form \eqn{A_0 + x_1 A_1 + ... + x_n A_n \preceq 0}. -The matrices \eqn{A_i} are symmetric \eqn{m \times m} real matrices and \eqn{\preceq 0} denoted negative semidefiniteness. -} -\section{Fields}{ -\itemize{ -\item{\code{matrices} }{A list with the matrices \eqn{A_0, A_1, ..., A_n}} -}} diff --git a/R-proj/man/Vpolytope.Rd b/R-proj/man/Vpolytope.Rd deleted file mode 100644 index e330af8b3..000000000 --- a/R-proj/man/Vpolytope.Rd +++ /dev/null @@ -1,17 +0,0 @@ -\name{Vpolytope} -\alias{Vpolytope} -\title{An \code{R} class to represent V-polytopes.} - -\description{ - A V-polytope is defined as the convex hull of \eqn{m} \eqn{d}-dimensional points which corresponds to its vertices. -} -\section{Fields}{ -\itemize{ - \item{\code{V} }{ A \eqn{m\times d} numerical matrix that contains the vertices row-wise} - - \item{\code{type} }{ An integer that declares the representation of the polytope. For V-representation the default value is 2.} - - \item{\code{dimension} }{ The dimension of the polytope.} - - \item{\code{volume} }{ The volume of the polytope, if it is known.} -}} diff --git a/R-proj/man/VpolytopeIntersection.Rd b/R-proj/man/VpolytopeIntersection.Rd deleted file mode 100644 index f7a75c662..000000000 --- a/R-proj/man/VpolytopeIntersection.Rd +++ /dev/null @@ -1,19 +0,0 @@ -\name{VpolytopeIntersection} -\alias{VpolytopeIntersection} -\title{An \code{R} class to represent the intersection of two V-polytopes.} - -\description{ - An intersection of two V-polytopes, \eqn{P_1}, \eqn{P_2}, is defined by the intersection of the two corresponding convex hulls. -} -\section{Fields}{ -\itemize{ -\item{\code{V1} }{ The numerical matrix that contains the vertices of \eqn{P_1} row-wise.} - -\item{\code{V2} }{ The numerical matrix that contains the vertices of \eqn{P_2} row-wise.} - -\item{\code{type} }{ An integer that declares the representation of the polytope. For this polytope the default value is 4.} - -\item{\code{dimension} }{ The dimension of the polytope.} - -\item{\code{volume} }{ The volume of the polytope, if it is known.} -}} diff --git a/R-proj/man/Zonotope.Rd b/R-proj/man/Zonotope.Rd deleted file mode 100644 index 959fbed5d..000000000 --- a/R-proj/man/Zonotope.Rd +++ /dev/null @@ -1,17 +0,0 @@ -\name{Zonotope} -\alias{Zonotope} -\title{An \code{R} class to represent zonotopes.} - -\description{ -A zonotope is a convex polytope defined by the Minkowski sum of \eqn{m} \eqn{d}-dimensional segments. -} -\section{Fields}{ -\itemize{ -\item{\code{G} }{ A \eqn{m\times d} numerical matrix that contains the segments (or generators) row-wise} - -\item{\code{type} }{ An integer that declares the representation of the polytope. For zonotopes the default value is 3.} - -\item{\code{dimension} }{ The dimension of the polytope.} - -\item{\code{volume} }{ The volume of the polytope, if it is known.} -}} diff --git a/R-proj/man/compute_indicators.Rd b/R-proj/man/compute_indicators.Rd deleted file mode 100644 index c0eaadd9e..000000000 --- a/R-proj/man/compute_indicators.Rd +++ /dev/null @@ -1,49 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/compute_indicators.R -\name{compute_indicators} -\alias{compute_indicators} -\title{Compute an indicator for each time period that describes the state of a market.} -\usage{ -compute_indicators( - returns, - win_length = NULL, - m = NULL, - n = NULL, - nwarning = NULL, - ncrisis = NULL, - seed = NULL -) -} -\arguments{ -\item{returns}{A \eqn{d}-dimensional vector that describes the direction of the first family of parallel hyperplanes.} - -\item{win_length}{Optional. The length of the sliding window. The default value is 60.} - -\item{m}{Optional. The number of slices for the copula. The default value is 100.} - -\item{n}{Optional. The number of points to sample. The default value is \eqn{5\cdot 10^5}.} - -\item{nwarning}{Optional. The number of consecutive indicators larger than 1 required to declare a warning period. The default value is 60.} - -\item{ncrisis}{Optional. The number of consecutive indicators larger than 1 required to declare a crisis period. The default value is 100.} - -\item{seed}{Optional. A fixed seed for the number generator.} -} -\value{ -A list that contains the indicators and the corresponding vector that label each time period with respect to the market state: a) normal, b) crisis, c) warning. -} -\description{ -Given a matrix that contains row-wise the assets' returns and a sliding window \code{win_length}, this function computes an approximation of the joint distribution (copula, e.g. see \url{https://en.wikipedia.org/wiki/Copula_(probability_theory)}) between portfolios' return and volatility in each time period defined by \code{win_len}. -For each copula it computes an indicator: If the indicator is large it corresponds to a crisis period and if it is small it corresponds to a normal period. -In particular, the periods over which the indicator is greater than 1 for more than 60 consecutive sliding windows are warnings and for more than 100 are crisis. The sliding window is shifted by one day. -} -\examples{ -# simple example on random asset returns -asset_returns = replicate(10, rnorm(14)) -market_states_and_indicators = compute_indicators(asset_returns, 10, 10, 10000, 2, 3) - -} -\references{ -\cite{L. Cales, A. Chalkis, I.Z. Emiris, V. Fisikopoulos, -\dQuote{Practical volume computation of structured convex bodies, and an application to modeling portfolio dependencies and financial crises,} \emph{Proc. of Symposium on Computational Geometry, Budapest, Hungary,} 2018.} -} diff --git a/R-proj/man/copula.Rd b/R-proj/man/copula.Rd deleted file mode 100644 index be99e4892..000000000 --- a/R-proj/man/copula.Rd +++ /dev/null @@ -1,48 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{copula} -\alias{copula} -\title{Construct a copula using uniform sampling from the unit simplex} -\usage{ -copula(r1, r2 = NULL, sigma = NULL, m = NULL, n = NULL, seed = NULL) -} -\arguments{ -\item{r1}{The \eqn{d}-dimensional normal vector of the first family of parallel hyperplanes.} - -\item{r2}{Optional. The \eqn{d}-dimensional normal vector of the second family of parallel hyperplanes.} - -\item{sigma}{Optional. The \eqn{d\times d} symmetric positive semidefine matrix that describes the family of concentric ellipsoids centered at the origin.} - -\item{m}{The number of the slices for the copula. The default value is 100.} - -\item{n}{The number of points to sample. The default value is \eqn{5\cdot 10^5}.} - -\item{seed}{Optional. A fixed seed for the number generator.} -} -\value{ -A \eqn{m\times m} numerical matrix that corresponds to a copula. -} -\description{ -Given two families of parallel hyperplanes or a family of parallel hyperplanes and a family of concentric ellispoids centered at the origin intersecting the canonical simplex, this function uniformly samples from the canonical simplex and construct an approximation of the bivariate probability distribution, called copula (see \url{https://en.wikipedia.org/wiki/Copula_(probability_theory)}). -At least two families of hyperplanes or one family of hyperplanes and one family of ellipsoids have to be given as input. -} -\examples{ -# compute a copula for two random families of parallel hyperplanes -h1 = runif(n = 10, min = 1, max = 1000) -h1 = h1 / 1000 -h2=runif(n = 10, min = 1, max = 1000) -h2 = h2 / 1000 -cop = copula(r1 = h1, r2 = h2, m = 10, n = 100000) - -# compute a copula for a family of parallel hyperplanes and a family of conentric ellipsoids -h = runif(n = 10, min = 1, max = 1000) -h = h / 1000 -E = replicate(10, rnorm(20)) -E = cov(E) -cop = copula(r1 = h, sigma = E, m = 10, n = 100000) - -} -\references{ -\cite{L. Cales, A. Chalkis, I.Z. Emiris, V. Fisikopoulos, -\dQuote{Practical volume computation of structured convex bodies, and an application to modeling portfolio dependencies and financial crises,} \emph{Proc. of Symposium on Computational Geometry, Budapest, Hungary,} 2018.} -} diff --git a/R-proj/man/dinvweibull_with_loc.Rd b/R-proj/man/dinvweibull_with_loc.Rd deleted file mode 100644 index b6600f816..000000000 --- a/R-proj/man/dinvweibull_with_loc.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/estimate_lipschitz_constant.R -\name{dinvweibull_with_loc} -\alias{dinvweibull_with_loc} -\title{Inverse weibull distribution PDF with location parameter} -\usage{ -dinvweibull_with_loc(x, k, lambda, theta) -} -\arguments{ -\item{x}{The argument of the PDF} - -\item{k}{The shape parameter} - -\item{lambda}{The scale parameter} - -\item{theta}{The location parameter} -} -\value{ -The value of the PDF of an Inverse Weibull distribution with parameters k, lambda, theta evaluated at x -} -\description{ -Inverse weibull distribution PDF with location parameter -} diff --git a/R-proj/man/direct_sampling.Rd b/R-proj/man/direct_sampling.Rd deleted file mode 100644 index 4609ec03d..000000000 --- a/R-proj/man/direct_sampling.Rd +++ /dev/null @@ -1,37 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{direct_sampling} -\alias{direct_sampling} -\title{Sample perfect uniformly distributed points from well known convex bodies: (a) the unit simplex, (b) the canonical simplex, (c) the boundary of a hypersphere or (d) the interior of a hypersphere.} -\usage{ -direct_sampling(body, n, seed = NULL) -} -\arguments{ -\item{body}{A list to request exact uniform sampling from special well known convex bodies through the following input parameters: -\itemize{ -\item{\code{type} }{ A string that declares the type of the body for the exact sampling: a) \code{'unit_simplex'} for the unit simplex, b) \code{'canonical_simplex'} for the canonical simplex, c) \code{'hypersphere'} for the boundary of a hypersphere centered at the origin, d) \code{'ball'} for the interior of a hypersphere centered at the origin.} -\item{\code{dimension} }{ An integer that declares the dimension when exact sampling is enabled for a simplex or a hypersphere.} -\item{\code{radius} }{ The radius of the \eqn{d}-dimensional hypersphere. The default value is \eqn{1}.} -}} - -\item{n}{The number of points that the function is going to sample.} - -\item{seed}{Optional. A fixed seed for the number generator.} -} -\value{ -A \eqn{d\times n} matrix that contains, column-wise, the sampled points from the convex polytope P. -} -\description{ -The \eqn{d}-dimensional unit simplex is the set of points \eqn{\vec{x}\in \R^d}, s.t.: \eqn{\sum_i x_i\leq 1}, \eqn{x_i\geq 0}. The \eqn{d}-dimensional canonical simplex is the set of points \eqn{\vec{x}\in \R^d}, s.t.: \eqn{\sum_i x_i = 1}, \eqn{x_i\geq 0}. -} -\examples{ -# 100 uniform points from the 2-d unit ball -points = direct_sampling(n = 100, body = list("type" = "ball", "dimension" = 2)) -} -\references{ -\cite{R.Y. Rubinstein and B. Melamed, -\dQuote{Modern simulation and modeling} \emph{ Wiley Series in Probability and Statistics,} 1998.} - -\cite{A Smith, Noah and W Tromble, Roy, -\dQuote{Sampling Uniformly from the Unit Simplex,} \emph{ Center for Language and Speech Processing Johns Hopkins University,} 2004.} -} diff --git a/R-proj/man/ess.Rd b/R-proj/man/ess.Rd deleted file mode 100644 index f9fbcbcb8..000000000 --- a/R-proj/man/ess.Rd +++ /dev/null @@ -1,24 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{ess} -\alias{ess} -\title{Gelman-Rubin and Brooks-Gelman Potential Scale Reduction Factor (PSRF) for each marginal} -\usage{ -ess(samples) -} -\arguments{ -\item{samples}{A matrix that contans column-wise the sampled points from a geometric random walk.} -} -\value{ -A vector that contains the values of PSRF for each coordinate -} -\description{ -Gelman-Rubin and Brooks-Gelman Potential Scale Reduction Factor (PSRF) for each marginal -} -\references{ -\cite{Gelman, A. and Rubin, D. B., -\dQuote{Inference from iterative simulation using multiple sequences,} \emph{Statistical Science,} 1992.} - -\cite{Brooks, S. and Gelman, A., -\dQuote{General Methods for Monitoring Convergence of Iterative Simulations,} \emph{Journal of Computational and Graphical Statistics,} 1998.} -} diff --git a/R-proj/man/estimtate_lipschitz_constant.Rd b/R-proj/man/estimtate_lipschitz_constant.Rd deleted file mode 100644 index 5418857d2..000000000 --- a/R-proj/man/estimtate_lipschitz_constant.Rd +++ /dev/null @@ -1,25 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/estimate_lipschitz_constant.R -\name{estimtate_lipschitz_constant} -\alias{estimtate_lipschitz_constant} -\title{Estimate the Lipschitz Constant of a function f} -\usage{ -estimtate_lipschitz_constant(f, P, n) -} -\arguments{ -\item{f}{Function whose Lipschitz constant is to be estimated} - -\item{P}{Domain of f (a convex polytope)} - -\item{n}{Number of samples to take - -The procedure draws n uniform samples from P and evaluates the Lipschitz -constant at subsequent samples (where the sampler moves to a new point), -It then returns the maximum observation} -} -\value{ -An estimate of the Lipschitz constant -} -\description{ -Estimate the Lipschitz Constant of a function f -} diff --git a/R-proj/man/exact_vol.Rd b/R-proj/man/exact_vol.Rd deleted file mode 100644 index 593247409..000000000 --- a/R-proj/man/exact_vol.Rd +++ /dev/null @@ -1,38 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{exact_vol} -\alias{exact_vol} -\title{Compute the exact volume of (a) a zonotope (b) an arbitrary simplex in V-representation or (c) if the volume is known and declared by the input object.} -\usage{ -exact_vol(P) -} -\arguments{ -\item{P}{A polytope} -} -\value{ -The exact volume of the input polytope, for zonotopes, simplices in V-representation and polytopes with known exact volume -} -\description{ -Given a zonotope (as an object of class Zonotope), this function computes the sum of the absolute values of the determinants of all the \eqn{d \times d} submatrices of the \eqn{m\times d} matrix \eqn{G} that contains row-wise the \eqn{m} \eqn{d}-dimensional segments that define the zonotope. -For an arbitrary simplex that is given in V-representation this function computes the absolute value of the determinant formed by the simplex's points assuming it is shifted to the origin. -} -\examples{ - -# compute the exact volume of a 5-dimensional zonotope defined by the Minkowski sum of 10 segments -Z = gen_rand_zonotope(2, 5) -vol = exact_vol(Z) - -\donttest{# compute the exact volume of a 2-d arbitrary simplex -V = matrix(c(2,3,-1,7,0,0),ncol = 2, nrow = 3, byrow = TRUE) -P = Vpolytope$new(V) -vol = exact_vol(P) -} - -# compute the exact volume the 10-dimensional cross polytope -P = gen_cross(10,'V') -vol = exact_vol(P) -} -\references{ -\cite{E. Gover and N. Krikorian, -\dQuote{Determinants and the Volumes of Parallelotopes and Zonotopes,} \emph{Linear Algebra and its Applications, 433(1), 28 - 40,} 2010.} -} diff --git a/R-proj/man/file_to_polytope.Rd b/R-proj/man/file_to_polytope.Rd deleted file mode 100644 index 8ec843d53..000000000 --- a/R-proj/man/file_to_polytope.Rd +++ /dev/null @@ -1,20 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/file_to_polytope.R -\name{file_to_polytope} -\alias{file_to_polytope} -\title{function to get an ine or an ext file and returns the corresponding polytope} -\usage{ -file_to_polytope(path, zonotope = FALSE) -} -\arguments{ -\item{path}{A string that containes the path to an ine or a ext file. The ine file desrcibes a H-polytope and ext file describes a V-polytope or a zonotope.} - -\item{zonotope}{A boolean parameter. It has to be TRUE when the path leads to an .ext file that describes a zonotope.} -} -\value{ -A polytope class. If the path corresponds to an ine file then the return value represents a H-polytope. If it corresponds to an ext file the return value represents a V-polytope (default choice) or a zonotope if the second argument is TRUE. -} -\description{ -For an ".ine" file it generates the corresponding H-polytope. For an ".ext" file it generates the corresponding V-polytope or zonotope. -For more details on those file formats see \url{https://github.com/GeomScale/volume_approximation/blob/develop/doc/cpp_interface.md#polytope-input}. -} diff --git a/R-proj/man/frustum_of_simplex.Rd b/R-proj/man/frustum_of_simplex.Rd deleted file mode 100644 index bcb075eb4..000000000 --- a/R-proj/man/frustum_of_simplex.Rd +++ /dev/null @@ -1,32 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{frustum_of_simplex} -\alias{frustum_of_simplex} -\title{Compute the percentage of the volume of the simplex that is contained in the intersection of a half-space and the simplex.} -\usage{ -frustum_of_simplex(a, z0) -} -\arguments{ -\item{a}{A \eqn{d}-dimensional vector that defines the direction of the hyperplane.} - -\item{z0}{The scalar that defines the half-space.} -} -\value{ -The percentage of the volume of the simplex that is contained in the intersection of a given half-space and the simplex. -} -\description{ -A half-space \eqn{H} is given as a pair of a vector \eqn{a\in R^d} and a scalar \eqn{z0\in R} s.t.: \eqn{a^Tx\leq z0}. This function calls the Ali's version of the Varsi formula to compute a frustum of the simplex. -} -\examples{ -# compute the frustum of H: -x1+x2<=0 -a=c(-1,1) -z0=0 -frustum = frustum_of_simplex(a, z0) -} -\references{ -\cite{Varsi, Giulio, -\dQuote{The multidimensional content of the frustum of the simplex,} \emph{Pacific J. Math. 46, no. 1, 303--314,} 1973.} - -\cite{Ali, Mir M., -\dQuote{Content of the frustum of a simplex,} \emph{ Pacific J. Math. 48, no. 2, 313--322,} 1973.} -} diff --git a/R-proj/man/gen_birkhoff.Rd b/R-proj/man/gen_birkhoff.Rd deleted file mode 100644 index b5659c021..000000000 --- a/R-proj/man/gen_birkhoff.Rd +++ /dev/null @@ -1,22 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/gen_birkhoff.R -\name{gen_birkhoff} -\alias{gen_birkhoff} -\title{Generator function for Birkhoff polytope} -\usage{ -gen_birkhoff(n) -} -\arguments{ -\item{n}{The order of the Birkhoff polytope} -} -\value{ -A polytope class representing the full dimensional \eqn{n}-Birkhoff polytope in H-representation. -} -\description{ -This function can be used to generate the full dimensional \eqn{n}-Birkhoff polytope in H-representation. -The dimension of the generated polytope is \eqn{(n-1)^2}. -} -\examples{ -# generate the Birkhoff polytope of order 5 -P = gen_birkhoff(5) -} diff --git a/R-proj/man/gen_cross.Rd b/R-proj/man/gen_cross.Rd deleted file mode 100644 index 53e84c78d..000000000 --- a/R-proj/man/gen_cross.Rd +++ /dev/null @@ -1,26 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/gen_cross.R -\name{gen_cross} -\alias{gen_cross} -\title{Generator function for cross polytopes} -\usage{ -gen_cross(dimension, representation) -} -\arguments{ -\item{dimension}{The dimension of the cross polytope.} - -\item{representation}{A string to declare the representation. It has to be \code{'H'} for H-representation or \code{'V'} for V-representation.} -} -\value{ -A polytope class representing a cross polytope in H- or V-representation. -} -\description{ -This function generates the \eqn{d}-dimensional cross polytope in H- or V-representation. -} -\examples{ -# generate a 10-dimensional cross polytope in H-representation -P = gen_cross(5, 'H') - -# generate a 15-dimension cross polytope in V-representation -P = gen_cross(15, 'V') -} diff --git a/R-proj/man/gen_cube.Rd b/R-proj/man/gen_cube.Rd deleted file mode 100644 index efb486d61..000000000 --- a/R-proj/man/gen_cube.Rd +++ /dev/null @@ -1,26 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/gen_cube.R -\name{gen_cube} -\alias{gen_cube} -\title{Generator function for hypercubes} -\usage{ -gen_cube(dimension, representation) -} -\arguments{ -\item{dimension}{The dimension of the hypercube} - -\item{representation}{A string to declare the representation. It has to be \code{'H'} for H-representation or \code{'V'} for V-representation.} -} -\value{ -A polytope class representing the unit \eqn{d}-dimensional hypercube in H- or V-representation. -} -\description{ -This function generates the \eqn{d}-dimensional unit hypercube \eqn{[-1,1]^d} in H- or V-representation. -} -\examples{ -# generate a 10-dimensional hypercube in H-representation -P = gen_cube(10, 'H') - -# generate a 15-dimension hypercube in V-representation -P = gen_cube(5, 'V') -} diff --git a/R-proj/man/gen_prod_simplex.Rd b/R-proj/man/gen_prod_simplex.Rd deleted file mode 100644 index 108a2dc1b..000000000 --- a/R-proj/man/gen_prod_simplex.Rd +++ /dev/null @@ -1,21 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/gen_prod_simplex.R -\name{gen_prod_simplex} -\alias{gen_prod_simplex} -\title{Generator function for product of simplices} -\usage{ -gen_prod_simplex(dimension) -} -\arguments{ -\item{dimension}{The dimension of the simplices.} -} -\value{ -A polytope class representing the product of the two \eqn{d}-dimensional unit simplices in H-representation. -} -\description{ -This function generates a \eqn{2d}-dimensional polytope that is defined as the product of two \eqn{d}-dimensional unit simplices in H-representation. -} -\examples{ -# generate a product of two 5-dimensional simplices. -P = gen_prod_simplex(5) -} diff --git a/R-proj/man/gen_rand_hpoly.Rd b/R-proj/man/gen_rand_hpoly.Rd deleted file mode 100644 index e4db1c9e5..000000000 --- a/R-proj/man/gen_rand_hpoly.Rd +++ /dev/null @@ -1,25 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/gen_rand_hpoly.R -\name{gen_rand_hpoly} -\alias{gen_rand_hpoly} -\title{Generator function for random H-polytopes} -\usage{ -gen_rand_hpoly(dimension, nfacets, seed = NULL) -} -\arguments{ -\item{dimension}{The dimension of the convex polytope.} - -\item{nfacets}{The number of the facets.} - -\item{seed}{Optional. A fixed seed for the generator.} -} -\value{ -A polytope class representing a H-polytope. -} -\description{ -This function generates a \eqn{d}-dimensional polytope in H-representation with \eqn{m} facets. We pick \eqn{m} random hyperplanes tangent on the \eqn{d}-dimensional unit hypersphere as facets. -} -\examples{ -# generate a 10-dimensional polytope with 50 facets -P = gen_rand_hpoly(10, 50) -} diff --git a/R-proj/man/gen_rand_vpoly.Rd b/R-proj/man/gen_rand_vpoly.Rd deleted file mode 100644 index e2c3c0978..000000000 --- a/R-proj/man/gen_rand_vpoly.Rd +++ /dev/null @@ -1,27 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/gen_rand_vpoly.R -\name{gen_rand_vpoly} -\alias{gen_rand_vpoly} -\title{Generator function for random V-polytopes} -\usage{ -gen_rand_vpoly(dimension, nvertices, generator = NULL, seed = NULL) -} -\arguments{ -\item{dimension}{The dimension of the convex polytope.} - -\item{nvertices}{The number of the vertices.} - -\item{generator}{The body that the generator samples uniformly the vertices from: (a) 'cube' or (b) 'sphere'.} - -\item{seed}{Optional. A fixed seed for the generator.} -} -\value{ -A polytope class representing a V-polytope. -} -\description{ -This function generates a \eqn{d}-dimensional polytope in V-representation with \eqn{m} vertices. We pick \eqn{m} random points from the boundary of the \eqn{d}-dimensional unit hypersphere as vertices. -} -\examples{ -# generate a 10-dimensional polytope defined as the convex hull of 25 random vertices -P = gen_rand_vpoly(10, 25) -} diff --git a/R-proj/man/gen_rand_zonotope.Rd b/R-proj/man/gen_rand_zonotope.Rd deleted file mode 100644 index ab971d35e..000000000 --- a/R-proj/man/gen_rand_zonotope.Rd +++ /dev/null @@ -1,28 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/gen_rand_zonotope.R -\name{gen_rand_zonotope} -\alias{gen_rand_zonotope} -\title{Generator function for zonotopes} -\usage{ -gen_rand_zonotope(dimension, nsegments, generator = NULL, seed = NULL) -} -\arguments{ -\item{dimension}{The dimension of the zonotope.} - -\item{nsegments}{The number of segments that generate the zonotope.} - -\item{generator}{The distribution to pick the length of each segment from \eqn{[0,100]}: (a) 'uniform', (b) 'gaussian' or (c) 'exponential'.} - -\item{seed}{Optional. A fixed seed for the generator.} -} -\value{ -A polytope class representing a zonotope. -} -\description{ -This function generates a random \eqn{d}-dimensional zonotope defined by the Minkowski sum of \eqn{m} \eqn{d}-dimensional segments. -The function considers \eqn{m} random directions in \eqn{R^d}. There are three strategies to pick the length of each segment: a) it is uniformly sampled from \eqn{[0,100]}, b) it is random from \eqn{\mathcal{N}(50,(50/3)^2)} truncated to \eqn{[0,100]}, c) it is random from \eqn{Exp(1/30)} truncated to \eqn{[0,100]}. -} -\examples{ -# generate a 10-dimensional zonotope defined by the Minkowski sum of 20 segments -P = gen_rand_zonotope(10, 20) -} diff --git a/R-proj/man/gen_simplex.Rd b/R-proj/man/gen_simplex.Rd deleted file mode 100644 index bed04a3a6..000000000 --- a/R-proj/man/gen_simplex.Rd +++ /dev/null @@ -1,26 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/gen_simplex.R -\name{gen_simplex} -\alias{gen_simplex} -\title{Generator function for simplices} -\usage{ -gen_simplex(dimension, representation) -} -\arguments{ -\item{dimension}{The dimension of the unit simplex.} - -\item{representation}{A string to declare the representation. It has to be \code{'H'} for H-representation or \code{'V'} for V-representation.} -} -\value{ -A polytope class representing the \eqn{d}-dimensional unit simplex in H- or V-representation. -} -\description{ -This function generates the \eqn{d}-dimensional unit simplex in H- or V-representation. -} -\examples{ -# generate a 10-dimensional simplex in H-representation -PolyList = gen_simplex(10, 'H') - -# generate a 20-dimensional simplex in V-representation -P = gen_simplex(20, 'V') -} diff --git a/R-proj/man/gen_skinny_cube.Rd b/R-proj/man/gen_skinny_cube.Rd deleted file mode 100644 index 916f5e20a..000000000 --- a/R-proj/man/gen_skinny_cube.Rd +++ /dev/null @@ -1,21 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/gen_skinny_cube.R -\name{gen_skinny_cube} -\alias{gen_skinny_cube} -\title{Generator function for skinny hypercubes} -\usage{ -gen_skinny_cube(dimension) -} -\arguments{ -\item{dimension}{The dimension of the skinny hypercube.} -} -\value{ -A polytope class representing the \eqn{d}-dimensional skinny hypercube in H-representation. -} -\description{ -This function generates a \eqn{d}-dimensional skinny hypercube \eqn{[-1,1]^{d-1}\times [-100,100]}. -} -\examples{ -# generate a 10-dimensional skinny hypercube. -P = gen_skinny_cube(10) -} diff --git a/R-proj/man/geweke.Rd b/R-proj/man/geweke.Rd deleted file mode 100644 index bcaa199d8..000000000 --- a/R-proj/man/geweke.Rd +++ /dev/null @@ -1,25 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{geweke} -\alias{geweke} -\title{Geweke's MCMC diagnostic} -\usage{ -geweke(samples, frac_first = NULL, frac_last = NULL) -} -\arguments{ -\item{samples}{A matrix that contans column-wise the sampled points from a geometric random walk.} - -\item{frac_first}{Optional. The portion of the first in order points in matrix samples.} - -\item{frac_last}{Optional. The portion of the last in order points in matrix samples.} -} -\value{ -A boolean to denote if the result of Geweke diagnostic: (i) false if the null hypothesis is rejected, (ii) true if the null hypothesis is not rejected. -} -\description{ -Geweke's MCMC diagnostic -} -\references{ -\cite{Geweke, J., -\dQuote{Evaluating the accuracy of sampling-based approaches to the calculation of posterior moments,} \emph{ In Bayesian Statistics 4. Proceedings of the Fourth Valencia International Meeting,} 1992.} -} diff --git a/R-proj/man/inner_ball.Rd b/R-proj/man/inner_ball.Rd deleted file mode 100644 index f267faad1..000000000 --- a/R-proj/man/inner_ball.Rd +++ /dev/null @@ -1,29 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{inner_ball} -\alias{inner_ball} -\title{Compute an inscribed ball of a convex polytope} -\usage{ -inner_ball(P, lpsolve = NULL) -} -\arguments{ -\item{P}{A convex polytope. It is an object from class (a) Hpolytope or (b) Vpolytope or (c) Zonotope or (d) VpolytopeIntersection.} - -\item{lpsolve}{Optional. A boolean variable to compute the Chebychev ball of an H-polytope using the lpsolve library.} -} -\value{ -A \eqn{(d+1)}-dimensional vector that describes the inscribed ball. The first \eqn{d} coordinates corresponds to the center of the ball and the last one to the radius. -} -\description{ -For a H-polytope described by a \eqn{m\times d} matrix \eqn{A} and a \eqn{m}-dimensional vector \eqn{b}, s.t.: \eqn{P=\{x\ |\ Ax\leq b\} }, this function computes the largest inscribed ball (Chebychev ball) by solving the corresponding linear program. -For both zonotopes and V-polytopes the function computes the minimum \eqn{r} s.t.: \eqn{ r e_i \in P} for all \eqn{i=1, \dots ,d}. Then the ball centered at the origin with radius \eqn{r/ \sqrt{d}} is an inscribed ball. -} -\examples{ -# compute the Chebychev ball of the 2d unit simplex -P = gen_cube(10,'H') -ball_vec = inner_ball(P) - -# compute an inscribed ball of the 3-dimensional unit cube in V-representation -P = gen_cube(3, 'V') -ball_vec = inner_ball(P, lpsolve = TRUE) -} diff --git a/R-proj/man/loadSdpaFormatFile.Rd b/R-proj/man/loadSdpaFormatFile.Rd deleted file mode 100644 index bb6aa7558..000000000 --- a/R-proj/man/loadSdpaFormatFile.Rd +++ /dev/null @@ -1,21 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{loadSdpaFormatFile} -\alias{loadSdpaFormatFile} -\title{Read a SDPA format file} -\usage{ -loadSdpaFormatFile(inputFile = NULL) -} -\arguments{ -\item{inputFile}{Name of the input file} -} -\value{ -A list with two named items: an item "matrices" which is a list of the matrices and an vector "objFunction" -} -\description{ -Read a SDPA format file -} -\examples{ -path = system.file('extdata', package = 'volesti') -l = loadSdpaFormatFile(paste0(path,'/sdpa_n2m3.txt')) -} diff --git a/R-proj/man/ode_solve.Rd b/R-proj/man/ode_solve.Rd deleted file mode 100644 index b4e8e4b90..000000000 --- a/R-proj/man/ode_solve.Rd +++ /dev/null @@ -1,47 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{ode_solve} -\alias{ode_solve} -\title{Solve an ODE of the form dx^n / dt^n = F(x, t)} -\usage{ -ode_solve( - n, - step_size, - order, - dimension, - initial_time, - F, - method, - domains = NULL, - initial_conditions = NULL -) -} -\arguments{ -\item{n}{The number of steps.} - -\item{step_size}{The step size.} - -\item{order}{The ODE order (default is n = 1)} - -\item{dimension}{The dimension of each derivative} - -\item{initial_time}{The initial time} - -\item{F}{The function oracle F(x, t) in the ODE.} - -\item{method}{The method to be used} - -\item{domains}{A list of n H-polytopes with keys "P_1", "P_2", ..., "P_n" that correspond to each derivative's domain} - -\item{initial_conditions}{The initial conditions provided to the solver. Must be provided in a list with keys "x_1", ..., "x_n" and column vectors as values. The state "x_n" represents the (n-1)-th order derivative with respect to time} -} -\value{ -A list which contains elements "x_1", ..., "x_n" representing each derivative results. Each "x_i" corresponds to a d x n matrix where each column represents a certain timestep of the solver. -} -\description{ -Solve an ODE of the form dx^n / dt^n = F(x, t) -} -\examples{ -# Please visit the examples directory on examples demonstrating usage of the ODE solvers. - -} diff --git a/R-proj/man/pinvweibull_with_loc.Rd b/R-proj/man/pinvweibull_with_loc.Rd deleted file mode 100644 index 08eecf30c..000000000 --- a/R-proj/man/pinvweibull_with_loc.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/estimate_lipschitz_constant.R -\name{pinvweibull_with_loc} -\alias{pinvweibull_with_loc} -\title{Inverse weibull distribution CDF with location parameter} -\usage{ -pinvweibull_with_loc(q, k, lambda, theta) -} -\arguments{ -\item{q}{The argument of the CDF} - -\item{k}{The shape parameter} - -\item{lambda}{The scale parameter} - -\item{theta}{The location parameter} -} -\value{ -The value of the CDF of an Inverse Weibull distribution with parameters k, lambda, theta evaluated at q -} -\description{ -Inverse weibull distribution CDF with location parameter -} diff --git a/R-proj/man/poly_gen.Rd b/R-proj/man/poly_gen.Rd deleted file mode 100644 index be2ed4dd0..000000000 --- a/R-proj/man/poly_gen.Rd +++ /dev/null @@ -1,28 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{poly_gen} -\alias{poly_gen} -\title{An internal Rccp function as a polytope generator} -\usage{ -poly_gen(kind_gen, Vpoly_gen, Zono_gen, dim_gen, m_gen, seed = NULL) -} -\arguments{ -\item{kind_gen}{An integer to declare the type of the polytope.} - -\item{Vpoly_gen}{A boolean parameter to declare if the requested polytope has to be in V-representation.} - -\item{Zono_gen}{A boolean parameter to declare if the requested polytope has to be a zonotope.} - -\item{dim_gen}{An integer to declare the dimension of the requested polytope.} - -\item{m_gen}{An integer to declare the number of generators for the requested random zonotope or the number of vertices for a V-polytope.} - -\item{seed}{Optional. A fixed seed for the random polytope generator.} -} -\value{ -A numerical matrix describing the requested polytope -} -\description{ -An internal Rccp function as a polytope generator -} -\keyword{internal} diff --git a/R-proj/man/psrf_multivariate.Rd b/R-proj/man/psrf_multivariate.Rd deleted file mode 100644 index b941783fa..000000000 --- a/R-proj/man/psrf_multivariate.Rd +++ /dev/null @@ -1,24 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{psrf_multivariate} -\alias{psrf_multivariate} -\title{Gelman-Rubin Potential Scale Reduction Factor (PSRF)} -\usage{ -psrf_multivariate(samples) -} -\arguments{ -\item{samples}{A matrix that contans column-wise the sampled points from a geometric random walk.} -} -\value{ -The value of multivariate PSRF by S. Brooks and A. Gelman. -} -\description{ -Gelman-Rubin Potential Scale Reduction Factor (PSRF) -} -\references{ -\cite{Gelman, A. and Rubin, D. B., -\dQuote{Inference from iterative simulation using multiple sequences,} \emph{Statistical Science,} 1992.} - -\cite{Brooks, S. and Gelman, A., -\dQuote{General Methods for Monitoring Convergence of Iterative Simulations,} \emph{Journal of Computational and Graphical Statistics,} 1998.} -} diff --git a/R-proj/man/psrf_univariate.Rd b/R-proj/man/psrf_univariate.Rd deleted file mode 100644 index 45aff7ee0..000000000 --- a/R-proj/man/psrf_univariate.Rd +++ /dev/null @@ -1,26 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{psrf_univariate} -\alias{psrf_univariate} -\title{Gelman-Rubin and Brooks-Gelman Potential Scale Reduction Factor (PSRF) for each marginal} -\usage{ -psrf_univariate(samples, method = NULL) -} -\arguments{ -\item{samples}{A matrix that contans column-wise the sampled points from a geometric random walk.} - -\item{method}{A string to reauest diagnostic: (i) \code{'normal'} for psrf of Gelman-Rubin and (ii) \code{'interval'} for psrf of Brooks-Gelman.} -} -\value{ -A vector that contains the values of PSRF for each coordinate -} -\description{ -Gelman-Rubin and Brooks-Gelman Potential Scale Reduction Factor (PSRF) for each marginal -} -\references{ -\cite{Gelman, A. and Rubin, D. B., -\dQuote{Inference from iterative simulation using multiple sequences,} \emph{Statistical Science,} 1992.} - -\cite{Brooks, S. and Gelman, A., -\dQuote{General Methods for Monitoring Convergence of Iterative Simulations,} \emph{Journal of Computational and Graphical Statistics,} 1998.} -} diff --git a/R-proj/man/raftery.Rd b/R-proj/man/raftery.Rd deleted file mode 100644 index 0415442e7..000000000 --- a/R-proj/man/raftery.Rd +++ /dev/null @@ -1,27 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{raftery} -\alias{raftery} -\title{Raftery and Lewis MCMC diagnostic} -\usage{ -raftery(samples, q = NULL, r = NULL, s = NULL) -} -\arguments{ -\item{samples}{A matrix that contans column-wise the sampled points from a geometric random walk.} - -\item{q}{Optional. The quantile of the quantity of interest. The default value is 0.025.} - -\item{r}{Optional. The level of precision desired. The default value is 0.01.} - -\item{s}{Optional. The probability associated with r. The default value is 0.95.} -} -\value{ -(i) The number of draws required for burn-in, (ii) the skip parameter for 1st-order Markov chain, (iii) the skip parameter sufficient to get independence chain, (iv) the number of draws required to achieve r precision, (v) the number of draws if the chain is white noise, (vi) the I-statistic from Raftery and Lewis (1992). -} -\description{ -Raftery and Lewis MCMC diagnostic -} -\references{ -\cite{Raftery, A. E. and Lewis, S. M., -\dQuote{How many iterations in the Gibbs sampler?,} \emph{Bayesian Statistics 4. Proceedings of the Fourth Valencia International Meeting,} 1992.} -} diff --git a/R-proj/man/readSdpaFormatFile.Rd b/R-proj/man/readSdpaFormatFile.Rd deleted file mode 100644 index 878a11965..000000000 --- a/R-proj/man/readSdpaFormatFile.Rd +++ /dev/null @@ -1,24 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_sdpa_file.R -\name{readSdpaFormatFile} -\alias{readSdpaFormatFile} -\title{Read a SDPA format file} -\usage{ -readSdpaFormatFile(path) -} -\arguments{ -\item{path}{Name of the input file} -} -\value{ -A list with two named items: an item "matrices" which is an object of class Spectrahedron and an vector "objFunction" -} -\description{ -Read a SDPA format file and return a spectrahedron (an object of class Spectrahedron) which is defined by -the linear matrix inequality in the input file, and the objective function. -} -\examples{ -path = system.file('extdata', package = 'volesti') -l = readSdpaFormatFile(paste0(path,'/sdpa_n2m3.txt')) -Spectrahedron = l$spectrahedron -objFunction = l$objFunction -} diff --git a/R-proj/man/rotate_polytope.Rd b/R-proj/man/rotate_polytope.Rd deleted file mode 100644 index 70c9c3adf..000000000 --- a/R-proj/man/rotate_polytope.Rd +++ /dev/null @@ -1,43 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/rotate_polytope.R -\name{rotate_polytope} -\alias{rotate_polytope} -\title{Apply a random rotation to a convex polytope (H-polytope, V-polytope, zonotope or intersection of two V-polytopes)} -\usage{ -rotate_polytope(P, T = NULL, seed = NULL) -} -\arguments{ -\item{P}{A convex polytope. It is an object from class (a) Hpolytope, (b) Vpolytope, (c) Zonotope, (d) intersection of two V-polytopes.} - -\item{T}{Optional. A \eqn{d\times d} rotation matrix.} - -\item{seed}{Optional. A fixed seed for the random linear map generator.} -} -\value{ -A list that contains the rotated polytope and the matrix \eqn{T} of the linear transformation. -} -\description{ -Given a convex H- or V- polytope or a zonotope or an intersection of two V-polytopes as input, this function applies (a) a random rotation or (b) a given rotation by an input matrix \eqn{T}. -} -\details{ -Let \eqn{P} be the given polytope and \eqn{Q} the rotated one and \eqn{T} be the matrix of the linear transformation. -\itemize{ -\item{If \eqn{P} is in H-representation and \eqn{A} is the matrix that contains the normal vectors of the facets of \eqn{Q} then \eqn{AT} contains the normal vactors of the facets of \eqn{P}.} -\item{If \eqn{P} is in V-representation and \eqn{V} is the matrix that contains column-wise the vertices of \eqn{Q} then \eqn{T^TV} contains the vertices of \eqn{P}.} -\item{If \eqn{P} is a zonotope and \eqn{G} is the matrix that contains column-wise the generators of \eqn{Q} then \eqn{T^TG} contains the generators of \eqn{P}.} -\item{If \eqn{M} is a matrix that contains column-wise points in \eqn{Q} then \eqn{T^TM} contains points in \eqn{P}.} -} -} -\examples{ -# rotate a H-polytope (2d unit simplex) -P = gen_simplex(2,'H') -poly_matrix_list = rotate_polytope(P) - -# rotate a V-polytope (3d cube) -P = gen_cube(3, 'V') -poly_matrix_list = rotate_polytope(P) - -# rotate a 5-dimensional zonotope defined by the Minkowski sum of 15 segments -Z = gen_rand_zonotope(3,6) -poly_matrix_list = rotate_polytope(Z) -} diff --git a/R-proj/man/rotating.Rd b/R-proj/man/rotating.Rd deleted file mode 100644 index 4b091f815..000000000 --- a/R-proj/man/rotating.Rd +++ /dev/null @@ -1,22 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{rotating} -\alias{rotating} -\title{An internal Rccp function for the random rotation of a convex polytope} -\usage{ -rotating(P, T = NULL, seed = NULL) -} -\arguments{ -\item{P}{A convex polytope (H-, V-polytope or a zonotope).} - -\item{T}{Optional. A rotation matrix.} - -\item{seed}{Optional. A fixed seed for the random linear map generator.} -} -\value{ -A matrix that describes the rotated polytope -} -\description{ -An internal Rccp function for the random rotation of a convex polytope -} -\keyword{internal} diff --git a/R-proj/man/round_polytope.Rd b/R-proj/man/round_polytope.Rd deleted file mode 100644 index 787e40fb0..000000000 --- a/R-proj/man/round_polytope.Rd +++ /dev/null @@ -1,47 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/round_polytope.R -\name{round_polytope} -\alias{round_polytope} -\title{Apply rounding to a convex polytope (H-polytope, V-polytope or a zonotope)} -\usage{ -round_polytope(P, method = NULL, seed = NULL) -} -\arguments{ -\item{P}{A convex polytope. It is an object from class (a) Hpolytope or (b) Vpolytope or (c) Zonotope.} - -\item{method}{Optional. The method to use for rounding, a) \code{'min_ellipsoid'} for the method based on mimimmum volume enclosing ellipsoid of a dataset, b) \code{'max_ellipsoid'} for the method based on maximum volume enclosed ellipsoid, (c) \code{'isotropy'} for the method based on svd decomposition. The default method is \code{'mee'} for all the representations.} - -\item{seed}{Optional. A fixed seed for the number generator.} -} -\value{ -A list with 4 elements: (a) a polytope of the same class as the input polytope class and (b) the element "T" which is the matrix of the inverse linear transformation that is applied on the input polytope, (c) the element "shift" which is the opposite vector of that which has shifted the input polytope, (d) the element "round_value" which is the determinant of the square matrix of the linear transformation that is applied on the input polytope. -} -\description{ -Given a convex H or V polytope or a zonotope as input this function brings the polytope in rounded position based on minimum volume enclosing ellipsoid of a pointset. -} -\examples{ -# round a 5d skinny cube -P = gen_skinny_cube(5) -listHpoly = round_polytope(P) - -# round a V-polytope (3d unit cube) -P = gen_cube(3, 'V') -ListVpoly = round_polytope(P) - -# round a 2-dimensional zonotope defined by 6 generators -Z = gen_rand_zonotope(2,6) -ListZono = round_polytope(Z) -} -\references{ -\cite{I.Z.Emiris and V. Fisikopoulos, -\dQuote{Practical polytope volume approximation,} \emph{ACM Trans. Math. Soft.,} 2018.}, - -\cite{Michael J. Todd and E. Alper Yildirim, -\dQuote{On Khachiyan’s Algorithm for the Computation of Minimum Volume Enclosing Ellipsoids,} \emph{Discrete Applied Mathematics,} 2007.} - -\cite{B. Cousins and S. Vempala, -\dQuote{A practical volume algorithm,} \emph{Math. Prog. Comp.,} 2016.}, - -\cite{Yin Zhang and Liyan Gao, -\dQuote{On Numerical Solution of the Maximum Volume Ellipsoid Problem,} \emph{SIAM Journal on Optimization,} 2003.}, -} diff --git a/R-proj/man/rounding.Rd b/R-proj/man/rounding.Rd deleted file mode 100644 index 75be33968..000000000 --- a/R-proj/man/rounding.Rd +++ /dev/null @@ -1,22 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{rounding} -\alias{rounding} -\title{Internal rcpp function for the rounding of a convex polytope} -\usage{ -rounding(P, method = NULL, seed = NULL) -} -\arguments{ -\item{P}{A convex polytope (H- or V-representation or zonotope).} - -\item{method}{Optional. The method to use for rounding, a) \code{'min_ellipsoid'} for the method based on mimimmum volume enclosing ellipsoid of a uniform sample from P, b) \code{'max_ellipsoid'} for the method based on maximum volume enclosed ellipsoid in P, (c) \code{'isotropy'} for the method based on isotropy. The default method is \code{'min_ellipsoid'} for all the representations.} - -\item{seed}{Optional. A fixed seed for the number generator.} -} -\value{ -A numerical matrix that describes the rounded polytope, a numerical matrix of the inverse linear transofmation that is applied on the input polytope, the numerical vector the the input polytope is shifted and the determinant of the matrix of the linear transformation that is applied on the input polytope. -} -\description{ -Internal rcpp function for the rounding of a convex polytope -} -\keyword{internal} diff --git a/R-proj/man/sample_points.Rd b/R-proj/man/sample_points.Rd deleted file mode 100644 index e969e557d..000000000 --- a/R-proj/man/sample_points.Rd +++ /dev/null @@ -1,82 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{sample_points} -\alias{sample_points} -\title{Sample uniformly, normally distributed, or logconcave distributed points from a convex Polytope (H-polytope, V-polytope, zonotope or intersection of two V-polytopes).} -\usage{ -sample_points(P, n, random_walk = NULL, distribution = NULL, seed = NULL) -} -\arguments{ -\item{P}{A convex polytope. It is an object from class (a) Hpolytope or (b) Vpolytope or (c) Zonotope or (d) VpolytopeIntersection or (e) sparse_constraint_problem.} - -\item{n}{The number of points that the function is going to sample from the convex polytope.} - -\item{random_walk}{Optional. A list that declares the random walk and some related parameters as follows: -\itemize{ -\item{\code{walk} }{ A string to declare the random walk: i) \code{'CDHR'} for Coordinate Directions Hit-and-Run, ii) \code{'RDHR'} for Random Directions Hit-and-Run, iii) \code{'BaW'} for Ball Walk, iv) \code{'BiW'} for Billiard walk, v) \code{'dikin'} for dikin walk, vi) \code{'vaidya'} for vaidya walk, vii) \code{'john'} for john walk, viii) \code{'BCDHR'} boundary sampling by keeping the extreme points of CDHR or ix) \code{'BRDHR'} boundary sampling by keeping the extreme points of RDHR, x) \code{'NUTS'} for NUTS Hamiltonian Monte Carlo sampler (logconcave densities), xi) \code{'HMC'} for Hamiltonian Monte Carlo (logconcave densities), xii) CRHMC for Riemannian HMC with H-polytope constraints (uniform and general logconcave densities), xiii) \code{'ULD'} for Underdamped Langevin Dynamics using the Randomized Midpoint Method (logconcave densities), xiii) \code{'ExactHMC'} for exact Hamiltonian Monte Carlo with reflections (spherical Gaussian or exponential distribution). The default walk is \code{'aBiW'} for the uniform distribution, \code{'CDHR'} for the Gaussian distribution and H-polytopes and \code{'BiW'} or \code{'RDHR'} for the same distributions and V-polytopes and zonotopes. \code{'NUTS'} is the default sampler for logconcave densities and \code{'CRHMC'} for logconcave densities with H-polytope and sparse constrainted problems.} -\item{\code{walk_length} }{ The number of the steps per generated point for the random walk. The default value is \eqn{1}.} -\item{\code{nburns} }{ The number of points to burn before start sampling. The default value is \eqn{1}.} -\item{\code{starting_point} }{ A \eqn{d}-dimensional numerical vector that declares a starting point in the interior of the polytope for the random walk. The default choice is the center of the ball as that one computed by the function \code{inner_ball()}.} -\item{\code{BaW_rad} }{ The radius for the ball walk.} -\item{\code{L} }{ The maximum length of the billiard trajectory or the radius for the step of dikin, vaidya or john walk.} -\item{\code{solver}} {Specify ODE solver for logconcave sampling. Options are i) leapfrog, ii) euler iii) runge-kutta iv) richardson} -\item{\code{step_size} {Optionally chosen step size for logconcave sampling. Defaults to a theoretical value if not provided.}} -}} - -\item{distribution}{Optional. A list that declares the target density and some related parameters as follows: -\itemize{ -\item{\code{density} }{ A string: (a) \code{'uniform'} for the uniform distribution or b) \code{'gaussian'} for the multidimensional spherical distribution c) \code{logconcave} with form proportional to exp(-f(x)) where f(x) is L-smooth and m-strongly-convex d) \code{'exponential'} for the exponential distribution. The default target distribution is the uniform distribution.} -\item{\code{variance} }{ The variance of the multidimensional spherical gaussian or the exponential distribution. The default value is 1.} -\item{\code{mode} }{ A \eqn{d}-dimensional numerical vector that declares the mode of the Gaussian distribution. The default choice is the center of the as that one computed by the function \code{inner_ball()}.} -\item{\code{bias} }{ The bias vector for the exponential distribution. The default vector is \eqn{c_1 = 1} and \eqn{c_i = 0} for \eqn{i \neq 1}.} -\item{\code{L_} }{ Smoothness constant (for logconcave). } -\item{\code{m} }{ Strong-convexity constant (for logconcave). } -\item{\code{negative_logprob} }{ Negative log-probability (for logconcave). } -\item{\code{negative_logprob_gradient} }{ Negative log-probability gradient (for logconcave). } -}} - -\item{seed}{Optional. A fixed seed for the number generator.} -} -\value{ -A \eqn{d\times n} matrix that contains, column-wise, the sampled points from the convex polytope P. -} -\description{ -Sample uniformly, normally distributed, or logconcave distributed points from a convex Polytope (H-polytope, V-polytope, zonotope or intersection of two V-polytopes). -} -\examples{ -# uniform distribution from the 3d unit cube in H-representation using ball walk -P = gen_cube(3, 'H') -points = sample_points(P, n = 100, random_walk = list("walk" = "BaW", "walk_length" = 5)) - -# gaussian distribution from the 2d unit simplex in H-representation with variance = 2 -A = matrix(c(-1,0,0,-1,1,1), ncol=2, nrow=3, byrow=TRUE) -b = c(0,0,1) -P = Hpolytope$new(A,b) -points = sample_points(P, n = 100, distribution = list("density" = "gaussian", "variance" = 2)) - -# uniform points from the boundary of a 2-dimensional random H-polytope -P = gen_rand_hpoly(2,20) -points = sample_points(P, n = 100, random_walk = list("walk" = "BRDHR")) - -# For sampling from logconcave densities see the examples directory - -} -\references{ -\cite{Robert L. Smith, -\dQuote{Efficient Monte Carlo Procedures for Generating Points Uniformly Distributed Over Bounded Regions,} \emph{Operations Research,} 1984.}, - -\cite{B.T. Polyak, E.N. Gryazina, -\dQuote{Billiard walk - a new sampling algorithm for control and optimization,} \emph{IFAC Proceedings Volumes,} 2014.}, - -\cite{Y. Chen, R. Dwivedi, M. J. Wainwright and B. Yu, -\dQuote{Fast MCMC Sampling Algorithms on Polytopes,} \emph{Journal of Machine Learning Research,} 2018.} - -\cite{Lee, Yin Tat, Ruoqi Shen, and Kevin Tian, -\dQuote{"Logsmooth Gradient Concentration and Tighter Runtimes for Metropolized Hamiltonian Monte Carlo,"} \emph{arXiv preprint arXiv:2002.04121}, 2020.} - -\cite{Shen, Ruoqi, and Yin Tat Lee, -\dQuote{"The randomized midpoint method for log-concave sampling.",} \emph{Advances in Neural Information Processing Systems}, 2019.} - -\cite{Augustin Chevallier, Sylvain Pion, Frederic Cazals, -\dQuote{"Hamiltonian Monte Carlo with boundary reflections, and application to polytope volume calculations,"} \emph{Research Report preprint hal-01919855}, 2018.} -} diff --git a/R-proj/man/sparse_constraint_problem.Rd b/R-proj/man/sparse_constraint_problem.Rd deleted file mode 100644 index 535dc8426..000000000 --- a/R-proj/man/sparse_constraint_problem.Rd +++ /dev/null @@ -1,26 +0,0 @@ -\name{sparse_constraint_problem} -\alias{sparse_constraint_problem} -\title{An \code{R} class to represent sparse constraint problems.} - -\description{ -A constraint problem is defined by a set of linear inequalities and equalities or equivalently a \eqn{d}-dimensional constraint problem is defined by a \eqn{mineq\times d} matrix Aineq and a \eqn{mineq}-dimensional vector bineq, s.t.: \eqn{Aineqx\leq bineq}, a \eqn{meq\times d} matrix Aeq and a \eqn{meq}-dimensional vector beq, s.t.: \eqn{Aeqx\eq beq} and two \eqn{d} vectors lb, ub such that \eqn{lb\leq x \leq ub}. -} -\section{Fields}{ -\itemize{ -\item{\code{Aineq} }{\eqn{mineq\times d} sparse matrix Aineq} - -\item{\code{bineq} }{\eqn{mineq}-dimensional vector bineq} - -\item{\code{Aeq} }{\eqn{meq\times d} sparse matrix Aeq} - -\item{\code{beq} }{\eqn{meq}-dimensional vector beq} - -\item{\code{lb} }{\eqn{d}-dimensional vector bineq} - -\item{\code{ub} }{\eqn{d}-dimensional vector bineq} - -\item{\code{type} }{An integer that declares the representation of the polytope. For sparse_constraint_problem the default value is 5.} - -\item{\code{dimension} }{The dimension of the polytope.} - -}} diff --git a/R-proj/man/volume.Rd b/R-proj/man/volume.Rd deleted file mode 100644 index cd325c87f..000000000 --- a/R-proj/man/volume.Rd +++ /dev/null @@ -1,55 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{volume} -\alias{volume} -\title{The main function for volume approximation of a convex Polytope (H-polytope, V-polytope, zonotope or intersection of two V-polytopes). It returns a list with two elements: (a) the logarithm of the estimated volume and (b) the estimated volume} -\usage{ -volume(P, settings = NULL, rounding = NULL, seed = NULL) -} -\arguments{ -\item{P}{A convex polytope. It is an object from class a) Hpolytope or b) Vpolytope or c) Zonotope or d) VpolytopeIntersection.} - -\item{settings}{Optional. A list that declares which algorithm, random walk and values of parameters to use, as follows: -\itemize{ -\item{\code{algorithm} }{ A string to set the algorithm to use: a) \code{'CB'} for CB algorithm, b) \code{'SoB'} for SOB algorithm or b) \code{'CG'} for CG algorithm. The defalut algorithm is \code{'CB'}.} -\item{\code{error} }{ A numeric value to set the upper bound for the approximation error. The default value is \eqn{1} for SOB algorithm and \eqn{0.1} otherwise.} -\item{\code{random_walk} }{ A string that declares the random walk method: a) \code{'CDHR'} for Coordinate Directions Hit-and-Run, b) \code{'RDHR'} for Random Directions Hit-and-Run, c) \code{'BaW'} for Ball Walk, or \code{'BiW'} for Billiard walk. For CB algorithm the default walk is \code{'BiW'}. For CG and SOB algorithms the default walk is \code{'CDHR'} for H-polytopes and \code{'RDHR'} for the other representations.} -\item{\code{walk_length} }{ An integer to set the number of the steps for the random walk. The default value is \eqn{\lfloor 10 + d/10\rfloor} for \code{'SOB'} and \eqn{1} otherwise.} -\item{\code{win_len} }{ The length of the sliding window for CB or CG algorithm. The default value is \eqn{250} for CB with BiW and \eqn{400+3d^2} for CB and any other random walk and \eqn{500+4d^2} for CG.} -\item{\code{hpoly} }{ A boolean parameter to use H-polytopes in MMC of CB algorithm when the input polytope is a zonotope. The default value is \code{TRUE} when the order of the zonotope is \eqn{<5}, otherwise it is \code{FALSE}.} -}} - -\item{rounding}{Optional. A string parameter to request a rounding method to be applied in the input polytope before volume computation: a) \code{'min_ellipsoid'}, b) \code{'svd'}, c) \code{'max_ellipsoid'} and d) \code{'none'} for no rounding.} - -\item{seed}{Optional. A fixed seed for the number generator.} -} -\value{ -The approximation of the volume of a convex polytope. -} -\description{ -For the volume approximation can be used three algorithms. Either CoolingBodies (CB) or SequenceOfBalls (SOB) or CoolingGaussian (CG). An H-polytope with \eqn{m} facets is described by a \eqn{m\times d} matrix \eqn{A} and a \eqn{m}-dimensional vector \eqn{b}, s.t.: \eqn{P=\{x\ |\ Ax\leq b\} }. A V-polytope is defined as the convex hull of \eqn{m} \eqn{d}-dimensional points which correspond to the vertices of P. A zonotope is desrcibed by the Minkowski sum of \eqn{m} \eqn{d}-dimensional segments. -} -\examples{ - -# calling SOB algorithm for a H-polytope (5d unit simplex) -HP = gen_cube(5,'H') -pair_vol = volume(HP) - -# calling CG algorithm for a V-polytope (3d simplex) -VP = gen_simplex(3,'V') -pair_vol = volume(VP, settings = list("algorithm" = "CG")) - -# calling CG algorithm for a 2-dimensional zonotope defined as the Minkowski sum of 4 segments -Z = gen_rand_zonotope(2, 4) -pair_vol = volume(Z, settings = list("random_walk" = "RDHR", "walk_length" = 2)) - -} -\references{ -\cite{I.Z.Emiris and V. Fisikopoulos, -\dQuote{Practical polytope volume approximation,} \emph{ACM Trans. Math. Soft.,} 2018.}, - -\cite{A. Chalkis and I.Z.Emiris and V. Fisikopoulos, -\dQuote{Practical Volume Estimation by a New Annealing Schedule for Cooling Convex Bodies,} \emph{CoRR, abs/1905.05494,} 2019.}, - -\cite{B. Cousins and S. Vempala, \dQuote{A practical volume algorithm,} \emph{Springer-Verlag Berlin Heidelberg and The Mathematical Programming Society,} 2015.} -} diff --git a/R-proj/man/writeSdpaFormatFile.Rd b/R-proj/man/writeSdpaFormatFile.Rd deleted file mode 100644 index 7c791dce0..000000000 --- a/R-proj/man/writeSdpaFormatFile.Rd +++ /dev/null @@ -1,34 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{writeSdpaFormatFile} -\alias{writeSdpaFormatFile} -\title{Write a SDPA format file} -\usage{ -writeSdpaFormatFile( - spectrahedron = NULL, - objectiveFunction = NULL, - outputFile = NULL -) -} -\arguments{ -\item{spectrahedron}{A spectrahedron in n dimensions; must be an object of class Spectrahedron} - -\item{objectiveFunction}{A numerical vector of length n} - -\item{outputFile}{Name of the output file} -} -\description{ -Outputs a spectrahedron (the matrices defining a linear matrix inequality) and a vector (the objective function) -to a SDPA format file. -} -\examples{ -\dontrun{ -A0 = matrix(c(-1,0,0,0,-2,1,0,1,-2), nrow=3, ncol=3, byrow = TRUE) -A1 = matrix(c(-1,0,0,0,0,1,0,1,0), nrow=3, ncol=3, byrow = TRUE) -A2 = matrix(c(0,0,-1,0,0,0,-1,0,0), nrow=3, ncol=3, byrow = TRUE) -lmi = list(A0, A1, A2) -S = Spectrahedron$new(lmi); -objFunction = c(1,1) -writeSdpaFormatFile(S, objFunction, "output.txt") -} -} diff --git a/R-proj/man/zono_approx.Rd b/R-proj/man/zono_approx.Rd deleted file mode 100644 index 9c27c369c..000000000 --- a/R-proj/man/zono_approx.Rd +++ /dev/null @@ -1,24 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/RcppExports.R -\name{zono_approx} -\alias{zono_approx} -\title{An internal Rccp function for the over-approximation of a zonotope} -\usage{ -zono_approx(Z, fit_ratio = NULL, settings = NULL, seed = NULL) -} -\arguments{ -\item{Z}{A zonotope.} - -\item{fit_ratio}{Optional. A boolean parameter to request the computation of the ratio of fitness.} - -\item{settings}{Optional. A list that declares the values of the parameters of CB algorithm.} - -\item{seed}{Optional. A fixed seed for the number generator.} -} -\value{ -A List that contains a numerical matrix that describes the PCA approximation as a H-polytope and the ratio of fitness. -} -\description{ -An internal Rccp function for the over-approximation of a zonotope -} -\keyword{internal} diff --git a/R-proj/man/zonotope_approximation.Rd b/R-proj/man/zonotope_approximation.Rd deleted file mode 100644 index 152a0b0a7..000000000 --- a/R-proj/man/zonotope_approximation.Rd +++ /dev/null @@ -1,39 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/zonotope_approximation.R -\name{zonotope_approximation} -\alias{zonotope_approximation} -\title{A function to over-approximate a zonotope with PCA method and to evaluate the approximation by computing a ratio of fitness.} -\usage{ -zonotope_approximation(Z, fit_ratio = NULL, settings = NULL, seed = NULL) -} -\arguments{ -\item{Z}{A zonotope.} - -\item{fit_ratio}{Optional. A boolean parameter to request the computation of the ratio of fitness.} - -\item{settings}{Optional. A list that declares the values of the parameters of CB algorithm as follows: -\itemize{ -\item{\code{error} }{ A numeric value to set the upper bound for the approximation error. The default value is \eqn{0.1}.} -\item{\code{walk_length} }{ An integer to set the number of the steps for the random walk. The default value is \eqn{1}.} -\item{\code{win_len} }{ The length of the sliding window for CB algorithm. The default value is \eqn{200}.} -\item{\code{hpoly} }{ A boolean parameter to use H-polytopes in MMC of CB algorithm. The default value is \code{TRUE} when the order of the zonotope is \eqn{<5}, otherwise it is \code{FALSE}.} -}} - -\item{seed}{Optional. A fixed seed for the number generator.} -} -\value{ -A list that contains the approximation body in H-representation and the ratio of fitness -} -\description{ -For the evaluation of the PCA method the exact volume of the approximation body is computed and the volume of the input zonotope is computed by CoolingBodies algorithm. The ratio of fitness is \eqn{R=vol(P) / vol(P_{red})}, where \eqn{P_{red}} is the approximate polytope. -} -\examples{ -# over-approximate a 2-dimensional zonotope with 10 generators and compute the ratio of fitness -Z = gen_rand_zonotope(2,12) -retList = zonotope_approximation(Z = Z) - -} -\references{ -\cite{A.K. Kopetzki and B. Schurmann and M. Althoff, -\dQuote{Methods for Order Reduction of Zonotopes,} \emph{IEEE Conference on Decision and Control,} 2017.} -} diff --git a/R-proj/src/Makevars b/R-proj/src/Makevars deleted file mode 100644 index 12623b8b9..000000000 --- a/R-proj/src/Makevars +++ /dev/null @@ -1,17 +0,0 @@ -PKG_CPPFLAGS= -I../../external/boost -I../../external/autodiff -I../../external/LPsolve_src/run_headers -I../../external/minimum_ellipsoid -I../../include - -PKG_CXXFLAGS= -Wno-deprecated-declarations -lm -ldl -Wno-ignored-attributes -DBOOST_NO_AUTO_PTR -DDISABLE_NLP_ORACLES - -PKG_LIBS=-LRproj_externals/lp_solve -llp_solve -L../../external/PackedCSparse/qd -lqd $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) - -$(SHLIB): Rproj_externals/lp_solve/liblp_solve.a ../../external/PackedCSparse/qd/libqd.a - -Rproj_externals/lp_solve/liblp_solve.a: - @(cd Rproj_externals/lp_solve && $(MAKE) liblp_solve.a \ - CC="$(CC)" CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" \ - CPICFLAGS="$(CPICFLAGS)" AR="$(AR)" RANLIB="$(RANLIB)") - -../../external/PackedCSparse/qd/libqd.a: - @(cd ../../PackedCSparse/qd && $(MAKE) libqd.a \ - CC="$(CC)" CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" \ - CPICFLAGS="$(CPICFLAGS)" AR="$(AR)") diff --git a/R-proj/src/Makevars.win b/R-proj/src/Makevars.win deleted file mode 100644 index 83ed4e0c6..000000000 --- a/R-proj/src/Makevars.win +++ /dev/null @@ -1,17 +0,0 @@ -PKG_CPPFLAGS=-I../../external/boost -I../../external/LPsolve_src/run_headers -I../../external/minimum_ellipsoid -I../../include -I../../include/convex_bodies/spectrahedra -PKG_CXXFLAGS= -Wno-deprecated-declarations -lm -ldl -Wno-ignored-attributes -DBOOST_NO_AUTO_PTR -DDISABLE_NLP_ORACLES - -PKG_LIBS=-LRproj_externals/lp_solve -llp_solve -L../../external/PackedCSparse/qd -lqd $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) - -$(SHLIB): Rproj_externals/lp_solve/liblp_solve.a ../../external/PackedCSparse/qd/libqd.a - -Rproj_externals/lp_solve/liblp_solve.a: - @(cd Rproj_externals/lp_solve && $(MAKE) liblp_solve.a \ - CC="$(CC)" CPPFLAGS="$(CPPFLAGS) -DUSRDLL -DINLINE=static" \ - CFLAGS="$(CFLAGS)" CPICFLAGS="$(CPICFLAGS)" AR="$(AR)" \ - RANLIB="$(RANLIB)") - -../../external/PackedCSparse/qd/libqd.a: - @(cd ../../PackedCSparse/qd && $(MAKE) libqd.a \ - CC="$(CC)" CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" \ - CPICFLAGS="$(CPICFLAGS)" AR="$(AR)") diff --git a/R-proj/src/copula.cpp b/R-proj/src/copula.cpp deleted file mode 100644 index 0e8069ea2..000000000 --- a/R-proj/src/copula.cpp +++ /dev/null @@ -1,114 +0,0 @@ -// [[Rcpp::depends(BH)]] - -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2018 Vissarion Fisikopoulos -// Copyright (c) 2018 Apostolos Chalkis - -//Contributed and/or modified by Apostolos Chalkis, as part of Google Summer of Code 2018 program. - - -#include -#include -#include -#include "convex_bodies/ellipsoid.h" -#include "cartesian_geom/cartesian_kernel.h" -#include -#include -#include "sampling/simplex.hpp" -#include "volume/copulas.h" - -//' Construct a copula using uniform sampling from the unit simplex -//' -//' Given two families of parallel hyperplanes or a family of parallel hyperplanes and a family of concentric ellispoids centered at the origin intersecting the canonical simplex, this function uniformly samples from the canonical simplex and construct an approximation of the bivariate probability distribution, called copula (see \url{https://en.wikipedia.org/wiki/Copula_(probability_theory)}). -//' At least two families of hyperplanes or one family of hyperplanes and one family of ellipsoids have to be given as input. -//' -//' @param r1 The \eqn{d}-dimensional normal vector of the first family of parallel hyperplanes. -//' @param r2 Optional. The \eqn{d}-dimensional normal vector of the second family of parallel hyperplanes. -//' @param sigma Optional. The \eqn{d\times d} symmetric positive semidefine matrix that describes the family of concentric ellipsoids centered at the origin. -//' @param m The number of the slices for the copula. The default value is 100. -//' @param n The number of points to sample. The default value is \eqn{5\cdot 10^5}. -//' @param seed Optional. A fixed seed for the number generator. -//' -//' @references \cite{L. Cales, A. Chalkis, I.Z. Emiris, V. Fisikopoulos, -//' \dQuote{Practical volume computation of structured convex bodies, and an application to modeling portfolio dependencies and financial crises,} \emph{Proc. of Symposium on Computational Geometry, Budapest, Hungary,} 2018.} -//' -//' @return A \eqn{m\times m} numerical matrix that corresponds to a copula. -//' @examples -//' # compute a copula for two random families of parallel hyperplanes -//' h1 = runif(n = 10, min = 1, max = 1000) -//' h1 = h1 / 1000 -//' h2=runif(n = 10, min = 1, max = 1000) -//' h2 = h2 / 1000 -//' cop = copula(r1 = h1, r2 = h2, m = 10, n = 100000) -//' -//' # compute a copula for a family of parallel hyperplanes and a family of conentric ellipsoids -//' h = runif(n = 10, min = 1, max = 1000) -//' h = h / 1000 -//' E = replicate(10, rnorm(20)) -//' E = cov(E) -//' cop = copula(r1 = h, sigma = E, m = 10, n = 100000) -//' -//' @export -// [[Rcpp::export]] -Rcpp::NumericMatrix copula (Rcpp::Nullable r1, - Rcpp::Nullable r2 = R_NilValue, - Rcpp::Nullable sigma = R_NilValue, - Rcpp::Nullable m = R_NilValue, - Rcpp::Nullable n = R_NilValue, - Rcpp::Nullable seed = R_NilValue){ - - typedef double NT; - typedef Cartesian Kernel; - typedef typename Kernel::Point Point; - typedef boost::mt19937 RNGType; - typedef Eigen::Matrix MT; - typedef Eigen::Matrix VT; - typedef Ellipsoid CopEll; - unsigned int num_slices = 100, numpoints = 500000; - - if (m.isNotNull()) { - num_slices = Rcpp::as(m); - } - - if (n.isNotNull()) { - numpoints = Rcpp::as(n); - } - - double seed3 = (!seed.isNotNull()) ? std::numeric_limits::signaling_NaN() : Rcpp::as(seed); - - Rcpp::NumericMatrix copula(num_slices, num_slices); - std::vector > StdCopula; - unsigned int dim = Rcpp::as >(r1).size(), i, j; - - std::vector hyp1 = Rcpp::as >(r1); - if (r2.isNotNull()) { - - std::vector hyp2 = Rcpp::as < std::vector < NT > > (r2); - StdCopula = twoParHypFam(dim, numpoints, num_slices, hyp1, hyp2, seed3); - - } else if (sigma.isNotNull()) { - - std::vector > Gin(dim, std::vector(dim)); - MT EE = Rcpp::as(sigma); - for (int i=0; i(dim, numpoints, num_slices, hyp1, Ell, seed3); - } else { - - throw Rcpp::exception("You have to give as input either two families of hyperplanes or one family of hyperplanes and one family of ellipsoids!"); - - } - - for(int i=0; i -#include -#include -#include "cartesian_geom/cartesian_kernel.h" -#include -#include -#include -#include -#include "volume/volume_sequence_of_balls.hpp" -#include "sampling/simplex.hpp" - -//' Sample perfect uniformly distributed points from well known convex bodies: (a) the unit simplex, (b) the canonical simplex, (c) the boundary of a hypersphere or (d) the interior of a hypersphere. -//' -//' The \eqn{d}-dimensional unit simplex is the set of points \eqn{\vec{x}\in \R^d}, s.t.: \eqn{\sum_i x_i\leq 1}, \eqn{x_i\geq 0}. The \eqn{d}-dimensional canonical simplex is the set of points \eqn{\vec{x}\in \R^d}, s.t.: \eqn{\sum_i x_i = 1}, \eqn{x_i\geq 0}. -//' -//' @param body A list to request exact uniform sampling from special well known convex bodies through the following input parameters: -//' \itemize{ -//' \item{\code{type} }{ A string that declares the type of the body for the exact sampling: a) \code{'unit_simplex'} for the unit simplex, b) \code{'canonical_simplex'} for the canonical simplex, c) \code{'hypersphere'} for the boundary of a hypersphere centered at the origin, d) \code{'ball'} for the interior of a hypersphere centered at the origin.} -//' \item{\code{dimension} }{ An integer that declares the dimension when exact sampling is enabled for a simplex or a hypersphere.} -//' \item{\code{radius} }{ The radius of the \eqn{d}-dimensional hypersphere. The default value is \eqn{1}.} -//' } -//' @param n The number of points that the function is going to sample. -//' @param seed Optional. A fixed seed for the number generator. -//' -//' @references \cite{R.Y. Rubinstein and B. Melamed, -//' \dQuote{Modern simulation and modeling} \emph{ Wiley Series in Probability and Statistics,} 1998.} -//' @references \cite{A Smith, Noah and W Tromble, Roy, -//' \dQuote{Sampling Uniformly from the Unit Simplex,} \emph{ Center for Language and Speech Processing Johns Hopkins University,} 2004.} -//' -//' @return A \eqn{d\times n} matrix that contains, column-wise, the sampled points from the convex polytope P. -//' @examples -//' # 100 uniform points from the 2-d unit ball -//' points = direct_sampling(n = 100, body = list("type" = "ball", "dimension" = 2)) -//' @export -// [[Rcpp::export]] -Rcpp::NumericMatrix direct_sampling(Rcpp::Nullable body, - Rcpp::Nullable n, - Rcpp::Nullable seed = R_NilValue) { - - typedef double NT; - typedef Cartesian Kernel; - typedef boost::mt19937 RNGType2; - typedef typename Kernel::Point Point; - typedef Eigen::Matrix VT; - typedef Eigen::Matrix MT; - typedef BoostRandomNumberGenerator RNGType; - - int dim, numpoints; - NT radius = 1.0; - std::list randPoints; - - if (!Rcpp::as(body).containsElementNamed("dimension")) { - throw Rcpp::exception("Dimension has to be given as input!"); - } - dim = Rcpp::as(Rcpp::as(body)["dimension"]); - if (dim <=1) throw Rcpp::exception("Dimension has to be larger than 1!"); - RNGType rng(dim); - - if (seed.isNotNull()) { - unsigned seed2 = Rcpp::as(seed); - rng.set_seed(seed2); - } - double seed3 = (!seed.isNotNull()) ? std::numeric_limits::signaling_NaN() : Rcpp::as(seed); - //RNGType rng2(5); - - numpoints = (!n.isNotNull()) ? 100 : Rcpp::as(n); - - numpoints = Rcpp::as(n); - if (numpoints <= 0) throw Rcpp::exception("The number of samples has to be a positice integer!"); - - - if (Rcpp::as(body).containsElementNamed("radius")) { - - radius = Rcpp::as(Rcpp::as(body)["radius"]); - if (radius <= NT(0)) throw Rcpp::exception("Radius has to be a positive number!"); - - } - if (!Rcpp::as(body).containsElementNamed("type")) { - - throw Rcpp::exception("The kind of body has to be given as input!"); - - } - if (Rcpp::as(Rcpp::as(body)["type"]).compare(std::string("hypersphere"))==0) { - - for (unsigned int k = 0; k < numpoints; ++k) { - randPoints.push_back(GetPointOnDsphere::apply(dim, radius, rng)); - } - - } else if (Rcpp::as(Rcpp::as(body)["type"]).compare(std::string("ball"))==0) { - - for (unsigned int k = 0; k < numpoints; ++k) { - randPoints.push_back(GetPointInDsphere::apply(dim, radius, rng)); - } - - } else if (Rcpp::as(Rcpp::as(body)["type"]).compare(std::string("unit_simplex"))==0) { - - Sam_Unit(dim, numpoints, randPoints, seed3); - - } else if (Rcpp::as(Rcpp::as(body)["type"]).compare(std::string("canonical_simplex"))==0) { - - Sam_Canon_Unit(dim, numpoints, randPoints, seed3); - - } else { - - throw Rcpp::exception("Wrong input!"); - - } - - MT RetMat(dim, numpoints); - unsigned int jj = 0; - - for (typename std::list::iterator rpit = randPoints.begin(); rpit!=randPoints.end(); rpit++, jj++) { - RetMat.col(jj) = rpit->getCoefficients(); - } - return Rcpp::wrap(RetMat); -} diff --git a/R-proj/src/ess.cpp b/R-proj/src/ess.cpp deleted file mode 100644 index 15730557c..000000000 --- a/R-proj/src/ess.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// [[Rcpp::depends(BH)]] - -// VolEsti (volume computation and sampling library) - -// Copyright (c) 20014-2020 Vissarion Fisikopoulos -// Copyright (c) 2018-2020 Apostolos Chalkis - -//Contributed and/or modified by Alexandros Manochis, as part of Google Summer of Code 2020 program. - -#include -#include -#include -#include -#include -#include -#include -#include "diagnostics/effective_sample_size.hpp" - -//' 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. -//' -//' @references \cite{Gelman, A. and Rubin, D. B., -//' \dQuote{Inference from iterative simulation using multiple sequences,} \emph{Statistical Science,} 1992.} -//' -//' @references \cite{Brooks, S. and Gelman, A., -//' \dQuote{General Methods for Monitoring Convergence of Iterative Simulations,} \emph{Journal of Computational and Graphical Statistics,} 1998.} -//' -//' @return A vector that contains the values of PSRF for each coordinate -//' -//' @export -// [[Rcpp::export]] -Rcpp::NumericVector ess(Rcpp::NumericMatrix samples) -{ - typedef double NT; - typedef Eigen::Matrix VT; - typedef Eigen::Matrix MT; - - MT samples_ = Rcpp::as(samples); - unsigned int min_ess = 0; - VT Neff = effective_sample_size(samples_, min_ess); - - return Rcpp::wrap(Neff); -} diff --git a/R-proj/src/exact_vol.cpp b/R-proj/src/exact_vol.cpp deleted file mode 100644 index d60d8fa4b..000000000 --- a/R-proj/src/exact_vol.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// [[Rcpp::depends(BH)]] - -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2019 Vissarion Fisikopoulos -// Copyright (c) 2018-2019 Apostolos Chalkis - - -#include -#include -#include -#include -#include -#include -#include -#include "cartesian_geom/cartesian_kernel.h" -#include "convex_bodies/hpolytope.h" -#include "convex_bodies/vpolytope.h" -#include "convex_bodies/zpolytope.h" -#include "volume/exact_vols.h" - -template -FT factorial(FT n) -{ - return (n == 1 || n == 0) ? 1 : factorial(n - 1) * n; -} - -//' Compute the exact volume of (a) a zonotope (b) an arbitrary simplex in V-representation or (c) if the volume is known and declared by the input object. -//' -//' Given a zonotope (as an object of class Zonotope), this function computes the sum of the absolute values of the determinants of all the \eqn{d \times d} submatrices of the \eqn{m\times d} matrix \eqn{G} that contains row-wise the \eqn{m} \eqn{d}-dimensional segments that define the zonotope. -//' For an arbitrary simplex that is given in V-representation this function computes the absolute value of the determinant formed by the simplex's points assuming it is shifted to the origin. -//' -//' @param P A polytope -//' -//' @references \cite{E. Gover and N. Krikorian, -//' \dQuote{Determinants and the Volumes of Parallelotopes and Zonotopes,} \emph{Linear Algebra and its Applications, 433(1), 28 - 40,} 2010.} -//' -//' @return The exact volume of the input polytope, for zonotopes, simplices in V-representation and polytopes with known exact volume -//' @examples -//' -//' # compute the exact volume of a 5-dimensional zonotope defined by the Minkowski sum of 10 segments -//' Z = gen_rand_zonotope(2, 5) -//' vol = exact_vol(Z) -//' -//' \donttest{# compute the exact volume of a 2-d arbitrary simplex -//' V = matrix(c(2,3,-1,7,0,0),ncol = 2, nrow = 3, byrow = TRUE) -//' P = Vpolytope$new(V) -//' vol = exact_vol(P) -//' } -//' -//' # compute the exact volume the 10-dimensional cross polytope -//' P = gen_cross(10,'V') -//' vol = exact_vol(P) -//' @export -// [[Rcpp::export]] -double exact_vol(Rcpp::Nullable P) { - - typedef double NT; - typedef Cartesian Kernel; - typedef typename Kernel::Point Point; - typedef Eigen::Matrix VT; - typedef Eigen::Matrix MT; - - if (NT(Rcpp::as(P).field("volume")) > 0.0) { - return NT(Rcpp::as(P).field("volume")); - } - - int type = Rcpp::as(P).field("type"), dim; - NT vol; - - if (type == 2) { - - dim = Rcpp::as(P).field("dimension"); - - if (Rcpp::as(Rcpp::as(P).field("V")).rows() == - Rcpp::as(Rcpp::as(P).field("V")).cols() + 1) { - - MT V = Rcpp::as(Rcpp::as(P).field("V")).transpose(), V2(dim,dim); - VT v0 = V.col(dim); - - for (int i = 0; i < dim; ++i) { - V2.col(i) = V.col(i) - v0; - } - vol = std::abs(V2.determinant()) / factorial(NT(dim)); - - } else { - throw Rcpp::exception("Volume unknown!"); - } - - } else if (type == 3) { - - typedef Zonotope zonotope; - dim = Rcpp::as(P).field("dimension"); - - zonotope ZP(dim, Rcpp::as(Rcpp::as(P).field("G")), - VT::Ones(Rcpp::as(Rcpp::as(P).field("G")).rows())); - vol = exact_zonotope_vol(ZP); - - } else { - throw Rcpp::exception("Volume unknown!"); - } - - return vol; -} diff --git a/R-proj/src/extractMatPoly.h b/R-proj/src/extractMatPoly.h deleted file mode 100644 index 5adb9d56b..000000000 --- a/R-proj/src/extractMatPoly.h +++ /dev/null @@ -1,37 +0,0 @@ -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2018 Vissarion Fisikopoulos, Apostolos Chalkis - -//Contributed and/or modified by Apostolos Chalkis, as part of Google Summer of Code 2018 program. - -// VolEsti is free software: you can redistribute it and/or modify it -// under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or (at -// your option) any later version. -// -// VolEsti is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// for more details. -// -// See the file COPYING.LESSER for the text of the GNU Lesser General -// Public License. If you did not receive this file along with HeaDDaCHe, -// see . - - -#ifndef EXTRACTMATPOLY_H -#define EXTRACTMATPOLY_H - -// Take a H or a V-polytope and return a numerical matrix in ine or ext format respectively -template -Rcpp::NumericMatrix extractMatPoly(Polytope P) { - - typedef typename Polytope::MT MT; - - MT Mat(P.get_mat().rows(), P.dimension()+1); - Mat << P.get_vec(), P.get_mat(); - - return Rcpp::wrap(Mat); -} - -#endif diff --git a/R-proj/src/frustum_of_simplex.cpp b/R-proj/src/frustum_of_simplex.cpp deleted file mode 100644 index 6b191079e..000000000 --- a/R-proj/src/frustum_of_simplex.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2018 Vissarion Fisikopoulos -// Copyright (c) 2018 Apostolos Chalkis - -#include -#include -#include "volume/exact_vols.h" - -//' Compute the percentage of the volume of the simplex that is contained in the intersection of a half-space and the simplex. -//' -//' A half-space \eqn{H} is given as a pair of a vector \eqn{a\in R^d} and a scalar \eqn{z0\in R} s.t.: \eqn{a^Tx\leq z0}. This function calls the Ali's version of the Varsi formula to compute a frustum of the simplex. -//' -//' @param a A \eqn{d}-dimensional vector that defines the direction of the hyperplane. -//' @param z0 The scalar that defines the half-space. -//' -//' @references \cite{Varsi, Giulio, -//' \dQuote{The multidimensional content of the frustum of the simplex,} \emph{Pacific J. Math. 46, no. 1, 303--314,} 1973.} -//' -//' @references \cite{Ali, Mir M., -//' \dQuote{Content of the frustum of a simplex,} \emph{ Pacific J. Math. 48, no. 2, 313--322,} 1973.} -//' -//' @return The percentage of the volume of the simplex that is contained in the intersection of a given half-space and the simplex. -//' -//' @examples -//' # compute the frustum of H: -x1+x2<=0 -//' a=c(-1,1) -//' z0=0 -//' frustum = frustum_of_simplex(a, z0) -//' @export -// [[Rcpp::export]] -double frustum_of_simplex(Rcpp::NumericVector a, double z0){ - - unsigned int dim = a.size(); - if (dim < 2) { - throw Rcpp::exception("Dimension has to be greater than 2"); - } - std::vector hyp = Rcpp::as >(a); - - return vol_Ali(hyp, -z0, dim); -} diff --git a/R-proj/src/geweke.cpp b/R-proj/src/geweke.cpp deleted file mode 100644 index 4c41b227e..000000000 --- a/R-proj/src/geweke.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// [[Rcpp::depends(BH)]] - -// VolEsti (volume computation and sampling library) - -// Copyright (c) 20014-2020 Vissarion Fisikopoulos -// Copyright (c) 2020 Apostolos Chalkis - -//Contributed and/or modified by Alexandros Manochis, as part of Google Summer of Code 2020 program. - - -#include -#include -#include -#include -#include -#include -#include -#include "diagnostics/geweke.hpp" - -//' Geweke's MCMC diagnostic -//' -//' @param samples A matrix that contans column-wise the sampled points from a geometric random walk. -//' @param frac_first Optional. The portion of the first in order points in matrix samples. -//' @param frac_last Optional. The portion of the last in order points in matrix samples. -//' -//' @references \cite{Geweke, J., -//' \dQuote{Evaluating the accuracy of sampling-based approaches to the calculation of posterior moments,} \emph{ In Bayesian Statistics 4. Proceedings of the Fourth Valencia International Meeting,} 1992.} -//' -//' @return A boolean to denote if the result of Geweke diagnostic: (i) false if the null hypothesis is rejected, (ii) true if the null hypothesis is not rejected. -//' -//' @export -// [[Rcpp::export]] -bool geweke(Rcpp::NumericMatrix samples, - Rcpp::Nullable frac_first = R_NilValue, - Rcpp::Nullable frac_last = R_NilValue) -{ - typedef double NT; - typedef Eigen::Matrix VT; - typedef Eigen::Matrix MT; - - NT frac_1, frac_2; - - frac_1 = (!frac_first.isNotNull()) ? NT(0.1) : Rcpp::as(frac_first); - frac_2 = (!frac_last.isNotNull()) ? NT(0.5) : Rcpp::as(frac_last); - - return perform_geweke(Rcpp::as(samples), frac_1, frac_2); -} diff --git a/R-proj/src/inner_ball.cpp b/R-proj/src/inner_ball.cpp deleted file mode 100644 index 8472ad3b8..000000000 --- a/R-proj/src/inner_ball.cpp +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (c) 2012-2018 Vissarion Fisikopoulos -// Copyright (c) 2018 Apostolos Chalkis - -#include -#include -#include -#include "cartesian_geom/cartesian_kernel.h" -#include -#include -#include -#include -#include "volume/volume_sequence_of_balls.hpp" -#include "preprocess/max_inscribed_ball.hpp" - -//' Compute an inscribed ball of a convex polytope -//' -//' For a H-polytope described by a \eqn{m\times d} matrix \eqn{A} and a \eqn{m}-dimensional vector \eqn{b}, s.t.: \eqn{P=\{x\ |\ Ax\leq b\} }, this function computes the largest inscribed ball (Chebychev ball) by solving the corresponding linear program. -//' For both zonotopes and V-polytopes the function computes the minimum \eqn{r} s.t.: \eqn{ r e_i \in P} for all \eqn{i=1, \dots ,d}. Then the ball centered at the origin with radius \eqn{r/ \sqrt{d}} is an inscribed ball. -//' -//' @param P A convex polytope. It is an object from class (a) Hpolytope or (b) Vpolytope or (c) Zonotope or (d) VpolytopeIntersection. -//' @param lpsolve Optional. A boolean variable to compute the Chebychev ball of an H-polytope using the lpsolve library. -//' -//' @return A \eqn{(d+1)}-dimensional vector that describes the inscribed ball. The first \eqn{d} coordinates corresponds to the center of the ball and the last one to the radius. -//' -//' @examples -//' # compute the Chebychev ball of the 2d unit simplex -//' P = gen_cube(10,'H') -//' ball_vec = inner_ball(P) -//' -//' # compute an inscribed ball of the 3-dimensional unit cube in V-representation -//' P = gen_cube(3, 'V') -//' ball_vec = inner_ball(P, lpsolve = TRUE) -//' @export -// [[Rcpp::export]] -Rcpp::NumericVector inner_ball(Rcpp::Reference P, - Rcpp::Nullable lpsolve = R_NilValue) { - - typedef double NT; - typedef Cartesian Kernel; - typedef typename Kernel::Point Point; - typedef BoostRandomNumberGenerator RNGType; - typedef HPolytope Hpolytope; - typedef VPolytope Vpolytope; - typedef Zonotope zonotope; - typedef IntersectionOfVpoly InterVP; - typedef Eigen::Matrix VT; - typedef Eigen::Matrix MT; - unsigned int n = P.field("dimension"), type = P.field("type"); - - std::pair InnerBall; - bool lp_solve = (lpsolve.isNotNull()) ? Rcpp::as(lpsolve) : false; - - switch (type) { - case 1: { - // Hpolytope - Hpolytope HP(n, Rcpp::as(P.field("A")), Rcpp::as(P.field("b"))); - if (lp_solve) { - InnerBall = ComputeChebychevBall(HP.get_mat(), HP.get_vec()); - } else { - InnerBall = HP.ComputeInnerBall(); - } - if (InnerBall.second < 0.0) throw Rcpp::exception("Unable to compute a feasible point."); - break; - } - case 2: { - // Vpolytope - Vpolytope VP(n, Rcpp::as(P.field("V")), VT::Ones(Rcpp::as(P.field("V")).rows())); - InnerBall = VP.ComputeInnerBall(); - if (InnerBall.second < 0.0) throw Rcpp::exception("Unable to compute a feasible point."); - break; - } - case 3: { - // Zonotope - zonotope ZP(n, Rcpp::as(P.field("G")), VT::Ones(Rcpp::as(P.field("G")).rows())); - InnerBall = ZP.ComputeInnerBall(); - if (InnerBall.second < 0.0) throw Rcpp::exception("Unable to compute a feasible point."); - break; - } - case 4: { - // Intersection of two V-polytopes - Vpolytope VP1(n, Rcpp::as(P.field("V1")), VT::Ones(Rcpp::as(P.field("V1")).rows())); - Vpolytope VP2(n, Rcpp::as(P.field("V2")), VT::Ones(Rcpp::as(P.field("V2")).rows())); - InterVP VPcVP(VP1, VP2); - if (!VPcVP.is_feasible()) throw Rcpp::exception("Empty set!"); - InnerBall = VPcVP.ComputeInnerBall(); - if (InnerBall.second < 0.0) throw Rcpp::exception("Unable to compute a feasible point."); - break; - } - } - - Rcpp::NumericVector vec(n + 1); - for (unsigned int k = 0; k < n; ++k){ - vec[k] = InnerBall.first[k]; - } - - vec[n] = InnerBall.second; - return vec; -} diff --git a/R-proj/src/ode_solve.cpp b/R-proj/src/ode_solve.cpp deleted file mode 100644 index 07766d33a..000000000 --- a/R-proj/src/ode_solve.cpp +++ /dev/null @@ -1,205 +0,0 @@ -// [[Rcpp::depends(BH)]] - -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2020 Vissarion Fisikopoulos -// Copyright (c) 2018-2020 Apostolos Chalkis -// Copyright (c) 2020-2020 Marios Papachristou - -//Contributed and/or modified by Marios Papachristou, as part of Google Summer of Code 2018 and 2019 program. - - -#include -#include -#include -#include -#include -#include -#include -#include "random_walks/random_walks.hpp" -#include "volume/volume_sequence_of_balls.hpp" -#include "volume/volume_cooling_gaussians.hpp" -#include "sampling/sampling.hpp" -#include "ode_solvers/ode_solvers.hpp" -#include "oracle_functors_rcpp.h" - -template < - typename Solver, - typename MT -> -void run_ode_solver( - Solver &solver, - unsigned int &order, - unsigned int &num_steps, - unsigned int &dimension, - Rcpp::List &results) { - - std::vector results_temp; - - for (unsigned int i = 0; i < order; i++) { - MT temp_result; - temp_result.resize(dimension, num_steps); - results_temp.push_back(temp_result); - } - - for (unsigned int i = 0; i < num_steps; i++) { - for (unsigned int j = 0; j < order; j++) { - results_temp[j].col(i) = solver.xs[j].getCoefficients(); - } - solver.step(i, true); - } - - for (unsigned int i = 0; i < order; i++) { - std::ostringstream stringStream; - stringStream << "x_" << i + 1; - std::string state_name = stringStream.str(); - - results.push_back(Rcpp::wrap(results_temp[i]), state_name.c_str()); - - } - -} - -//' Solve an ODE of the form dx^n / dt^n = F(x, t) -//' -//' @param n The number of steps. -//' @param step_size The step size. -//' @param order The ODE order (default is n = 1) -//' @param dimension The dimension of each derivative -//' @param initial_time The initial time -//' @param F The function oracle F(x, t) in the ODE. -//' @param method The method to be used -//' @param initial_conditions The initial conditions provided to the solver. Must be provided in a list with keys "x_1", ..., "x_n" and column vectors as values. The state "x_n" represents the (n-1)-th order derivative with respect to time -//' @param domains A list of n H-polytopes with keys "P_1", "P_2", ..., "P_n" that correspond to each derivative's domain -//' -//' @return A list which contains elements "x_1", ..., "x_n" representing each derivative results. Each "x_i" corresponds to a d x n matrix where each column represents a certain timestep of the solver. -//' -//' @examples -//' # Please visit the examples directory on examples demonstrating usage of the ODE solvers. -//' -//' @export -// [[Rcpp::export]] -Rcpp::List ode_solve(Rcpp::Nullable n, - Rcpp::Nullable step_size, - Rcpp::Nullable order, - Rcpp::Nullable dimension, - Rcpp::Nullable initial_time, - Rcpp::Function F, - Rcpp::Nullable method, - Rcpp::Nullable domains = R_NilValue, - Rcpp::Nullable initial_conditions = R_NilValue) -{ - - typedef double NT; - typedef Cartesian Kernel; - typedef BoostRandomNumberGenerator RNGType; - typedef typename Kernel::Point Point; - typedef HPolytope Hpolytope; - typedef Eigen::Matrix VT; - typedef Eigen::Matrix MT; - typedef std::vector pts; - typedef std::vector hp_bounds; - typedef RcppFunctor::GradientFunctor func; - - unsigned int n_ = Rcpp::as(n); - NT step_size_ = Rcpp::as(step_size); - unsigned int order_ = Rcpp::as(order); - std::string method_ = Rcpp::as(method); - unsigned int dim = Rcpp::as(dimension); - NT initial_time_ = Rcpp::as(initial_time); - - // Create functors - RcppFunctor::parameters rcpp_functor_params(1, 1, order_); - - // Create C++ functor - func F_(rcpp_functor_params, F, false); - - // Initialize initial conditions - pts initial_conditions_; - VT temp_initial_condition; - - for (unsigned int i = 1; i <= order_; i++) { - std::ostringstream stringStream; - stringStream << "x_" << i; - std::string state_name = stringStream.str(); - - if (Rcpp::as(initial_conditions).containsElementNamed(state_name.c_str())) { - temp_initial_condition = Rcpp::as(Rcpp::as(initial_conditions)[state_name.c_str()]); - Point p(temp_initial_condition); - initial_conditions_.push_back(p); - } else { - Point p(dim); - initial_conditions_.push_back(p); - } - - } - - unsigned int i = 0; - unsigned int t = 0; - F_(i, initial_conditions_, t); - - hp_bounds domains_; - - // Initialize domains - // TODO Test and add other polytope types - for (unsigned int i = 0; i < order_; i++) { - std::ostringstream stringStream; - stringStream << "P_" << i + 1; - std::string domain_name = stringStream.str(); - - if (Rcpp::as(domains).containsElementNamed(domain_name.c_str())) { - - Hpolytope HP(dim, Rcpp::as( - Rcpp::as(Rcpp::as(domains) - [domain_name.c_str()]).field("A")), - Rcpp::as( - Rcpp::as(Rcpp::as(domains) - [domain_name.c_str()]).field("b")) - ); - - HP.normalize(); - - Hpolytope *HP_ref = &HP; - - if (!HP_ref->is_in(initial_conditions_[i])) { - std::ostringstream errStream; - errStream << "Initial condition out of bounds for state " << i + 1 << ".\n"; - throw Rcpp::exception(errStream.str().c_str()); - } - domains_.push_back(HP_ref); - } else { - domains_.push_back(NULL); - } - } - - Rcpp::List results; - - if (method_ == "euler") { - EulerODESolver euler_solver = - EulerODESolver - (initial_time_, step_size_, initial_conditions_, F_, domains_); - run_ode_solver, MT>(euler_solver, order_, n_, dim, results); - } else if (method_ == "leapfrog") { - if (order_ % 2 == 1) { - throw Rcpp::exception("Leapfrog is an even order solver."); - } - LeapfrogODESolver leapfrog_solver = - LeapfrogODESolver - (initial_time_, step_size_, initial_conditions_, F_, domains_); - run_ode_solver, MT>(leapfrog_solver, order_, n_, dim, results); - } else if (method_ == "runge_kutta") { - RKODESolver rk_solver = - RKODESolver - (initial_time_, step_size_, initial_conditions_, F_, domains_); - run_ode_solver, MT>(rk_solver, order_, n_, dim, results); - } else if (method_ == "richardson") { - RichardsonExtrapolationODESolver r_solver = - RichardsonExtrapolationODESolver - (initial_time_, step_size_, initial_conditions_, F_, domains_); - run_ode_solver, MT>(r_solver, order_, n_, dim, results); - } else { - throw Rcpp::exception("Unrecognized solver. Aborting."); - } - - return results; -} diff --git a/R-proj/src/oracle_functors_rcpp.h b/R-proj/src/oracle_functors_rcpp.h deleted file mode 100644 index 6929540ca..000000000 --- a/R-proj/src/oracle_functors_rcpp.h +++ /dev/null @@ -1,160 +0,0 @@ -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2020 Vissarion Fisikopoulos -// Copyright (c) 2018-2020 Apostolos Chalkis -// Copyright (c) 2020-2020 Marios Papachristou - -// Contributed and/or modified by Marios Papachristou, as part of Google Summer of Code 2020 program. - -// Licensed under GNU LGPL.3, see LICENCE file - -#ifndef ODE_SOLVERS_ORACLE_FUNCTORS_RCPP_HPP -#define ODE_SOLVERS_ORACLE_FUNCTORS_RCPP_HPP - -enum ode_solvers { - no_solver, - leapfrog, - euler, - runge_kutta, - richardson, - collocation, - implicit_midpoint -}; - -// Holds Oracle Functor that wraps an R function via RCpp -// The R function is provided as an Rcpp::Function object -// The functor uses Rcpp::as and Rcpp::wrap to do the conversion, -// call the oracle, and convert the results back to C++ -struct RcppFunctor { - - template < - typename NT - > - struct parameters { - NT L; // Lipschitz constant of gradient - NT m; // Strong-convexity parameter - NT eta; // Step-size (if defined by user) - NT kappa; // Condition number - unsigned int order; // Order of ODE functor - - parameters( - NT L_, - NT m_, - NT eta_, - unsigned int order_=2 - ) : - L(L_), - m(m_), - eta(eta_), - kappa(L_ / m_), - order(order_) - {} - }; - - // Log-probability gradient functor - template - < - typename Point - > - struct GradientFunctor { - typedef typename Point::FT NT; - typedef typename Point::Coeff VT; - typedef std::vector pts; - - parameters params; - Rcpp::Function neg_grad_f; // Negative gradient as an Rcpp::Function - bool negate; - - GradientFunctor( - parameters params_, - Rcpp::Function neg_grad_f_, - bool negate_=true): - params(params_), - neg_grad_f(neg_grad_f_), - negate(negate_) - {}; - - // The index i represents the state vector index - Point operator() (unsigned int const& i, pts const& xs, NT const& t) const { - if (i == params.order - 1) { - // Convert point to Rcpp::NumericMatrix - - VT y = Rcpp::as(neg_grad_f(Rcpp::wrap(xs[0].getCoefficients()))); - - Point z(y); - - if (negate) z = (-1.0) * z; - - // Return result as Point - return z; - } else { - return xs[i + 1]; // returns derivative - } - } - - Point operator() (Point const& x) const { - VT y = Rcpp::as(neg_grad_f(Rcpp::wrap(x.getCoefficients()))); - - Point z(y); - - if (negate) z = (-1.0) * z; - - // Return result as Point - return z; - } - - }; - - // Negative log-probability functor - template - < - typename Point - > - struct FunctionFunctor { - typedef typename Point::FT NT; - typedef typename Point::Coeff VT; - - parameters params; - Rcpp::Function negative_logprob; - - FunctionFunctor( - parameters params_, - Rcpp::Function negative_logprob_) : - params(params_), - negative_logprob(negative_logprob_) - {}; - - NT operator() (Point const& x) const { - return Rcpp::as(negative_logprob(Rcpp::wrap(x.getCoefficients()))); - } - - }; - - // Log-probability hessian functor - template - < - typename Point - > - struct HessianFunctor { - typedef typename Point::FT NT; - typedef typename Point::Coeff VT; - - parameters params; - Rcpp::Function hessian; // Negative hessian as an Rcpp::Function - - HessianFunctor( - parameters params_, - Rcpp::Function hessian_) : - params(params_), - hessian(hessian_) - {}; - - Point operator() (Point const& x) const { - VT y= Rcpp::as(hessian(Rcpp::wrap(x.getCoefficients()))); - return Point(y); - } - - }; -}; - -#endif diff --git a/R-proj/src/poly_gen.cpp b/R-proj/src/poly_gen.cpp deleted file mode 100644 index 1ffa75d7f..000000000 --- a/R-proj/src/poly_gen.cpp +++ /dev/null @@ -1,114 +0,0 @@ -// [[Rcpp::depends(BH)]] - -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2018 Vissarion Fisikopoulos -// Copyright (c) 2018 Apostolos Chalkis - -//Contributed and/or modified by Apostolos Chalkis, as part of Google Summer of Code 2018 program. - - -#include -#include -#include -#include "cartesian_geom/cartesian_kernel.h" -#include -#include -#include -#include -#include "convex_bodies/hpolytope.h" -#include "convex_bodies/vpolytope.h" -#include "convex_bodies/zpolytope.h" -#include "generators/known_polytope_generators.h" -#include "generators/h_polytopes_generator.h" -#include "generators/v_polytopes_generators.h" -#include "generators/z_polytopes_generators.h" -#include "extractMatPoly.h" - -//' An internal Rccp function as a polytope generator -//' -//' @param kind_gen An integer to declare the type of the polytope. -//' @param Vpoly_gen A boolean parameter to declare if the requested polytope has to be in V-representation. -//' @param Zono_gen A boolean parameter to declare if the requested polytope has to be a zonotope. -//' @param dim_gen An integer to declare the dimension of the requested polytope. -//' @param m_gen An integer to declare the number of generators for the requested random zonotope or the number of vertices for a V-polytope. -//' @param seed Optional. A fixed seed for the random polytope generator. -//' -//' @keywords internal -//' -//' @return A numerical matrix describing the requested polytope -// [[Rcpp::export]] -Rcpp::NumericMatrix poly_gen (int kind_gen, bool Vpoly_gen, bool Zono_gen, int dim_gen, int m_gen, - Rcpp::Nullable seed = R_NilValue) { - - typedef double NT; - typedef Cartesian Kernel; - typedef typename Kernel::Point Point; - typedef boost::mt19937 RNGType; - typedef HPolytope Hpolytope; - typedef VPolytope Vpolytope; - typedef Zonotope zonotope; - - double seed_rcpp = (!seed.isNotNull()) ? std::numeric_limits::signaling_NaN() : Rcpp::as(seed); - - if (Zono_gen) { - switch (kind_gen) { - - case 1: - return extractMatPoly(gen_zonotope_uniform(dim_gen, m_gen, seed_rcpp)); - case 2: - return extractMatPoly(gen_zonotope_gaussian(dim_gen, m_gen, seed_rcpp)); - case 3: - return extractMatPoly(gen_zonotope_exponential(dim_gen, m_gen, seed_rcpp)); - - } - - } else if (Vpoly_gen) { - switch (kind_gen) { - - case 1: - return extractMatPoly(generate_cube(dim_gen, true)); - - case 2: - return extractMatPoly(generate_cross(dim_gen, true)); - - case 3: - return extractMatPoly(generate_simplex(dim_gen, true)); - - case 4: - return extractMatPoly(random_vpoly(dim_gen, m_gen, seed_rcpp)); - - case 5: - return extractMatPoly(random_vpoly_incube(dim_gen, m_gen, seed_rcpp)); - - } - } else { - switch (kind_gen) { - - case 1: - return extractMatPoly(generate_cube(dim_gen, false)); - - case 2: - return extractMatPoly(generate_cross(dim_gen, false)); - - case 3: - return extractMatPoly(generate_simplex(dim_gen, false)); - - case 4: - return extractMatPoly(generate_prod_simplex(dim_gen)); - - case 5: - return extractMatPoly(generate_skinny_cube(dim_gen)); - - case 6: - return extractMatPoly(random_hpoly(dim_gen, m_gen, seed_rcpp)); - - case 7: - return extractMatPoly(generate_birkhoff(dim_gen)); - - } - } - - throw Rcpp::exception("Wrong inputs!"); - -} diff --git a/R-proj/src/polytopes_modules.cpp b/R-proj/src/polytopes_modules.cpp deleted file mode 100644 index 443251fbb..000000000 --- a/R-proj/src/polytopes_modules.cpp +++ /dev/null @@ -1,240 +0,0 @@ -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2019 Vissarion Fisikopoulos -// Copyright (c) 2018-2019 Apostolos Chalkis - - -#include - -class Hpolytope { -public: - Hpolytope() {} - Hpolytope(Rcpp::NumericMatrix _A, Rcpp::NumericVector _b) : A(_A), b(_b), Aeq(Rcpp::NumericMatrix(0,0)), - beq(Rcpp::NumericVector(0)), vol(std::numeric_limits::signaling_NaN()), dimension(_A.ncol()), type(1) {} - Hpolytope(Rcpp::NumericMatrix _A, Rcpp::NumericVector _b, Rcpp::NumericMatrix _Aeq, Rcpp::NumericVector _beq) : - A(_A), b(_b), Aeq(_Aeq), beq(_beq), vol(std::numeric_limits::signaling_NaN()), dimension(_A.ncol()), type(1) {} - Hpolytope(Rcpp::NumericMatrix _A, Rcpp::NumericVector _b, double volume) : A(_A), b(_b), - Aeq(Rcpp::NumericMatrix(0,0)), beq(Rcpp::NumericVector(0)), vol(volume), dimension(_A.ncol()), type(1) {} - Hpolytope(Rcpp::NumericMatrix _A, Rcpp::NumericVector _b, Rcpp::NumericMatrix _Aeq, Rcpp::NumericVector _beq, - double volume) : A(_A), b(_b), Aeq(_Aeq), beq(_beq), vol(volume), dimension(_A.ncol()), type(1) {} - Rcpp::NumericMatrix A; - Rcpp::NumericVector b; - Rcpp::NumericMatrix Aeq; - Rcpp::NumericVector beq; - double vol; - unsigned int dimension; - int type; -}; - -class Vpolytope { -public: - Vpolytope() {} - Vpolytope(Rcpp::NumericMatrix _V) : V(_V), vol(std::numeric_limits::signaling_NaN()), dimension(_V.ncol()), type(2) {} - Vpolytope(Rcpp::NumericMatrix _V, double volume) : V(_V), vol(volume), dimension(_V.ncol()), type(2) {} - Rcpp::NumericMatrix V; - double vol; - unsigned int dimension; - int type; -}; - -class Zonotope { -public: - Zonotope() {} - Zonotope(Rcpp::NumericMatrix _G) : G(_G), vol(std::numeric_limits::signaling_NaN()), dimension(_G.ncol()), type(3) {} - Zonotope(Rcpp::NumericMatrix _G, double volume) : G(_G), vol(volume), dimension(_G.ncol()), type(3) {} - Rcpp::NumericMatrix G; - double vol; - unsigned int dimension; - int type; -}; - -class VPinterVP { -public: - VPinterVP() {} - VPinterVP(Rcpp::NumericMatrix _V1, Rcpp::NumericMatrix _V2) : V1(_V1), V2(_V2), vol(std::numeric_limits::signaling_NaN()), dimension(_V1.ncol()), type(4) {} - VPinterVP(Rcpp::NumericMatrix _V1, Rcpp::NumericMatrix _V2, double volume) : V1(_V1), V2(_V2), vol(volume), dimension(_V1.ncol()), type(4) {} - Rcpp::NumericMatrix V1; - Rcpp::NumericMatrix V2; - double vol; - unsigned int dimension; - int type; -}; -#include -using SpMat=Eigen::SparseMatrix ; -class sparse_constraint_problem { -public: - sparse_constraint_problem() {} - sparse_constraint_problem(SpMat _Aineq, Rcpp::NumericVector _bineq, SpMat _Aeq, Rcpp::NumericVector _beq) : Aineq(_Aineq), bineq(_bineq), Aeq(_Aeq), beq(_beq), - lb(Rcpp::NumericVector(_Aineq.cols(),-1e9)), ub(Rcpp::NumericMatrix(_Aineq.cols(),1e9)), dimension(_Aineq.cols()), type(5) {} - sparse_constraint_problem(SpMat _Aineq, Rcpp::NumericVector _bineq, SpMat _Aeq, Rcpp::NumericVector _beq, - Rcpp::NumericVector _lb, Rcpp::NumericVector _ub) : Aineq(_Aineq), bineq(_bineq), Aeq(_Aeq), beq(_beq), - lb(_lb), ub(_ub), dimension(_Aineq.cols()), type(5) {} - sparse_constraint_problem(SpMat _Aeq, Rcpp::NumericVector _beq) : Aineq(SpMat(0, _Aeq.cols())), bineq(Rcpp::NumericVector(0)), Aeq(_Aeq), beq(_beq), - lb(Rcpp::NumericVector(_Aeq.cols(),-1e9)), ub(Rcpp::NumericMatrix(_Aeq.cols(),1e9)), dimension(_Aeq.cols()), type(5) {} - SpMat Aineq; - Rcpp::NumericVector bineq; - SpMat Aeq; - Rcpp::NumericVector beq; - Rcpp::NumericVector lb; - Rcpp::NumericVector ub; - unsigned int dimension; - int type; -}; -RCPP_MODULE(polytopes){ - using namespace Rcpp ; - - //' An exposed class to represent a H-polytope - //' - //' @description A H-polytope is a convex polytope defined by a set of linear inequalities or equivalently a \eqn{d}-dimensional H-polytope with \eqn{m} facets is defined by a \eqn{m\times d} matrix A and a \eqn{m}-dimensional vector b, s.t.: \eqn{Ax\leq b}. - //' - //' @field A \eqn{m\times d} numerical matrix A - //' @field b \eqn{m}-dimensional vector b - //' @field Aeq \eqn{q\times d} numerical matrix Aeq - //' @field beq \eqn{q}-dimensional vector beq - //' @field volume The volume of the polytope. - //' @field dimension An integer that declares the dimension of the polytope. It has not be given to the constructor. - //' @field type An integer that declares the representation of the polytope. For H-representation the default value is 1. It has not be given to the constructor. - //' - //' @example - //' # create a 2-d unit simplex - //' A = matrix(c(-1,0,0,-1,1,1), ncol=2, nrow=3, byrow=TRUE) - //' b = c(0,0,1) - //' P = Hpolytope$new(A,b) - //' @export - class_("Hpolytope") - // expose the default constructor - .constructor() - .constructor() - .constructor() - .constructor() - .constructor() - - .field( "A", &Hpolytope::A ) - .field( "b", &Hpolytope::b ) - .field( "Aeq", &Hpolytope::Aeq ) - .field( "beq", &Hpolytope::beq ) - .field( "volume", &Hpolytope::vol ) - .field( "dimension", &Hpolytope::dimension ) - .field( "type", &Hpolytope::type ); - - //' An exposed C++ class to represent a V-polytope - //' - //' @description A V-polytope is a convex polytope defined by the set of its vertices. - //' - //' @field V \eqn{m\times d} numerical matrix that contains the vertices row-wise - //' @field volume The volume of the polytope. - //' @field dimension An integer that declares the dimension of the polytope. It has not be given to the constructor. - //' @field type An integer that declares the representation of the polytope. For H-representation the default value is 2. It has not be given to the constructor. - //' - //' @example - //' # Create a 2-d cube in V-representation - //' V = matrix(c(-1,1,1,1,1,-1,-1,-1), ncol=3, byrow=TRUE) - //' P = Vpolytope$new(V) - //' @export - class_("Vpolytope") - // expose the default constructor - .constructor() - .constructor() - .constructor() - - .field( "V", &Vpolytope::V ) - .field( "volume", &Vpolytope::vol ) - .field( "dimension", &Vpolytope::dimension ) - .field( "type", &Vpolytope::type ); - - //' An exposed C++ class to represent a zonotope - //' - //' @description A zonotope is a convex polytope defined by the Minkowski sum of \eqn{m} \eqn{d}-dimensional segments. - //' - //' @field G \eqn{m\times d} numerical matrix that contains the segments (or generators) row-wise - //' @field volume The volume of the polytope. - //' @field dimension An integer that declares the dimension of the polytope. It has not be given to the constructor. - //' @field type An integer that declares the representation of the polytope. For H-representation the default value is 3. It has not be given to the constructor. - //' - //' @example - //' # Create a 2-d zonotope with 4 generators - //' G = matrix(c(1,0,0,1,-0.73,0.67,-0.25,0.96), ncol = 2, nrow = 4, byrow = TRUE) - //' P = Zonotope$new(G) - //' @export - class_("Zonotope") - // expose the default constructor - .constructor() - .constructor() - .constructor() - - .field( "G", &Zonotope::G ) - .field( "volume", &Zonotope::vol ) - .field( "dimension", &Zonotope::dimension ) - .field( "type", &Zonotope::type ); - - //' An exposed C++ class to represent an intersection of two V-polytopes - //' - //' @description An intersection of two V-polytopes is defined by the intersection of the two coresponding convex hulls. - //' - //' @field V1 \eqn{m\times d} numerical matrix that contains the vertices of the first V-polytope (row-wise) - //' @field V2 \eqn{q\times d} numerical matrix that contains the vertices of the second V-polytope (row-wise) - //' @field volume The volume of the polytope. - //' @field dimension An integer that declares the dimension of the polytope. It has not be given to the constructor. - //' @field type An integer that declares the representation of the polytope. For H-representation the default value is 4. It has not be given to the constructor. - //' - //' @example - //' # define the intwrsection of a 2-d simplex with a 2-d cross polytope - //' P1 = gen_simplex(2,'V') - //' P2 = gen_cross(2,'V') - //' P = VpolytopeIntersection$new(P1$V, P2$V) - //' @export - class_("VpolytopeIntersection") - // expose the default constructor - .constructor() - .constructor() - .constructor() - - .field( "V1", &VPinterVP::V1 ) - .field( "V2", &VPinterVP::V2 ) - .field( "volume", &VPinterVP::vol ) - .field( "dimension", &VPinterVP::dimension ) - .field( "type", &VPinterVP::type ); - - //' An exposed class to represent a sparse constraint problem - //' - //' @description A constraint problem is defined by a set of linear inequalities and equalities or equivalently a \eqn{d}-dimensional constraint problem is defined by a \eqn{mineq\times d} matrix Aineq and a \eqn{mineq}-dimensional vector bineq, s.t.: \eqn{Aineqx\leq bineq}, a \eqn{meq\times d} matrix Aeq and a \eqn{meq}-dimensional vector beq, s.t.: \eqn{Aeqx\eq beq} and two \eqn{d} vectors lb, ub such that \eqn{lb\leq x \leq ub}. - //' - //' @field Aineq \eqn{mineq\times d} sparse matrix Aineq - //' @field bineq \eqn{mineq}-dimensional vector bineq - //' @field Aeq \eqn{meq\times d} sparse matrix Aeq - //' @field beq \eqn{meq}-dimensional vector beq - //' @field lb \eqn{d}-dimensional vector lb - //' @field ub \eqn{d}-dimensional vector ub - //' @field dimension An integer that declares the dimension of the polytope. It has not be given to the constructor. - //' @field type An integer that declares the representation of the polytope. For sparse_constraint_problem the default value is 5. It has not be given to the constructor. - //' - //' @example - //' # create a 2-d unit simplex - //' Aineq = matrix(, nrow=0, ncol=2, byrow = TRUE) - //' Aineq = as( Aineq, 'dgCMatrix' ) - //' bineq= matrix(,nrow=0, ncol=1, byrow=TRUE) - //' Aeq = matrix(c(1,1), ncol=2, nrow=1, byrow=TRUE) - //' Aeq = as( Aeq, 'dgCMatrix' ) - //' beq = c(1) - //' lb = c(0,0) - //' ub = c(1,1) - //' P = sparse_constraint_problem$new(Aineq, bineq, Aeq, beq, lb, ub) - //' @export - class_("sparse_constraint_problem") - // expose the default constructor - .constructor() - .constructor() - .constructor() - .constructor() - - .field( "Aineq", &sparse_constraint_problem::Aineq ) - .field( "bineq", &sparse_constraint_problem::bineq ) - .field( "Aeq", &sparse_constraint_problem::Aeq ) - .field( "beq", &sparse_constraint_problem::beq ) - .field( "lb", &sparse_constraint_problem::lb ) - .field( "ub", &sparse_constraint_problem::ub ) - .field( "dimension", &sparse_constraint_problem::dimension ) - .field( "type", &sparse_constraint_problem::type ); -} - -extern SEXP _rcpp_module_boot_polytopes(void); diff --git a/R-proj/src/psrf_multivariate.cpp b/R-proj/src/psrf_multivariate.cpp deleted file mode 100644 index d9392f3f8..000000000 --- a/R-proj/src/psrf_multivariate.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// [[Rcpp::depends(BH)]] - -// VolEsti (volume computation and sampling library) - -// Copyright (c) 20014-2020 Vissarion Fisikopoulos -// Copyright (c) 2018-2020 Apostolos Chalkis - -//Contributed and/or modified by Alexandros Manochis, as part of Google Summer of Code 2020 program. - - -#include -#include -#include -#include -#include -#include -#include -#include "diagnostics/multivariate_psrf.hpp" - -//' Gelman-Rubin Potential Scale Reduction Factor (PSRF) -//' -//' @param samples A matrix that contans column-wise the sampled points from a geometric random walk. -//' -//' @references \cite{Gelman, A. and Rubin, D. B., -//' \dQuote{Inference from iterative simulation using multiple sequences,} \emph{Statistical Science,} 1992.} -//' -//' @references \cite{Brooks, S. and Gelman, A., -//' \dQuote{General Methods for Monitoring Convergence of Iterative Simulations,} \emph{Journal of Computational and Graphical Statistics,} 1998.} -//' -//' @return The value of multivariate PSRF by S. Brooks and A. Gelman. -//' -//' @export -// [[Rcpp::export]] -double psrf_multivariate(Rcpp::NumericMatrix samples) -{ - typedef double NT; - typedef Eigen::Matrix VT; - typedef Eigen::Matrix MT; - - return multivariate_psrf(Rcpp::as(samples)); -} diff --git a/R-proj/src/psrf_univariate.cpp b/R-proj/src/psrf_univariate.cpp deleted file mode 100644 index f01edadaf..000000000 --- a/R-proj/src/psrf_univariate.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// [[Rcpp::depends(BH)]] - -// VolEsti (volume computation and sampling library) - -// Copyright (c) 20014-2020 Vissarion Fisikopoulos -// Copyright (c) 2018-2020 Apostolos Chalkis - -//Contributed and/or modified by Alexandros Manochis, as part of Google Summer of Code 2020 program. - - -#include -#include -#include -#include -#include -#include -#include -#include "diagnostics/univariate_psrf.hpp" -#include "diagnostics/interval_psrf.hpp" - -//' 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.} -//' -//' @references \cite{Brooks, S. and Gelman, A., -//' \dQuote{General Methods for Monitoring Convergence of Iterative Simulations,} \emph{Journal of Computational and Graphical Statistics,} 1998.} -//' -//' @return A vector that contains the values of PSRF for each coordinate -//' -//' @export -// [[Rcpp::export]] -Rcpp::NumericVector psrf_univariate(Rcpp::NumericMatrix samples, - Rcpp::Nullable method = R_NilValue) -{ - typedef double NT; - typedef Eigen::Matrix VT; - typedef Eigen::Matrix MT; - - VT scores(samples.nrow()); - - std::string method_rcpp = std::string("normal"); - if(method.isNotNull()) { - method_rcpp = Rcpp::as(method); - } - - if (method_rcpp.compare(std::string("normal")) == 0) { - scores = univariate_psrf(Rcpp::as(samples)); - } else if(method_rcpp.compare(std::string("interval")) == 0) { - scores = interval_psrf(Rcpp::as(samples)); - } else { - throw Rcpp::exception("Unknown method!"); - } - - return Rcpp::wrap(scores); -} diff --git a/R-proj/src/raftery.cpp b/R-proj/src/raftery.cpp deleted file mode 100644 index e8e4f9ec8..000000000 --- a/R-proj/src/raftery.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// [[Rcpp::depends(BH)]] - -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2020 Vissarion Fisikopoulos -// Copyright (c) 2020 Apostolos Chalkis - -//Contributed and/or modified by Alexandros Manochis, as part of Google Summer of Code 2020 program. - - -#include -#include -#include -#include "cartesian_geom/cartesian_kernel.h" -#include -#include -#include -#include -#include "diagnostics/raftery.hpp" - -//' Raftery and Lewis MCMC diagnostic -//' -//' @param samples A matrix that contans column-wise the sampled points from a geometric random walk. -//' @param q Optional. The quantile of the quantity of interest. The default value is 0.025. -//' @param r Optional. The level of precision desired. The default value is 0.01. -//' @param s Optional. The probability associated with r. The default value is 0.95. -//' -//' @references \cite{Raftery, A. E. and Lewis, S. M., -//' \dQuote{How many iterations in the Gibbs sampler?,} \emph{Bayesian Statistics 4. Proceedings of the Fourth Valencia International Meeting,} 1992.} -//' -//' @return (i) The number of draws required for burn-in, (ii) the skip parameter for 1st-order Markov chain, (iii) the skip parameter sufficient to get independence chain, (iv) the number of draws required to achieve r precision, (v) the number of draws if the chain is white noise, (vi) the I-statistic from Raftery and Lewis (1992). -//' -//' @export -// [[Rcpp::export]] -Rcpp::NumericMatrix raftery(Rcpp::NumericMatrix samples, - Rcpp::Nullable q = R_NilValue, - Rcpp::Nullable r = R_NilValue, - Rcpp::Nullable s = R_NilValue) -{ - typedef double NT; - typedef Eigen::Matrix VT; - typedef Eigen::Matrix MT; - - NT _q = (!q.isNotNull()) ? 0.025 : Rcpp::as(q); - NT _r = (!r.isNotNull()) ? 0.01 : Rcpp::as(r); - NT _s = (!s.isNotNull()) ? 0.95 : Rcpp::as(s); - - MT results = perform_raftery(Rcpp::as(samples), _q, _r, _s); - - return Rcpp::wrap(results); -} diff --git a/R-proj/src/rotating.cpp b/R-proj/src/rotating.cpp deleted file mode 100644 index 607c00921..000000000 --- a/R-proj/src/rotating.cpp +++ /dev/null @@ -1,102 +0,0 @@ -// [[Rcpp::depends(BH)]] - -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2018 Vissarion Fisikopoulos -// Copyright (c) 2018 Apostolos Chalkis - -//Contributed and/or modified by Apostolos Chalkis, as part of Google Summer of Code 2018 program. - - -#include -#include -#include -#include "cartesian_geom/cartesian_kernel.h" -#include -#include -#include -#include -#include "volume/volume_sequence_of_balls.hpp" -#include "volume/rotating.hpp" -#include "extractMatPoly.h" - -//' An internal Rccp function for the random rotation of a convex polytope -//' -//' @param P A convex polytope (H-, V-polytope or a zonotope). -//' @param T Optional. A rotation matrix. -//' @param seed Optional. A fixed seed for the random linear map generator. -//' -//' @keywords internal -//' -//' @return A matrix that describes the rotated polytope -// [[Rcpp::export]] -Rcpp::NumericMatrix rotating (Rcpp::Reference P, Rcpp::Nullable T = R_NilValue, - Rcpp::Nullable seed = R_NilValue){ - - typedef double NT; - typedef Cartesian Kernel; - typedef typename Kernel::Point Point; - typedef BoostRandomNumberGenerator RNGType; - typedef HPolytope Hpolytope; - typedef VPolytope Vpolytope; - typedef Zonotope zonotope; - typedef IntersectionOfVpoly InterVP; - typedef Eigen::Matrix VT; - typedef Eigen::Matrix MT; - - MT TransorfMat; - Rcpp::NumericMatrix Mat; - unsigned int n = P.field("dimension"), type = P.field("type"); - - int seed_rcpp = (!seed.isNotNull()) ? std::chrono::system_clock::now() - .time_since_epoch().count() - : Rcpp::as(seed); - - switch (type) { - case 1: { - // Hpolytope - Hpolytope HP(n, Rcpp::as(P.field("A")), Rcpp::as(P.field("b"))); - if (T.isNotNull()) { - TransorfMat = Rcpp::as(T); - HP.linear_transformIt(TransorfMat.inverse()); - } else { - TransorfMat = rotating < MT > (HP, seed_rcpp); - } - Mat = extractMatPoly(HP); - break; - } - case 2: { - // Vpolytope - Vpolytope VP(n, Rcpp::as(P.field("V")), VT::Ones(Rcpp::as(P.field("V")).rows())); - if (T.isNotNull()) { - TransorfMat = Rcpp::as(T); - VP.linear_transformIt(TransorfMat.inverse()); - } else { - TransorfMat = rotating < MT > (VP, seed_rcpp); - } - Mat = extractMatPoly(VP); - break; - } - case 3: { - // Zonotope - zonotope ZP(n, Rcpp::as(P.field("G")), VT::Ones(Rcpp::as(P.field("G")).rows())); - if (T.isNotNull()) { - TransorfMat = Rcpp::as(T); - ZP.linear_transformIt(TransorfMat.inverse()); - } else { - TransorfMat = rotating < MT > (ZP, seed_rcpp); - } - Mat = extractMatPoly(ZP); - break; - } - case 4: { - throw Rcpp::exception("volesti does not support rotation for this representation currently."); - } - } - - TransorfMat.conservativeResize(n+1, n); - TransorfMat.row(n) = VT::Ones(n); - MT res(TransorfMat.rows(), Rcpp::as(Mat).rows()+n); - res << Rcpp::as(Mat).transpose(), TransorfMat; - return Rcpp::wrap(res); -} diff --git a/R-proj/src/rounding.cpp b/R-proj/src/rounding.cpp deleted file mode 100644 index 0b2cbe0f0..000000000 --- a/R-proj/src/rounding.cpp +++ /dev/null @@ -1,142 +0,0 @@ -// [[Rcpp::depends(BH)]] - -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2020 Vissarion Fisikopoulos -// Copyright (c) 2018-2020 Apostolos Chalkis - -//Contributed and/or modified by Apostolos Chalkis, as part of Google Summer of Code 2018 program. -//Contributed and/or modified by Alexandros Manochis, as part of Google Summer of Code 2020 program. - - -#include -#include -#include -#include "cartesian_geom/cartesian_kernel.h" -#include -#include -#include -#include -#include "random_walks/random_walks.hpp" -#include "volume/volume_sequence_of_balls.hpp" -#include "volume/volume_cooling_gaussians.hpp" -#include "preprocess/min_sampling_covering_ellipsoid_rounding.hpp" -#include "preprocess/svd_rounding.hpp" -#include "preprocess/max_inscribed_ellipsoid_rounding.hpp" -#include "extractMatPoly.h" - -template -< - typename MT, - typename VT, - typename WalkType, - typename Polytope, - typename Point, - typename NT, - typename RNGType -> -std::tuple apply_rounding(Polytope &P, - std::string const& method_rcpp, - unsigned int const& walkL, - std::pair &InnerBall, - RNGType &rng) -{ - std::tuple round_res; - if (method_rcpp.compare(std::string("min_ellipsoid")) == 0) { - round_res = min_sampling_covering_ellipsoid_rounding(P, InnerBall, walkL, rng); - } else if (method_rcpp.compare(std::string("isotropy")) == 0) { - round_res = svd_rounding(P, InnerBall, walkL, rng); - } else { - throw Rcpp::exception("Unknown method!"); - } - return round_res; -} - -//' Internal rcpp function for the rounding of a convex polytope -//' -//' @param P A convex polytope (H- or V-representation or zonotope). -//' @param method Optional. The method to use for rounding, a) \code{'min_ellipsoid'} for the method based on mimimmum volume enclosing ellipsoid of a uniform sample from P, b) \code{'max_ellipsoid'} for the method based on maximum volume enclosed ellipsoid in P, (c) \code{'isotropy'} for the method based on isotropy. The default method is \code{'min_ellipsoid'} for all the representations. -//' @param seed Optional. A fixed seed for the number generator. -//' -//' @keywords internal -//' -//' @return A numerical matrix that describes the rounded polytope, a numerical matrix of the inverse linear transofmation that is applied on the input polytope, the numerical vector the the input polytope is shifted and the determinant of the matrix of the linear transformation that is applied on the input polytope. -// [[Rcpp::export]] -Rcpp::List rounding (Rcpp::Reference P, - Rcpp::Nullable method = R_NilValue, - Rcpp::Nullable seed = R_NilValue){ - - typedef double NT; - typedef Cartesian Kernel; - typedef typename Kernel::Point Point; - typedef BoostRandomNumberGenerator RNGType; - typedef HPolytope Hpolytope; - typedef VPolytope Vpolytope; - typedef Zonotope zonotope; - typedef Eigen::Matrix VT; - typedef Eigen::Matrix MT; - - unsigned int n = P.field("dimension"), walkL = 2, type = P.field("type"); - std::string method_rcpp = std::string("isotropy"); - if(method.isNotNull()) { - method_rcpp = Rcpp::as(method); - if (method_rcpp.compare(std::string("max_ellipsoid")) == 0 && type != 1) { - Rcpp::exception("This method can not be used for V- or Z-polytopes!"); - } - } - - RNGType rng(n); - if (seed.isNotNull()) { - unsigned seed_rcpp = Rcpp::as(seed); - rng.set_seed(seed_rcpp); - } - - std::pair InnerBall; - Rcpp::NumericMatrix Mat; - - std::tuple round_res; - switch (type) { - case 1: { - // Hpolytope - - if (Rcpp::as(P.field("Aeq")).rows() > 0) { - throw Rcpp::exception("volesti supports rounding for full dimensional polytopes"); - } - Hpolytope HP(n, Rcpp::as(P.field("A")), Rcpp::as(P.field("b"))); - InnerBall = HP.ComputeInnerBall(); - if (InnerBall.second < 0.0) throw Rcpp::exception("Unable to compute a feasible point."); - if (method_rcpp.compare(std::string("max_ellipsoid")) == 0) { - round_res = max_inscribed_ellipsoid_rounding(HP, InnerBall.first); - } else { - round_res = apply_rounding(HP, method_rcpp, walkL, InnerBall, rng); - } - Mat = extractMatPoly(HP); - break; - } - case 2: { - // Vpolytope - Vpolytope VP(n, Rcpp::as(P.field("V")), VT::Ones(Rcpp::as(P.field("V")).rows())); - InnerBall = VP.ComputeInnerBall(); - if (InnerBall.second < 0.0) throw Rcpp::exception("Unable to compute a feasible point."); - round_res = apply_rounding(VP, method_rcpp, walkL, InnerBall, rng); - Mat = extractMatPoly(VP); - break; - } - case 3: { - // Zonotope - zonotope ZP(n, Rcpp::as(P.field("G")), VT::Ones(Rcpp::as(P.field("G")).rows())); - InnerBall = ZP.ComputeInnerBall(); - if (InnerBall.second < 0.0) throw Rcpp::exception("Unable to compute a feasible point."); - round_res = apply_rounding(ZP, method_rcpp, walkL, InnerBall, rng); - Mat = extractMatPoly(ZP); - break; - } - case 4: { - throw Rcpp::exception("volesti does not support rounding for this representation currently."); - } - } - - return Rcpp::List::create(Rcpp::Named("Mat") = Mat, Rcpp::Named("T") = Rcpp::wrap(std::get<0>(round_res)), - Rcpp::Named("shift") = Rcpp::wrap(std::get<1>(round_res)), - Rcpp::Named("round_value") = std::get<2>(round_res)); -} diff --git a/R-proj/src/sample_points.cpp b/R-proj/src/sample_points.cpp deleted file mode 100644 index 1014e74ea..000000000 --- a/R-proj/src/sample_points.cpp +++ /dev/null @@ -1,795 +0,0 @@ -// [[Rcpp::depends(BH)]] - -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2021 Vissarion Fisikopoulos -// Copyright (c) 2018-2021 Apostolos Chalkis - -//Contributed and/or modified by Apostolos Chalkis, as part of Google Summer of Code 2018 and 2019 program. - -// Contributed and/or modified by Alexandros Manochis, as part of Google Summer of Code 2020 program. - - -#include -#include -#include -#include -#include -#include -#include -#include "random_walks/random_walks.hpp" -#include "volume/volume_sequence_of_balls.hpp" -#include "volume/volume_cooling_gaussians.hpp" -#include "sampling/sampling.hpp" -#include "ode_solvers/ode_solvers.hpp" -#include "oracle_functors_rcpp.h" -#include "preprocess/crhmc/constraint_problem.h" -enum random_walks { - ball_walk, - rdhr, - cdhr, - billiard, - accelarated_billiard, - dikin_walk, - vaidya_walk, - john_walk, - brdhr, - bcdhr, - hmc, - nuts, - gaussian_hmc, - exponential_hmc, - uld, - crhmc -}; - -template < - typename Polytope, - typename RNGType, - typename PointList, - typename NT, - typename Point, - typename NegativeGradientFunctor, - typename NegativeLogprobFunctor, - typename HessianFunctor -> -void sample_from_polytope(Polytope &P, int type, RNGType &rng, PointList &randPoints, - unsigned int const& walkL, unsigned int const& numpoints, - bool const& gaussian, NT const& a, NT const& L, Point const& c, - Point const& StartingPoint, unsigned int const& nburns, - bool const& set_L, NT const& eta, random_walks walk, - NegativeGradientFunctor *F=NULL, NegativeLogprobFunctor *f=NULL, - HessianFunctor *h=NULL, ode_solvers solver_type = no_solver) -{ - switch (walk) - { - case bcdhr: - uniform_sampling_boundary (randPoints, P, rng, walkL, numpoints, - StartingPoint, nburns); - break; - case brdhr: - uniform_sampling_boundary (randPoints, P, rng, walkL, numpoints, - StartingPoint, nburns); - break; - case cdhr: - if(gaussian) { - gaussian_sampling(randPoints, P, rng, walkL, numpoints, - a, StartingPoint, nburns); - } else { - uniform_sampling(randPoints, P, rng, walkL, numpoints, - StartingPoint, nburns); - } - break; - case rdhr: - if(gaussian) { - gaussian_sampling(randPoints, P, rng, walkL, numpoints, - a, StartingPoint, nburns); - } else { - uniform_sampling(randPoints, P, rng, walkL, numpoints, - StartingPoint, nburns); - } - break; - case gaussian_hmc: - if(set_L) { - GaussianHamiltonianMonteCarloExactWalk WalkType(L); - gaussian_sampling(randPoints, P, rng, WalkType, walkL, numpoints, a, StartingPoint, nburns); - } else { - gaussian_sampling(randPoints, P, rng, walkL, numpoints, a, - StartingPoint, nburns); - } - break; - case vaidya_walk: - if (set_L) { - VaidyaWalk WalkType(L); - uniform_sampling(randPoints, P, rng, WalkType, walkL, numpoints, StartingPoint, nburns); - } else { - uniform_sampling(randPoints, P, rng, walkL, numpoints, - StartingPoint, nburns); - } - break; - case dikin_walk: - if (set_L) { - DikinWalk WalkType(L); - uniform_sampling(randPoints, P, rng, WalkType, walkL, numpoints, StartingPoint, nburns); - } else { - uniform_sampling(randPoints, P, rng, walkL, numpoints, - StartingPoint, nburns); - } - break; - case john_walk: - if (set_L) { - JohnWalk WalkType(L); - uniform_sampling(randPoints, P, rng, WalkType, walkL, numpoints, StartingPoint, nburns); - } else { - uniform_sampling(randPoints, P, rng, walkL, numpoints, - StartingPoint, nburns); - } - break; - case billiard: - if(set_L) { - BilliardWalk WalkType(L); - uniform_sampling(randPoints, P, rng, WalkType, walkL, numpoints, StartingPoint, nburns); - } else { - uniform_sampling(randPoints, P, rng, walkL, numpoints, - StartingPoint, nburns); - } - break; - case accelarated_billiard: - if(set_L) { - AcceleratedBilliardWalk WalkType(L); - uniform_sampling(randPoints, P, rng, WalkType, walkL, numpoints, StartingPoint, nburns); - } else { - uniform_sampling(randPoints, P, rng, walkL, numpoints, - StartingPoint, nburns); - } - break; - case exponential_hmc: - if (set_L) { - ExponentialHamiltonianMonteCarloExactWalk WalkType(L); - exponential_sampling(randPoints, P, rng, WalkType, walkL, numpoints, c, a, StartingPoint, nburns); - } else { - exponential_sampling(randPoints, P, rng, walkL, numpoints, c, a, - StartingPoint, nburns); - } - break; - case ball_walk: - if (set_L) { - if (gaussian) { - GaussianBallWalk WalkType(L); - gaussian_sampling(randPoints, P, rng, WalkType, walkL, numpoints, a, - StartingPoint, nburns); - } else { - BallWalk WalkType(L); - uniform_sampling(randPoints, P, rng, WalkType, walkL, numpoints, - StartingPoint, nburns); - } - } else { - if(gaussian) { - gaussian_sampling(randPoints, P, rng, walkL, numpoints, - a, StartingPoint, nburns); - } else { - uniform_sampling(randPoints, P, rng, walkL, numpoints, - StartingPoint, nburns); - } - } - break; - case hmc: - switch (solver_type) { - case leapfrog: - logconcave_sampling < - PointList, - Polytope, - RNGType, - HamiltonianMonteCarloWalk, - NT, - Point, - NegativeGradientFunctor, - NegativeLogprobFunctor, - LeapfrogODESolver < - Point, - NT, - Polytope, - NegativeGradientFunctor - > - >(randPoints, P, rng, walkL, numpoints, StartingPoint, nburns, *F, *f); - break; - case euler: - logconcave_sampling < - PointList, - Polytope, - RNGType, - HamiltonianMonteCarloWalk, - NT, - Point, - NegativeGradientFunctor, - NegativeLogprobFunctor, - EulerODESolver < - Point, - NT, - Polytope, - NegativeGradientFunctor - > - >(randPoints, P, rng, walkL, numpoints, StartingPoint, nburns, *F, *f); - break; - default: - break; - } - - break; - case crhmc:{ - execute_crhmc(P, rng, randPoints, walkL, numpoints, nburns, F, f, h); - break; - } - case nuts: - - logconcave_sampling < - PointList, - Polytope, - RNGType, - NutsHamiltonianMonteCarloWalk, - NT, - Point, - NegativeGradientFunctor, - NegativeLogprobFunctor, - LeapfrogODESolver < - Point, - NT, - Polytope, - NegativeGradientFunctor - > - >(randPoints, P, rng, walkL, numpoints, StartingPoint, nburns, *F, *f); - - break; - case uld: - - logconcave_sampling < - PointList, - Polytope, - RNGType, - UnderdampedLangevinWalk, - NT, - Point, - NegativeGradientFunctor, - NegativeLogprobFunctor, - LeapfrogODESolver < - Point, - NT, - Polytope, - NegativeGradientFunctor - > - >(randPoints, P, rng, walkL, numpoints, StartingPoint, nburns, *F, *f); - - break; - default: - throw Rcpp::exception("Unknown random walk!"); - } -} - -//' Sample uniformly, normally distributed, or logconcave distributed points from a convex Polytope (H-polytope, V-polytope, zonotope or intersection of two V-polytopes). -//' -//' @param P A convex polytope. It is an object from class (a) Hpolytope or (b) Vpolytope or (c) Zonotope or (d) VpolytopeIntersection. -//' @param n The number of points that the function is going to sample from the convex polytope. -//' @param random_walk Optional. A list that declares the random walk and some related parameters as follows: -//' \itemize{ -//' \item{\code{walk} }{ A string to declare the random walk: i) \code{'CDHR'} for Coordinate Directions Hit-and-Run, -//' ii) \code{'RDHR'} for Random Directions Hit-and-Run, iii) \code{'BaW'} for Ball Walk, iv) \code{'BiW'} for Billiard walk, -//' v) \code{'dikin'} for dikin walk, vi) \code{'vaidya'} for vaidya walk, vii) \code{'john'} for john walk, -//' viii) \code{'BCDHR'} boundary sampling by keeping the extreme points of CDHR or ix) \code{'BRDHR'} boundary sampling by keeping the extreme points of RDHR, -//' x) \code{'NUTS'} for NUTS Hamiltonian Monte Carlo sampler (logconcave densities), xi) \code{'HMC'} for Hamiltonian Monte Carlo (logconcave densities), -//' xii) CRHMC for Riemannian HMC with H-polytope constraints (uniform and general logconcave densities), -//' xiii) \code{'ULD'} for Underdamped Langevin Dynamics using the Randomized Midpoint Method (logconcave densities), -//' xiii) \code{'ExactHMC'} for exact Hamiltonian Monte Carlo with reflections (spherical Gaussian or exponential distribution). -//' The default walk is \code{'aBiW'} for the uniform distribution, \code{'CDHR'} for the Gaussian distribution and H-polytopes and -//' \code{'BiW'} or \code{'RDHR'} for the same distributions and V-polytopes and zonotopes. \code{'NUTS'} is the default sampler for logconcave densities and \code{'CRHMC'} -//' for logconcave densities with H-polytope and sparse constrainted problems.} -//' \item{\code{walk_length} }{ The number of the steps per generated point for the random walk. The default value is \eqn{1}.} -//' \item{\code{nburns} }{ The number of points to burn before start sampling. The default value is \eqn{1}.} -//' \item{\code{starting_point} }{ A \eqn{d}-dimensional numerical vector that declares a starting point in the interior of the polytope for the random walk. The default choice is the center of the ball as that one computed by the function \code{inner_ball()}.} -//' \item{\code{BaW_rad} }{ The radius for the ball walk.} -//' \item{\code{L} }{ The maximum length of the billiard trajectory or the radius for the step of dikin, vaidya or john walk.} -//' \item{\code{solver} }{ Specify ODE solver for logconcave sampling. Options are i) leapfrog, ii) euler iii) runge-kutta iv) richardson} -//' \item{\code{step_size }{ Optionally chosen step size for logconcave sampling. Defaults to a theoretical value if not provided.} -//' } -//' @param distribution Optional. A list that declares the target density and some related parameters as follows: -//' \itemize{ -//' \item{\code{density} }{ A string: (a) \code{'uniform'} for the uniform distribution or b) \code{'gaussian'} for the multidimensional spherical distribution c) \code{logconcave} with form proportional to exp(-f(x)) where f(x) is L-smooth and m-strongly-convex d) \code{'exponential'} for the exponential distribution. The default target distribution is the uniform distribution.} -//' \item{\code{variance} }{ The variance of the multidimensional spherical gaussian or the exponential distribution. The default value is 1.} -//' \item{\code{mode} }{ A \eqn{d}-dimensional numerical vector that declares the mode of the Gaussian distribution. The default choice is the center of the as that one computed by the function \code{inner_ball()}.} -//' \item{\code{bias} }{ The bias vector for the exponential distribution. The default vector is \eqn{c_1 = 1} and \eqn{c_i = 0} for \eqn{i \neq 1}.} -//' \item{\code{L_} }{ Smoothness constant (for logconcave). } -//' \item{\code{m} }{ Strong-convexity constant (for logconcave). } -//' \item{\code{negative_logprob} }{ Negative log-probability (for logconcave). } -//' \item{\code{negative_logprob_gradient} }{ Negative log-probability gradient (for logconcave). } -//' } -//' @param seed Optional. A fixed seed for the number generator. -//' -//' @references \cite{Robert L. Smith, -//' \dQuote{Efficient Monte Carlo Procedures for Generating Points Uniformly Distributed Over Bounded Regions,} \emph{Operations Research,} 1984.}, -//' -//' @references \cite{B.T. Polyak, E.N. Gryazina, -//' \dQuote{Billiard walk - a new sampling algorithm for control and optimization,} \emph{IFAC Proceedings Volumes,} 2014.}, -//' -//' @references \cite{Y. Chen, R. Dwivedi, M. J. Wainwright and B. Yu, -//' \dQuote{Fast MCMC Sampling Algorithms on Polytopes,} \emph{Journal of Machine Learning Research,} 2018.} -//' -//' @references \cite{Lee, Yin Tat, Ruoqi Shen, and Kevin Tian, -//' \dQuote{"Logsmooth Gradient Concentration and Tighter Runtimes for Metropolized Hamiltonian Monte Carlo,"} \emph{arXiv preprint arXiv:2002.04121}, 2020.} -//' -//' @references \cite{Shen, Ruoqi, and Yin Tat Lee, -//' \dQuote{"The randomized midpoint method for log-concave sampling.",} \emph{Advances in Neural Information Processing Systems}, 2019.} -//' -//' @references \cite{Augustin Chevallier, Sylvain Pion, Frederic Cazals, -//' \dQuote{"Hamiltonian Monte Carlo with boundary reflections, and application to polytope volume calculations,"} \emph{Research Report preprint hal-01919855}, 2018.} -//' -//' @return A \eqn{d\times n} matrix that contains, column-wise, the sampled points from the convex polytope P. -//' @examples -//' # uniform distribution from the 3d unit cube in H-representation using ball walk -//' P = gen_cube(3, 'H') -//' points = sample_points(P, n = 100, random_walk = list("walk" = "BaW", "walk_length" = 5)) -//' -//' # gaussian distribution from the 2d unit simplex in H-representation with variance = 2 -//' A = matrix(c(-1,0,0,-1,1,1), ncol=2, nrow=3, byrow=TRUE) -//' b = c(0,0,1) -//' P = Hpolytope$new(A,b) -//' points = sample_points(P, n = 100, distribution = list("density" = "gaussian", "variance" = 2)) -//' -//' # uniform points from the boundary of a 2-dimensional random H-polytope -//' P = gen_rand_hpoly(2,20) -//' points = sample_points(P, n = 100, random_walk = list("walk" = "BRDHR")) -//' -//' # For sampling from logconcave densities see the examples directory -//' -//' @export -// [[Rcpp::export]] -Rcpp::NumericMatrix sample_points(Rcpp::Nullable P, - Rcpp::Nullable n, - Rcpp::Nullable random_walk = R_NilValue, - Rcpp::Nullable distribution = R_NilValue, - Rcpp::Nullable seed = R_NilValue){ - - typedef double NT; - typedef Cartesian Kernel; - typedef BoostRandomNumberGenerator RNGType; - typedef typename Kernel::Point Point; - typedef HPolytope Hpolytope; - typedef VPolytope Vpolytope; - typedef Zonotope zonotope; - typedef IntersectionOfVpoly InterVP; - typedef Eigen::Matrix VT; - typedef Eigen::Matrix MT; - typedef Eigen::SparseMatrix SpMat; - typedef constraint_problem sparse_problem; - - unsigned int type = Rcpp::as(P).field("type"), dim = Rcpp::as(P).field("dimension"), - walkL = 1, numpoints, nburns = 0; - - RcppFunctor::GradientFunctor *F = NULL; - RcppFunctor::FunctionFunctor *f = NULL; - RcppFunctor::HessianFunctor *h = NULL; - - GaussianFunctor::GradientFunctor *G = NULL; - GaussianFunctor::FunctionFunctor *g = NULL; - GaussianFunctor::HessianFunctor *hess_g = NULL; - bool functor_defined = true; - - - RNGType rng(dim); - if (seed.isNotNull()) { - unsigned seed_rcpp = Rcpp::as(seed); - rng.set_seed(seed_rcpp); - } - - Point c(dim); - - NT radius = 1.0, L; - bool set_mode = false, gaussian = false, logconcave = false, exponential = false, - set_starting_point = false, set_L = false; - - random_walks walk; - ode_solvers solver; // Used only for logconcave sampling - - NT eta = 1; - std::list randPoints; - std::pair InnerBall; - Point mode(dim); - - numpoints = Rcpp::as(n); - if (numpoints <= 0) throw Rcpp::exception("The number of samples has to be a positive integer!"); - - if (!distribution.isNotNull() || !Rcpp::as(distribution).containsElementNamed("density")) { - walk = billiard; - } else if ( - Rcpp::as(Rcpp::as(distribution)["density"]).compare(std::string("uniform")) == 0) { - walk = billiard; - } else if ( - Rcpp::as(Rcpp::as(distribution)["density"]).compare(std::string("gaussian")) == 0) { - gaussian = true; - } else if ( - Rcpp::as(Rcpp::as(distribution)["density"]).compare(std::string("exponential")) == 0) { - walk = exponential_hmc; - exponential = true; - } else if ( - Rcpp::as(Rcpp::as(distribution)["density"]).compare(std::string("logconcave")) == 0) { - logconcave = true; - } else { - throw Rcpp::exception("Wrong distribution!"); - } - - if (Rcpp::as(distribution).containsElementNamed("mode")) { - if (!(gaussian || logconcave)) throw Rcpp::exception("Mode is given only for Gaussian/logconcave sampling!"); - if (Rcpp::as(Rcpp::as(distribution)["mode"]).size() != dim) { - throw Rcpp::exception("Mode has to be a point in the same dimension as the polytope P"); - } else { - set_mode = true; - VT temp = Rcpp::as(Rcpp::as(distribution)["mode"]); - mode = Point(dim, std::vector(&temp[0], temp.data() + temp.cols() * temp.rows())); - } - } - - NT a = 0.5; - if (Rcpp::as(distribution).containsElementNamed("variance")) { - a = 1.0 / (2.0 * Rcpp::as(Rcpp::as(distribution)["variance"])); - if (exponential) a = Rcpp::as(Rcpp::as(distribution)["variance"]); - if (!(gaussian || logconcave || exponential)) { - Rcpp::warning("The variance can be set only for Gaussian and exponential sampling!"); - } else if (a <= 0.0) { - throw Rcpp::exception("The variance has to be positive!"); - } - } - - if (Rcpp::as(distribution).containsElementNamed("bias")) { - c = Point(Rcpp::as(Rcpp::as(distribution)["bias"])); - } - - if (Rcpp::as(distribution).containsElementNamed("negative_logprob") && - Rcpp::as(distribution).containsElementNamed("negative_logprob_gradient")) { - - if (!logconcave) { - throw Rcpp::exception("The negative logprob and its gradient can be set only for logconcave sampling!"); - } - - // Parse arguments - Rcpp::Function negative_logprob = Rcpp::as(distribution)["negative_logprob"]; - Rcpp::Function negative_logprob_gradient = Rcpp::as(distribution)["negative_logprob_gradient"]; - - NT L_ = 1, m = 1; - - if (Rcpp::as(distribution).containsElementNamed("L_")) { - L_ = Rcpp::as(Rcpp::as(distribution)["L_"]); - if (L_ <= NT(0)) { - throw Rcpp::exception("The smoothness constant must be positive"); - } - } else { - L_ = -1; - } - - if (Rcpp::as(distribution).containsElementNamed("m")) { - m = Rcpp::as(Rcpp::as(distribution)["m"]); - if (m <= NT(0)) { - throw Rcpp::exception("The strong-convexity constant must be positive"); - } - } else { - m = -1; - } - - if (Rcpp::as(random_walk).containsElementNamed("step_size")) { - eta = NT(Rcpp::as(Rcpp::as(random_walk)["step_size"])); - if (eta <= NT(0)) { - throw Rcpp::exception("Step size must be positive"); - } - } else { - eta = NT(-1); - } - - if (Rcpp::as(random_walk).containsElementNamed("solver")) { - std::string solver_str = Rcpp::as(Rcpp::as(random_walk)["solver"]); - if (solver_str == "leapfrog") { - solver = leapfrog; - } else if (solver_str == "euler") { - solver = euler; - } else if (solver_str == "implicit_midpoint"){ - solver = implicit_midpoint; - } else { - throw Rcpp::exception("Invalid ODE solver specified. Aborting."); - } - } else { - solver = leapfrog; - } - // Create functors - RcppFunctor::parameters rcpp_functor_params(L_, m, eta, 2); - F = new RcppFunctor::GradientFunctor(rcpp_functor_params, negative_logprob_gradient); - f = new RcppFunctor::FunctionFunctor(rcpp_functor_params, negative_logprob); - if(Rcpp::as(distribution).containsElementNamed("negative_logprob_hessian")){ - Rcpp::Function negative_logprob_hessian = Rcpp::as(distribution)["negative_logprob_hessian"]; - h = new RcppFunctor::HessianFunctor(rcpp_functor_params, negative_logprob_hessian); - } - } - - else if (logconcave && !Rcpp::as(distribution).containsElementNamed("negative_logprob") && - !Rcpp::as(distribution).containsElementNamed("negative_logprob_gradient")) { - - functor_defined = false; - - if (Rcpp::as(random_walk).containsElementNamed("step_size")) { - eta = NT(Rcpp::as(Rcpp::as(random_walk)["step_size"])); - if (eta <= NT(0)) { - throw Rcpp::exception("Step size must be positive"); - } - } else { - eta = NT(-1); - } - - if (Rcpp::as(random_walk).containsElementNamed("solver")) { - std::string solver_str = Rcpp::as(Rcpp::as(random_walk)["solver"]); - if (solver_str == "leapfrog") { - solver = leapfrog; - } else if (solver_str == "euler") { - solver = euler; - } else if (solver_str == "implicit_midpoint"){ - solver = implicit_midpoint; - } else { - throw Rcpp::exception("Invalid ODE solver specified. Aborting."); - } - } else { - Rcpp::warning("Solver set to leapfrog."); - solver = leapfrog; - } - // Create functors - GaussianFunctor::parameters* gaussian_functor_params=new GaussianFunctor::parameters(mode, a, eta); - G = new GaussianFunctor::GradientFunctor(*gaussian_functor_params); - g = new GaussianFunctor::FunctionFunctor(*gaussian_functor_params); - hess_g = new GaussianFunctor::HessianFunctor(*gaussian_functor_params); - } - - if (!random_walk.isNotNull() || !Rcpp::as(random_walk).containsElementNamed("walk")) { - if (exponential) { - if (type !=1) { - throw Rcpp::exception("Exponential sampling is supported only for H-polytopes"); - } - walk = exponential_hmc; - } else if (logconcave) { - walk = (type == 5) ? crhmc : nuts; - } else if (gaussian) { - walk = (type == 1) ? cdhr : rdhr; - } else { - walk = (type == 1) ? accelarated_billiard : billiard; - } - } else if (Rcpp::as(Rcpp::as(random_walk)["walk"]).compare(std::string("CDHR")) == 0) { - walk = cdhr; - } else if (Rcpp::as(Rcpp::as(random_walk)["walk"]).compare(std::string("dikin")) == 0) { - walk = dikin_walk; - if (Rcpp::as(random_walk).containsElementNamed("L")) { - L = Rcpp::as(Rcpp::as(random_walk)["L"]); - set_L = true; - if (L <= 0.0) throw Rcpp::exception("L must be a postitive number!"); - } - } else if (Rcpp::as(Rcpp::as(random_walk)["walk"]).compare(std::string("vaidya")) == 0) { - walk = vaidya_walk; - if (Rcpp::as(random_walk).containsElementNamed("L")) { - L = Rcpp::as(Rcpp::as(random_walk)["L"]); - set_L = true; - if (L <= 0.0) throw Rcpp::exception("L must be a postitive number!"); - } - } else if (Rcpp::as(Rcpp::as(random_walk)["walk"]).compare(std::string("john")) == 0) { - walk = john_walk; - if (Rcpp::as(random_walk).containsElementNamed("L")) { - L = Rcpp::as(Rcpp::as(random_walk)["L"]); - set_L = true; - if (L <= 0.0) throw Rcpp::exception("L must be a postitive number!"); - } - } else if (Rcpp::as(Rcpp::as(random_walk)["walk"]).compare(std::string("RDHR")) == 0) { - walk = rdhr; - } else if (Rcpp::as(Rcpp::as(random_walk)["walk"]).compare(std::string("BaW")) == 0) { - walk = ball_walk; - if (Rcpp::as(random_walk).containsElementNamed("BaW_rad")) { - L = Rcpp::as(Rcpp::as(random_walk)["BaW_rad"]); - set_L = true; - if (L <= 0.0) throw Rcpp::exception("BaW diameter must be a postitive number!"); - } - } else if (Rcpp::as(Rcpp::as(random_walk)["walk"]).compare(std::string("BiW")) == 0) { - if (gaussian) throw Rcpp::exception("Billiard walk can be used only for uniform sampling!"); - walk = billiard; - if (Rcpp::as(random_walk).containsElementNamed("L")) { - L = Rcpp::as(Rcpp::as(random_walk)["L"]); - set_L = true; - if (L <= 0.0) throw Rcpp::exception("L must be a postitive number!"); - } - } else if (Rcpp::as(Rcpp::as(random_walk)["walk"]).compare(std::string("aBiW")) == 0) { - if (gaussian) throw Rcpp::exception("Billiard walk can be used only for uniform sampling!"); - walk = accelarated_billiard; - if (Rcpp::as(random_walk).containsElementNamed("L")) { - L = Rcpp::as(Rcpp::as(random_walk)["L"]); - set_L = true; - if (L <= 0.0) throw Rcpp::exception("L must be a postitive number!"); - } - } else if (Rcpp::as(Rcpp::as(random_walk)["walk"]).compare(std::string("BRDHR")) == 0) { - if (gaussian || exponential) throw Rcpp::exception("Gaussian sampling from the boundary is not supported!"); - walk = brdhr; - } else if (Rcpp::as(Rcpp::as(random_walk)["walk"]).compare(std::string("BCDHR")) == 0) { - if (gaussian) throw Rcpp::exception("Gaussian sampling from the boundary is not supported!"); - walk = bcdhr; - } else if(Rcpp::as(Rcpp::as(random_walk)["walk"]).compare(std::string("ExactHMC")) == 0) { - if (!exponential && !gaussian) throw Rcpp::exception("Exact HMC is supported only for exponential or spherical Gaussian sampling."); - if(exponential){ - walk = exponential_hmc; - } else { - walk = gaussian_hmc; - } - } else if (Rcpp::as(Rcpp::as(random_walk)["walk"]).compare(std::string("HMC")) == 0) { - if (!logconcave) throw Rcpp::exception("HMC is not supported for non first-order sampling"); - if (F->params.L < 0) throw Rcpp::exception("The smoothness constant is absent"); - if (F->params.m < 0) throw Rcpp::exception("The strong-convexity constant is absent"); - walk = hmc; - } else if (Rcpp::as(Rcpp::as(random_walk)["walk"]).compare(std::string("NUTS")) == 0) { - if (!logconcave) throw Rcpp::exception("NUTS is not supported for non first-order sampling"); - walk = nuts; - } else if (Rcpp::as(Rcpp::as(random_walk)["walk"]).compare(std::string("ULD")) == 0) { - if (!logconcave) throw Rcpp::exception("ULD is not supported for non first-order sampling"); - walk = uld; - } else if(Rcpp::as(Rcpp::as(random_walk)["walk"]).compare(std::string("CRHMC")) == 0){ - if (!logconcave) throw Rcpp::exception("CRHMC is used for logconcave sampling"); - if (type !=1 && type !=5 ) { - throw Rcpp::exception("CRHMC sampling is supported only for H-polytopes and Sparse Problems."); - } - walk =crhmc; - if(solver!=implicit_midpoint){ - Rcpp::warning("Solver set to implicit midpoint."); - } - solver = implicit_midpoint; - } else { - throw Rcpp::exception("Unknown walk type!"); - } - - Point StartingPoint; - if (Rcpp::as(random_walk).containsElementNamed("starting_point")) { - if (Rcpp::as(Rcpp::as(random_walk)["starting_point"]).size() != dim) { - throw Rcpp::exception("Starting Point has to lie in the same dimension as the polytope P"); - } else { - set_starting_point = true; - VT temp = Rcpp::as(Rcpp::as(random_walk)["starting_point"]); - StartingPoint = Point(dim, std::vector(&temp[0], temp.data() + temp.cols() * temp.rows())); - } - } - - if (Rcpp::as(random_walk).containsElementNamed("walk_length")) { - walkL = Rcpp::as(Rcpp::as(random_walk)["walk_length"]); - if (walkL <= 0) { - throw Rcpp::exception("The walk length has to be a positive integer!"); - } - } - - if (Rcpp::as(random_walk).containsElementNamed("nburns")) { - nburns = Rcpp::as(Rcpp::as(random_walk)["nburns"]); - if (nburns < 0) { - throw Rcpp::exception("The number of points to burn before sampling has to be a positive integer!"); - } - } - - switch(type) { - case 1: { - // Hpolytope - Hpolytope HP(dim, Rcpp::as(Rcpp::as(P).field("A")), - Rcpp::as(Rcpp::as(P).field("b"))); - - InnerBall = HP.ComputeInnerBall(); - if (InnerBall.second < 0.0) throw Rcpp::exception("Unable to compute a feasible point."); - if (!set_starting_point || (!set_mode && gaussian)) { - if (!set_starting_point) StartingPoint = InnerBall.first; - if (!set_mode && gaussian) mode = InnerBall.first; - } - if (HP.is_in(StartingPoint) == 0) { - throw Rcpp::exception("The given point is not in the interior of the polytope!"); - } - if (gaussian) { - StartingPoint = StartingPoint - mode; - HP.shift(mode.getCoefficients()); - } - if (functor_defined) { - sample_from_polytope(HP, type, rng, randPoints, walkL, numpoints, gaussian, a, L, c, - StartingPoint, nburns, set_L, eta, walk, F, f, h, solver); - } - else { - sample_from_polytope(HP, type, rng, randPoints, walkL, numpoints, gaussian, a, L, c, - StartingPoint, nburns, set_L, eta, walk, G, g, hess_g, solver); - } - break; - } - case 2: { - // Vpolytope - Vpolytope VP(dim, Rcpp::as(Rcpp::as(P).field("V")), - VT::Ones(Rcpp::as(Rcpp::as(P).field("V")).rows())); - - InnerBall = VP.ComputeInnerBall(); - if (InnerBall.second < 0.0) throw Rcpp::exception("Unable to compute a feasible point."); - if (!set_starting_point || (!set_mode && gaussian)) { - if (!set_starting_point) StartingPoint = InnerBall.first; - if (!set_mode && gaussian) mode = InnerBall.first; - } - if (VP.is_in(StartingPoint) == 0) - throw Rcpp::exception("The given point is not in the interior of the polytope!"); - if (gaussian) { - StartingPoint = StartingPoint - mode; - VP.shift(mode.getCoefficients()); - } - sample_from_polytope(VP, type, rng, randPoints, walkL, numpoints, gaussian, a, L, c, - StartingPoint, nburns, set_L, eta, walk, F, f, h, solver); - break; - } - case 3: { - // Zonotope - zonotope ZP(dim, Rcpp::as(Rcpp::as(P).field("G")), - VT::Ones(Rcpp::as(Rcpp::as(P).field("G")).rows())); - - InnerBall = ZP.ComputeInnerBall(); - if (InnerBall.second < 0.0) throw Rcpp::exception("Unable to compute a feasible point."); - if (!set_starting_point || (!set_mode && gaussian)) { - if (!set_starting_point) StartingPoint = InnerBall.first; - if (!set_mode && gaussian) mode = InnerBall.first; - } - if (ZP.is_in(StartingPoint) == 0) - throw Rcpp::exception("The given point is not in the interior of the polytope!"); - if (gaussian) { - StartingPoint = StartingPoint - mode; - ZP.shift(mode.getCoefficients()); - } - sample_from_polytope(ZP, type, rng, randPoints, walkL, numpoints, gaussian, a, L, c, - StartingPoint, nburns, set_L, eta, walk, F, f, h, solver); - break; - } - case 4: { - // Intersection of two V-polytopes - Vpolytope VP1(dim, Rcpp::as(Rcpp::as(P).field("V1")), - VT::Ones(Rcpp::as(Rcpp::as(P).field("V1")).rows())); - Vpolytope VP2(dim, Rcpp::as(Rcpp::as(P).field("V2")), - VT::Ones(Rcpp::as(Rcpp::as(P).field("V2")).rows())); - InterVP VPcVP(VP1, VP2); - - if (!VPcVP.is_feasible()) throw Rcpp::exception("Empty set!"); - InnerBall = VPcVP.ComputeInnerBall(); - if (InnerBall.second < 0.0) throw Rcpp::exception("Unable to compute a feasible point."); - if (!set_starting_point) StartingPoint = InnerBall.first; - if (!set_mode && gaussian) mode = InnerBall.first; - if (VPcVP.is_in(StartingPoint) == 0) - throw Rcpp::exception("The given point is not in the interior of the polytope!"); - if (gaussian) { - StartingPoint = StartingPoint - mode; - VPcVP.shift(mode.getCoefficients()); - } - sample_from_polytope(VPcVP, type, rng, randPoints, walkL, numpoints, gaussian, a, L, c, - StartingPoint, nburns, set_L, eta, walk, F, f, h, solver); - break; - } - case 5: { - // Sparse constraint_problem - SpMat Aeq = Rcpp::as(Rcpp::as(P).field("Aeq")); - VT beq= Rcpp::as(Rcpp::as(P).field("beq")); - SpMat Aineq = Rcpp::as(Rcpp::as(P).field("Aineq")); - VT bineq= Rcpp::as(Rcpp::as(P).field("bineq")); - VT lb= Rcpp::as(Rcpp::as(P).field("lb")); - VT ub= Rcpp::as(Rcpp::as(P).field("ub")); - sparse_problem problem(dim, Aeq, beq, Aineq, bineq, lb, ub); - if(walk!=crhmc){throw Rcpp::exception("Sparse problems are supported only by the CRHMC walk.");} - if (functor_defined) { - execute_crhmc, RcppFunctor::GradientFunctor,RcppFunctor::FunctionFunctor, RcppFunctor::HessianFunctor, CRHMCWalk, 8>(problem, rng, randPoints, walkL, numpoints, nburns, F, f, h); - } - else { - execute_crhmc, GaussianFunctor::GradientFunctor,GaussianFunctor::FunctionFunctor, GaussianFunctor::HessianFunctor, CRHMCWalk, 8>(problem, rng, randPoints, walkL, numpoints, nburns, G, g, hess_g); - } - break; - } - } - - if (numpoints % 2 == 1 && (walk == brdhr || walk == bcdhr)) numpoints--; - MT RetMat(dim, numpoints); - unsigned int jj = 0; - - for (typename std::list::iterator rpit = randPoints.begin(); rpit!=randPoints.end(); rpit++, jj++) { - if (gaussian) { - RetMat.col(jj) = (*rpit).getCoefficients() + mode.getCoefficients(); - } else { - RetMat.col(jj) = (*rpit).getCoefficients(); - } - } - - return Rcpp::wrap(RetMat); -} diff --git a/R-proj/src/spectrahedron.cpp b/R-proj/src/spectrahedron.cpp deleted file mode 100644 index e7926597c..000000000 --- a/R-proj/src/spectrahedron.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2020 Vissarion Fisikopoulos -// Copyright (c) 2020 Apostolos Chalkis - -//Contributed and/or modified by Repouskos Panagiotis, as part of Google Summer of Code 2019 program. - -// Licensed under GNU LGPL.3, see LICENCE file - - -#include -#include -#include -#include "cartesian_geom/cartesian_kernel.h" -#include -#include -#include -#include -#include "convex_bodies/spectrahedra/LMI.h" -#include "convex_bodies/spectrahedra/spectrahedron.h" -#include "SDPAFormatManager.h" - -//' Write a SDPA format file -//' -//' Outputs a spectrahedron (the matrices defining a linear matrix inequality) and a vector (the objective function) -//' to a SDPA format file. -//' -//' @param spectrahedron A spectrahedron in n dimensions; must be an object of class Spectrahedron -//' @param objectiveFunction A numerical vector of length n -//' @param outputFile Name of the output file -//' -//' @examples -//' \dontrun{ -//' A0 = matrix(c(-1,0,0,0,-2,1,0,1,-2), nrow=3, ncol=3, byrow = TRUE) -//' A1 = matrix(c(-1,0,0,0,0,1,0,1,0), nrow=3, ncol=3, byrow = TRUE) -//' A2 = matrix(c(0,0,-1,0,0,0,-1,0,0), nrow=3, ncol=3, byrow = TRUE) -//' lmi = list(A0, A1, A2) -//' S = Spectrahedron$new(lmi); -//' objFunction = c(1,1) -//' writeSdpaFormatFile(S, objFunction, "output.txt") -//' } -//' @export -// [[Rcpp::export]] -void writeSdpaFormatFile(Rcpp::Nullable spectrahedron = R_NilValue, - Rcpp::Nullable objectiveFunction = R_NilValue, - Rcpp::Nullable outputFile = R_NilValue) { - - typedef double NT; - typedef Eigen::Matrix VT; - typedef Eigen::Matrix MT; - typedef Cartesian Kernel; - typedef typename Kernel::Point Point; - typedef boost::mt19937 RNGType; - typedef LMI LMI; - typedef Spectrahedron Spectrahedron; - - std::vector matrices = Rcpp::as > (Rcpp::as (spectrahedron).field("matrices")); - LMI lmi(matrices); - Spectrahedron _spectrahedron(lmi); - Point c(Rcpp::as (objectiveFunction)); - - std::filebuf fb; - fb.open(Rcpp::as (outputFile), std::ios::out); - std::ostream os(&fb); - - SdpaFormatManager sdpaFormatManager; - sdpaFormatManager.writeSDPAFormatFile(os, _spectrahedron, c); - - return; -} - - - -//' Read a SDPA format file -//' -//' @param inputFile Name of the input file -//' -//' @return A list with two named items: an item "matrices" which is a list of the matrices and an vector "objFunction" -//' -//' @examples -//' path = system.file('extdata', package = 'volesti') -//' l = loadSdpaFormatFile(paste0(path,'/sdpa_n2m3.txt')) -//' @export -// [[Rcpp::export]] -Rcpp::List loadSdpaFormatFile(Rcpp::Nullable inputFile = R_NilValue) { - - typedef double NT; - typedef Eigen::Matrix VT; - typedef Eigen::Matrix MT; - typedef Cartesian Kernel; - typedef typename Kernel::Point Point; - typedef boost::mt19937 RNGType; - typedef LMI LMI; - typedef Spectrahedron Spectrahedron; - - Spectrahedron _spectrahedron; - Point c; - - // open stream - std::ifstream os; - os.open(Rcpp::as (inputFile),std::ifstream::in); - - // read file - SdpaFormatManager sdpaFormatManager; - sdpaFormatManager.loadSDPAFormatFile(os, _spectrahedron, c); - - std::vector matrices = _spectrahedron.getLMI().getMatrices(); - - // return spectrahedron and objective function - Rcpp::List _matrices; - - for (auto matrix : matrices) - _matrices.push_back(Rcpp::wrap(matrix)); - - Rcpp::List retList = Rcpp::List::create(Rcpp::Named("matrices") = _matrices , Rcpp::_["objFunction"] = Rcpp::wrap(c.getCoefficients())); - return Rcpp::wrap(retList); -} diff --git a/R-proj/src/spectrahedron_module.cpp b/R-proj/src/spectrahedron_module.cpp deleted file mode 100644 index 8dedd2dc1..000000000 --- a/R-proj/src/spectrahedron_module.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2020 Vissarion Fisikopoulos -// Copyright (c) 2020 Apostolos Chalkis - -//Contributed and/or modified by Repouskos Panagiotis, as part of Google Summer of Code 2019 program. - -// Licensed under GNU LGPL.3, see LICENCE file - - -#include - -class Spectrahedron { -public: - /// A list with the matrices A0, ..., An - Rcpp::List matrices; - - Spectrahedron() {} - - Spectrahedron(Rcpp::List _matrices) : matrices(_matrices) {} -}; - -RCPP_MODULE(spectrahedron){ - using namespace Rcpp ; - - //' An exposed class to represent a spectrahedron - //' - //' @description A spectrahedron is a convex body defined by a linear matrix inequality of the form \eqn{A_0 + x_1 A_1 + ... + x_n A_n \preceq 0}. - //' The matrices \eqn{A_i} are symmetric \eqn{m \times m} real matrices and \eqn{\preceq 0} denoted negative semidefiniteness. - //' - //' @field matrices The matrices \eqn{A_0, A_1, ..., A_n} - //' - //' @example - //' A0 = matrix(c(-1,0,0,0,-2,1,0,1,-2), nrow=3, ncol=3, byrow = TRUE) - //' A1 = matrix(c(-1,0,0,0,0,1,0,1,0), nrow=3, ncol=3, byrow = TRUE) - //' A2 = matrix(c(0,0,-1,0,0,0,-1,0,0), nrow=3, ncol=3, byrow = TRUE) - //' lmi = list(M0, M1,M2) - //' S = Spectrahedron$new(lmi); - //' - //' @export - class_("Spectrahedron") - // expose the default constructor - .constructor() - .constructor() - .field( "matrices", &Spectrahedron::matrices); -} - -extern SEXP _rcpp_module_boot_spectrahedron(void); diff --git a/R-proj/src/volume.cpp b/R-proj/src/volume.cpp deleted file mode 100644 index 0a47210aa..000000000 --- a/R-proj/src/volume.cpp +++ /dev/null @@ -1,407 +0,0 @@ -// [[Rcpp::depends(BH)]] - -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2020 Vissarion Fisikopoulos -// Copyright (c) 2018-2020 Apostolos Chalkis - -//Contributed and/or modified by Apostolos Chalkis, as part of Google Summer of Code 2018 and 2019 program. - - -#include -#include -#include -#include -#include -#include -#include "random_walks/random_walks.hpp" -#include "volume/volume_cooling_gaussians.hpp" -#include "volume/volume_sequence_of_balls.hpp" -#include "volume/volume_cooling_gaussians.hpp" -#include "volume/volume_cooling_balls.hpp" -#include "volume/volume_cooling_hpoly.hpp" -#include "preprocess/max_inscribed_ellipsoid_rounding.hpp" -#include "preprocess/svd_rounding.hpp" - -enum random_walks {ball_walk, rdhr, cdhr, billiard, accelarated_billiard}; -enum volume_algorithms {CB, CG, SOB}; -enum rounding_type {none, min_ellipsoid, max_ellipsoid, isotropy}; - -template -std::pair generic_volume(Polytope& P, RNGType &rng, unsigned int walk_length, NT e, - volume_algorithms const& algo, unsigned int win_len, - rounding_type const& rounding, random_walks const& walk) -{ - typedef typename Polytope::MT MT; - typedef typename Polytope::VT VT; - typedef typename Polytope::PointType Point; - - typedef HPolytope Hpolytope; - - NT round_val = 1.0; - unsigned int n = P.dimension(); - std::pair InnerBall; - - if (rounding != none){ - InnerBall = P.ComputeInnerBall(); - if (InnerBall.second < 0.0) throw Rcpp::exception("Unable to compute a feasible point."); - } - - switch (rounding) - { - case min_ellipsoid: - switch (walk) - { - case cdhr: - round_val = std::get<2>(min_sampling_covering_ellipsoid_rounding(P, InnerBall, 10 + 10 * n, rng)); - break; - case accelarated_billiard: - round_val = std::get<2>(min_sampling_covering_ellipsoid_rounding(P, InnerBall, 2, rng)); - break; - default: - round_val = std::get<2>(min_sampling_covering_ellipsoid_rounding(P, InnerBall, 2, rng)); - break; - } - break; - case isotropy: - switch (walk) - { - case cdhr: - round_val = std::get<2>(svd_rounding(P, InnerBall, 10 + 10 * n, rng)); - break; - case accelarated_billiard: - round_val = std::get<2>(svd_rounding(P, InnerBall, 2, rng)); - break; - default: - round_val = std::get<2>(svd_rounding(P, InnerBall, 2, rng)); - break; - } - break; - case max_ellipsoid: - round_val = std::get<2>(max_inscribed_ellipsoid_rounding(P, InnerBall.first)); - break; - default: - break; - } - - NT vol; - std::pair pair_vol; - switch (algo) - { - case CG: - switch (walk) - { - case cdhr: - vol = volume_cooling_gaussians(P, rng, e, walk_length); - pair_vol = std::pair (std::log(vol), vol); - break; - case rdhr: - vol = volume_cooling_gaussians(P, rng, e, walk_length); - pair_vol = std::pair (std::log(vol), vol); - break; - case ball_walk: - vol = volume_cooling_gaussians(P, rng, e, walk_length); - pair_vol = std::pair (std::log(vol), vol); - break; - default: - throw Rcpp::exception("This random walk can not be used by CG algorithm!"); - break; - } - break; - case CB: - switch (walk) - { - case cdhr: - pair_vol = volume_cooling_balls(P, rng, e, walk_length, win_len); - break; - case rdhr: - pair_vol = volume_cooling_balls(P, rng, e, walk_length, win_len); - break; - case ball_walk: - pair_vol = volume_cooling_balls(P, rng, e, walk_length, win_len); - break; - case billiard: - pair_vol = volume_cooling_balls(P, rng, e, walk_length, win_len); - break; - case accelarated_billiard: - pair_vol = volume_cooling_balls(P, rng, e, walk_length, win_len); - break; - default: - throw Rcpp::exception("This random walk can not be used by CB algorithm!"); - break; - } - break; - case SOB: - switch (walk) - { - case cdhr: - vol = volume_sequence_of_balls(P, rng, e, walk_length); - pair_vol = std::pair (std::log(vol), vol); - break; - case rdhr: - vol = volume_sequence_of_balls(P, rng, e, walk_length); - pair_vol = std::pair (std::log(vol), vol); - break; - case ball_walk: - vol = volume_sequence_of_balls(P, rng, e, walk_length); - pair_vol = std::pair (std::log(vol), vol); - break; - case billiard: - vol = volume_sequence_of_balls(P, rng, e, walk_length); - break; - case accelarated_billiard: - vol = volume_sequence_of_balls(P, rng, e, walk_length); - pair_vol = std::pair (std::log(vol), vol); - break; - default: - throw Rcpp::exception("This random walk can not be used by CB algorithm!"); - break; - } - break; - default: - throw Rcpp::exception("Unknown algorithm!"); - break; - } - if (pair_vol.second < 0.0) throw Rcpp::exception("volesti failed to terminate."); - pair_vol.first += std::log(round_val); - pair_vol.second *= round_val; - return pair_vol; -} - -//' The main function for volume approximation of a convex Polytope (H-polytope, V-polytope, zonotope or intersection of two V-polytopes). It returns a list with two elements: (a) the logarithm of the estimated volume and (b) the estimated volume -//' -//' For the volume approximation can be used three algorithms. Either CoolingBodies (CB) or SequenceOfBalls (SOB) or CoolingGaussian (CG). An H-polytope with \eqn{m} facets is described by a \eqn{m\times d} matrix \eqn{A} and a \eqn{m}-dimensional vector \eqn{b}, s.t.: \eqn{P=\{x\ |\ Ax\leq b\} }. A V-polytope is defined as the convex hull of \eqn{m} \eqn{d}-dimensional points which correspond to the vertices of P. A zonotope is desrcibed by the Minkowski sum of \eqn{m} \eqn{d}-dimensional segments. -//' -//' @param P A convex polytope. It is an object from class a) Hpolytope or b) Vpolytope or c) Zonotope or d) VpolytopeIntersection. -//' @param settings Optional. A list that declares which algorithm, random walk and values of parameters to use, as follows: -//' \itemize{ -//' \item{\code{algorithm} }{ A string to set the algorithm to use: a) \code{'CB'} for CB algorithm, b) \code{'SoB'} for SOB algorithm or b) \code{'CG'} for CG algorithm. The defalut algorithm is \code{'CB'}.} -//' \item{\code{error} }{ A numeric value to set the upper bound for the approximation error. The default value is \eqn{1} for SOB algorithm and \eqn{0.1} otherwise.} -//' \item{\code{random_walk} }{ A string that declares the random walk method: a) \code{'CDHR'} for Coordinate Directions Hit-and-Run, b) \code{'RDHR'} for Random Directions Hit-and-Run, c) \code{'BaW'} for Ball Walk, or \code{'BiW'} for Billiard walk. For CB algorithm the default walk is \code{'BiW'}. For CG and SOB algorithms the default walk is \code{'CDHR'} for H-polytopes and \code{'RDHR'} for the other representations.} -//' \item{\code{walk_length} }{ An integer to set the number of the steps for the random walk. The default value is \eqn{\lfloor 10 + d/10\rfloor} for \code{'SOB'} and \eqn{1} otherwise.} -//' \item{\code{win_len} }{ The length of the sliding window for CB or CG algorithm. The default value is \eqn{250} for CB with BiW and \eqn{400+3d^2} for CB and any other random walk and \eqn{500+4d^2} for CG.} -//' \item{\code{hpoly} }{ A boolean parameter to use H-polytopes in MMC of CB algorithm when the input polytope is a zonotope. The default value is \code{TRUE} when the order of the zonotope is \eqn{<5}, otherwise it is \code{FALSE}.} -//' } -//' @param rounding Optional. A string parameter to request a rounding method to be applied in the input polytope before volume computation: a) \code{'min_ellipsoid'}, b) \code{'svd'}, c) \code{'max_ellipsoid'} and d) \code{'none'} for no rounding. -//' @param seed Optional. A fixed seed for the number generator. -//' -//' @references \cite{I.Z.Emiris and V. Fisikopoulos, -//' \dQuote{Practical polytope volume approximation,} \emph{ACM Trans. Math. Soft.,} 2018.}, -//' @references \cite{A. Chalkis and I.Z.Emiris and V. Fisikopoulos, -//' \dQuote{Practical Volume Estimation by a New Annealing Schedule for Cooling Convex Bodies,} \emph{CoRR, abs/1905.05494,} 2019.}, -//' @references \cite{B. Cousins and S. Vempala, \dQuote{A practical volume algorithm,} \emph{Springer-Verlag Berlin Heidelberg and The Mathematical Programming Society,} 2015.} -//' -//' -//' @return The approximation of the volume of a convex polytope. -//' @examples -//' -//' # calling SOB algorithm for a H-polytope (5d unit simplex) -//' HP = gen_cube(5,'H') -//' pair_vol = volume(HP) -//' -//' # calling CG algorithm for a V-polytope (3d simplex) -//' VP = gen_simplex(3,'V') -//' pair_vol = volume(VP, settings = list("algorithm" = "CG")) -//' -//' # calling CG algorithm for a 2-dimensional zonotope defined as the Minkowski sum of 4 segments -//' Z = gen_rand_zonotope(2, 4) -//' pair_vol = volume(Z, settings = list("random_walk" = "RDHR", "walk_length" = 2)) -//' -//' @export -// [[Rcpp::export]] -Rcpp::List volume (Rcpp::Reference P, - Rcpp::Nullable settings = R_NilValue, - Rcpp::Nullable rounding = R_NilValue, - Rcpp::Nullable seed = R_NilValue) { - - typedef double NT; - typedef Cartesian Kernel; - typedef typename Kernel::Point Point; - typedef BoostRandomNumberGenerator RNGType; - typedef HPolytope Hpolytope; - typedef VPolytope Vpolytope; - typedef Zonotope zonotope; - typedef IntersectionOfVpoly InterVP; - typedef Eigen::Matrix VT; - typedef Eigen::Matrix MT; - unsigned int n = P.field("dimension"), walkL, type = P.field("type"); - - RNGType rng(n); - if (seed.isNotNull()) { - unsigned seed_rcpp = Rcpp::as(seed); - rng.set_seed(seed_rcpp); - } - - bool round = false, hpoly = false; - unsigned int win_len = 300; - - random_walks walk; - volume_algorithms algo; - rounding_type rounding_method; - - if (!rounding.isNotNull()) { - rounding_method = (type == 2) ? min_ellipsoid : none; - } else if (Rcpp::as(rounding).compare(std::string("min_ellipsoid")) == 0) { - rounding_method = min_ellipsoid; - } else if (Rcpp::as(rounding).compare(std::string("max_ellipsoid")) == 0) { - if (type != 1) throw Rcpp::exception("This rounding method can be used only for H-polytopes!"); - rounding_method = max_ellipsoid; - } else if (Rcpp::as(rounding).compare(std::string("isotropy")) == 0) { - rounding_method = isotropy; - } else if (Rcpp::as(rounding).compare(std::string("none")) == 0) { - rounding_method = none; - } - - NT e; - - if (!Rcpp::as(settings).containsElementNamed("algorithm")) { - algo = CB; - walkL = (!Rcpp::as(settings).containsElementNamed("walk_length")) ? 1 : Rcpp::as( - Rcpp::as(settings)["walk_length"]); - e = (!Rcpp::as(settings).containsElementNamed("error")) ? 0.1 : Rcpp::as( - Rcpp::as(settings)["error"]); - } else if (Rcpp::as(Rcpp::as(settings)["algorithm"]).compare(std::string("SOB")) == 0) { - algo = SOB; - walkL = (!Rcpp::as(settings).containsElementNamed("walk_length")) ? 10 + n / 10 : Rcpp::as( - Rcpp::as(settings)["walk_length"]); - e = (!Rcpp::as(settings).containsElementNamed("error")) ? 1.0 : Rcpp::as( - Rcpp::as(settings)["error"]); - } else if (Rcpp::as(Rcpp::as(settings)["algorithm"]).compare(std::string("CG")) == 0) { - algo = CG; - walkL = (!Rcpp::as(settings).containsElementNamed("walk_length")) ? 1 : Rcpp::as( - Rcpp::as(settings)["walk_length"]); - e = (!Rcpp::as(settings).containsElementNamed("error")) ? 0.1 : Rcpp::as( - Rcpp::as(settings)["error"]); - } else if (Rcpp::as(Rcpp::as(settings)["algorithm"]).compare(std::string("CB")) == 0) { - algo = CB; - walkL = (!Rcpp::as(settings).containsElementNamed("walk_length")) ? 1 : Rcpp::as( - Rcpp::as(settings)["walk_length"]); - e = (!Rcpp::as(settings).containsElementNamed("error")) ? 0.1 : Rcpp::as( - Rcpp::as(settings)["error"]); - } else { - throw Rcpp::exception("Unknown method!"); - } - - if (!Rcpp::as(settings).containsElementNamed("random_walk")) { - if (algo == CB) { - walk = (type == 1) ? accelarated_billiard : billiard; - } else { - win_len = 4 * n * n + 500; - if (type == 1) { - walk = cdhr; - } else { - walk = rdhr; - } - } - }else if (Rcpp::as(Rcpp::as(settings)["random_walk"]).compare(std::string("CDHR")) == 0) { - walk = cdhr; - if (algo == CB) win_len = 3*n*n+400; - } else if (Rcpp::as(Rcpp::as(settings)["random_walk"]).compare(std::string("RDHR")) == 0) { - walk = rdhr; - if (algo == CB) win_len = 3*n*n+400; - } else if (Rcpp::as(Rcpp::as(settings)["random_walk"]).compare(std::string("BaW")) == 0) { - walk = ball_walk; - if (algo == CB) win_len = 3*n*n+400; - } else if (Rcpp::as(Rcpp::as(settings)["random_walk"]).compare(std::string("BiW")) == 0) { - if (algo == CG) { - if (type !=1){ - Rcpp::Rcout << "Billiard walk is not supported for CG algorithm. RDHR is used."<(settings).containsElementNamed("win_len")) { - win_len = Rcpp::as(Rcpp::as(settings)["win_len"]); - if (algo == SOB) Rf_warning("input 'win_len' can be used only for CG or CB algorithms."); - } - - std::pair pair_vol; - NT vol; - - switch(type) { - case 1: { - // Hpolytope - Hpolytope HP(n, Rcpp::as(P.field("A")), Rcpp::as(P.field("b"))); - pair_vol = generic_volume(HP, rng, walkL, e, algo, win_len, rounding_method, walk); - break; - } - case 2: { - // Vpolytope - Vpolytope VP(n, Rcpp::as(P.field("V")), VT::Ones(Rcpp::as(P.field("V")).rows())); - pair_vol = generic_volume(VP, rng, walkL, e, algo, win_len, rounding_method, walk); - break; - } - case 3: { - // Zonotope - zonotope ZP(n, Rcpp::as(P.field("G")), VT::Ones(Rcpp::as(P.field("G")).rows())); - if (Rcpp::as(settings).containsElementNamed("hpoly")) { - hpoly = Rcpp::as(Rcpp::as(settings)["hpoly"]); - if (hpoly && (algo == CG || algo == SOB)) - Rf_warning("flag 'hpoly' can be used to only in MMC of CB algorithm for zonotopes."); - } else if (ZP.num_of_generators() / ZP.dimension() < 5) { - hpoly = true; - } else { - hpoly = false; - } - if (hpoly && algo == CB) { - switch (walk) - { - case cdhr: - vol = volume_cooling_hpoly(ZP, rng, e, walkL, win_len); - pair_vol = std::pair (std::log(vol), vol); - break; - case rdhr: - vol = volume_cooling_hpoly(ZP, rng, e, walkL, win_len); - pair_vol = std::pair (std::log(vol), vol); - break; - case ball_walk: - vol = volume_cooling_hpoly(ZP, rng, e, walkL, win_len); - pair_vol = std::pair (std::log(vol), vol); - break; - case billiard: - vol = volume_cooling_hpoly(ZP, rng, e, walkL, win_len); - pair_vol = std::pair (std::log(vol), vol); - break; - case accelarated_billiard: - vol = volume_cooling_hpoly(ZP, rng, e, walkL, win_len); - pair_vol = std::pair (std::log(vol), vol); - break; - default: - throw Rcpp::exception("This random walk can not be used by CB algorithm!"); - break; - } - } - pair_vol = generic_volume(ZP, rng, walkL, e, algo, win_len, rounding_method, walk); - break; - } - case 4: { - // Intersection of two V-polytopes - Vpolytope VP1(n, Rcpp::as(P.field("V1")), VT::Ones(Rcpp::as(P.field("V1")).rows())); - Vpolytope VP2(n, Rcpp::as(P.field("V2")), VT::Ones(Rcpp::as(P.field("V2")).rows())); - InterVP VPcVP; - if (!seed.isNotNull()) { - InterVP VPcVP(VP1, VP2); - } else { - unsigned seed3 = Rcpp::as(seed); - InterVP VPcVP(VP1, VP2, seed3); - } - if (!VPcVP.is_feasible()) throw Rcpp::exception("Empty set!"); - pair_vol = generic_volume(VPcVP, rng, walkL, e, algo, win_len, rounding_method, walk); - break; - } - } - - return Rcpp::List::create(Rcpp::Named("log_volume") = pair_vol.first, Rcpp::Named("volume") = pair_vol.second); -} diff --git a/R-proj/src/zonotope_approximation.cpp b/R-proj/src/zonotope_approximation.cpp deleted file mode 100644 index 237ec96e1..000000000 --- a/R-proj/src/zonotope_approximation.cpp +++ /dev/null @@ -1,102 +0,0 @@ -// [[Rcpp::depends(BH)]] - -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2018 Vissarion Fisikopoulos -// Copyright (c) 2018 Apostolos Chalkis - - -#include -#include -#include -#include -#include -#include -#include "random_walks/random_walks.hpp" -#include "volume/volume_sequence_of_balls.hpp" -#include "volume/volume_cooling_gaussians.hpp" -#include "volume/volume_cooling_balls.hpp" -#include "volume/volume_cooling_hpoly.hpp" - -//' An internal Rccp function for the over-approximation of a zonotope -//' -//' @param Z A zonotope. -//' @param fit_ratio Optional. A boolean parameter to request the computation of the ratio of fitness. -//' @param settings Optional. A list that declares the values of the parameters of CB algorithm. -//' @param seed Optional. A fixed seed for the number generator. -//' -//' @keywords internal -//' -//' @return A List that contains a numerical matrix that describes the PCA approximation as a H-polytope and the ratio of fitness. -// [[Rcpp::export]] -Rcpp::List zono_approx (Rcpp::Reference Z, - Rcpp::Nullable fit_ratio = R_NilValue, - Rcpp::Nullable settings = R_NilValue, - Rcpp::Nullable seed = R_NilValue) { - - typedef double NT; - typedef Cartesian Kernel; - typedef BoostRandomNumberGenerator RNGType; - typedef typename Kernel::Point Point; - typedef HPolytope Hpolytope; - typedef Zonotope zonotope; - typedef Eigen::Matrix VT; - typedef Eigen::Matrix MT; - int n = Rcpp::as(Z.field("dimension")), k = Rcpp::as(Z.field("G")).rows(), win_len = 200, walkL = 1; - - RNGType rng(n); - if (seed.isNotNull()) { - unsigned seed_rcpp = Rcpp::as(seed); - rng.set_seed(seed_rcpp); - } - - NT e = 0.1, ratio = std::numeric_limits::signaling_NaN(); - bool hpoly = false; - - MT X(n, 2 * k); - X << Rcpp::as(Z.field("G")).transpose(), -Rcpp::as(Z.field("G")).transpose(); - Eigen::JacobiSVD svd(X * X.transpose(), Eigen::ComputeFullU | Eigen::ComputeFullV); - MT G(k, 2 * n); - G << Rcpp::as(Z.field("G")) * svd.matrixU(), Rcpp::as(Z.field("G")) * svd.matrixU(); - VT Gred_ii = G.transpose().cwiseAbs().rowwise().sum(); - MT A(n, 2 * n); - A << -MT::Identity(n, n), MT::Identity(n, n); - MT Mat(2 * n, n + 1); - Mat << Gred_ii, A.transpose() * svd.matrixU().transpose(); - - //Hpolytope HP(n, A.transpose() * svd.matrixU().transpose(), Gred_ii); - - if (fit_ratio.isNotNull() && Rcpp::as(fit_ratio)) { - NT vol_red = std::abs(svd.matrixU().determinant()); - for (int i = 0; i < n; ++i) { - vol_red *= 2.0 * Gred_ii(i); - } - - walkL = (!Rcpp::as(settings).containsElementNamed("walk_length")) ? 1 : Rcpp::as( - Rcpp::as(settings)["walk_length"]); - e = (!Rcpp::as(settings).containsElementNamed("error")) ? 0.1 : Rcpp::as( - Rcpp::as(settings)["error"]); - win_len = (!Rcpp::as(settings).containsElementNamed("win_len")) ? 200 : Rcpp::as( - Rcpp::as(settings)["win_len"]); - - zonotope ZP(n, Rcpp::as(Z.field("G")), VT::Ones(Rcpp::as(Z.field("G")).rows())); - - if (Rcpp::as(settings).containsElementNamed("hpoly")) { - hpoly = Rcpp::as(Rcpp::as(settings)["hpoly"]); - } else if (ZP.num_of_generators() / ZP.dimension() < 5 ) { - hpoly = true; - } else { - hpoly = false; - } - - NT vol; - if (!hpoly) { - vol = volume_cooling_balls(ZP, rng, e, walkL, win_len).second; - } else { - vol = volume_cooling_hpoly(ZP, rng, e, walkL, win_len); - } - ratio = std::pow(vol_red / vol, 1.0 / NT(n)); - } - - return Rcpp::List::create(Rcpp::Named("Mat") = Rcpp::wrap(Mat), Rcpp::Named("fit_ratio") = ratio); -} diff --git a/R-proj/tests/testthat.R b/R-proj/tests/testthat.R deleted file mode 100644 index 051a041f8..000000000 --- a/R-proj/tests/testthat.R +++ /dev/null @@ -1,3 +0,0 @@ -library(testthat) - -test_check("volesti") diff --git a/R-proj/tests/testthat/test_Hvol.R b/R-proj/tests/testthat/test_Hvol.R deleted file mode 100644 index 061a33acf..000000000 --- a/R-proj/tests/testthat/test_Hvol.R +++ /dev/null @@ -1,66 +0,0 @@ -context("H-polytopes' volume test") - -library(volesti) - - -Hruntest <- function(P, name_string, exactvol, tol, num_of_exps, alg, seed){ - - vol = 0 - for (j in 1:num_of_exps) { - if (alg == "CB") { - vol = vol + volume(P, seed = seed)$volume - } else if (alg == "SOB") { - vol = vol + volume(P, settings = list("algorithm" = "SOB"), seed = seed)$volume - } else { - vol = vol + volume(P, settings = list("algorithm" = "CG"), seed = seed)$volume - } - } - vol = vol / num_of_exps - error = abs(vol - exactvol) / exactvol - if (error >= tol){ - res = 0 - } else { - res = 1 - } - return(res) -} - -cran_only = TRUE - -for (i in 1:2) { - - if (i==1) { - algo = 'CG' - num_of_exps = 10 - } else { - algo = 'CB' - num_of_exps = 10 - } - - - test_that("Volume H-cube10", { - P = gen_cube(10, 'H') - res = Hruntest(P, 'H-cube10', 1024, 0.2, num_of_exps, algo, 5) - expect_equal(res, 1) - }) - - test_that("Volume H-cross5", { - P = gen_cross(5, 'H') - res = Hruntest(P, 'H-cross10', 0.2666667, 0.2, num_of_exps, algo, 5) - expect_equal(res, 1) - }) - - - test_that("Volume H-prod_simplex_5_5", { - P = gen_prod_simplex(5) - res = Hruntest(P, 'H-prod_simplex_5_5', (1/prod(1:5))^2, 0.2, num_of_exps, algo, 5) - expect_equal(res, 1) - }) - - test_that("Volume H-cube10", { - P = gen_cube(10, 'H') - res = Hruntest(P, 'H-cube10', 1024, 0.2, 5, "SOB", 5) - expect_equal(res, 1) - }) - -} diff --git a/R-proj/tests/testthat/test_InnerBall.R b/R-proj/tests/testthat/test_InnerBall.R deleted file mode 100644 index cb19e1c00..000000000 --- a/R-proj/tests/testthat/test_InnerBall.R +++ /dev/null @@ -1,135 +0,0 @@ -context("Chebychev ball test") - -library(volesti) - -runCheTest <- function(P, name_string, radius, tol) { - - vec_ball = inner_ball(P, lpsolve = TRUE) - rad = vec_ball[length(vec_ball)] - - error = abs(radius - rad) / radius - if (error >= tol){ - res = 0 - } else { - res = 1 - } - return(res) -} - -tol = 0.00001 - -test_that("Chebychev test", { - P = gen_cube(10, 'H') - res = runCheTest(P, 'H-cube10', 1.0, tol) - expect_equal(res, 1) -}) - -test_that("Chebychev test", { - P = gen_cube(20, 'H') - res = runCheTest(P, 'H-cube20', 1.0, tol) - expect_equal(res, 1) -}) - -test_that("Chebychev test", { - P = gen_cube(30, 'H') - res = runCheTest(P, 'H-cube30', 1.0, tol) - expect_equal(res, 1) -}) - -test_that("Chebychev test", { - P = gen_cross(10, 'H') - res = runCheTest(P, 'H-cross10', 0.316228, tol) - expect_equal(res, 1) -}) - -test_that("Chebychev test", { - P = gen_birkhoff(3) - res = runCheTest(P, 'H-birk3', 0.207107, tol) - expect_equal(res, 1) -}) - - -test_that("Chebychev test", { - P = gen_birkhoff(4) - res = runCheTest(P, 'H-birk4', 0.122008, tol) - expect_equal(res, 1) -}) - - -test_that("Chebychev test", { - P = gen_birkhoff(5) - res = runCheTest(P, 'H-birk5', 0.0833333, tol) - expect_equal(res, 1) -}) - -test_that("Chebychev test", { - P = gen_birkhoff(6) - res = runCheTest(P, 'H-birk6', 0.0618034, tol) - expect_equal(res, 1) -}) - -test_that("Chebychev test", { - P = gen_prod_simplex(5) - res = runCheTest(P, 'H-prod_simplex_5_5', 0.138197, tol) - expect_equal(res, 1) -}) - -test_that("Chebychev test", { - P = gen_prod_simplex(10) - res = runCheTest(P, 'H-prod_simplex_10_10', 0.0759747, tol) - expect_equal(res, 1) -}) - -test_that("Chebychev test", { - P = gen_prod_simplex(15) - res = runCheTest(P, 'H-prod_simplex_15_15', 0.0529858, tol) - expect_equal(res, 1) -}) - -test_that("Chebychev test", { - P = gen_prod_simplex(20) - res = runCheTest(P, 'H-prod_simplex_20_20', 0.0408628, tol) - expect_equal(res, 1) -}) - -test_that("Chebychev test", { - P = gen_simplex(10, 'H') - res = runCheTest(P, 'H-simplex10', 0.0759747, tol) - expect_equal(res, 1) -}) - -test_that("Chebychev test", { - P = gen_simplex(20, 'H') - res = runCheTest(P, 'H-simplex20', 0.0408628, tol) - expect_equal(res, 1) -}) - -test_that("Chebychev test", { - P = gen_simplex(30, 'H') - res = runCheTest(P, 'H-simplex30', 0.0281871, tol) - expect_equal(res, 1) -}) - -test_that("Chebychev test", { - P = gen_simplex(40, 'H') - res = runCheTest(P, 'H-simplex40', 0.0215868, tol) - expect_equal(res, 1) -}) - -test_that("Chebychev test", { - P = gen_simplex(50, 'H') - res = runCheTest(P, 'H-simplex50', 0.017522, tol) - expect_equal(res, 1) -}) - -test_that("Chebychev test", { - P = gen_skinny_cube(10) - res = runCheTest(P, 'H-skinny_cube10', 1.0, tol) - expect_equal(res, 1) -}) - -test_that("Chebychev test", { - P = gen_skinny_cube(20) - res = runCheTest(P, 'H-skinny_cube20', 1.0, tol) - expect_equal(res, 1) -}) diff --git a/R-proj/tests/testthat/test_Vvol.R b/R-proj/tests/testthat/test_Vvol.R deleted file mode 100644 index 9e18e52b2..000000000 --- a/R-proj/tests/testthat/test_Vvol.R +++ /dev/null @@ -1,44 +0,0 @@ -context("V-polytopes' volume test") - -library(volesti) - -Vruntest <- function(P, name_string, exactvol, tol, num_of_exps, algorithm,seed){ - - vol = 0 - for (j in 1:num_of_exps) { - if (algorithm == "CB") { - vol = vol + volume(P, rounding = "none", seed = seed)$volume - } else { - vol = vol + volume(P, settings = list("algorithm" = "CG", "error" = 0.1), rounding = "none", seed = seed)$volume - } - } - vol = vol / num_of_exps - error = abs(vol - exactvol) / exactvol - if (error >= tol){ - res = 0 - } else { - res = 1 - } - return(res) -} - -cran_only = TRUE -num_of_exps = 2 - -for (i in 1:2) { - seed = 5 - if (i==1) { - algo = 'CG' - tol = 0.2 - } else { - algo = 'CB' - tol = 0.2 - } - - test_that("Volume V-simplex3", { - P = gen_simplex(3, 'V') - res = Vruntest(P, 'V-simplex3', 1/prod(1:3), tol, num_of_exps, algo, seed) - expect_equal(res, 1) - }) - -} diff --git a/R-proj/tests/testthat/test_Zvol.R b/R-proj/tests/testthat/test_Zvol.R deleted file mode 100644 index f382b003c..000000000 --- a/R-proj/tests/testthat/test_Zvol.R +++ /dev/null @@ -1,45 +0,0 @@ -context("Zonotopes' volume test") - -library(volesti) - -Zruntest <- function(P, name_string, tol, num_of_exps, algo, seed){ - - exactvol = exact_vol(P) - vol = 0 - for (j in 1:num_of_exps) { - if (algo == "CB") { - vol = vol + volume(P, settings = list("hpoly" = FALSE), rounding = "none", seed = seed)$volume - } else { - vol = vol + volume(P, settings = list("algorithm" = "CG", "error" = 0.1), rounding = "none", seed = seed)$volume - } - } - vol = vol / num_of_exps - error = abs(vol - exactvol) / exactvol - if (error >= tol){ - res = 0 - } else { - res = 1 - } - return(res) -} - -cran_only = TRUE -num_of_exps = 2 - -for (i in 1:2) { - if (i==1) { - algo = 'CG' - tol = 0.2 - } else { - algo = 'CB' - tol = 0.2 - } - - test_that("Volume Zonotope_2_4", { - #skip_if(Sys.info()[["machine"]] %in% c("x86_32")) - Z = gen_rand_zonotope(2, 4, seed = 127) - res = Zruntest(Z, 'Zonotope_2_4', tol, num_of_exps, algo, 5) - expect_equal(res, 1) - }) - -} diff --git a/R-proj/tests/testthat/test_copulas.R b/R-proj/tests/testthat/test_copulas.R deleted file mode 100644 index e0ee51375..000000000 --- a/R-proj/tests/testthat/test_copulas.R +++ /dev/null @@ -1,23 +0,0 @@ -context("Copulas' test") - -library(volesti) - -test_that("10-dimensional 2-hyp_fam copula", { - h1 = h1 = runif(n = 10, min = 1, max = 1000) - h1 = h1 / 1000 - h2 = h2 = runif(n = 10, min = 1, max = 1000) - h2 = h1 / 1000 - cop = copula(r1 = h1 , r2 = h2 , m = 10, n = 100000) - res = sum(cop) - expect_equal(res, 1) -}) - -test_that("20-dimensional 1_hyp_1_ell fam copula", { - h = h = runif(n = 20, min = 1, max = 1000) - h = h / 1000 - E = replicate(20, rnorm(30)) - E = cov(E) - cop = copula(r1 = h , sigma = E , m = 100, n = 100000) - res = sum(cop) - expect_equal(res, 1) -}) \ No newline at end of file diff --git a/R-proj/tests/testthat/test_rounding.R b/R-proj/tests/testthat/test_rounding.R deleted file mode 100644 index 5d308e367..000000000 --- a/R-proj/tests/testthat/test_rounding.R +++ /dev/null @@ -1,49 +0,0 @@ -context("Rounding test") - -library(volesti) - -testRound <- function(P, exactvol, tol, name_string, num_of_exps, algo, rotation,seed){ - - if (rotation) { - P = rand_rotate(P) - listHpoly = round_polytope(P, seed = seed) - } else { - listHpoly = round_polytope(P, seed = seed) - } - vol = 0 - for (j in 1:num_of_exps) { - if (algo == "CB") { - vol = vol + listHpoly$round_value * volume(listHpoly$P, seed = seed)$volume - } else { - vol = vol + listHpoly$round_value * volume(listHpoly$P, settings=list("algorithm"="CG", "error"=0.1), seed = seed)$volume - } - } - vol = vol / num_of_exps - error = abs(vol - exactvol) / exactvol - if (error >= tol){ - res = 0 - } else { - res = 1 - } - return(res) - - -} - -cran_only = TRUE - -for (i in 1:2) { - - num_of_exps = 10 - - - - test_that("Rounding H-skinny_cube10", { - seed=5 - P = gen_skinny_cube(10) - res = testRound(P, 102400, 0.3, 'H-skinny_cube10', num_of_exps, 'CB', FALSE,seed) - expect_equal(res, 1) - }) - - -} diff --git a/R-proj/tests/testthat/test_sampling.R b/R-proj/tests/testthat/test_sampling.R deleted file mode 100644 index d051dc70e..000000000 --- a/R-proj/tests/testthat/test_sampling.R +++ /dev/null @@ -1,91 +0,0 @@ -context("Sampling test") - -library(volesti) - -runsample <- function(P, name_string, dist){ - if (dist == "uniform") { - p = sample_points(P, n = 100) - } else { - p = sample_points(P, n = 100, distribution = list("density" = "gaussian")) - } - if (length(p[is.nan(p)])>0 | length(p[is.infinite(p)])>0) { - res = 0 - } else { - res = 1 - } - return(res) - -} - -logconcave_sample<- function(P,distribution, n_samples ,n_burns){ - if (distribution == "uniform"){ - f <- function(x) (0) - grad_f <- function(x) (0) - L=1 - m=1 - pts <- sample_points(P, n = n_samples, random_walk = list("walk" = "CRHMC", "nburns" = n_burns, "walk_length" = 1, "solver" = "implicit_midpoint"), distribution = list("density" = "logconcave", "negative_logprob" = f, "negative_logprob_gradient" = grad_f, "L_" = L, "m" = m)) - return(max(psrf_univariate(pts, "interval"))) - } - else if(distribution == "gaussian"){ - pts <- sample_points(P, n = n_samples, random_walk = list("walk" = "CRHMC", "nburns" = n_burns, "walk_length" = 1, "solver" = "implicit_midpoint"), distribution = list("density" = "logconcave", "variance"=8)) - return(max(psrf_univariate(pts, "interval"))) - } -} - -for (i in 1:2) { - - if (i==1) { - distribution = 'gaussian' - } else { - distribution = 'uniform' - } - - test_that("Sampling test", { - P= gen_cube(10, 'H') - res = runsample(P, 'H-cube10', distribution) - expect_equal(res, 1) - }) - - test_that("Sampling test", { - P = gen_cross(10, 'H') - res = runsample(P, 'H-cross10', distribution) - expect_equal(res, 1) - }) - - test_that("Sampling test", { - P = gen_prod_simplex(5) - res = runsample(P, 'H-prod_simplex_5_5', distribution) - expect_equal(res, 1) - }) - - test_that("Sampling test", { - P = gen_prod_simplex(10) - res = runsample(P, 'H-prod_simplex_10_10', distribution) - expect_equal(res, 1) - }) - - test_that("Sampling test", { - P = gen_simplex(10, 'H') - res = runsample(P, 'H-prod_simplex10', distribution) - expect_equal(res, 1) - }) - - test_that("Sampling test", { - P = gen_skinny_cube(10) - res = runsample(P, 'H-skinny_cube10', distribution) - expect_equal(res, 1) - }) - - test_that("Sampling test", { - P = gen_skinny_cube(20) - res = runsample(P, 'H-skinny_cube20', distribution) - expect_equal(res, 1) - }) - - test_that("Sampling test", { - Z = gen_rand_zonotope(4, 8) - res = runsample(Z, 'zonotope_4_8', distribution) - expect_equal(res, 1) - }) - -} diff --git a/R-proj/vignettes/Arxiv.Rnw b/R-proj/vignettes/Arxiv.Rnw deleted file mode 100644 index f6c506299..000000000 --- a/R-proj/vignettes/Arxiv.Rnw +++ /dev/null @@ -1,7 +0,0 @@ -\documentclass{article} -\usepackage{pdfpages} -%\VignetteIndexEntry{Arxiv paper} - -\begin{document} -\includepdf[pages=-, fitpaper=true]{volesti_arxiv.pdf} -\end{document} diff --git a/R-proj/vignettes/volesti_arxiv.pdf b/R-proj/vignettes/volesti_arxiv.pdf deleted file mode 100644 index 1b9438218..000000000 Binary files a/R-proj/vignettes/volesti_arxiv.pdf and /dev/null differ diff --git a/R-proj/volesti.Rproj b/R-proj/volesti.Rproj deleted file mode 100644 index 21a4da087..000000000 --- a/R-proj/volesti.Rproj +++ /dev/null @@ -1,17 +0,0 @@ -Version: 1.0 - -RestoreWorkspace: Default -SaveWorkspace: Default -AlwaysSaveHistory: Default - -EnableCodeIndexing: Yes -UseSpacesForTab: Yes -NumSpacesForTab: 2 -Encoding: UTF-8 - -RnwWeave: Sweave -LaTeX: pdfLaTeX - -BuildType: Package -PackageUseDevtools: Yes -PackageInstallArgs: --no-multiarch --with-keep.source diff --git a/cran_gen/.Rbuildignore b/cran_gen/.Rbuildignore deleted file mode 100644 index fd2ed1b3d..000000000 --- a/cran_gen/.Rbuildignore +++ /dev/null @@ -1,4 +0,0 @@ -^.*\.Rproj$ -^\.Rproj\.user$ -^volesti\.Rproj$ -^inst/checks$ diff --git a/cran_gen/Makefile b/cran_gen/Makefile deleted file mode 100644 index 3f53931a7..000000000 --- a/cran_gen/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -LP_SOLVE_CPPFLAGS=$(CPPFLAGS) -I../../headers/include \ - -I$(R_INCLUDE_DIR) \ - -DYY_NEVER_INTERACTIVE \ - -DPARSER_LP -DINVERSE_ACTIVE=INVERSE_LUSOL \ - -DRoleIsExternalInvEngine - -LP_SOLVE_SOURCES=colamd.c lp_MDO.c lp_mipbb.c lp_rlp.c mmio.c commonlib.c \ - lp_MPS.c lp_params.c lp_scale.c lp_SOS.c \ - lp_presolve.c lp_simplex.c yacc_read.c ini.c lp_crash.c \ - lp_price.c lp_utils.c lp_Hash.c lp_lib.c lp_pricePSE.c \ - lp_wlp.c lp_LUSOL.c lp_matrix.c lp_report.c lusol.c \ - myblas.c - -LP_SOLVE_OBJECTS=$(LP_SOLVE_SOURCES:.c=.o) - -liblp_solve.a: $(LP_SOLVE_OBJECTS) - $(AR) rc liblp_solve.a $(LP_SOLVE_OBJECTS) && $(RANLIB) liblp_solve.a - -.c.o: - $(CC) $(CFLAGS) $(CPICFLAGS) $(LP_SOLVE_CPPFLAGS) -c $< -o $@ - -clean: - rm -rf $(LP_SOLVE_OBJECTS) liblp_solve.a diff --git a/cran_gen/Makevars b/cran_gen/Makevars deleted file mode 100644 index 8194d4c8a..000000000 --- a/cran_gen/Makevars +++ /dev/null @@ -1,16 +0,0 @@ -PKG_CPPFLAGS=-Iexternal -Iexternal/lpsolve/headers/run_headers -Iexternal/minimum_ellipsoid -Iinclude -Iinclude/convex_bodies/spectrahedra -PKG_CXXFLAGS= -DBOOST_NO_AUTO_PTR -DDISABLE_NLP_ORACLES - -PKG_LIBS=-Lexternal/lpsolve/build/lp_solve -llp_solve -Lexternal/PackedCSparse/qd -lqd $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) - -$(SHLIB): external/lpsolve/build/lp_solve/liblp_solve.a external/PackedCSparse/qd/libqd.a - -external/lpsolve/build/lp_solve/liblp_solve.a: - @(cd external/lpsolve/build/lp_solve && $(MAKE) liblp_solve.a \ - CC="$(CC)" CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" \ - CPICFLAGS="$(CPICFLAGS)" AR="$(AR)" RANLIB="$(RANLIB)") - -external/PackedCSparse/qd/libqd.a: - @(cd external/PackedCSparse/qd/ && $(MAKE) libqd.a \ - CC="$(CC)" CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" \ - CPICFLAGS="$(CPICFLAGS)" AR="$(AR)") diff --git a/cran_gen/Makevars.win b/cran_gen/Makevars.win deleted file mode 100644 index e4f79d991..000000000 --- a/cran_gen/Makevars.win +++ /dev/null @@ -1,17 +0,0 @@ -PKG_CPPFLAGS=-Iexternal -Iexternal/lpsolve/headers/run_headers -Iexternal/minimum_ellipsoid -Iinclude -Iinclude/convex_bodies/spectrahedra -PKG_CXXFLAGS= -lm -ldl -DBOOST_NO_AUTO_PTR -DDISABLE_NLP_ORACLES - -PKG_LIBS=-Lexternal/lpsolve/build/lp_solve -llp_solve -Lexternal/PackedCSparse/qd -lqd $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) - -$(SHLIB): external/lpsolve/build/lp_solve/liblp_solve.a external/PackedCSparse/qd/libqd.a - -external/lpsolve/build/lp_solve/liblp_solve.a: - @(cd external/lpsolve/build/lp_solve && $(MAKE) liblp_solve.a \ - CC="$(CC)" CPPFLAGS="$(CPPFLAGS) -DUSRDLL -DINLINE=static" \ - CFLAGS="$(CFLAGS)" CPICFLAGS="$(CPICFLAGS)" AR="$(AR)" \ - RANLIB="$(RANLIB)") - -external/PackedCSparse/qd/libqd.a: - @(cd external/PackedCSparse/qd/ && $(MAKE) libqd.a \ - CC="$(CC)" CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" \ - CPICFLAGS="$(CPICFLAGS)" AR="$(AR)") diff --git a/cran_gen/NEWS.md b/cran_gen/NEWS.md deleted file mode 100644 index 5038f653b..000000000 --- a/cran_gen/NEWS.md +++ /dev/null @@ -1,31 +0,0 @@ -# volesti 1.0.0 - -* This is the first release of volesti R-Package. - -# volesti 1.0.1 - -* Fix some bugs for solaris os. - -# volesti 1.0.2 - -* Remove r-striper to avoid CRAN policy violation. - -# volesti 1.0.3 - -* Fix CRAN warnings. - -# volesti 1.1.0 - -* New volume computation algorithm. -* Billiard walk for uniform sampling. -* Modified exact volume computation function. -* Implementation and evaluation of PCA method for zonotope approximation. -* Boundary sampling. -* Improved functionality for finance applications. -* Improved names for functions and input variables. -* Use exclusively Eigen/BH library for linear algebra. - -# volesti 1.1.1 - -* Fix CRAN warnings about deprecated use of ftime - diff --git a/cran_gen/README.md b/cran_gen/README.md deleted file mode 100644 index 8a9245ec5..000000000 --- a/cran_gen/README.md +++ /dev/null @@ -1,35 +0,0 @@ -# Volume computation and sampling - -## About -The `volesti` package provides [R](https://www.r-project.org/) with functions for volume estimation and sampling. In particular, it provides an R interface for the C++ library [**volesti**](https://github.com/GeomScale/volume_approximation). - -`volesti` computes approximations of volume of polytopes given as a set of points or linear inequalities or as a Minkowski sum of segments (zonotopes). There are algorithms for volume approximation as well as algorithms for sampling, rounding and rotating polytopes. Last but not least, `volesti` provides implementations of geometric algorithms to compute the score of a portfolio given asset returns and to detect financial crises in stock markets. - -## Download and install - -* The latest stable version is available from CRAN. -* The latest development version is available on Github `www.github.com/GeomScale/volume_approximation` - -* Install `volesti` by running: -``` -install.packages("volesti") -``` -* The package-dependencies are: `Rcpp`, `RcppEigen`, `BH`. - -## Documentation - -* [Using the R Interface](https://github.com/GeomScale/volume_approximation/blob/v1.1.1/doc/r_interface.md) -* [Wikipage with Tutorials and Demos](https://github.com/GeomScale/volume_approximation/wiki) -* [Tutorial given to PyData meetup](https://vissarion.github.io/tutorials/volesti_tutorial_pydata.html) - - -## Credits - -* [Contributors and Package History](https://github.com/GeomScale/volume_approximation/blob/v1.1.1/doc/credits.md) -* [List of Publications](https://github.com/GeomScale/volume_approximation/blob/v1.1.1/doc/publications.md) - -Copyright (c) 2012-2020 Vissarion Fisikopoulos -Copyright (c) 2018-2020 Apostolos Chalkis - -You may redistribute or modify the software under the GNU Lesser General Public License as published by Free Software Foundation, either version 3 of the License, or (at your option) any later version. It is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. - diff --git a/cran_gen/genCRANpkg.R b/cran_gen/genCRANpkg.R deleted file mode 100644 index abf51d88a..000000000 --- a/cran_gen/genCRANpkg.R +++ /dev/null @@ -1,186 +0,0 @@ -# create cran package folder -dir.create("cran_package") -# set /root as main path -path = getwd() -path = substr(path, start=1, stop=nchar(path)-9) - -# download lpSolveAPI and crate src/Rproj_externals/lp_solve -library(downloader) -download("https://cran.r-project.org/src/contrib/Archive/lpSolveAPI/lpSolveAPI_5.5.2.0-17.6.tar.gz", dest="lpSolve.tar.gz", mode="wb") -untar("lpSolve.tar.gz", exdir = path) -unlink("lpSolve.tar.gz") -dir.create(paste0(path,"/R-proj/src/Rproj_externals")) -dir_lp = paste0(path,"/lpSolveAPI/src/lp_solve") -lp_dist = paste0(path,"/R-proj/src/Rproj_externals") -file.copy(dir_lp, lp_dist, recursive=TRUE) - -# fix ftime deprecation, taken from: https://github.com/GeomScale/volesti/pull/89/files -library(xfun) -gsub_file( - paste0(path,"/R-proj/src/Rproj_externals/lp_solve/commonlib.c"), - "struct timeb buf;", "", - fixed=TRUE) -gsub_file( - paste0(path,"/R-proj/src/Rproj_externals/lp_solve/commonlib.c"), - "ftime(&buf);", "", - fixed=TRUE) -gsub_file( - paste0(path,"/R-proj/src/Rproj_externals/lp_solve/commonlib.c"), - "return((double)buf.time+((double) buf.millitm)/1000.0);", - "return((double)0);", - fixed=TRUE) - -# add lpsolve header files in external -library(downloader) -download("https://cran.r-project.org/src/contrib/Archive/lpSolve/lpSolve_5.6.15.tar.gz", dest="lpSolve.tar.gz", mode="wb") -untar("lpSolve.tar.gz", exdir = path) -unlink("lpSolve.tar.gz") -dir.create(paste0(path,"/external/LPsolve_src")) -dir.create(paste0(path,"/external/LPsolve_src/include")) -dir.create(paste0(path,"/external/LPsolve_src/run_headers")) -dir_lp = paste0(path,"/lpSolveAPI/inst/include") -h_files = dir(dir_lp, "*.h", ignore.case = TRUE, all.files = TRUE) -lp_dist = paste0(path,"/external/LPsolve_src/include") -file.copy(file.path(dir_lp, h_files), lp_dist, recursive=TRUE, overwrite=TRUE) -# replace the lpsolve header file that issues a warning in mac's cran test -file.copy(paste0(path,"/external/cmake-files/lpsolve_modified_header_files/lp_rlp.h"), lp_dist, recursive=TRUE, overwrite=TRUE) -dir_lp = paste0(path,"/lpSolve/src") -h_files = dir(dir_lp, "*.h", ignore.case = TRUE, all.files = TRUE) -lp_dist = paste0(path,"/external/LPsolve_src/run_headers") -file.copy(file.path(dir_lp, h_files), lp_dist, recursive=TRUE) -unlink(paste0(path,"/lpSolveAPI"), recursive=TRUE) -unlink(paste0(path,"/lpSolve"), recursive=TRUE) - -# copy paste the src folder -src_dir = paste0(path,'/R-proj/src') -src_dist = paste0(path,'/cran_gen/cran_package') -file.copy(src_dir, src_dist, recursive=TRUE) - -# copy paste the inst folder -inst_dir = paste0(path,'/R-proj/inst') -inst_dist = paste0(path,'/cran_gen/cran_package') -file.copy(inst_dir, inst_dist, recursive=TRUE) - -# copy paste the man folder -man_dir = paste0(path,'/R-proj/man') -man_dist = paste0(path,'/cran_gen/cran_package') -file.copy(man_dir, man_dist, recursive=TRUE) - -# copy paste the R folder -R_dir = paste0(path,'/R-proj/R') -R_dist = paste0(path,'/cran_gen/cran_package') -file.copy(R_dir, R_dist, recursive=TRUE) - -# copy paste the tests folder -tests_dir = paste0(path,'/R-proj/tests') -tests_dist = paste0(path,'/cran_gen/cran_package') -file.copy(tests_dir, tests_dist, recursive=TRUE) - -# copy paste the DESCRIPTION file -descr_dir = paste0(path,'/R-proj/DESCRIPTION') -descr_dist = paste0(path,'/cran_gen/cran_package') -file.copy(descr_dir, descr_dist, recursive=TRUE) - -# copy paste the NAMESPACE file -namesp_dir = paste0(path,'/R-proj/NAMESPACE') -namesp_dist = paste0(path,'/cran_gen/cran_package') -file.copy(namesp_dir, namesp_dist, recursive=TRUE) - -# copy paste the volesti.Rproj -volpro_dir = paste0(path,'/R-proj/volesti.Rproj') -volpro_dist = paste0(path,'/cran_gen/cran_package') -file.copy(volpro_dir, volpro_dist, recursive=TRUE) - -# copy paste the external folder -external_dir = paste0(path,'/external') -external_dist = paste0(path,'/cran_gen/cran_package/src') -file.copy(external_dir, external_dist, recursive=TRUE) - -# copy paste the include folder -include_dir = paste0(path,'/include') -include_dist = paste0(path,'/cran_gen/cran_package/src') -file.copy(include_dir, include_dist, recursive=TRUE) - -# copy paste the README.md file -readme_dir = paste0(path,'/cran_gen/README.md') -readme_dist = paste0(path,'/cran_gen/cran_package') -file.copy(readme_dir, readme_dist, recursive=TRUE) - -# copy paste the NEWS.md file -news_dir = paste0(path,'/cran_gen/NEWS.md') -news_dist = paste0(path,'/cran_gen/cran_package') -file.copy(news_dir, news_dist, recursive=TRUE) - -# copy paste the cran-comments.md file -#cran_com_dir = paste0(path,'/cran_gen/cran-comments.md') -#cran_com_dist = paste0(path,'/cran_gen/cran_package') -#file.copy(cran_com_dir, cran_com_dist, recursive=TRUE) - -# copy paste the Rbuildignore.md file -Rbuild_dir = paste0(path,'/cran_gen/.Rbuildignore') -Rbuild_dist = paste0(path,'/cran_gen/cran_package') -file.copy(Rbuild_dir, Rbuild_dist, recursive=TRUE) - -# replace the Makevars -makevars_dir = paste0(path,'/cran_gen/Makevars') -makevars_dist = paste0(path, '/cran_gen/cran_package/src') -file.copy(makevars_dir, makevars_dist, recursive=TRUE) - -# replace the Makevars.win -makevarswin_dir = paste0(path,'/cran_gen/Makevars.win') -makevarswin_dist = paste0(path, '/cran_gen/cran_package/src') -file.copy(makevarswin_dir, makevarswin_dist, recursive=TRUE) - -# copy paste the LICENCE -dir_lic = paste0(path,'/LICENSE') -lic_dist = paste0(path,'/cran_package/inst/doc') - -# delete misc.h from include -dir_misc = paste0(path,'/cran_gen/cran_package/src/include/misc.h') -unlink(dir_misc, recursive = TRUE) - -# delete linear_extensions.h from include -dir_lin_ext = paste0(path,'/cran_gen/cran_package/src/include/linear_extensions.h') -unlink(dir_lin_ext, recursive = TRUE) - -# create lpsolve folder -dir.create(paste0(path,"/cran_gen/cran_package/src/external/lpsolve")) -dir.create(paste0(path,"/cran_gen/cran_package/src/external/lpsolve/build")) -dir.create(paste0(path,"/cran_gen/cran_package/src/external/lpsolve/headers")) -dir_lp = paste0(path,"/cran_gen/cran_package/src/Rproj_externals/lp_solve") -lp_dist = (paste0(path,"/cran_gen/cran_package/src/external/lpsolve/build")) -file.copy(dir_lp, lp_dist, recursive=TRUE) -dir_lp = paste0(path,"/cran_gen/cran_package/src/external/LPsolve_src/include") -lp_dist = (paste0(path,"/cran_gen/cran_package/src/external/lpsolve/headers")) -file.copy(dir_lp, lp_dist, recursive=TRUE) -dir_lp = paste0(path,"/cran_gen/cran_package/src/external/LPsolve_src/run_headers") -lp_dist = (paste0(path,"/cran_gen/cran_package/src/external/lpsolve/headers")) -file.copy(dir_lp, lp_dist, recursive=TRUE) -dir_lpsolve_heds = paste0(path,"/cran_gen/cran_package/src/external/LPsolve_src") -unlink(dir_lpsolve_heds, recursive = TRUE) -dir_lpsolve_heds = paste0(path,"/cran_gen/cran_package/src/Rproj_externals") -unlink(dir_lpsolve_heds, recursive = TRUE) - -# replace the Makefile -makefile_dir = paste0(path,'/cran_gen/Makefile') -makefile_dist = paste0(path, '/cran_gen/cran_package/src/external/lpsolve/build/lp_solve') -file.copy(makefile_dir, makefile_dist, recursive=TRUE) - - - -# set new cran package folder as wrking directory -setwd(paste0(path,'/cran_gen/cran_package')) -# enable devtools and Rcpp libraries -library(devtools) -library(Rcpp) - -# build package tar.gz -Rcpp::compileAttributes() -devtools::build() - -# set /root/R-proj as the working directory -setwd(paste0(path,'/R-proj')) - -# delete folder cran_package -#dir_cr_pkg = paste0(path,'/cran_gen/cran_package') -#unlink(dir_cr_pkg, recursive = TRUE) diff --git a/include/ode_solvers/oracle_functors_rcpp.hpp b/include/ode_solvers/oracle_functors_rcpp.hpp deleted file mode 100644 index 853dcb3c0..000000000 --- a/include/ode_solvers/oracle_functors_rcpp.hpp +++ /dev/null @@ -1,159 +0,0 @@ -// VolEsti (volume computation and sampling library) - -// Copyright (c) 2012-2020 Vissarion Fisikopoulos -// Copyright (c) 2018-2020 Apostolos Chalkis -// Copyright (c) 2020-2020 Marios Papachristou - -// Contributed and/or modified by Marios Papachristou, as part of Google Summer of Code 2020 program. - -// Licensed under GNU LGPL.3, see LICENCE file - -#ifndef ODE_SOLVERS_ORACLE_FUNCTORS_RCPP_HPP -#define ODE_SOLVERS_ORACLE_FUNCTORS_RCPP_HPP - -enum ode_solvers { - no_solver, - leapfrog, - euler, - runge_kutta, - richardson, - collocation -}; - -// Holds Oracle Functor that wraps an R function via RCpp -// The R function is provided as an Rcpp::Function object -// The functor uses Rcpp::as and Rcpp::wrap to do the conversion, -// call the oracle, and convert the results back to C++ -struct RcppFunctor { - - template < - typename NT - > - struct parameters { - NT L; // Lipschitz constant of gradient - NT m; // Strong-convexity parameter - NT eta; // Step-size (if defined by user) - NT kappa; // Condition number - unsigned int order; // Order of ODE functor - - parameters( - NT L_, - NT m_, - NT eta_, - unsigned int order_=2 - ) : - L(L_), - m(m_), - eta(eta_), - kappa(L_ / m_), - order(order_) - {} - }; - - // Log-probability gradient functor - template - < - typename Point - > - struct GradientFunctor { - typedef typename Point::FT NT; - typedef typename Point::Coeff VT; - typedef std::vector pts; - - parameters params; - Rcpp::Function neg_grad_f; // Negative gradient as an Rcpp::Function - bool negate; - - GradientFunctor( - parameters params_, - Rcpp::Function neg_grad_f_, - bool negate_=true): - params(params_), - neg_grad_f(neg_grad_f_), - negate(negate_) - {}; - - // The index i represents the state vector index - Point operator() (unsigned int const& i, pts const& xs, NT const& t) const { - if (i == params.order - 1) { - // Convert point to Rcpp::NumericMatrix - - VT y = Rcpp::as(neg_grad_f(Rcpp::wrap(xs[0].getCoefficients()))); - - Point z(y); - - if (negate) z = (-1.0) * z; - - // Return result as Point - return z; - } else { - return xs[i + 1]; // returns derivative - } - } - - Point operator() (Point const& x) const { - VT y = Rcpp::as(neg_grad_f(Rcpp::wrap(x.getCoefficients()))); - - Point z(y); - - if (negate) z = (-1.0) * z; - - // Return result as Point - return z; - } - - }; - - // Negative log-probability functor - template - < - typename Point - > - struct FunctionFunctor { - typedef typename Point::FT NT; - typedef typename Point::Coeff VT; - - parameters params; - Rcpp::Function negative_logprob; - - FunctionFunctor( - parameters params_, - Rcpp::Function negative_logprob_) : - params(params_), - negative_logprob(negative_logprob_) - {}; - - NT operator() (Point const& x) const { - return Rcpp::as(negative_logprob(Rcpp::wrap(x.getCoefficients()))); - } - - }; - - // Log-probability hessian functor - template - < - typename Point - > - struct HessianFunctor { - typedef typename Point::FT NT; - typedef typename Point::Coeff VT; - - parameters params; - Rcpp::Function hessian; // Negative hessian as an Rcpp::Function - - HessianFunctor( - parameters params_, - Rcpp::Function hessian_) : - params(params_), - hessian(hessian_) - {}; - - Point operator() (Point const& x) const { - VT y= Rcpp::as(hessian(Rcpp::wrap(x.getCoefficients()))); - return Point(y); - } - - }; -}; - -#endif diff --git a/test/crhmc_sampling_test.cpp b/test/crhmc_sampling_test.cpp index a13a6e299..79697b4a4 100644 --- a/test/crhmc_sampling_test.cpp +++ b/test/crhmc_sampling_test.cpp @@ -13,7 +13,6 @@ #include "doctest.h" #include "generators/known_polytope_generators.h" #include "misc/misc.h" -#include "ode_solvers.hpp" #include "preprocess/crhmc/crhmc_input.h" #include "preprocess/crhmc/crhmc_problem.h" #include "preprocess/crhmc/crhmc_problem.h" diff --git a/test/sampling_correlation_matrices_test.cpp b/test/sampling_correlation_matrices_test.cpp index f2f90c529..39bb0e605 100644 --- a/test/sampling_correlation_matrices_test.cpp +++ b/test/sampling_correlation_matrices_test.cpp @@ -9,18 +9,18 @@ #include "doctest.h" #include -#include "misc.h" + #include "random.hpp" #include "random/uniform_int.hpp" #include "random/normal_distribution.hpp" #include "random/uniform_real_distribution.hpp" #include "cartesian_geom/cartesian_kernel.h" +#include "diagnostics/univariate_psrf.hpp" +#include "misc/misc.h" #include "random_walks/random_walks.hpp" #include "sampling/sample_correlation_matrices.hpp" -#include "diagnostics/univariate_psrf.hpp" - template MT rebuildMatrix(const VT &xvector, const unsigned int n){ MT mat = MT::Identity(n,n);