gko::stop::Criterion#
Abstract base for all stopping criteria. The factory (a
CriterionFactory) takes the system matrix, the right-hand side, the
initial guess and, optionally, the initial residual (CriterionArgs). The
resulting Criterion is queried every iteration through update(), which
collects the iteration count, residual, residual norm, implicit squared
residual norm and solution, followed by check(). Custom criteria derive
from Criterion and override check_impl.
-
class Criterion #
Inherits from
public gko::PolymorphicObject
The Criterion class is a base class for all stopping criteria. It contains a factory to instantiate criteria. It is up to each specific stopping criterion to decide what to do with the data that is passed to it.
Note that depending on the criterion, convergence may not have happened after stopping.
Subclassed by
Public Functions
- inline bool check(
- uint8 stopping_id,
- bool set_finalized,
- array<stopping_status> *stop_status,
- bool *one_changed,
- const Updater &updater,
This checks whether convergence was reached for a certain criterion. The actual implantation of the criterion goes here.
- Parameters:
stopping_id – id of the stopping criterion
set_finalized – Controls if the current version should count as finalized or not
stop_status – status of the stopping criterion
one_changed – indicates if the status of a vector has changed
updater – the Updater object containing all the information
- Returns:
whether convergence was completely reached
-
class Updater#
The Updater class serves for convenient argument passing to the Criterion’s check function. The pattern used is a Builder, except Updater builds a function’s arguments before calling the function itself, and does not build an object. This allows calling a Criterion’s check in the form
stop_criterion->update() .num_iterations(num_iterations) .ignore_residual_check(ignore_residual_check) .residual_norm(residual_norm) .implicit_sq_residual_norm(implicit_sq_residual_norm) .residual(residual) .solution(solution) .check(converged);
If there is a need for a new form of data to pass to the Criterion, it should be added here.