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 bcfd7a5
Show file tree
Hide file tree
Showing 16 changed files with 89 additions and 626 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Version: 1.2.0
Date: 2024-02-29
Maintainer: Vissarion Fisikopoulos <[email protected]>
Depends: Rcpp (>= 0.12.17)
Imports: methods, stats
Imports: methods, stats, Matrix
LinkingTo: Rcpp, RcppEigen, BH
Suggests: testthat
Encoding: UTF-8
Expand Down
4 changes: 1 addition & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +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)
export(psrf_univariate)
Expand All @@ -30,10 +28,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
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
# volesti 1.2.0

- New functions: dinvweibull_with_loc, ess, estimtate_lipschitz_constant, gen_birkhoff, geweke
ode_solve, pinvweibull_with_loc, psrf_multivariate, psrf_univariate, raftery
pinvweibull_with_loc, psrf_multivariate, psrf_univariate, raftery

- New features in sample_points function:
a) new walks: i) Dikin walk, ii) Vaidya walk, iii) John walk,
Expand Down
49 changes: 31 additions & 18 deletions R/HpolytopeSparseClass.R
Original file line number Diff line number Diff line change
@@ -1,26 +1,41 @@
#' An R class to represent an H-polytope
#' 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{b}{An \eqn{m}-dimensional vector b.}
#' \item{bineq}{An \eqn{m}-dimensional vector for the ineqaulities.}
#'
#' \item{volume}{The volume of the polytope if it is known, \eqn{NaN} otherwise by default.}
#' \item{Aineq}{An \eqn{m'\times d} sparse numerical matrix for the equalities.}
#'
#' \item{type}{A character with default value 'Hpolytope', to declare the representation of the polytope.}
#' \item{bineq}{An \eqn{m'}-dimensional vector for the eqaulities.}
#'
#' \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)
#' @importFrom "Matrix" "CsparseMatrix"
HpolytopeSparse <- setClass (
# Class name
"HpolytopeSparse",
Expand All @@ -33,19 +48,17 @@ HpolytopeSparse <- setClass (
beq = "numeric",
lb = "numeric",
ub = "numeric",
dimension = "numeric",
type = "character"
),

# Initializing slots
prototype = list(
Aineq = as(0, "CsparseMatrix"),
bineq = as.numeric(NULL),
Aeq = as(0, "CsparseMatrix"),
beq = as.numeric(NULL),
lb = as.numeric(NULL),
ub = as.numeric(NULL),
dimension = as.numeric(NaN),
Aineq = Matrix::sparseMatrix(i = integer(0), j = integer(0), x = double(0), dims = c(0, 0)),
bineq = numeric(0),
Aeq = Matrix::sparseMatrix(i = integer(0), j = integer(0), x = double(0), dims = c(0, 0)),
beq = numeric(0),
lb = numeric(0),
ub = numeric(0),
type = "HpolytopeSparse"
)
)
62 changes: 0 additions & 62 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -187,30 +187,6 @@ load_sdpa_format_file <- function(input_file = NULL) {
.Call(`_volesti_load_sdpa_format_file`, input_file)
}

#' 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
#' F <- function (x) (-x)
#' initial_conditions <- list("x_1" = c(0), "x_2" = c(1))
#' states <- ode_solve(dimension=1, n=1000, F=F, initial_time=0, step_size=0.01, order=2, method="leapfrog", initial_conditions=initial_conditions, domains = list())
#'
#' @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.
Expand Down Expand Up @@ -384,44 +360,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.

31 changes: 0 additions & 31 deletions man/examples/simple_ode.R

This file was deleted.

34 changes: 0 additions & 34 deletions man/examples/simple_ode_truncated.R

This file was deleted.

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

This file was deleted.

49 changes: 0 additions & 49 deletions man/ode_solve.Rd

This file was deleted.

Loading

0 comments on commit bcfd7a5

Please sign in to comment.