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. This version uses the S7 object system for improved performance and maintainability.


CVXR

R-CMD-check CRANstatus Downloads

CVXR provides an object-oriented modeling language for convex optimization, similar to CVXPY, CVX, YALMIP, and Convex.jl. It allows you to formulate convex optimization problems in natural mathematical syntax rather than the restrictive standard form required by most solvers. You specify an objective and a 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 and passed to an appropriate backend solver.

This version is a ground-up rewrite built on the S7 object system, designed to mirror CVXPY 1.9.1 closely. It is ~4–5x faster than the previous S4-based release, ships with 15 solvers (4 built-in), and supports DCP, DGP, DQCP, disciplined nonlinear programming (DNLP), complex variables, mixed-integer programming, warm-starting, and a derivative / sensitivity-analysis API.

For tutorials, worked examples, and the full story, visit the CVXR website.

Installation

Install the released version from CRAN:

install.packages("CVXR")

Or install the development version from GitHub:

# install.packages("pak")
pak::pak("cvxgrp/CVXR")

Quick example

library(CVXR)

# Data
set.seed(42)
n <- 50; p <- 10
X <- matrix(rnorm(n * p), n, p)
beta_true <- c(rep(1, 5), rep(0, 5))
y <- X %*% beta_true + rnorm(n, sd = 0.5)

# Problem
beta <- Variable(p)
objective <- Minimize(sum_squares(y - X %*% beta) + 0.1 * p_norm(beta, 1))
prob <- Problem(objective)

# Solve (Clarabel is the default solver)
result <- psolve(prob)
result                          # optimal value
estimated <- value(beta)        # coefficient estimates

Documentation

If you use CVXR in your work, please cite the paper above (citation("CVXR")).

License

Apache License 2.0

Reference manual

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

install.packages("CVXR")

1.9.2 by Anqi Fu, 2 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] , Steven Diamond [aut] , John Miller [aut] , Stephen Boyd [ctb]


Documentation:   PDF Manual  


Apache License 2.0 | file LICENSE license


Imports S7, methods, Matrix, Rcpp, clarabel, cli, gmp, highs, osqp, scs, slam

Suggests jsonlite, knitr, rmarkdown, testthat, rlang

Enhances Rmosek, gurobi, Rglpk, ECOSolveR, Rcplex, cccp, piqp, scip, xpress, diffcp, ipopt, sparsediff, Uno

Linking to Rcpp, RcppEigen


Imported by BsplineQuantReg, DebiasInfer, DiSCos, EmpiricalDynamics, HierPortfolios, HonestDiD, MaximinInfer, PlackettLuce, Rdimtools, RobustIV, SIHR, SLSEdesign, WRI, aramappings, fdaSP, filling, fungible, graphicalExtremes, gtDesign, lglasso, pvEBayes, rclsp, rdborrow, savvyGLM, scpi, spBPS, spStack, wdnet.

Depended on by tramnet.

Suggested by EpiForsk, PCRA, PortfolioAnalytics, ccar3, fairml, homomorpheR, mlr3fairness, portfolioBacktest, rolloptim, starnet, transreg.


See at CRAN