Skip to content

Status at the limit: SCS_INDETERMINATE when the last iterate gives no estimate - #565

Merged
bodono merged 1 commit into
masterfrom
claude/status-at-limit
Nov 25, 2026
Merged

bodono merged 1 commit into
masterfrom
claude/status-at-limit

Conversation

@bodono

@bodono bodono commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

When SCS stops at max_iters or time_limit_secs, set_unfinished reports what the last iterate supports. In one case it has nothing to report: tau = 0 (the cone projection clips it at zero) while b'y >= 0 and c'x >= 0. A solution estimate (x, y, s) / tau needs tau > 0, and a certificate estimate y / (-b'y) or (x, s) / (-c'x) needs b'y < 0 or c'x < 0, so the iterate is an estimate of neither. Until now SCS returned SCS_FAILED there, which says that SCS broke when it only ran out of iterations, and it:

  • printed ERROR: could not determine problem status.;
  • set the status to " (inaccurate - reached max_iters)", with no prefix;
  • returned the raw homogeneous iterate in x, y, s, not divided by tau (x = 0.557 on the test LP below, which looks like a point);
  • never wrote pobj, dobj, gap, res_pri or res_dual, so a zeroed ScsInfo read as gap 0 and residuals 0;
  • appended the suffix to whatever the caller's status held. A caller that does not zero ScsInfo (scs-matlab declares it without initialising it) got its text past the end of the 128-byte field. With such an info, the test below aborts the test binary on master on macOS: the fortified strcat traps.

Change

  • No estimate: SCS_INDETERMINATE (-3) with the status indeterminate (inaccurate - reached max_iters) (or time_limit_secs). x, y, s and pobj, dobj, gap, res_pri, res_dual, res_infeas, res_unbdd_a, res_unbdd_p, comp_slack are NaN. -3 is no longer deprecated. SCS 1.x and 2.x returned -3 in the same form.
  • Iterate not finite (NaN or Inf in x, y, s, tau or kappa): SCS_FAILED, status failure with no suffix, the same NaN fields, and the line Failure:the iterate is not finite (NaN or Inf). This test runs first, before the existing branches.
  • Status text: every branch now starts the status with strcpy, so the suffix is never appended to the caller's bytes.
  • Unchanged: the certificate and solution branches, the suffix, the main loop and all iterates.
  • Deterministic: every test is exact (isfinite, tau > 0, the signs of b'y and c'x). The status depends only on the last iterate, with no threshold and no older iterate.
  • API: no new setting, field or exit code. The existing all_finite is reused.

Why NaN rather than the raw iterate: the ray has no documented meaning and looks like a solution. The cost is that a warm start from this result starts from zero, as a cold start does, because warm_start_vars reads NaN as 0. The scale and the per-row multipliers still carry over.

Behaviour changes

  1. The no-estimate case, as above: -4 becomes -3.
  2. A non-finite iterate at the limit becomes -4 wherever it lands. Because this test runs before the existing branches, such an iterate no longer comes back as a 2, -6 or -7.
    • Measured: the test LP warm-started at half the largest float returns solved (inaccurate - reached max_iters) today at max_iters = 1, with a non-finite solution. Tau is fixed at 1 in iteration 0.
    • A diverged run whose x overflowed while y stayed finite would move from -7 to -4. None is known.

Where the no-estimate case happens

Measured on master 4ccf238:

  • The first iterations:
    • one-variable LPs with 4 rows: 5,480 of 4.7M runs, all at max_iters 2 or 3;
    • 300 random tiny LPs: 10 of 18,000 runs.
  • Runs whose iterates diverged: netlib beaconfd with CG at eps 1e-4, 19 of 500 starts at 700 iterations (NVPL). In the one start examined on the Mac, the iterates were of size 1e69 to 1e71.
  • One start, one iteration apart (beaconfd on the Mac, start u24):
    • at 700 iterations: -4 on master, -3 with this change, from the same iterate (tau, kappa, b'y, c'x and the residuals print identically);
    • at 701 iterations: infeasible (inaccurate) on both, although beaconfd is feasible.
    • So an inaccurate certificate at the limit rests on the sign of b'y at one iterate. The new docs section says so.
  • All 36 Mac starts (u1 to u36, 700 iterations): every status and every printed iterate quantity is the same as on master, except u24 (-4 to -3).

Tests (test/problems/test_inaccurate.h)

The test problem is the box LP min 2x s.t. -2 <= x <= 2, which SCS solves in 25 iterations.

  • test_indeterminate_at_limit: max_iters = 2, with ScsInfo filled with 0x7f bytes first.
    • Expects -3, the exact status string, 2 iterations, NaN x, y, s and NaN objective and residual fields.
    • Margins measured before this change (QDLDL and CG; double, DLONG and single; normalize, adaptive scale and acceleration each on or off): unclipped tau -0.023 to -0.046, b'y +0.56 to +0.72, c'x +0.56 to +1.1, at an iterate of norm about 2.
    • Other side:
      • max_iters = 3 gives 2;
      • the default max_iters gives 1;
      • a warm-started solve on the same workspace after the -3 gives 1 at x = -2.
  • test_nonfinite_at_limit: the box LP warm-started at x = y = s = half the largest finite scs_float, at max_iters 1 and 2. This tests an overflow.
    • Expects -4, the status failure, and NaN x, y, s.
    • info.iter is not checked: a linear solver that rejects the overflowed system itself also stops with -4 and failure, at another iteration count.
  • On master:
    • the first test aborts on macOS with the 0x7f info. With a zeroed info it fails with -4 and the status " (inaccurate - reached max_iters)";
    • the second test fails at max_iters = 1 with status 2.

Run on an M-series Mac (Apple clang, Accelerate's BLAS and LAPACK): the Make builds (default, SFLOAT=1, USE_LAPACK=0, DEFLATE_VECTORS=0, DLONG=1, NO_PRINTING=1), each with the direct, indirect, dense and Accelerate test binaries it builds, plus CMake/ctest. All pass. Against master's logs, with timings removed, the only differences are the two new tests and the test count. The Accelerate binaries also differ in other tests, but by the same amounts as two runs of master do: Accelerate's sparse solver is not reproducible from run to run. The two new tests are also clean under ASan + UBSan, with the flags of the spectral job, for direct, indirect, dense and Accelerate, in double and single. Not run locally: MKL, cuDSS, the GPU solvers and gcc. In CI, the new tests pass in every job that runs them: Linux (gcc), Windows and macOS, in single and double precision; MKL; OpenMP; the spectral job with its sanitizers; Valgrind; and the simulated GPU and cuDSS jobs. In every one of those jobs the non-finite case reached the new branch and printed its line. None of them stopped with a failed linear solve instead.

Docs

  • exit_flags.rst: the -3 and -4 rows, and a new section "At max_iters or time_limit_secs" on how the last iterate decides among 2, -6/-7, -3 and -4, and what each returns.
  • settings.rst: the max_iters and time_limit_secs rows, and "How to check it worked".
  • info.rst: which fields are NaN.
  • warm_start.rst: NaN entries of a warm start are read as zero.
  • The termination section: a short "Iteration and time limits" subsection.
  • help/index.rst: a troubleshooting entry for indeterminate.

Wrappers

  • CVXPY 1.8.2 maps -3 and -4 both to SOLVER_ERROR, so CVXPY users get the same SolverError as before. Nothing is needed.
  • scs-python: only constants. The comment on INDETERMINATE ("norm too small") should change. Tests for -3 and for the non-finite -4 can follow once scs_source points at a commit with this change.
  • scs-matlab: returns status_val and status as given. The uninitialised ScsInfo no longer leads to an overrun.
  • Not checked: SCS.jl's MOI status mapping, the R package and the JavaScript wrapper.

For the maintainer

  • The wording of the non-finite message, and whether it should ask users to open an issue. An overflow from huge but finite data or a huge warm start is not a bug, so it does not ask.

🤖 Generated with Claude Code

…mate

When SCS stops at max_iters or time_limit_secs at an iterate with tau = 0
(project_cones clips it at zero) and b'y >= 0, c'x >= 0, the iterate is an
estimate of neither a solution, which needs tau > 0, nor a certificate,
which needs b'y < 0 or c'x < 0. set_unfinished returned SCS_FAILED there,
printed "ERROR: could not determine problem status.", left the raw
iterate in x, y, s, never wrote pobj, dobj, gap, res_pri and res_dual, and
appended " (inaccurate - reached max_iters)" to whatever info->status held
(past the end of the field when the caller had not zeroed ScsInfo, as
scs-matlab does not).

It now returns SCS_INDETERMINATE (-3, no longer deprecated), status
"indeterminate (inaccurate - reached max_iters)" (or time_limit_secs),
with x, y, s and the objective and residual fields NaN. An iterate that is
not finite (NaN or Inf in x, y, s, tau or kappa) is tested first and
returns SCS_FAILED, status "failure" with no suffix, the same NaN fields;
before, such an iterate could come back as "solved (inaccurate)" (tau is
fixed at 1 in iteration 0) or as an inaccurate certificate. Every branch
now writes the status before the suffix is appended.

All tests are exact, so the status is a function of the last iterate
alone; the iterates and the other branches are unchanged. No new setting,
field or exit code; the existing all_finite is reused.

Tests (box LP min 2x, -2 <= x <= 2): test_indeterminate_at_limit
(max_iters 2 with a 0x7f-filled ScsInfo; max_iters 3, the default, and a
warm-started re-solve as the other side) and test_nonfinite_at_limit (a
warm start at half the largest scs_float, max_iters 1 and 2). Docs:
exit flags (the -3 and -4 rows, a section on the status at the limit),
settings, info, warm start, termination and help.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bodono
bodono marked this pull request as ready for review November 25, 2026 21:38
@bodono
bodono merged commit eeef310 into master Nov 25, 2026
95 checks passed
@bodono
bodono deleted the claude/status-at-limit branch November 25, 2026 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant