Disciplined Convex Optimization

An object-oriented modeling language for disciplined convex programming (DCP) as described in Fu, Narasimhan, and Boyd (2020, ). It allows the user to formulate convex optimization problems in a natural way following mathematical convention and DCP rules. The system analyzes the problem, verifies its convexity, converts it into a canonical form, and hands it off to an appropriate solver to obtain the solution. Interfaces to solvers on CRAN and elsewhere are provided, both commercial and open source.

Travis-CI BuildStatus CRAN_Status_Badge CoverageStatus

CVXR provides an object-oriented modeling language for convex optimization, similar to CVX, CVXPY, YALMIP, and Convex.jl. It allows the user to formulate convex optimization problems in a natural mathematical syntax rather than the restrictive standard form required by most solvers. The user specifies an objective and set of constraints by combining constants, variables, and parameters using a library of functions with known mathematical properties. CVXR then applies signed disciplined convex programming (DCP) to verify the problem’s convexity. Once verified, the problem is converted into standard conic form using graph implementations and passed to a cone solver such as ECOS or SCS.

CVXR includes several open source solvers in addition to the default ECOS and SCS. Recent versions (0.97+) also include support for commercial solvers such as MOSEK and GUROBI.


This package is now released on CRAN, so you can install the current released version as you would any other package for R, version 3.4 and higher. (CVXR is known to work with earlier versions of R too, but we don’t check our releases against older versions of R.)

install.packages('CVXR', repos = "https://CRAN.R-project.org")

Development versions can be installed from the Github repository assuming you have the development tools for R available, including the C compilers etc. Execute:



A number of tutorial examples are available on the CVXR website.


CVXR 0.99-5

  • Bug fix for LogSumExp atom. This should address the issue reported on StackOverflow
  • Require ECOSolveR version 0.5.1 and above to avoid convolution example failure on 32-bit platforms.

CVXR 0.99-4

  • Updated tests to check against scs version 1.2.3, which now returns optimal rather than optimal_inaccurrate as it did earlier (test-g01-non_optimal.R#35).

  • Some cleanup of manual tests. New SCS returns slightly different values for Sigma in manual test (test-vignette#646) for worst-case covariance example.

CVXR 0.99-3

  • Bug fix to MOSEK and GUROBI solver interfaces; dimensions now converted to expected python types.
  • Sanitized src directory: proper naming of CVXR header to include while compiling attributes with Rcpp.

CVXR 0.99-2

  • Typo fixes to URLs.

CVXR 0.99-1

  • Bug fix: Updated python glue for both version 2 and 3 (gurobiglue.py)
  • Bug fix: Workaround for zero extent sparse matrices in R not being handled by reticulate (mosekglue.py)

CVXR 0.99

  • Bug fix: duplicated integer and boolean indices.
  • Bug fix: correct typo in constraint specification to GLPK.
  • Added tutorial articles based on v0.99 to CVXR website on using other solvers, integer programming, MOSEK and GUROBI examples.

CVXR 0.98-1

  • Minor typographical fixes.

CVXR 0.98

  • Dropped delay_load parameter dropped in reticulate::import_from_path, per changes in reticulate.

  • Cleaned up hooks into reticulate for commercial solvers.

CVXR 0.97-1

  • Minor typo and documentation fixes.

CVXR 0.97

  • Added LPSOLVE via lpSolveAPI
  • Added GLPK via Rglpk
  • Added MOSEK
  • Added GUROBI
  • Bug fix: issue #25. All CVXR expressions retain dimensions. Culprit was drop = FALSE (in function Index.get_special_slice) as suspected.

CVXR 0.96

  • Added a note that CVXR can probably be compiled from source for earlier versions of R. This is issue #24

  • Using pkgdown. This also addresses issue #23

  • Bug fix: issue #28 Function intf_sign (interface.R) was unnecessarily using a tolerance parameter, now eliminated.

CVXR 0.95

  • Updated Solver.solve to adapt to new ECOSolveR. Require version 0.4 of ECOSolveR now.

  • Updated unpack_results to behave exactly like in CVXPY. Added documentation and testthat tests. Documented in Getting Faster Results article.

CVXR 0.94-4

  • First CRAN release 2017-11-20.

CVXR pre-0.94-4

  • Several wrong turns and much hand-wringing. Complete rewrite in preparation for release.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


1.0-9 by Anqi Fu, 9 months ago

https://cvxr.rbind.io, https://www.cvxgrp.org/CVXR/

Report a bug at https://github.com/cvxgrp/CVXR/issues

Browse source code at https://github.com/cran/CVXR

Authors: Anqi Fu [aut, cre] , Balasubramanian Narasimhan [aut] , David W Kang [aut] , Steven Diamond [aut] , John Miller [aut] , Stephen Boyd [ctb] , Paul Kunsberg Rosenfield [ctb]

Documentation:   PDF Manual  

Task views: Optimization and Mathematical Programming

Apache License 2.0 | file LICENSE license

Imports methods, R6, Matrix, Rcpp, bit64, gmp, Rmpfr, ECOSolveR, scs, stats, osqp

Suggests knitr, rmarkdown, testthat, nnls, slam, covr

Enhances Rcplex, gurobi, rcbc, cccp, Rmosek, Rglpk

Linking to Rcpp, RcppEigen

Imported by LavaCvxr, PlackettLuce, Rdimtools, Riemann, SIHR, WRI, ecpc, fairml, filling, kantorovich.

Depended on by tramnet.

Suggested by portfolioBacktest.

Enhanced by starnet.

See at CRAN