![]() |
aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
|
Abstract class template representing a CredalNet inference engine. More...
#include <agrum/CN/inferenceEngine.h>
Public Attributes | |
Signaler3< Size, double, double > | onProgress |
Progression, error and time. More... | |
Signaler1< std::string > | onStop |
Criteria messageApproximationScheme. More... | |
Public Member Functions | |
Constructors / Destructors | |
InferenceEngine (const CredalNet< GUM_SCALAR > &credalNet) | |
Construtor. More... | |
virtual | ~InferenceEngine () |
Destructor. More... | |
Pure virtual methods | |
virtual void | makeInference ()=0 |
To be redefined by each credal net algorithm. 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) |
void | storeBNOpt (const bool value) |
bool | repetitiveInd () const |
Get the current independence status. More... | |
bool | storeVertices () const |
Get the number of iterations without changes used to stop some algorithms. More... | |
bool | storeBNOpt () const |
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... | |
virtual void | insertEvidenceFile (const std::string &path) |
Insert evidence from file. 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 | |
virtual void | eraseAllEvidence () |
Erase all inference related data to perform another one. More... | |
Potential< GUM_SCALAR > | marginalMin (const NodeId id) const |
Get the lower marginals of a given node id. More... | |
Potential< GUM_SCALAR > | marginalMax (const NodeId id) const |
Get the upper 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 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 & | expectationMax (const NodeId id) const |
Get the upper 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 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 | |
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 | repetitiveInd_ |
True if using repetitive independence ( dynamic network only ), 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 | |
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 | |
const GUM_SCALAR | computeEpsilon_ () |
Compute approximation scheme epsilon using the old marginals and the new ones. More... | |
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... | |
Abstract class template representing a CredalNet inference engine.
Used by credal network inference algorithms such as CNLoopyPropagation (inner multi-threading) or CNMonteCarloSampling (outer multi-threading).
GUM_SCALAR | A floating type ( float, double, long double ... ). |
Definition at line 54 of file inferenceEngine.h.
|
private |
Definition at line 64 of file inferenceEngine.h.
|
private |
Definition at line 57 of file inferenceEngine.h.
|
private |
Definition at line 61 of file inferenceEngine.h.
|
private |
Definition at line 59 of file inferenceEngine.h.
|
private |
Definition at line 58 of file inferenceEngine.h.
|
private |
Definition at line 63 of file inferenceEngine.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 |
Construtor.
credalNet | The credal net to be used with this inference engine. |
Definition at line 40 of file inferenceEngine_tpl.h.
|
virtual |
Destructor.
Definition at line 52 of file inferenceEngine_tpl.h.
|
inlineprotected |
Compute approximation scheme epsilon using the old marginals and the new ones.
Highest delta on either lower or upper marginal is epsilon.
Also updates oldMarginals to current marginals.
Definition at line 987 of file inferenceEngine_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().
const CredalNet< GUM_SCALAR > & gum::credal::InferenceEngine< GUM_SCALAR >::credalNet | ( | ) | const |
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().
void gum::credal::InferenceEngine< GUM_SCALAR >::dynamicExpectations | ( | ) |
Compute dynamic expectations.
Definition at line 699 of file inferenceEngine_tpl.h.
|
protected |
Rearrange lower and upper expectations to suit dynamic networks.
Definition at line 704 of file inferenceEngine_tpl.h.
const std::vector< GUM_SCALAR > & gum::credal::InferenceEngine< 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.
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.
const std::vector< GUM_SCALAR > & gum::credal::InferenceEngine< 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.
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().
|
virtual |
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 in gum::credal::MultipleInferenceEngine< GUM_SCALAR, BNInferenceEngine >, and gum::credal::CNLoopyPropagation< GUM_SCALAR >.
Definition at line 62 of file inferenceEngine_tpl.h.
const GUM_SCALAR & gum::credal::InferenceEngine< GUM_SCALAR >::expectationMax | ( | const NodeId | id | ) | const |
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.
const GUM_SCALAR & gum::credal::InferenceEngine< GUM_SCALAR >::expectationMax | ( | const std::string & | varName | ) | const |
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.
const GUM_SCALAR & gum::credal::InferenceEngine< GUM_SCALAR >::expectationMin | ( | const NodeId | id | ) | const |
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.
const GUM_SCALAR & gum::credal::InferenceEngine< GUM_SCALAR >::expectationMin | ( | const std::string & | varName | ) | const |
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.
|
inline |
Get approximation scheme state.
Definition at line 500 of file inferenceEngine.h.
const NodeProperty< std::vector< NodeId > > & gum::credal::InferenceEngine< GUM_SCALAR >::getT0Cluster | ( | ) | const |
Get the t0_ cluster.
Definition at line 976 of file inferenceEngine_tpl.h.
const NodeProperty< std::vector< NodeId > > & gum::credal::InferenceEngine< GUM_SCALAR >::getT1Cluster | ( | ) | const |
Get the t1_ cluster.
Definition at line 982 of file inferenceEngine_tpl.h.
VarMod2BNsMap< GUM_SCALAR > * gum::credal::InferenceEngine< GUM_SCALAR >::getVarMod2BNsMap | ( | ) |
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().
|
protected |
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.
|
protected |
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.
|
protected |
Initialize credal set vertices with empty sets.
Definition at line 663 of file inferenceEngine_tpl.h.
void gum::credal::InferenceEngine< GUM_SCALAR >::insertEvidence | ( | const std::map< std::string, std::vector< GUM_SCALAR > > & | eviMap | ) |
Insert evidence from map.
eviMap | The map variable name - likelihood. |
Definition at line 226 of file inferenceEngine_tpl.h.
void gum::credal::InferenceEngine< GUM_SCALAR >::insertEvidence | ( | const NodeProperty< std::vector< GUM_SCALAR > > & | evidence | ) |
Insert evidence from Property.
evidence | The on nodes Property containing likelihoods. |
Definition at line 248 of file inferenceEngine_tpl.h.
|
virtual |
Insert evidence from file.
path | The path to the evidence file. |
Reimplemented in gum::credal::CNLoopyPropagation< GUM_SCALAR >, and gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >.
Definition at line 266 of file inferenceEngine_tpl.h.
void gum::credal::InferenceEngine< GUM_SCALAR >::insertModals | ( | const std::map< std::string, std::vector< GUM_SCALAR > > & | modals | ) |
Insert variables modalities from map to compute expectations.
modals | The map variable name - modalities. |
Definition at line 190 of file inferenceEngine_tpl.h.
void gum::credal::InferenceEngine< GUM_SCALAR >::insertModalsFile | ( | const std::string & | path | ) |
Insert variables modalities from file to compute expectations.
path | The path to the modalities file. |
Definition at line 143 of file inferenceEngine_tpl.h.
void gum::credal::InferenceEngine< GUM_SCALAR >::insertQuery | ( | const NodeProperty< std::vector< bool > > & | query | ) |
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.
void gum::credal::InferenceEngine< GUM_SCALAR >::insertQueryFile | ( | const std::string & | path | ) |
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().
|
pure virtual |
To be redefined by each credal net algorithm.
Starts the inference.
Implemented in gum::credal::MultipleInferenceEngine< GUM_SCALAR, BNInferenceEngine >, gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >, and gum::credal::CNLoopyPropagation< GUM_SCALAR >.
gum::Potential< GUM_SCALAR > gum::credal::InferenceEngine< GUM_SCALAR >::marginalMax | ( | const NodeId | id | ) | const |
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.
INLINE Potential< GUM_SCALAR > gum::credal::InferenceEngine< GUM_SCALAR >::marginalMax | ( | const std::string & | varName | ) | const |
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.
gum::Potential< GUM_SCALAR > gum::credal::InferenceEngine< GUM_SCALAR >::marginalMin | ( | const NodeId | id | ) | const |
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.
INLINE Potential< GUM_SCALAR > gum::credal::InferenceEngine< GUM_SCALAR >::marginalMin | ( | const std::string & | varName | ) | const |
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().
|
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().
bool gum::credal::InferenceEngine< GUM_SCALAR >::repetitiveInd | ( | ) | const |
Get the current independence status.
True
if repetitive, False
otherwise. Definition at line 118 of file inferenceEngine_tpl.h.
|
protected |
Initialize t0_ and t1_ clusters.
Definition at line 767 of file inferenceEngine_tpl.h.
void gum::credal::InferenceEngine< GUM_SCALAR >::saveExpectations | ( | const std::string & | path | ) | const |
Saves expectations to file.
path | The path to the file to be used. |
Definition at line 542 of file inferenceEngine_tpl.h.
void gum::credal::InferenceEngine< GUM_SCALAR >::saveMarginals | ( | const std::string & | path | ) | const |
Saves marginals to file.
path | The path to the file to be used. |
Definition at line 518 of file inferenceEngine_tpl.h.
void gum::credal::InferenceEngine< GUM_SCALAR >::saveVertices | ( | const std::string & | path | ) | const |
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().
void gum::credal::InferenceEngine< GUM_SCALAR >::setRepetitiveInd | ( | const bool | repetitive | ) |
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().
void gum::credal::InferenceEngine< GUM_SCALAR >::storeBNOpt | ( | const bool | value | ) |
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.
bool gum::credal::InferenceEngine< GUM_SCALAR >::storeBNOpt | ( | ) | const |
True
if optimal bayes net are stored for each variable and each modality, False
otherwise. Definition at line 133 of file inferenceEngine_tpl.h.
void gum::credal::InferenceEngine< GUM_SCALAR >::storeVertices | ( | const bool | value | ) |
value | True if vertices are to be stored, false otherwise. |
Definition at line 102 of file inferenceEngine_tpl.h.
bool gum::credal::InferenceEngine< GUM_SCALAR >::storeVertices | ( | ) | const |
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.
std::string gum::credal::InferenceEngine< GUM_SCALAR >::toString | ( | ) | const |
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().
|
inlineprotected |
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.
|
inlineprotected |
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.
|
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().
const std::vector< std::vector< GUM_SCALAR > > & gum::credal::InferenceEngine< GUM_SCALAR >::vertices | ( | const NodeId | id | ) | const |
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 |
Number of iterations before checking stopping criteria.
Definition at line 413 of file approximationScheme.h.
|
protected |
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.
|
protected |
Object used to efficiently store optimal bayes net during inference, for some algorithms.
Definition at line 141 of file inferenceEngine.h.
|
protected |
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.
|
protected |
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.
|
protected |
Holds observed variables states.
Definition at line 101 of file inferenceEngine.h.
|
protected |
Upper expectations, if some variables modalities were inserted.
Definition at line 88 of file inferenceEngine.h.
|
protected |
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 |
Last epsilon value.
Definition at line 371 of file approximationScheme.h.
|
protected |
Upper marginals.
Definition at line 78 of file inferenceEngine.h.
|
protected |
Lower marginals.
Definition at line 76 of file inferenceEngine.h.
|
protected |
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.
|
protected |
Variables modalities used to compute expectations.
Definition at line 98 of file inferenceEngine.h.
|
protected |
Old upper marginals used to compute epsilon.
Definition at line 73 of file inferenceEngine.h.
|
protected |
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.
|
protected |
Holds the query nodes states.
Definition at line 103 of file inferenceEngine.h.
|
protected |
True
if using repetitive independence ( dynamic network only ), False
otherwise.
False
by default.
Definition at line 127 of file inferenceEngine.h.
|
protected |
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.
|
protected |
True
if credal sets vertices are stored, False
otherwise.
False
by default.
Definition at line 123 of file inferenceEngine.h.
|
protected |
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.
|
protected |
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.
|
protected |
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.