Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions docs/src/algorithm/acceleration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,33 @@ if the norm of the residual after the AA step is larger than some amount (eg, if
it increases the residual from the previous iterate). After rejecting a step we
revert the iterate to :math:`x^k` and reset the AA state.

The safeguard judges each step as soon as the iteration that used it is done,
before anything reads that iteration's iterate. Every 25 iterations SCS
computes its residuals and runs a check: the :ref:`termination <termination>`
tests, the time limit, the :ref:`update of the scale <updating_scale>` and
the tolerances the linear solves read until the next check (the refinement's
and, for the indirect solvers, CG's; see :ref:`linear_solver`).
When the step of a check's iteration is rejected, none of these reads that
iteration: the check runs at the next iteration instead, which never carries
an accelerated step, because the rejection has reset the AA state and the
first AA call after a reset only records the iterate. So a check waits at most
one iteration, whatever :code:`acceleration_interval`,
:code:`acceleration_lookback` and the AA type, and an iterate built from a
rejected step is never tested for convergence, used to update the scale or to
set a solve's tolerance, or returned. For the same reason AA makes no step at
the last iteration (:code:`max_iters`), whose iterate is returned (see
:ref:`exit flags <exit_flags_limit>`). The one decision still made on
an iterate the safeguard has not judged is whether to refine the linear
solves (see :ref:`refinement`), which is decided at the solve itself.

Before SCS 3.4.0 the check ran before the safeguard, and every check is an AA
iteration at the default :code:`acceleration_interval` of 5. A scale update
there could read the iterate of a step the safeguard would then reject; the
update resets AA, so the step was not tested at all and was kept. On HUESTIS
(Maros-Meszaros), which spends thousands of iterations with the scale at its
limit while AA proposes very large steps, that made 71 of 82 runs fail with
QDLDL (eps 1e-4 and 1e-6, 41 initial scales each, 22,600 iterations).

Relaxation
""""""""""

Expand Down
6 changes: 6 additions & 0 deletions docs/src/algorithm/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ To guard against transient iterates that momentarily pass the residual tests
SCS additionally requires the certificate conditions to hold at two
consecutive residual checks before declaring infeasibility or unboundedness.

All of these tests read only iterates the acceleration safeguard has accepted.
When the accelerated step of an iteration with a check due is rejected, the
check is made at the next iteration instead, which carries no accelerated step
(see :ref:`acceleration`). So a solve can stop one iteration after a multiple
of 25.

In some rare cases a problem is both primal and dual infeasible. In this case
SCS will return one of the two above certificates, whichever one it finds
first. However, in that case the interpretation of infeasibility in one space
Expand Down
10 changes: 9 additions & 1 deletion docs/src/algorithm/scale.rst
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,12 @@ SCS computes the residuals to test for convergence, which is every 25
iterations starting at iteration 0 (:code:`CONVERGED_INTERVAL` in
:code:`include/glbopts.h`). At each of these iterations it takes one sample
of the imbalance between the two residuals and then decides whether to update.
It reads only iterates the :ref:`acceleration <acceleration>` safeguard has
accepted: when the accelerated step of such an iteration is rejected, the
convergence test, the sample and the decision move to the next iteration,
which carries no accelerated step. Iteration counts below (:math:`l`, and the
100 iterations between updates) are counted from the iterations the checks
were due at, so a check that moves does not change them.

Specifically, at such an iteration :math:`k` consider the case where :math:`l`
iterations have elapsed since the last update of the :code:`scale` parameter
Expand Down Expand Up @@ -373,7 +379,9 @@ perturbed matrix, so is somewhat expensive for larger problems and should be
done sparingly. Also, since changing the :code:`scale` or the per-row
multipliers changes the operator we are using in DR splitting, every update
also resets the :ref:`Anderson acceleration <acceleration>`, whichever linear
solver is in use. After a reset the acceleration has to fill its memory again
solver is in use. The reset comes after the safeguard has judged the
iteration's accelerated step, so an update never keeps a step without that
test. After a reset the acceleration has to fill its memory again
before it produces a step: the first call after the reset only records the
iterate, and the first step comes :code:`acceleration_lookback` calls later,
with one call every :code:`acceleration_interval` iterations. With the default
Expand Down
5 changes: 5 additions & 0 deletions docs/src/api/exit_flags.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ Each status except :code:`failure` ends in :code:`(inaccurate - reached
max_iters)` or :code:`(inaccurate - reached time_limit_secs)`, for example
:code:`indeterminate (inaccurate - reached max_iters)`.

The last iterate is never built from an accelerated step that the
:ref:`acceleration <acceleration>` safeguard rejected: AA makes no step at the
last iteration, and the time limit is tested only at a convergence check,
which reads only iterates the safeguard has accepted.

The estimates returned with 2, -6 and -7 do not meet the tolerances. A
certificate estimate rests on the sign of :math:`b^\top y` or :math:`c^\top
x` at the last iterate alone, which on a run whose iterates diverged can
Expand Down
2 changes: 1 addition & 1 deletion docs/src/api/info.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ the following fields.
- Final value of the scalar :code:`scale` parameter, which can be passed as the :code:`scale` setting of a new workspace for a similar problem (see :ref:`updating_scale`). The per-row multipliers of :code:`adaptive_diag_scale` are not returned and start at one in a new workspace. When the same workspace is solved again both the :code:`scale` and the multipliers carry over from the previous solve (see :ref:`warm_start`)
* - :code:`rejected_accel_steps`
- :code:`scs_int`
- Number of times an AA update was rejected by the safeguarding check (see :ref:`acceleration`)
- Number of times an AA update was rejected by the safeguarding check (see :ref:`acceleration`). The safeguard tests every AA step, including the step of the iteration the solve stops at and of an iteration with a scale update (before SCS 3.4.0 it did not test either, and a step at a scale update was counted as accepted)
* - :code:`accepted_accel_steps`
- :code:`scs_int`
- Number of times an AA update was accepted by the safeguarding check (see :ref:`acceleration`)
Expand Down
6 changes: 4 additions & 2 deletions docs/src/api/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ They are set in the :ref:`ScsSettings <ScsSettings>` struct.
- 1.5
* - :code:`time_limit_secs`
- :code:`scs_float`
- Time limit for the solve in seconds (can be fractional). :code:`0` is interpreted as no limit. The clock starts when :code:`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 (:code:`CONVERGED_INTERVAL` in :code:`include/glbopts.h`), so a solve can overrun it by up to 25 iterations. When the limit is reached SCS returns its best guess with an inaccurate status, or :code:`SCS_INDETERMINATE` when the last iterate gives none, see :ref:`exit flags <exit_flags_limit>`. It has no effect if SCS is compiled with the :code:`NO_TIMER` :ref:`compile flag <compile_flags>`. It can be changed after setup, for example to give the solve what is left of a total time budget, see :ref:`update_settings`.
- Time limit for the solve in seconds (can be fractional). :code:`0` is interpreted as no limit. The clock starts when :code:`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 (:code:`CONVERGED_INTERVAL` in :code:`include/glbopts.h`), so a solve can overrun it by up to 25 iterations (26 when a check waits one iteration for the :ref:`acceleration <acceleration>` safeguard). When the limit is reached SCS returns its best guess with an inaccurate status, or :code:`SCS_INDETERMINATE` when the last iterate gives none, see :ref:`exit flags <exit_flags_limit>`. It has no effect if SCS is compiled with the :code:`NO_TIMER` :ref:`compile flag <compile_flags>`. It can be changed after setup, for example to give the solve what is left of a total time budget, see :ref:`update_settings`.
- :math:`[0, \infty)`
- 0
* - :code:`verbose`
Expand Down Expand Up @@ -236,7 +236,9 @@ What it does not do
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 plus the time to finish (as with any time limit). The limit
25 iterations (26 when a check waits one iteration for the
:ref:`acceleration <acceleration>` safeguard) plus the time to finish (as
with any time limit). The limit
has no effect in a build with the :code:`NO_TIMER` :ref:`compile flag
<compile_flags>`.
* It does not change the setup time reported in the :ref:`info <info>`
Expand Down
8 changes: 5 additions & 3 deletions docs/src/linear_solver/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -663,9 +663,11 @@ CG requires one multiply each of sparse matrices :math:`P, A, A^\top`. The
system is solved up to some tolerance, which is tuned to ensure that the
overall algorithm converges: each solve targets a small fraction
(:code:`CG_TOL_FACTOR`, default :math:`0.03`) of the smaller of the primal
and dual residuals at SCS's last convergence check (every 25 iterations; the
residuals a CSV log recomputes every iteration are not used, so logging does
not change the solves), additionally capped by a term decaying with
and dual residuals at SCS's last convergence check (every 25 iterations, or
one iteration later when the :ref:`acceleration <acceleration>` safeguard has
rejected that iteration's step; the residuals a CSV log recomputes every
iteration are not used, so logging does not change the solves), additionally
capped by a term decaying with
iteration :math:`k` like :math:`O(1/k^\gamma)` where :math:`\gamma` is
determined by the constant :code:`CG_RATE` (defaults to :math:`2`), and
floored at :code:`CG_BEST_TOL`. Each solve is warm-started from the previous
Expand Down
9 changes: 8 additions & 1 deletion include/glbopts.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,16 @@ static inline void *scs_calloc(size_t count, size_t size) {

/* print summary output every this num iterations */
#define PRINT_INTERVAL (250)
/* check for convergence every this num iterations */
/* check for convergence (and sample and maybe update the scale) every this
* num iterations. A check due at an iteration whose Anderson acceleration
* step the safeguard rejects runs at the next iteration instead, which
* carries no such step (see the AA safeguard in scs_solve). */
#define CONVERGED_INTERVAL (25)
#endif
/* the summary is printed at a check */
#if PRINT_INTERVAL % CONVERGED_INTERVAL != 0
#error "PRINT_INTERVAL must be a multiple of CONVERGED_INTERVAL"
#endif

/* maintain the iterates at L2 norm = ITERATE_NORM * sqrt(n+m+1) */
#define ITERATE_NORM (1.)
Expand Down
Loading
Loading