Skip to content

Commit

Permalink
Update Rd files and remove unused
Browse files Browse the repository at this point in the history
  • Loading branch information
vfisikop committed Mar 5, 2024
1 parent 4ae6dd8 commit 8efcdea
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 252 deletions.
3 changes: 1 addition & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export(gen_simplex)
export(gen_skinny_cube)
export(geweke)
export(inner_ball)
export(loadSdpaFormatFile)
export(ode_solve)
export(pinvweibull_with_loc)
export(psrf_multivariate)
Expand All @@ -30,10 +29,10 @@ export(rotate_polytope)
export(round_polytope)
export(sample_points)
export(volume)
export(writeSdpaFormatFile)
export(write_sdpa_format_file)
export(zonotope_approximation)
exportClasses(Hpolytope)
exportClasses(HpolytopeSparse)
exportClasses(Spectrahedron)
exportClasses(Vpolytope)
exportClasses(VpolytopeIntersection)
Expand Down
38 changes: 26 additions & 12 deletions R/HpolytopeSparseClass.R
Original file line number Diff line number Diff line change
@@ -1,26 +1,42 @@
#' An R class to represent an H-polytope
library(Matrix)

#' An R class to represent an H-polytope defined by a sparse matrix
#'
#' An 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}.
#' A sparse 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}, where $A$ is sparse.
#'
#' \describe{
#' \item{A}{An \eqn{m\times d} numerical matrix.}
#' \item{Aineq}{An \eqn{m\times d} sparse numerical matrix for the inequalities.}
#'
#' \item{bineq}{An \eqn{m}-dimensional vector for the ineqaulities.}
#'
#' \item{b}{An \eqn{m}-dimensional vector b.}
#' \item{Aineq}{An \eqn{m'\times d} sparse numerical matrix for the equalities.}
#'
#' \item{volume}{The volume of the polytope if it is known, \eqn{NaN} otherwise by default.}
#' \item{bineq}{An \eqn{m'}-dimensional vector for the eqaulities.}
#'
#' \item{type}{A character with default value 'Hpolytope', to declare the representation of the polytope.}
#' \item{lb}{\eqn{d}-dimensional vector lb.}
#'
#' \item{ub}{\eqn{d}-dimensional vector ub.}
#'
#' \item{type}{A character with default value 'HpolytopeSparse', to declare the representation of the polytope.}
#' }
#'
#' @examples
#' A = matrix(c(-1,0,0,-1,1,1), ncol=2, nrow=3, byrow=TRUE)
#' b = c(0,0,1)
#' P = Hpolytope(A = A, b = b)
#' library(Matrix)
#' bineq=c(10,10,10,10,10)
#' 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=(0)
#' Aeq = matrix(, nrow=0, ncol=2, byrow = TRUE)
#' Aeq=as( Aeq, 'dgCMatrix' )
#' lb=-100000*c(1,1);
#' ub=100000*c(1,1);
#' P <- HpolytopeSparse(Aineq = Aineq, bineq = bineq, Aeq = Aeq, beq = beq, lb = lb, ub = ub)
#'
#' @name HpolytopeSparse-class
#' @rdname HpolytopeSparse-class
#' @exportClass HpolytopeSparse
library(Matrix)
HpolytopeSparse <- setClass (
# Class name
"HpolytopeSparse",
Expand All @@ -33,7 +49,6 @@ HpolytopeSparse <- setClass (
beq = "numeric",
lb = "numeric",
ub = "numeric",
dimension = "numeric",
type = "character"
),

Expand All @@ -45,7 +60,6 @@ HpolytopeSparse <- setClass (
beq = as.numeric(NULL),
lb = as.numeric(NULL),
ub = as.numeric(NULL),
dimension = as.numeric(NaN),
type = "HpolytopeSparse"
)
)
38 changes: 0 additions & 38 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -384,44 +384,6 @@ sample_points <- function(P, n, random_walk = NULL, distribution = NULL, seed =
.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(matrices = 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.
Expand Down
42 changes: 42 additions & 0 deletions man/HpolytopeSparse-class.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 0 additions & 21 deletions man/loadSdpaFormatFile.Rd

This file was deleted.

14 changes: 12 additions & 2 deletions man/sample_points.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 0 additions & 34 deletions man/writeSdpaFormatFile.Rd

This file was deleted.

2 changes: 1 addition & 1 deletion src/Makevars
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PKG_CPPFLAGS=-Iexternal -Iexternal/lpSolve/src -Iexternal/minimum_ellipsoid -Ivolesti/include -Ivolesti/include/convex_bodies/spectrahedra
PKG_CXXFLAGS= -DBOOST_NO_AUTO_PTR -DDISABLE_NLP_ORACLES -Wno-deprecated-declarations -lm -ldl -Wno-ignored-attributes
PKG_CXXFLAGS= -DBOOST_NO_AUTO_PTR -DDISABLE_NLP_ORACLES

PKG_LIBS=-Lexternal/lpSolve/src -llp_solve -Lexternal/PackedCSparse/qd -lqd $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)

Expand Down
25 changes: 0 additions & 25 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,29 +223,6 @@ BEGIN_RCPP
return rcpp_result_gen;
END_RCPP
}
// writeSdpaFormatFile
void writeSdpaFormatFile(Rcpp::Reference spectrahedron, Rcpp::Nullable<Rcpp::NumericVector> objectiveFunction, Rcpp::Nullable<std::string> outputFile);
RcppExport SEXP _volesti_writeSdpaFormatFile(SEXP spectrahedronSEXP, SEXP objectiveFunctionSEXP, SEXP outputFileSEXP) {
BEGIN_RCPP
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< Rcpp::Reference >::type spectrahedron(spectrahedronSEXP);
Rcpp::traits::input_parameter< Rcpp::Nullable<Rcpp::NumericVector> >::type objectiveFunction(objectiveFunctionSEXP);
Rcpp::traits::input_parameter< Rcpp::Nullable<std::string> >::type outputFile(outputFileSEXP);
writeSdpaFormatFile(spectrahedron, objectiveFunction, outputFile);
return R_NilValue;
END_RCPP
}
// loadSdpaFormatFile
Rcpp::List loadSdpaFormatFile(Rcpp::Nullable<std::string> inputFile);
RcppExport SEXP _volesti_loadSdpaFormatFile(SEXP inputFileSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< Rcpp::Nullable<std::string> >::type inputFile(inputFileSEXP);
rcpp_result_gen = Rcpp::wrap(loadSdpaFormatFile(inputFile));
return rcpp_result_gen;
END_RCPP
}
// volume
Rcpp::List volume(Rcpp::Reference P, Rcpp::Nullable<Rcpp::List> settings, Rcpp::Nullable<std::string> rounding);
RcppExport SEXP _volesti_volume(SEXP PSEXP, SEXP settingsSEXP, SEXP roundingSEXP) {
Expand Down Expand Up @@ -303,8 +280,6 @@ static const R_CallMethodDef CallEntries[] = {
{"_volesti_rotating", (DL_FUNC) &_volesti_rotating, 3},
{"_volesti_rounding", (DL_FUNC) &_volesti_rounding, 3},
{"_volesti_sample_points", (DL_FUNC) &_volesti_sample_points, 5},
{"_volesti_writeSdpaFormatFile", (DL_FUNC) &_volesti_writeSdpaFormatFile, 3},
{"_volesti_loadSdpaFormatFile", (DL_FUNC) &_volesti_loadSdpaFormatFile, 1},
{"_volesti_volume", (DL_FUNC) &_volesti_volume, 3},
{"_volesti_write_sdpa_format_file", (DL_FUNC) &_volesti_write_sdpa_format_file, 3},
{"_volesti_zono_approx", (DL_FUNC) &_volesti_zono_approx, 4},
Expand Down
Loading

0 comments on commit 8efcdea

Please sign in to comment.