![]() |
aGrUM
0.16.0
|
GibbsKL computes the KL divergence betweens 2 BNs using an approximation pattern: GIBBS sampling. More...
#include <GibbsBNdistance.h>
Public Attributes | |
Signaler3< Size, double, double > | onProgress |
Progression, error and time. More... | |
Signaler1< std::string > | onStop |
Criteria messageApproximationScheme. More... | |
Public Member Functions | |
GibbsBNdistance (const IBayesNet< GUM_SCALAR > &P, const IBayesNet< GUM_SCALAR > &Q) | |
constructor must give 2 BNs More... | |
GibbsBNdistance (const BNdistance< GUM_SCALAR > &kl) | |
copy constructor More... | |
~GibbsBNdistance () | |
destructor More... | |
void | setBurnIn (Size b) |
Number of burn in for one iteration. More... | |
Size | burnIn () const |
Returns the number of burn in. More... | |
Complexity | difficulty () const |
return KL::Complexity::Heavy,KL::Complexity::Difficult,KL::Complexity::Correct depending on the BNs __p and __q More... | |
Size | nbrDrawnVar () const |
Getters and setters. More... | |
void | setNbrDrawnVar (Size nbr) |
bool | isDrawnAtRandom () const |
void | setDrawnAtRandom (bool atRandom) |
Instantiation | monteCarloSample () |
draws a Monte Carlo sample More... | |
Instantiation | nextSample (Instantiation prev) |
draws next sample of Gibbs sampling More... | |
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) |
Given that we approximate f(t), stopping criterion on |f(t+1)-f(t)|. More... | |
double | epsilon () const |
Returns the value of epsilon. More... | |
void | disableEpsilon () |
Disable stopping criterion on epsilon. More... | |
void | enableEpsilon () |
Enable stopping criterion on epsilon. More... | |
bool | isEnabledEpsilon () const |
Returns true if stopping criterion on epsilon is enabled, false otherwise. More... | |
void | setMinEpsilonRate (double rate) |
Given that we approximate f(t), stopping criterion on d/dt(|f(t+1)-f(t)|). More... | |
double | minEpsilonRate () const |
Returns the value of the minimal epsilon rate. More... | |
void | disableMinEpsilonRate () |
Disable stopping criterion on epsilon rate. More... | |
void | enableMinEpsilonRate () |
Enable stopping criterion on epsilon rate. More... | |
bool | isEnabledMinEpsilonRate () const |
Returns true if stopping criterion on epsilon rate is enabled, false otherwise. More... | |
void | setMaxIter (Size max) |
Stopping criterion on number of iterations. More... | |
Size | maxIter () const |
Returns the criterion on number of iterations. More... | |
void | disableMaxIter () |
Disable stopping criterion on max iterations. More... | |
void | enableMaxIter () |
Enable stopping criterion on max iterations. More... | |
bool | isEnabledMaxIter () const |
Returns true if stopping criterion on max iterations is enabled, false otherwise. More... | |
void | setMaxTime (double timeout) |
Stopping criterion on timeout. More... | |
double | maxTime () const |
Returns the timeout (in seconds). More... | |
double | currentTime () const |
Returns the current running time in second. More... | |
void | disableMaxTime () |
Disable stopping criterion on timeout. More... | |
void | enableMaxTime () |
Enable stopping criterion on timeout. More... | |
bool | isEnabledMaxTime () const |
Returns true if stopping criterion on timeout is enabled, false otherwise. More... | |
void | setPeriodSize (Size p) |
How many samples between two stopping is enable. More... | |
Size | periodSize () const |
Returns the period size. More... | |
void | setVerbosity (bool v) |
Set the verbosity on (true) or off (false). More... | |
bool | verbosity () const |
Returns true if verbosity is enabled. More... | |
ApproximationSchemeSTATE | stateApproximationScheme () const |
Returns the approximation scheme state. More... | |
Size | nbrIterations () const |
Returns the number of iterations. More... | |
const std::vector< double > & | history () const |
Returns the scheme history. More... | |
void | initApproximationScheme () |
Initialise the scheme. More... | |
bool | startOfPeriod () |
Returns true if we are at the beginning of a period (compute error is mandatory). More... | |
void | updateApproximationScheme (unsigned int incr=1) |
Update the scheme w.r.t the new error and increment steps. More... | |
Size | remainingBurnIn () |
Returns the remaining burn in. More... | |
void | stopApproximationScheme () |
Stop the approximation scheme. More... | |
bool | continueApproximationScheme (double error) |
Update the scheme w.r.t the new error. More... | |
Getters and setters | |
std::string | messageApproximationScheme () const |
Returns the approximation scheme message. More... | |
Public Types | |
enum | ApproximationSchemeSTATE : char { ApproximationSchemeSTATE::Undefined, ApproximationSchemeSTATE::Continue, ApproximationSchemeSTATE::Epsilon, ApproximationSchemeSTATE::Rate, ApproximationSchemeSTATE::Limit, ApproximationSchemeSTATE::TimeLimit, ApproximationSchemeSTATE::Stopped } |
The different state of an approximation scheme. More... | |
Protected Attributes | |
const IBayesNet< GUM_SCALAR > & | _p |
const IBayesNet< GUM_SCALAR > & | _q |
GUM_SCALAR | _klPQ |
GUM_SCALAR | _klQP |
GUM_SCALAR | _hellinger |
GUM_SCALAR | _bhattacharya |
GUM_SCALAR | _jsd |
Size | _errorPQ |
Size | _errorQP |
double | _current_epsilon |
Current epsilon. More... | |
double | _last_epsilon |
Last epsilon value. More... | |
double | _current_rate |
Current rate. More... | |
Size | _current_step |
The current step. More... | |
Timer | _timer |
The timer. More... | |
ApproximationSchemeSTATE | _current_state |
The current state. More... | |
std::vector< double > | _history |
The scheme history, used only if verbosity == true. More... | |
double | _eps |
Threshold for convergence. More... | |
bool | _enabled_eps |
If true, the threshold convergence is enabled. More... | |
double | _min_rate_eps |
Threshold for the epsilon rate. More... | |
bool | _enabled_min_rate_eps |
If true, the minimal threshold for epsilon rate is enabled. More... | |
double | _max_time |
The timeout. More... | |
bool | _enabled_max_time |
If true, the timeout is enabled. More... | |
Size | _max_iter |
The maximum iterations. More... | |
bool | _enabled_max_iter |
If true, the maximum iterations stopping criterion is enabled. More... | |
Size | _burn_in |
Number of iterations before checking stopping criteria. More... | |
Size | _period_size |
Checking criteria frequency. More... | |
bool | _verbosity |
If true, verbosity is enabled. More... | |
Size | _counting |
number of samples drawn More... | |
const IBayesNet< GUM_SCALAR > & | _sampling_bn |
const NodeProperty< Idx > * | _hardEv |
Sequence< NodeId > | _samplingNodes |
Size | _nbr |
bool | _atRandom |
Protected Member Functions | |
void | _computeKL () final |
void | _process () |
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 79 of file GibbsBNdistance.h.
|
stronginherited |
The different state of an approximation scheme.
Enumerator | |
---|---|
Undefined | |
Continue | |
Epsilon | |
Rate | |
Limit | |
TimeLimit | |
Stopped |
Definition at line 65 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 52 of file GibbsKL_tpl.h.
References GIBBSKL_DEFAULT_BURNIN, GIBBSKL_DEFAULT_EPSILON, GIBBSKL_DEFAULT_MAXITER, GIBBSKL_DEFAULT_MIN_EPSILON_RATE, GIBBSKL_DEFAULT_PERIOD_SIZE, GIBBSKL_DEFAULT_TIMEOUT, GIBBSKL_DEFAULT_VERBOSITY, gum::GibbsBNdistance< GUM_SCALAR >::setBurnIn(), gum::ApproximationScheme::setEpsilon(), gum::ApproximationScheme::setMaxIter(), gum::ApproximationScheme::setMaxTime(), gum::ApproximationScheme::setMinEpsilonRate(), gum::ApproximationScheme::setPeriodSize(), and gum::ApproximationScheme::setVerbosity().
|
explicit |
copy constructor
Definition at line 73 of file GibbsKL_tpl.h.
References GIBBSKL_DEFAULT_BURNIN, GIBBSKL_DEFAULT_EPSILON, GIBBSKL_DEFAULT_MAXITER, GIBBSKL_DEFAULT_MIN_EPSILON_RATE, GIBBSKL_DEFAULT_PERIOD_SIZE, GIBBSKL_DEFAULT_TIMEOUT, GIBBSKL_DEFAULT_VERBOSITY, gum::GibbsBNdistance< GUM_SCALAR >::setBurnIn(), gum::ApproximationScheme::setEpsilon(), gum::ApproximationScheme::setMaxIter(), gum::ApproximationScheme::setMaxTime(), gum::ApproximationScheme::setMinEpsilonRate(), gum::ApproximationScheme::setPeriodSize(), and gum::ApproximationScheme::setVerbosity().
gum::GibbsBNdistance< GUM_SCALAR >::~GibbsBNdistance | ( | ) |
destructor
Definition at line 96 of file GibbsKL_tpl.h.
|
finalprotectedvirtual |
Reimplemented from gum::BNdistance< GUM_SCALAR >.
Definition at line 101 of file GibbsKL_tpl.h.
References gum::BNdistance< GUM_SCALAR >::_bhattacharya, gum::BNdistance< GUM_SCALAR >::_errorPQ, gum::BNdistance< GUM_SCALAR >::_errorQP, gum::BNdistance< GUM_SCALAR >::_hellinger, gum::BNdistance< GUM_SCALAR >::_jsd, gum::BNdistance< GUM_SCALAR >::_klPQ, gum::BNdistance< GUM_SCALAR >::_klQP, gum::BNdistance< GUM_SCALAR >::_p, gum::BNdistance< GUM_SCALAR >::_q, gum::GibbsBNdistance< GUM_SCALAR >::burnIn(), gum::ApproximationScheme::continueApproximationScheme(), gum::ApproximationScheme::disableMinEpsilonRate(), gum::ApproximationScheme::enableMinEpsilonRate(), gum::ApproximationScheme::initApproximationScheme(), gum::HashTable< Key, Val, Alloc >::insert(), gum::ApproximationScheme::isEnabledMinEpsilonRate(), gum::GibbsOperator< GUM_SCALAR >::monteCarloSample(), gum::Variable::name(), gum::Instantiation::nbrDim(), gum::ApproximationScheme::nbrIterations(), gum::GibbsOperator< GUM_SCALAR >::nextSample(), gum::ApproximationScheme::updateApproximationScheme(), and gum::Instantiation::variable().
|
protectedinherited |
Definition at line 178 of file BNdistance_tpl.h.
References gum::BNdistance< GUM_SCALAR >::__done, and gum::BNdistance< GUM_SCALAR >::_computeKL().
Referenced by gum::BNdistance< GUM_SCALAR >::bhattacharya(), gum::BNdistance< GUM_SCALAR >::errorPQ(), gum::BNdistance< GUM_SCALAR >::errorQP(), gum::BNdistance< GUM_SCALAR >::hellinger(), gum::BNdistance< GUM_SCALAR >::jsd(), gum::BNdistance< GUM_SCALAR >::klPQ(), and gum::BNdistance< GUM_SCALAR >::klQP().
|
inherited |
Definition at line 93 of file BNdistance_tpl.h.
References gum::BNdistance< GUM_SCALAR >::_bhattacharya, and gum::BNdistance< GUM_SCALAR >::_process().
Size gum::GibbsBNdistance< GUM_SCALAR >::burnIn | ( | ) | const |
Returns the number of burn in.
Definition at line 189 of file GibbsKL_tpl.h.
References gum::ApproximationScheme::_burn_in.
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::_computeKL().
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 227 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_current_epsilon, gum::ApproximationScheme::_current_rate, gum::ApproximationScheme::_current_state, gum::ApproximationScheme::_current_step, gum::ApproximationScheme::_enabled_eps, gum::ApproximationScheme::_enabled_max_iter, gum::ApproximationScheme::_enabled_max_time, gum::ApproximationScheme::_enabled_min_rate_eps, gum::ApproximationScheme::_eps, gum::ApproximationScheme::_history, gum::ApproximationScheme::_last_epsilon, gum::ApproximationScheme::_max_iter, gum::ApproximationScheme::_max_time, gum::ApproximationScheme::_min_rate_eps, gum::ApproximationScheme::_stopScheme(), gum::ApproximationScheme::_timer, gum::IApproximationSchemeConfiguration::Continue, gum::IApproximationSchemeConfiguration::Epsilon, GUM_EMIT3, GUM_ERROR, gum::IApproximationSchemeConfiguration::Limit, gum::IApproximationSchemeConfiguration::messageApproximationScheme(), gum::IApproximationSchemeConfiguration::onProgress, gum::IApproximationSchemeConfiguration::Rate, gum::ApproximationScheme::startOfPeriod(), gum::ApproximationScheme::stateApproximationScheme(), gum::Timer::step(), gum::IApproximationSchemeConfiguration::TimeLimit, and gum::ApproximationScheme::verbosity().
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), gum::SamplingInference< GUM_SCALAR >::_loopApproxInference(), gum::learning::DAG2BNLearner< ALLOC >::createBN(), gum::learning::GreedyHillClimbing::learnStructure(), gum::learning::LocalSearchWithTabuList::learnStructure(), and gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::makeInference().
|
virtualinherited |
Returns the current running time in second.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 128 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_timer, and gum::Timer::step().
Referenced by gum::learning::genericBNLearner::currentTime().
|
inherited |
return KL::Complexity::Heavy,KL::Complexity::Difficult,KL::Complexity::Correct depending on the BNs __p and __q
Definition at line 70 of file BNdistance_tpl.h.
References gum::BNdistance< GUM_SCALAR >::__difficulty.
|
virtualinherited |
Disable stopping criterion on epsilon.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 54 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_enabled_eps.
Referenced by gum::learning::genericBNLearner::disableEpsilon().
|
virtualinherited |
Disable stopping criterion on max iterations.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 105 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_enabled_max_iter.
Referenced by gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::__mcInitApproximationScheme(), gum::learning::genericBNLearner::disableMaxIter(), and gum::learning::GreedyHillClimbing::GreedyHillClimbing().
|
virtualinherited |
Disable stopping criterion on timeout.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 131 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_enabled_max_time.
Referenced by gum::learning::genericBNLearner::disableMaxTime(), and gum::learning::GreedyHillClimbing::GreedyHillClimbing().
|
virtualinherited |
Disable stopping criterion on epsilon rate.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 79 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_enabled_min_rate_eps.
Referenced by gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::__mcInitApproximationScheme(), gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), gum::learning::genericBNLearner::disableMinEpsilonRate(), and gum::learning::GreedyHillClimbing::GreedyHillClimbing().
|
virtualinherited |
Enable stopping criterion on epsilon.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 57 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_enabled_eps.
Referenced by gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::__mcInitApproximationScheme(), and gum::learning::genericBNLearner::enableEpsilon().
|
virtualinherited |
Enable stopping criterion on max iterations.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 108 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_enabled_max_iter.
Referenced by gum::learning::genericBNLearner::enableMaxIter().
|
virtualinherited |
Enable stopping criterion on timeout.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 134 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_enabled_max_time.
Referenced by gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::CNMonteCarloSampling(), and gum::learning::genericBNLearner::enableMaxTime().
|
virtualinherited |
Enable stopping criterion on epsilon rate.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 84 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_enabled_min_rate_eps.
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), and gum::learning::genericBNLearner::enableMinEpsilonRate().
|
virtualinherited |
Returns the value of epsilon.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 51 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_eps.
Referenced by gum::ImportanceSampling< GUM_SCALAR >::_onContextualize(), and gum::learning::genericBNLearner::epsilon().
|
inherited |
Definition at line 105 of file BNdistance_tpl.h.
References gum::BNdistance< GUM_SCALAR >::_errorPQ, and gum::BNdistance< GUM_SCALAR >::_process().
|
inherited |
Definition at line 111 of file BNdistance_tpl.h.
References gum::BNdistance< GUM_SCALAR >::_errorQP, and gum::BNdistance< GUM_SCALAR >::_process().
|
inherited |
Definition at line 87 of file BNdistance_tpl.h.
References gum::BNdistance< GUM_SCALAR >::_hellinger, and gum::BNdistance< GUM_SCALAR >::_process().
|
virtualinherited |
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 173 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_history, GUM_ERROR, gum::ApproximationScheme::stateApproximationScheme(), gum::IApproximationSchemeConfiguration::Undefined, and gum::ApproximationScheme::verbosity().
Referenced by gum::learning::genericBNLearner::history().
|
inherited |
Initialise the scheme.
Definition at line 187 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_current_epsilon, gum::ApproximationScheme::_current_rate, gum::ApproximationScheme::_current_state, gum::ApproximationScheme::_current_step, gum::ApproximationScheme::_history, gum::ApproximationScheme::_timer, gum::IApproximationSchemeConfiguration::Continue, and gum::Timer::reset().
Referenced by gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::__mcInitApproximationScheme(), gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), gum::SamplingInference< GUM_SCALAR >::_loopApproxInference(), gum::SamplingInference< GUM_SCALAR >::_onStateChanged(), gum::learning::DAG2BNLearner< ALLOC >::createBN(), gum::learning::GreedyHillClimbing::learnStructure(), and gum::learning::LocalSearchWithTabuList::learnStructure().
|
inlineinherited |
Definition at line 70 of file gibbsOperator.h.
References gum::GibbsOperator< GUM_SCALAR >::_atRandom.
|
virtualinherited |
Returns true if stopping criterion on epsilon is enabled, false otherwise.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 61 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_enabled_eps.
Referenced by gum::learning::genericBNLearner::isEnabledEpsilon().
|
virtualinherited |
Returns true if stopping criterion on max iterations is enabled, false otherwise.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 112 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_enabled_max_iter.
Referenced by gum::learning::genericBNLearner::isEnabledMaxIter().
|
virtualinherited |
Returns true if stopping criterion on timeout is enabled, false otherwise.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 138 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_enabled_max_time.
Referenced by gum::learning::genericBNLearner::isEnabledMaxTime().
|
virtualinherited |
Returns true if stopping criterion on epsilon rate is enabled, false otherwise.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 90 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_enabled_min_rate_eps.
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), and gum::learning::genericBNLearner::isEnabledMinEpsilonRate().
|
inherited |
Definition at line 99 of file BNdistance_tpl.h.
References gum::BNdistance< GUM_SCALAR >::_jsd, and gum::BNdistance< GUM_SCALAR >::_process().
|
inherited |
Definition at line 75 of file BNdistance_tpl.h.
References gum::BNdistance< GUM_SCALAR >::_klPQ, and gum::BNdistance< GUM_SCALAR >::_process().
|
inherited |
Definition at line 81 of file BNdistance_tpl.h.
References gum::BNdistance< GUM_SCALAR >::_klQP, and gum::BNdistance< GUM_SCALAR >::_process().
|
virtualinherited |
Returns the criterion on number of iterations.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 102 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_max_iter.
Referenced by gum::learning::genericBNLearner::maxIter().
|
virtualinherited |
Returns the timeout (in seconds).
Implements gum::IApproximationSchemeConfiguration.
Definition at line 125 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_max_time.
Referenced by gum::learning::genericBNLearner::maxTime().
|
inherited |
Returns the approximation scheme message.
Definition at line 40 of file IApproximationSchemeConfiguration_inl.h.
References gum::IApproximationSchemeConfiguration::Continue, gum::IApproximationSchemeConfiguration::Epsilon, gum::IApproximationSchemeConfiguration::epsilon(), gum::IApproximationSchemeConfiguration::Limit, gum::IApproximationSchemeConfiguration::maxIter(), gum::IApproximationSchemeConfiguration::maxTime(), gum::IApproximationSchemeConfiguration::minEpsilonRate(), gum::IApproximationSchemeConfiguration::Rate, gum::IApproximationSchemeConfiguration::stateApproximationScheme(), gum::IApproximationSchemeConfiguration::Stopped, gum::IApproximationSchemeConfiguration::TimeLimit, and gum::IApproximationSchemeConfiguration::Undefined.
Referenced by gum::ApproximationScheme::_stopScheme(), gum::ApproximationScheme::continueApproximationScheme(), and gum::credal::InferenceEngine< GUM_SCALAR >::getApproximationSchemeMsg().
|
virtualinherited |
Returns the value of the minimal epsilon rate.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 74 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_min_rate_eps.
Referenced by gum::learning::genericBNLearner::minEpsilonRate().
|
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 70 of file gibbsOperator_tpl.h.
References gum::GibbsOperator< GUM_SCALAR >::__drawVarMonteCarlo(), gum::GibbsOperator< GUM_SCALAR >::_hardEv, gum::GibbsOperator< GUM_SCALAR >::_sampling_bn, gum::Instantiation::add(), and gum::Instantiation::chgVal().
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), gum::GibbsSampling< GUM_SCALAR >::_monteCarloSample(), and gum::GibbsOperator< GUM_SCALAR >::setDrawnAtRandom().
|
inlineinherited |
Getters and setters.
Definition at line 66 of file gibbsOperator.h.
References gum::GibbsOperator< GUM_SCALAR >::_nbr.
|
virtualinherited |
Returns the number of iterations.
OperationNotAllowed | Raised if the scheme did not perform. |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 163 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_current_step, GUM_ERROR, gum::ApproximationScheme::stateApproximationScheme(), and gum::IApproximationSchemeConfiguration::Undefined.
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), and gum::learning::genericBNLearner::nbrIterations().
|
inherited |
draws next sample of Gibbs sampling
Definition at line 95 of file gibbsOperator_tpl.h.
References gum::GibbsOperator< GUM_SCALAR >::__GibbsSample(), gum::GibbsOperator< GUM_SCALAR >::_atRandom, gum::GibbsOperator< GUM_SCALAR >::_counting, gum::GibbsOperator< GUM_SCALAR >::_nbr, gum::GibbsOperator< GUM_SCALAR >::_samplingNodes, gum::randomValue(), and gum::SequenceImplementation< Key, Alloc, Gen >::size().
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), gum::GibbsSampling< GUM_SCALAR >::_draw(), and gum::GibbsOperator< GUM_SCALAR >::setDrawnAtRandom().
|
inherited |
Definition at line 117 of file BNdistance_tpl.h.
References gum::BNdistance< GUM_SCALAR >::_p.
|
virtualinherited |
Returns the period size.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 149 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_period_size.
Referenced by gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::makeInference(), and gum::learning::genericBNLearner::periodSize().
|
inherited |
Definition at line 122 of file BNdistance_tpl.h.
References gum::BNdistance< GUM_SCALAR >::_q.
|
inherited |
Returns the remaining burn in.
Definition at line 210 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_burn_in, and gum::ApproximationScheme::_current_step.
void gum::GibbsBNdistance< GUM_SCALAR >::setBurnIn | ( | Size | b | ) |
Number of burn in for one iteration.
b | The number of burn in. |
OutOfLowerBound | Raised if b < 1. |
Definition at line 184 of file GibbsKL_tpl.h.
References gum::ApproximationScheme::_burn_in.
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance().
|
inlineinherited |
Definition at line 72 of file gibbsOperator.h.
References gum::GibbsOperator< GUM_SCALAR >::_atRandom, gum::GibbsOperator< GUM_SCALAR >::monteCarloSample(), and gum::GibbsOperator< GUM_SCALAR >::nextSample().
|
virtualinherited |
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. |
OutOfLowerBound | Raised if eps < 0. |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 43 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_enabled_eps, gum::ApproximationScheme::_eps, and GUM_ERROR.
Referenced by gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::__mcInitApproximationScheme(), gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::GibbsSampling< GUM_SCALAR >::GibbsSampling(), gum::learning::GreedyHillClimbing::GreedyHillClimbing(), gum::SamplingInference< GUM_SCALAR >::SamplingInference(), and gum::learning::genericBNLearner::setEpsilon().
|
virtualinherited |
Stopping criterion on number of iterations.
If the criterion was disabled it will be enabled.
max | The maximum number of iterations. |
OutOfLowerBound | Raised if max <= 1. |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 95 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_enabled_max_iter, gum::ApproximationScheme::_max_iter, and GUM_ERROR.
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::SamplingInference< GUM_SCALAR >::SamplingInference(), and gum::learning::genericBNLearner::setMaxIter().
|
virtualinherited |
Stopping criterion on timeout.
If the criterion was disabled it will be enabled.
timeout | The timeout value in seconds. |
OutOfLowerBound | Raised if timeout <= 0.0. |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 118 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_enabled_max_time, gum::ApproximationScheme::_max_time, and GUM_ERROR.
Referenced by gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::CNMonteCarloSampling(), gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::SamplingInference< GUM_SCALAR >::SamplingInference(), and gum::learning::genericBNLearner::setMaxTime().
|
virtualinherited |
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. |
OutOfLowerBound | if rate<0 |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 66 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_enabled_min_rate_eps, gum::ApproximationScheme::_min_rate_eps, and GUM_ERROR.
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::GibbsSampling< GUM_SCALAR >::GibbsSampling(), gum::SamplingInference< GUM_SCALAR >::SamplingInference(), and gum::learning::genericBNLearner::setMinEpsilonRate().
|
inlineinherited |
|
virtualinherited |
How many samples between two stopping is enable.
p | The new period value. |
OutOfLowerBound | Raised if p < 1. |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 143 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_period_size, and GUM_ERROR.
Referenced by gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::CNMonteCarloSampling(), gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::SamplingInference< GUM_SCALAR >::SamplingInference(), and gum::learning::genericBNLearner::setPeriodSize().
|
virtualinherited |
Set the verbosity on (true) or off (false).
v | If true, then verbosity is turned on. |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 152 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_verbosity.
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::GibbsBNdistance(), gum::SamplingInference< GUM_SCALAR >::SamplingInference(), and gum::learning::genericBNLearner::setVerbosity().
|
inherited |
Returns true if we are at the beginning of a period (compute error is mandatory).
Definition at line 197 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_burn_in, gum::ApproximationScheme::_current_step, and gum::ApproximationScheme::_period_size.
Referenced by gum::ApproximationScheme::continueApproximationScheme().
|
virtualinherited |
Returns the approximation scheme state.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 158 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_current_state.
Referenced by gum::ApproximationScheme::continueApproximationScheme(), gum::ApproximationScheme::history(), gum::ApproximationScheme::nbrIterations(), and gum::learning::genericBNLearner::stateApproximationScheme().
|
inherited |
Stop the approximation scheme.
Definition at line 219 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_current_state, gum::ApproximationScheme::_stopScheme(), gum::IApproximationSchemeConfiguration::Continue, and gum::IApproximationSchemeConfiguration::Stopped.
Referenced by gum::learning::DAG2BNLearner< ALLOC >::createBN(), gum::learning::GreedyHillClimbing::learnStructure(), and gum::learning::LocalSearchWithTabuList::learnStructure().
|
inherited |
Update the scheme w.r.t the new error and increment steps.
incr | The new increment steps. |
Definition at line 206 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_current_step.
Referenced by gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), gum::SamplingInference< GUM_SCALAR >::_loopApproxInference(), gum::learning::DAG2BNLearner< ALLOC >::createBN(), gum::learning::GreedyHillClimbing::learnStructure(), gum::learning::LocalSearchWithTabuList::learnStructure(), and gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::makeInference().
|
virtualinherited |
Returns true if verbosity is enabled.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 154 of file approximationScheme_inl.h.
References gum::ApproximationScheme::_verbosity.
Referenced by gum::ApproximationScheme::continueApproximationScheme(), gum::ApproximationScheme::history(), and gum::learning::genericBNLearner::verbosity().
|
protectedinherited |
Definition at line 90 of file gibbsOperator.h.
Referenced by gum::GibbsOperator< GUM_SCALAR >::isDrawnAtRandom(), gum::GibbsOperator< GUM_SCALAR >::nextSample(), and gum::GibbsOperator< GUM_SCALAR >::setDrawnAtRandom().
|
protectedinherited |
Definition at line 142 of file BNdistance.h.
Referenced by gum::ExactBNdistance< GUM_SCALAR >::_computeKL(), gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), and gum::BNdistance< GUM_SCALAR >::bhattacharya().
|
protectedinherited |
Number of iterations before checking stopping criteria.
Definition at line 414 of file approximationScheme.h.
Referenced by gum::GibbsSampling< GUM_SCALAR >::burnIn(), gum::GibbsBNdistance< GUM_SCALAR >::burnIn(), gum::ApproximationScheme::remainingBurnIn(), gum::GibbsSampling< GUM_SCALAR >::setBurnIn(), gum::GibbsBNdistance< GUM_SCALAR >::setBurnIn(), and gum::ApproximationScheme::startOfPeriod().
|
protectedinherited |
number of samples drawn
Definition at line 82 of file gibbsOperator.h.
Referenced by gum::GibbsOperator< GUM_SCALAR >::nextSample().
|
protectedinherited |
Current epsilon.
Definition at line 369 of file approximationScheme.h.
Referenced by gum::ApproximationScheme::continueApproximationScheme(), and gum::ApproximationScheme::initApproximationScheme().
|
protectedinherited |
Current rate.
Definition at line 375 of file approximationScheme.h.
Referenced by gum::ApproximationScheme::continueApproximationScheme(), and gum::ApproximationScheme::initApproximationScheme().
|
protectedinherited |
The current state.
Definition at line 384 of file approximationScheme.h.
Referenced by gum::ApproximationScheme::_stopScheme(), gum::ApproximationScheme::continueApproximationScheme(), gum::ApproximationScheme::initApproximationScheme(), gum::ApproximationScheme::stateApproximationScheme(), and gum::ApproximationScheme::stopApproximationScheme().
|
protectedinherited |
The current step.
Definition at line 378 of file approximationScheme.h.
Referenced by gum::learning::Miic::_initiation(), gum::learning::Miic::_iteration(), gum::learning::Miic::_orientation_3off2(), gum::learning::Miic::_orientation_latents(), gum::learning::Miic::_orientation_miic(), gum::ApproximationScheme::continueApproximationScheme(), gum::ApproximationScheme::initApproximationScheme(), gum::learning::Miic::learnMixedStructure(), gum::ApproximationScheme::nbrIterations(), gum::ApproximationScheme::remainingBurnIn(), gum::ApproximationScheme::startOfPeriod(), and gum::ApproximationScheme::updateApproximationScheme().
|
protectedinherited |
If true, the threshold convergence is enabled.
Definition at line 393 of file approximationScheme.h.
Referenced by gum::ApproximationScheme::continueApproximationScheme(), gum::ApproximationScheme::disableEpsilon(), gum::ApproximationScheme::enableEpsilon(), gum::ApproximationScheme::isEnabledEpsilon(), and gum::ApproximationScheme::setEpsilon().
|
protectedinherited |
If true, the maximum iterations stopping criterion is enabled.
Definition at line 411 of file approximationScheme.h.
Referenced by gum::ApproximationScheme::continueApproximationScheme(), gum::ApproximationScheme::disableMaxIter(), gum::ApproximationScheme::enableMaxIter(), gum::ApproximationScheme::isEnabledMaxIter(), and gum::ApproximationScheme::setMaxIter().
|
protectedinherited |
If true, the timeout is enabled.
Definition at line 405 of file approximationScheme.h.
Referenced by gum::ApproximationScheme::continueApproximationScheme(), gum::ApproximationScheme::disableMaxTime(), gum::ApproximationScheme::enableMaxTime(), gum::ApproximationScheme::isEnabledMaxTime(), and gum::ApproximationScheme::setMaxTime().
|
protectedinherited |
If true, the minimal threshold for epsilon rate is enabled.
Definition at line 399 of file approximationScheme.h.
Referenced by gum::ApproximationScheme::continueApproximationScheme(), gum::ApproximationScheme::disableMinEpsilonRate(), gum::ApproximationScheme::enableMinEpsilonRate(), gum::ApproximationScheme::isEnabledMinEpsilonRate(), and gum::ApproximationScheme::setMinEpsilonRate().
|
protectedinherited |
Threshold for convergence.
Definition at line 390 of file approximationScheme.h.
Referenced by gum::ApproximationScheme::continueApproximationScheme(), gum::ApproximationScheme::epsilon(), and gum::ApproximationScheme::setEpsilon().
|
protectedinherited |
Definition at line 145 of file BNdistance.h.
Referenced by gum::ExactBNdistance< GUM_SCALAR >::_computeKL(), gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), and gum::BNdistance< GUM_SCALAR >::errorPQ().
|
protectedinherited |
Definition at line 146 of file BNdistance.h.
Referenced by gum::ExactBNdistance< GUM_SCALAR >::_computeKL(), gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), and gum::BNdistance< GUM_SCALAR >::errorQP().
|
protectedinherited |
Definition at line 84 of file gibbsOperator.h.
Referenced by gum::GibbsOperator< GUM_SCALAR >::__updateSamplingNodes(), and gum::GibbsOperator< GUM_SCALAR >::monteCarloSample().
|
protectedinherited |
Definition at line 141 of file BNdistance.h.
Referenced by gum::ExactBNdistance< GUM_SCALAR >::_computeKL(), gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), and gum::BNdistance< GUM_SCALAR >::hellinger().
|
protectedinherited |
The scheme history, used only if verbosity == true.
Definition at line 387 of file approximationScheme.h.
Referenced by gum::ApproximationScheme::continueApproximationScheme(), gum::ApproximationScheme::history(), and gum::ApproximationScheme::initApproximationScheme().
|
protectedinherited |
Definition at line 143 of file BNdistance.h.
Referenced by gum::ExactBNdistance< GUM_SCALAR >::_computeKL(), gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), and gum::BNdistance< GUM_SCALAR >::jsd().
|
protectedinherited |
Definition at line 139 of file BNdistance.h.
Referenced by gum::ExactBNdistance< GUM_SCALAR >::_computeKL(), gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), and gum::BNdistance< GUM_SCALAR >::klPQ().
|
protectedinherited |
Definition at line 140 of file BNdistance.h.
Referenced by gum::ExactBNdistance< GUM_SCALAR >::_computeKL(), gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), and gum::BNdistance< GUM_SCALAR >::klQP().
|
protectedinherited |
Last epsilon value.
Definition at line 372 of file approximationScheme.h.
Referenced by gum::ApproximationScheme::continueApproximationScheme().
|
protectedinherited |
The maximum iterations.
Definition at line 408 of file approximationScheme.h.
Referenced by gum::ApproximationScheme::continueApproximationScheme(), gum::ApproximationScheme::maxIter(), and gum::ApproximationScheme::setMaxIter().
|
protectedinherited |
The timeout.
Definition at line 402 of file approximationScheme.h.
Referenced by gum::ApproximationScheme::continueApproximationScheme(), gum::ApproximationScheme::maxTime(), and gum::ApproximationScheme::setMaxTime().
|
protectedinherited |
Threshold for the epsilon rate.
Definition at line 396 of file approximationScheme.h.
Referenced by gum::ApproximationScheme::continueApproximationScheme(), gum::ApproximationScheme::minEpsilonRate(), and gum::ApproximationScheme::setMinEpsilonRate().
|
protectedinherited |
Definition at line 87 of file gibbsOperator.h.
Referenced by gum::GibbsOperator< GUM_SCALAR >::__updateSamplingNodes(), gum::GibbsOperator< GUM_SCALAR >::nbrDrawnVar(), gum::GibbsOperator< GUM_SCALAR >::nextSample(), and gum::GibbsOperator< GUM_SCALAR >::setNbrDrawnVar().
|
protectedinherited |
|
protectedinherited |
Checking criteria frequency.
Definition at line 417 of file approximationScheme.h.
Referenced by gum::ApproximationScheme::periodSize(), gum::ApproximationScheme::setPeriodSize(), and gum::ApproximationScheme::startOfPeriod().
|
protectedinherited |
Definition at line 137 of file BNdistance.h.
Referenced by gum::BNdistance< GUM_SCALAR >::__checkCompatibility(), gum::ExactBNdistance< GUM_SCALAR >::_computeKL(), gum::GibbsBNdistance< GUM_SCALAR >::_computeKL(), and gum::BNdistance< GUM_SCALAR >::q().
|
protectedinherited |
|
protectedinherited |
Definition at line 85 of file gibbsOperator.h.
Referenced by gum::GibbsOperator< GUM_SCALAR >::__updateSamplingNodes(), and gum::GibbsOperator< GUM_SCALAR >::nextSample().
|
protectedinherited |
The timer.
Definition at line 381 of file approximationScheme.h.
Referenced by gum::learning::Miic::_initiation(), gum::learning::Miic::_iteration(), gum::learning::Miic::_orientation_3off2(), gum::learning::Miic::_orientation_latents(), gum::learning::Miic::_orientation_miic(), gum::ApproximationScheme::_stopScheme(), gum::ApproximationScheme::continueApproximationScheme(), gum::ApproximationScheme::currentTime(), gum::ApproximationScheme::initApproximationScheme(), and gum::learning::Miic::learnMixedStructure().
|
protectedinherited |
If true, verbosity is enabled.
Definition at line 420 of file approximationScheme.h.
Referenced by gum::ApproximationScheme::setVerbosity(), and gum::ApproximationScheme::verbosity().
Progression, error and time.
Definition at line 59 of file IApproximationSchemeConfiguration.h.
Referenced by gum::learning::Miic::_initiation(), gum::learning::Miic::_iteration(), gum::learning::Miic::_orientation_3off2(), gum::learning::Miic::_orientation_latents(), gum::learning::Miic::_orientation_miic(), gum::ApproximationScheme::continueApproximationScheme(), and gum::learning::genericBNLearner::distributeProgress().
|
inherited |
Criteria messageApproximationScheme.
Definition at line 62 of file IApproximationSchemeConfiguration.h.
Referenced by gum::ApproximationScheme::_stopScheme(), and gum::learning::genericBNLearner::distributeStop().