From 70bc7ae0accddd152d54dadecda0a3369becab9f Mon Sep 17 00:00:00 2001 From: Tolis Date: Fri, 22 May 2020 23:21:13 +0300 Subject: [PATCH 1/3] pass cran check --- R-proj/R/round_polytope.R | 2 +- R-proj/man/direct_sampling.Rd | 4 +++- R-proj/man/round_polytope.Rd | 4 +++- R-proj/man/rounding.Rd | 4 +++- R-proj/man/sample_points.Rd | 4 +++- R-proj/man/volume.Rd | 4 +++- R-proj/man/zono_approx.Rd | 4 +++- R-proj/man/zonotope_approximation.Rd | 19 +++++-------------- R-proj/src/Makevars | 2 +- R-proj/src/Makevars.win | 2 +- R-proj/src/copula.cpp | 2 +- R-proj/src/direct_sampling.cpp | 1 - R-proj/src/volume.cpp | 10 +++++----- R-proj/src/zonotope_approximation.cpp | 8 ++++---- cran_gen/Makevars | 2 +- cran_gen/Makevars.win | 2 +- include/convex_bodies/hpolytope.h | 2 +- include/convex_bodies/vpolytope.h | 2 +- include/convex_bodies/zpolytope.h | 4 ++-- include/sampling/simplex.hpp | 2 -- include/volume/volume_cooling_balls.hpp | 1 - 21 files changed, 42 insertions(+), 43 deletions(-) diff --git a/R-proj/R/round_polytope.R b/R-proj/R/round_polytope.R index 53a5f06e4..75a283830 100644 --- a/R-proj/R/round_polytope.R +++ b/R-proj/R/round_polytope.R @@ -25,7 +25,7 @@ #' 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) 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..a8d2dc495 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 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/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/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/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 = "< std::vector > twoParHypFam(const int dim, const int num, const int num_slices, - const std::vector &pl1, const std::vector &pl2) + const std::vector &pl1, const std::vector &pl2, + double seed = std::numeric_limits::signaling_NaN()) { int i,j,col,row; @@ -37,7 +38,7 @@ std::vector > twoParHypFam(const int dim, std::pair< std::vector,std::vector > result; Point p; - Sam_Canon_Unit (dim, num, points); + Sam_Canon_Unit (dim, num, points, seed); std::vector > Matrix(num_slices); std::vector > pos_Matrix(num_slices); @@ -135,7 +136,8 @@ std::vector > hypfam_ellfam(int dim, int num, int num_slices, std::vector pl, - ellipsoid G) + ellipsoid G, + double seed = std::numeric_limits::signaling_NaN()) { int i,j,col,row; @@ -146,7 +148,7 @@ std::vector > hypfam_ellfam(int dim, std::pair< std::vector,std::vector > result; Point p; - Sam_Canon_Unit (dim, num, points); + Sam_Canon_Unit (dim, num, points, seed); std::vector > Matrix(num_slices); std::vector > pos_Matrix(num_slices);