80 const std::string& key) {
84 "The key " << section <<
"." << key
85 <<
" of the configuration must not be negative.")
87 return static_cast< Size >(value);
95 setEpsilon(conf.typed<
double >(section,
"epsilon"));
99 if (withVerbosity)
setVerbosity(conf.typed<
bool >(section,
"verbosity"));
100 if (withMaxTime)
setMaxTime(conf.typed<
double >(section,
"maxTime"));
This file contains general scheme for iteratively convergent algorithms.
Inline implementatioh of gum::ApproximationSettings.
ApproximationScheme()
Build a scheme whose parameters are read from the configuration.
Size current_step_
The current step.
double current_epsilon_
Current epsilon.
double last_epsilon_
Last epsilon value.
double eps_
Threshold for convergence.
static Size sizeFromConfiguration_(const std::string §ion, const std::string &key)
Read a non negative integer key of gum::Configuration.
void setMaxIter(Size max) override
Stopping criterion on number of iterations.
void disableMaxTime() override
Disable stopping criterion on timeout.
void setMaxTime(double timeout) override
Stopping criterion on timeout.
void setMinEpsilonRate(double rate) override
Given that we approximate f(t), stopping criterion on d/dt(|f(t+1)-f(t)|).
void setFromConfiguration_(const std::string §ion, bool withMaxTime, bool withVerbosity=true)
Set the parameters of the scheme from a section of gum::Configuration.
bool enabled_max_time_
If true, the timeout is enabled.
Size max_iter_
The maximum iterations.
bool enabled_eps_
If true, the threshold convergence is enabled.
ApproximationSchemeSTATE current_state_
The current state.
double min_rate_eps_
Threshold for the epsilon rate.
void setPeriodSize(Size p) override
How many samples between two stopping is enable.
std::vector< double > history_
The scheme history, used only if verbosity == true.
~ApproximationScheme() override
Build a scheme whose parameters are read from the configuration.
double current_rate_
Current rate.
ApproximationSchemeSTATE stateApproximationScheme() const override
Returns the approximation scheme state.
Size period_size_
Checking criteria frequency.
bool startOfPeriod() const
Returns true if we are at the beginning of a period (compute error is mandatory).
bool enabled_max_iter_
If true, the maximum iterations stopping criterion is enabled.
double max_time_
The timeout.
bool continueApproximationScheme(double error)
Update the scheme w.r.t the new error.
void stopScheme_(ApproximationSchemeSTATE new_state)
Stop the scheme given a new state.
bool verbosity_
If true, verbosity is enabled.
bool verbosity() const override
Returns true if verbosity is enabled.
Size burn_in_
Number of iterations before checking stopping criteria.
void setVerbosity(bool v) override
Set the verbosity on (true) or off (false).
bool enabled_min_rate_eps_
If true, the minimal threshold for epsilon rate is enabled.
void setEpsilon(double eps) override
Given that we approximate f(t), stopping criterion on |f(t+1)-f(t)|.
Sectioned key/value configuration with typed and documented keys.
static Configuration & instance()
The global configuration.
T typed(std::string_view section, std::string_view key) const
Value of section.key converted according to its declared type.
Signaler< Size, double, double > onProgress
Progression, error and time.
ApproximationSchemeSTATE
The different state of an approximation scheme.
std::string messageApproximationScheme() const
Returns the approximation scheme message.
Exception : operation not allowed.
Exception : out of bound.
double step() const
Returns the delta time between now and the last reset() call (or the constructor).
bool hasListener() override
Typed, documented, sectioned configuration singleton read from an .ini content.
#define GUM_ERROR(type, msg)
std::size_t Size
In aGrUM, hashed values are unsigned long int.
gum is the global namespace for all aGrUM entities
#define GUM_EMIT3(signal, arg1, arg2, arg3)