diff --git a/R-proj/R/RcppExports.R b/R-proj/R/RcppExports.R index 898e40401..1362b3ecc 100644 --- a/R-proj/R/RcppExports.R +++ b/R-proj/R/RcppExports.R @@ -10,6 +10,7 @@ #' @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.} @@ -31,8 +32,8 @@ #' cop = copula(r1 = h, sigma = E, m = 10, n = 100000) #' #' @export -copula <- function(r1 = NULL, r2 = NULL, sigma = NULL, m = NULL, n = NULL) { - .Call(`_volesti_copula`, r1, r2, sigma, m, n) +copula <- function(r1 = NULL, 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. diff --git a/R-proj/R/compute_indicators.R b/R-proj/R/compute_indicators.R index a93199b81..00d223693 100644 --- a/R-proj/R/compute_indicators.R +++ b/R-proj/R/compute_indicators.R @@ -10,6 +10,7 @@ #' @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.} @@ -17,7 +18,7 @@ #' @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. #' #' @export -compute_indicators <- function(returns, win_length = NULL, m = NULL, n = NULL, nwarning = NULL, ncrisis = NULL) { +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 @@ -43,7 +44,7 @@ compute_indicators <- function(returns, win_length = NULL, m = NULL, n = NULL, n compRet[j] = compRet[j] - 1 } - cop = copula(r1 = compRet, sigma = E, m = m, n = n) + cop = copula(r1 = compRet, sigma = E, m = m, n = n, seed = seed) blue_mass = 0 red_mass = 0 diff --git a/R-proj/R/round_polytope.R b/R-proj/R/round_polytope.R index 53a5f06e4..784bf90f9 100644 --- a/R-proj/R/round_polytope.R +++ b/R-proj/R/round_polytope.R @@ -25,9 +25,9 @@ #' Z = gen_rand_zonotope(2,6) #' ListZono = round_polytope(Z) #' @export -round_polytope <- function(P){ +round_polytope <- function(P, seed = NULL){ - ret_list = rounding(P) + ret_list = rounding(P, seed) #get the matrix that describes the polytope Mat = ret_list$Mat diff --git a/R-proj/man/compute_indicators.Rd b/R-proj/man/compute_indicators.Rd index df93bc806..b8e01b9a4 100644 --- a/R-proj/man/compute_indicators.Rd +++ b/R-proj/man/compute_indicators.Rd @@ -5,7 +5,7 @@ \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) + 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.} @@ -19,6 +19,8 @@ compute_indicators(returns, win_length = NULL, m = NULL, n = NULL, \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. diff --git a/R-proj/man/copula.Rd b/R-proj/man/copula.Rd index 5743fc616..1231f54f4 100644 --- a/R-proj/man/copula.Rd +++ b/R-proj/man/copula.Rd @@ -4,7 +4,8 @@ \alias{copula} \title{Construct a copula using uniform sampling from the unit simplex} \usage{ -copula(r1 = NULL, r2 = NULL, sigma = NULL, m = NULL, n = NULL) +copula(r1 = NULL, r2 = NULL, sigma = NULL, m = NULL, n = NULL, + seed = NULL) } \arguments{ \item{r1}{A \eqn{d}-dimensional vector that describes the direction of the first family of parallel hyperplanes.} @@ -16,6 +17,8 @@ copula(r1 = NULL, r2 = NULL, sigma = NULL, m = NULL, n = NULL) \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{numSlices\times numSlices} numerical matrix that corresponds to a copula. diff --git a/R-proj/man/direct_sampling.Rd b/R-proj/man/direct_sampling.Rd index ef6bf21c7..b7c9a1374 100644 --- a/R-proj/man/direct_sampling.Rd +++ b/R-proj/man/direct_sampling.Rd @@ -4,7 +4,7 @@ \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 = NULL, n = NULL) +direct_sampling(body = NULL, n = NULL, seed = NULL) } \arguments{ \item{body}{A list to request exact uniform sampling from special well known convex bodies through the following input parameters: @@ -15,6 +15,8 @@ direct_sampling(body = NULL, n = NULL) }} \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. diff --git a/R-proj/man/round_polytope.Rd b/R-proj/man/round_polytope.Rd index 6874f8eff..e25e90bbe 100644 --- a/R-proj/man/round_polytope.Rd +++ b/R-proj/man/round_polytope.Rd @@ -4,10 +4,12 @@ \alias{round_polytope} \title{Apply rounding to a convex polytope (H-polytope, V-polytope or a zonotope)} \usage{ -round_polytope(P) +round_polytope(P, seed = NULL) } \arguments{ \item{P}{A convex polytope. It is an object from class (a) Hpolytope or (b) Vpolytope or (c) Zonotope.} + +\item{seed}{Optional. A fixed seed for the number generator.} } \value{ A list with 2 elements: (a) a polytope of the same class as the input polytope class and (b) the element "round_value" which is the determinant of the square matrix of the linear transformation that was applied on the polytope that is given as input. diff --git a/R-proj/man/rounding.Rd b/R-proj/man/rounding.Rd index e28fdc0e9..ed6a6c89b 100644 --- a/R-proj/man/rounding.Rd +++ b/R-proj/man/rounding.Rd @@ -4,10 +4,12 @@ \alias{rounding} \title{Internal rcpp function for the rounding of a convex polytope} \usage{ -rounding(P) +rounding(P, seed = NULL) } \arguments{ \item{P}{A convex polytope (H- or V-representation or zonotope).} + +\item{seed}{Optional. A fixed seed for the number generator.} } \value{ A numerical matrix that describes the rounded polytope and contains the round value. diff --git a/R-proj/man/sample_points.Rd b/R-proj/man/sample_points.Rd index 204f311f6..8cf6f5598 100644 --- a/R-proj/man/sample_points.Rd +++ b/R-proj/man/sample_points.Rd @@ -5,7 +5,7 @@ \title{Sample uniformly or normally distributed points from a convex Polytope (H-polytope, V-polytope or a zonotope).} \usage{ sample_points(P = NULL, n = NULL, random_walk = NULL, - distribution = 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) an intersection of two V-polytopes.} @@ -28,6 +28,8 @@ sample_points(P = NULL, n = NULL, random_walk = NULL, \item{\code{variance} }{ The variance of the multidimensional spherical gaussian. 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 Chebychev ball.} }} + +\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. diff --git a/R-proj/man/volume.Rd b/R-proj/man/volume.Rd index 2b51d4d11..035607962 100644 --- a/R-proj/man/volume.Rd +++ b/R-proj/man/volume.Rd @@ -4,7 +4,7 @@ \alias{volume} \title{The main function for volume approximation of a convex Polytope (H-polytope, V-polytope or a zonotope)} \usage{ -volume(P, settings = NULL, rounding = NULL) +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.} @@ -20,6 +20,8 @@ volume(P, settings = NULL, rounding = NULL) }} \item{rounding}{Optional. A boolean parameter for rounding. The default value is \code{TRUE} for V-polytopes and \code{FALSE} otherwise.} + +\item{seed}{Optional. A fixed seed for the number generator.} } \value{ The approximation of the volume of a convex polytope. diff --git a/R-proj/man/zono_approx.Rd b/R-proj/man/zono_approx.Rd index 1670d3e14..e3996dc35 100644 --- a/R-proj/man/zono_approx.Rd +++ b/R-proj/man/zono_approx.Rd @@ -4,7 +4,7 @@ \alias{zono_approx} \title{An internal Rccp function for the over-approximation of a zonotope} \usage{ -zono_approx(Z, fit_ratio = NULL, settings = NULL) +zono_approx(Z, fit_ratio = NULL, settings = NULL, seed = NULL) } \arguments{ \item{Z}{A zonotope.} @@ -12,6 +12,8 @@ zono_approx(Z, fit_ratio = NULL, settings = NULL) \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. diff --git a/R-proj/man/zonotope_approximation.Rd b/R-proj/man/zonotope_approximation.Rd index b3472734f..f42fdbae7 100644 --- a/R-proj/man/zonotope_approximation.Rd +++ b/R-proj/man/zonotope_approximation.Rd @@ -4,7 +4,8 @@ \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) +zonotope_approximation(Z, fit_ratio = NULL, settings = NULL, + seed = NULL) } \arguments{ \item{Z}{A zonotope.} @@ -14,22 +15,12 @@ zonotope_approximation(Z, fit_ratio = NULL, settings = NULL) \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{1} for \code{'SOB'} 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. The default walk is \code{'CDHR'} for H-polytopes and \code{'BiW'} 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{rounding} }{ A boolean parameter for rounding. The default value is \code{FALSE}.} -\item{\code{inner_ball} }{ A \eqn{d+1} numeric vector that contains an inner ball. The first \eqn{d} coordinates corresponds to the center and the last one to the radius of the ball. If it is not given then for H-polytopes the Chebychev ball is computed, for V-polytopes \eqn{d+1} vertices are picked randomly and the Chebychev ball of the defined simplex is computed. For a zonotope that is defined by the Minkowski sum of \eqn{m} segments we compute the maximal \eqn{r} s.t.: \eqn{re_i\in Z} for all \eqn{i=1,\dots ,d}, then the ball centered at the origin with radius \eqn{r/\sqrt{d}} is an inscribed ball.} -\item{\code{len_win} }{ The length of the sliding window for CG algorithm. The default value is \eqn{500+4dimension^2}.} -\item{\code{BW_rad} }{ The radius for the ball walk. The default value is \eqn{4r/dimension}, where \eqn{r} is the radius of the inscribed ball of the polytope.} -\item{\code{ub} }{ The lower bound for the ratios in MMC in CB algorithm. The default value is \eqn{0.1}.} -\item{\code{lb} }{ The upper bound for the ratios in MMC in CB algorithm. The default value is \eqn{0.15}.} -\item{\code{N} }{ An integer that controls the number of points \eqn{\nu N} generated in each convex body in annealing schedule of algorithm CB.} -\item{\code{nu} }{ The degrees of freedom for the t-student distribution in t-tests in CB algorithm. The default value is \eqn{10}.} -\item{\code{alpha} }{ The significance level for the t-tests in CB algorithm. The default values is 0.2.} -\item{\code{prob} }{ The probability is used for the empirical confidence interval in ratio estimation of CB algorithm. The default value is \eqn{0.75}.} +\item{\code{win_len} }{ The length of the sliding window for CG algorithm. The default value is \eqn{500+4dimension^2}.} \item{\code{hpoly} }{ A boolean parameter to use H-polytopes in MMC of CB algorithm. The default value is \code{FALSE}.} -\item{\code{minmaxW} }{ A boolean parameter to use the sliding window with a minmax values as a stopping criterion.} -\item{\code{L} }{The maximum length of the billiard trajectory.} }} + +\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 diff --git a/R-proj/src/Makevars b/R-proj/src/Makevars index fa2b37e3f..1ef84c4f9 100644 --- a/R-proj/src/Makevars +++ b/R-proj/src/Makevars @@ -1,4 +1,4 @@ -PKG_CPPFLAGS=-I../../external/boost -I../../external/LPsolve_src/run_headers -I../../external/minimum_ellipsoid -I../../include -I../../include/volume -I../../include/generators -I../../include/samplers -I../../include/annealing -I../../include/convex_bodies -I../../include/lp_oracles -I../../include/misc +PKG_CPPFLAGS=-I../../external/boost -I../../external/LPsolve_src/run_headers -I../../external/minimum_ellipsoid -I../../include PKG_CXXFLAGS= -lm -ldl -Wno-ignored-attributes -DBOOST_NO_AUTO_PTR CXX_STD = CXX11 diff --git a/R-proj/src/Makevars.win b/R-proj/src/Makevars.win index a70f47bb1..30c291f94 100644 --- a/R-proj/src/Makevars.win +++ b/R-proj/src/Makevars.win @@ -1,4 +1,4 @@ -PKG_CPPFLAGS=-I../../external/boost -I../../external/LPsolve_src/run_headers -I../../external/minimum_ellipsoid -I../../include -I../../include/volume -I../../include/generators -I../../include/samplers -I../../include/annealing -I../../include/convex_bodies -I../../include/lp_oracles -I../../include/misc +PKG_CPPFLAGS=-I../../external/boost -I../../external/LPsolve_src/run_headers -I../../external/minimum_ellipsoid -I../../include PKG_CXXFLAGS= -lm -ldl -Wno-ignored-attributes -DBOOST_NO_AUTO_PTR CXX_STD = CXX11 diff --git a/R-proj/src/copula.cpp b/R-proj/src/copula.cpp index f24433cbc..eab05a2c2 100644 --- a/R-proj/src/copula.cpp +++ b/R-proj/src/copula.cpp @@ -10,7 +10,7 @@ #include #include #include -#include "ellipsoids.h" +#include "convex_bodies/ellipsoids.h" #include "cartesian_geom/cartesian_kernel.h" #include #include @@ -26,6 +26,7 @@ //' @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.} @@ -52,7 +53,8 @@ Rcpp::NumericMatrix copula (Rcpp::Nullable r1 = R_NilValue, Rcpp::Nullable r2 = R_NilValue, Rcpp::Nullable sigma = R_NilValue, Rcpp::Nullable m = R_NilValue, - Rcpp::Nullable n = R_NilValue){ + Rcpp::Nullable n = R_NilValue, + Rcpp::Nullable seed = R_NilValue){ typedef double NT; typedef Cartesian Kernel; @@ -71,6 +73,8 @@ Rcpp::NumericMatrix copula (Rcpp::Nullable r1 = R_NilValue, 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; @@ -85,7 +89,7 @@ Rcpp::NumericMatrix copula (Rcpp::Nullable r1 = R_NilValue, if (r2.isNotNull()) { std::vector hyp2 = Rcpp::as < std::vector < NT > > (r2); - StdCopula = twoParHypFam(dim, numpoints, num_slices, hyp1, hyp2); + StdCopula = twoParHypFam(dim, numpoints, num_slices, hyp1, hyp2, seed3); } else if (sigma.isNotNull()) { @@ -97,7 +101,7 @@ Rcpp::NumericMatrix copula (Rcpp::Nullable r1 = R_NilValue, } } CopEll Ell(Gin); - StdCopula = hypfam_ellfam(dim, numpoints, num_slices, hyp1, Ell); + StdCopula = hypfam_ellfam(dim, numpoints, num_slices, hyp1, Ell, seed3); } else { throw Rcpp::exception("Wrong inputs"); diff --git a/R-proj/src/direct_sampling.cpp b/R-proj/src/direct_sampling.cpp index 4140fbefa..8fbcbb6e1 100644 --- a/R-proj/src/direct_sampling.cpp +++ b/R-proj/src/direct_sampling.cpp @@ -68,7 +68,6 @@ Rcpp::NumericMatrix direct_sampling(Rcpp::Nullable body = R_NilValue if (seed.isNotNull()) { unsigned seed2 = std::chrono::system_clock::now().time_since_epoch().count(); - std::cout<<"seed = "<::signaling_NaN() : Rcpp::as(seed); diff --git a/R-proj/src/rounding.cpp b/R-proj/src/rounding.cpp index f08561160..41785e503 100644 --- a/R-proj/src/rounding.cpp +++ b/R-proj/src/rounding.cpp @@ -92,33 +92,27 @@ Rcpp::List rounding (Rcpp::Reference P, Rcpp::Nullable seed = R_NilValue switch (type) { case 1: { if (cdhr) { - round_res = round_polytope(HP, InnerBall, walkL, - rng); + round_res = round_polytope(HP, InnerBall, walkL, rng); } else { - round_res = round_polytope(HP, InnerBall, walkL, - rng); + round_res = round_polytope(HP, InnerBall, walkL, rng); } Mat = extractMatPoly(HP); break; } case 2: { if (cdhr) { - round_res = round_polytope(VP, InnerBall, walkL, - rng); + round_res = round_polytope(VP, InnerBall, walkL, rng); } else { - round_res = round_polytope(VP, InnerBall, walkL, - rng); + round_res = round_polytope(VP, InnerBall, walkL, rng); } Mat = extractMatPoly(VP); break; } case 3: { if (cdhr) { - round_res = round_polytope(ZP, InnerBall, walkL, - rng); + round_res = round_polytope(ZP, InnerBall, walkL, rng); } else { - round_res = round_polytope(ZP, InnerBall, walkL, - rng); + round_res = round_polytope(ZP, InnerBall, walkL, rng); } Mat = extractMatPoly(ZP); break; diff --git a/R-proj/src/volume.cpp b/R-proj/src/volume.cpp index a47e97ea7..2bd143db2 100644 --- a/R-proj/src/volume.cpp +++ b/R-proj/src/volume.cpp @@ -14,11 +14,11 @@ #include #include #include "random_walks/random_walks.hpp" -#include "volume_cooling_gaussians.hpp" -#include "volume_sequence_of_balls.hpp" -#include "volume_cooling_gaussians.hpp" -#include "volume_cooling_balls.hpp" -#include "volume_cooling_hpoly.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" template diff --git a/R-proj/src/zonotope_approximation.cpp b/R-proj/src/zonotope_approximation.cpp index eabf7c174..ce38ee492 100644 --- a/R-proj/src/zonotope_approximation.cpp +++ b/R-proj/src/zonotope_approximation.cpp @@ -12,10 +12,10 @@ #include #include #include "random_walks/random_walks.hpp" -#include "volume_sequence_of_balls.hpp" -#include "volume_cooling_gaussians.hpp" -#include "volume_cooling_balls.hpp" -#include "volume_cooling_hpoly.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 //' diff --git a/R-proj/tests/testthat/test_rounding.R b/R-proj/tests/testthat/test_rounding.R index ad7d03459..54eb5dbf4 100644 --- a/R-proj/tests/testthat/test_rounding.R +++ b/R-proj/tests/testthat/test_rounding.R @@ -6,9 +6,9 @@ testRound <- function(P, exactvol, tol, name_string, num_of_exps, algo, rotation if (rotation) { P = rand_rotate(P) - listHpoly = round_polytope(P) + listHpoly = round_polytope(P, seed = seed) } else { - listHpoly = round_polytope(P) + listHpoly = round_polytope(P, seed = seed) } vol = 0 for (j in 1:num_of_exps) { diff --git a/cran_gen/Makevars b/cran_gen/Makevars index 471f24c4c..616400b1f 100644 --- a/cran_gen/Makevars +++ b/cran_gen/Makevars @@ -1,4 +1,4 @@ -PKG_CPPFLAGS=-Iexternal/lpsolve/headers/run_headers -Iexternal/minimum_ellipsoid -Iinclude -Iinclude/volume -Iinclude/lp_oracles -Iinclude/generators -Iinclude/samplers -Iinclude/annealing -Iinclude/convex_bodies +PKG_CPPFLAGS=-Iexternal -Iexternal/lpsolve/headers/run_headers -Iexternal/minimum_ellipsoid -Iinclude PKG_CXXFLAGS= -DBOOST_NO_AUTO_PTR CXX_STD = CXX11 diff --git a/cran_gen/Makevars.win b/cran_gen/Makevars.win index d9a91c106..5075c172f 100644 --- a/cran_gen/Makevars.win +++ b/cran_gen/Makevars.win @@ -1,4 +1,4 @@ -PKG_CPPFLAGS=-Iexternal/lpsolve/headers/run_headers -Iexternal/minimum_ellipsoid -Iinclude -Iinclude/volume -Iinclude/generators -Iinclude/lp_oracles -Iinclude/samplers -Iinclude/annealing -Iinclude/convex_bodies +PKG_CPPFLAGS=-Iexternal -Iexternal/lpsolve/headers/run_headers -Iexternal/minimum_ellipsoid -Iinclude PKG_CXXFLAGS= -lm -ldl -DBOOST_NO_AUTO_PTR CXX_STD = CXX11 diff --git a/include/convex_bodies/hpolytope.h b/include/convex_bodies/hpolytope.h index b224ab432..0cc84bb1d 100644 --- a/include/convex_bodies/hpolytope.h +++ b/include/convex_bodies/hpolytope.h @@ -14,7 +14,7 @@ #include #include #include -#include "solve_lp.h" +#include "lp_oracles/solve_lp.h" // H-polytope class template diff --git a/include/convex_bodies/vpolytope.h b/include/convex_bodies/vpolytope.h index 0008e4bd6..7402f1eba 100644 --- a/include/convex_bodies/vpolytope.h +++ b/include/convex_bodies/vpolytope.h @@ -15,7 +15,7 @@ #include #include -#include "vpolyoracles.h" +#include "lp_oracles/vpolyoracles.h" #include "khach.h" //min and max values for the Hit and Run functions diff --git a/include/convex_bodies/zpolytope.h b/include/convex_bodies/zpolytope.h index d2a803c5d..871263c0d 100644 --- a/include/convex_bodies/zpolytope.h +++ b/include/convex_bodies/zpolytope.h @@ -15,8 +15,8 @@ #include #include -#include "vpolyoracles.h" -#include "zpolyoracles.h" +#include "lp_oracles/vpolyoracles.h" +#include "lp_oracles/zpolyoracles.h" template class Zonotope { diff --git a/include/random_walks/uniform_billiard_walk.hpp b/include/random_walks/uniform_billiard_walk.hpp index 9630702f1..e704c7acd 100644 --- a/include/random_walks/uniform_billiard_walk.hpp +++ b/include/random_walks/uniform_billiard_walk.hpp @@ -249,7 +249,7 @@ struct Walk _v = GetDirection::apply(n, rng); Point p0 = _p; int it = 0; - while (it < 10*n) + while (it < 50*n) { auto pbpair = P.line_positive_intersect(_p, _v, _lambdas, _Av, _lambda_prev); @@ -264,7 +264,9 @@ struct Walk P.compute_reflection(_v, _p, pbpair.second); it++; } - if (it == 30*n) _p = p0; + if (it == 50*n){ + _p = p0; + } } p = _p; } @@ -307,7 +309,7 @@ private : T -= _lambda_prev; P.compute_reflection(_v, _p, pbpair.second); - while (it < 30*n) + while (it <= 50*n) { std::pair pbpair = P.line_positive_intersect(_p, _v, _lambdas, _Av, _lambda_prev); @@ -315,6 +317,10 @@ private : _p += (T * _v); _lambda_prev = T; break; + }else if (it == 50*n) { + _lambda_prev = rng.sample_urdist() * pbpair.first; + _p += (_lambda_prev * _v); + break; } _lambda_prev = dl * pbpair.first; _p += (_lambda_prev * _v); @@ -322,7 +328,8 @@ private : P.compute_reflection(_v, _p, pbpair.second); it++; } - if (it == 10*n) _p = p0; + //if (it == 30*n) _p = p0; + } double _L; diff --git a/include/sampling/simplex.hpp b/include/sampling/simplex.hpp index 760f1e4bf..2cf1c0bb1 100644 --- a/include/sampling/simplex.hpp +++ b/include/sampling/simplex.hpp @@ -36,7 +36,6 @@ void Sam_Unit(unsigned int dim, unsigned rng_seed = std::chrono::system_clock::now().time_since_epoch().count(); RNGType rng(rng_seed); if (!std::isnan(seed)) { - std::cout<<"seed = "<