gko::stop#

Stopping criteria for iterative solvers. The iterative solvers in gko::solver consume one or more CriterionFactory objects through with_criteria(...). Each factory produces a Criterion whose check() decides whether to stop on each iteration. Multiple criteria passed to with_criteria stop the solver as soon as any of them fires.

Base machinery#

  • Criterion: abstract base for all stopping criteria.

  • Combined: meta-criterion that stops when any of a list of inner criteria fires.

Built-in criteria#

  • Iteration: fixed iteration cap.

  • Time: wall-clock cap.

  • ResidualNorm: explicit and implicit residual-norm criteria for solver tolerance tests, with three baseline modes (right-hand-side, initial-residual, absolute).

Helper functions#

The quickest way to configure stopping is to pass these functions to with_criteria; the value type is taken from the solver’s vectors:

  • max_iters(n): stop after n iterations (Iteration).

  • min_iters(n, criteria...): check the given criteria only after n iterations have finished (Iteration).

  • time_limit(duration): wall-clock cap (Time).

  • relative_residual_norm(tol), initial_residual_norm(tol), absolute_residual_norm(tol) and their *_implicit_residual_norm variants (ResidualNorm).

auto factory =
    gko::solver::Cg<double>::build()
        .with_criteria(
            gko::stop::max_iters(1000u),
            gko::stop::min_iters(10u, gko::stop::relative_residual_norm(1e-10)))
        .on(exec);