Using Other Solvers

Author

Anqi Fu and Balasubramanian Narasimhan

Introduction

CVXR (version packageVersion("CVXR")) supports length(installed_solvers) solvers, including several bundled open source solvers and optional commercial ones.

Open Source Solvers (on CRAN)

  • Clarabel, a versatile conic solver written in Rust (default solver).
  • SCS, a conic solver using operator splitting, effective for large-scale problems.
  • OSQP, for quadratic and linear programs.
  • HiGHS, for linear, quadratic, and mixed-integer programs.
  • ECOS / ECOS_BB, an interior-point solver for second-order cone programs (ECOS_BB adds mixed-integer support).
  • GLPK / GLPK_MI, for linear programs and mixed-integer linear programs.
  • CVXOPT, for linear and second-order cone programs.
  • PIQP, a proximal interior-point solver for quadratic programs.
  • SCIP for linear, second-order cone programs and mixed-integer programs.

Commercial Solvers

  • MOSEK, supporting LP, QP, SOCP, SDP, and exponential/power cone programs. Free academic licenses available.
  • Gurobi, supporting LP, QP, SOCP, and mixed-integer programs. Free academic licenses available.
  • CPLEX, supporting LP, QP, and mixed-integer programs.
  • XPRESS supporting LP, QP, SOCP and mixed-integer programs

Solver Capabilities

The table below shows each solver, its R package dependency, and the problem classes it supports.

Solver Capabilities
Solver R package LP QP SOCP SDP EXP MIP
CLARABEL clarabel
SCS scs
OSQP osqp
HIGHS highs
ECOS ECOSolveR
ECOS_BB ECOSolveR
GLPK Rglpk
GLPK_MI Rglpk
CPLEX Rcplex
GUROBI gurobi
MOSEK Rmosek
CVXOPT cccp
PIQP piqp
SCIP scip
XPRESS xpress

Installing Commercial Solvers

Once a commercial solver is installed, it will be auto-detected depending on the type of problem you solve. However, you can force its use by passing solver = "MOSEK", solver = "GUROBI", or solver = "CPLEX" to psolve().

Below we provide some hints for installing commercial solvers.

MOSEK

MOSEK provides an academic version that is free of charge: one can obtain the free academic license after registering. Once the license for the product has been activated, the Rmosek documentation provides all the details for installation.

To be concrete, on my Apple Silicon Mac, the personal use installation lands in ~/mosek/11.1. So all one has to do is to source("~/mosek/11.1/tools/platform/osxaarch64/rmosek.R") and follow the directions given.

A quick check to ensure things are working is to run the example:

library(Rmosek)
example(mosek)

Gurobi

Gurobi offers free academic licenses and includes a binary R package in the installation bundle. On my Apple Silicon mac, this binary package may be found at /Library/gurobi1301/macos_universal2/R along with a README containing instructions to follow. Verify with:

library(gurobi)
model <- list(A = matrix(c(1, 1), nrow = 1),
              obj = c(1, 1), sense = "<=", rhs = 1)
gurobi(model)

CPLEX

IBM CPLEX is available through IBM’s academic initiative. The hardest part is finding the community edition and IBM doesn’t make this easy, but a free community edition is available. There is also a specific version for Apple Silicon and you have to ensure that you don’t mistakenly use the x86_64 version; that will not work on the Apple Silicon platform, even if you use rosetta.

Once CPLEX is installed, the R package installation is from source and so you need compilation tools. An example R installation script for Apple Silicon is below.

cplex_location <- "/Applications/CPLEX_Studio_Community2212"
arch <- "arm64"
cplex_configure_args <- c(Rcplex = sprintf("--with-cplex-include='%s/cplex/include' --with-cplex-lib='-L%s/cplex/lib/%s_osx/static_pic -lilocplex -lcplex'", cplex_location, cplex_location, arch))
install.packages("Rcplex", configure.args = cplex_configure_args)

XPRESS

XPRESS can be downloaded from the website after surrendering some information on who you are etc. Once again, a community license is automatically included with the download. The annoyance is that the license needs to be available any time you use the solver. So I usually copy the first section below into ~/.Rprofile after verifying that it works in an initial R session.

## Test that this code chunk doesn't warn in an R session and then copy into ~/.Rprofile
XPRESSDIR <- "/Applications/FICO Xpress/xpressmp"
XPRESS_LICENSE_FILE <- "xpauth.xpr" ## sometimes named "community-xpauth.xpr"
XPAUTH_PATH <- sprintf("%s/bin/%s", XPRESSDIR, XPRESS_LICENSE_FILE)
if (!file.exists(XPAUTH_PATH)) {
  warning(sprintf("XPRESS license file not located at %s", XPAUTH_PATH))
}
## Set environment variables
Sys.setenv(
  XPRESSDIR = XPRESSDIR,
  XPAUTH_PATH = XPAUTH_PATH
)

Install the solver from source (so you need compilation tools) via:

install.packages(sprintf("%s/R/xpress.tar.gz", XPRESSDIR))

Finally, verify that this runs.

library(xpress)
prob <- createprob()
print(prob)

Session Info

R version 4.5.3 (2026-03-11)
Platform: aarch64-apple-darwin20
Running under: macOS Tahoe 26.3.1

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRblas.0.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/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] kableExtra_1.4.0 CVXR_1.8.2      

loaded via a namespace (and not attached):
 [1] gmp_0.7-5.1        clarabel_0.11.2    xml2_1.5.2         slam_0.1-55       
 [5] stringi_1.8.7      lattice_0.22-9     digest_0.6.39      magrittr_2.0.4    
 [9] evaluate_1.0.5     grid_4.5.3         RColorBrewer_1.1-3 fastmap_1.2.0     
[13] rprojroot_2.1.1    jsonlite_2.0.0     Matrix_1.7-5       ECOSolveR_0.6.1   
[17] backports_1.5.1    scs_3.2.7          Rmosek_11.1.1      xpress_9.8.1      
[21] viridisLite_0.4.3  scales_1.4.0       codetools_0.2-20   textshaping_1.0.5 
[25] cli_3.6.5          rlang_1.1.7        Rglpk_0.6-5.1      yaml_2.3.12       
[29] otel_0.2.0         tools_4.5.3        osqp_1.0.0         Rcplex_0.3-8      
[33] checkmate_2.3.4    scip_1.10.0-3      here_1.0.2         gurobi_13.0-1     
[37] vctrs_0.7.2        R6_2.6.1           lifecycle_1.0.5    stringr_1.6.0     
[41] htmlwidgets_1.6.4  pkgconfig_2.0.3    cccp_0.3-3         pillar_1.11.1     
[45] glue_1.8.0         Rcpp_1.1.1         systemfonts_1.3.2  tibble_3.3.1      
[49] xfun_0.57          rstudioapi_0.18.0  knitr_1.51         dichromat_2.0-0.1 
[53] highs_1.12.0-3     farver_2.1.2       htmltools_0.5.9    rmarkdown_2.31    
[57] svglite_2.2.2      piqp_0.6.2         compiler_4.5.3     S7_0.2.1          

References