Settings
These settings control how SCS behaves during a solve. They are set in the ScsSettings struct.
Name |
Type |
Description |
Permitted values |
Default |
|---|---|---|---|---|
|
|
Whether to perform heuristic data rescaling. See Data equilibration. |
True/False |
1 |
|
|
Initial dual scale factor, updated if |
\((0, \infty)\) |
0.1 |
|
|
Whether to heuristically adapt dual |
True/False |
1 |
|
|
Whether to refine the metric \(R\) per row, using the primal residual profile. Requires |
True/False |
1 |
|
|
Primal scale factor. See Non-identity DR Scaling. |
\((0, \infty)\) |
1e-6 (1e-2 in single precision builds) |
|
|
Maximum number of iterations to run. When it is reached SCS returns its best guess with an inaccurate status, or |
\(\mathbf{N}\) |
1e5 |
|
|
Absolute feasibility tolerance, see Termination criteria. |
\([0, \infty)\) |
1e-4 |
|
|
Relative feasibility tolerance, see Termination criteria. |
\([0, \infty)\) |
1e-4 |
|
|
Infeasibility tolerance (primal and dual), see Certificate of infeasibility. |
\([0, \infty)\) |
1e-7 |
|
|
Douglas-Rachford relaxation parameter. See Relaxation. |
\((0, 2)\) |
1.5 |
|
|
Time limit for the solve in seconds (can be fractional). |
\([0, \infty)\) |
0 |
|
|
Whether to print solver output to stdout. |
True/False |
1 |
|
|
Set to True if you initialize the solver with a guess of the solution. See Caching the workspace and warm-starts. This is overridden by the argument passed to |
True/False |
0 |
|
|
How much memory to use for Anderson acceleration. More memory requires more time to compute but can give more reliable steps. |
\(\mathbf{N}\) |
10 |
|
|
Run Anderson acceleration every |
\(\mathbf{N}\) |
5 |
|
|
Whether AA uses type-I ( |
True/False |
1 |
|
|
Tikhonov regularization \(\epsilon\) for the AA least-squares solve. A positive value is relative: \(\epsilon\) is the value times \(\|S_k\|_F \|Y_k\|_F\) for type-I and times \(\|Y_k\|_F^2\) for type-II. A negative value is absolute: \(\epsilon\) is its magnitude, with no scaling. |
\((-\infty, \infty)\) |
1e-8 |
|
|
AA relaxation factor \(\beta\); |
\([0, 2]\) |
1.0 |
|
|
If this is set the problem data is dumped to this filename. |
Any filename |
NULL |
|
|
If this is set SCS will write csv logs of various quantities through the solver (makes the solver much slower). The residuals it computes every iteration for the log are not used by the algorithm, which uses those of its convergence checks, so logging does not change the iterates (only the time: a solve with |
Any filename |
NULL |
Changing settings after setup
Note
scs_update_settings is new after SCS 3.3.2: SCS 3.3.2 and earlier
do not have it, and the Python update(**settings) below needs an
scs-python release built on an SCS that does.
Some settings are read only while SCS iterates, so they can be changed on an existing workspace between solves, without repeating the setup (the data scaling and the factorization or preconditioning of the linear system). This helps when:
you have a total time budget that includes the setup.
time_limit_secscounts the solve only, so a solve that stops on the limit overruns the budget by the setup time. Set up first, measure how long it took, then give the solve what is left;you want to solve to a loose tolerance first and then tighten it, or change
max_iters, on the same workspace;you want verbose output or a CSV log for some solves and not others.
The settings that can be changed after setup are:
Setting |
Notes |
|---|---|
|
The clock still starts when the solve starts. |
|
|
|
Also used by the scale updates, which happen during the solve. |
|
|
|
Only the solve output: the setup output has already been printed. |
|
The file is opened when each solve starts. SCS keeps its own copy of the name. |
|
Accepted, but in C the |
Every other setting is used to set up the workspace and cannot be changed after it (see the table at the end of this section). To change one of those, set up a new workspace.
In C
Call scs_update_settings with a complete ScsSettings struct, normally the one you passed to scs_init with
the fields you want to change edited. The setup settings in it must still
have the values you passed to scs_init; if any differs, or a new
value fails the checks scs_init applies, SCS prints a message naming
the setting, changes nothing, and returns a negative value. The new values
stay in force for every later solve on the workspace until you change them
again. To spend a total budget of budget seconds:
/* time scs_init with your own clock: the setup time SCS measures is only
* reported in ScsInfo after a solve */
double t0 = now_in_seconds();
ScsWork *w = scs_init(d, k, stgs);
double remaining = budget - (now_in_seconds() - t0);
if (remaining > 0) {
stgs->time_limit_secs = remaining; /* 0 would mean no limit */
if (scs_update_settings(w, stgs) < 0) {
/* nothing was changed; SCS printed why */
}
exitflag = scs_solve(w, sol, &info, 0);
} /* else the budget is spent: do not solve */
Do not set time_limit_secs to 0 when the budget is spent:
0 means no limit. Either skip the solve or set a tiny positive value,
which stops the solve at its first convergence check, after one iteration.
In Python
Pass the new values to update as keyword arguments, see
Python. Only the settings you pass change; passing a setup
setting raises an error and changes nothing.
t0 = time.perf_counter()
solver = scs.SCS(data, cone, eps_abs=1e-6, eps_rel=1e-6)
remaining = budget - (time.perf_counter() - t0)
if remaining > 0:
solver.update(time_limit_secs=remaining)
sol = solver.solve()
How to check it worked
A solve stopped by the time limit returns an inaccurate exit flag, or SCS_INDETERMINATE, and its status ends in
(inaccurate - reached time_limit_secs). With verbose on, scs_update_settings
prints the values now in force, starting settings updated:.
What it does not do
It does not make
time_limit_secsinclude the setup: the limit still counts from the start of the solve, so subtract the setup time yourself as above.It does not make the limit exact: SCS tests the time only when it checks convergence, every 25 iterations, so a solve can overrun the limit by up to 25 iterations (26 when a check waits one iteration for the acceleration safeguard) plus the time to finish (as with any time limit). The limit has no effect in a build with the
NO_TIMERcompile flag.It does not change the setup time reported in the info struct (
scs_updatedoes: it reports its own time as the setup time).It does not redo any part of the setup, and it does not reset what the workspace carries from one solve to the next: the adapted
scale, theadaptive_diag_scalemultipliers and the acceleration memory (see Caching the workspace and warm-starts). A solve after the call therefore starts from the same state it would have started from without it. Called before the first solve, it solves with the same settings as passing the values toscs_init(the results agree up to the backend’s rounding).It must not be called while a solve on the same workspace is running.
Settings fixed at setup, and why:
Setting |
Why it cannot change after setup |
|---|---|
|
The data were rescaled during setup. |
|
They are in the matrix the linear solver factorized (or
preconditioned) during setup. |
|
Setup decides from them whether the per-row multipliers of
|
|
The acceleration memory was sized and configured with them during setup. |
|
Read only by the solve, but the acceleration memory is kept from one solve to the next and holds steps taken at the old interval. |
|
The data were written during setup. |