Convex Optimization in R

What is CVXR?

CVXR is an R package that 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 form using graph implementations and passed to a quadratic solver such as OSQP, or a cone solver such as ECOS or SCS, or even commericial solvers, if installed.

Citing CVXR

CVXR is published in Fu, Narasimhan, and Boyd (2020) <doi:10.18637/jss.v094.i14>. A BibTeX citation entry using citation key cvxr2020 is below.

@Article{cvxr2020,
    title = {{CVXR}: An {R} Package for Disciplined Convex Optimization},
    author = {Anqi Fu and Balasubramanian Narasimhan and Stephen Boyd},
    journal = {Journal of Statistical Software},
    year = {2020},
    volume = {94},
    number = {14},
    pages = {1--34},
    doi = {10.18637/jss.v094.i14},
  }

Supported Solvers

Solver R package LP QP SOCP SDP EXP MIP
CBC rcbc
GLPK Rglpk
GLPK_MI Rglpk
OSQP osqp
CPLEX Rcplex
ECOS ECOSolveR
ECOS_BB ECOSolveR
GUROBI gurobi
MOSEK Rmosek
SCS scs

For more detail, see Using other solvers.

News

For the latest news, please see the Package Documentation.

CVXR continues to be developed on Github. Version 1.0 was a major release implementing the reductions framework described in Agrawal et al. (2018). More details of all the changes can be found in What’s new in 1.0.

Installing CVXR

CVXR is installed like any other R package from CRAN.

Documentation

Two videos provide a good starting point:

Materials form our useR! 2019 including exercises and solutions are available as a bookdown project. Follow the instructions in the README.

An introductory vignette is installed with the package and can be viewed using vignette("cvxr_intro", package = "CVXR").

A large set of examples, many ported from CVXPY, are available on this site in the Examples section.

Acknowledgements

We are grateful to Steven Diamond, John Miller, and Paul Kunsberg Rosenfield for their contributions to the software’s development. In particular, we are indebted to Steven Diamond for his work on CVXPY. Most of CVXR’s code, documentation, and examples were ported from his Python library.

About this site

Much of the documentation on this site was modified from CVXPY in a semi-automated way.

This site was constructed using R markdown documents, the wonderful blogdown package by Yihui Xie, and the Hugo Alabaster theme. The pages are served out of the CVXR docs repository.

References

Agrawal, Akshay, Robin Verschueren, Steven Diamond, and Stephen Boyd. 2018. “A Rewriting System for Convex Optimization Problems.” Journal of Control and Decision 5 (1): 42–60. https://doi.org/10.1080/23307706.2017.1397554.

Fu, Anqi, Balasubramanian Narasimhan, and Stephen Boyd. 2020. “CVXR: An R Package for Disciplined Convex Optimization.” Journal of Statistical Software 94 (14): 1–34. https://doi.org/10.18637/jss.v094.i14.