![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
<agrum/MRF/inference/marginalTargetedMRFInference.h> More...
#include <marginalTargetedMRFInference.h>
Public Types | |
| enum class | StateOfInference { OutdatedStructure , OutdatedTensors , ReadyForInference , Done } |
| current state of the inference More... | |
Public Member Functions | |
| Tensor< GUM_SCALAR > | evidenceImpact (NodeId target, const NodeSet &evs) |
| Create a gum::Tensor for P(target|evs) (for all instanciation of target and evs). | |
| Tensor< GUM_SCALAR > | evidenceImpact (const std::string &target, const std::vector< std::string > &evs) |
| Create a gum::Tensor for P(target|evs) (for all instanciation of target and evs). | |
Constructors / Destructors | |
| MarginalTargetedMRFInference (const IMarkovRandomField< GUM_SCALAR > *mn) | |
| default constructor | |
| virtual | ~MarginalTargetedMRFInference () |
| destructor | |
Probability computations | |
| virtual const Tensor< GUM_SCALAR > & | posterior (NodeId node) |
| Computes and returns the posterior of a node. | |
| virtual const Tensor< GUM_SCALAR > & | posterior (const std::string &nodeName) |
| Computes and returns the posterior of a node. | |
Targets | |
| virtual void | eraseAllTargets () |
| Clear all previously defined targets. | |
| virtual void | addAllTargets () final |
| adds all nodes as targets | |
| virtual void | addTarget (NodeId target) final |
| Add a marginal target to the list of targets. | |
| virtual void | addTarget (const std::string &nodeName) final |
| Add a marginal target to the list of targets. | |
| virtual void | eraseTarget (NodeId target) final |
| removes an existing (marginal) target | |
| virtual void | eraseTarget (const std::string &nodeName) final |
| removes an existing (marginal) target | |
| virtual bool | isTarget (NodeId node) const final |
| return true if variable is a (marginal) target | |
| virtual bool | isTarget (const std::string &nodeName) const final |
| return true if variable is a (marginal) target | |
| virtual Size | nbrTargets () const noexcept final |
| returns the number of marginal targets | |
| virtual const NodeSet & | targets () const noexcept final |
| returns the list of marginal targets | |
Information Theory related functions | |
| virtual GUM_SCALAR | H (NodeId X) final |
| Entropy Compute Shanon's entropy of a node given the observation. | |
| virtual GUM_SCALAR | H (const std::string &nodeName) final |
| Entropy Compute Shanon's entropy of a node given the observation. | |
Accessors / Modifiers | |
| virtual const GraphicalModel & | model () const final |
| Returns a constant reference over the IBayesNet referenced by this class. | |
| virtual const NodeProperty< Size > & | domainSizes () const final |
| get the domain sizes of the random variables of the model | |
| virtual bool | isInferenceReady () const noexcept final |
| returns whether the inference object is in a ready state | |
| virtual bool | isInferenceOutdatedStructure () const noexcept final |
| returns whether the inference object is in a OutdatedStructure state | |
| virtual bool | isInferenceOutdatedTensors () const noexcept final |
| returns whether the inference object is in a OutdatedTensor state | |
| virtual bool | isInferenceDone () const noexcept final |
| returns whether the inference object is in a InferenceDone state | |
| virtual void | prepareInference () final |
| prepare the internal inference structures for the next inference | |
| virtual void | makeInference () final |
| perform the heavy computations needed to compute the targets' posteriors | |
| virtual void | clear () |
| clears all the data structures allocated for the last inference | |
| virtual StateOfInference | state () const noexcept final |
| returns the state of the inference engine | |
Evidence | |
| virtual void | addEvidence (NodeId id, const Idx val) final |
| adds a new hard evidence on node id | |
| virtual void | addEvidence (const std::string &nodeName, const Idx val) final |
| adds a new hard evidence on node named nodeName | |
| virtual void | addEvidence (NodeId id, const std::string &label) final |
| adds a new hard evidence on node id | |
| virtual void | addEvidence (const std::string &nodeName, const std::string &label) final |
| adds a new hard evidence on node named nodeName | |
| virtual void | addEvidence (NodeId id, const std::vector< GUM_SCALAR > &vals) final |
| adds a new evidence on node id (might be soft or hard) | |
| virtual void | addEvidence (const std::string &nodeName, const std::vector< GUM_SCALAR > &vals) final |
| adds a new evidence on node named nodeName (might be soft or hard) | |
| virtual void | addEvidence (const Tensor< GUM_SCALAR > &pot) final |
| adds a new evidence on node id (might be soft or hard) | |
| virtual void | addEvidence (Tensor< GUM_SCALAR > &&pot) final |
| adds a new evidence on node id (might be soft or hard) | |
| virtual void | addSetOfEvidence (const Set< const Tensor< GUM_SCALAR > * > &potset) final |
| adds a new set of evidence | |
| virtual void | addListOfEvidence (const List< const Tensor< GUM_SCALAR > * > &potlist) final |
| adds a new list of evidence | |
| virtual void | chgEvidence (NodeId id, const Idx val) final |
| change the value of an already existing hard evidence | |
| virtual void | chgEvidence (const std::string &nodeName, const Idx val) final |
| change the value of an already existing hard evidence | |
| virtual void | chgEvidence (NodeId id, const std::string &label) final |
| change the value of an already existing hard evidence | |
| virtual void | chgEvidence (const std::string &nodeName, const std::string &label) final |
| change the value of an already existing hard evidence | |
| virtual void | chgEvidence (NodeId id, const std::vector< GUM_SCALAR > &vals) final |
| change the value of an already existing evidence (might be soft or hard) | |
| virtual void | chgEvidence (const std::string &nodeName, const std::vector< GUM_SCALAR > &vals) final |
| change the value of an already existing evidence (might be soft or hard) | |
| virtual void | chgEvidence (const Tensor< GUM_SCALAR > &pot) final |
| change the value of an already existing evidence (might be soft or hard) | |
| virtual void | eraseAllEvidence () final |
| removes all the evidence entered into the network | |
| virtual void | eraseEvidence (NodeId id) final |
| removed the evidence, if any, corresponding to node id | |
| virtual void | eraseEvidence (const std::string &nodeName) final |
| removed the evidence, if any, corresponding to node of name nodeName | |
| virtual bool | hasEvidence () const final |
| indicates whether some node(s) have received evidence | |
| virtual bool | hasEvidence (NodeId id) const final |
| indicates whether node id has received an evidence | |
| virtual bool | hasEvidence (const std::string &nodeName) const final |
| indicates whether node id has received an evidence | |
| virtual bool | hasHardEvidence (NodeId id) const final |
| indicates whether node id has received a hard evidence | |
| virtual bool | hasHardEvidence (const std::string &nodeName) const final |
| indicates whether node id has received a hard evidence | |
| virtual bool | hasSoftEvidence (NodeId id) const final |
| indicates whether node id has received a soft evidence | |
| virtual bool | hasSoftEvidence (const std::string &nodeName) const final |
| indicates whether node id has received a soft evidence | |
| virtual Size | nbrEvidence () const final |
| returns the number of evidence entered into the Bayesian network | |
| virtual Size | nbrHardEvidence () const final |
| returns the number of hard evidence entered into the Bayesian network | |
| virtual Size | nbrSoftEvidence () const final |
| returns the number of soft evidence entered into the Bayesian network | |
| const NodeProperty< const Tensor< GUM_SCALAR > * > & | evidence () const |
| returns the set of evidence | |
| const NodeSet & | softEvidenceNodes () const |
| returns the set of nodes with soft evidence | |
| const NodeSet & | hardEvidenceNodes () const |
| returns the set of nodes with hard evidence | |
| const NodeProperty< Idx > & | hardEvidence () const |
| indicate for each node with hard evidence which value it took | |
Protected Member Functions | |
| virtual void | onMarginalTargetAdded_ (const NodeId id)=0 |
| fired after a new marginal target is inserted | |
| virtual void | onMarginalTargetErased_ (const NodeId id)=0 |
| fired before a marginal target is removed | |
| virtual void | onAllMarginalTargetsAdded_ ()=0 |
| fired after all the nodes of the MRF are added as marginal targets | |
| virtual void | onAllMarginalTargetsErased_ ()=0 |
| fired before a all marginal targets are removed | |
| virtual void | onModelChanged_ (const GraphicalModel *mn) |
| fired after a new Markov net has been assigned to the engine | |
| virtual const Tensor< GUM_SCALAR > & | posterior_ (NodeId id)=0 |
| asks derived classes for the posterior of a given variable | |
| void | setTargetedMode_ () |
| bool | isTargetedMode_ () const |
| virtual void | onStateChanged_ ()=0 |
| fired when the stage is changed | |
| virtual void | onEvidenceAdded_ (const NodeId id, bool isHardEvidence)=0 |
| fired after a new evidence is inserted | |
| virtual void | onEvidenceErased_ (const NodeId id, bool isHardEvidence)=0 |
| fired before an evidence is removed | |
| virtual void | onAllEvidenceErased_ (bool contains_hard_evidence)=0 |
| fired before all the evidence are erased | |
| virtual void | onEvidenceChanged_ (const NodeId id, bool hasChangedSoftHard)=0 |
| fired after an evidence is changed, in particular when its status (soft/hard) changes | |
| virtual void | updateOutdatedStructure_ ()=0 |
| prepares inference when the latter is in OutdatedStructure state | |
| virtual void | updateOutdatedTensors_ ()=0 |
| prepares inference when the latter is in OutdatedTensors state | |
| virtual void | makeInference_ ()=0 |
| called when the inference has to be performed effectively | |
| void | setOutdatedStructureState_ () |
| put the inference into an outdated model structure state | |
| void | setOutdatedTensorsState_ () |
| puts the inference into an OutdatedTensors state if it is not already in an OutdatedStructure state | |
| virtual void | setState_ (const StateOfInference state) final |
| set the state of the inference engine and call the notification onStateChanged_ when necessary (i.e. when the state has effectively changed). | |
| void | setModel_ (const GraphicalModel *model) |
| void | setModelDuringConstruction_ (const GraphicalModel *model) |
| assigns a model during the inference engine construction | |
| bool | hasNoModel_ () const |
Private Member Functions | |
| void | _setAllMarginalTargets_ () |
| sets all the nodes of the Markov net as targets | |
| Tensor< GUM_SCALAR > | _createHardEvidence_ (NodeId id, Idx val) const |
| create the internal structure for a hard evidence | |
| bool | _isHardEvidence_ (const Tensor< GUM_SCALAR > &pot, Idx &val) const |
| checks whether a tensor corresponds to a hard evidence or not | |
| void | _computeDomainSizes_ () |
| computes the domain sizes of the random variables | |
Private Attributes | |
| bool | _targeted_mode_ |
| whether the actual targets are default | |
| NodeSet | _targets_ |
| the set of marginal targets | |
| StateOfInference | _state_ {StateOfInference::OutdatedStructure} |
| the current state of the inference (outdated/ready/done) | |
| const GraphicalModel * | _model_ {nullptr} |
| the Bayes net on which we perform inferences | |
| NodeProperty< Size > | _domain_sizes_ |
| the domain sizes of the random variables | |
| NodeProperty< const Tensor< GUM_SCALAR > * > | _evidence_ |
| the set of evidence entered into the network | |
| NodeProperty< Idx > | _hard_evidence_ |
| assign to each node with a hard evidence the index of its observed value | |
| NodeSet | _soft_evidence_nodes_ |
| the set of nodes that received soft evidence | |
| NodeSet | _hard_evidence_nodes_ |
| the set of nodes that received hard evidence | |
Accessors / Modifiers | |
| friend | MarginalTargetedMRFInference< GUM_SCALAR > |
| allow JointInference to access the single targets and inference states | |
| friend | JointTargetedMRFInference< GUM_SCALAR > |
| assigns a new MRF to the inference engine | |
| friend | EvidenceMRFInference< GUM_SCALAR > |
| assigns a new MRF to the inference engine | |
| virtual void | setMRF (const IMarkovRandomField< GUM_SCALAR > *mrf) |
| assigns a new MRF to the inference engine | |
| virtual const IMarkovRandomField< GUM_SCALAR > & | MRF () const final |
| Returns a constant reference over the IMarkovRandomField referenced by this class. | |
| void | _setMRFDuringConstruction_ (const IMarkovRandomField< GUM_SCALAR > *mn) |
| assigns a MRF during the inference engine construction | |
<agrum/MRF/inference/marginalTargetedMRFInference.h>
A generic class for the computation of (possibly incrementally) marginal posteriors
The goal of this class is to take care of the marginal targets used for computing marginal posteriors. The MarginalTargetedMRFInference class inherits from Inference that takes care of handling both evidence and the current state of the inference. Note that the MarginalTargetedMRFInference is designed to be used in incremental inference engines.
Definition at line 76 of file marginalTargetedMRFInference.h.
|
stronginherited |
current state of the inference
graphicalModelInference can be in one of 4 different states:
| Enumerator | |
|---|---|
| OutdatedStructure | |
| OutdatedTensors | |
| ReadyForInference | |
| Done | |
Definition at line 127 of file graphicalModelInference.h.
|
explicit |
default constructor
Definition at line 55 of file marginalTargetedMRFInference_tpl.h.
References MarginalTargetedMRFInference(), gum::MRFInference< GUM_SCALAR >::MRFInference(), gum::MRFInference< GUM_SCALAR >::_setMRFDuringConstruction_(), _targeted_mode_, _targets_, gum::NodeGraphPart::asNodeSet(), gum::UGmodel::graph(), and gum::GraphicalModelInference< GUM_SCALAR >::hasNoModel_().
Referenced by gum::JointTargetedMRFInference< GUM_SCALAR >::JointTargetedMRFInference(), MarginalTargetedMRFInference(), and ~MarginalTargetedMRFInference().
|
virtual |
destructor
Definition at line 71 of file marginalTargetedMRFInference_tpl.h.
References MarginalTargetedMRFInference().
|
privateinherited |
computes the domain sizes of the random variables
Definition at line 162 of file graphicalModelInference_tpl.h.
References _domain_sizes_, _model_, and hasNoModel_().
Referenced by GraphicalModelInference(), setModel_(), and setModelDuringConstruction_().
|
privateinherited |
create the internal structure for a hard evidence
Definition at line 184 of file graphicalModelInference_tpl.h.
References _model_, gum::Tensor< GUM_SCALAR >::deterministicTensor(), and GUM_ERROR.
Referenced by addEvidence(), and chgEvidence().
|
privateinherited |
checks whether a tensor corresponds to a hard evidence or not
Definition at line 203 of file graphicalModelInference_tpl.h.
References gum::Instantiation::end(), GUM_ERROR, gum::Instantiation::inc(), gum::Instantiation::setFirst(), and gum::Instantiation::val().
Referenced by addEvidence(), and chgEvidence().
|
private |
sets all the nodes of the Markov net as targets
Definition at line 222 of file marginalTargetedMRFInference_tpl.h.
References _targets_, gum::GraphicalModelInference< GUM_SCALAR >::hasNoModel_(), gum::MRFInference< GUM_SCALAR >::MRF(), and onAllMarginalTargetsAdded_().
Referenced by onModelChanged_().
|
privateinherited |
assigns a MRF during the inference engine construction
Definition at line 87 of file MRFInference_tpl.h.
References gum::GraphicalModelInference< GUM_SCALAR >::setModelDuringConstruction_().
Referenced by gum::EvidenceMRFInference< GUM_SCALAR >::EvidenceMRFInference(), gum::JointTargetedMRFInference< GUM_SCALAR >::JointTargetedMRFInference(), and gum::MarginalTargetedMRFInference< GUM_SCALAR >::MarginalTargetedMRFInference().
|
finalvirtual |
adds all nodes as targets
Definition at line 143 of file marginalTargetedMRFInference_tpl.h.
References _targets_, GUM_ERROR, gum::GraphicalModelInference< GUM_SCALAR >::hasNoModel_(), gum::MRFInference< GUM_SCALAR >::MRF(), onMarginalTargetAdded_(), gum::GraphicalModelInference< GUM_SCALAR >::OutdatedStructure, gum::GraphicalModelInference< GUM_SCALAR >::setState_(), and setTargetedMode_().
|
finalvirtualinherited |
adds a new hard evidence on node named nodeName
| UndefinedElement | if nodeName does not belong to the Bayesian network |
| InvalidArgument | if val is not a value for id |
| InvalidArgument | if nodeName already has an evidence |
Definition at line 235 of file graphicalModelInference_tpl.h.
References addEvidence(), and model().
|
finalvirtualinherited |
adds a new hard evidence on node named nodeName
| UndefinedElement | if nodeName does not belong to the Bayesian network |
| InvalidArgument | if val is not a value for id |
| InvalidArgument | if nodeName already has an evidence |
Definition at line 249 of file graphicalModelInference_tpl.h.
References addEvidence(), and model().
|
finalvirtualinherited |
adds a new evidence on node named nodeName (might be soft or hard)
| UndefinedElement | if id does not belong to the Bayesian network |
| InvalidArgument | if nodeName already has an evidence |
| FatalError | if vals=[0,0,...,0] |
| InvalidArgument | if the size of vals is different from the domain size of node nodeName |
Definition at line 281 of file graphicalModelInference_tpl.h.
References addEvidence(), and model().
|
finalvirtualinherited |
adds a new evidence on node id (might be soft or hard)
| UndefinedElement | if the tensor is defined over several nodes |
| UndefinedElement | if the node on which the tensor is defined does not belong to the Bayesian network |
| InvalidArgument | if the node of the tensor already has an evidence |
| FatalError | if pot=[0,0,...,0] |
Definition at line 323 of file graphicalModelInference_tpl.h.
References addEvidence().
|
finalvirtualinherited |
adds a new hard evidence on node id
| UndefinedElement | if id does not belong to the Bayesian network |
| InvalidArgument | if val is not a value for id |
| InvalidArgument | if id already has an evidence |
Definition at line 229 of file graphicalModelInference_tpl.h.
References _createHardEvidence_(), and addEvidence().
Referenced by addEvidence(), addEvidence(), addEvidence(), addEvidence(), addEvidence(), addEvidence(), addEvidence(), addListOfEvidence(), addSetOfEvidence(), gum::MarginalTargetedInference< GUM_SCALAR >::evidenceImpact(), gum::MarginalTargetedMRFInference< GUM_SCALAR >::evidenceImpact(), gum::JointTargetedInference< GUM_SCALAR >::evidenceJointImpact(), gum::JointTargetedMRFInference< GUM_SCALAR >::evidenceJointImpact(), and gum::LoopySamplingInference< GUM_SCALAR, APPROX >::makeInference_().
|
finalvirtualinherited |
adds a new hard evidence on node id
| UndefinedElement | if id does not belong to the Bayesian network |
| InvalidArgument | if val is not a value for id |
| InvalidArgument | if id already has an evidence |
Definition at line 242 of file graphicalModelInference_tpl.h.
References addEvidence(), and model().
|
finalvirtualinherited |
adds a new evidence on node id (might be soft or hard)
| UndefinedElement | if id does not belong to the Bayesian network |
| InvalidArgument | if id already has an evidence |
| FatalError | if vals=[0,0,...,0] |
| InvalidArgument | if the size of vals is different from the domain size of node id |
Definition at line 257 of file graphicalModelInference_tpl.h.
References _model_, addEvidence(), and GUM_ERROR.
|
finalvirtualinherited |
adds a new evidence on node id (might be soft or hard)
| UndefinedElement | if the tensor is defined over several nodes |
| UndefinedElement | if the node on which the tensor is defined does not belong to the Bayesian network |
| InvalidArgument | if the node of the tensor already has an evidence |
| FatalError | if pot=[0,0,...,0] |
Definition at line 288 of file graphicalModelInference_tpl.h.
References _evidence_, _hard_evidence_, _hard_evidence_nodes_, _isHardEvidence_(), _model_, _soft_evidence_nodes_, GUM_ERROR, hasEvidence(), onEvidenceAdded_(), OutdatedStructure, and setState_().
|
finalvirtualinherited |
adds a new list of evidence
| UndefinedElement | if some tensor is defined over several nodes |
| UndefinedElement | if the node on which some tensor is defined does not belong to the Bayesian network |
| InvalidArgument | if the node of some tensor already has an evidence |
| FatalError | if pot=[0,0,...,0] |
Definition at line 330 of file graphicalModelInference_tpl.h.
References addEvidence().
|
finalvirtualinherited |
adds a new set of evidence
| UndefinedElement | if some tensor is defined over several nodes |
| UndefinedElement | if the node on which some tensor is defined does not belong to the Bayesian network |
| InvalidArgument | if the node of some tensor already has an evidence |
| FatalError | if pot=[0,0,...,0] |
Definition at line 338 of file graphicalModelInference_tpl.h.
References addEvidence().
|
finalvirtual |
Add a marginal target to the list of targets.
| UndefinedElement | if target is not a NodeId in the Markov net |
Definition at line 163 of file marginalTargetedMRFInference_tpl.h.
References addTarget(), GUM_ERROR, gum::GraphicalModelInference< GUM_SCALAR >::hasNoModel_(), and gum::MRFInference< GUM_SCALAR >::MRF().
|
finalvirtual |
Add a marginal target to the list of targets.
| UndefinedElement | if target is not a NodeId in the Markov net |
Definition at line 121 of file marginalTargetedMRFInference_tpl.h.
References _targets_, GUM_ERROR, gum::GraphicalModelInference< GUM_SCALAR >::hasNoModel_(), gum::MRFInference< GUM_SCALAR >::MRF(), onMarginalTargetAdded_(), gum::GraphicalModelInference< GUM_SCALAR >::OutdatedStructure, gum::GraphicalModelInference< GUM_SCALAR >::setState_(), and setTargetedMode_().
Referenced by addTarget(), and evidenceImpact().
|
finalvirtualinherited |
change the value of an already existing hard evidence
| UndefinedElement | if nodeName does not belong to the Bayesian network |
| InvalidArgument | if val is not a value for id |
| InvalidArgument | if id does not already have an evidence |
Definition at line 397 of file graphicalModelInference_tpl.h.
References chgEvidence(), and model().
|
finalvirtualinherited |
change the value of an already existing hard evidence
| UndefinedElement | if nodeName does not belong to the Bayesian network |
| InvalidArgument | if val is not a value for id |
| InvalidArgument | if id does not already have an evidence |
Definition at line 411 of file graphicalModelInference_tpl.h.
References chgEvidence(), and model().
|
finalvirtualinherited |
change the value of an already existing evidence (might be soft or hard)
| UndefinedElement | if nodeName does not belong to the Bayesian network |
| InvalidArgument | if the node does not already have an evidence |
| FatalError | if vals=[0,0,...,0] |
| InvalidArgument | if the size of vals is different from the domain size of node id |
Definition at line 445 of file graphicalModelInference_tpl.h.
References chgEvidence(), and model().
|
finalvirtualinherited |
change the value of an already existing evidence (might be soft or hard)
| UndefinedElement | if the tensor is defined over several nodes |
| UndefinedElement | if the node on which the tensor is defined does not belong to the Bayesian network |
| InvalidArgument | if the node of the tensor does not already have an evidence |
| FatalError | if pot=[0,0,...,0] |
Definition at line 452 of file graphicalModelInference_tpl.h.
References _evidence_, _hard_evidence_, _hard_evidence_nodes_, _isHardEvidence_(), _model_, _soft_evidence_nodes_, gum::Instantiation::end(), GUM_ERROR, hasEvidence(), hasHardEvidence(), gum::Instantiation::inc(), isInferenceOutdatedStructure(), onEvidenceChanged_(), OutdatedStructure, OutdatedTensors, gum::Instantiation::setFirst(), and setState_().
|
finalvirtualinherited |
change the value of an already existing hard evidence
| UndefinedElement | if id does not belong to the Bayesian network |
| InvalidArgument | if val is not a value for id |
| InvalidArgument | if id does not already have an evidence |
Definition at line 391 of file graphicalModelInference_tpl.h.
References _createHardEvidence_(), and chgEvidence().
Referenced by chgEvidence(), chgEvidence(), chgEvidence(), chgEvidence(), chgEvidence(), chgEvidence(), gum::MarginalTargetedInference< GUM_SCALAR >::evidenceImpact(), gum::MarginalTargetedMRFInference< GUM_SCALAR >::evidenceImpact(), gum::JointTargetedInference< GUM_SCALAR >::evidenceJointImpact(), and gum::JointTargetedMRFInference< GUM_SCALAR >::evidenceJointImpact().
|
finalvirtualinherited |
change the value of an already existing hard evidence
| UndefinedElement | if id does not belong to the Bayesian network |
| InvalidArgument | if val is not a value for id |
| InvalidArgument | if id does not already have an evidence |
Definition at line 404 of file graphicalModelInference_tpl.h.
References chgEvidence(), and model().
|
finalvirtualinherited |
change the value of an already existing evidence (might be soft or hard)
| UndefinedElement | if id does not belong to the Bayesian network |
| InvalidArgument | if the node does not already have an evidence |
| FatalError | if vals=[0,0,...,0] |
| InvalidArgument | if the size of vals is different from the domain size of node id |
Definition at line 420 of file graphicalModelInference_tpl.h.
References _model_, chgEvidence(), and GUM_ERROR.
|
virtualinherited |
clears all the data structures allocated for the last inference
Reimplemented in gum::ShaferShenoyLIMIDInference< GUM_SCALAR >.
Definition at line 155 of file graphicalModelInference_tpl.h.
References eraseAllEvidence(), OutdatedStructure, and setState_().
Referenced by setModel_().
|
finalvirtualinherited |
get the domain sizes of the random variables of the model
Definition at line 173 of file graphicalModelInference_tpl.h.
References _domain_sizes_.
|
finalvirtualinherited |
removes all the evidence entered into the network
Definition at line 540 of file graphicalModelInference_tpl.h.
References _evidence_, _hard_evidence_, _hard_evidence_nodes_, _soft_evidence_nodes_, isInferenceOutdatedStructure(), onAllEvidenceErased_(), OutdatedStructure, OutdatedTensors, and setState_().
Referenced by clear(), gum::MarginalTargetedInference< GUM_SCALAR >::evidenceImpact(), gum::MarginalTargetedMRFInference< GUM_SCALAR >::evidenceImpact(), gum::JointTargetedInference< GUM_SCALAR >::evidenceJointImpact(), gum::JointTargetedMRFInference< GUM_SCALAR >::evidenceJointImpact(), gum::JointTargetedInference< GUM_SCALAR >::jointMutualInformation(), and gum::JointTargetedMRFInference< GUM_SCALAR >::jointMutualInformation().
|
virtual |
Clear all previously defined targets.
Reimplemented in gum::JointTargetedMRFInference< GUM_SCALAR >.
Definition at line 110 of file marginalTargetedMRFInference_tpl.h.
References _targets_, onAllMarginalTargetsErased_(), gum::GraphicalModelInference< GUM_SCALAR >::OutdatedStructure, gum::GraphicalModelInference< GUM_SCALAR >::setState_(), and setTargetedMode_().
Referenced by gum::JointTargetedMRFInference< GUM_SCALAR >::eraseAllMarginalTargets(), and evidenceImpact().
|
finalvirtualinherited |
removed the evidence, if any, corresponding to node of name nodeName
Definition at line 534 of file graphicalModelInference_tpl.h.
References eraseEvidence(), and model().
|
finalvirtualinherited |
removed the evidence, if any, corresponding to node id
Definition at line 514 of file graphicalModelInference_tpl.h.
References _evidence_, _hard_evidence_, _hard_evidence_nodes_, _soft_evidence_nodes_, hasEvidence(), hasHardEvidence(), isInferenceOutdatedStructure(), onEvidenceErased_(), OutdatedStructure, OutdatedTensors, and setState_().
Referenced by eraseEvidence().
|
finalvirtual |
removes an existing (marginal) target
Definition at line 198 of file marginalTargetedMRFInference_tpl.h.
References eraseTarget(), GUM_ERROR, gum::GraphicalModelInference< GUM_SCALAR >::hasNoModel_(), and gum::MRFInference< GUM_SCALAR >::MRF().
|
finalvirtual |
removes an existing (marginal) target
Definition at line 175 of file marginalTargetedMRFInference_tpl.h.
References _targeted_mode_, _targets_, GUM_ERROR, gum::GraphicalModelInference< GUM_SCALAR >::hasNoModel_(), gum::MRFInference< GUM_SCALAR >::MRF(), onMarginalTargetErased_(), gum::GraphicalModelInference< GUM_SCALAR >::OutdatedStructure, and gum::GraphicalModelInference< GUM_SCALAR >::setState_().
Referenced by eraseTarget().
|
inherited |
returns the set of evidence
Definition at line 587 of file graphicalModelInference_tpl.h.
References _evidence_.
Referenced by gum::ImportanceSampling< GUM_SCALAR >::onContextualize_(), gum::MarginalTargetedInference< GUM_SCALAR >::posterior(), and gum::MarginalTargetedMRFInference< GUM_SCALAR >::posterior().
| Tensor< GUM_SCALAR > gum::MarginalTargetedMRFInference< GUM_SCALAR >::evidenceImpact | ( | const std::string & | target, |
| const std::vector< std::string > & | evs ) |
Create a gum::Tensor for P(target|evs) (for all instanciation of target and evs).
| target | the nodeId of the target variable |
| evs | the nodeId of the observed variable |
Definition at line 312 of file marginalTargetedMRFInference_tpl.h.
References evidenceImpact(), and gum::MRFInference< GUM_SCALAR >::MRF().
| Tensor< GUM_SCALAR > gum::MarginalTargetedMRFInference< GUM_SCALAR >::evidenceImpact | ( | NodeId | target, |
| const NodeSet & | evs ) |
Create a gum::Tensor for P(target|evs) (for all instanciation of target and evs).
| mn | the MarkovRandomField |
| target | the nodeId of the targetted variable |
| evs | the vector of nodeId of the observed variables |
Definition at line 274 of file marginalTargetedMRFInference_tpl.h.
References gum::GraphicalModelInference< GUM_SCALAR >::addEvidence(), addTarget(), gum::GraphicalModelInference< GUM_SCALAR >::chgEvidence(), gum::Set< Key >::contains(), gum::Instantiation::end(), gum::GraphicalModelInference< GUM_SCALAR >::eraseAllEvidence(), eraseAllTargets(), GUM_ERROR, gum::Instantiation::incNotVar(), gum::Instantiation::incVar(), gum::GraphicalModelInference< GUM_SCALAR >::makeInference(), gum::MRFInference< GUM_SCALAR >::MRF(), posterior(), gum::Instantiation::setFirst(), gum::Instantiation::setFirstVar(), and gum::Instantiation::val().
Referenced by evidenceImpact().
|
finalvirtual |
Entropy Compute Shanon's entropy of a node given the observation.
Definition at line 268 of file marginalTargetedMRFInference_tpl.h.
References H(), and gum::MRFInference< GUM_SCALAR >::MRF().
|
finalvirtual |
Entropy Compute Shanon's entropy of a node given the observation.
Definition at line 260 of file marginalTargetedMRFInference_tpl.h.
References posterior().
Referenced by H().
|
inherited |
indicate for each node with hard evidence which value it took
Definition at line 580 of file graphicalModelInference_tpl.h.
References _hard_evidence_.
Referenced by gum::GibbsSampling< GUM_SCALAR >::GibbsSampling(), gum::SamplingInference< GUM_SCALAR >::contextualize(), gum::ImportanceSampling< GUM_SCALAR >::draw_(), and gum::WeightedSampling< GUM_SCALAR >::draw_().
|
inherited |
returns the set of nodes with hard evidence
the set of nodes that received hard evidence
Definition at line 599 of file graphicalModelInference_tpl.h.
References _hard_evidence_nodes_.
Referenced by gum::SamplingInference< GUM_SCALAR >::contextualize(), gum::ImportanceSampling< GUM_SCALAR >::draw_(), gum::MonteCarloSampling< GUM_SCALAR >::draw_(), gum::WeightedSampling< GUM_SCALAR >::draw_(), gum::ImportanceSampling< GUM_SCALAR >::onContextualize_(), gum::MarginalTargetedInference< GUM_SCALAR >::posterior(), gum::MarginalTargetedMRFInference< GUM_SCALAR >::posterior(), gum::SamplingInference< GUM_SCALAR >::setEstimatorFromBN_(), and gum::SamplingInference< GUM_SCALAR >::setEstimatorFromLBP_().
|
finalvirtualinherited |
indicates whether some node(s) have received evidence
Definition at line 346 of file graphicalModelInference_tpl.h.
References _evidence_.
Referenced by addEvidence(), chgEvidence(), eraseEvidence(), and hasEvidence().
|
finalvirtualinherited |
indicates whether node id has received an evidence
Definition at line 371 of file graphicalModelInference_tpl.h.
References hasEvidence(), and model().
|
finalvirtualinherited |
indicates whether node id has received an evidence
Definition at line 352 of file graphicalModelInference_tpl.h.
References _evidence_.
|
finalvirtualinherited |
indicates whether node id has received a hard evidence
Definition at line 378 of file graphicalModelInference_tpl.h.
References hasHardEvidence(), and model().
|
finalvirtualinherited |
indicates whether node id has received a hard evidence
Definition at line 358 of file graphicalModelInference_tpl.h.
References _hard_evidence_nodes_.
Referenced by chgEvidence(), gum::ImportanceSampling< GUM_SCALAR >::draw_(), eraseEvidence(), hasHardEvidence(), and gum::JointTargetedMRFInference< GUM_SCALAR >::jointPosterior().
|
inlineprotectedinherited |
Definition at line 542 of file graphicalModelInference.h.
References _model_.
Referenced by gum::EvidenceInference< GUM_SCALAR >::EvidenceInference(), gum::EvidenceMRFInference< GUM_SCALAR >::EvidenceMRFInference(), gum::JointTargetedInference< GUM_SCALAR >::JointTargetedInference(), gum::JointTargetedMRFInference< GUM_SCALAR >::JointTargetedMRFInference(), gum::MarginalTargetedInference< GUM_SCALAR >::MarginalTargetedInference(), gum::MarginalTargetedMRFInference< GUM_SCALAR >::MarginalTargetedMRFInference(), _computeDomainSizes_(), gum::MarginalTargetedInference< GUM_SCALAR >::_setAllMarginalTargets_(), gum::MarginalTargetedMRFInference< GUM_SCALAR >::_setAllMarginalTargets_(), gum::MarginalTargetedInference< GUM_SCALAR >::addAllTargets(), gum::MarginalTargetedMRFInference< GUM_SCALAR >::addAllTargets(), gum::JointTargetedInference< GUM_SCALAR >::addJointTarget(), gum::JointTargetedMRFInference< GUM_SCALAR >::addJointTarget(), gum::MarginalTargetedInference< GUM_SCALAR >::addTarget(), gum::MarginalTargetedInference< GUM_SCALAR >::addTarget(), gum::MarginalTargetedMRFInference< GUM_SCALAR >::addTarget(), gum::MarginalTargetedMRFInference< GUM_SCALAR >::addTarget(), gum::JointTargetedInference< GUM_SCALAR >::eraseJointTarget(), gum::JointTargetedMRFInference< GUM_SCALAR >::eraseJointTarget(), gum::MarginalTargetedInference< GUM_SCALAR >::eraseTarget(), gum::MarginalTargetedInference< GUM_SCALAR >::eraseTarget(), gum::MarginalTargetedMRFInference< GUM_SCALAR >::eraseTarget(), gum::MarginalTargetedMRFInference< GUM_SCALAR >::eraseTarget(), gum::JointTargetedInference< GUM_SCALAR >::isJointTarget(), gum::JointTargetedMRFInference< GUM_SCALAR >::isJointTarget(), gum::MarginalTargetedInference< GUM_SCALAR >::isTarget(), and gum::MarginalTargetedMRFInference< GUM_SCALAR >::isTarget().
|
finalvirtualinherited |
indicates whether node id has received a soft evidence
Definition at line 385 of file graphicalModelInference_tpl.h.
References hasSoftEvidence(), and model().
|
finalvirtualinherited |
indicates whether node id has received a soft evidence
Definition at line 364 of file graphicalModelInference_tpl.h.
References _soft_evidence_nodes_.
Referenced by hasSoftEvidence().
|
finalvirtualnoexceptinherited |
returns whether the inference object is in a InferenceDone state
The inference object is in a done state when the posteriors can be retrieved without performing a new inference, i.e., all the heavy computations have already been performed. Typically, in a junction tree algorithm, this corresponds to a situation in which all the messages needed in the JT have been computed and sent.
Definition at line 104 of file graphicalModelInference_tpl.h.
Referenced by gum::JointTargetedInference< GUM_SCALAR >::jointPosterior(), gum::JointTargetedMRFInference< GUM_SCALAR >::jointPosterior(), makeInference(), gum::MarginalTargetedInference< GUM_SCALAR >::posterior(), gum::MarginalTargetedMRFInference< GUM_SCALAR >::posterior(), and prepareInference().
|
finalvirtualnoexceptinherited |
returns whether the inference object is in a OutdatedStructure state
Definition at line 92 of file graphicalModelInference_tpl.h.
References _state_, and OutdatedStructure.
Referenced by chgEvidence(), eraseAllEvidence(), and eraseEvidence().
|
finalvirtualnoexceptinherited |
returns whether the inference object is in a OutdatedTensor state
Definition at line 98 of file graphicalModelInference_tpl.h.
References _state_, and OutdatedTensors.
|
finalvirtualnoexceptinherited |
returns whether the inference object is in a ready state
Definition at line 86 of file graphicalModelInference_tpl.h.
References _state_, and ReadyForInference.
Referenced by makeInference(), gum::SamplingInference< GUM_SCALAR >::onStateChanged_(), and prepareInference().
|
finalvirtual |
return true if variable is a (marginal) target
Definition at line 104 of file marginalTargetedMRFInference_tpl.h.
References isTarget(), and gum::MRFInference< GUM_SCALAR >::MRF().
|
finalvirtual |
return true if variable is a (marginal) target
Definition at line 88 of file marginalTargetedMRFInference_tpl.h.
References _targets_, GUM_ERROR, gum::GraphicalModelInference< GUM_SCALAR >::hasNoModel_(), and gum::MRFInference< GUM_SCALAR >::MRF().
Referenced by isTarget(), gum::JointTargetedMRFInference< GUM_SCALAR >::posterior(), and posterior().
|
protected |
Definition at line 320 of file marginalTargetedMRFInference_tpl.h.
References _targeted_mode_.
|
finalvirtualinherited |
perform the heavy computations needed to compute the targets' posteriors
In a Junction tree propagation scheme, for instance, the heavy computations are those of the messages sent in the JT. This is precisely what makeInference should compute. Later, the computations of the posteriors can be done "lightly" by multiplying and projecting those messages.
Definition at line 638 of file graphicalModelInference_tpl.h.
References Done, isInferenceDone(), isInferenceReady(), makeInference_(), prepareInference(), and setState_().
Referenced by gum::MarginalTargetedInference< GUM_SCALAR >::evidenceImpact(), gum::MarginalTargetedMRFInference< GUM_SCALAR >::evidenceImpact(), gum::JointTargetedInference< GUM_SCALAR >::evidenceJointImpact(), gum::JointTargetedMRFInference< GUM_SCALAR >::evidenceJointImpact(), gum::JointTargetedInference< GUM_SCALAR >::jointMutualInformation(), gum::JointTargetedMRFInference< GUM_SCALAR >::jointMutualInformation(), gum::JointTargetedInference< GUM_SCALAR >::jointPosterior(), gum::JointTargetedMRFInference< GUM_SCALAR >::jointPosterior(), gum::LoopySamplingInference< GUM_SCALAR, APPROX >::makeInference_(), gum::MarginalTargetedInference< GUM_SCALAR >::posterior(), and gum::MarginalTargetedMRFInference< GUM_SCALAR >::posterior().
|
protectedpure virtualinherited |
called when the inference has to be performed effectively
Once the inference is done, fillPosterior_ can be called.
Implemented in gum::LazyPropagation< GUM_SCALAR >, gum::LoopyBeliefPropagation< GUM_SCALAR >, gum::LoopySamplingInference< GUM_SCALAR, GibbsSampling >, gum::LoopySamplingInference< GUM_SCALAR, ImportanceSampling >, gum::LoopySamplingInference< GUM_SCALAR, MonteCarloSampling >, gum::LoopySamplingInference< GUM_SCALAR, WeightedSampling >, gum::SamplingInference< GUM_SCALAR >, gum::ShaferShenoyInference< GUM_SCALAR >, gum::ShaferShenoyLIMIDInference< GUM_SCALAR >, gum::ShaferShenoyMRFInference< GUM_SCALAR >, and gum::VariableElimination< GUM_SCALAR >.
References makeInference_(), setOutdatedStructureState_(), and setOutdatedTensorsState_().
Referenced by makeInference(), and makeInference_().
|
finalvirtualinherited |
Returns a constant reference over the IBayesNet referenced by this class.
| UndefinedElement | is raised if no Bayes net has been assigned to the inference. |
Definition at line 126 of file graphicalModelInference_tpl.h.
References _model_, and GUM_ERROR.
Referenced by GraphicalModelInference(), addEvidence(), addEvidence(), addEvidence(), addEvidence(), gum::BayesNetInference< GUM_SCALAR >::BN(), chgEvidence(), chgEvidence(), chgEvidence(), chgEvidence(), eraseEvidence(), hasEvidence(), hasHardEvidence(), hasSoftEvidence(), gum::MRFInference< GUM_SCALAR >::MRF(), onModelChanged_(), gum::ShaferShenoyLIMIDInference< GUM_SCALAR >::onModelChanged_(), setModel_(), and setModelDuringConstruction_().
|
finalvirtualinherited |
Returns a constant reference over the IMarkovRandomField referenced by this class.
| UndefinedElement | is raised if no Markov net has been assigned to the inference. |
Definition at line 75 of file MRFInference_tpl.h.
References gum::GraphicalModelInference< GUM_SCALAR >::model().
Referenced by gum::MarginalTargetedMRFInference< GUM_SCALAR >::_setAllMarginalTargets_(), gum::MarginalTargetedMRFInference< GUM_SCALAR >::addAllTargets(), gum::JointTargetedMRFInference< GUM_SCALAR >::addJointTarget(), gum::MarginalTargetedMRFInference< GUM_SCALAR >::addTarget(), gum::MarginalTargetedMRFInference< GUM_SCALAR >::addTarget(), gum::JointTargetedMRFInference< GUM_SCALAR >::eraseJointTarget(), gum::MarginalTargetedMRFInference< GUM_SCALAR >::eraseTarget(), gum::MarginalTargetedMRFInference< GUM_SCALAR >::eraseTarget(), gum::MarginalTargetedMRFInference< GUM_SCALAR >::evidenceImpact(), gum::MarginalTargetedMRFInference< GUM_SCALAR >::evidenceImpact(), gum::JointTargetedMRFInference< GUM_SCALAR >::evidenceJointImpact(), gum::JointTargetedMRFInference< GUM_SCALAR >::evidenceJointImpact(), gum::MarginalTargetedMRFInference< GUM_SCALAR >::H(), gum::JointTargetedMRFInference< GUM_SCALAR >::isJointTarget(), gum::MarginalTargetedMRFInference< GUM_SCALAR >::isTarget(), gum::MarginalTargetedMRFInference< GUM_SCALAR >::isTarget(), gum::JointTargetedMRFInference< GUM_SCALAR >::jointMutualInformation(), gum::JointTargetedMRFInference< GUM_SCALAR >::jointMutualInformation(), gum::JointTargetedMRFInference< GUM_SCALAR >::posterior(), gum::MarginalTargetedMRFInference< GUM_SCALAR >::posterior(), and gum::JointTargetedMRFInference< GUM_SCALAR >::superForJointComputable_().
|
finalvirtualinherited |
returns the number of evidence entered into the Bayesian network
Definition at line 562 of file graphicalModelInference_tpl.h.
References _evidence_.
|
finalvirtualinherited |
returns the number of hard evidence entered into the Bayesian network
Definition at line 568 of file graphicalModelInference_tpl.h.
References _hard_evidence_nodes_.
|
finalvirtualinherited |
returns the number of soft evidence entered into the Bayesian network
Definition at line 574 of file graphicalModelInference_tpl.h.
References _soft_evidence_nodes_.
|
finalvirtualnoexcept |
returns the number of marginal targets
Definition at line 216 of file marginalTargetedMRFInference_tpl.h.
References _targets_.
|
protectedpure virtualinherited |
fired before all the evidence are erased
Implemented in gum::LazyPropagation< GUM_SCALAR >, gum::LoopyBeliefPropagation< GUM_SCALAR >, gum::SamplingInference< GUM_SCALAR >, gum::ShaferShenoyInference< GUM_SCALAR >, gum::ShaferShenoyLIMIDInference< GUM_SCALAR >, gum::ShaferShenoyMRFInference< GUM_SCALAR >, and gum::VariableElimination< GUM_SCALAR >.
References onAllEvidenceErased_().
Referenced by eraseAllEvidence(), and onAllEvidenceErased_().
|
protectedpure virtual |
fired after all the nodes of the MRF are added as marginal targets
Implemented in gum::ShaferShenoyMRFInference< GUM_SCALAR >.
Referenced by _setAllMarginalTargets_().
|
protectedpure virtual |
fired before a all marginal targets are removed
Implemented in gum::ShaferShenoyMRFInference< GUM_SCALAR >.
Referenced by eraseAllTargets().
|
protectedpure virtualinherited |
fired after a new evidence is inserted
Implemented in gum::LazyPropagation< GUM_SCALAR >, gum::LoopyBeliefPropagation< GUM_SCALAR >, gum::SamplingInference< GUM_SCALAR >, gum::ShaferShenoyInference< GUM_SCALAR >, gum::ShaferShenoyLIMIDInference< GUM_SCALAR >, gum::ShaferShenoyMRFInference< GUM_SCALAR >, and gum::VariableElimination< GUM_SCALAR >.
References onEvidenceAdded_().
Referenced by addEvidence(), and onEvidenceAdded_().
|
protectedpure virtualinherited |
fired after an evidence is changed, in particular when its status (soft/hard) changes
| nodeId | the node of the changed evidence |
| hasChangedSoftHard | true if the evidence has changed from Soft to Hard or from Hard to Soft |
Implemented in gum::LazyPropagation< GUM_SCALAR >, gum::LoopyBeliefPropagation< GUM_SCALAR >, gum::SamplingInference< GUM_SCALAR >, gum::ShaferShenoyInference< GUM_SCALAR >, gum::ShaferShenoyLIMIDInference< GUM_SCALAR >, gum::ShaferShenoyMRFInference< GUM_SCALAR >, and gum::VariableElimination< GUM_SCALAR >.
References onEvidenceChanged_().
Referenced by chgEvidence(), and onEvidenceChanged_().
|
protectedpure virtualinherited |
fired before an evidence is removed
Implemented in gum::LazyPropagation< GUM_SCALAR >, gum::LoopyBeliefPropagation< GUM_SCALAR >, gum::SamplingInference< GUM_SCALAR >, gum::ShaferShenoyInference< GUM_SCALAR >, gum::ShaferShenoyLIMIDInference< GUM_SCALAR >, gum::ShaferShenoyMRFInference< GUM_SCALAR >, and gum::VariableElimination< GUM_SCALAR >.
References onEvidenceErased_().
Referenced by eraseEvidence(), and onEvidenceErased_().
|
protectedpure virtual |
fired after a new marginal target is inserted
| id | The target variable's id. |
Implemented in gum::ShaferShenoyMRFInference< GUM_SCALAR >.
Referenced by addAllTargets(), and addTarget().
|
protectedpure virtual |
fired before a marginal target is removed
| id | The target variable's id. |
Implemented in gum::ShaferShenoyMRFInference< GUM_SCALAR >.
Referenced by eraseTarget().
|
protectedvirtual |
fired after a new Markov net has been assigned to the engine
Implements gum::GraphicalModelInference< GUM_SCALAR >.
Reimplemented in gum::JointTargetedMRFInference< GUM_SCALAR >, and gum::ShaferShenoyMRFInference< GUM_SCALAR >.
Definition at line 77 of file marginalTargetedMRFInference_tpl.h.
References _setAllMarginalTargets_(), and _targeted_mode_.
Referenced by gum::JointTargetedMRFInference< GUM_SCALAR >::onModelChanged_().
|
protectedpure virtualinherited |
fired when the stage is changed
Implemented in gum::LazyPropagation< GUM_SCALAR >, gum::LoopyBeliefPropagation< GUM_SCALAR >, gum::SamplingInference< GUM_SCALAR >, gum::ShaferShenoyInference< GUM_SCALAR >, gum::ShaferShenoyLIMIDInference< GUM_SCALAR >, gum::ShaferShenoyMRFInference< GUM_SCALAR >, and gum::VariableElimination< GUM_SCALAR >.
References onStateChanged_().
Referenced by onStateChanged_(), and setState_().
|
virtual |
Computes and returns the posterior of a node.
| nodeName | the anme of the node for which we need a posterior probability |
| UndefinedElement | if node is not in the set of targets |
Reimplemented in gum::JointTargetedMRFInference< GUM_SCALAR >.
Definition at line 252 of file marginalTargetedMRFInference_tpl.h.
References gum::MRFInference< GUM_SCALAR >::MRF(), and posterior().
|
virtual |
Computes and returns the posterior of a node.
| node | the node for which we need a posterior probability |
| UndefinedElement | if node is not in the set of targets |
Reimplemented in gum::JointTargetedMRFInference< GUM_SCALAR >.
Definition at line 236 of file marginalTargetedMRFInference_tpl.h.
References gum::GraphicalModelInference< GUM_SCALAR >::evidence(), GUM_ERROR, gum::GraphicalModelInference< GUM_SCALAR >::hardEvidenceNodes(), gum::GraphicalModelInference< GUM_SCALAR >::isInferenceDone(), isTarget(), gum::GraphicalModelInference< GUM_SCALAR >::makeInference(), and posterior_().
Referenced by evidenceImpact(), H(), gum::JointTargetedMRFInference< GUM_SCALAR >::posterior(), and posterior().
|
protectedpure virtual |
asks derived classes for the posterior of a given variable
| id | The variable's id. |
Implemented in gum::ShaferShenoyMRFInference< GUM_SCALAR >.
Referenced by posterior().
|
finalvirtualinherited |
prepare the internal inference structures for the next inference
Definition at line 622 of file graphicalModelInference_tpl.h.
References _model_, _state_, GUM_ERROR, isInferenceDone(), isInferenceReady(), OutdatedStructure, ReadyForInference, setState_(), updateOutdatedStructure_(), and updateOutdatedTensors_().
Referenced by makeInference(), and gum::SamplingInference< GUM_SCALAR >::samplingBN().
|
protectedinherited |
Definition at line 136 of file graphicalModelInference_tpl.h.
References _computeDomainSizes_(), _model_, clear(), model(), onModelChanged_(), OutdatedStructure, and setState_().
Referenced by gum::BayesNetInference< GUM_SCALAR >::setBN(), and gum::MRFInference< GUM_SCALAR >::setMRF().
|
protectedinherited |
assigns a model during the inference engine construction
Definition at line 146 of file graphicalModelInference_tpl.h.
References _computeDomainSizes_(), _model_, model(), OutdatedStructure, and setState_().
Referenced by gum::BayesNetInference< GUM_SCALAR >::_setBayesNetDuringConstruction_(), and gum::MRFInference< GUM_SCALAR >::_setMRFDuringConstruction_().
|
virtualinherited |
assigns a new MRF to the inference engine
Assigns a new MRF to the MRFInference engine and sends messages to the descendants of MRFInference to inform them that the MRF has changed.
Definition at line 81 of file MRFInference_tpl.h.
References gum::GraphicalModelInference< GUM_SCALAR >::setModel_().
|
protectedinherited |
put the inference into an outdated model structure state
OutdatedStructure: in this state, the inference is fully unprepared to be applied because some events changed the "logical" structure of the model: for instance a node received a hard evidence, which implies that its outgoing arcs can be removed from the model, hence involving a structural change in the model. As a consequence, the (incremental) inference (probably) needs a significant amount of preparation to be ready for the next inference. In a Lazy propagation, for instance, this step amounts to compute a new join tree, hence a new structure in which inference will be applied. Note that classes that inherit from graphicalModelInference may be smarter than graphicalModelInference and may, in some situations, find out that their data structures are still ok for inference and, therefore, only resort to perform the actions related to the OutdatedTensors state. As an example, consider a LazyPropagation inference in Bayes Net A->B->C->D->E in which C has received hard evidence e_C and E is the only target. In this case, A and B are not needed for inference, the only tensors that matter are P(D|e_C) and P(E|D). So the smallest join tree needed for inference contains only one clique DE. Now, adding new evidence e_A on A has no impact on E given hard evidence e_C. In this case, LazyPropagation can be smart and not update its join tree.
Definition at line 609 of file graphicalModelInference_tpl.h.
References OutdatedStructure, and setState_().
Referenced by makeInference_().
|
protectedinherited |
puts the inference into an OutdatedTensors state if it is not already in an OutdatedStructure state
OutdatedTensors: in this state, the structure of the model remains unchanged, only some tensors stored in it have changed. Therefore, the inference probably just needs to invalidate some already computed tensors to be ready. Only a light amount of preparation is needed to be able to perform inference.
Definition at line 616 of file graphicalModelInference_tpl.h.
References OutdatedTensors, and setState_().
Referenced by makeInference_().
|
finalprotectedvirtualinherited |
set the state of the inference engine and call the notification onStateChanged_ when necessary (i.e. when the state has effectively changed).
Definition at line 117 of file graphicalModelInference_tpl.h.
References _state_, onStateChanged_(), and state().
Referenced by gum::MarginalTargetedInference< GUM_SCALAR >::addAllTargets(), gum::MarginalTargetedMRFInference< GUM_SCALAR >::addAllTargets(), addEvidence(), gum::JointTargetedInference< GUM_SCALAR >::addJointTarget(), gum::JointTargetedMRFInference< GUM_SCALAR >::addJointTarget(), gum::MarginalTargetedInference< GUM_SCALAR >::addTarget(), gum::MarginalTargetedMRFInference< GUM_SCALAR >::addTarget(), chgEvidence(), clear(), eraseAllEvidence(), gum::JointTargetedInference< GUM_SCALAR >::eraseAllJointTargets(), gum::JointTargetedMRFInference< GUM_SCALAR >::eraseAllJointTargets(), gum::MarginalTargetedInference< GUM_SCALAR >::eraseAllTargets(), gum::MarginalTargetedMRFInference< GUM_SCALAR >::eraseAllTargets(), eraseEvidence(), gum::JointTargetedInference< GUM_SCALAR >::eraseJointTarget(), gum::JointTargetedMRFInference< GUM_SCALAR >::eraseJointTarget(), gum::MarginalTargetedInference< GUM_SCALAR >::eraseTarget(), gum::MarginalTargetedMRFInference< GUM_SCALAR >::eraseTarget(), makeInference(), prepareInference(), setModel_(), setModelDuringConstruction_(), setOutdatedStructureState_(), and setOutdatedTensorsState_().
|
protected |
Definition at line 325 of file marginalTargetedMRFInference_tpl.h.
References _targeted_mode_, and _targets_.
Referenced by addAllTargets(), gum::JointTargetedMRFInference< GUM_SCALAR >::addJointTarget(), addTarget(), and eraseAllTargets().
|
inherited |
returns the set of nodes with soft evidence
the set of nodes that received soft evidence
Definition at line 593 of file graphicalModelInference_tpl.h.
References _soft_evidence_nodes_.
Referenced by gum::SamplingInference< GUM_SCALAR >::contextualize().
|
finalvirtualnoexceptinherited |
returns the state of the inference engine
Definition at line 111 of file graphicalModelInference_tpl.h.
References _state_.
Referenced by setState_().
|
finalvirtualnoexcept |
returns the list of marginal targets
Definition at line 210 of file marginalTargetedMRFInference_tpl.h.
References _targets_.
Referenced by gum::JointTargetedMRFInference< GUM_SCALAR >::evidenceJointImpact(), gum::JointTargetedMRFInference< GUM_SCALAR >::evidenceJointImpact(), gum::JointTargetedMRFInference< GUM_SCALAR >::jointMutualInformation(), and gum::JointTargetedMRFInference< GUM_SCALAR >::jointMutualInformation().
|
protectedpure virtualinherited |
prepares inference when the latter is in OutdatedStructure state
Note that the values of evidence are not necessarily known and can be changed between updateOutdatedStructure_ and makeInference_.
Implemented in gum::LazyPropagation< GUM_SCALAR >, gum::LoopyBeliefPropagation< GUM_SCALAR >, gum::SamplingInference< GUM_SCALAR >, gum::ShaferShenoyInference< GUM_SCALAR >, gum::ShaferShenoyLIMIDInference< GUM_SCALAR >, gum::ShaferShenoyMRFInference< GUM_SCALAR >, and gum::VariableElimination< GUM_SCALAR >.
References updateOutdatedStructure_().
Referenced by prepareInference(), and updateOutdatedStructure_().
|
protectedpure virtualinherited |
prepares inference when the latter is in OutdatedTensors state
Note that the values of evidence are not necessarily known and can be changed between updateOutdatedTensors_ and makeInference_.
Implemented in gum::LazyPropagation< GUM_SCALAR >, gum::LoopyBeliefPropagation< GUM_SCALAR >, gum::SamplingInference< GUM_SCALAR >, gum::ShaferShenoyInference< GUM_SCALAR >, gum::ShaferShenoyLIMIDInference< GUM_SCALAR >, gum::ShaferShenoyMRFInference< GUM_SCALAR >, and gum::VariableElimination< GUM_SCALAR >.
References updateOutdatedTensors_().
Referenced by prepareInference(), and updateOutdatedTensors_().
|
privateinherited |
the domain sizes of the random variables
Definition at line 507 of file graphicalModelInference.h.
Referenced by _computeDomainSizes_(), and domainSizes().
|
privateinherited |
the set of evidence entered into the network
Definition at line 510 of file graphicalModelInference.h.
Referenced by ~GraphicalModelInference(), addEvidence(), chgEvidence(), eraseAllEvidence(), eraseEvidence(), evidence(), hasEvidence(), hasEvidence(), and nbrEvidence().
|
privateinherited |
assign to each node with a hard evidence the index of its observed value
Definition at line 513 of file graphicalModelInference.h.
Referenced by addEvidence(), chgEvidence(), eraseAllEvidence(), eraseEvidence(), and hardEvidence().
|
privateinherited |
the set of nodes that received hard evidence
Definition at line 519 of file graphicalModelInference.h.
Referenced by addEvidence(), chgEvidence(), eraseAllEvidence(), eraseEvidence(), hardEvidenceNodes(), hasHardEvidence(), and nbrHardEvidence().
|
privateinherited |
the Bayes net on which we perform inferences
Definition at line 504 of file graphicalModelInference.h.
Referenced by GraphicalModelInference(), _computeDomainSizes_(), _createHardEvidence_(), addEvidence(), addEvidence(), chgEvidence(), chgEvidence(), hasNoModel_(), model(), prepareInference(), setModel_(), and setModelDuringConstruction_().
|
privateinherited |
the set of nodes that received soft evidence
Definition at line 516 of file graphicalModelInference.h.
Referenced by addEvidence(), chgEvidence(), eraseAllEvidence(), eraseEvidence(), hasSoftEvidence(), nbrSoftEvidence(), and softEvidenceNodes().
|
privateinherited |
the current state of the inference (outdated/ready/done)
Definition at line 501 of file graphicalModelInference.h.
Referenced by isInferenceDone(), isInferenceOutdatedStructure(), isInferenceOutdatedTensors(), isInferenceReady(), prepareInference(), setState_(), and state().
|
private |
whether the actual targets are default
Definition at line 259 of file marginalTargetedMRFInference.h.
Referenced by MarginalTargetedMRFInference(), eraseTarget(), isTargetedMode_(), onModelChanged_(), and setTargetedMode_().
|
private |
the set of marginal targets
Definition at line 262 of file marginalTargetedMRFInference.h.
Referenced by MarginalTargetedMRFInference(), _setAllMarginalTargets_(), addAllTargets(), addTarget(), eraseAllTargets(), eraseTarget(), isTarget(), nbrTargets(), setTargetedMode_(), and targets().
|
privateinherited |
assigns a new MRF to the inference engine
Assigns a new MRF to the MRFInference engine and sends messages to the descendants of MRFInference to inform them that the MRF has changed.
Definition at line 223 of file MRFInference.h.
|
privateinherited |
assigns a new MRF to the inference engine
Assigns a new MRF to the MRFInference engine and sends messages to the descendants of MRFInference to inform them that the MRF has changed.
Definition at line 222 of file MRFInference.h.
|
privateinherited |
allow JointInference to access the single targets and inference states
Definition at line 221 of file MRFInference.h.