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#
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 afterniterations (Iteration).min_iters(n, criteria...): check the given criteria only afterniterations 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_normvariants (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);