gko::stop::Iteration#
Stops the solver after a fixed number of iterations. Use as a safety
net inside Combined so a divergent solve cannot run
indefinitely.
gko::stop::max_iters(n) builds this criterion directly.
gko::stop::min_iters(n, criterion) wraps other criteria so that they are
only checked once n iterations have finished; with several criteria it
combines them first, and from then on it behaves like the wrapped
criteria.
-
class Iteration #
Inherits from
public gko::stop::Criterion
The Iteration class is a stopping criterion which stops the iteration process after a preset number of iterations.
Note
to use this stopping criterion, it is required to update the iteration count for the ::check() method.
- deferred_factory_parameter<const Iteration::Factory> gko::stop::max_iters(
- size_type count,
Creates the precursor to an Iteration stopping criterion factory, to be used in conjunction with
.with_criteria(...)function calls when building a solver factory. This stopping criterion will stop the iteration aftercountiterations of the solver have finished.Full usage example: Stop after 100 iterations or when the relative residual norm is below \(10^{-10}\), whichever happens first.
auto factory = gko::solver::Cg<double>::build() .with_criteria( gko::stop::max_iters(100), gko::stop::relative_residual_norm(1e-10)) .on(exec);
- Parameters:
count – the number of iterations after which to stop
- Returns:
a deferred_factory_parameter that can be passed to the
with_criteriafunction when building a solver.
The two min_iters overloads are declared in ginkgo/core/stop/iteration.hpp as:
deferred_factory_parameter<const CriterionFactory> min_iters(
size_type count,
deferred_factory_parameter<const CriterionFactory> criterion);
template <typename... Args>
std::enable_if_t<sizeof...(Args) >= 2,
deferred_factory_parameter<const CriterionFactory>>
min_iters(size_type count, Args&&... criteria);
count is the number of iterations after which checking of the wrapped
criteria starts. With two or more criteria, they are combined with
Combined (stop when any fires) inside the wrapper.