![]() |
aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
|
<agrum/CN/CNLoopyPropagation.h> More...
#include <CNLoopyPropagation.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) |
Insert evidence from file. More... | |
Public algorithm methods | |
void | makeInference () |
Starts the inference. More... | |
Getters and setters | |
void | inferenceType (InferenceType inft) |
Set the inference type. More... | |
InferenceType | inferenceType () |
Get the inference type. More... | |
Post-inference methods | |
void | eraseAllEvidence () |
Erase all inference related data to perform another one. More... | |
void | saveInference (const std::string &path) |
Constructors / Destructors | |
CNLoopyPropagation (const CredalNet< GUM_SCALAR > &cnet) | |
Constructor. More... | |
virtual | ~CNLoopyPropagation () |
Destructor. 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 | InferenceType : char { InferenceType::nodeToNeighbours, InferenceType::ordered, InferenceType::randomOrder } |
Inference type to be used by the algorithm. More... | |
using | msg = std::vector< Potential< GUM_SCALAR > *> |
using | cArcP = const Arc * |
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 | |
NodeProperty< bool > | update_p_ |
Used to keep track of which node needs to update it's information coming from it's parents. More... | |
NodeProperty< bool > | update_l_ |
Used to keep track of which node needs to update it's information coming from it's children. More... | |
NodeSet | active_nodes_set |
The current node-set to iterate through at this current step. More... | |
NodeSet | next_active_nodes_set |
The next node-set, i.e. More... | |
NodeProperty< NodeSet *> | msg_l_sent_ |
Used to keep track of one's messages sent to it's parents. More... | |
ArcProperty< GUM_SCALAR > | ArcsL_min_ |
"Lower" information \( \Lambda \) coming from one's children. More... | |
ArcProperty< GUM_SCALAR > | ArcsP_min_ |
"Lower" information \( \pi \) coming from one's parent. More... | |
NodeProperty< GUM_SCALAR > | NodesL_min_ |
"Lower" node information \( \Lambda \) obtained by combinaison of children messages. More... | |
NodeProperty< GUM_SCALAR > | NodesP_min_ |
"Lower" node information \( \pi \) obtained by combinaison of parent's messages. More... | |
ArcProperty< GUM_SCALAR > | ArcsL_max_ |
"Upper" information \( \Lambda \) coming from one's children. More... | |
ArcProperty< GUM_SCALAR > | ArcsP_max_ |
"Upper" information \( \pi \) coming from one's parent. More... | |
NodeProperty< GUM_SCALAR > | NodesL_max_ |
"Upper" node information \( \Lambda \) obtained by combinaison of children messages. More... | |
NodeProperty< GUM_SCALAR > | NodesP_max_ |
"Upper" node information \( \pi \) obtained by combinaison of parent's messages. More... | |
bool | InferenceUpToDate_ |
TRUE if inference has already been performed, FALSE otherwise. 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 | 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 | initialize_ () |
Topological forward propagation to initialize old marginals & messages. More... | |
Protected algorithm methods | |
void | makeInferenceNodeToNeighbours_ () |
Starts the inference with this inference type. More... | |
void | makeInferenceByOrderedArcs_ () |
Starts the inference with this inference type. More... | |
void | makeInferenceByRandomOrder_ () |
Starts the inference with this inference type. More... | |
void | updateMarginals_ () |
Compute marginals from up-to-date messages. More... | |
void | msgL_ (const NodeId X, const NodeId demanding_parent) |
Sends a message to one's parent, i.e. More... | |
void | compute_ext_ (GUM_SCALAR &msg_l_min, GUM_SCALAR &msg_l_max, std::vector< GUM_SCALAR > &lx, GUM_SCALAR &num_min, GUM_SCALAR &num_max, GUM_SCALAR &den_min, GUM_SCALAR &den_max) |
Used by msgL_. More... | |
void | compute_ext_ (std::vector< std::vector< GUM_SCALAR > > &combi_msg_p, const NodeId &id, GUM_SCALAR &msg_l_min, GUM_SCALAR &msg_l_max, std::vector< GUM_SCALAR > &lx, const Idx &pos) |
Used by msgL_. More... | |
void | enum_combi_ (std::vector< std::vector< std::vector< GUM_SCALAR > > > &msgs_p, const NodeId &id, GUM_SCALAR &msg_l_min, GUM_SCALAR &msg_l_max, std::vector< GUM_SCALAR > &lx, const Idx &pos) |
Used by msgL_. More... | |
void | msgP_ (const NodeId X, const NodeId demanding_child) |
Sends a message to one's child, i.e. More... | |
void | enum_combi_ (std::vector< std::vector< std::vector< GUM_SCALAR > > > &msgs_p, const NodeId &id, GUM_SCALAR &msg_p_min, GUM_SCALAR &msg_p_max) |
Used by msgP_. More... | |
void | compute_ext_ (std::vector< std::vector< GUM_SCALAR > > &combi_msg_p, const NodeId &id, GUM_SCALAR &msg_p_min, GUM_SCALAR &msg_p_max) |
Used by msgP_. More... | |
void | refreshLMsPIs_ (bool refreshIndic=false) |
Get the last messages from one's parents and children. More... | |
GUM_SCALAR | calculateEpsilon_ () |
Compute epsilon. More... | |
Post-inference protected methods | |
void | computeExpectations_ () |
Since the network is binary, expectations can be computed from the final marginals which give us the credal set vertices. More... | |
void | updateIndicatrices_ () |
Only update indicatrices variables at the end of computations ( calls msgP_ ). More... | |
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... | |
<agrum/CN/CNLoopyPropagation.h>
Class implementing loopy-propagation with binary networks - L2U algorithm.
GUM_SCALAR | A floating type ( float, double, long double ... ). |
Definition at line 57 of file CNLoopyPropagation.h.
|
private |
To easily access InferenceEngine< GUM_SCALAR > methods.
Definition at line 365 of file CNLoopyPropagation.h.
using gum::credal::CNLoopyPropagation< GUM_SCALAR >::cArcP = const Arc* |
Definition at line 60 of file CNLoopyPropagation.h.
using gum::credal::CNLoopyPropagation< GUM_SCALAR >::msg = std::vector< Potential< GUM_SCALAR >* > |
Definition at line 59 of file CNLoopyPropagation.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.
|
strong |
Inference type to be used by the algorithm.
Definition at line 65 of file CNLoopyPropagation.h.
|
explicit |
Constructor.
cnet | The CredalNet to be used with this algorithm. |
Definition at line 1466 of file CNLoopyPropagation_tpl.h.
|
virtual |
Destructor.
Definition at line 1500 of file CNLoopyPropagation_tpl.h.
|
protected |
Compute epsilon.
Definition at line 1419 of file CNLoopyPropagation_tpl.h.
|
protected |
Used by msgL_.
pour les fonctions suivantes, les GUM_SCALAR min/max doivent etre initialises (min a 1 et max a 0) pour comparer avec les resultats intermediaires
Compute the final message for the given parent's message and likelihood (children's messages), numerators & denominators.
msg_l_min | The reference to the current lower value of the message to be sent. |
msg_l_max | The reference to the current upper value of the message to be sent. |
lx | The lower and upper likelihood. |
num_min | The reference to the previously computed lower numerator. |
num_max | The reference to the previously computed upper numerator. |
den_min | The reference to the previously computed lower denominator. |
den_max | The reference to the previously computed upper denominator. |
une fois les cpts marginalises sur X et Ui, on calcul le min/max,
Definition at line 174 of file CNLoopyPropagation_tpl.h.
|
protected |
Used by msgL_.
extremes pour une combinaison des parents, message vers parent
Compute the numerators & denominators for the given parent's message and likelihood (children's messages). Marginalisation.
combi_msg_p | The parent's choosen message. |
id | The constant id of the node sending the message. |
msg_l_min | The reference to the current lower value of the message to be sent. |
msg_l_max | The reference to the current upper value of the message to be sent. |
lx | The lower and upper likelihood. |
pos | The position of the parent node to receive the message in the CPT of the one sending the message ( first parent, second ... ). |
Definition at line 263 of file CNLoopyPropagation_tpl.h.
|
protected |
Used by msgP_.
extremes pour une combinaison des parents, message vers enfant marginalisation cpts
Marginalisation.
combi_msg_p | The parent's choosen message. |
id | The constant id of the node sending the message. |
msg_p_min | The reference to the current lower value of the message to be sent. |
msg_p_max | The reference to the current upper value of the message to be sent. |
Definition at line 329 of file CNLoopyPropagation_tpl.h.
|
inlineprotectedinherited |
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.
|
protected |
Since the network is binary, expectations can be computed from the final marginals which give us the credal set vertices.
Definition at line 1441 of file CNLoopyPropagation_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().
|
protected |
Used by msgL_.
comme precedemment mais pour message parent, vraisemblance prise en compte
Enumerate parent's messages.
msgs_p | All the messages from the parents which will be enumerated. |
id | The constant id of the node sending the message. |
msg_l_min | The reference to the current lower value of the message to be sent. |
msg_l_max | The reference to the current upper value of the message to be sent. |
lx | The lower and upper likelihood. |
pos | The position of the parent node to receive the message in the CPT of the one sending the message ( first parent, second ... ). |
Definition at line 453 of file CNLoopyPropagation_tpl.h.
|
protected |
Used by msgP_.
enumerate combinations messages parents, pour message vers enfant
Enumerate parent's messages.
msgs_p | All the messages from the parents which will be enumerated. |
id | The constant id of the node sending the message. |
msg_p_min | The reference to the current lower value of the message to be sent. |
msg_p_max | The reference to the current upper value of the message to be sent. |
Definition at line 378 of file CNLoopyPropagation_tpl.h.
|
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 from gum::credal::InferenceEngine< GUM_SCALAR >.
Definition at line 565 of file CNLoopyPropagation_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.
|
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().
void gum::credal::CNLoopyPropagation< GUM_SCALAR >::inferenceType | ( | InferenceType | inft | ) |
Set the inference type.
inft | The choosen InferenceType . |
Definition at line 1517 of file CNLoopyPropagation_tpl.h.
CNLoopyPropagation< GUM_SCALAR >::InferenceType gum::credal::CNLoopyPropagation< GUM_SCALAR >::inferenceType | ( | ) |
Get the inference type.
Definition at line 1523 of file CNLoopyPropagation_tpl.h.
|
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.
|
protected |
Topological forward propagation to initialize old marginals & messages.
Definition at line 594 of file CNLoopyPropagation_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.
|
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 |
Insert evidence from file.
path | The path to the evidence file. |
Reimplemented from gum::credal::InferenceEngine< GUM_SCALAR >.
Definition at line 379 of file CNLoopyPropagation.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::InferenceEngine< GUM_SCALAR >.
Definition at line 535 of file CNLoopyPropagation_tpl.h.
|
protected |
Starts the inference with this inference type.
Definition at line 802 of file CNLoopyPropagation_tpl.h.
|
protected |
Starts the inference with this inference type.
Definition at line 758 of file CNLoopyPropagation_tpl.h.
|
protected |
Starts the inference with this inference type.
Definition at line 716 of file CNLoopyPropagation_tpl.h.
|
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().
|
protected |
Sends a message to one's parent, i.e.
X is sending a message to a demanding_parent.
X | The constant node id of the node sending the message. |
demanding_parent | The constant node id of the node receiving the message. |
Definition at line 835 of file CNLoopyPropagation_tpl.h.
|
protected |
Sends a message to one's child, i.e.
X is sending a message to a demanding_child.
X | The constant node id of the node sending the message. |
demanding_child | The constant node id of the node receiving the message. |
Definition at line 1018 of file CNLoopyPropagation_tpl.h.
|
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().
|
protected |
Get the last messages from one's parents and children.
Definition at line 1223 of file CNLoopyPropagation_tpl.h.
|
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.
void gum::credal::CNLoopyPropagation< GUM_SCALAR >::saveInference | ( | const std::string & | path | ) |
This one is easier to read but harder for scripts to parse.
path | The path to the file to save marginals. |
Definition at line 28 of file CNLoopyPropagation_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.
|
protected |
Only update indicatrices variables at the end of computations ( calls msgP_ ).
Definition at line 1427 of file CNLoopyPropagation_tpl.h.
|
protected |
Compute marginals from up-to-date messages.
Definition at line 1326 of file CNLoopyPropagation_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.
|
private |
A pointer to it's IBayesNet used as a DAG.
Definition at line 374 of file CNLoopyPropagation.h.
|
private |
A pointer to the CredalNet to be used.
Definition at line 371 of file CNLoopyPropagation.h.
|
private |
The choosen inference type.
nodeToNeighbours by Default.
Definition at line 368 of file CNLoopyPropagation.h.
|
protected |
The current node-set to iterate through at this current step.
Definition at line 326 of file CNLoopyPropagation.h.
|
protected |
"Upper" information \( \Lambda \) coming from one's children.
Definition at line 348 of file CNLoopyPropagation.h.
|
protected |
"Lower" information \( \Lambda \) coming from one's children.
Definition at line 336 of file CNLoopyPropagation.h.
|
protected |
"Upper" information \( \pi \) coming from one's parent.
Definition at line 350 of file CNLoopyPropagation.h.
|
protected |
"Lower" information \( \pi \) coming from one's parent.
Definition at line 338 of file CNLoopyPropagation.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.
|
protected |
TRUE
if inference has already been performed, FALSE
otherwise.
Definition at line 361 of file CNLoopyPropagation.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.
|
protected |
Used to keep track of one's messages sent to it's parents.
Definition at line 333 of file CNLoopyPropagation.h.
|
protected |
The next node-set, i.e.
the nodes that will send messages at the next step.
Definition at line 330 of file CNLoopyPropagation.h.
|
protected |
"Upper" node information \( \Lambda \) obtained by combinaison of children messages.
Definition at line 353 of file CNLoopyPropagation.h.
|
protected |
"Lower" node information \( \Lambda \) obtained by combinaison of children messages.
Definition at line 341 of file CNLoopyPropagation.h.
|
protected |
"Upper" node information \( \pi \) obtained by combinaison of parent's messages.
Definition at line 357 of file CNLoopyPropagation.h.
|
protected |
"Lower" node information \( \pi \) obtained by combinaison of parent's messages.
Definition at line 345 of file CNLoopyPropagation.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.
|
protectedinherited |
True
if using repetitive independence ( dynamic network only ), False
otherwise.
False
by default.
Definition at line 127 of file inferenceEngine.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.
|
protected |
Used to keep track of which node needs to update it's information coming from it's children.
Definition at line 323 of file CNLoopyPropagation.h.
|
protected |
Used to keep track of which node needs to update it's information coming from it's parents.
Definition at line 319 of file CNLoopyPropagation.h.
|
protectedinherited |
If true, verbosity is enabled.
Definition at line 419 of file approximationScheme.h.