Matlab interface for SCS 3.0.0 and higher. The full documentation is available here.
The easiest way to install SCS is to download the pre-compiled MATLAB Toolbox file:
- Go to the SCS Releases page.
- Download the latest
SCS.mltbxfile. - Open the file in MATLAB (or double-click it) to install.
This version comes with pre-compiled binaries for Windows, Linux, and Apple Silicon Macs, so you don't need a C compiler.
If you are on an unsupported platform or prefer to build from source:
- Clone the repository recursively:
git clone --recursive https://github.com/bodono/scs-matlab.git
- In MATLAB, run the installer:
cd <path/to/scs-matlab> make_scs
data.P = sparse([3., -1.; -1., 2.]);
data.A = sparse([-1., 1.; 1., 0.; 0., 1.]);
data.b = [-1; 0.3; -0.5];
data.c = [-1.; -1.];
cone.z = 1;
cone.l = 2;
[x, y, s, info] = scs(data, cone, settings);To warm-start, add fields x, y, s to the data struct from a
previous solve.
When solving a sequence of problems where only b and/or c change (e.g.,
MPC, parameter sweeps), use the workspace API to avoid re-factorizing:
work = scs_init(data, cone, settings); % factorize once
[x, y, s, info] = scs_solve(work); % solve
scs_update(work, b_new, []); % update b ([] = unchanged)
[x, y, s, info] = scs_solve(work); % re-solve (no re-factorization)
warm.x = x; warm.y = y; warm.s = s;
[x, y, s, info] = scs_solve(work, warm); % warm-started re-solve
scs_finish(work); % free workspaceBy default SCS uses MATLAB's built-in sparse LDL factorization (MA57 under the hood). Alternatives:
settings.use_qdldl = true; % bundled QDLDL sparse direct solver
settings.use_indirect = true; % conjugate gradient (iterative)
settings.dense = true; % dense Cholesky (for dense A)
settings.gpu = true; % GPU solverThe cone struct fields correspond to the cone types. See the
cone documentation for details.
| Field | Cone |
|---|---|
z |
Zero (equality constraints) |
l |
Non-negative orthant |
bl, bu |
Box |
q |
Second-order |
s |
Semidefinite |
cs |
Complex semidefinite |
ep |
Primal exponential |
ed |
Dual exponential |
p |
Power |