Settings

These settings control how SCS behaves during a solve. They are set in the ScsSettings struct.

Name

Type

Description

Permitted values

Default

normalize

scs_int

Whether to perform heuristic data rescaling. See Data equilibration.

True/False

1

scale

scs_float

Initial dual scale factor, updated if adaptive_scale is True. See Non-identity DR Scaling.

\((0, \infty)\)

0.1

adaptive_scale

scs_int

Whether to heuristically adapt dual scale through the solve. See Non-identity DR Scaling.

True/False

1

adaptive_diag_scale

scs_int

Whether to refine the metric \(R\) per row, using the primal residual profile. Requires adaptive_scale (silently disabled without it). See Non-identity DR Scaling.

True/False

1

rho_x

scs_float

Primal scale factor. See Non-identity DR Scaling.

\((0, \infty)\)

1e-6 (1e-2 in single precision builds)

max_iters

scs_int

Maximum number of iterations to run. When it is reached SCS returns its best guess with an inaccurate status, or SCS_INDETERMINATE when the last iterate gives none, see exit flags.

\(\mathbf{N}\)

1e5

eps_abs

scs_float

Absolute feasibility tolerance, see Termination criteria. 0 gives a purely relative test.

\([0, \infty)\)

1e-4

eps_rel

scs_float

Relative feasibility tolerance, see Termination criteria. 0 gives a purely absolute test. If eps_abs and eps_rel are both 0 the optimality test can never pass (the code tests with a strict inequality), and a problem that has a solution runs until max_iters or time_limit_secs.

\([0, \infty)\)

1e-4

eps_infeas

scs_float

Infeasibility tolerance (primal and dual), see Certificate of infeasibility. 0 switches the infeasibility and unboundedness tests off, so SCS never stops early with an infeasible or unbounded status.

\([0, \infty)\)

1e-7

alpha

scs_float

Douglas-Rachford relaxation parameter. See Relaxation.

\((0, 2)\)

1.5

time_limit_secs

scs_float

Time limit for the solve in seconds (can be fractional). 0 is interpreted as no limit. The clock starts when scs_solve is called, so the setup time (e.g., the initial factorization) is not counted, although the time column of the printed output does include it. The limit is only tested when convergence is checked, every 25 iterations (CONVERGED_INTERVAL in include/glbopts.h), so a solve can overrun it by up to 25 iterations (26 when a check waits one iteration for the acceleration safeguard). When the limit is reached SCS returns its best guess with an inaccurate status, or SCS_INDETERMINATE when the last iterate gives none, see exit flags. It has no effect if SCS is compiled with the NO_TIMER compile flag. It can be changed after setup, for example to give the solve what is left of a total time budget, see Changing settings after setup.

\([0, \infty)\)

0

verbose

scs_int

Whether to print solver output to stdout.

True/False

1

warm_start

scs_int

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 scs_solve.

True/False

0

acceleration_lookback

scs_int

How much memory to use for Anderson acceleration. More memory requires more time to compute but can give more reliable steps. 0 disables it. See Acceleration.

\(\mathbf{N}\)

10

acceleration_interval

scs_int

Run Anderson acceleration every acceleration_interval iterations. See Acceleration.

\(\mathbf{N}\)

5

acceleration_type_1

scs_int

Whether AA uses type-I (1) or type-II (0). See Acceleration.

True/False

1

acceleration_regularization

scs_float

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. 0 turns the regularization off. The default is tuned for type-I; type-II is typically more stable and tolerates a smaller value (e.g. 1e-12). See Acceleration.

\((-\infty, \infty)\)

1e-8

acceleration_relaxation

scs_float

AA relaxation factor \(\beta\); 1.0 recovers vanilla AA. See Acceleration.

\([0, 2]\)

1.0

write_data_filename

char *

If this is set the problem data is dumped to this filename.

Any filename

NULL

log_csv_filename

char *

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 time_limit_secs can stop sooner).

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_secs counts 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

time_limit_secs

The clock still starts when the solve starts. 0 means no limit.

max_iters

eps_abs, eps_rel, eps_infeas

Also used by the scale updates, which happen during the solve.

alpha

verbose

Only the solve output: the setup output has already been printed.

log_csv_filename

The file is opened when each solve starts. SCS keeps its own copy of the name.

warm_start

Accepted, but in C the warm_start argument of scs_solve always replaces it.

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_secs include 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_TIMER compile flag.

  • It does not change the setup time reported in the info struct (scs_update does: 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, the adaptive_diag_scale multipliers 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 to scs_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

normalize

The data were rescaled during setup.

scale, rho_x

They are in the matrix the linear solver factorized (or preconditioned) during setup. scale is compared with the value passed to scs_init, not the value adaptive_scale has moved it to, so passing the original struct back is accepted.

adaptive_scale, adaptive_diag_scale

Setup decides from them whether the per-row multipliers of adaptive_diag_scale exist (it switches adaptive_diag_scale off when adaptive_scale is off; the value passed to scs_init is the one compared).

acceleration_lookback, acceleration_type_1, acceleration_regularization, acceleration_relaxation

The acceleration memory was sized and configured with them during setup.

acceleration_interval

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.

write_data_filename

The data were written during setup.