Skip to content

Commit 0ce5001

Browse files
authored
Estimate the logarithm of the polytope volume in CB algorithm (#157)
* modify the cooling balls volume function to return both log_volume and volume estimated * modify c++ tests * update Rd files * update R tests * update c++ tests
1 parent 9fe4692 commit 0ce5001

21 files changed

+152
-126
lines changed

R-proj/R/RcppExports.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ rotating <- function(P, T = NULL, seed = NULL) {
297297
#' Internal rcpp function for the rounding of a convex polytope
298298
#'
299299
#' @param P A convex polytope (H- or V-representation or zonotope).
300-
#' @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{'svd'} for the method based on svd decomposition. The default method is \code{'min_ellipsoid'} for all the representations.
300+
#' @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.
301301
#' @param seed Optional. A fixed seed for the number generator.
302302
#'
303303
#' @keywords internal
@@ -410,7 +410,7 @@ loadSdpaFormatFile <- function(inputFile = NULL) {
410410
.Call(`_volesti_loadSdpaFormatFile`, inputFile)
411411
}
412412

413-
#' The main function for volume approximation of a convex Polytope (H-polytope, V-polytope, zonotope or intersection of two V-polytopes)
413+
#' 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
414414
#'
415415
#' 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.
416416
#'
@@ -439,15 +439,15 @@ loadSdpaFormatFile <- function(inputFile = NULL) {
439439
#'
440440
#' # calling SOB algorithm for a H-polytope (5d unit simplex)
441441
#' HP = gen_cube(5,'H')
442-
#' vol = volume(HP)
442+
#' pair_vol = volume(HP)
443443
#'
444444
#' # calling CG algorithm for a V-polytope (3d simplex)
445445
#' VP = gen_simplex(3,'V')
446-
#' vol = volume(VP, settings = list("algorithm" = "CG"))
446+
#' pair_vol = volume(VP, settings = list("algorithm" = "CG"))
447447
#'
448448
#' # calling CG algorithm for a 2-dimensional zonotope defined as the Minkowski sum of 4 segments
449449
#' Z = gen_rand_zonotope(2, 4)
450-
#' vol = volume(Z, settings = list("random_walk" = "RDHR", "walk_length" = 2))
450+
#' pair_vol = volume(Z, settings = list("random_walk" = "RDHR", "walk_length" = 2))
451451
#'
452452
#' @export
453453
volume <- function(P, settings = NULL, rounding = NULL, seed = NULL) {

R-proj/R/round_polytope.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#' 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.
44
#'
55
#' @param P A convex polytope. It is an object from class (a) Hpolytope or (b) Vpolytope or (c) Zonotope.
6-
#' @param method Optional. The method to use for rounding, a) \code{'mee'} for the method based on mimimmum volume enclosing ellipsoid of a dataset, b) \code{'mve'} for the method based on maximum volume enclosed ellipsoid, (c) \code{'svd'} for the method based on svd decomposition. The default method is \code{'mee'} for all the representations.
6+
#' @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.
77
#' @param seed Optional. A fixed seed for the number generator.
88
#'
99
#' @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.

R-proj/man/round_polytope.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

R-proj/man/rounding.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

R-proj/man/volume.Rd

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

R-proj/src/rounding.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ std::tuple<MT, VT, NT> apply_rounding(Polytope &P,
4343
std::tuple<MT, VT, NT> round_res;
4444
if (method_rcpp.compare(std::string("min_ellipsoid")) == 0) {
4545
round_res = min_sampling_covering_ellipsoid_rounding<WalkType, MT, VT>(P, InnerBall, walkL, rng);
46-
} else if (method_rcpp.compare(std::string("svd")) == 0) {
46+
} else if (method_rcpp.compare(std::string("isotropy")) == 0) {
4747
round_res = svd_rounding<WalkType, MT, VT>(P, InnerBall, walkL, rng);
4848
} else {
4949
throw Rcpp::exception("Unknown method!");
@@ -54,7 +54,7 @@ std::tuple<MT, VT, NT> apply_rounding(Polytope &P,
5454
//' Internal rcpp function for the rounding of a convex polytope
5555
//'
5656
//' @param P A convex polytope (H- or V-representation or zonotope).
57-
//' @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{'svd'} for the method based on svd decomposition. The default method is \code{'min_ellipsoid'} for all the representations.
57+
//' @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.
5858
//' @param seed Optional. A fixed seed for the number generator.
5959
//'
6060
//' @keywords internal
@@ -76,7 +76,7 @@ Rcpp::List rounding (Rcpp::Reference P,
7676
typedef Eigen::Matrix<NT,Eigen::Dynamic,Eigen::Dynamic> MT;
7777

7878
unsigned int n = P.field("dimension"), walkL = 2, type = P.field("type");
79-
std::string method_rcpp = std::string("min_ellipsoid");
79+
std::string method_rcpp = std::string("isotropy");
8080
if(method.isNotNull()) {
8181
method_rcpp = Rcpp::as<std::string>(method);
8282
if (method_rcpp.compare(std::string("max_ellipsoid")) == 0 && type != 1) {

0 commit comments

Comments
 (0)