12. Stopping, Budgets and Error Recovery
This chapter collects the stopping controls, counters and error classes shared by all solvers. Local solvers use StopOptions; value search uses BudgetOptions, and the two control families are defined separately.
12.1 Stopping options
StopOptions fields and defaults:
| Field | Default | Meaning |
|---|---|---|
max_iterations | 5000 | Outer iteration cap; 0 still evaluates the initial point and checks convergence |
max_evaluations | None | Strict objective-call cap; None leaves iterations as the sole limit |
gradient_tolerance | \(10^{-6}\) | Stationarity (gradient/KKT/interval) tolerance |
value_tolerance | None | Optional objective-stagnation tolerance |
step_tolerance | None | Optional accepted-step stagnation tolerance |
Mixed tolerances meet the condition
where scale is the larger norm of adjacent iterates or the larger absolute objective value. Both stagnation tolerances start disabled; once enabled they report ObjectiveStagnation or StepStagnation.
12.2 Decision order
The outer decision order at each step:
- on a satisfied convergence criterion, return convergence (
GradientTolerance,KktToleranceorIntervalTolerance); - on reaching the objective-call budget, return
MaxEvaluations; - on reaching the iteration cap, return
MaxIterations; - on a satisfied enabled stagnation criterion at an accepted step, return a
Stagnatedreason.
Convergence takes priority: when the last allowed iterate meets the convergence condition, the result counts as converged. When the budget runs out mid-trial, the solver returns the most recent fully evaluated accepted point, labeled MaxEvaluations.
12.3 Evaluation counts
The seven fields of EvaluationCounts:
| Field | Counted object |
|---|---|
objective | Objective or residual calls, including rejected trials and failed callbacks |
gradient | Gradient requests; least-squares Jacobian requests count here |
hessian | Dense Hessian or Hessian-vector product requests |
constraints | Nonlinear constraint value or model-state evaluations |
residuals | Residual vector requests |
jacobian | Residual or constraint Jacobian requests |
subproblem | Synthesized subproblem model evaluations, separate from the outer objective budget |
A combined value/gradient call counts once in each category. max_evaluations consumes only the objective field.
12.4 Status and termination reasons
The five Status values:
| Value | Meaning |
|---|---|
Converged | A solver convergence criterion holds |
MaxIterations | Iteration cap exhausted |
MaxEvaluations | Objective budget exhausted |
Stagnated | An enabled stagnation criterion holds |
Failed | State of an error-recovery checkpoint |
TerminationReason records the criterion precisely: GradientTolerance, KktTolerance, IntervalTolerance, MaxIterations, MaxEvaluations, ObjectiveStagnation, StepStagnation, Failed.
Value search uses SearchTermination: TargetReached, MaxEvaluations, MaxIterations, Stagnated, Cancelled.
12.5 Error classes
The Error enum variants:
| Variant | Trigger |
|---|---|
InvalidInput | An option, domain, direction or precondition fails |
DimensionMismatch | Vector or matrix shape mismatch, with expected and actual shapes |
NonFinite | A non-finite value in inputs, callback outputs or intermediate arithmetic |
MissingHessian | A dense Newton method requests a Hessian the problem leaves absent |
SingularSystem | A linear system that is singular, inconsistent or numerically unsolvable |
Infeasible | A constraint system or linearized subproblem infeasible |
LineSearchFailed | Line-search trials exhausted, with trial count and final step |
IterationLimit | A nested solver exhausts its iterations, with solver name and count |
SubproblemStopped | A synthesized subproblem stops, with solver name, reason and count |
EvaluationBudgetExceeded | Internal objective-budget signal |
SearchStopped | An extra evaluation request on a stopped context |
SearchFailure | Value-search failure, with best point and counts |
Evaluation | An application callback fails, with operation class and message |
SolverFailure | A local solve fails, with outer name, source error and checkpoint |
12.6 Checkpoints and recovery
Error wrappers retain valid state:
Error::root_cause()unwrapsSolverFailure/SearchFailureand returns the underlying class;Error::last_solution()returns the local solver’s full evaluation checkpoint with statusFailed;Error::last_point()returns the best evaluated point of a value search;Error::source()chains follow the standardstd::error::Errorconvention.
A checkpoint is a fully evaluated accepted state with current counts. A failure in the initial evaluation leaves the checkpoint absent. The recovery point serves as a restart seed, and its objective can exceed the smallest value seen during the search.
12.7 Budget boundaries
- a zero objective budget fails at entry validation; a zero iteration cap is legal, returning after the initial evaluation under the convergence criterion;
- budget exhaustion during initialization, a generation or a trial keeps the most recent fully evaluated point;
- nested subproblems (the SQP QP model, the PHR inner loop) return
IterationLimitorSubproblemStoppedwhen their iterations run out; - callback panics propagate under the Rust unwinding rules.
Software interface
StopOptions,Tolerance,EvaluationCounts: see chapter 20.- Error-handling examples and recovery methods: see chapter 20.
- Defaults per solver family: see chapters 16–19.
- API pages (docs.rs):
StopOptions,EvaluationCounts,Error.
References
- J. Nocedal, S. J. Wright, Numerical Optimization, 2nd ed., 2006, Section 3.2 (termination) and Chapter 18 (SQP subproblems).