diff --git a/.Rbuildignore b/.Rbuildignore index 5e48a56..3e74ce9 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -5,6 +5,7 @@ osqp_sources/CMakeCache.txt$ osqp_sources/\.bumpversion.cfg$ ^.*editorconfig$ ^.*git$ +^.*valgrind-suppress.supp$ cmake_uninstall.cmake$ cmake_install.cmake$ osqp-targets.cmake$ @@ -19,3 +20,4 @@ CMakeDirectoryInformation.cmake libosqp.a ^appveyor\.yml$ ^cran_comments\.md$ +^CRAN-RELEASE$ diff --git a/.travis.yml b/.travis.yml index 99a672a..7e729e2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: r + r: - release - oldrel @@ -40,3 +41,6 @@ matrix: - os: osx r: oldrel disable_homebrew: false + allow_failures: + - r: oldrel + os: linux diff --git a/DESCRIPTION b/DESCRIPTION index 0ee0492..000b711 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: osqp Type: Package Title: Quadratic Programming Solver using the 'OSQP' Library -Version: 0.5.0 -Date: 2018-12-09 +Version: 0.6.0 +Date: 2019-09-02 Authors@R: c(person("Bartolomeo", "Stellato", email = "bartolomeo.stellato@gmail.com", role = c("cre", "aut", "ctb", "cph")), person("Goran", "Banjac", role = c("aut", "ctb", "cph")), person("Paul", "Goulart", role = c("aut", "ctb", "cph")), person("Stephen", "Boyd", role = c("aut", "ctb", "cph")), person("Eric", "Anderson", role=c("ctb"))) Copyright: file COPYRIGHT Description: Provides bindings to the 'OSQP' solver. The 'OSQP' solver is a numerical optimization package or solving convex quadratic programs written in 'C' and based on the alternating direction method of multipliers, 'ADMM'. B. Stellato, G. Banjac, P. Goulart, A. Bemporad, S. Boyd (2018) . @@ -13,6 +13,6 @@ RoxygenNote: 6.1.1 Collate: 'RcppExports.R' 'osqp-package.R' 'solve.R' 'osqp.R' 'params.R' NeedsCompilation: yes -Packaged: 2018-12-09 20:32:49 UTC -Date/Publication: 2018-12-09 13:10:50 UTC +Packaged: 2019-09-02 00:00:00 UTC +Date/Publication: 2019-09-02 00:00:00 UTC Suggests: testthat diff --git a/NAMESPACE b/NAMESPACE index 9135a6d..6f35ad2 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -6,6 +6,7 @@ export(osqp) export(osqpSettings) export(solve_osqp) importFrom(Matrix,sparseMatrix) +importFrom(Matrix,triu) importFrom(R6,R6Class) importFrom(Rcpp,sourceCpp) importFrom(methods,as) diff --git a/NEWS.md b/NEWS.md index 0371ba2..157bbf3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# Version 0.6.0 (2 September 2019) OSQP 0.6.0 + +* Updated OSQP to version 0.6.0 + # Version 0.5.0 (10 December 2018) OSQP 0.5.0 * Updated OSQP to version 0.5.0 diff --git a/R/osqp.R b/R/osqp.R index 425735d..ed0c9fe 100644 --- a/R/osqp.R +++ b/R/osqp.R @@ -2,13 +2,14 @@ #' OSQP Solver object #' #' @importFrom Matrix sparseMatrix +#' @importFrom Matrix triu #' @importFrom methods as #' @importFrom R6 R6Class #' @param P,A sparse matrices of class dgCMatrix or coercible into such, with P positive semidefinite. #' @param q,l,u Numeric vectors, with possibly infinite elements in l and u #' @param pars list with optimization parameters, conveniently set with the function #' \code{\link{osqpSettings}}. For \code{osqpObject$UpdateSettings(newPars)} only a subset of the settings -#' can be updated once the problem has been initnialized. +#' can be updated once the problem has been initialized. #' @seealso \code{\link{solve_osqp}} #' @section Usage: #' \preformatted{model = osqp(P=NULL, q=NULL, A=NULL, l=NULL, u=NULL, pars=osqpSettings()) @@ -76,10 +77,11 @@ osqp = function(P=NULL, q=NULL, A=NULL, l=NULL, u=NULL, pars = osqpSettings()) { n = dim(P)[1] - if (is.null(P)) + if (is.null(P)){ P = sparseMatrix(integer(), integer(), x = numeric(), dims = c(n, n)) - else - P = as(P, "dgCMatrix") + } else { + P = triu(as(P, "dgCMatrix")) + } if (is.null(q)) q = numeric(n) diff --git a/R/params.R b/R/params.R index 15a8326..472d879 100644 --- a/R/params.R +++ b/R/params.R @@ -15,7 +15,7 @@ #' @param delta regularization parameter for polish #' @param polish boolean, polish ADMM solution #' @param polish_refine_iter iterative refinement steps in polish -#' @param verbose boolean, write out progres +#' @param verbose boolean, write out progress #' @param scaled_termination boolean, use scaled termination criteria #' @param check_termination integer, check termination interval. If 0, termination checking is disabled #' @param warm_start boolean, warm start @@ -60,4 +60,3 @@ checkpar = function(l, r) { return (r) l } - diff --git a/R/solve.R b/R/solve.R index 7e3ac63..7d1c918 100644 --- a/R/solve.R +++ b/R/solve.R @@ -4,6 +4,7 @@ #' s.t. \deqn{l_i < (A x)_i < u_i}{li < (A x)i < ui} #' for real matrices P (nxn, positive semidefinite) and A (mxn) with m number of constraints #' @param P,A sparse matrices of class dgCMatrix or coercible into such, with P positive semidefinite. +#' Only the upper triangular part of P will be used. #' @param q,l,u Numeric vectors, with possibly infinite elements in l and u #' @param pars list with optimization parameters, conveniently set with the function \code{osqpSettings} #' @return A list with elements x (the primal solution), y (the dual solution), prim_inf_cert, @@ -40,4 +41,3 @@ solve_osqp <- function(P=NULL, q=NULL, A=NULL, l=NULL, u=NULL, pars = osqpSettin model = osqp(P, q, A, l, u, pars) model$Solve() } - diff --git a/man/osqp.Rd b/man/osqp.Rd index c4d6091..a1c04bf 100644 --- a/man/osqp.Rd +++ b/man/osqp.Rd @@ -14,7 +14,7 @@ osqp(P = NULL, q = NULL, A = NULL, l = NULL, u = NULL, \item{pars}{list with optimization parameters, conveniently set with the function \code{\link{osqpSettings}}. For \code{osqpObject$UpdateSettings(newPars)} only a subset of the settings -can be updated once the problem has been initnialized.} +can be updated once the problem has been initialized.} } \value{ An R6-object of class "osqp_model" with methods defined which can be further diff --git a/man/osqpSettings.Rd b/man/osqpSettings.Rd index 4da93dc..470abe1 100644 --- a/man/osqpSettings.Rd +++ b/man/osqpSettings.Rd @@ -38,7 +38,7 @@ osqpSettings(rho = 0.1, sigma = 1e-06, max_iter = 4000L, \item{polish_refine_iter}{iterative refinement steps in polish} -\item{verbose}{boolean, write out progres} +\item{verbose}{boolean, write out progress} \item{scaled_termination}{boolean, use scaled termination criteria} diff --git a/man/solve_osqp.Rd b/man/solve_osqp.Rd index ac5d16d..a5395e8 100644 --- a/man/solve_osqp.Rd +++ b/man/solve_osqp.Rd @@ -8,7 +8,8 @@ solve_osqp(P = NULL, q = NULL, A = NULL, l = NULL, u = NULL, pars = osqpSettings()) } \arguments{ -\item{P, A}{sparse matrices of class dgCMatrix or coercible into such, with P positive semidefinite.} +\item{P, A}{sparse matrices of class dgCMatrix or coercible into such, with P positive semidefinite. +Only the upper triangular part of P will be used.} \item{q, l, u}{Numeric vectors, with possibly infinite elements in l and u} diff --git a/src/osqp/Makefile b/src/osqp/Makefile index 49becec..66dc412 100644 --- a/src/osqp/Makefile +++ b/src/osqp/Makefile @@ -28,6 +28,7 @@ OSQP_SOURCES = \ $(OSQP_SRC_DIR)/src/auxil.c \ $(OSQP_SRC_DIR)/src/cs.c \ $(OSQP_SRC_DIR)/src/ctrlc.c \ +$(OSQP_SRC_DIR)/src/error.c \ $(OSQP_SRC_DIR)/src/kkt.c \ $(OSQP_SRC_DIR)/src/lin_alg.c \ $(OSQP_SRC_DIR)/src/lin_sys.c \ diff --git a/src/osqp_solve_interface.cpp b/src/osqp_solve_interface.cpp index e464d3c..d8c94f1 100644 --- a/src/osqp_solve_interface.cpp +++ b/src/osqp_solve_interface.cpp @@ -24,7 +24,6 @@ SEXP osqpSetup(const S4& P, const NumericVector& q, const S4& A, const NumericVe IntegerVector dimP = P.slot("Dim"); - IntegerVector dimA = A.slot("Dim"); int n = dimP[0]; int m = dimA[0]; @@ -55,9 +54,10 @@ SEXP osqpSetup(const S4& P, const NumericVector& q, const S4& A, const NumericVe data->l = lvec.data(); data->u = uvec.data(); + OSQPWorkspace* workp; + osqp_setup(&workp, data.get(), settings.get()); - Rcpp::XPtr work(osqp_setup(data.get(), settings.get())); - + Rcpp::XPtr work(workp); return work; } diff --git a/src/osqp_sources b/src/osqp_sources index a02dc21..0baddd3 160000 --- a/src/osqp_sources +++ b/src/osqp_sources @@ -1 +1 @@ -Subproject commit a02dc213c864d880131f5a11e150e7e37e85d689 +Subproject commit 0baddd36bd57ec1cace0a52c6dd9663e8f16df0a diff --git a/tests/testthat/test-solve-basic-qp.R b/tests/testthat/test-solve-basic-qp.R index f968c89..5c87ea2 100644 --- a/tests/testthat/test-solve-basic-qp.R +++ b/tests/testthat/test-solve-basic-qp.R @@ -13,8 +13,8 @@ define_simple_qp <- function(){ l <- rep_len(-Inf, 5) settings <- osqpSettings(verbose = FALSE, - eps_rel = 1e-09, - eps_abs = 1e-09) + eps_rel = 1e-05, + eps_abs = 1e-05) # Create OSQP model model <- osqp(P, q, A, l, u, settings) @@ -82,4 +82,3 @@ test_that("Update bounds QP", { -80.0890909023583, 1e-03) }) -