SkillAgentSearch skills...

CVXR

An R modeling language for convex optimization problems.

Install / Use

/learn @cvxgrp/CVXR
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

<!-- README.md is generated from README.Rmd. Please edit that file -->

CVXR <img src="man/figures/logo.png" width="120" align="right" />

<!-- badges: start -->

R-CMD-check CRAN
status Downloads

<!-- badges: end -->

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.8 closely. It is ~4–5x faster than the previous S4-based release, ships with 13 solvers (4 built-in), and supports DCP, DGP, DQCP, complex variables, mixed-integer programming, and warm-starting.

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

View on GitHub
GitHub Stars216
CategoryDevelopment
Updated2d ago
Forks33

Languages

R

Security Score

80/100

Audited on Mar 31, 2026

No findings