Monitors whether some variable has converged to a definite value. More...
#include <Convergence_monitor.hpp>
Public Member Functions | |
| Convergence_monitor (double iteration_fraction) | |
| void | add_sample (Int iteration, double value) |
| Adds a sample to the value and noise monitors. | |
| Int | n_sample () const |
Forwards to History_stats::n_sample | |
| Int | last_iter () const |
Forwards to History_stats::last_iter | |
| double | iteration_fraction () const |
Forwards to History_stats::iteration_fraction | |
| double | last_value () const |
Forwards to History_stats::last_value for the value History_stats | |
| double | smoothed () const |
Forwards to History_stats::smoothed for the value History_stats | |
| double | trend () const |
Forwards to History_stats::trend for the value History_stats | |
| double | curvature () const |
Forwards to History_stats::curvature for the value History_stats | |
| double | noise () const |
Forwards to History_stats::smoothed for the noise History_stats | |
| double | noise_trend () const |
Forwards to History_stats::trend for the noise History_stats | |
| double | noise_curvature () const |
Forwards to History_stats::curvature for the noise History_stats | |
| bool | converged (math::Tolerance trend_tol, math::Tolerance noise_tol) const |
| Checks whether the variable has converged to within the specified tolerances. | |
| void | reset () |
| Clears the sample history. | |
Monitors whether some variable has converged to a definite value.
This is essentially a package of two History_stats objects, one of which monitors the history of the variable itself, and the other of which monitors the history of the deviation of the variable from the curve fit, which is referred to as the noise. The variable is considered to be converged if there is no significant drift over time (the trend() and curvature() are sufficiently small) and either of the following is true:
noise() is sufficiently small, indicating that the variable has converged to a single value.noise() has stagnated (its trend() and curvature() are sufficiently small), indicating that the variable is displaying an oscillatory pattern that is not changing over time, and running more iterations will not provide any new information. | hexed::Convergence_monitor::Convergence_monitor | ( | double | iteration_fraction | ) |
| iteration_fraction | The iteration_fraction passed to the History_stats |
| void hexed::Convergence_monitor::add_sample | ( | Int | iteration, |
| double | value ) |
Adds a sample to the value and noise monitors.
History_stats::add_sample | bool hexed::Convergence_monitor::converged | ( | math::Tolerance | trend_tol, |
| math::Tolerance | noise_tol ) const |
Checks whether the variable has converged to within the specified tolerances.
trend_tol applies to the variation of the curve fit over the last iteration_fraction iterations, where the absolute value of the linear and quadratic components are taken separately so that they can't cancel out. trend_tol.rel is relative to smoothed() + noise() so that it can still be applicable to quantities that converge to zero if they do so in an oscillatory manner. noise_tol.rel is relative to smoothed(), and trend_tol is used to assess whether the noise has stagnated, with trend_tol.rel being relative to noise() in this case.