![]() |
aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
|
<agrum/CN/CNMonteCarloSampling.h> More...
#include <CNMonteCarloSampling.h>
Public Attributes | |
Signaler3< Size, double, double > | onProgress |
Progression, error and time. More... | |
Signaler1< std::string > | onStop |
Criteria messageApproximationScheme. More... | |
Public Member Functions | |
virtual void | insertEvidenceFile (const std::string &path) |
unsigned int notOptDelete; More... | |
Constructors / Destructors | |
CNMonteCarloSampling (const CredalNet< GUM_SCALAR > &credalNet) | |
Constructor. More... | |
virtual | ~CNMonteCarloSampling () |
Destructor. More... | |
Public algorithm methods | |
void | makeInference () |
Starts the inference. More... | |
Post-inference methods | |
virtual void | eraseAllEvidence () |
Erase all inference related data to perform another one. More... | |
Getters and setters | |
VarMod2BNsMap< GUM_SCALAR > * | getVarMod2BNsMap () |
Get optimum IBayesNet. More... | |
const CredalNet< GUM_SCALAR > & | credalNet () const |
Get this creadal network. More... | |
const NodeProperty< std::vector< NodeId > > & | getT0Cluster () const |
Get the t0_ cluster. More... | |
const NodeProperty< std::vector< NodeId > > & | getT1Cluster () const |
Get the t1_ cluster. More... | |
void | setRepetitiveInd (const bool repetitive) |
void | storeVertices (const bool value) |
bool | storeVertices () const |
Get the number of iterations without changes used to stop some algorithms. More... | |
void | storeBNOpt (const bool value) |
bool | storeBNOpt () const |
bool | repetitiveInd () const |
Get the current independence status. More... | |
Pre-inference initialization methods | |
void | insertModalsFile (const std::string &path) |
Insert variables modalities from file to compute expectations. More... | |
void | insertModals (const std::map< std::string, std::vector< GUM_SCALAR > > &modals) |
Insert variables modalities from map to compute expectations. More... | |
void | insertEvidence (const std::map< std::string, std::vector< GUM_SCALAR > > &eviMap) |
Insert evidence from map. More... | |
void | insertEvidence (const NodeProperty< std::vector< GUM_SCALAR > > &evidence) |
Insert evidence from Property. More... | |
void | insertQueryFile (const std::string &path) |
Insert query variables states from file. More... | |
void | insertQuery (const NodeProperty< std::vector< bool > > &query) |
Insert query variables and states from Property. More... | |
Post-inference methods | |
Potential< GUM_SCALAR > | marginalMin (const NodeId id) const |
Get the lower marginals of a given node id. More... | |
Potential< GUM_SCALAR > | marginalMin (const std::string &varName) const |
Get the lower marginals of a given variable name. More... | |
Potential< GUM_SCALAR > | marginalMax (const NodeId id) const |
Get the upper marginals of a given node id. More... | |
Potential< GUM_SCALAR > | marginalMax (const std::string &varName) const |
Get the upper marginals of a given variable name. More... | |
const GUM_SCALAR & | expectationMin (const NodeId id) const |
Get the lower expectation of a given node id. More... | |
const GUM_SCALAR & | expectationMin (const std::string &varName) const |
Get the lower expectation of a given variable name. More... | |
const GUM_SCALAR & | expectationMax (const NodeId id) const |
Get the upper expectation of a given node id. More... | |
const GUM_SCALAR & | expectationMax (const std::string &varName) const |
Get the upper expectation of a given variable name. More... | |
const std::vector< GUM_SCALAR > & | dynamicExpMin (const std::string &varName) const |
Get the lower dynamic expectation of a given variable prefix (without the time step included, i.e. More... | |
const std::vector< GUM_SCALAR > & | dynamicExpMax (const std::string &varName) const |
Get the upper dynamic expectation of a given variable prefix (without the time step included, i.e. More... | |
const std::vector< std::vector< GUM_SCALAR > > & | vertices (const NodeId id) const |
Get the vertice of a given node id. More... | |
void | saveMarginals (const std::string &path) const |
Saves marginals to file. More... | |
void | saveExpectations (const std::string &path) const |
Saves expectations to file. More... | |
void | saveVertices (const std::string &path) const |
Saves vertices to file. More... | |
void | dynamicExpectations () |
Compute dynamic expectations. More... | |
std::string | toString () const |
Print all nodes marginals to standart output. More... | |
const std::string | getApproximationSchemeMsg () |
Get approximation scheme state. More... | |
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 | |
bool | repetitiveInd_ |
_margis_ | l_marginalMin_ |
Threads lower marginals, one per thread. More... | |
_margis_ | l_marginalMax_ |
Threads upper marginals, one per thread. More... | |
_expes_ | l_expectationMin_ |
Threads lower expectations, one per thread. More... | |
_expes_ | l_expectationMax_ |
Threads upper expectations, one per thread. More... | |
_modals_ | l_modal_ |
Threads modalities. More... | |
_credalSets_ | l_marginalSets_ |
Threads vertices. More... | |
_margis_ | l_evidence_ |
Threads evidence. More... | |
_clusters_ | l_clusters_ |
Threads clusters. More... | |
std::vector< _bnet_ *> | workingSet_ |
Threads IBayesNet. More... | |
std::vector< List< const Potential< GUM_SCALAR > *> *> | workingSetE_ |
Threads evidence. More... | |
std::vector< BNInferenceEngine *> | l_inferenceEngine_ |
Threads BNInferenceEngine. More... | |
std::vector< VarMod2BNsMap< GUM_SCALAR > *> | l_optimalNet_ |
Threads optimal IBayesNet. More... | |
const CredalNet< GUM_SCALAR > * | credalNet_ |
A pointer to the Credal Net used. More... | |
margi | oldMarginalMin_ |
Old lower marginals used to compute epsilon. More... | |
margi | oldMarginalMax_ |
Old upper marginals used to compute epsilon. More... | |
margi | marginalMin_ |
Lower marginals. More... | |
margi | marginalMax_ |
Upper marginals. More... | |
credalSet | marginalSets_ |
Credal sets vertices, if enabled. More... | |
expe | expectationMin_ |
Lower expectations, if some variables modalities were inserted. More... | |
expe | expectationMax_ |
Upper expectations, if some variables modalities were inserted. More... | |
dynExpe | dynamicExpMin_ |
Lower dynamic expectations. More... | |
dynExpe | dynamicExpMax_ |
Upper dynamic expectations. More... | |
dynExpe | modal_ |
Variables modalities used to compute expectations. More... | |
margi | evidence_ |
Holds observed variables states. More... | |
query | query_ |
Holds the query nodes states. More... | |
cluster | t0_ |
Clusters of nodes used with dynamic networks. More... | |
cluster | t1_ |
Clusters of nodes used with dynamic networks. More... | |
bool | storeVertices_ |
True if credal sets vertices are stored, False otherwise. More... | |
bool | storeBNOpt_ |
Iterations limit stopping rule used by some algorithms such as CNMonteCarloSampling. More... | |
VarMod2BNsMap< GUM_SCALAR > | dbnOpt_ |
Object used to efficiently store optimal bayes net during inference, for some algorithms. More... | |
int | timeSteps_ |
The number of time steps of this network (only usefull for dynamic networks). More... | |
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... | |
Protected Member Functions | |
Protected initialization methods | |
Fusion of threads optimal IBayesNet. | |
void | initThreadsData_ (const Size &num_threads, const bool _storeVertices_, const bool _storeBNOpt_) |
Initialize threads data. More... | |
Protected algorithms methods | |
bool | updateThread_ (const NodeId &id, const std::vector< GUM_SCALAR > &vertex, const bool &elimRedund=false) |
Update thread information (marginals, expectations, IBayesNet, vertices) for a given node id. More... | |
void | updateMarginals_ () |
Fusion of threads marginals. More... | |
const GUM_SCALAR | computeEpsilon_ () |
Compute epsilon and update old marginals. More... | |
void | updateOldMarginals_ () |
Update old marginals (from current marginals). More... | |
Proptected post-inference methods | |
void | optFusion_ () |
Fusion of threads optimal IBayesNet. More... | |
void | expFusion_ () |
Fusion of threads expectations. More... | |
void | verticesFusion_ () |
Protected initialization methods | |
void | repetitiveInit_ () |
Initialize t0_ and t1_ clusters. More... | |
void | initExpectations_ () |
Initialize lower and upper expectations before inference, with the lower expectation being initialized on the highest modality and the upper expectation being initialized on the lowest modality. More... | |
void | initMarginals_ () |
Initialize lower and upper old marginals and marginals before inference, with the lower marginal being 1 and the upper 0. More... | |
void | initMarginalSets_ () |
Initialize credal set vertices with empty sets. More... | |
Protected algorithms methods | |
void | updateExpectations_ (const NodeId &id, const std::vector< GUM_SCALAR > &vertex) |
Given a node id and one of it's possible vertex obtained during inference, update this node lower and upper expectations. More... | |
void | updateCredalSets_ (const NodeId &id, const std::vector< GUM_SCALAR > &vertex, const bool &elimRedund=false) |
Given a node id and one of it's possible vertex, update it's credal set. More... | |
Proptected post-inference methods | |
void | dynamicExpectations_ () |
Rearrange lower and upper expectations to suit dynamic networks. More... | |
<agrum/CN/CNMonteCarloSampling.h>
Inference by basic sampling algorithm (pure random) of bnet in credal networks.
GUM_SCALAR | A floating type ( float, double, long double ... ). |
BNInferenceEngine | A IBayesNet inference engine such as LazyPropagation ( recommanded ). |
Definition at line 60 of file CNMonteCarloSampling.h.
|
private |
To easily acces MultipleInferenceEngine< GUM_SCALAR, BNInferenceEngine
methods.
Definition at line 65 of file CNMonteCarloSampling.h.
|
stronginherited |
The different state of an approximation scheme.
Enumerator | |
---|---|
Undefined | |
Continue | |
Epsilon | |
Rate | |
Limit | |
TimeLimit | |
Stopped |
Definition at line 64 of file IApproximationSchemeConfiguration.h.
|
explicit |
Constructor.
credalNet | The CredalNet to be used by the algorithm. |
Definition at line 29 of file CNMonteCarloSampling_tpl.h.
References gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::CNMonteCarloSampling().
Referenced by gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::CNMonteCarloSampling().
|
virtual |
Destructor.
Definition at line 48 of file CNMonteCarloSampling_tpl.h.
|
inlineprivate |
Get the binary representation of a given value.
toFill | A reference to the bits to fill. Size must be correct before passing argument (i.e. big enough to represent value ) |
value | The constant integer we want to binarize. |
Definition at line 273 of file CNMonteCarloSampling_tpl.h.
|
inlineprivate |
Insert CredalNet evidence into a thread BNInferenceEngine.
Definition at line 392 of file CNMonteCarloSampling_tpl.h.
Referenced by gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::_threadInference_().
|
private |
Initialize approximation Scheme.
Definition at line 188 of file CNMonteCarloSampling_tpl.h.
Referenced by gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::makeInference().
|
private |
Initialize threads data.
Definition at line 203 of file CNMonteCarloSampling_tpl.h.
Referenced by gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::makeInference().
|
inlineprivate |
Thread performs an inference using BNInferenceEngine.
Calls verticesSampling and insertEvidence.
Definition at line 178 of file CNMonteCarloSampling_tpl.h.
References gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::_insertEvidence_(), and gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::_verticesSampling_().
Referenced by gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::makeInference().
|
inlineprivate |
Update thread data after a IBayesNet inference.
Definition at line 151 of file CNMonteCarloSampling_tpl.h.
Referenced by gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::makeInference().
|
inlineprivate |
Thread samples a IBayesNet from the CredalNet.
Definition at line 287 of file CNMonteCarloSampling_tpl.h.
Referenced by gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::_threadInference_().
|
inlineprotectedinherited |
Compute epsilon and update old marginals.
Definition at line 296 of file multipleInferenceEngine_tpl.h.
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 208 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
Get this creadal network.
Definition at line 57 of file inferenceEngine_tpl.h.
|
virtualinherited |
Returns the current running time in second.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 115 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Disable stopping criterion on epsilon.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 53 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Disable stopping criterion on max iterations.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 94 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Disable stopping criterion on timeout.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 118 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Disable stopping criterion on epsilon rate.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 74 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
Compute dynamic expectations.
Definition at line 699 of file inferenceEngine_tpl.h.
|
protectedinherited |
Rearrange lower and upper expectations to suit dynamic networks.
Definition at line 704 of file inferenceEngine_tpl.h.
|
inherited |
Get the upper dynamic expectation of a given variable prefix (without the time step included, i.e.
call with "temp" to get "temp_0", ..., "temp_T").
varName | The variable name prefix which upper expectation we want. |
Definition at line 497 of file inferenceEngine_tpl.h.
|
inherited |
Get the lower dynamic expectation of a given variable prefix (without the time step included, i.e.
call with "temp" to get "temp_0", ..., "temp_T").
varName | The variable name prefix which lower expectation we want. |
Definition at line 481 of file inferenceEngine_tpl.h.
|
virtualinherited |
Enable stopping criterion on epsilon.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 56 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Enable stopping criterion on max iterations.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 97 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Enable stopping criterion on timeout.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 121 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Enable stopping criterion on epsilon rate.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 77 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Returns the value of epsilon.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 50 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Erase all inference related data to perform another one.
You need to insert evidence again if needed but modalities are kept. You can insert new ones by using the appropriate method which will delete the old ones.
Reimplemented from gum::credal::InferenceEngine< GUM_SCALAR >.
Definition at line 517 of file multipleInferenceEngine_tpl.h.
|
inherited |
Get the upper expectation of a given node id.
id | The node id which upper expectation we want. |
Definition at line 473 of file inferenceEngine_tpl.h.
|
inherited |
Get the upper expectation of a given variable name.
varName | The variable name which upper expectation we want. |
Definition at line 459 of file inferenceEngine_tpl.h.
|
inherited |
Get the lower expectation of a given node id.
id | The node id which lower expectation we want. |
Definition at line 466 of file inferenceEngine_tpl.h.
|
inherited |
Get the lower expectation of a given variable name.
varName | The variable name which lower expectation we want. |
Definition at line 451 of file inferenceEngine_tpl.h.
|
protectedinherited |
Fusion of threads expectations.
Definition at line 400 of file multipleInferenceEngine_tpl.h.
|
inlineinherited |
Get approximation scheme state.
Definition at line 500 of file inferenceEngine.h.
|
inherited |
Get the t0_ cluster.
Definition at line 976 of file inferenceEngine_tpl.h.
|
inherited |
Get the t1_ cluster.
Definition at line 982 of file inferenceEngine_tpl.h.
|
inherited |
Get optimum IBayesNet.
Definition at line 138 of file inferenceEngine_tpl.h.
|
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 157 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
Initialise the scheme.
Definition at line 168 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
protectedinherited |
Initialize lower and upper expectations before inference, with the lower expectation being initialized on the highest modality and the upper expectation being initialized on the lowest modality.
Definition at line 678 of file inferenceEngine_tpl.h.
|
protectedinherited |
Initialize lower and upper old marginals and marginals before inference, with the lower marginal being 1 and the upper 0.
Definition at line 646 of file inferenceEngine_tpl.h.
|
protectedinherited |
Initialize credal set vertices with empty sets.
Definition at line 663 of file inferenceEngine_tpl.h.
|
inlineprotectedinherited |
Initialize threads data.
num_threads | The number of threads. |
<em>storeVertices</em> | True if vertices should be stored, False otherwise. |
<em>storeBNOpt</em> | True if optimal IBayesNet should be stored, false otherwise. |
Definition at line 41 of file multipleInferenceEngine_tpl.h.
|
inherited |
Insert evidence from map.
eviMap | The map variable name - likelihood. |
Definition at line 226 of file inferenceEngine_tpl.h.
|
inherited |
Insert evidence from Property.
evidence | The on nodes Property containing likelihoods. |
Definition at line 248 of file inferenceEngine_tpl.h.
|
inlinevirtual |
unsigned int notOptDelete;
Reimplemented from gum::credal::InferenceEngine< GUM_SCALAR >.
Definition at line 124 of file CNMonteCarloSampling.h.
|
inherited |
Insert variables modalities from map to compute expectations.
modals | The map variable name - modalities. |
Definition at line 190 of file inferenceEngine_tpl.h.
|
inherited |
Insert variables modalities from file to compute expectations.
path | The path to the modalities file. |
Definition at line 143 of file inferenceEngine_tpl.h.
|
inherited |
Insert query variables and states from Property.
query | The on nodes Property containing queried variables states. |
Definition at line 327 of file inferenceEngine_tpl.h.
|
inherited |
Insert query variables states from file.
path | The path to the query file. |
Definition at line 344 of file inferenceEngine_tpl.h.
|
virtualinherited |
Returns true if stopping criterion on epsilon is enabled, false otherwise.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 60 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Returns true if stopping criterion on max iterations is enabled, false otherwise.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 101 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Returns true if stopping criterion on timeout is enabled, false otherwise.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 125 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Returns true if stopping criterion on epsilon rate is enabled, false otherwise.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 81 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Starts the inference.
Implements gum::credal::MultipleInferenceEngine< GUM_SCALAR, BNInferenceEngine >.
Definition at line 53 of file CNMonteCarloSampling_tpl.h.
References gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::_mcInitApproximationScheme_(), gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::_mcThreadDataCopy_(), gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::_threadInference_(), and gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::_threadUpdate_().
|
inherited |
Get the upper marginals of a given node id.
id | The node id which upper marginals we want. |
Definition at line 440 of file inferenceEngine_tpl.h.
|
inherited |
Get the upper marginals of a given variable name.
varName | The variable name which upper marginals we want. |
Definition at line 425 of file inferenceEngine_tpl.h.
|
inherited |
Get the lower marginals of a given node id.
id | The node id which lower marginals we want. |
Definition at line 430 of file inferenceEngine_tpl.h.
|
inherited |
Get the lower marginals of a given variable name.
varName | The variable name which lower marginals we want. |
Definition at line 419 of file inferenceEngine_tpl.h.
|
virtualinherited |
Returns the criterion on number of iterations.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 91 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Returns the timeout (in seconds).
Implements gum::IApproximationSchemeConfiguration.
Definition at line 112 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
Returns the approximation scheme message.
Definition at line 38 of file IApproximationSchemeConfiguration_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Returns the value of the minimal epsilon rate.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 71 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Returns the number of iterations.
OperationNotAllowed | Raised if the scheme did not perform. |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 148 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
protectedinherited |
Fusion of threads optimal IBayesNet.
Definition at line 470 of file multipleInferenceEngine_tpl.h.
|
virtualinherited |
Returns the period size.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 134 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
Returns the remaining burn in.
Definition at line 191 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
Get the current independence status.
True
if repetitive, False
otherwise. Definition at line 118 of file inferenceEngine_tpl.h.
|
protectedinherited |
Initialize t0_ and t1_ clusters.
Definition at line 767 of file inferenceEngine_tpl.h.
|
inherited |
Saves expectations to file.
path | The path to the file to be used. |
Definition at line 542 of file inferenceEngine_tpl.h.
|
inherited |
Saves marginals to file.
path | The path to the file to be used. |
Definition at line 518 of file inferenceEngine_tpl.h.
|
inherited |
Saves vertices to file.
path | The path to the file to be used. |
Definition at line 612 of file inferenceEngine_tpl.h.
|
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 42 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
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 84 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
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 105 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
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 63 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
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 128 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
repetitive | True if repetitive independence is to be used, false otherwise. Only usefull with dynamic networks. |
Definition at line 109 of file inferenceEngine_tpl.h.
|
virtualinherited |
Set the verbosity on (true) or off (false).
v | If true, then verbosity is turned on. |
Implements gum::IApproximationSchemeConfiguration.
Definition at line 137 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
Returns true if we are at the beginning of a period (compute error is mandatory).
Definition at line 178 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Returns the approximation scheme state.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 143 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
Stop the approximation scheme.
Definition at line 200 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
value | True if optimal Bayesian networks are to be stored for each variable and each modality. |
Definition at line 97 of file inferenceEngine_tpl.h.
|
inherited |
True
if optimal bayes net are stored for each variable and each modality, False
otherwise. Definition at line 133 of file inferenceEngine_tpl.h.
|
inherited |
value | True if vertices are to be stored, false otherwise. |
Definition at line 102 of file inferenceEngine_tpl.h.
|
inherited |
Get the number of iterations without changes used to stop some algorithms.
True
if vertice are stored, False
otherwise. Definition at line 128 of file inferenceEngine_tpl.h.
|
inherited |
Print all nodes marginals to standart output.
Definition at line 586 of file inferenceEngine_tpl.h.
|
inherited |
Update the scheme w.r.t the new error and increment steps.
incr | The new increment steps. |
Definition at line 187 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inlineprotectedinherited |
Given a node id and one of it's possible vertex, update it's credal set.
To maximise efficiency, don't pass a vertex we know is inside the polytope (i.e. not at an extreme value for any modality)
id | The id of the node to be updated |
vertex | A (potential) vertex of the node credal set |
elimRedund | remove redundant vertex (inside a facet) |
Definition at line 902 of file inferenceEngine_tpl.h.
|
inlineprotectedinherited |
Given a node id and one of it's possible vertex obtained during inference, update this node lower and upper expectations.
id | The id of the node to be updated |
vertex | A (potential) vertex of the node credal set |
Definition at line 881 of file inferenceEngine_tpl.h.
|
inlineprotectedinherited |
Fusion of threads marginals.
Definition at line 267 of file multipleInferenceEngine_tpl.h.
|
protectedinherited |
Update old marginals (from current marginals).
Call this once to initialize old marginals (after burn-in for example) and then use computeEpsilon_ which does the same job but compute epsilon too.
Definition at line 338 of file multipleInferenceEngine_tpl.h.
|
inlineprotectedinherited |
Update thread information (marginals, expectations, IBayesNet, vertices) for a given node id.
id | The id of the node to be updated. |
vertex | The vertex. |
elimRedund | true if redundancy elimination is to be performed, false otherwise and by default. |
True
if the IBayesNet is kept (for now), False
otherwise. Definition at line 85 of file multipleInferenceEngine_tpl.h.
|
virtualinherited |
Returns true if verbosity is enabled.
Implements gum::IApproximationSchemeConfiguration.
Definition at line 139 of file approximationScheme_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
Get the vertice of a given node id.
id | The node id which vertice we want. |
Definition at line 513 of file inferenceEngine_tpl.h.
|
protectedinherited |
Definition at line 366 of file multipleInferenceEngine_tpl.h.
|
protectedinherited |
Number of iterations before checking stopping criteria.
Definition at line 413 of file approximationScheme.h.
|
protectedinherited |
A pointer to the Credal Net used.
Definition at line 68 of file inferenceEngine.h.
|
protectedinherited |
Current epsilon.
Definition at line 368 of file approximationScheme.h.
|
protectedinherited |
Current rate.
Definition at line 374 of file approximationScheme.h.
|
protectedinherited |
The current state.
Definition at line 383 of file approximationScheme.h.
|
protectedinherited |
The current step.
Definition at line 377 of file approximationScheme.h.
|
protectedinherited |
Object used to efficiently store optimal bayes net during inference, for some algorithms.
Definition at line 141 of file inferenceEngine.h.
|
protectedinherited |
Upper dynamic expectations.
If the network if not dynamic it's content is the same as expectationMax_.
Definition at line 95 of file inferenceEngine.h.
|
protectedinherited |
Lower dynamic expectations.
If the network is not dynamic it's content is the same as expectationMin_.
Definition at line 92 of file inferenceEngine.h.
|
protectedinherited |
If true, the threshold convergence is enabled.
Definition at line 392 of file approximationScheme.h.
|
protectedinherited |
If true, the maximum iterations stopping criterion is enabled.
Definition at line 410 of file approximationScheme.h.
|
protectedinherited |
If true, the timeout is enabled.
Definition at line 404 of file approximationScheme.h.
|
protectedinherited |
If true, the minimal threshold for epsilon rate is enabled.
Definition at line 398 of file approximationScheme.h.
|
protectedinherited |
Threshold for convergence.
Definition at line 389 of file approximationScheme.h.
|
protectedinherited |
Holds observed variables states.
Definition at line 101 of file inferenceEngine.h.
|
protectedinherited |
Upper expectations, if some variables modalities were inserted.
Definition at line 88 of file inferenceEngine.h.
|
protectedinherited |
Lower expectations, if some variables modalities were inserted.
Definition at line 85 of file inferenceEngine.h.
|
protectedinherited |
The scheme history, used only if verbosity == true.
Definition at line 386 of file approximationScheme.h.
|
protectedinherited |
Threads clusters.
Definition at line 105 of file multipleInferenceEngine.h.
|
protectedinherited |
Threads evidence.
Definition at line 103 of file multipleInferenceEngine.h.
|
protectedinherited |
Threads upper expectations, one per thread.
Definition at line 97 of file multipleInferenceEngine.h.
|
protectedinherited |
Threads lower expectations, one per thread.
Definition at line 95 of file multipleInferenceEngine.h.
|
protectedinherited |
Threads BNInferenceEngine.
Definition at line 113 of file multipleInferenceEngine.h.
|
protectedinherited |
Threads upper marginals, one per thread.
Definition at line 93 of file multipleInferenceEngine.h.
|
protectedinherited |
Threads lower marginals, one per thread.
Definition at line 91 of file multipleInferenceEngine.h.
|
protectedinherited |
Threads vertices.
Definition at line 101 of file multipleInferenceEngine.h.
|
protectedinherited |
Threads modalities.
Definition at line 99 of file multipleInferenceEngine.h.
|
protectedinherited |
Threads optimal IBayesNet.
Definition at line 115 of file multipleInferenceEngine.h.
|
protectedinherited |
Last epsilon value.
Definition at line 371 of file approximationScheme.h.
|
protectedinherited |
Upper marginals.
Definition at line 78 of file inferenceEngine.h.
|
protectedinherited |
Lower marginals.
Definition at line 76 of file inferenceEngine.h.
|
protectedinherited |
Credal sets vertices, if enabled.
Definition at line 81 of file inferenceEngine.h.
|
protectedinherited |
The maximum iterations.
Definition at line 407 of file approximationScheme.h.
|
protectedinherited |
The timeout.
Definition at line 401 of file approximationScheme.h.
|
protectedinherited |
Threshold for the epsilon rate.
Definition at line 395 of file approximationScheme.h.
|
protectedinherited |
Variables modalities used to compute expectations.
Definition at line 98 of file inferenceEngine.h.
|
protectedinherited |
Old upper marginals used to compute epsilon.
Definition at line 73 of file inferenceEngine.h.
|
protectedinherited |
Old lower marginals used to compute epsilon.
Definition at line 71 of file inferenceEngine.h.
Progression, error and time.
Definition at line 58 of file IApproximationSchemeConfiguration.h.
|
inherited |
Criteria messageApproximationScheme.
Definition at line 61 of file IApproximationSchemeConfiguration.h.
|
protectedinherited |
Checking criteria frequency.
Definition at line 416 of file approximationScheme.h.
|
protectedinherited |
Holds the query nodes states.
Definition at line 103 of file inferenceEngine.h.
|
protected |
Definition at line 126 of file CNMonteCarloSampling.h.
|
protectedinherited |
Iterations limit stopping rule used by some algorithms such as CNMonteCarloSampling.
The algorithms stops if no changes occured within 1000 iterations by default. int iterStop_; True
is optimal bayes net are stored, for each variable and each modality, False
otherwise. Not all algorithms offers this option. False
by default.
Definition at line 137 of file inferenceEngine.h.
|
protectedinherited |
True
if credal sets vertices are stored, False
otherwise.
False
by default.
Definition at line 123 of file inferenceEngine.h.
|
protectedinherited |
Clusters of nodes used with dynamic networks.
Any node key in t0_ is present at \( t=0 \) and any node belonging to the node set of this key share the same CPT than the key. Used for sampling with repetitive independence.
Definition at line 111 of file inferenceEngine.h.
|
protectedinherited |
Clusters of nodes used with dynamic networks.
Any node key in t1_ is present at \( t=1 \) and any node belonging to the node set of this key share the same CPT than the key. Used for sampling with repetitive independence.
Definition at line 118 of file inferenceEngine.h.
|
protectedinherited |
The timer.
Definition at line 380 of file approximationScheme.h.
|
protectedinherited |
The number of time steps of this network (only usefull for dynamic networks).
Definition at line 148 of file inferenceEngine.h.
|
protectedinherited |
If true, verbosity is enabled.
Definition at line 419 of file approximationScheme.h.
|
protectedinherited |
Threads IBayesNet.
Definition at line 108 of file multipleInferenceEngine.h.
|
protectedinherited |
Threads evidence.
Definition at line 110 of file multipleInferenceEngine.h.