Skip to content

Commit

Permalink
version1.1.2-2 (#168)
Browse files Browse the repository at this point in the history
* remove loadSdpaFormatFile function

* update the description file and the news_md file

* Make load_sdpa_format_file internal (#27)

* update the Rd files and the namespace

* update the description file

Co-authored-by: Vissarion Fisikopoulos <fisikop@gmail.com>
  • Loading branch information
TolisChal and vissarion authored Jul 20, 2021
1 parent 0ccd791 commit 276710b
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 120 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/R-CDM-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ jobs:
fail-fast: false
matrix:
config:
- {os: macOS-latest, r: 'devel'}
# - {os: macOS-latest, r: 'devel'}
- {os: macOS-latest, r: 'release'}
- {os: windows-latest, r: 'devel'}
# - {os: windows-latest, r: 'devel'}
- {os: windows-latest, r: 'release'}
# - {os: ubuntu-latest, r: 'devel'} # error in "Run r-lib/actions/setup-r@master"
# - {os: ubuntu-latest, r: 'release'} ##[error]Error in library(devtools) : there is no package called ‘devtools’
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions R-proj/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Description: Provides an R interface for 'volesti' C++ package. 'volesti' comput
(a.k.a. zonotopes). There are three algorithms for volume estimation as well as algorithms
for sampling, rounding and rotating polytopes. Moreover, 'volesti' provides algorithms for
estimating copulas useful in computational finance.
Version: 1.1.2
Date: 2020-10-18
Version: 1.1.2-2
Date: 2021-07-14
Maintainer: Vissarion Fisikopoulos <vissarion.fisikopoulos@gmail.com>
Depends: Rcpp (>= 0.12.17)
Imports: methods, stats
Expand Down
4 changes: 1 addition & 3 deletions R-proj/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ export(gen_rand_zonotope)
export(gen_simplex)
export(gen_skinny_cube)
export(inner_ball)
export(loadSdpaFormatFile)
export(load_sdpa_format_file)
export(readSdpaFormatFile)
export(read_sdpa_format_file)
export(rotate_polytope)
export(round_polytope)
export(sample_points)
Expand Down
27 changes: 4 additions & 23 deletions R-proj/R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,13 @@ inner_ball <- function(P) {
.Call(`_volesti_inner_ball`, P)
}

#' Read a SDPA format file
#' An internal Rccp function to read a SDPA format file
#'
#' @param input_file 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"
#' @keywords internal
#'
#' @examples
#' path = system.file('extdata', package = 'volesti')
#' l = load_sdpa_format_file(paste0(path,'/sdpa_n2m3.txt'))
#'
#' @export
#' @return A list with two named items: an item "matrices" which is a list of the matrices and an vector "objFunction"
load_sdpa_format_file <- function(input_file = NULL) {
.Call(`_volesti_load_sdpa_format_file`, input_file)
}
Expand Down Expand Up @@ -302,7 +298,7 @@ volume <- function(P, settings = NULL, rounding = FALSE) {
#' 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);
#' S = Spectrahedron(matrices = lmi)
#' objFunction = c(1,1)
#' write_sdpa_format_file(S, objFunction, "output.txt")
#' }
Expand All @@ -311,21 +307,6 @@ write_sdpa_format_file <- function(spectrahedron, objective_function, output_fil
invisible(.Call(`_volesti_write_sdpa_format_file`, spectrahedron, objective_function, output_file))
}

#' 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)
}

#' An internal Rccp function for the over-approximation of a zonotope
#'
#' @param Z A zonotope.
Expand Down
6 changes: 3 additions & 3 deletions R-proj/R/read_sdpa_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#'
#' @examples
#' path = system.file('extdata', package = 'volesti')
#' l = readSdpaFormatFile(paste0(path,'/sdpa_n2m3.txt'))
#' l = read_sdpa_format_file(paste0(path,'/sdpa_n2m3.txt'))
#' Spectrahedron = l$spectrahedron
#' objFunction = l$objFunction
#' @export
Expand All @@ -18,8 +18,8 @@
#' @importFrom Rcpp loadModule
#' @importFrom "methods" "new"
#' @exportPattern "^[[:alpha:]]+"
readSdpaFormatFile <- function(path){
l = loadSdpaFormatFile(path)
read_sdpa_format_file <- function(path){
l = load_sdpa_format_file(path)
S = Spectrahedron(matrices = l$matrices)

return(list("spectrahedron"=S, "objFunction"= l$objFunction))
Expand Down
22 changes: 0 additions & 22 deletions R-proj/man/loadSdpaFormatFile.Rd

This file was deleted.

10 changes: 3 additions & 7 deletions R-proj/man/load_sdpa_format_file.Rd

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

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

10 changes: 3 additions & 7 deletions R-proj/src/load_sdpa_format_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,13 @@
#include "convex_bodies/spectrahedra/spectrahedron.h"
#include "SDPAFormatManager.h"

//' Read a SDPA format file
//' An internal Rccp function to read a SDPA format file
//'
//' @param input_file 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"
//' @keywords internal
//'
//' @examples
//' path = system.file('extdata', package = 'volesti')
//' l = load_sdpa_format_file(paste0(path,'/sdpa_n2m3.txt'))
//'
//' @export
//' @return A list with two named items: an item "matrices" which is a list of the matrices and an vector "objFunction"
// [[Rcpp::export]]
Rcpp::List load_sdpa_format_file(Rcpp::Nullable<std::string> input_file = R_NilValue) {

Expand Down
47 changes: 0 additions & 47 deletions R-proj/src/write_sdpa_format_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,50 +68,3 @@ void write_sdpa_format_file(Rcpp::Reference spectrahedron,
return;
}



//' 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
// [[Rcpp::export]]
Rcpp::List loadSdpaFormatFile(Rcpp::Nullable<std::string> inputFile = R_NilValue) {

typedef double NT;
typedef Eigen::Matrix<NT, Eigen::Dynamic, 1> VT;
typedef Eigen::Matrix<NT, Eigen::Dynamic, Eigen::Dynamic> MT;
typedef Cartesian<NT> Kernel;
typedef typename Kernel::Point Point;
typedef boost::mt19937 RNGType;
typedef LMI<NT, MT, VT> LMI;
typedef Spectrahedron<NT, MT, VT> Spectrahedron;

Spectrahedron _spectrahedron;
Point c;

// open stream
std::ifstream os;
os.open(Rcpp::as<std::string> (inputFile),std::ifstream::in);

// read file
SdpaFormatManager<NT> sdpaFormatManager;
sdpaFormatManager.loadSDPAFormatFile(os, _spectrahedron, c);

std::vector<MT> matrices = _spectrahedron.getLMI().getMatrices();

// return spectrahedron and objective function
Rcpp::List _matrices;

for (auto matrix : matrices)
_matrices.push_back(Rcpp::wrap(matrix));

Rcpp::List retList = Rcpp::List::create(Rcpp::Named("matrices") = _matrices , Rcpp::_["objFunction"] = Rcpp::wrap(c.getCoefficients()));
return Rcpp::wrap(retList);
}
11 changes: 11 additions & 0 deletions cran_gen/NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,14 @@

* Fix CRAN warnings about deprecated use of ftime

# volesti 1.1.2

- Improve functionality of R function.
- Use lower case and "_" separated names for the volesti's functions.
- Use R classes for the convex polytopes

# volesti 1.1.2-2

- Remove `loadSdpaFormatFile()` and `readSdpaFormatFile()` functions.


0 comments on commit 276710b

Please sign in to comment.