aGrUM 3.3.2
a C++ library for (probabilistic) graphical models
gum::learning::DAG2BNLearner Class Reference

A class that, given a structure and a parameter estimator returns a full Bayes net. More...

#include <agrum/BN/learning/paramUtils/DAG2BNLearner.h>

Inheritance diagram for gum::learning::DAG2BNLearner:
[legend]
Collaboration diagram for gum::learning::DAG2BNLearner:
[legend]

Public Types

enum class  ApproximationSchemeSTATE : char {
  Undefined , Continue , Epsilon , Rate ,
  Limit , TimeLimit , Stopped
}
 The different state of an approximation scheme. More...

Public Member Functions

void setEpsilon (double eps) override
 sets the stopping criterion of EM as being the minimal difference between two consecutive log-likelihoods
void setMinDiffEpsilon (double eps)
 sets the stopping criterion of EM as being the minimal difference between two consecutive log-likelihoods
void setMinEpsilonRate (double rate) override
 sets the stopping criterion of EM as being the minimal log-likelihood's evolution rate
Constructors / Destructors
 DAG2BNLearner ()
 default constructor
 DAG2BNLearner (const DAG2BNLearner &from)
 copy constructor
 DAG2BNLearner (DAG2BNLearner &&from) noexcept
 move constructor
virtual DAG2BNLearner * clone () const
 virtual copy constructor
 ~DAG2BNLearner () override
 destructor
Operators
DAG2BNLearner & operator= (const DAG2BNLearner &from)
 copy operator
DAG2BNLearner & operator= (DAG2BNLearner &&from) noexcept
 move operator
Getters and setters
double epsilon () const override
 Returns the value of epsilon.
void disableEpsilon () override
 Disable stopping criterion on epsilon.
void enableEpsilon () override
 Enable stopping criterion on epsilon.
bool isEnabledEpsilon () const override
 Returns true if stopping criterion on epsilon is enabled, false otherwise.
double minEpsilonRate () const override
 Returns the value of the minimal epsilon rate.
void disableMinEpsilonRate () override
 Disable stopping criterion on epsilon rate.
void enableMinEpsilonRate () override
 Enable stopping criterion on epsilon rate.
bool isEnabledMinEpsilonRate () const override
 Returns true if stopping criterion on epsilon rate is enabled, false otherwise.
void setMaxIter (Size max) override
 Stopping criterion on number of iterations.
Size maxIter () const override
 Returns the criterion on number of iterations.
void disableMaxIter () override
 Disable stopping criterion on max iterations.
void enableMaxIter () override
 Enable stopping criterion on max iterations.
bool isEnabledMaxIter () const override
 Returns true if stopping criterion on max iterations is enabled, false otherwise.
void setMaxTime (double timeout) override
 Stopping criterion on timeout.
double maxTime () const override
 Returns the timeout (in seconds).
double currentTime () const override
 Returns the current running time in second.
void disableMaxTime () override
 Disable stopping criterion on timeout.
void enableMaxTime () override
 Enable stopping criterion on timeout.
bool isEnabledMaxTime () const override
 Returns true if stopping criterion on timeout is enabled, false otherwise.
void setPeriodSize (Size p) override
 How many samples between two stopping is enable.
Size periodSize () const override
 Returns the period size.
void setVerbosity (bool v) override
 Set the verbosity on (true) or off (false).
bool verbosity () const override
 Returns true if verbosity is enabled.
ApproximationSchemeSTATE stateApproximationScheme () const override
 Returns the approximation scheme state.
Size nbrIterations () const override
 Returns the number of iterations.
const std::vector< double > & history () const override
 Returns the scheme history.
void initApproximationScheme ()
 Initialise the scheme.
bool startOfPeriod () const
 Returns true if we are at the beginning of a period (compute error is mandatory).
void updateApproximationScheme (unsigned int incr=1)
 Update the scheme w.r.t the new error and increment steps.
Size remainingBurnIn () const
 Returns the remaining burn in.
void stopApproximationScheme ()
 Stop the approximation scheme.
bool continueApproximationScheme (double error)
 Update the scheme w.r.t the new error.
Getters and setters
std::string messageApproximationScheme () const
 Returns the approximation scheme message.

Public Attributes

Signaler< Size, double, double > onProgress
 Progression, error and time.
Signaler< std::string_view > onStop
 Criteria messageApproximationScheme.

Protected Member Functions

void setFromConfiguration_ (const std::string &section, bool withMaxTime, bool withVerbosity=true)
 Set the parameters of the scheme from a section of gum::Configuration.

Static Protected Member Functions

static Size sizeFromConfiguration_ (const std::string &section, const std::string &key)
 Read a non negative integer key of gum::Configuration.

Protected Attributes

double current_epsilon_ {-1.}
 Current epsilon.
double last_epsilon_ {-1.}
 Last epsilon value.
double current_rate_ {-1.}
 Current rate.
Size current_step_ {0}
 The current step.
Timer timer_
 The timer.
ApproximationSchemeSTATE current_state_
 The current state.
std::vector< double > history_
 The scheme history, used only if verbosity == true.
double eps_
 Threshold for convergence.
bool enabled_eps_
 If true, the threshold convergence is enabled.
double min_rate_eps_
 Threshold for the epsilon rate.
bool enabled_min_rate_eps_
 If true, the minimal threshold for epsilon rate is enabled.
double max_time_
 The timeout.
bool enabled_max_time_
 If true, the timeout is enabled.
Size max_iter_
 The maximum iterations.
bool enabled_max_iter_
 If true, the maximum iterations stopping criterion is enabled.
Size burn_in_
 Number of iterations before checking stopping criteria.
Size period_size_
 Checking criteria frequency.
bool verbosity_
 If true, verbosity is enabled.

Private Member Functions

void stopScheme_ (ApproximationSchemeSTATE new_state)
 Stop the scheme given a new state.

Accessors / Modifiers

DAG2BNLearner & setNoise (const double noise)
 sets the noise amount used to perturb the initial CPTs used by EM
template<GUM_Numeric GUM_SCALAR = double>
BayesNet< GUM_SCALAR > createBNwithEM (ParamEstimator &bootstrap_estimator, ParamEstimator &EM_estimator, const DAG &dag)
 creates a BN with a given structure (dag) using the EM algorithm
template<GUM_Numeric GUM_SCALAR>
BayesNet< GUM_SCALAR > createBNwithEM (ParamEstimator &bootstrap_estimator, ParamEstimator &EM_estimator, const BayesNet< GUM_SCALAR > &bn)
 creates a BN using the EM algorithm with the structure specified by bn, initialized by the parameters of bn
template<GUM_Numeric GUM_SCALAR>
BayesNet< GUM_SCALAR > createBNwithEM (ParamEstimator &bootstrap_estimator, ParamEstimator &EM_estimator, BayesNet< GUM_SCALAR > &&bn)
 creates a BN using the EM algorithm with the structure specified by bn, initialized by the parameters of bn
EMApproximationScheme & approximationScheme ()
 returns the approximation policy of the EM learning algorithm
template<GUM_Numeric GUM_SCALAR = double>
static BayesNet< GUM_SCALAR > createBN (ParamEstimator &estimator, const DAG &dag)
 create a BN from a DAG using a one pass generator (typically ML)

Detailed Description

A class that, given a structure and a parameter estimator returns a full Bayes net.

Definition at line 70 of file DAG2BNLearner.h.

Member Enumeration Documentation

◆ ApproximationSchemeSTATE

The different state of an approximation scheme.

Enumerator
Undefined 
Continue 
Epsilon 
Rate 
Limit 
TimeLimit 
Stopped 

Definition at line 87 of file IApproximationSchemeConfiguration.h.

87 : char {
88 Undefined,
89 Continue,
90 Epsilon,
91 Rate,
92 Limit,
93 TimeLimit,
94 Stopped
95 };

Constructor & Destructor Documentation

◆ DAG2BNLearner() [1/3]

gum::learning::DAG2BNLearner::DAG2BNLearner ( )

default constructor

Referenced by DAG2BNLearner(), DAG2BNLearner(), clone(), createBN(), operator=(), operator=(), and setNoise().

Here is the caller graph for this function:

◆ DAG2BNLearner() [2/3]

gum::learning::DAG2BNLearner::DAG2BNLearner ( const DAG2BNLearner & from)

copy constructor

References DAG2BNLearner().

Here is the call graph for this function:

◆ DAG2BNLearner() [3/3]

gum::learning::DAG2BNLearner::DAG2BNLearner ( DAG2BNLearner && from)
noexcept

move constructor

References DAG2BNLearner().

Here is the call graph for this function:

◆ ~DAG2BNLearner()

gum::learning::DAG2BNLearner::~DAG2BNLearner ( )
override

destructor

Member Function Documentation

◆ approximationScheme()

EMApproximationScheme & gum::learning::DAG2BNLearner::approximationScheme ( )

returns the approximation policy of the EM learning algorithm

References gum::learning::EMApproximationScheme::EMApproximationScheme().

Here is the call graph for this function:

◆ clone()

virtual DAG2BNLearner * gum::learning::DAG2BNLearner::clone ( ) const
nodiscardvirtual

virtual copy constructor

References DAG2BNLearner().

Here is the call graph for this function:

◆ continueApproximationScheme()

bool gum::ApproximationScheme::continueApproximationScheme ( double error)
inherited

Update the scheme w.r.t the new error.

Test the stopping criterion that are enabled.

Parameters
errorThe new error value.
Returns
false if state become != ApproximationSchemeSTATE::Continue
Exceptions
OperationNotAllowedRaised if state != ApproximationSchemeSTATE::Continue.

Definition at line 107 of file approximationScheme.cpp.

107 {
108 // For coherence, we fix the time used in the method
109
110 double timer_step = timer_.step();
111
112 if (enabled_max_time_) {
113 if (timer_step > max_time_) {
115 return false;
116 }
117 }
118
119 if (!startOfPeriod()) { return true; }
120
122 GUM_ERROR(
123 OperationNotAllowed,
124 "state of the approximation scheme is not correct : " << messageApproximationScheme());
125 }
126
127 if (verbosity()) { history_.push_back(error); }
128
129 if (enabled_max_iter_) {
130 if (current_step_ >= max_iter_) {
132 return false;
133 }
134 }
135
137 current_epsilon_ = error; // eps rate isEnabled needs it so affectation was
138 // moved from eps isEnabled below
139
140 if (enabled_eps_) {
141 if (current_epsilon_ <= eps_) {
143 return false;
144 }
145 }
146
147 if (last_epsilon_ >= 0.) {
148 if (current_epsilon_ > .0) {
149 // ! current_epsilon_ can be 0. AND epsilon
150 // isEnabled can be disabled !
152 }
153 // limit with current eps ---> 0 is | 1 - ( last_eps / 0 ) | --->
154 // infinity the else means a return false if we isEnabled the rate below,
155 // as we would have returned false if epsilon isEnabled was enabled
156 else {
158 }
159
163 return false;
164 }
165 }
166 }
167
169 if (onProgress.hasListener()) {
171 }
172
173 return true;
174 } else {
175 return false;
176 }
177 }
Size current_step_
The current step.
double current_epsilon_
Current epsilon.
double last_epsilon_
Last epsilon value.
double eps_
Threshold for convergence.
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.
std::vector< double > history_
The scheme history, used only if verbosity == true.
double current_rate_
Current rate.
ApproximationSchemeSTATE stateApproximationScheme() const override
Returns the approximation scheme state.
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.
void stopScheme_(ApproximationSchemeSTATE new_state)
Stop the scheme given a new state.
bool verbosity() const override
Returns true if verbosity is enabled.
bool enabled_min_rate_eps_
If true, the minimal threshold for epsilon rate is enabled.
Signaler< Size, double, double > onProgress
Progression, error and time.
std::string messageApproximationScheme() const
Returns the approximation scheme message.
double step() const
Returns the delta time between now and the last reset() call (or the constructor).
Definition timer_inl.h:72
#define GUM_ERROR(type, msg)
Definition exceptions.h:76
#define GUM_EMIT3(signal, arg1, arg2, arg3)
Definition signaler.h:291

References gum::IApproximationSchemeConfiguration::Continue, current_epsilon_, current_rate_, current_state_, current_step_, enabled_eps_, enabled_max_iter_, enabled_max_time_, enabled_min_rate_eps_, eps_, gum::IApproximationSchemeConfiguration::Epsilon, GUM_EMIT3, GUM_ERROR, gum::__sig__::BasicSignaler< Args... >::hasListener(), history_, last_epsilon_, gum::IApproximationSchemeConfiguration::Limit, max_iter_, max_time_, gum::IApproximationSchemeConfiguration::messageApproximationScheme(), min_rate_eps_, gum::IApproximationSchemeConfiguration::onProgress, gum::IApproximationSchemeConfiguration::Rate, startOfPeriod(), stateApproximationScheme(), gum::Timer::step(), stopScheme_(), gum::IApproximationSchemeConfiguration::TimeLimit, timer_, and verbosity().

Referenced by gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), gum::MCBNDistance< GUM_SCALAR >::computeKL_(), gum::learning::GreedyHillClimbing::learnStructure(), gum::learning::GreedyThickThinning::learnStructure(), gum::learning::LocalSearchWithTabuList::learnStructure(), gum::SamplingInference< GUM_SCALAR >::loopApproxInference_(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::makeInferenceByOrderedArcs_(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::makeInferenceByRandomOrder_(), and gum::credal::CNLoopyPropagation< GUM_SCALAR >::makeInferenceNodeToNeighbours_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createBN()

template<GUM_Numeric GUM_SCALAR>
BayesNet< GUM_SCALAR > gum::learning::DAG2BNLearner::createBN ( ParamEstimator & estimator,
const DAG & dag )
static

create a BN from a DAG using a one pass generator (typically ML)

create a BN

Definition at line 76 of file DAG2BNLearner_tpl.h.

76 {
77 return DAG2BNLearner()._createBN_(estimator, dag, false);
78 }
DAG2BNLearner()
default constructor

References DAG2BNLearner().

Referenced by createBNwithEM(), gum::learning::ConstraintBasedLearning::learnBN(), gum::learning::GreedyHillClimbing::learnBN(), gum::learning::GreedyThickThinning::learnBN(), gum::learning::LocalSearchWithTabuList::learnBN(), and setNoise().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createBNwithEM() [1/3]

template<GUM_Numeric GUM_SCALAR>
BayesNet< GUM_SCALAR > gum::learning::DAG2BNLearner::createBNwithEM ( ParamEstimator & bootstrap_estimator,
ParamEstimator & EM_estimator,
BayesNet< GUM_SCALAR > && bn )

creates a BN using the EM algorithm with the structure specified by bn, initialized by the parameters of bn

create a BN with EM: initialized by the parameters of a BN

Parameters
bna Bayes Net that is used both for specifying the structure of the returned BN and for initializing the parameters for the EM algorithm. CPTs filled exclusively with only zeroes are initialized directly the BNLearner using the bootstrap_estimator.
Warning
: the bn is modified by EM. If you do not want its value to be altered, prefer using the createBNwithEM with the const ref parameter
Parameters
bootstrap_estimatorthe ParamEstimator used to initialize the CPTs of bn when those are filled exclusively with zeroes
EM_estimatorthe ParamEstimator used in all the EM steps (except the initialization). It is used in a loop until the stopping condition is met (max of relative error on every parameter<epsilon)
Returns
a BN whose structure is the same as bn and whose parameters are learnt by EM.

Definition at line 160 of file DAG2BNLearner_tpl.h.

162 {
163 // estimate the parameters of the fully zeroed CPTs using the bootstrap estimator
164 const VariableNodeMap& varmap = bn.variableNodeMap();
165 for (const auto id: bn.internalDag()) {
166 // get the CPT of node id and its variables in the correct order
167 auto& pot = const_cast< Tensor< GUM_SCALAR >& >(bn.cpt(id));
168
169 // check if the CPT contains only zeroes
170 bool all_zeroed = true;
171 for (gum::Instantiation inst(pot); !inst.end(); inst.inc()) {
172 if (pot[inst] != 0.0) {
173 all_zeroed = false;
174 break;
175 }
176 }
177
178 // estimate the initial parameters of pot if all_zeroed
179 if (all_zeroed) {
180 // get the conditioning variables: they are all the variables except
181 // the first one in pot
182 const auto& vars = pot.variablesSequence();
183 std::vector< NodeId > conditioning_ids(vars.size() - 1);
184 for (auto i = std::size_t(1); i < vars.size(); ++i) {
185 conditioning_ids[i - 1] = varmap.get(*(vars[i]));
186 }
187
188 // estimate the initial parameters of pot
189 bootstrap_estimator.setParameters(id, conditioning_ids, pot, false);
190 }
191 }
192
193 return _performEM_(bootstrap_estimator, EM_estimator, std::move(bn));
194 }

References gum::Instantiation::end(), gum::VariableNodeMap::get(), gum::learning::ParamEstimator::setParameters(), and gum::MultiDimDecorator< GUM_ELEMENT >::variablesSequence().

Here is the call graph for this function:

◆ createBNwithEM() [2/3]

template<GUM_Numeric GUM_SCALAR>
BayesNet< GUM_SCALAR > gum::learning::DAG2BNLearner::createBNwithEM ( ParamEstimator & bootstrap_estimator,
ParamEstimator & EM_estimator,
const BayesNet< GUM_SCALAR > & bn )

creates a BN using the EM algorithm with the structure specified by bn, initialized by the parameters of bn

create a BN with EM: initialized by the parameters of a BN

Parameters
bna Bayes Net that is used both for specifying the structure of the returned BN and for initializing the parameters for the EM algorithm. CPTs filled exclusively with only zeroes are initialized directly the BNLearner using the bootstrap_estimator.
Warning
: the bn is copied, so that it is unmodified by EM. If you do not care about its current value, prefer using the createBNwithEM with the ref ref parameter
Parameters
bootstrap_estimatorthe ParamEstimator used to initialize the CPTs of bn when those are filled exclusively with zeroes
EM_estimatorthe ParamEstimator used in all the EM steps (except the initialization). It is used in a loop until the stopping condition is met (max of relative error on every parameter<epsilon)
Returns
a BN whose structure is the same as bn and whose parameters are learnt by EM.

Definition at line 147 of file DAG2BNLearner_tpl.h.

149 {
150 // for EM estimations, we need to disable caches
151 bootstrap_estimator.clear();
152 EM_estimator.clear();
153
154 auto bn_copy(bn);
155 return createBNwithEM(bootstrap_estimator, EM_estimator, std::move(bn_copy));
156 }
BayesNet< GUM_SCALAR > createBNwithEM(ParamEstimator &bootstrap_estimator, ParamEstimator &EM_estimator, const DAG &dag)
creates a BN with a given structure (dag) using the EM algorithm

References gum::learning::ParamEstimator::clear(), and createBNwithEM().

Here is the call graph for this function:

◆ createBNwithEM() [3/3]

template<GUM_Numeric GUM_SCALAR>
BayesNet< GUM_SCALAR > gum::learning::DAG2BNLearner::createBNwithEM ( ParamEstimator & bootstrap_estimator,
ParamEstimator & EM_estimator,
const DAG & dag )

creates a BN with a given structure (dag) using the EM algorithm

create a BN with EM: initialized by an estimator

Parameters
bootstrap_estimatorthe ParamEstimator used to initialize EM
EM_estimatorthe ParamEstimator used in all the EM steps (except the initialization). It is used in a loop until the stopping condition is met (max of relative error on every parameter<epsilon)
dagthe graphical structure of the returned BN
Returns
a BN learnt by EM whose graphical structure is dag

Definition at line 132 of file DAG2BNLearner_tpl.h.

134 {
135 // for EM estimations, we need to disable caches
136 bootstrap_estimator.clear();
137 EM_estimator.clear();
138
139 // bootstrap EM by learning an initial model
140 BayesNet< GUM_SCALAR > bn = createBN< GUM_SCALAR >(bootstrap_estimator, dag);
141
142 return _performEM_(bootstrap_estimator, EM_estimator, std::move(bn));
143 }
static BayesNet< GUM_SCALAR > createBN(ParamEstimator &estimator, const DAG &dag)
create a BN from a DAG using a one pass generator (typically ML)

References gum::learning::ParamEstimator::clear(), and createBN().

Referenced by createBNwithEM(), and setNoise().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ currentTime()

INLINE double gum::ApproximationScheme::currentTime ( ) const
overridevirtualinherited

Returns the current running time in second.

Returns
Returns the current running time in second.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 137 of file approximationScheme_inl.h.

137{ return timer_.step(); }

References gum::Timer::step(), and timer_.

Referenced by gum::learning::IBNLearner::currentTime(), and gum::learning::IBNLearner::EMCurrentTime().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ disableEpsilon()

INLINE void gum::ApproximationScheme::disableEpsilon ( )
overridevirtualinherited

Disable stopping criterion on epsilon.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 75 of file approximationScheme_inl.h.

75{ enabled_eps_ = false; }

References enabled_eps_.

Referenced by gum::learning::EMApproximationScheme::EMApproximationScheme(), gum::learning::LocalSearchWithTabuList::LocalSearchWithTabuList(), gum::learning::IBNLearner::disableEpsilon(), gum::learning::IBNLearner::EMdisableEpsilon(), gum::SamplingInference< GUM_SCALAR >::loopApproxInference_(), and gum::learning::EMApproximationScheme::setMinEpsilonRate().

Here is the caller graph for this function:

◆ disableMaxIter()

INLINE void gum::ApproximationScheme::disableMaxIter ( )
overridevirtualinherited

Disable stopping criterion on max iterations.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 116 of file approximationScheme_inl.h.

116{ enabled_max_iter_ = false; }

References enabled_max_iter_.

Referenced by gum::learning::GreedyHillClimbing::GreedyHillClimbing(), gum::learning::GreedyThickThinning::GreedyThickThinning(), gum::learning::LocalSearchWithTabuList::LocalSearchWithTabuList(), gum::learning::IBNLearner::disableMaxIter(), and gum::learning::IBNLearner::EMdisableMaxIter().

Here is the caller graph for this function:

◆ disableMaxTime()

INLINE void gum::ApproximationScheme::disableMaxTime ( )
overridevirtualinherited

Disable stopping criterion on timeout.

Returns
Disable stopping criterion on timeout.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 140 of file approximationScheme_inl.h.

140{ enabled_max_time_ = false; }

References enabled_max_time_.

Referenced by ApproximationScheme(), gum::learning::GreedyHillClimbing::GreedyHillClimbing(), gum::learning::GreedyThickThinning::GreedyThickThinning(), gum::learning::LocalSearchWithTabuList::LocalSearchWithTabuList(), gum::learning::IBNLearner::disableMaxTime(), and gum::learning::IBNLearner::EMdisableMaxTime().

Here is the caller graph for this function:

◆ disableMinEpsilonRate()

◆ enableEpsilon()

INLINE void gum::ApproximationScheme::enableEpsilon ( )
overridevirtualinherited

Enable stopping criterion on epsilon.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 78 of file approximationScheme_inl.h.

78{ enabled_eps_ = true; }

References enabled_eps_.

Referenced by gum::learning::IBNLearner::EMenableEpsilon(), gum::learning::IBNLearner::enableEpsilon(), and gum::SamplingInference< GUM_SCALAR >::loopApproxInference_().

Here is the caller graph for this function:

◆ enableMaxIter()

INLINE void gum::ApproximationScheme::enableMaxIter ( )
overridevirtualinherited

Enable stopping criterion on max iterations.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 119 of file approximationScheme_inl.h.

119{ enabled_max_iter_ = true; }

References enabled_max_iter_.

Referenced by gum::learning::IBNLearner::EMenableMaxIter(), and gum::learning::IBNLearner::enableMaxIter().

Here is the caller graph for this function:

◆ enableMaxTime()

INLINE void gum::ApproximationScheme::enableMaxTime ( )
overridevirtualinherited

Enable stopping criterion on timeout.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 143 of file approximationScheme_inl.h.

143{ enabled_max_time_ = true; }

References enabled_max_time_.

Referenced by gum::learning::IBNLearner::EMenableMaxTime(), and gum::learning::IBNLearner::enableMaxTime().

Here is the caller graph for this function:

◆ enableMinEpsilonRate()

INLINE void gum::ApproximationScheme::enableMinEpsilonRate ( )
overridevirtualinherited

Enable stopping criterion on epsilon rate.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 99 of file approximationScheme_inl.h.

99{ enabled_min_rate_eps_ = true; }

References enabled_min_rate_eps_.

Referenced by gum::learning::EMApproximationScheme::EMApproximationScheme(), gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), gum::MCBNDistance< GUM_SCALAR >::computeKL_(), gum::learning::IBNLearner::EMenableMinEpsilonRate(), gum::learning::IBNLearner::enableMinEpsilonRate(), and gum::SamplingInference< GUM_SCALAR >::loopApproxInference_().

Here is the caller graph for this function:

◆ epsilon()

INLINE double gum::ApproximationScheme::epsilon ( ) const
overridevirtualinherited

◆ history()

INLINE const std::vector< double > & gum::ApproximationScheme::history ( ) const
overridevirtualinherited

Returns the scheme history.

Returns
Returns the scheme history.
Exceptions
OperationNotAllowedRaised if the scheme did not performed or if verbosity is set to false.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 179 of file approximationScheme_inl.h.

179 {
181 GUM_ERROR(OperationNotAllowed, "state of the approximation scheme is udefined")
182 }
183
184 if (!verbosity()) GUM_ERROR(OperationNotAllowed, "No history when verbosity=false")
185
186 return history_;
187 }

References GUM_ERROR, history_, stateApproximationScheme(), gum::IApproximationSchemeConfiguration::Undefined, and verbosity().

Referenced by gum::learning::IBNLearner::EMHistory(), and gum::learning::IBNLearner::history().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initApproximationScheme()

INLINE void gum::ApproximationScheme::initApproximationScheme ( )
inherited

Initialise the scheme.

Definition at line 190 of file approximationScheme_inl.h.

190 {
192 current_step_ = 0;
194 history_.clear();
195 timer_.reset();
196 }
void reset()
Reset the timer.
Definition timer_inl.h:53

References gum::IApproximationSchemeConfiguration::Continue, current_epsilon_, current_rate_, current_state_, current_step_, history_, gum::Timer::reset(), and timer_.

Referenced by gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), gum::MCBNDistance< GUM_SCALAR >::computeKL_(), gum::learning::GreedyHillClimbing::learnStructure(), gum::learning::GreedyThickThinning::learnStructure(), gum::learning::LocalSearchWithTabuList::learnStructure(), gum::SamplingInference< GUM_SCALAR >::loopApproxInference_(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::makeInference(), and gum::SamplingInference< GUM_SCALAR >::onStateChanged_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isEnabledEpsilon()

INLINE bool gum::ApproximationScheme::isEnabledEpsilon ( ) const
overridevirtualinherited

Returns true if stopping criterion on epsilon is enabled, false otherwise.

Returns
Returns true if stopping criterion on epsilon is enabled, false otherwise.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 82 of file approximationScheme_inl.h.

82{ return enabled_eps_; }

References enabled_eps_.

Referenced by gum::learning::IBNLearner::EMisEnabledEpsilon(), gum::learning::IBNLearner::isEnabledEpsilon(), and gum::SamplingInference< GUM_SCALAR >::loopApproxInference_().

Here is the caller graph for this function:

◆ isEnabledMaxIter()

INLINE bool gum::ApproximationScheme::isEnabledMaxIter ( ) const
overridevirtualinherited

Returns true if stopping criterion on max iterations is enabled, false otherwise.

Returns
Returns true if stopping criterion on max iterations is enabled, false otherwise.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 123 of file approximationScheme_inl.h.

123{ return enabled_max_iter_; }

References enabled_max_iter_.

Referenced by gum::learning::IBNLearner::EMisEnabledMaxIter(), and gum::learning::IBNLearner::isEnabledMaxIter().

Here is the caller graph for this function:

◆ isEnabledMaxTime()

INLINE bool gum::ApproximationScheme::isEnabledMaxTime ( ) const
overridevirtualinherited

Returns true if stopping criterion on timeout is enabled, false otherwise.

Returns
Returns true if stopping criterion on timeout is enabled, false otherwise.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 147 of file approximationScheme_inl.h.

147{ return enabled_max_time_; }

References enabled_max_time_.

Referenced by gum::learning::IBNLearner::EMisEnabledMaxTime(), and gum::learning::IBNLearner::isEnabledMaxTime().

Here is the caller graph for this function:

◆ isEnabledMinEpsilonRate()

INLINE bool gum::ApproximationScheme::isEnabledMinEpsilonRate ( ) const
overridevirtualinherited

Returns true if stopping criterion on epsilon rate is enabled, false otherwise.

Returns
Returns true if stopping criterion on epsilon rate is enabled, false otherwise.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 103 of file approximationScheme_inl.h.

103{ return enabled_min_rate_eps_; }

References enabled_min_rate_eps_.

Referenced by gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), gum::MCBNDistance< GUM_SCALAR >::computeKL_(), gum::learning::IBNLearner::EMisEnabledMinEpsilonRate(), gum::learning::IBNLearner::isEnabledMinEpsilonRate(), and gum::SamplingInference< GUM_SCALAR >::loopApproxInference_().

Here is the caller graph for this function:

◆ maxIter()

INLINE Size gum::ApproximationScheme::maxIter ( ) const
overridevirtualinherited

Returns the criterion on number of iterations.

Returns
Returns the criterion on number of iterations.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 113 of file approximationScheme_inl.h.

113{ return max_iter_; }

References max_iter_.

Referenced by gum::learning::IBNLearner::EMMaxIter(), and gum::learning::IBNLearner::maxIter().

Here is the caller graph for this function:

◆ maxTime()

INLINE double gum::ApproximationScheme::maxTime ( ) const
overridevirtualinherited

Returns the timeout (in seconds).

Returns
Returns the timeout (in seconds).

Implements gum::IApproximationSchemeConfiguration.

Definition at line 134 of file approximationScheme_inl.h.

134{ return max_time_; }

References max_time_.

Referenced by gum::learning::IBNLearner::EMMaxTime(), and gum::learning::IBNLearner::maxTime().

Here is the caller graph for this function:

◆ messageApproximationScheme()

std::string gum::IApproximationSchemeConfiguration::messageApproximationScheme ( ) const
inherited

Returns the approximation scheme message.

Returns
Returns the approximation scheme message.

Definition at line 64 of file IApproximationSchemeConfiguration.cpp.

64 {
65 switch (stateApproximationScheme()) {
66 case ApproximationSchemeSTATE::Continue : return "in progress";
67
69 return std::format("stopped with epsilon={}", epsilon());
70
72 return std::format("stopped with rate={}", minEpsilonRate());
73
75 return std::format("stopped with max iteration={}", maxIter());
76
78 return std::format("stopped with timeout={}", maxTime());
79
80 case ApproximationSchemeSTATE::Stopped : return "stopped on request";
81
82 case ApproximationSchemeSTATE::Undefined : return "undefined state";
83 }
84 return {};
85 }
virtual double epsilon() const =0
Returns the value of epsilon.
virtual ApproximationSchemeSTATE stateApproximationScheme() const =0
Returns the approximation scheme state.
virtual double minEpsilonRate() const =0
Returns the value of the minimal epsilon rate.
virtual Size maxIter() const =0
Returns the criterion on number of iterations.
virtual double maxTime() const =0
Returns the timeout (in seconds).

References Continue, Epsilon, epsilon(), Limit, maxIter(), maxTime(), minEpsilonRate(), Rate, stateApproximationScheme(), Stopped, TimeLimit, and Undefined.

Referenced by gum::ApproximationScheme::continueApproximationScheme(), gum::learning::IBNLearner::EMStateMessage(), and gum::credal::InferenceEngine< GUM_SCALAR >::getApproximationSchemeMsg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ minEpsilonRate()

INLINE double gum::ApproximationScheme::minEpsilonRate ( ) const
overridevirtualinherited

Returns the value of the minimal epsilon rate.

Returns
Returns the value of the minimal epsilon rate.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 93 of file approximationScheme_inl.h.

93{ return min_rate_eps_; }

References min_rate_eps_.

Referenced by gum::learning::IBNLearner::EMMinEpsilonRate(), and gum::learning::IBNLearner::minEpsilonRate().

Here is the caller graph for this function:

◆ nbrIterations()

INLINE Size gum::ApproximationScheme::nbrIterations ( ) const
overridevirtualinherited

Returns the number of iterations.

Returns
Returns the number of iterations.
Exceptions
OperationNotAllowedRaised if the scheme did not perform.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 170 of file approximationScheme_inl.h.

170 {
172 GUM_ERROR(OperationNotAllowed, "state of the approximation scheme is undefined")
173 }
174
175 return current_step_;
176 }

Referenced by gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), gum::MCBNDistance< GUM_SCALAR >::computeKL_(), gum::learning::IBNLearner::EMnbrIterations(), and gum::learning::IBNLearner::nbrIterations().

Here is the caller graph for this function:

◆ operator=() [1/2]

DAG2BNLearner & gum::learning::DAG2BNLearner::operator= ( const DAG2BNLearner & from)

copy operator

References DAG2BNLearner().

Here is the call graph for this function:

◆ operator=() [2/2]

DAG2BNLearner & gum::learning::DAG2BNLearner::operator= ( DAG2BNLearner && from)
noexcept

move operator

References DAG2BNLearner().

Here is the call graph for this function:

◆ periodSize()

INLINE Size gum::ApproximationScheme::periodSize ( ) const
overridevirtualinherited

Returns the period size.

Returns
Returns the period size.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 156 of file approximationScheme_inl.h.

156{ return period_size_; }
Size period_size_
Checking criteria frequency.

References period_size_.

Referenced by gum::learning::IBNLearner::EMPeriodSize(), and gum::learning::IBNLearner::periodSize().

Here is the caller graph for this function:

◆ remainingBurnIn()

INLINE Size gum::ApproximationScheme::remainingBurnIn ( ) const
inherited

Returns the remaining burn in.

Returns
Returns the remaining burn in.

Definition at line 213 of file approximationScheme_inl.h.

213 {
214 if (burn_in_ > current_step_) {
215 return burn_in_ - current_step_;
216 } else {
217 return 0;
218 }
219 }
Size burn_in_
Number of iterations before checking stopping criteria.

◆ setEpsilon()

INLINE void gum::learning::EMApproximationScheme::setEpsilon ( double eps)
overridevirtualinherited

sets the stopping criterion of EM as being the minimal difference between two consecutive log-likelihoods

Parameters
epsthe log-likelihood difference below which EM stops its iterations
Warning
setting this stopping criterion disables the min rate criterion (if it was enabled)
Exceptions
OutOfBoundsRaised if eps <= 0

Reimplemented from gum::ApproximationScheme.

Definition at line 53 of file EMApproximationScheme_inl.h.

53 {
54 if (eps <= 0) GUM_ERROR(OutOfBounds, "EM's min diff epsilon value must be strictly positive")
57 }
ApproximationScheme()
Build a scheme whose parameters are read from the configuration.
void disableMinEpsilonRate() override
Disable stopping criterion on epsilon rate.
void setEpsilon(double eps) override
sets the stopping criterion of EM as being the minimal difference between two consecutive log-likelih...

References gum::ApproximationScheme::disableMinEpsilonRate(), GUM_ERROR, and gum::ApproximationScheme::setEpsilon().

Referenced by ~EMApproximationScheme(), gum::learning::IBNLearner::EMsetEpsilon(), gum::learning::IBNLearner::setEpsilon(), setMinDiffEpsilon(), and gum::learning::IBNLearner::useEMWithDiffCriterion().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFromConfiguration_()

void gum::ApproximationScheme::setFromConfiguration_ ( const std::string & section,
bool withMaxTime,
bool withVerbosity = true )
protectedinherited

Set the parameters of the scheme from a section of gum::Configuration.

The keys epsilon, minEpsilonRate, maxIter and periodSize of the section are read (and maxTime if withMaxTime is true, verbosity if withVerbosity is true, burnIn if the section has this key) and applied through the corresponding setters, which enable the matching stopping criteria and check the values.

Parameters
sectionThe name of the section of the configuration.
withMaxTimeIf true, the key maxTime is read and the timeout is enabled.
withVerbosityIf true, the key verbosity is read ; otherwise the verbosity is left unchanged.
Exceptions
OutOfBoundsRaised if a value of the section is not valid for its setter.

Definition at line 90 of file approximationScheme.cpp.

92 {
93 const auto& conf = Configuration::instance();
94
95 setEpsilon(conf.typed< double >(section, "epsilon"));
96 setMinEpsilonRate(conf.typed< double >(section, "minEpsilonRate"));
97 setMaxIter(sizeFromConfiguration_(section, "maxIter"));
98 setPeriodSize(sizeFromConfiguration_(section, "periodSize"));
99 if (withVerbosity) setVerbosity(conf.typed< bool >(section, "verbosity"));
100 if (withMaxTime) setMaxTime(conf.typed< double >(section, "maxTime"));
101 // only some sections have a burn-in (approximation, gibbs, gibbsKL)
102 if (conf.has(section, "burnIn")) burn_in_ = sizeFromConfiguration_(section, "burnIn");
103 }
static Size sizeFromConfiguration_(const std::string &section, 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 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 setPeriodSize(Size p) override
How many samples between two stopping is enable.
void setVerbosity(bool v) override
Set the verbosity on (true) or off (false).
void setEpsilon(double eps) override
Given that we approximate f(t), stopping criterion on |f(t+1)-f(t)|.
static Configuration & instance()
The global configuration.

References burn_in_, gum::Configuration::instance(), setEpsilon(), setMaxIter(), setMaxTime(), setMinEpsilonRate(), setPeriodSize(), setVerbosity(), and sizeFromConfiguration_().

Referenced by ApproximationScheme(), gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::MCBNDistance< GUM_SCALAR >::MCBNDistance(), gum::MCBNDistance< GUM_SCALAR >::MCBNDistance(), and gum::SamplingInference< GUM_SCALAR >::SamplingInference().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setMaxIter()

INLINE void gum::ApproximationScheme::setMaxIter ( Size max)
overridevirtualinherited

Stopping criterion on number of iterations.

If the criterion was disabled it will be enabled.

Parameters
maxThe maximum number of iterations.
Exceptions
OutOfBoundsRaised if max <= 1.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 106 of file approximationScheme_inl.h.

106 {
107 if (max < 1) { GUM_ERROR(OutOfBounds, "max should be >=1") }
108 max_iter_ = max;
109 enabled_max_iter_ = true;
110 }

References enabled_max_iter_, GUM_ERROR, and max_iter_.

Referenced by gum::learning::IBNLearner::EMsetMaxIter(), setFromConfiguration_(), and gum::learning::IBNLearner::setMaxIter().

Here is the caller graph for this function:

◆ setMaxTime()

INLINE void gum::ApproximationScheme::setMaxTime ( double timeout)
overridevirtualinherited

Stopping criterion on timeout.

If the criterion was disabled it will be enabled.

Parameters
timeoutThe timeout value in seconds.
Exceptions
OutOfBoundsRaised if timeout <= 0.0.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 127 of file approximationScheme_inl.h.

127 {
128 if (timeout <= 0.) { GUM_ERROR(OutOfBounds, "timeout should be >0.") }
129 max_time_ = timeout;
130 enabled_max_time_ = true;
131 }

References enabled_max_time_, GUM_ERROR, and max_time_.

Referenced by gum::learning::IBNLearner::EMsetMaxTime(), setFromConfiguration_(), and gum::learning::IBNLearner::setMaxTime().

Here is the caller graph for this function:

◆ setMinDiffEpsilon()

INLINE void gum::learning::EMApproximationScheme::setMinDiffEpsilon ( double eps)
inherited

sets the stopping criterion of EM as being the minimal difference between two consecutive log-likelihoods

Parameters
epsthe log-likelihood difference below which EM stops its iterations
Warning
setting this stopping criterion disables the min rate criterion (if it was enabled)
Exceptions
OutOfBoundsRaised if eps <= 0

Definition at line 59 of file EMApproximationScheme_inl.h.

59{ setEpsilon(eps); }

References setEpsilon().

Referenced by ~EMApproximationScheme().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setMinEpsilonRate()

INLINE void gum::learning::EMApproximationScheme::setMinEpsilonRate ( double rate)
overridevirtualinherited

sets the stopping criterion of EM as being the minimal log-likelihood's evolution rate

Parameters
ratethe log-likelihood evolution rate below which EM stops its iterations
Warning
setting this stopping criterion disables the min diff criterion (if it was enabled)
Exceptions
OutOfBoundsif rate<0

Reimplemented from gum::ApproximationScheme.

Definition at line 61 of file EMApproximationScheme_inl.h.

61 {
62 if (rate <= 0.0)
63 GUM_ERROR(OutOfBounds, "EM's min log-likelihood evolution rate must be strictly positive")
66 }
void disableEpsilon() override
Disable stopping criterion on epsilon.
void setMinEpsilonRate(double rate) override
sets the stopping criterion of EM as being the minimal log-likelihood's evolution rate

References gum::ApproximationScheme::disableEpsilon(), GUM_ERROR, and gum::ApproximationScheme::setMinEpsilonRate().

Referenced by ~EMApproximationScheme(), gum::learning::IBNLearner::EMsetMinEpsilonRate(), gum::learning::IBNLearner::setMinEpsilonRate(), and gum::learning::IBNLearner::useEM().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setNoise()

DAG2BNLearner & gum::learning::DAG2BNLearner::setNoise ( const double noise)

sets the noise amount used to perturb the initial CPTs used by EM

Parameters
noiseWhen EM starts, it initializes all the CPTs of the Bayes net. EM adds a noise to these CPTs by mixing their values with some random noise. The formula used is, up to some normalizing constant: new_cpt = (1-noise) * cpt + noise * random_cpt(). Of course, noise must belong to interval [0,1].

References DAG2BNLearner(), createBN(), and createBNwithEM().

Referenced by gum::learning::IBNLearner::useEM(), and gum::learning::IBNLearner::useEMWithDiffCriterion().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setPeriodSize()

INLINE void gum::ApproximationScheme::setPeriodSize ( Size p)
overridevirtualinherited

How many samples between two stopping is enable.

Parameters
pThe new period value.
Exceptions
OutOfBoundsRaised if p < 1.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 150 of file approximationScheme_inl.h.

150 {
151 if (p < 1) { GUM_ERROR(OutOfBounds, "p should be >=1") }
152
153 period_size_ = p;
154 }

References GUM_ERROR, and period_size_.

Referenced by gum::learning::IBNLearner::EMsetPeriodSize(), setFromConfiguration_(), and gum::learning::IBNLearner::setPeriodSize().

Here is the caller graph for this function:

◆ setVerbosity()

INLINE void gum::ApproximationScheme::setVerbosity ( bool v)
overridevirtualinherited

Set the verbosity on (true) or off (false).

Parameters
vIf true, then verbosity is turned on.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 159 of file approximationScheme_inl.h.

159{ verbosity_ = v; }
bool verbosity_
If true, verbosity is enabled.

References verbosity_.

Referenced by gum::learning::IBNLearner::EMsetVerbosity(), setFromConfiguration_(), and gum::learning::IBNLearner::setVerbosity().

Here is the caller graph for this function:

◆ sizeFromConfiguration_()

Size gum::ApproximationScheme::sizeFromConfiguration_ ( const std::string & section,
const std::string & key )
staticprotectedinherited

Read a non negative integer key of gum::Configuration.

Parameters
sectionThe name of the section of the configuration.
keyThe name of the key of the section.
Returns
The value of the key.
Exceptions
OutOfBoundsRaised if the value is negative.

Definition at line 79 of file approximationScheme.cpp.

80 {
81 const auto value = Configuration::instance().typed< std::int64_t >(section, key);
82 if (value < 0) {
83 GUM_ERROR(OutOfBounds,
84 "The key " << section << "." << key
85 << " of the configuration must not be negative.")
86 }
87 return static_cast< Size >(value);
88 }
T typed(std::string_view section, std::string_view key) const
Value of section.key converted according to its declared type.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74

References GUM_ERROR, gum::Configuration::instance(), and gum::Configuration::typed().

Referenced by gum::GibbsSampling< GUM_SCALAR >::GibbsSampling(), and setFromConfiguration_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ startOfPeriod()

INLINE bool gum::ApproximationScheme::startOfPeriod ( ) const
inherited

Returns true if we are at the beginning of a period (compute error is mandatory).

Returns
Returns true if we are at the beginning of a period (compute error is mandatory).

Definition at line 200 of file approximationScheme_inl.h.

200 {
201 if (current_step_ < burn_in_) { return false; }
202
203 if (period_size_ == 1) { return true; }
204
205 return ((current_step_ - burn_in_) % period_size_ == 0);
206 }

Referenced by continueApproximationScheme().

Here is the caller graph for this function:

◆ stateApproximationScheme()

INLINE IApproximationSchemeConfiguration::ApproximationSchemeSTATE gum::ApproximationScheme::stateApproximationScheme ( ) const
overridevirtualinherited

Returns the approximation scheme state.

Returns
Returns the approximation scheme state.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 165 of file approximationScheme_inl.h.

165 {
166 return current_state_;
167 }

Referenced by continueApproximationScheme(), gum::learning::IBNLearner::EMState(), gum::learning::IBNLearner::EMStateApproximationScheme(), history(), and gum::learning::IBNLearner::stateApproximationScheme().

Here is the caller graph for this function:

◆ stopApproximationScheme()

INLINE void gum::ApproximationScheme::stopApproximationScheme ( )
inherited

Stop the approximation scheme.

Definition at line 222 of file approximationScheme_inl.h.

References gum::IApproximationSchemeConfiguration::Continue, and current_state_.

Referenced by gum::learning::GreedyHillClimbing::learnStructure(), gum::learning::GreedyThickThinning::learnStructure(), gum::learning::LocalSearchWithTabuList::learnStructure(), and gum::credal::CNLoopyPropagation< GUM_SCALAR >::makeInferenceNodeToNeighbours_().

Here is the caller graph for this function:

◆ stopScheme_()

INLINE void gum::ApproximationScheme::stopScheme_ ( ApproximationSchemeSTATE new_state)
privateinherited

Stop the scheme given a new state.

Parameters
new_stateThe scheme new state.

Definition at line 231 of file approximationScheme_inl.h.

231 {
232 if (new_state == ApproximationSchemeSTATE::Continue) { return; }
233
234 if (new_state == ApproximationSchemeSTATE::Undefined) { return; }
235
236 current_state_ = new_state;
237 timer_.pause();
238
240 }
Signaler< std::string_view > onStop
Criteria messageApproximationScheme.
double pause()
Pause the timer and return the delta (.
Definition timer_inl.h:75
#define GUM_EMIT1(signal, arg1)
Definition signaler.h:289

References gum::IApproximationSchemeConfiguration::Continue, and gum::IApproximationSchemeConfiguration::Undefined.

Referenced by continueApproximationScheme().

Here is the caller graph for this function:

◆ updateApproximationScheme()

INLINE void gum::ApproximationScheme::updateApproximationScheme ( unsigned int incr = 1)
inherited

◆ verbosity()

INLINE bool gum::ApproximationScheme::verbosity ( ) const
overridevirtualinherited

Returns true if verbosity is enabled.

Returns
Returns true if verbosity is enabled.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 161 of file approximationScheme_inl.h.

161{ return verbosity_; }

Referenced by ApproximationScheme(), gum::learning::EMApproximationScheme::EMApproximationScheme(), continueApproximationScheme(), gum::learning::IBNLearner::EMVerbosity(), history(), and gum::learning::IBNLearner::verbosity().

Here is the caller graph for this function:

Member Data Documentation

◆ burn_in_

Size gum::ApproximationScheme::burn_in_
protectedinherited

◆ current_epsilon_

double gum::ApproximationScheme::current_epsilon_ {-1.}
protectedinherited

Current epsilon.

Definition at line 419 of file approximationScheme.h.

Referenced by continueApproximationScheme(), and initApproximationScheme().

◆ current_rate_

double gum::ApproximationScheme::current_rate_ {-1.}
protectedinherited

Current rate.

Definition at line 425 of file approximationScheme.h.

Referenced by continueApproximationScheme(), and initApproximationScheme().

◆ current_state_

ApproximationSchemeSTATE gum::ApproximationScheme::current_state_
protectedinherited

◆ current_step_

◆ enabled_eps_

bool gum::ApproximationScheme::enabled_eps_
protectedinherited

If true, the threshold convergence is enabled.

Definition at line 443 of file approximationScheme.h.

Referenced by ApproximationScheme(), continueApproximationScheme(), disableEpsilon(), enableEpsilon(), isEnabledEpsilon(), and setEpsilon().

◆ enabled_max_iter_

bool gum::ApproximationScheme::enabled_max_iter_
protectedinherited

If true, the maximum iterations stopping criterion is enabled.

Definition at line 461 of file approximationScheme.h.

Referenced by ApproximationScheme(), continueApproximationScheme(), disableMaxIter(), enableMaxIter(), isEnabledMaxIter(), and setMaxIter().

◆ enabled_max_time_

bool gum::ApproximationScheme::enabled_max_time_
protectedinherited

If true, the timeout is enabled.

Definition at line 455 of file approximationScheme.h.

Referenced by ApproximationScheme(), continueApproximationScheme(), disableMaxTime(), enableMaxTime(), isEnabledMaxTime(), and setMaxTime().

◆ enabled_min_rate_eps_

bool gum::ApproximationScheme::enabled_min_rate_eps_
protectedinherited

If true, the minimal threshold for epsilon rate is enabled.

Definition at line 449 of file approximationScheme.h.

Referenced by ApproximationScheme(), continueApproximationScheme(), disableMinEpsilonRate(), enableMinEpsilonRate(), isEnabledMinEpsilonRate(), and setMinEpsilonRate().

◆ eps_

double gum::ApproximationScheme::eps_
protectedinherited

Threshold for convergence.

Definition at line 440 of file approximationScheme.h.

Referenced by ApproximationScheme(), continueApproximationScheme(), epsilon(), and setEpsilon().

◆ history_

std::vector< double > gum::ApproximationScheme::history_
protectedinherited

The scheme history, used only if verbosity == true.

Definition at line 437 of file approximationScheme.h.

Referenced by continueApproximationScheme(), history(), and initApproximationScheme().

◆ last_epsilon_

double gum::ApproximationScheme::last_epsilon_ {-1.}
protectedinherited

Last epsilon value.

Definition at line 422 of file approximationScheme.h.

Referenced by continueApproximationScheme().

◆ max_iter_

Size gum::ApproximationScheme::max_iter_
protectedinherited

The maximum iterations.

Definition at line 458 of file approximationScheme.h.

Referenced by ApproximationScheme(), continueApproximationScheme(), maxIter(), and setMaxIter().

◆ max_time_

double gum::ApproximationScheme::max_time_
protectedinherited

The timeout.

Definition at line 452 of file approximationScheme.h.

Referenced by ApproximationScheme(), continueApproximationScheme(), maxTime(), and setMaxTime().

◆ min_rate_eps_

double gum::ApproximationScheme::min_rate_eps_
protectedinherited

Threshold for the epsilon rate.

Definition at line 446 of file approximationScheme.h.

Referenced by ApproximationScheme(), continueApproximationScheme(), minEpsilonRate(), and setMinEpsilonRate().

◆ onProgress

◆ onStop

Signaler< std::string_view > gum::IApproximationSchemeConfiguration::onStop
inherited

Criteria messageApproximationScheme.

Definition at line 84 of file IApproximationSchemeConfiguration.h.

Referenced by gum::learning::IBNLearner::distributeStop().

◆ period_size_

Size gum::ApproximationScheme::period_size_
protectedinherited

Checking criteria frequency.

Definition at line 467 of file approximationScheme.h.

Referenced by ApproximationScheme(), periodSize(), and setPeriodSize().

◆ timer_

◆ verbosity_

bool gum::ApproximationScheme::verbosity_
protectedinherited

If true, verbosity is enabled.

Definition at line 470 of file approximationScheme.h.

Referenced by ApproximationScheme(), and setVerbosity().


The documentation for this class was generated from the following files: