![]() |
aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
|
GibbsKL computes the KL divergence betweens 2 BNs using an approximation pattern: GIBBS sampling. More...
#include <GibbsBNdistance.h>
Public Types | |
| enum class | ApproximationSchemeSTATE : char { Undefined , Continue , Epsilon , Rate , Limit , TimeLimit , Stopped } |
| The different state of an approximation scheme. More... | |
Public Member Functions | |
| GibbsBNdistance (const IBayesNet< GUM_SCALAR > &P, const IBayesNet< GUM_SCALAR > &Q) | |
| constructor must give 2 BNs | |
| GibbsBNdistance (const BNdistance< GUM_SCALAR > &kl) | |
| copy constructor | |
| ~GibbsBNdistance () override | |
| destructor | |
| void | setBurnIn (Size b) |
| Number of burn in for one iteration. | |
| Size | burnIn () const |
| Returns the number of burn in. | |
| Complexity | difficulty () const |
| return KL::Complexity::Heavy,KL::Complexity::Difficult,KL::Complexity::Correct depending on the BNs p and q | |
| Size | nbrDrawnVar () const |
| Getters and setters. | |
| void | setNbrDrawnVar (Size nbr) |
| bool | isDrawnAtRandom () const |
| void | setDrawnAtRandom (bool atRandom) |
| Instantiation | monteCarloSample () |
| draws a Monte Carlo sample | |
| Instantiation | nextSample (Instantiation prev) |
| draws next sample of Gibbs sampling | |
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, double > | onProgress |
| Progression, error and time. | |
| Signaler< std::string_view > | onStop |
| Criteria messageApproximationScheme. | |
Protected Member Functions | |
| void | computeKL_ () final |
| void | process_ () |
| void | updateSamplingNodes_ () |
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< 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. | |
| Size | counting_ |
| const IBayesNet< GUM_SCALAR > & | samplingBn_ |
| const NodeProperty< Idx > * | hardEv_ |
| Sequence< NodeId > | samplingNodes_ |
| Size | nbr_ |
| bool | atRandom_ |
Private Member Functions | |
| bool | _checkCompatibility_ () const |
| void | stopScheme_ (ApproximationSchemeSTATE new_state) |
| Stop the scheme given a new state. | |
| void | _drawVarMonteCarlo_ (NodeId nod, Instantiation *I) |
| void | _GibbsSample_ (NodeId id, Instantiation *I) |
| change in Instantiation I a new drawn value for id | |
Private Attributes | |
| Complexity | _difficulty_ |
| bool | _done_ |
GibbsKL computes the KL divergence betweens 2 BNs using an approximation pattern: GIBBS sampling.
KL.process() computes KL(P||Q) using klPQ() and KL(Q||P) using klQP(). The computations are made once. The second is for free :) GibbsKL 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.
snippets :
Definition at line 96 of file GibbsBNdistance.h.
|
stronginherited |
The different state of an approximation scheme.
| Enumerator | |
|---|---|
| Undefined | |
| Continue | |
| Epsilon | |
| Rate | |
| Limit | |
| TimeLimit | |
| Stopped | |
Definition at line 87 of file IApproximationSchemeConfiguration.h.
| gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance | ( | const IBayesNet< GUM_SCALAR > & | P, |
| const IBayesNet< GUM_SCALAR > & | Q ) |
constructor must give 2 BNs
| gum::OperationNotAllowed | if the 2 BNs have not the same domainSize or compatible node sets. |
Definition at line 74 of file GibbsBNdistance_tpl.h.
References gum::ApproximationScheme::ApproximationScheme(), gum::BNdistance< GUM_SCALAR >::BNdistance(), GibbsBNdistance(), gum::GibbsOperator< GUM_SCALAR >::GibbsOperator(), GIBBSKL_DEFAULT_BURNIN, GIBBSKL_DEFAULT_EPSILON, GIBBSKL_DEFAULT_MAXITER, GIBBSKL_DEFAULT_MIN_EPSILON_RATE, GIBBSKL_DEFAULT_PERIOD_SIZE, GIBBSKL_DEFAULT_TIMEOUT, GIBBSKL_DEFAULT_VERBOSITY, GIBBSKL_DRAWN_AT_RANDOM, GIBBSKL_POURCENT_DRAWN_SAMPLE, setBurnIn(), gum::ApproximationScheme::setEpsilon(), gum::ApproximationScheme::setMaxIter(), gum::ApproximationScheme::setMaxTime(), gum::ApproximationScheme::setMinEpsilonRate(), gum::ApproximationScheme::setPeriodSize(), and gum::ApproximationScheme::setVerbosity().
Referenced by GibbsBNdistance(), GibbsBNdistance(), and ~GibbsBNdistance().
|
explicit |
copy constructor
Definition at line 93 of file GibbsBNdistance_tpl.h.
References gum::ApproximationScheme::ApproximationScheme(), gum::BNdistance< GUM_SCALAR >::BNdistance(), GibbsBNdistance(), gum::GibbsOperator< GUM_SCALAR >::GibbsOperator(), GIBBSKL_DEFAULT_BURNIN, GIBBSKL_DEFAULT_EPSILON, GIBBSKL_DEFAULT_MAXITER, GIBBSKL_DEFAULT_MIN_EPSILON_RATE, GIBBSKL_DEFAULT_PERIOD_SIZE, GIBBSKL_DEFAULT_TIMEOUT, GIBBSKL_DEFAULT_VERBOSITY, GIBBSKL_POURCENT_DRAWN_SAMPLE, gum::BNdistance< GUM_SCALAR >::p(), setBurnIn(), gum::ApproximationScheme::setEpsilon(), gum::ApproximationScheme::setMaxIter(), gum::ApproximationScheme::setMaxTime(), gum::ApproximationScheme::setMinEpsilonRate(), gum::ApproximationScheme::setPeriodSize(), and gum::ApproximationScheme::setVerbosity().
|
override |
destructor
Definition at line 113 of file GibbsBNdistance_tpl.h.
References GibbsBNdistance().
|
privateinherited |
Definition at line 145 of file BNdistance_tpl.h.
References GUM_ERROR, gum::Variable::name(), p_, q_, and gum::DiscreteVariable::toString().
Referenced by BNdistance().
|
privateinherited |
Definition at line 103 of file gibbsOperator_tpl.h.
References gum::Instantiation::chgVal(), gum::Instantiation::erase(), and samplingBn_.
Referenced by monteCarloSample().
|
privateinherited |
change in Instantiation I a new drawn value for id
Definition at line 123 of file gibbsOperator_tpl.h.
References gum::Instantiation::chgVal(), gum::Tensor< GUM_SCALAR >::draw(), gum::Instantiation::erase(), gum::MultiDimDecorator< GUM_ELEMENT >::nbrDim(), gum::Tensor< GUM_SCALAR >::normalize(), samplingBn_, and gum::Tensor< GUM_SCALAR >::sum().
Referenced by nextSample().
|
inherited |
Definition at line 110 of file BNdistance_tpl.h.
References bhattacharya_, and process_().
| Size gum::GibbsBNdistance< GUM_SCALAR >::burnIn | ( | ) | const |
Returns the number of burn in.
Definition at line 206 of file GibbsBNdistance_tpl.h.
References gum::ApproximationScheme::burn_in_.
Referenced by computeKL_().
|
finalprotectedvirtual |
Reimplemented from gum::BNdistance< GUM_SCALAR >.
Definition at line 118 of file GibbsBNdistance_tpl.h.
References gum::BNdistance< GUM_SCALAR >::bhattacharya_, burnIn(), gum::ApproximationScheme::continueApproximationScheme(), gum::ApproximationScheme::disableMinEpsilonRate(), 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::GibbsOperator< GUM_SCALAR >::monteCarloSample(), gum::Variable::name(), gum::Instantiation::nbrDim(), gum::ApproximationScheme::nbrIterations(), gum::GibbsOperator< GUM_SCALAR >::nextSample(), gum::BNdistance< GUM_SCALAR >::p_, gum::BNdistance< GUM_SCALAR >::q_, gum::ApproximationScheme::updateApproximationScheme(), gum::GibbsOperator< GUM_SCALAR >::updateSamplingNodes_(), and gum::Instantiation::variable().
Update the scheme w.r.t the new error.
Test the stopping criterion that are enabled.
| error | The new error value. |
| OperationNotAllowed | Raised if state != ApproximationSchemeSTATE::Continue. |
Definition at line 69 of file approximationScheme.cpp.
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_().
|
overridevirtualinherited |
Returns the current running time in second.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 137 of file approximationScheme_inl.h.
References timer_.
|
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.
References _difficulty_.
|
overridevirtualinherited |
Disable stopping criterion on epsilon.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 75 of file approximationScheme_inl.h.
References enabled_eps_.
Referenced by gum::learning::EMApproximationScheme::EMApproximationScheme(), and gum::learning::EMApproximationScheme::setMinEpsilonRate().
|
overridevirtualinherited |
Disable stopping criterion on max iterations.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 116 of file approximationScheme_inl.h.
References enabled_max_iter_.
Referenced by gum::learning::GreedyHillClimbing::GreedyHillClimbing(), and gum::learning::GreedyThickThinning::GreedyThickThinning().
|
overridevirtualinherited |
Disable stopping criterion on timeout.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 140 of file approximationScheme_inl.h.
References enabled_max_time_.
Referenced by gum::learning::GreedyHillClimbing::GreedyHillClimbing(), and gum::learning::GreedyThickThinning::GreedyThickThinning().
|
overridevirtualinherited |
Disable stopping criterion on epsilon rate.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 96 of file approximationScheme_inl.h.
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().
|
overridevirtualinherited |
Enable stopping criterion on epsilon.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 78 of file approximationScheme_inl.h.
References enabled_eps_.
|
overridevirtualinherited |
Enable stopping criterion on max iterations.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 119 of file approximationScheme_inl.h.
References enabled_max_iter_.
|
overridevirtualinherited |
Enable stopping criterion on timeout.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 143 of file approximationScheme_inl.h.
References enabled_max_time_.
|
overridevirtualinherited |
Enable stopping criterion on epsilon rate.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 99 of file approximationScheme_inl.h.
References enabled_min_rate_eps_.
Referenced by gum::learning::EMApproximationScheme::EMApproximationScheme(), gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), and gum::MCBNDistance< GUM_SCALAR >::computeKL_().
|
overridevirtualinherited |
Returns the value of epsilon.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 72 of file approximationScheme_inl.h.
References eps_.
Referenced by gum::ImportanceSampling< GUM_SCALAR >::onContextualize_(), and gum::ImportanceSampling< GUM_SCALAR >::unsharpenBN_().
|
inherited |
Definition at line 122 of file BNdistance_tpl.h.
References errorPQ_, and process_().
|
inherited |
Definition at line 128 of file BNdistance_tpl.h.
References errorQP_, and process_().
|
inherited |
Definition at line 104 of file BNdistance_tpl.h.
References hellinger_, and process_().
|
overridevirtualinherited |
Returns the scheme history.
| OperationNotAllowed | Raised 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.
References GUM_ERROR, stateApproximationScheme(), and gum::IApproximationSchemeConfiguration::Undefined.
|
inherited |
Initialise the scheme.
Definition at line 190 of file approximationScheme_inl.h.
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_().
|
inherited |
|
overridevirtualinherited |
Returns true if stopping criterion on epsilon is enabled, false otherwise.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 82 of file approximationScheme_inl.h.
References enabled_eps_.
|
overridevirtualinherited |
Returns true if stopping criterion on max iterations is enabled, false otherwise.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 123 of file approximationScheme_inl.h.
References enabled_max_iter_.
|
overridevirtualinherited |
Returns true if stopping criterion on timeout is enabled, false otherwise.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 147 of file approximationScheme_inl.h.
References enabled_max_time_.
|
overridevirtualinherited |
Returns true if stopping criterion on epsilon rate is enabled, false otherwise.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 103 of file approximationScheme_inl.h.
References enabled_min_rate_eps_.
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), and gum::MCBNDistance< GUM_SCALAR >::computeKL_().
|
inherited |
Definition at line 116 of file BNdistance_tpl.h.
References jsd_, and process_().
|
inherited |
Definition at line 92 of file BNdistance_tpl.h.
References klPQ_, and process_().
|
inherited |
Definition at line 98 of file BNdistance_tpl.h.
References klQP_, and process_().
|
overridevirtualinherited |
Returns the criterion on number of iterations.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 113 of file approximationScheme_inl.h.
References max_iter_.
|
overridevirtualinherited |
Returns the timeout (in seconds).
Implements gum::IApproximationSchemeConfiguration.
Definition at line 134 of file approximationScheme_inl.h.
References max_time_.
|
inherited |
Returns the approximation scheme message.
Definition at line 64 of file IApproximationSchemeConfiguration.cpp.
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().
|
overridevirtualinherited |
Returns the value of the minimal epsilon rate.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 93 of file approximationScheme_inl.h.
References min_rate_eps_.
|
inherited |
draws a Monte Carlo sample
returns a MC sample This is not a really sample since we take into account evidence without care about parent of evidence, etc. This is just a not-so-bad first sample for GibbsSampler
Definition at line 88 of file gibbsOperator_tpl.h.
References _drawVarMonteCarlo_(), gum::Instantiation::add(), gum::Instantiation::chgVal(), hardEv_, and samplingBn_.
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), and gum::GibbsSampling< GUM_SCALAR >::monteCarloSample_().
|
inherited |
|
overridevirtualinherited |
Returns the number of iterations.
| OperationNotAllowed | Raised if the scheme did not perform. |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 170 of file approximationScheme_inl.h.
References current_step_, GUM_ERROR, stateApproximationScheme(), and gum::IApproximationSchemeConfiguration::Undefined.
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), and gum::MCBNDistance< GUM_SCALAR >::computeKL_().
|
inherited |
draws next sample of Gibbs sampling
Definition at line 110 of file gibbsOperator_tpl.h.
References _GibbsSample_(), atRandom_, counting_, nbr_, gum::randomValue(), and samplingNodes_.
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), and gum::GibbsSampling< GUM_SCALAR >::draw_().
|
inherited |
Definition at line 134 of file BNdistance_tpl.h.
References p_.
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance().
|
overridevirtualinherited |
Returns the period size.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 156 of file approximationScheme_inl.h.
References period_size_.
|
protectedinherited |
Definition at line 177 of file BNdistance_tpl.h.
References _done_, and computeKL_().
Referenced by bhattacharya(), errorPQ(), errorQP(), hellinger(), jsd(), klPQ(), and klQP().
|
inherited |
|
inherited |
Returns the remaining burn in.
Definition at line 213 of file approximationScheme_inl.h.
References burn_in_, and current_step_.
| void gum::GibbsBNdistance< GUM_SCALAR >::setBurnIn | ( | Size | b | ) |
Number of burn in for one iteration.
| b | The number of burn in. |
| OutOfBounds | Raised if b < 1. |
Definition at line 201 of file GibbsBNdistance_tpl.h.
References gum::ApproximationScheme::burn_in_.
Referenced by GibbsBNdistance(), and GibbsBNdistance().
|
inherited |
Definition at line 152 of file gibbsOperator_tpl.h.
References atRandom_.
|
overridevirtualinherited |
Given that we approximate f(t), stopping criterion on |f(t+1)-f(t)|.
If the criterion was disabled it will be enabled.
| eps | The new epsilon value. |
| OutOfBounds | Raised if eps < 0. |
Implements gum::IApproximationSchemeConfiguration.
Reimplemented in gum::learning::EMApproximationScheme.
Definition at line 64 of file approximationScheme_inl.h.
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().
|
overridevirtualinherited |
Stopping criterion on number of iterations.
If the criterion was disabled it will be enabled.
| max | The maximum number of iterations. |
| OutOfBounds | Raised if max <= 1. |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 106 of file approximationScheme_inl.h.
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().
|
overridevirtualinherited |
Stopping criterion on timeout.
If the criterion was disabled it will be enabled.
| timeout | The timeout value in seconds. |
| OutOfBounds | Raised if timeout <= 0.0. |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 127 of file approximationScheme_inl.h.
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().
|
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
| rate | The minimal epsilon rate. |
| OutOfBounds | if rate<0 |
Implements gum::IApproximationSchemeConfiguration.
Reimplemented in gum::learning::EMApproximationScheme.
Definition at line 85 of file approximationScheme_inl.h.
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().
|
inherited |
|
overridevirtualinherited |
How many samples between two stopping is enable.
| p | The new period value. |
| OutOfBounds | Raised if p < 1. |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 150 of file approximationScheme_inl.h.
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().
|
overridevirtualinherited |
Set the verbosity on (true) or off (false).
| v | If true, then verbosity is turned on. |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 159 of file approximationScheme_inl.h.
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().
|
inherited |
Returns true if we are at the beginning of a period (compute error is mandatory).
Definition at line 200 of file approximationScheme_inl.h.
Referenced by continueApproximationScheme().
|
overridevirtualinherited |
Returns the approximation scheme state.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 165 of file approximationScheme_inl.h.
Referenced by continueApproximationScheme(), history(), and nbrIterations().
|
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_().
|
privateinherited |
Stop the scheme given a new state.
| new_state | The scheme new state. |
Definition at line 231 of file approximationScheme_inl.h.
References gum::IApproximationSchemeConfiguration::Continue, and gum::IApproximationSchemeConfiguration::Undefined.
Referenced by continueApproximationScheme(), and gum::credal::MultipleInferenceEngine< GUM_SCALAR, LazyPropagation< GUM_SCALAR > >::disableMaxIter().
|
inherited |
Update the scheme w.r.t the new error and increment steps.
| incr | The new increment steps. |
Definition at line 209 of file approximationScheme_inl.h.
References current_step_.
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_().
|
protectedinherited |
Definition at line 73 of file gibbsOperator_tpl.h.
References GUM_ERROR, hardEv_, nbr_, samplingBn_, and samplingNodes_.
Referenced by gum::GibbsSampling< GUM_SCALAR >::burnIn_(), and gum::GibbsBNdistance< GUM_SCALAR >::computeKL_().
|
overridevirtualinherited |
Returns true if verbosity is enabled.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 161 of file approximationScheme_inl.h.
References verbosity_.
Referenced by ApproximationScheme(), gum::learning::EMApproximationScheme::EMApproximationScheme(), and continueApproximationScheme().
|
privateinherited |
Definition at line 171 of file BNdistance.h.
Referenced by BNdistance(), BNdistance(), and difficulty().
|
privateinherited |
Definition at line 172 of file BNdistance.h.
Referenced by BNdistance(), BNdistance(), and process_().
|
protectedinherited |
Definition at line 104 of file gibbsOperator.h.
Referenced by GibbsOperator(), isDrawnAtRandom(), nextSample(), and setDrawnAtRandom().
|
protectedinherited |
Definition at line 166 of file BNdistance.h.
Referenced by bhattacharya(), gum::ExactBNdistance< GUM_SCALAR >::computeKL_(), gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), and gum::MCBNDistance< GUM_SCALAR >::computeKL_().
|
protectedinherited |
Number of iterations before checking stopping criteria.
Definition at line 423 of file approximationScheme.h.
Referenced by ApproximationScheme(), gum::GibbsBNdistance< GUM_SCALAR >::burnIn(), gum::GibbsSampling< GUM_SCALAR >::burnIn(), remainingBurnIn(), gum::GibbsBNdistance< GUM_SCALAR >::setBurnIn(), and gum::GibbsSampling< GUM_SCALAR >::setBurnIn().
|
protectedinherited |
Definition at line 98 of file gibbsOperator.h.
Referenced by GibbsOperator(), and nextSample().
|
protectedinherited |
Current epsilon.
Definition at line 378 of file approximationScheme.h.
Referenced by continueApproximationScheme().
|
protectedinherited |
Current rate.
Definition at line 384 of file approximationScheme.h.
Referenced by continueApproximationScheme().
|
protectedinherited |
The current state.
Definition at line 393 of file approximationScheme.h.
Referenced by ApproximationScheme(), continueApproximationScheme(), and initApproximationScheme().
|
protectedinherited |
The current step.
Definition at line 387 of file approximationScheme.h.
Referenced by continueApproximationScheme(), initApproximationScheme(), gum::learning::Miic::initiation_(), gum::learning::SimpleMiic::initiation_(), gum::learning::Miic::iteration_(), gum::learning::SimpleMiic::iteration_(), gum::learning::Miic::learnMixedStructure(), gum::learning::SimpleMiic::learnMixedStructure(), gum::learning::Miic::learnSkeleton(), nbrIterations(), gum::learning::SimpleMiic::orientationLatents_(), gum::learning::Miic::orientationMiic_(), gum::learning::SimpleMiic::orientationMiic_(), remainingBurnIn(), and updateApproximationScheme().
|
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().
|
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().
|
protectedinherited |
If true, the timeout is enabled.
Definition at line 414 of file approximationScheme.h.
Referenced by ApproximationScheme(), continueApproximationScheme(), disableMaxTime(), enableMaxTime(), isEnabledMaxTime(), and setMaxTime().
|
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().
|
protectedinherited |
Threshold for convergence.
Definition at line 399 of file approximationScheme.h.
Referenced by ApproximationScheme(), continueApproximationScheme(), epsilon(), and setEpsilon().
|
protectedinherited |
Definition at line 162 of file BNdistance.h.
Referenced by BNdistance(), BNdistance(), gum::ExactBNdistance< GUM_SCALAR >::computeKL_(), gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), gum::MCBNDistance< GUM_SCALAR >::computeKL_(), and errorPQ().
|
protectedinherited |
Definition at line 163 of file BNdistance.h.
Referenced by BNdistance(), BNdistance(), gum::ExactBNdistance< GUM_SCALAR >::computeKL_(), gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), gum::MCBNDistance< GUM_SCALAR >::computeKL_(), and errorQP().
|
protectedinherited |
Definition at line 100 of file gibbsOperator.h.
Referenced by GibbsOperator(), monteCarloSample(), and updateSamplingNodes_().
|
protectedinherited |
Definition at line 165 of file BNdistance.h.
Referenced by gum::ExactBNdistance< GUM_SCALAR >::computeKL_(), gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), gum::MCBNDistance< GUM_SCALAR >::computeKL_(), and hellinger().
|
protectedinherited |
The scheme history, used only if verbosity == true.
Definition at line 396 of file approximationScheme.h.
Referenced by continueApproximationScheme().
|
protectedinherited |
Definition at line 167 of file BNdistance.h.
Referenced by gum::ExactBNdistance< GUM_SCALAR >::computeKL_(), gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), gum::MCBNDistance< GUM_SCALAR >::computeKL_(), and jsd().
|
protectedinherited |
Definition at line 159 of file BNdistance.h.
Referenced by BNdistance(), BNdistance(), gum::ExactBNdistance< GUM_SCALAR >::computeKL_(), gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), gum::MCBNDistance< GUM_SCALAR >::computeKL_(), and klPQ().
|
protectedinherited |
Definition at line 160 of file BNdistance.h.
Referenced by BNdistance(), BNdistance(), gum::ExactBNdistance< GUM_SCALAR >::computeKL_(), gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), gum::MCBNDistance< GUM_SCALAR >::computeKL_(), and klQP().
|
protectedinherited |
Last epsilon value.
Definition at line 381 of file approximationScheme.h.
Referenced by continueApproximationScheme().
|
protectedinherited |
The maximum iterations.
Definition at line 417 of file approximationScheme.h.
Referenced by ApproximationScheme(), continueApproximationScheme(), maxIter(), and setMaxIter().
|
protectedinherited |
The timeout.
Definition at line 411 of file approximationScheme.h.
Referenced by ApproximationScheme(), continueApproximationScheme(), maxTime(), and setMaxTime().
|
protectedinherited |
Threshold for the epsilon rate.
Definition at line 405 of file approximationScheme.h.
Referenced by ApproximationScheme(), continueApproximationScheme(), minEpsilonRate(), and setMinEpsilonRate().
|
protectedinherited |
Definition at line 103 of file gibbsOperator.h.
Referenced by GibbsOperator(), nbrDrawnVar(), nextSample(), setNbrDrawnVar(), and updateSamplingNodes_().
Progression, error and time.
Definition at line 81 of file IApproximationSchemeConfiguration.h.
Referenced by gum::ApproximationScheme::continueApproximationScheme(), gum::learning::IBNLearner::distributeProgress(), gum::learning::Miic::initiation_(), gum::learning::SimpleMiic::initiation_(), gum::learning::Miic::iteration_(), gum::learning::SimpleMiic::iteration_(), gum::learning::SimpleMiic::orientationLatents_(), gum::learning::Miic::orientationMiic_(), and gum::learning::SimpleMiic::orientationMiic_().
|
inherited |
Criteria messageApproximationScheme.
Definition at line 84 of file IApproximationSchemeConfiguration.h.
Referenced by gum::learning::IBNLearner::distributeStop().
|
protectedinherited |
Definition at line 156 of file BNdistance.h.
Referenced by BNdistance(), BNdistance(), _checkCompatibility_(), gum::ExactBNdistance< GUM_SCALAR >::computeKL_(), gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), gum::MCBNDistance< GUM_SCALAR >::computeKL_(), gum::MCBNDistance< GUM_SCALAR >::drawSample_(), and p().
|
protectedinherited |
Checking criteria frequency.
Definition at line 426 of file approximationScheme.h.
Referenced by ApproximationScheme(), and periodSize().
|
protectedinherited |
Definition at line 157 of file BNdistance.h.
Referenced by BNdistance(), BNdistance(), _checkCompatibility_(), gum::ExactBNdistance< GUM_SCALAR >::computeKL_(), gum::GibbsBNdistance< GUM_SCALAR >::computeKL_(), gum::MCBNDistance< GUM_SCALAR >::computeKL_(), and q().
|
protectedinherited |
Definition at line 99 of file gibbsOperator.h.
Referenced by GibbsOperator(), _drawVarMonteCarlo_(), _GibbsSample_(), monteCarloSample(), and updateSamplingNodes_().
|
protectedinherited |
Definition at line 101 of file gibbsOperator.h.
Referenced by nextSample(), and updateSamplingNodes_().
|
protectedinherited |
The timer.
Definition at line 390 of file approximationScheme.h.
Referenced by continueApproximationScheme(), currentTime(), gum::learning::Miic::initiation_(), gum::learning::SimpleMiic::initiation_(), gum::learning::Miic::iteration_(), gum::learning::SimpleMiic::iteration_(), gum::learning::Miic::learnMixedStructure(), gum::learning::SimpleMiic::learnMixedStructure(), gum::learning::Miic::learnSkeleton(), gum::learning::SimpleMiic::orientationLatents_(), gum::learning::Miic::orientationMiic_(), and gum::learning::SimpleMiic::orientationMiic_().
|
protectedinherited |
If true, verbosity is enabled.
Definition at line 429 of file approximationScheme.h.
Referenced by ApproximationScheme(), setVerbosity(), and verbosity().