aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
gum::MCBNDistance< GUM_SCALAR > Class Template Reference

MCBNDistance computes the KL divergence betweens 2 BNs using an approximation pattern: independent (forward/topological) Monte Carlo sampling. More...

#include <MCBNDistance.h>

Inheritance diagram for gum::MCBNDistance< GUM_SCALAR >:
Collaboration diagram for gum::MCBNDistance< GUM_SCALAR >:

Public Types

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

Public Member Functions

 MCBNDistance (const IBayesNet< GUM_SCALAR > &P, const IBayesNet< GUM_SCALAR > &Q)
 constructor must give 2 BNs
 MCBNDistance (const BNdistance< GUM_SCALAR > &kl)
 copy constructor
 ~MCBNDistance () override
 destructor
Complexity difficulty () const
 return KL::Complexity::Heavy,KL::Complexity::Difficult,KL::Complexity::Correct depending on the BNs p and q
Accessors to results. The first call do the computations. The

others do not.

double klPQ ()
Size errorPQ ()
double klQP ()
Size errorQP ()
double hellinger ()
double bhattacharya ()
double jsd ()
const IBayesNet< GUM_SCALAR > & p () const
const IBayesNet< GUM_SCALAR > & q () const
Getters and setters
void setEpsilon (double eps) override
 Given that we approximate f(t), stopping criterion on |f(t+1)-f(t)|.
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.
void setMinEpsilonRate (double rate) override
 Given that we approximate f(t), stopping criterion on d/dt(|f(t+1)-f(t)|).
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, doubleonProgress
 Progression, error and time.
Signaler< std::string_view > onStop
 Criteria messageApproximationScheme.

Protected Member Functions

void computeKL_ () final
Instantiation drawSample_ (const Sequence< NodeId > &topoOrder) const
 draws an instantiation of p_'s variables, independently, following topoOrder (no evidence to handle in this hierarchy)
void process_ ()

Protected Attributes

const IBayesNet< GUM_SCALAR > & p_
const IBayesNet< GUM_SCALAR > & q_
GUM_SCALAR klPQ_
GUM_SCALAR klQP_
Size errorPQ_
Size errorQP_
GUM_SCALAR hellinger_
GUM_SCALAR bhattacharya_
GUM_SCALAR jsd_
double current_epsilon_
 Current epsilon.
double last_epsilon_
 Last epsilon value.
double current_rate_
 Current rate.
Size current_step_
 The current step.
Timer timer_
 The timer.
ApproximationSchemeSTATE current_state_
 The current state.
std::vector< doublehistory_
 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

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

Private Attributes

Complexity _difficulty_
bool _done_

Detailed Description

template<GUM_Numeric GUM_SCALAR>
class gum::MCBNDistance< GUM_SCALAR >

MCBNDistance computes the KL divergence betweens 2 BNs using an approximation pattern: independent (forward/topological) Monte Carlo sampling.

Unlike GibbsBNdistance, samples are drawn independently from P at each iteration (no Markov chain, hence no burn-in needed).

KL.process() computes KL(P||Q) using klPQ() and KL(Q||P) using klQP(). The computations are made once. The second is for free :) MCBNDistance allows as well to compute in the same time the Hellinger distance ( \(*\sqrt{\sum_i (\sqrt{p_i}-\sqrt{q_i})^2}\)) (Kokolakis and Nanopoulos, 2001) and Bhattacharya distance (Kaylath,T. 1967)

It may happen that P*ln(P/Q) is not computable (Q=0 and P!=0). In such a case, KL keeps working but trace this error (errorPQ() and errorQP()). In those cases, Hellinger distance approximation is under-evaluated.

Warning
: convergence and stop criteria are designed w.r.t the main computation : KL(P||Q). The 3 others have no guarantee.

snippets :

gum::KL base_kl(net1,net2);
if (base_kl.difficulty()!=KL::HEAVY) {
gum::ExactBNdistance kl(base_kl);
std::cout<<"KL net1||net2 :"<<kl.klPQ()<<std::endl;
} else {
gum::MCBNDistance kl(base_kl);
std::cout<<"KL net1||net2 :"<<kl.klPQ()<<std::endl;
}
ExactBNdistance computes exactly the KL divergence betweens 2 BNs.
MCBNDistance computes the KL divergence betweens 2 BNs using an approximation pattern: independent (f...

Definition at line 97 of file MCBNDistance.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

◆ MCBNDistance() [1/2]

template<GUM_Numeric GUM_SCALAR>
gum::MCBNDistance< GUM_SCALAR >::MCBNDistance ( const IBayesNet< GUM_SCALAR > & P,
const IBayesNet< GUM_SCALAR > & Q )

constructor must give 2 BNs

Exceptions
gum::OperationNotAllowedif the 2 BNs have not the same domainSize or compatible node sets.

Definition at line 69 of file MCBNDistance_tpl.h.

70 :
73
80 }
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.
ApproximationScheme(bool verbosity=false)
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)|.
BNdistance(const IBayesNet< GUM_SCALAR > &P, const IBayesNet< GUM_SCALAR > &Q)
constructor must give 2 BNs
MCBNDistance(const IBayesNet< GUM_SCALAR > &P, const IBayesNet< GUM_SCALAR > &Q)
constructor must give 2 BNs

References gum::ApproximationScheme::ApproximationScheme(), gum::BNdistance< GUM_SCALAR >::BNdistance(), MCBNDistance(), MCBNDISTANCE_DEFAULT_EPSILON, MCBNDISTANCE_DEFAULT_MAXITER, MCBNDISTANCE_DEFAULT_MIN_EPSILON_RATE, MCBNDISTANCE_DEFAULT_PERIOD_SIZE, MCBNDISTANCE_DEFAULT_TIMEOUT, MCBNDISTANCE_DEFAULT_VERBOSITY, gum::ApproximationScheme::setEpsilon(), gum::ApproximationScheme::setMaxIter(), gum::ApproximationScheme::setMaxTime(), gum::ApproximationScheme::setMinEpsilonRate(), gum::ApproximationScheme::setPeriodSize(), and gum::ApproximationScheme::setVerbosity().

Referenced by MCBNDistance(), MCBNDistance(), and ~MCBNDistance().

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

◆ MCBNDistance() [2/2]

◆ ~MCBNDistance()

template<GUM_Numeric GUM_SCALAR>
gum::MCBNDistance< GUM_SCALAR >::~MCBNDistance ( )
override

destructor

Definition at line 96 of file MCBNDistance_tpl.h.

96 {
98 }

References MCBNDistance().

Here is the call graph for this function:

Member Function Documentation

◆ _checkCompatibility_()

template<GUM_Numeric GUM_SCALAR>
bool gum::BNdistance< GUM_SCALAR >::_checkCompatibility_ ( ) const
privateinherited

Definition at line 145 of file BNdistance_tpl.h.

145 {
146 // should not be used
147 if (p_.size() != q_.size())
149 "BNdistance : the 2 BNs are not compatible (not the same size)")
150
151 for (auto node: p_.nodes()) {
152 const DiscreteVariable& vp = p_.variable(node);
153 if (!q_.exists(vp.name())) {
154 GUM_ERROR(OperationNotAllowed,
155 "BNdistance : the 2 BNs are not compatible (variable : " + vp.name() + ")");
156 }
157 const DiscreteVariable& vq = q_.variableFromName(vp.name());
158 if (vp != vq)
160 "BNdistance : the 2 BNs are not compatible "
161 "(not the same variable for the same name : "
162 + vp.toString() + "and " + vq.toString() + ")");
163 }
164
165 if (std::fabs(p_.log10DomainSize() - q_.log10DomainSize()) > 1e-14) {
167 "BNdistance : the 2 BNs are not compatible (not the same domainSize) : p="
168 << p_.log10DomainSize() << " q=" << q_.log10DomainSize() << " => "
169 << p_.log10DomainSize() - q_.log10DomainSize());
170 }
171
172 return true;
173 }
const IBayesNet< GUM_SCALAR > & q_
Definition BNdistance.h:157
const IBayesNet< GUM_SCALAR > & p_
Definition BNdistance.h:156
#define GUM_ERROR(type, msg)
Definition exceptions.h:76

References GUM_ERROR, gum::Variable::name(), p_, q_, and gum::DiscreteVariable::toString().

Referenced by BNdistance().

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

◆ bhattacharya()

template<GUM_Numeric GUM_SCALAR>
double gum::BNdistance< GUM_SCALAR >::bhattacharya ( )
inherited
Returns
Bhattacharya distance (
See also
http://en.wikipedia.org/wiki/Bhattacharya_distance)

Definition at line 110 of file BNdistance_tpl.h.

110 {
111 process_();
112 return bhattacharya_;
113 }
GUM_SCALAR bhattacharya_
Definition BNdistance.h:166

References bhattacharya_, and process_().

Here is the call graph for this function:

◆ computeKL_()

template<GUM_Numeric GUM_SCALAR>
void gum::MCBNDistance< GUM_SCALAR >::computeKL_ ( )
finalprotectedvirtual

Reimplemented from gum::BNdistance< GUM_SCALAR >.

Definition at line 114 of file MCBNDistance_tpl.h.

114 {
115 auto Iq = q_.completeInstantiation();
116 const auto topoOrder = p_.topologicalOrder();
118
119 // map between drawSample_() variables and q_ variables (using name of vars)
121 {
122 auto Ip = p_.completeInstantiation();
123 for (Idx ite = 0; ite < Ip.nbrDim(); ++ite) {
124 map.insert(&Ip.variable(ite), &q_.variableFromName(Ip.variable(ite).name()));
125 }
126 }
127
128 klPQ_ = klQP_ = hellinger_ = jsd_ = (GUM_SCALAR)0.0;
129 errorPQ_ = errorQP_ = 0;
131 delta = ratio = error = (GUM_SCALAR)-1;
132 GUM_SCALAR oldPQ = 0.0;
134
135 do {
136 this->disableMinEpsilonRate();
139
140 Iq.setValsFrom(map, I);
141
142 pp = p_.jointProbability(I);
143 pq = q_.jointProbability(Iq);
144 pmid = (pp + pq) / 2.0;
145
146 if (pp != (GUM_SCALAR)0.0) {
148
149 if (pq != (GUM_SCALAR)0.0) {
151 this->enableMinEpsilonRate();
152 ratio = pq / pp;
154 klPQ_ += delta;
155
156 // pmid!=0
157 jsd_ -= std::log2(pp / pmid) + ratio * std::log2(pq / pmid);
158 } else {
159 errorPQ_++;
160 }
161 }
162
163 if (pq != (GUM_SCALAR)0.0) {
164 if (pp != (GUM_SCALAR)0.0) {
165 // if we are here, it is certain that delta and ratio have been
166 // computed further lines above.
167 klQP_ += (GUM_SCALAR)(-delta * ratio);
168 } else {
169 errorQP_++;
170 }
171 }
172
173 if (this->isEnabledMinEpsilonRate()) {
174 // delta is used as a temporary variable
177 oldPQ = delta;
178 }
180
181 klPQ_ = -klPQ_ / (nbrIterations());
182 klQP_ = -klQP_ / (nbrIterations());
183 jsd_ = -0.5 * jsd_ / (nbrIterations());
186 }
void updateApproximationScheme(unsigned int incr=1)
Update the scheme w.r.t the new error and increment steps.
bool isEnabledMinEpsilonRate() const override
Returns true if stopping criterion on epsilon rate is enabled, false otherwise.
void disableMinEpsilonRate() override
Disable stopping criterion on epsilon rate.
bool continueApproximationScheme(double error)
Update the scheme w.r.t the new error.
void initApproximationScheme()
Initialise the scheme.
Size nbrIterations() const override
Returns the number of iterations.
void enableMinEpsilonRate() override
Enable stopping criterion on epsilon rate.
GUM_SCALAR hellinger_
Definition BNdistance.h:165
GUM_SCALAR klPQ_
Definition BNdistance.h:159
GUM_SCALAR jsd_
Definition BNdistance.h:167
GUM_SCALAR klQP_
Definition BNdistance.h:160
Instantiation drawSample_(const Sequence< NodeId > &topoOrder) const
draws an instantiation of p_'s variables, independently, following topoOrder (no evidence to handle i...

References gum::BNdistance< GUM_SCALAR >::bhattacharya_, gum::ApproximationScheme::continueApproximationScheme(), gum::ApproximationScheme::disableMinEpsilonRate(), drawSample_(), gum::ApproximationScheme::enableMinEpsilonRate(), gum::BNdistance< GUM_SCALAR >::errorPQ_, gum::BNdistance< GUM_SCALAR >::errorQP_, gum::BNdistance< GUM_SCALAR >::hellinger_, gum::ApproximationScheme::initApproximationScheme(), gum::HashTable< Key, Val >::insert(), gum::ApproximationScheme::isEnabledMinEpsilonRate(), gum::BNdistance< GUM_SCALAR >::jsd_, gum::BNdistance< GUM_SCALAR >::klPQ_, gum::BNdistance< GUM_SCALAR >::klQP_, gum::ApproximationScheme::nbrIterations(), gum::BNdistance< GUM_SCALAR >::p_, gum::BNdistance< GUM_SCALAR >::q_, and gum::ApproximationScheme::updateApproximationScheme().

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 69 of file approximationScheme.cpp.

69 {
70 // For coherence, we fix the time used in the method
71
72 double timer_step = timer_.step();
73
75 if (timer_step > max_time_) {
77 return false;
78 }
79 }
80
81 if (!startOfPeriod()) { return true; }
82
85 OperationNotAllowed,
86 "state of the approximation scheme is not correct : " << messageApproximationScheme());
87 }
88
89 if (verbosity()) { history_.push_back(error); }
90
92 if (current_step_ >= max_iter_) {
94 return false;
95 }
96 }
97
99 current_epsilon_ = error; // eps rate isEnabled needs it so affectation was
100 // moved from eps isEnabled below
101
102 if (enabled_eps_) {
103 if (current_epsilon_ <= eps_) {
105 return false;
106 }
107 }
108
109 if (last_epsilon_ >= 0.) {
110 if (current_epsilon_ > .0) {
111 // ! current_epsilon_ can be 0. AND epsilon
112 // isEnabled can be disabled !
114 }
115 // limit with current eps ---> 0 is | 1 - ( last_eps / 0 ) | --->
116 // infinity the else means a return false if we isEnabled the rate below,
117 // as we would have returned false if epsilon isEnabled was enabled
118 else {
120 }
121
125 return false;
126 }
127 }
128 }
129
131 if (onProgress.hasListener()) {
133 }
134
135 return true;
136 } else {
137 return false;
138 }
139 }
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.
#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, history_, last_epsilon_, gum::IApproximationSchemeConfiguration::Limit, max_iter_, max_time_, gum::IApproximationSchemeConfiguration::messageApproximationScheme(), min_rate_eps_, gum::IApproximationSchemeConfiguration::onProgress, gum::IApproximationSchemeConfiguration::Rate, startOfPeriod(), stateApproximationScheme(), 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:

◆ 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 timer_.

◆ difficulty()

template<GUM_Numeric GUM_SCALAR>
Complexity gum::BNdistance< GUM_SCALAR >::difficulty ( ) const
inherited

return KL::Complexity::Heavy,KL::Complexity::Difficult,KL::Complexity::Correct depending on the BNs p and q

Definition at line 87 of file BNdistance_tpl.h.

87 {
88 return _difficulty_;
89 }
Complexity _difficulty_
Definition BNdistance.h:171

References _difficulty_.

◆ 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(), 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(), and gum::learning::GreedyThickThinning::GreedyThickThinning().

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 gum::learning::GreedyHillClimbing::GreedyHillClimbing(), and gum::learning::GreedyThickThinning::GreedyThickThinning().

Here is the caller graph for this function:

◆ disableMinEpsilonRate()

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

Disable stopping criterion on epsilon rate.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 96 of file approximationScheme_inl.h.

96{ enabled_min_rate_eps_ = false; }

References enabled_min_rate_eps_.

Referenced by gum::learning::GreedyHillClimbing::GreedyHillClimbing(), gum::learning::GreedyThickThinning::GreedyThickThinning(), gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), gum::MCBNDistance< GUM_SCALAR >::computeKL_(), and gum::learning::EMApproximationScheme::setEpsilon().

Here is the caller graph for this function:

◆ drawSample_()

template<GUM_Numeric GUM_SCALAR>
Instantiation gum::MCBNDistance< GUM_SCALAR >::drawSample_ ( const Sequence< NodeId > & topoOrder) const
protected

draws an instantiation of p_'s variables, independently, following topoOrder (no evidence to handle in this hierarchy)

Definition at line 101 of file MCBNDistance_tpl.h.

101 {
103
104 for (const auto nod: topoOrder) {
105 I.add(p_.variable(nod));
107 Itop.erase(p_.variable(nod));
108 I.chgVal(p_.variable(nod), p_.cpt(nod).extract(Itop).draw());
109 }
110 return I;
111 }

References gum::Instantiation::add(), gum::Instantiation::chgVal(), gum::Instantiation::erase(), and gum::BNdistance< GUM_SCALAR >::p_.

Referenced by computeKL_().

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

◆ 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_.

◆ 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_.

◆ 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_.

◆ 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_(), and gum::MCBNDistance< GUM_SCALAR >::computeKL_().

Here is the caller graph for this function:

◆ epsilon()

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

Returns the value of epsilon.

Returns
Returns the value of epsilon.

Implements gum::IApproximationSchemeConfiguration.

Definition at line 72 of file approximationScheme_inl.h.

72{ return eps_; }

References eps_.

Referenced by gum::ImportanceSampling< GUM_SCALAR >::onContextualize_(), and gum::ImportanceSampling< GUM_SCALAR >::unsharpenBN_().

Here is the caller graph for this function:

◆ errorPQ()

template<GUM_Numeric GUM_SCALAR>
Size gum::BNdistance< GUM_SCALAR >::errorPQ ( )
inherited
Returns
the number of errors while processing divergence KL(P||Q)

Definition at line 122 of file BNdistance_tpl.h.

122 {
123 process_();
124 return errorPQ_;
125 }

References errorPQ_, and process_().

Here is the call graph for this function:

◆ errorQP()

template<GUM_Numeric GUM_SCALAR>
Size gum::BNdistance< GUM_SCALAR >::errorQP ( )
inherited
Returns
the number of errors while processing divergence KL(Q||P)

Definition at line 128 of file BNdistance_tpl.h.

128 {
129 process_();
130 return errorQP_;
131 }

References errorQP_, and process_().

Here is the call graph for this function:

◆ hellinger()

template<GUM_Numeric GUM_SCALAR>
double gum::BNdistance< GUM_SCALAR >::hellinger ( )
inherited
Returns
hellinger distance (
See also
http://en.wikipedia.org/wiki/Hellinger_distance)

Definition at line 104 of file BNdistance_tpl.h.

104 {
105 process_();
106 return hellinger_;
107 }

References hellinger_, and process_().

Here is the call graph for this function:

◆ 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, stateApproximationScheme(), and gum::IApproximationSchemeConfiguration::Undefined.

Here is the call 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 }

References ApproximationScheme(), gum::IApproximationSchemeConfiguration::Continue, current_state_, current_step_, and initApproximationScheme().

Referenced by gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), gum::MCBNDistance< GUM_SCALAR >::computeKL_(), initApproximationScheme(), 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_.

◆ 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_.

◆ 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_.

◆ 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_(), and gum::MCBNDistance< GUM_SCALAR >::computeKL_().

Here is the caller graph for this function:

◆ jsd()

template<GUM_Numeric GUM_SCALAR>
double gum::BNdistance< GUM_SCALAR >::jsd ( )
inherited
Returns
Jensen-Shannon divergence(
See also
https://en.wikipedia.org/wiki/Jensen%E2%80%93Shannon_divergence)

Definition at line 116 of file BNdistance_tpl.h.

116 {
117 process_();
118 return jsd_;
119 }

References jsd_, and process_().

Here is the call graph for this function:

◆ klPQ()

template<GUM_Numeric GUM_SCALAR>
double gum::BNdistance< GUM_SCALAR >::klPQ ( )
inherited
Returns
divergence KL(P||Q)

Definition at line 92 of file BNdistance_tpl.h.

92 {
93 process_();
94 return klPQ_;
95 }

References klPQ_, and process_().

Here is the call graph for this function:

◆ klQP()

template<GUM_Numeric GUM_SCALAR>
double gum::BNdistance< GUM_SCALAR >::klQP ( )
inherited
Returns
divergence KL(Q||P)

Definition at line 98 of file BNdistance_tpl.h.

98 {
99 process_();
100 return klQP_;
101 }

References klQP_, and process_().

Here is the call 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_.

◆ 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_.

◆ 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::credal::InferenceEngine< GUM_SCALAR >::getApproximationSchemeMsg(), and gum::credal::MultipleInferenceEngine< GUM_SCALAR, LazyPropagation< GUM_SCALAR > >::isEnabledMaxIter().

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_.

◆ 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 }

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

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

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

◆ p()

template<GUM_Numeric GUM_SCALAR>
const IBayesNet< GUM_SCALAR > & gum::BNdistance< GUM_SCALAR >::p ( ) const
inherited
Returns
p

Definition at line 134 of file BNdistance_tpl.h.

134 {
135 return p_;
136 }

References p_.

Referenced by gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance().

Here is the caller 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_.

◆ process_()

template<GUM_Numeric GUM_SCALAR>
void gum::BNdistance< GUM_SCALAR >::process_ ( )
protectedinherited

Definition at line 177 of file BNdistance_tpl.h.

177 {
178 if (!_done_) {
179 computeKL_();
180 _done_ = true;
181 }
182 }
virtual void computeKL_()

References _done_, and computeKL_().

Referenced by bhattacharya(), errorPQ(), errorQP(), hellinger(), jsd(), klPQ(), and klQP().

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

◆ q()

template<GUM_Numeric GUM_SCALAR>
const IBayesNet< GUM_SCALAR > & gum::BNdistance< GUM_SCALAR >::q ( ) const
inherited
Returns
q

Definition at line 139 of file BNdistance_tpl.h.

139 {
140 return q_;
141 }

References q_.

◆ 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.

References burn_in_, and current_step_.

◆ setEpsilon()

INLINE void gum::ApproximationScheme::setEpsilon ( double eps)
overridevirtualinherited

Given that we approximate f(t), stopping criterion on |f(t+1)-f(t)|.

If the criterion was disabled it will be enabled.

Parameters
epsThe new epsilon value.
Exceptions
OutOfBoundsRaised if eps < 0.

Implements gum::IApproximationSchemeConfiguration.

Reimplemented in gum::learning::EMApproximationScheme.

Definition at line 64 of file approximationScheme_inl.h.

64 {
65 if (eps < 0.) { GUM_ERROR(OutOfBounds, "eps should be >=0") }
66
67 eps_ = eps;
68 enabled_eps_ = true;
69 }

References enabled_eps_, eps_, and GUM_ERROR.

Referenced by gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::GibbsSampling< GUM_SCALAR >::GibbsSampling(), gum::learning::GreedyHillClimbing::GreedyHillClimbing(), gum::learning::GreedyThickThinning::GreedyThickThinning(), gum::MCBNDistance< GUM_SCALAR >::MCBNDistance(), gum::MCBNDistance< GUM_SCALAR >::MCBNDistance(), gum::SamplingInference< GUM_SCALAR >::SamplingInference(), and gum::learning::EMApproximationScheme::setEpsilon().

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::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 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::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 caller graph for this function:

◆ setMinEpsilonRate()

INLINE void gum::ApproximationScheme::setMinEpsilonRate ( double rate)
overridevirtualinherited

Given that we approximate f(t), stopping criterion on d/dt(|f(t+1)-f(t)|).

If the criterion was disabled it will be enabled

Parameters
rateThe minimal epsilon rate.
Exceptions
OutOfBoundsif rate<0

Implements gum::IApproximationSchemeConfiguration.

Reimplemented in gum::learning::EMApproximationScheme.

Definition at line 85 of file approximationScheme_inl.h.

85 {
86 if (rate < 0) { GUM_ERROR(OutOfBounds, "rate should be >=0") }
87
88 min_rate_eps_ = rate;
90 }

References enabled_min_rate_eps_, GUM_ERROR, and min_rate_eps_.

Referenced by gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::GibbsSampling< GUM_SCALAR >::GibbsSampling(), gum::MCBNDistance< GUM_SCALAR >::MCBNDistance(), gum::MCBNDistance< GUM_SCALAR >::MCBNDistance(), gum::SamplingInference< GUM_SCALAR >::SamplingInference(), and gum::learning::EMApproximationScheme::setMinEpsilonRate().

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.

Referenced by 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 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::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 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(), history(), and nbrIterations().

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.

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
239 if (onStop.hasListener()) { GUM_EMIT1(onStop, messageApproximationScheme()); }
240 }
Signaler< std::string_view > onStop
Criteria messageApproximationScheme.
#define GUM_EMIT1(signal, arg1)
Definition signaler.h:289

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

Referenced by continueApproximationScheme(), and gum::credal::MultipleInferenceEngine< GUM_SCALAR, LazyPropagation< GUM_SCALAR > >::disableMaxIter().

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_; }

References verbosity_.

Referenced by ApproximationScheme(), gum::learning::EMApproximationScheme::EMApproximationScheme(), and continueApproximationScheme().

Here is the caller graph for this function:

Member Data Documentation

◆ _difficulty_

template<GUM_Numeric GUM_SCALAR>
Complexity gum::BNdistance< GUM_SCALAR >::_difficulty_
privateinherited

Definition at line 171 of file BNdistance.h.

Referenced by BNdistance(), BNdistance(), and difficulty().

◆ _done_

template<GUM_Numeric GUM_SCALAR>
bool gum::BNdistance< GUM_SCALAR >::_done_
privateinherited

Definition at line 172 of file BNdistance.h.

Referenced by BNdistance(), BNdistance(), and process_().

◆ bhattacharya_

template<GUM_Numeric GUM_SCALAR>
GUM_SCALAR gum::BNdistance< GUM_SCALAR >::bhattacharya_
protectedinherited

◆ burn_in_

Size gum::ApproximationScheme::burn_in_
protectedinherited

◆ current_epsilon_

double gum::ApproximationScheme::current_epsilon_
protectedinherited

Current epsilon.

Definition at line 378 of file approximationScheme.h.

Referenced by continueApproximationScheme().

◆ current_rate_

double gum::ApproximationScheme::current_rate_
protectedinherited

Current rate.

Definition at line 384 of file approximationScheme.h.

Referenced by continueApproximationScheme().

◆ current_state_

ApproximationSchemeSTATE gum::ApproximationScheme::current_state_
protectedinherited

The current state.

Definition at line 393 of file approximationScheme.h.

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

◆ current_step_

◆ enabled_eps_

bool gum::ApproximationScheme::enabled_eps_
protectedinherited

If true, the threshold convergence is enabled.

Definition at line 402 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 420 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 414 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 408 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 399 of file approximationScheme.h.

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

◆ errorPQ_

template<GUM_Numeric GUM_SCALAR>
Size gum::BNdistance< GUM_SCALAR >::errorPQ_
protectedinherited

◆ errorQP_

template<GUM_Numeric GUM_SCALAR>
Size gum::BNdistance< GUM_SCALAR >::errorQP_
protectedinherited

◆ hellinger_

template<GUM_Numeric GUM_SCALAR>
GUM_SCALAR gum::BNdistance< GUM_SCALAR >::hellinger_
protectedinherited

◆ history_

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

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

Definition at line 396 of file approximationScheme.h.

Referenced by continueApproximationScheme().

◆ jsd_

template<GUM_Numeric GUM_SCALAR>
GUM_SCALAR gum::BNdistance< GUM_SCALAR >::jsd_
protectedinherited

◆ klPQ_

template<GUM_Numeric GUM_SCALAR>
GUM_SCALAR gum::BNdistance< GUM_SCALAR >::klPQ_
protectedinherited

◆ klQP_

template<GUM_Numeric GUM_SCALAR>
GUM_SCALAR gum::BNdistance< GUM_SCALAR >::klQP_
protectedinherited

◆ last_epsilon_

double gum::ApproximationScheme::last_epsilon_
protectedinherited

Last epsilon value.

Definition at line 381 of file approximationScheme.h.

Referenced by continueApproximationScheme().

◆ max_iter_

Size gum::ApproximationScheme::max_iter_
protectedinherited

The maximum iterations.

Definition at line 417 of file approximationScheme.h.

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

◆ max_time_

double gum::ApproximationScheme::max_time_
protectedinherited

The timeout.

Definition at line 411 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 405 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().

◆ p_

◆ period_size_

Size gum::ApproximationScheme::period_size_
protectedinherited

Checking criteria frequency.

Definition at line 426 of file approximationScheme.h.

Referenced by ApproximationScheme(), and periodSize().

◆ q_

template<GUM_Numeric GUM_SCALAR>
const IBayesNet< GUM_SCALAR >& gum::BNdistance< GUM_SCALAR >::q_
protectedinherited

◆ timer_

◆ verbosity_

bool gum::ApproximationScheme::verbosity_
protectedinherited

If true, verbosity is enabled.

Definition at line 429 of file approximationScheme.h.

Referenced by ApproximationScheme(), setVerbosity(), and verbosity().


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