Warm Starts

Version 1.0 features
Author

Anqi Fu, David Kang and Balasubramanian Narasimhan

Starting with version 0.11.1, CVXR supports Parameter objects that allow you to change problem data and re-solve without reconstructing the problem from scratch. This uses the EvalParams reduction under the hood to substitute parameter values before each solve.

Lasso Example

We demonstrate the parametric workflow in a simple lasso problem:

\[ \begin{array}{ll} \underset{x}{\mbox{minimize}} & \frac{1}{2}\|Ax - b\|_2^2 + \gamma \|x\|_1\\ \mbox{subject to} & x \geq 0 \end{array} \]

where \(\gamma > 0\) is a regularization parameter.

## Problem data
set.seed(1)
m <- 200
n <- 100
A <- matrix(rnorm(m*n), nrow = m, ncol = n)
b <- rnorm(m)

## Define the problem once using a Parameter
x <- Variable(n)
gamma <- Parameter(nonneg = TRUE)
obj <- Minimize(.5 * sum_squares(A %*% x - b) + gamma * norm1(x))
constraint <- list(x >= 0)
prob <- Problem(obj, constraint)

## Sweep over gamma values
gamma_vals <- c(0.1, 0.5, 1, 2, 5, 10)
timings <- numeric(length(gamma_vals))
opt_vals <- numeric(length(gamma_vals))

for (i in seq_along(gamma_vals)) {
    value(gamma) <- gamma_vals[i]
    timings[i] <- system.time(opt_vals[i] <- psolve(prob, solver = "OSQP"))["elapsed"]
    check_solver_status(prob)
}

results <- data.frame(
    gamma = gamma_vals,
    optimal_value = round(opt_vals, 4),
    elapsed = round(timings, 3)
)

The first solve includes one-time compilation overhead; subsequent re-solves skip this step entirely:

knitr::kable(results, col.names = c("$\\gamma$", "Optimal Value", "Elapsed (s)"))
\(\gamma\) Optimal Value Elapsed (s)
0.1 69.0620 0.416
0.5 70.2521 0.061
1.0 71.6561 0.015
2.0 74.2157 0.015
5.0 80.1189 0.014
10.0 85.6434 0.013

Session Info

R version 4.6.0 (2026-04-24)
Platform: aarch64-apple-darwin23
Running under: macOS Tahoe 26.5.1

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.6/Resources/lib/libRblas.0.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.6/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.1

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/Los_Angeles
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] Matrix_1.7-5 CVXR_1.9.1  

loaded via a namespace (and not attached):
 [1] cli_3.6.6         knitr_1.51        rlang_1.2.0       xfun_0.57        
 [5] clarabel_0.11.2   otel_0.2.0        highs_1.12.0-3    scs_3.2.7        
 [9] S7_0.2.2          jsonlite_2.0.0    backports_1.5.1   rprojroot_2.1.1  
[13] htmltools_0.5.9   gmp_0.7-5.1       rmarkdown_2.31    grid_4.6.0       
[17] evaluate_1.0.5    fastmap_1.2.0     yaml_2.3.12       compiler_4.6.0   
[21] htmlwidgets_1.6.4 Rcpp_1.1.1-1.1    here_1.0.2        osqp_1.0.0       
[25] lattice_0.22-9    digest_0.6.39     checkmate_2.3.4   tools_4.6.0      

References