Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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:

FieldDefaultMeaning
max_iterations5000Outer iteration cap; 0 still evaluates the initial point and checks convergence
max_evaluationsNoneStrict objective-call cap; None leaves iterations as the sole limit
gradient_tolerance\(10^{-6}\)Stationarity (gradient/KKT/interval) tolerance
value_toleranceNoneOptional objective-stagnation tolerance
step_toleranceNoneOptional accepted-step stagnation tolerance

Mixed tolerances meet the condition

$$ \text{difference}\le \tau_{\text{abs}}+\tau_{\text{rel}}\,\text{scale}, $$

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:

  1. on a satisfied convergence criterion, return convergence (GradientTolerance, KktTolerance or IntervalTolerance);
  2. on reaching the objective-call budget, return MaxEvaluations;
  3. on reaching the iteration cap, return MaxIterations;
  4. on a satisfied enabled stagnation criterion at an accepted step, return a Stagnated reason.

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:

FieldCounted object
objectiveObjective or residual calls, including rejected trials and failed callbacks
gradientGradient requests; least-squares Jacobian requests count here
hessianDense Hessian or Hessian-vector product requests
constraintsNonlinear constraint value or model-state evaluations
residualsResidual vector requests
jacobianResidual or constraint Jacobian requests
subproblemSynthesized 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:

ValueMeaning
ConvergedA solver convergence criterion holds
MaxIterationsIteration cap exhausted
MaxEvaluationsObjective budget exhausted
StagnatedAn enabled stagnation criterion holds
FailedState 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:

VariantTrigger
InvalidInputAn option, domain, direction or precondition fails
DimensionMismatchVector or matrix shape mismatch, with expected and actual shapes
NonFiniteA non-finite value in inputs, callback outputs or intermediate arithmetic
MissingHessianA dense Newton method requests a Hessian the problem leaves absent
SingularSystemA linear system that is singular, inconsistent or numerically unsolvable
InfeasibleA constraint system or linearized subproblem infeasible
LineSearchFailedLine-search trials exhausted, with trial count and final step
IterationLimitA nested solver exhausts its iterations, with solver name and count
SubproblemStoppedA synthesized subproblem stops, with solver name, reason and count
EvaluationBudgetExceededInternal objective-budget signal
SearchStoppedAn extra evaluation request on a stopped context
SearchFailureValue-search failure, with best point and counts
EvaluationAn application callback fails, with operation class and message
SolverFailureA local solve fails, with outer name, source error and checkpoint

12.6 Checkpoints and recovery

Error wrappers retain valid state:

  • Error::root_cause() unwraps SolverFailure/SearchFailure and returns the underlying class;
  • Error::last_solution() returns the local solver’s full evaluation checkpoint with status Failed;
  • Error::last_point() returns the best evaluated point of a value search;
  • Error::source() chains follow the standard std::error::Error convention.

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 IterationLimit or SubproblemStopped when their iterations run out;
  • callback panics propagate under the Rust unwinding rules.

Software interface

References

  • J. Nocedal, S. J. Wright, Numerical Optimization, 2nd ed., 2006, Section 3.2 (termination) and Chapter 18 (SQP subproblems).