aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
gum::MarginalTargetedMRFInference< GUM_SCALAR > Class Template Referenceabstract

<agrum/MRF/inference/marginalTargetedMRFInference.h> More...

#include <marginalTargetedMRFInference.h>

Inheritance diagram for gum::MarginalTargetedMRFInference< GUM_SCALAR >:
Collaboration diagram for gum::MarginalTargetedMRFInference< GUM_SCALAR >:

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 NodeSettargets () 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 GraphicalModelmodel () 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 NodeSetsoftEvidenceNodes () const
 returns the set of nodes with soft evidence
const NodeSethardEvidenceNodes () 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

Detailed Description

template<typename GUM_SCALAR>
class gum::MarginalTargetedMRFInference< GUM_SCALAR >

<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.

Member Enumeration Documentation

◆ StateOfInference

template<typename GUM_SCALAR>
enum class gum::GraphicalModelInference::StateOfInference
stronginherited

current state of the inference

graphicalModelInference can be in one of 4 different states:

  • 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.
  • 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.
  • Ready4Inference: in this state, all the data structures are ready for inference. There just remains to perform the inference computations.
  • Done: the heavy computations of inference have been done. There might still remain a few light computations to perform to get the posterior tensors we need.
Enumerator
OutdatedStructure 
OutdatedTensors 
ReadyForInference 
Done 

Definition at line 127 of file graphicalModelInference.h.

127{ OutdatedStructure, OutdatedTensors, ReadyForInference, Done };

Constructor & Destructor Documentation

◆ MarginalTargetedMRFInference()

template<typename GUM_SCALAR>
gum::MarginalTargetedMRFInference< GUM_SCALAR >::MarginalTargetedMRFInference ( const IMarkovRandomField< GUM_SCALAR > * mn)
explicit

default constructor

Warning
By default, all the nodes of the Markov net are targets.
note that, by aGrUM's rule, the MRF is not copied but only referenced by the inference algorithm.

Definition at line 55 of file marginalTargetedMRFInference_tpl.h.

57 // assign a MRF if this has not been done before (due to virtual inheritance)
59
60 // sets all the nodes as targets
61 if (mn != nullptr) {
62 _targeted_mode_ = false;
63 _targets_ = mn->graph().asNodeSet();
64 }
65
67 }
MRFInference(const IMarkovRandomField< GUM_SCALAR > *mn)
default constructor
void _setMRFDuringConstruction_(const IMarkovRandomField< GUM_SCALAR > *mn)
assigns a MRF during the inference engine construction
<agrum/MRF/inference/marginalTargetedMRFInference.h>
bool _targeted_mode_
whether the actual targets are default
NodeSet _targets_
the set of marginal targets
MarginalTargetedMRFInference(const IMarkovRandomField< GUM_SCALAR > *mn)
default constructor

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~MarginalTargetedMRFInference()

template<typename GUM_SCALAR>
gum::MarginalTargetedMRFInference< GUM_SCALAR >::~MarginalTargetedMRFInference ( )
virtual

destructor

Definition at line 71 of file marginalTargetedMRFInference_tpl.h.

References MarginalTargetedMRFInference().

Here is the call graph for this function:

Member Function Documentation

◆ _computeDomainSizes_()

template<typename GUM_SCALAR>
void gum::GraphicalModelInference< GUM_SCALAR >::_computeDomainSizes_ ( )
privateinherited

computes the domain sizes of the random variables

Definition at line 162 of file graphicalModelInference_tpl.h.

162 {
163 _domain_sizes_.clear();
164 if (!hasNoModel_()) {
165 for (auto node: _model_->nodes()) {
166 _domain_sizes_.insert(node, _model_->variable(node).domainSize());
167 }
168 }
169 }
<agrum/base/graphicalModels/graphicalModel.h>
NodeProperty< Size > _domain_sizes_
the domain sizes of the random variables
const GraphicalModel * _model_
the Bayes net on which we perform inferences

References _domain_sizes_, _model_, and hasNoModel_().

Referenced by GraphicalModelInference(), setModel_(), and setModelDuringConstruction_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _createHardEvidence_()

template<typename GUM_SCALAR>
Tensor< GUM_SCALAR > gum::GraphicalModelInference< GUM_SCALAR >::_createHardEvidence_ ( NodeId id,
Idx val ) const
privateinherited

create the internal structure for a hard evidence

Definition at line 184 of file graphicalModelInference_tpl.h.

184 {
185 // check that it is possible to create the evidence
186 if (_model_ == nullptr)
188 "No Bayes net has been assigned to the "
189 "inference algorithm");
190
191 if (!_model_->exists(id)) { GUM_ERROR(UndefinedElement, id << " is not a NodeId in the model") }
192
193 if (_model_->variable(id).domainSize() <= val) {
195 "node " << _model_->variable(id) << " has fewer possible values than " << val);
196 }
197
199 }
static Tensor< GUM_SCALAR > deterministicTensor(const DiscreteVariable &var, Idx value)
#define GUM_ERROR(type, msg)
Definition exceptions.h:72

References _model_, gum::Tensor< GUM_SCALAR >::deterministicTensor(), and GUM_ERROR.

Referenced by addEvidence(), and chgEvidence().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _isHardEvidence_()

template<typename GUM_SCALAR>
bool gum::GraphicalModelInference< GUM_SCALAR >::_isHardEvidence_ ( const Tensor< GUM_SCALAR > & pot,
Idx & val ) const
privateinherited

checks whether a tensor corresponds to a hard evidence or not

Definition at line 203 of file graphicalModelInference_tpl.h.

204 {
205 // checking if pot is determininstic
206 bool notZero = false;
208
209 for (I.setFirst(); !I.end(); I.inc()) {
210 if (pot[I] != 0.0) {
211 if (notZero) { // we already met a non-zero value
212 return false;
213 } else {
214 val = I.val(0);
215 notZero = true; // this is the first met non-zero value
216 }
217 }
218 }
219
220 if (!notZero) { // we met no non-zero value
221 GUM_ERROR(FatalError, "Evidence of impossibility (vector of 0s)")
222 }
223
224 return true; // pot is deterministic
225 }

References gum::Instantiation::end(), GUM_ERROR, gum::Instantiation::inc(), gum::Instantiation::setFirst(), and gum::Instantiation::val().

Referenced by addEvidence(), and chgEvidence().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _setAllMarginalTargets_()

template<typename GUM_SCALAR>
void gum::MarginalTargetedMRFInference< GUM_SCALAR >::_setAllMarginalTargets_ ( )
private

sets all the nodes of the Markov net as targets

Definition at line 222 of file marginalTargetedMRFInference_tpl.h.

222 {
223 _targets_.clear();
224 if (!this->hasNoModel_()) {
225 _targets_ = this->MRF().graph().asNodeSet();
227 }
228 }
virtual const IMarkovRandomField< GUM_SCALAR > & MRF() const final
Returns a constant reference over the IMarkovRandomField referenced by this class.
virtual void onAllMarginalTargetsAdded_()=0
fired after all the nodes of the MRF are added as marginal targets

References _targets_, gum::GraphicalModelInference< GUM_SCALAR >::hasNoModel_(), gum::MRFInference< GUM_SCALAR >::MRF(), and onAllMarginalTargetsAdded_().

Referenced by onModelChanged_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _setMRFDuringConstruction_()

template<typename GUM_SCALAR>
void gum::MRFInference< GUM_SCALAR >::_setMRFDuringConstruction_ ( const IMarkovRandomField< GUM_SCALAR > * mn)
privateinherited

assigns a MRF during the inference engine construction

Definition at line 87 of file MRFInference_tpl.h.

88 {
90 }
void setModelDuringConstruction_(const GraphicalModel *model)
assigns a model during the inference engine construction
<agrum/MRF/inference/MRFInference.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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addAllTargets()

template<typename GUM_SCALAR>
void gum::MarginalTargetedMRFInference< GUM_SCALAR >::addAllTargets ( )
finalvirtual

adds all nodes as targets

Definition at line 143 of file marginalTargetedMRFInference_tpl.h.

143 {
144 // check if the node belongs to the Markov random field
145 if (this->hasNoModel_())
147 "No Markov net has been assigned to the "
148 "inference algorithm");
149
150
151 setTargetedMode_(); // does nothing if already in targeted mode
152 for (const auto target: this->MRF().graph()) {
153 if (!_targets_.contains(target)) {
154 _targets_.insert(target);
157 }
158 }
159 }
virtual void setState_(const StateOfInference state) final
set the state of the inference engine and call the notification onStateChanged_ when necessary (i....
virtual void onMarginalTargetAdded_(const NodeId id)=0
fired after a new marginal target is inserted

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_().

Here is the call graph for this function:

◆ addEvidence() [1/8]

template<typename GUM_SCALAR>
INLINE void gum::GraphicalModelInference< GUM_SCALAR >::addEvidence ( const std::string & nodeName,
const Idx val )
finalvirtualinherited

adds a new hard evidence on node named nodeName

Exceptions
UndefinedElementif nodeName does not belong to the Bayesian network
InvalidArgumentif val is not a value for id
InvalidArgumentif nodeName already has an evidence

Definition at line 235 of file graphicalModelInference_tpl.h.

236 {
238 }
virtual void addEvidence(NodeId id, const Idx val) final
adds a new hard evidence on node id
virtual const GraphicalModel & model() const final
Returns a constant reference over the IBayesNet referenced by this class.

References addEvidence(), and model().

Here is the call graph for this function:

◆ addEvidence() [2/8]

template<typename GUM_SCALAR>
INLINE void gum::GraphicalModelInference< GUM_SCALAR >::addEvidence ( const std::string & nodeName,
const std::string & label )
finalvirtualinherited

adds a new hard evidence on node named nodeName

Exceptions
UndefinedElementif nodeName does not belong to the Bayesian network
InvalidArgumentif val is not a value for id
InvalidArgumentif nodeName already has an evidence

Definition at line 249 of file graphicalModelInference_tpl.h.

250 {
251 const NodeId id = this->model().idFromName(nodeName);
252 addEvidence(id, this->model().variable(id)[label]);
253 }
virtual NodeId idFromName(const std::string &name) const =0
Getter by name.

References addEvidence(), and model().

Here is the call graph for this function:

◆ addEvidence() [3/8]

template<typename GUM_SCALAR>
void gum::GraphicalModelInference< GUM_SCALAR >::addEvidence ( const std::string & nodeName,
const std::vector< GUM_SCALAR > & vals )
finalvirtualinherited

adds a new evidence on node named nodeName (might be soft or hard)

Exceptions
UndefinedElementif id does not belong to the Bayesian network
InvalidArgumentif nodeName already has an evidence
FatalErrorif vals=[0,0,...,0]
InvalidArgumentif the size of vals is different from the domain size of node nodeName

Definition at line 281 of file graphicalModelInference_tpl.h.

282 {
284 }

References addEvidence(), and model().

Here is the call graph for this function:

◆ addEvidence() [4/8]

template<typename GUM_SCALAR>
INLINE void gum::GraphicalModelInference< GUM_SCALAR >::addEvidence ( const Tensor< GUM_SCALAR > & pot)
finalvirtualinherited

adds a new evidence on node id (might be soft or hard)

Exceptions
UndefinedElementif the tensor is defined over several nodes
UndefinedElementif the node on which the tensor is defined does not belong to the Bayesian network
InvalidArgumentif the node of the tensor already has an evidence
FatalErrorif pot=[0,0,...,0]

Definition at line 323 of file graphicalModelInference_tpl.h.

References addEvidence().

Here is the call graph for this function:

◆ addEvidence() [5/8]

template<typename GUM_SCALAR>
INLINE void gum::GraphicalModelInference< GUM_SCALAR >::addEvidence ( NodeId id,
const Idx val )
finalvirtualinherited

adds a new hard evidence on node id

Exceptions
UndefinedElementif id does not belong to the Bayesian network
InvalidArgumentif val is not a value for id
InvalidArgumentif id already has an evidence

Definition at line 229 of file graphicalModelInference_tpl.h.

229 {
231 }
Tensor< GUM_SCALAR > _createHardEvidence_(NodeId id, Idx val) const
create the internal structure for a hard evidence

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_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addEvidence() [6/8]

template<typename GUM_SCALAR>
INLINE void gum::GraphicalModelInference< GUM_SCALAR >::addEvidence ( NodeId id,
const std::string & label )
finalvirtualinherited

adds a new hard evidence on node id

Exceptions
UndefinedElementif id does not belong to the Bayesian network
InvalidArgumentif val is not a value for id
InvalidArgumentif id already has an evidence

Definition at line 242 of file graphicalModelInference_tpl.h.

243 {
244 addEvidence(id, this->model().variable(id)[label]);
245 }

References addEvidence(), and model().

Here is the call graph for this function:

◆ addEvidence() [7/8]

template<typename GUM_SCALAR>
void gum::GraphicalModelInference< GUM_SCALAR >::addEvidence ( NodeId id,
const std::vector< GUM_SCALAR > & vals )
finalvirtualinherited

adds a new evidence on node id (might be soft or hard)

Exceptions
UndefinedElementif id does not belong to the Bayesian network
InvalidArgumentif id already has an evidence
FatalErrorif vals=[0,0,...,0]
InvalidArgumentif the size of vals is different from the domain size of node id

Definition at line 257 of file graphicalModelInference_tpl.h.

258 {
259 // checks that the evidence is meaningful
260 if (_model_ == nullptr)
262 "No Bayes net has been assigned to the "
263 "inference algorithm");
264
265 if (!_model_->exists(id)) { GUM_ERROR(UndefinedElement, id << " is not a NodeId in the model") }
266
267 if (_model_->variable(id).domainSize() != vals.size()) {
269 "node " << _model_->variable(id)
270 << " and its evidence vector have different sizes.");
271 }
272
274 pot.add(_model_->variable(id));
275 pot.fillWith(vals);
277 }

References _model_, addEvidence(), and GUM_ERROR.

Here is the call graph for this function:

◆ addEvidence() [8/8]

template<typename GUM_SCALAR>
void gum::GraphicalModelInference< GUM_SCALAR >::addEvidence ( Tensor< GUM_SCALAR > && pot)
finalvirtualinherited

adds a new evidence on node id (might be soft or hard)

Exceptions
UndefinedElementif the tensor is defined over several nodes
UndefinedElementif the node on which the tensor is defined does not belong to the Bayesian network
InvalidArgumentif the node of the tensor already has an evidence
FatalErrorif pot=[0,0,...,0]

Definition at line 288 of file graphicalModelInference_tpl.h.

288 {
289 // check if the tensor corresponds to an evidence
290 if (pot.nbrDim() != 1) { GUM_ERROR(InvalidArgument, pot << " is not mono-dimensional.") }
291 if (_model_ == nullptr)
293 "No Bayes net has been assigned to the "
294 "inference algorithm");
295
296 NodeId id = _model_->nodeId(pot.variable(0));
297
298 if (hasEvidence(id)) {
300 " node " << id << " already has an evidence. Please use chgEvidence().");
301 }
302
303 // check whether we have a hard evidence (and also check whether the
304 // tensor only contains 0 (in this case, this will automatically raise
305 // an exception) )
306 Idx val = 0;
308
309 // insert the evidence
311 if (is_hard_evidence) { // pot is deterministic
312 _hard_evidence_.insert(id, val);
313 _hard_evidence_nodes_.insert(id);
314 } else {
315 _soft_evidence_nodes_.insert(id);
316 }
319 }
NodeProperty< const Tensor< GUM_SCALAR > * > _evidence_
the set of evidence entered into the network
bool _isHardEvidence_(const Tensor< GUM_SCALAR > &pot, Idx &val) const
checks whether a tensor corresponds to a hard evidence or not
NodeSet _soft_evidence_nodes_
the set of nodes that received soft evidence
virtual bool hasEvidence() const final
indicates whether some node(s) have received evidence
virtual void onEvidenceAdded_(const NodeId id, bool isHardEvidence)=0
fired after a new evidence is inserted
NodeSet _hard_evidence_nodes_
the set of nodes that received hard evidence
NodeProperty< Idx > _hard_evidence_
assign to each node with a hard evidence the index of its observed value

References _evidence_, _hard_evidence_, _hard_evidence_nodes_, _isHardEvidence_(), _model_, _soft_evidence_nodes_, GUM_ERROR, hasEvidence(), onEvidenceAdded_(), OutdatedStructure, and setState_().

Here is the call graph for this function:

◆ addListOfEvidence()

template<typename GUM_SCALAR>
INLINE void gum::GraphicalModelInference< GUM_SCALAR >::addListOfEvidence ( const List< const Tensor< GUM_SCALAR > * > & potlist)
finalvirtualinherited

adds a new list of evidence

Exceptions
UndefinedElementif some tensor is defined over several nodes
UndefinedElementif the node on which some tensor is defined does not belong to the Bayesian network
InvalidArgumentif the node of some tensor already has an evidence
FatalErrorif pot=[0,0,...,0]

Definition at line 330 of file graphicalModelInference_tpl.h.

331 {
332 for (const auto pot: potlist)
334 }

References addEvidence().

Here is the call graph for this function:

◆ addSetOfEvidence()

template<typename GUM_SCALAR>
INLINE void gum::GraphicalModelInference< GUM_SCALAR >::addSetOfEvidence ( const Set< const Tensor< GUM_SCALAR > * > & potset)
finalvirtualinherited

adds a new set of evidence

Exceptions
UndefinedElementif some tensor is defined over several nodes
UndefinedElementif the node on which some tensor is defined does not belong to the Bayesian network
InvalidArgumentif the node of some tensor already has an evidence
FatalErrorif pot=[0,0,...,0]

Definition at line 338 of file graphicalModelInference_tpl.h.

339 {
340 for (const auto pot: potset)
342 }

References addEvidence().

Here is the call graph for this function:

◆ addTarget() [1/2]

template<typename GUM_SCALAR>
void gum::MarginalTargetedMRFInference< GUM_SCALAR >::addTarget ( const std::string & nodeName)
finalvirtual

Add a marginal target to the list of targets.

Exceptions
UndefinedElementif target is not a NodeId in the Markov net

Definition at line 163 of file marginalTargetedMRFInference_tpl.h.

163 {
164 // check if the node belongs to the Markov random field
165 if (this->hasNoModel_())
167 "No Markov net has been assigned to the "
168 "inference algorithm");
169
171 }
virtual void addTarget(NodeId target) final
Add a marginal target to the list of targets.

References addTarget(), GUM_ERROR, gum::GraphicalModelInference< GUM_SCALAR >::hasNoModel_(), and gum::MRFInference< GUM_SCALAR >::MRF().

Here is the call graph for this function:

◆ addTarget() [2/2]

template<typename GUM_SCALAR>
void gum::MarginalTargetedMRFInference< GUM_SCALAR >::addTarget ( NodeId target)
finalvirtual

Add a marginal target to the list of targets.

Exceptions
UndefinedElementif target is not a NodeId in the Markov net

Definition at line 121 of file marginalTargetedMRFInference_tpl.h.

121 {
122 // check if the node belongs to the Markov random field
123 if (this->hasNoModel_())
125 "No Markov net has been assigned to the "
126 "inference algorithm");
127
128 if (!this->MRF().graph().exists(target)) {
129 GUM_ERROR(UndefinedElement, target << " is not a NodeId in the Markov random field")
130 }
131
132 setTargetedMode_(); // does nothing if already in targeted mode
133 // add the new target
134 if (!_targets_.contains(target)) {
135 _targets_.insert(target);
138 }
139 }

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chgEvidence() [1/7]

template<typename GUM_SCALAR>
INLINE void gum::GraphicalModelInference< GUM_SCALAR >::chgEvidence ( const std::string & nodeName,
const Idx val )
finalvirtualinherited

change the value of an already existing hard evidence

Exceptions
UndefinedElementif nodeName does not belong to the Bayesian network
InvalidArgumentif val is not a value for id
InvalidArgumentif id does not already have an evidence

Definition at line 397 of file graphicalModelInference_tpl.h.

398 {
400 }
virtual void chgEvidence(NodeId id, const Idx val) final
change the value of an already existing hard evidence

References chgEvidence(), and model().

Here is the call graph for this function:

◆ chgEvidence() [2/7]

template<typename GUM_SCALAR>
INLINE void gum::GraphicalModelInference< GUM_SCALAR >::chgEvidence ( const std::string & nodeName,
const std::string & label )
finalvirtualinherited

change the value of an already existing hard evidence

Exceptions
UndefinedElementif nodeName does not belong to the Bayesian network
InvalidArgumentif val is not a value for id
InvalidArgumentif id does not already have an evidence

Definition at line 411 of file graphicalModelInference_tpl.h.

412 {
413 NodeId id = this->model().idFromName(nodeName);
414 chgEvidence(id, this->model().variable(id)[label]);
415 }

References chgEvidence(), and model().

Here is the call graph for this function:

◆ chgEvidence() [3/7]

template<typename GUM_SCALAR>
INLINE void gum::GraphicalModelInference< GUM_SCALAR >::chgEvidence ( const std::string & nodeName,
const std::vector< GUM_SCALAR > & vals )
finalvirtualinherited

change the value of an already existing evidence (might be soft or hard)

Exceptions
UndefinedElementif nodeName does not belong to the Bayesian network
InvalidArgumentif the node does not already have an evidence
FatalErrorif vals=[0,0,...,0]
InvalidArgumentif the size of vals is different from the domain size of node id

Definition at line 445 of file graphicalModelInference_tpl.h.

446 {
448 }

References chgEvidence(), and model().

Here is the call graph for this function:

◆ chgEvidence() [4/7]

template<typename GUM_SCALAR>
void gum::GraphicalModelInference< GUM_SCALAR >::chgEvidence ( const Tensor< GUM_SCALAR > & pot)
finalvirtualinherited

change the value of an already existing evidence (might be soft or hard)

Exceptions
UndefinedElementif the tensor is defined over several nodes
UndefinedElementif the node on which the tensor is defined does not belong to the Bayesian network
InvalidArgumentif the node of the tensor does not already have an evidence
FatalErrorif pot=[0,0,...,0]

Definition at line 452 of file graphicalModelInference_tpl.h.

452 {
453 // check if the tensor corresponds to an evidence
454 if (pot.nbrDim() != 1) {
455 GUM_ERROR(InvalidArgument, pot << " is not a mono-dimensional tensor.")
456 }
457 if (_model_ == nullptr)
459 "No Bayes net has been assigned to the "
460 "inference algorithm");
461
462 NodeId id = _model_->nodeId(pot.variable(0));
463
464 if (!hasEvidence(id)) {
465 GUM_ERROR(InvalidArgument, id << " has no evidence. Please use addEvidence().")
466 }
467
468 // check whether we have a hard evidence (and also check whether the
469 // tensor only contains 0 (in this case, this will automatically raise
470 // an exception) )
471 Idx val;
473
474 // modify the evidence already stored
477 for (I.setFirst(); !I.end(); I.inc()) {
478 localPot->set(I, pot[I]);
479 }
480
481 // the inference state will be different
482 // whether evidence change from Hard to Soft or not.
483 bool hasChangedSoftHard = false;
484
485 if (is_hard_evidence) {
486 if (!hasHardEvidence(id)) {
487 hasChangedSoftHard = true;
488 _hard_evidence_.insert(id, val);
489 _hard_evidence_nodes_.insert(id);
490 _soft_evidence_nodes_.erase(id);
491 } else {
493 }
494 } else {
495 if (hasHardEvidence(id)) { // evidence was hard
496 _hard_evidence_.erase(id);
497 _hard_evidence_nodes_.erase(id);
498 _soft_evidence_nodes_.insert(id);
499 hasChangedSoftHard = true;
500 }
501 }
502
503 if (hasChangedSoftHard) {
505 } else {
507 }
508
510 }
virtual bool hasHardEvidence(NodeId id) const final
indicates whether node id has received a hard evidence
virtual bool isInferenceOutdatedStructure() const noexcept final
returns whether the inference object is in a OutdatedStructure state
virtual void onEvidenceChanged_(const NodeId id, bool hasChangedSoftHard)=0
fired after an evidence is changed, in particular when its status (soft/hard) changes

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_().

Here is the call graph for this function:

◆ chgEvidence() [5/7]

template<typename GUM_SCALAR>
INLINE void gum::GraphicalModelInference< GUM_SCALAR >::chgEvidence ( NodeId id,
const Idx val )
finalvirtualinherited

change the value of an already existing hard evidence

Exceptions
UndefinedElementif id does not belong to the Bayesian network
InvalidArgumentif val is not a value for id
InvalidArgumentif id does not already have an evidence

Definition at line 391 of file graphicalModelInference_tpl.h.

391 {
393 }

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chgEvidence() [6/7]

template<typename GUM_SCALAR>
INLINE void gum::GraphicalModelInference< GUM_SCALAR >::chgEvidence ( NodeId id,
const std::string & label )
finalvirtualinherited

change the value of an already existing hard evidence

Exceptions
UndefinedElementif id does not belong to the Bayesian network
InvalidArgumentif val is not a value for id
InvalidArgumentif id does not already have an evidence

Definition at line 404 of file graphicalModelInference_tpl.h.

405 {
406 chgEvidence(id, this->model().variable(id)[label]);
407 }

References chgEvidence(), and model().

Here is the call graph for this function:

◆ chgEvidence() [7/7]

template<typename GUM_SCALAR>
INLINE void gum::GraphicalModelInference< GUM_SCALAR >::chgEvidence ( NodeId id,
const std::vector< GUM_SCALAR > & vals )
finalvirtualinherited

change the value of an already existing evidence (might be soft or hard)

Exceptions
UndefinedElementif id does not belong to the Bayesian network
InvalidArgumentif the node does not already have an evidence
FatalErrorif vals=[0,0,...,0]
InvalidArgumentif the size of vals is different from the domain size of node id

Definition at line 420 of file graphicalModelInference_tpl.h.

421 {
422 // check whether this corresponds to an evidence
423 if (_model_ == nullptr)
425 "No Bayes net has been assigned to the "
426 "inference algorithm");
427
428 if (!_model_->exists(id)) { GUM_ERROR(UndefinedElement, id << " is not a NodeId in the model") }
429
430 if (_model_->variable(id).domainSize() != vals.size()) {
432 "node " << _model_->variable(id) << " and its evidence have different sizes.");
433 }
434
435 // create the tensor corresponding to vals
437 pot.add(_model_->variable(id));
438 pot.fillWith(vals);
440 }

References _model_, chgEvidence(), and GUM_ERROR.

Here is the call graph for this function:

◆ clear()

template<typename GUM_SCALAR>
INLINE void gum::GraphicalModelInference< GUM_SCALAR >::clear ( )
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.

155 {
158 }
virtual void eraseAllEvidence() final
removes all the evidence entered into the network

References eraseAllEvidence(), OutdatedStructure, and setState_().

Referenced by setModel_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ domainSizes()

template<typename GUM_SCALAR>
INLINE const NodeProperty< Size > & gum::GraphicalModelInference< GUM_SCALAR >::domainSizes ( ) const
finalvirtualinherited

get the domain sizes of the random variables of the model

Definition at line 173 of file graphicalModelInference_tpl.h.

173 {
174 return _domain_sizes_;
175 }

References _domain_sizes_.

◆ eraseAllEvidence()

template<typename GUM_SCALAR>
INLINE void gum::GraphicalModelInference< GUM_SCALAR >::eraseAllEvidence ( )
finalvirtualinherited

removes all the evidence entered into the network

Definition at line 540 of file graphicalModelInference_tpl.h.

540 {
541 bool has_hard_evidence = !_hard_evidence_.empty();
543
544 for (const auto& pair: _evidence_) {
545 if (pair.second != nullptr) { delete (pair.second); }
546 }
547
548 _evidence_.clear();
549 _hard_evidence_.clear();
550 _hard_evidence_nodes_.clear();
551 _soft_evidence_nodes_.clear();
552
553 if (has_hard_evidence) {
555 } else {
557 }
558 }
virtual void onAllEvidenceErased_(bool contains_hard_evidence)=0
fired before all the evidence are erased

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eraseAllTargets()

template<typename GUM_SCALAR>
INLINE void gum::MarginalTargetedMRFInference< GUM_SCALAR >::eraseAllTargets ( )
virtual

Clear all previously defined targets.

Reimplemented in gum::JointTargetedMRFInference< GUM_SCALAR >.

Definition at line 110 of file marginalTargetedMRFInference_tpl.h.

110 {
112
113 _targets_.clear();
114 setTargetedMode_(); // does nothing if already in targeted mode
115
117 }
virtual void onAllMarginalTargetsErased_()=0
fired before a all marginal targets are removed

References _targets_, onAllMarginalTargetsErased_(), gum::GraphicalModelInference< GUM_SCALAR >::OutdatedStructure, gum::GraphicalModelInference< GUM_SCALAR >::setState_(), and setTargetedMode_().

Referenced by gum::JointTargetedMRFInference< GUM_SCALAR >::eraseAllMarginalTargets(), and evidenceImpact().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eraseEvidence() [1/2]

template<typename GUM_SCALAR>
INLINE void gum::GraphicalModelInference< GUM_SCALAR >::eraseEvidence ( const std::string & nodeName)
finalvirtualinherited

removed the evidence, if any, corresponding to node of name nodeName

Definition at line 534 of file graphicalModelInference_tpl.h.

534 {
536 }
virtual void eraseEvidence(NodeId id) final
removed the evidence, if any, corresponding to node id

References eraseEvidence(), and model().

Here is the call graph for this function:

◆ eraseEvidence() [2/2]

template<typename GUM_SCALAR>
INLINE void gum::GraphicalModelInference< GUM_SCALAR >::eraseEvidence ( NodeId id)
finalvirtualinherited

removed the evidence, if any, corresponding to node id

Definition at line 514 of file graphicalModelInference_tpl.h.

514 {
515 if (hasEvidence(id)) {
516 if (hasHardEvidence(id)) {
517 onEvidenceErased_(id, true);
518 _hard_evidence_.erase(id);
519 _hard_evidence_nodes_.erase(id);
521 } else {
522 onEvidenceErased_(id, false);
523 _soft_evidence_nodes_.erase(id);
525 }
526
527 delete (_evidence_[id]);
528 _evidence_.erase(id);
529 }
530 }
virtual void onEvidenceErased_(const NodeId id, bool isHardEvidence)=0
fired before an evidence is removed

References _evidence_, _hard_evidence_, _hard_evidence_nodes_, _soft_evidence_nodes_, hasEvidence(), hasHardEvidence(), isInferenceOutdatedStructure(), onEvidenceErased_(), OutdatedStructure, OutdatedTensors, and setState_().

Referenced by eraseEvidence().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eraseTarget() [1/2]

template<typename GUM_SCALAR>
void gum::MarginalTargetedMRFInference< GUM_SCALAR >::eraseTarget ( const std::string & nodeName)
finalvirtual

removes an existing (marginal) target

Warning
If the target does not already exist, the method does nothing. In particular, it does not raise any exception.

Definition at line 198 of file marginalTargetedMRFInference_tpl.h.

198 {
199 // check if the node belongs to the Markov random field
200 if (this->hasNoModel_())
202 "No Markov net has been assigned to the "
203 "inference algorithm");
204
206 }
virtual void eraseTarget(NodeId target) final
removes an existing (marginal) target

References eraseTarget(), GUM_ERROR, gum::GraphicalModelInference< GUM_SCALAR >::hasNoModel_(), and gum::MRFInference< GUM_SCALAR >::MRF().

Here is the call graph for this function:

◆ eraseTarget() [2/2]

template<typename GUM_SCALAR>
void gum::MarginalTargetedMRFInference< GUM_SCALAR >::eraseTarget ( NodeId target)
finalvirtual

removes an existing (marginal) target

Warning
If the target does not already exist, the method does nothing. In particular, it does not raise any exception.

Definition at line 175 of file marginalTargetedMRFInference_tpl.h.

175 {
176 // check if the node belongs to the Markov random field
177 if (this->hasNoModel_())
179 "No Markov net has been assigned to the "
180 "inference algorithm");
181
182 if (!this->MRF().graph().exists(target)) {
183 GUM_ERROR(UndefinedElement, target << " is not a NodeId in the Markov random field")
184 }
185
186
187 if (_targets_.contains(target)) {
188 _targeted_mode_ = true; // we do not use setTargetedMode_ because we do not
189 // want to clear the targets
191 _targets_.erase(target);
193 }
194 }
virtual void onMarginalTargetErased_(const NodeId id)=0
fired before a marginal target is removed

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evidence()

template<typename GUM_SCALAR>
INLINE const NodeProperty< const Tensor< GUM_SCALAR > * > & gum::GraphicalModelInference< GUM_SCALAR >::evidence ( ) const
inherited

returns the set of evidence

Definition at line 587 of file graphicalModelInference_tpl.h.

587 {
588 return _evidence_;
589 }

References _evidence_.

Referenced by gum::ImportanceSampling< GUM_SCALAR >::onContextualize_(), gum::MarginalTargetedInference< GUM_SCALAR >::posterior(), and gum::MarginalTargetedMRFInference< GUM_SCALAR >::posterior().

Here is the caller graph for this function:

◆ evidenceImpact() [1/2]

template<typename GUM_SCALAR>
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).

Warning
If some evs are d-separated, they are not included in the Tensor
Parameters
targetthe nodeId of the target variable
evsthe nodeId of the observed variable
Returns
a Tensor

Definition at line 312 of file marginalTargetedMRFInference_tpl.h.

314 {
315 const auto& mn = this->MRF();
316 return evidenceImpact(mn.idFromName(target), mn.nodeset(evs));
317 }
Tensor< GUM_SCALAR > evidenceImpact(NodeId target, const NodeSet &evs)
Create a gum::Tensor for P(target|evs) (for all instanciation of target and evs).

References evidenceImpact(), and gum::MRFInference< GUM_SCALAR >::MRF().

Here is the call graph for this function:

◆ evidenceImpact() [2/2]

template<typename GUM_SCALAR>
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).

Warning
If some evs are d-separated, they are not included in the Tensor
Parameters
mnthe MarkovRandomField
targetthe nodeId of the targetted variable
evsthe vector of nodeId of the observed variables
Returns
a Tensor

Definition at line 274 of file marginalTargetedMRFInference_tpl.h.

275 {
276 const auto& vtarget = this->MRF().variable(target);
277
278 if (evs.contains(target)) {
280 "Target <" << vtarget.name() << "> (" << target << ") can not be in evs (" << evs
281 << ").");
282 }
283 auto condset = this->MRF().minimalCondSet(target, evs);
284
286 this->eraseAllTargets();
287 this->eraseAllEvidence();
288 res.add(this->MRF().variable(target));
289 this->addTarget(target);
290 for (const auto& n: condset) {
291 res.add(this->MRF().variable(n));
292 this->addEvidence(n, 0);
293 }
294
296 for (inst.setFirst(); !inst.end(); inst.incNotVar(vtarget)) {
297 // inferring
298 for (const auto& n: condset)
299 this->chgEvidence(n, inst.val(this->MRF().variable(n)));
300 this->makeInference();
301 // populate res
302 for (inst.setFirstVar(vtarget); !inst.end(); inst.incVar(vtarget)) {
303 res.set(inst, this->posterior(target)[inst]);
304 }
305 inst.setFirstVar(vtarget); // remove inst.end() flag
306 }
307
308 return res;
309 }
virtual void makeInference() final
perform the heavy computations needed to compute the targets' posteriors
virtual const Tensor< GUM_SCALAR > & posterior(NodeId node)
Computes and returns the posterior of a node.
virtual void eraseAllTargets()
Clear all previously defined targets.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ H() [1/2]

template<typename GUM_SCALAR>
INLINE GUM_SCALAR gum::MarginalTargetedMRFInference< GUM_SCALAR >::H ( const std::string & nodeName)
finalvirtual

Entropy Compute Shanon's entropy of a node given the observation.

See also
http://en.wikipedia.org/wiki/Information_entropy

Definition at line 268 of file marginalTargetedMRFInference_tpl.h.

268 {
269 return H(this->MRF().idFromName(nodeName));
270 }
virtual GUM_SCALAR H(NodeId X) final
Entropy Compute Shanon's entropy of a node given the observation.

References H(), and gum::MRFInference< GUM_SCALAR >::MRF().

Here is the call graph for this function:

◆ H() [2/2]

template<typename GUM_SCALAR>
INLINE GUM_SCALAR gum::MarginalTargetedMRFInference< GUM_SCALAR >::H ( NodeId X)
finalvirtual

Entropy Compute Shanon's entropy of a node given the observation.

See also
http://en.wikipedia.org/wiki/Information_entropy

Definition at line 260 of file marginalTargetedMRFInference_tpl.h.

260 {
261 return posterior(X).entropy();
262 }

References posterior().

Referenced by H().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hardEvidence()

template<typename GUM_SCALAR>
INLINE const NodeProperty< Idx > & gum::GraphicalModelInference< GUM_SCALAR >::hardEvidence ( ) const
inherited

indicate for each node with hard evidence which value it took

Definition at line 580 of file graphicalModelInference_tpl.h.

580 {
581 return _hard_evidence_;
582 }

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_().

Here is the caller graph for this function:

◆ hardEvidenceNodes()

template<typename GUM_SCALAR>
INLINE const NodeSet & gum::GraphicalModelInference< GUM_SCALAR >::hardEvidenceNodes ( ) const
inherited

◆ hasEvidence() [1/3]

template<typename GUM_SCALAR>
INLINE bool gum::GraphicalModelInference< GUM_SCALAR >::hasEvidence ( ) const
finalvirtualinherited

indicates whether some node(s) have received evidence

Definition at line 346 of file graphicalModelInference_tpl.h.

346 {
347 return !_evidence_.empty();
348 }

References _evidence_.

Referenced by addEvidence(), chgEvidence(), eraseEvidence(), and hasEvidence().

Here is the caller graph for this function:

◆ hasEvidence() [2/3]

template<typename GUM_SCALAR>
INLINE bool gum::GraphicalModelInference< GUM_SCALAR >::hasEvidence ( const std::string & nodeName) const
finalvirtualinherited

indicates whether node id has received an evidence

Definition at line 371 of file graphicalModelInference_tpl.h.

371 {
372 return hasEvidence(this->model().idFromName(nodeName));
373 }

References hasEvidence(), and model().

Here is the call graph for this function:

◆ hasEvidence() [3/3]

template<typename GUM_SCALAR>
INLINE bool gum::GraphicalModelInference< GUM_SCALAR >::hasEvidence ( NodeId id) const
finalvirtualinherited

indicates whether node id has received an evidence

Definition at line 352 of file graphicalModelInference_tpl.h.

352 {
353 return _evidence_.exists(id);
354 }

References _evidence_.

◆ hasHardEvidence() [1/2]

template<typename GUM_SCALAR>
INLINE bool gum::GraphicalModelInference< GUM_SCALAR >::hasHardEvidence ( const std::string & nodeName) const
finalvirtualinherited

indicates whether node id has received a hard evidence

Definition at line 378 of file graphicalModelInference_tpl.h.

378 {
379 return hasHardEvidence(this->model().idFromName(nodeName));
380 }

References hasHardEvidence(), and model().

Here is the call graph for this function:

◆ hasHardEvidence() [2/2]

template<typename GUM_SCALAR>
INLINE bool gum::GraphicalModelInference< GUM_SCALAR >::hasHardEvidence ( NodeId id) const
finalvirtualinherited

indicates whether node id has received a hard evidence

Definition at line 358 of file graphicalModelInference_tpl.h.

358 {
359 return _hard_evidence_nodes_.exists(id);
360 }

References _hard_evidence_nodes_.

Referenced by chgEvidence(), gum::ImportanceSampling< GUM_SCALAR >::draw_(), eraseEvidence(), hasHardEvidence(), and gum::JointTargetedMRFInference< GUM_SCALAR >::jointPosterior().

Here is the caller graph for this function:

◆ hasNoModel_()

template<typename GUM_SCALAR>
bool gum::GraphicalModelInference< GUM_SCALAR >::hasNoModel_ ( ) const
inlineprotectedinherited

Definition at line 542 of file graphicalModelInference.h.

542{ return _model_ == nullptr; };

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().

Here is the caller graph for this function:

◆ hasSoftEvidence() [1/2]

template<typename GUM_SCALAR>
INLINE bool gum::GraphicalModelInference< GUM_SCALAR >::hasSoftEvidence ( const std::string & nodeName) const
finalvirtualinherited

indicates whether node id has received a soft evidence

Definition at line 385 of file graphicalModelInference_tpl.h.

385 {
386 return hasSoftEvidence(this->model().idFromName(nodeName));
387 }
virtual bool hasSoftEvidence(NodeId id) const final
indicates whether node id has received a soft evidence

References hasSoftEvidence(), and model().

Here is the call graph for this function:

◆ hasSoftEvidence() [2/2]

template<typename GUM_SCALAR>
INLINE bool gum::GraphicalModelInference< GUM_SCALAR >::hasSoftEvidence ( NodeId id) const
finalvirtualinherited

indicates whether node id has received a soft evidence

Definition at line 364 of file graphicalModelInference_tpl.h.

364 {
365 return _soft_evidence_nodes_.exists(id);
366 }

References _soft_evidence_nodes_.

Referenced by hasSoftEvidence().

Here is the caller graph for this function:

◆ isInferenceDone()

template<typename GUM_SCALAR>
INLINE bool gum::GraphicalModelInference< GUM_SCALAR >::isInferenceDone ( ) const
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.

104 {
106 }
StateOfInference _state_
the current state of the inference (outdated/ready/done)

References _state_, and Done.

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().

Here is the caller graph for this function:

◆ isInferenceOutdatedStructure()

template<typename GUM_SCALAR>
INLINE bool gum::GraphicalModelInference< GUM_SCALAR >::isInferenceOutdatedStructure ( ) const
finalvirtualnoexceptinherited

returns whether the inference object is in a OutdatedStructure state

Definition at line 92 of file graphicalModelInference_tpl.h.

92 {
94 }

References _state_, and OutdatedStructure.

Referenced by chgEvidence(), eraseAllEvidence(), and eraseEvidence().

Here is the caller graph for this function:

◆ isInferenceOutdatedTensors()

template<typename GUM_SCALAR>
INLINE bool gum::GraphicalModelInference< GUM_SCALAR >::isInferenceOutdatedTensors ( ) const
finalvirtualnoexceptinherited

returns whether the inference object is in a OutdatedTensor state

Definition at line 98 of file graphicalModelInference_tpl.h.

98 {
100 }

References _state_, and OutdatedTensors.

◆ isInferenceReady()

template<typename GUM_SCALAR>
INLINE bool gum::GraphicalModelInference< GUM_SCALAR >::isInferenceReady ( ) const
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().

Here is the caller graph for this function:

◆ isTarget() [1/2]

template<typename GUM_SCALAR>
INLINE bool gum::MarginalTargetedMRFInference< GUM_SCALAR >::isTarget ( const std::string & nodeName) const
finalvirtual

return true if variable is a (marginal) target

Definition at line 104 of file marginalTargetedMRFInference_tpl.h.

104 {
105 return isTarget(this->MRF().idFromName(nodeName));
106 }
virtual bool isTarget(NodeId node) const final
return true if variable is a (marginal) target

References isTarget(), and gum::MRFInference< GUM_SCALAR >::MRF().

Here is the call graph for this function:

◆ isTarget() [2/2]

template<typename GUM_SCALAR>
INLINE bool gum::MarginalTargetedMRFInference< GUM_SCALAR >::isTarget ( NodeId node) const
finalvirtual

return true if variable is a (marginal) target

Definition at line 88 of file marginalTargetedMRFInference_tpl.h.

88 {
89 // check that the variable belongs to the mn
90 if (this->hasNoModel_())
92 "No Markov net has been assigned to the "
93 "inference algorithm");
94 if (!this->MRF().graph().exists(node)) {
95 GUM_ERROR(UndefinedElement, node << " is not a NodeId in the Markov random field")
96 }
97
98 return _targets_.contains(node);
99 }

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isTargetedMode_()

template<typename GUM_SCALAR>
INLINE bool gum::MarginalTargetedMRFInference< GUM_SCALAR >::isTargetedMode_ ( ) const
protected

Definition at line 320 of file marginalTargetedMRFInference_tpl.h.

320 {
321 return _targeted_mode_;
322 }

References _targeted_mode_.

◆ makeInference()

template<typename GUM_SCALAR>
INLINE void gum::GraphicalModelInference< GUM_SCALAR >::makeInference ( )
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.

638 {
639 if (isInferenceDone()) { return; }
640
642
644
646 }
virtual void prepareInference() final
prepare the internal inference structures for the next inference
virtual bool isInferenceReady() const noexcept final
returns whether the inference object is in a ready state
virtual void makeInference_()=0
called when the inference has to be performed effectively
virtual bool isInferenceDone() const noexcept final
returns whether the inference object is in a InferenceDone state

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ makeInference_()

template<typename GUM_SCALAR>
virtual void gum::GraphicalModelInference< GUM_SCALAR >::makeInference_ ( )
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_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ model()

template<typename GUM_SCALAR>
INLINE const GraphicalModel & gum::GraphicalModelInference< GUM_SCALAR >::model ( ) const
finalvirtualinherited

Returns a constant reference over the IBayesNet referenced by this class.

Exceptions
UndefinedElementis raised if no Bayes net has been assigned to the inference.

Definition at line 126 of file graphicalModelInference_tpl.h.

126 {
127 if (_model_ == nullptr)
129 "No Bayes net has been assigned to "
130 "the inference algorithm.");
131 return *_model_;
132 }

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_().

Here is the caller graph for this function:

◆ MRF()

template<typename GUM_SCALAR>
INLINE const IMarkovRandomField< GUM_SCALAR > & gum::MRFInference< GUM_SCALAR >::MRF ( ) const
finalvirtualinherited

Returns a constant reference over the IMarkovRandomField referenced by this class.

Exceptions
UndefinedElementis raised if no Markov net has been assigned to the inference.

Definition at line 75 of file MRFInference_tpl.h.

75 {
76 return static_cast< const IMarkovRandomField< GUM_SCALAR >& >(this->model());
77 }

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_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nbrEvidence()

template<typename GUM_SCALAR>
INLINE Size gum::GraphicalModelInference< GUM_SCALAR >::nbrEvidence ( ) const
finalvirtualinherited

returns the number of evidence entered into the Bayesian network

Definition at line 562 of file graphicalModelInference_tpl.h.

562 {
563 return _evidence_.size();
564 }

References _evidence_.

◆ nbrHardEvidence()

template<typename GUM_SCALAR>
INLINE Size gum::GraphicalModelInference< GUM_SCALAR >::nbrHardEvidence ( ) const
finalvirtualinherited

returns the number of hard evidence entered into the Bayesian network

Definition at line 568 of file graphicalModelInference_tpl.h.

568 {
569 return _hard_evidence_nodes_.size();
570 }

References _hard_evidence_nodes_.

◆ nbrSoftEvidence()

template<typename GUM_SCALAR>
INLINE Size gum::GraphicalModelInference< GUM_SCALAR >::nbrSoftEvidence ( ) const
finalvirtualinherited

returns the number of soft evidence entered into the Bayesian network

Definition at line 574 of file graphicalModelInference_tpl.h.

574 {
575 return _soft_evidence_nodes_.size();
576 }

References _soft_evidence_nodes_.

◆ nbrTargets()

template<typename GUM_SCALAR>
INLINE Size gum::MarginalTargetedMRFInference< GUM_SCALAR >::nbrTargets ( ) const
finalvirtualnoexcept

returns the number of marginal targets

Definition at line 216 of file marginalTargetedMRFInference_tpl.h.

216 {
217 return _targets_.size();
218 }

References _targets_.

◆ onAllEvidenceErased_()

template<typename GUM_SCALAR>
virtual void gum::GraphicalModelInference< GUM_SCALAR >::onAllEvidenceErased_ ( bool contains_hard_evidence)
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_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onAllMarginalTargetsAdded_()

template<typename GUM_SCALAR>
virtual void gum::MarginalTargetedMRFInference< GUM_SCALAR >::onAllMarginalTargetsAdded_ ( )
protectedpure virtual

fired after all the nodes of the MRF are added as marginal targets

Implemented in gum::ShaferShenoyMRFInference< GUM_SCALAR >.

Referenced by _setAllMarginalTargets_().

Here is the caller graph for this function:

◆ onAllMarginalTargetsErased_()

template<typename GUM_SCALAR>
virtual void gum::MarginalTargetedMRFInference< GUM_SCALAR >::onAllMarginalTargetsErased_ ( )
protectedpure virtual

fired before a all marginal targets are removed

Implemented in gum::ShaferShenoyMRFInference< GUM_SCALAR >.

Referenced by eraseAllTargets().

Here is the caller graph for this function:

◆ onEvidenceAdded_()

template<typename GUM_SCALAR>
virtual void gum::GraphicalModelInference< GUM_SCALAR >::onEvidenceAdded_ ( const NodeId id,
bool isHardEvidence )
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_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onEvidenceChanged_()

template<typename GUM_SCALAR>
virtual void gum::GraphicalModelInference< GUM_SCALAR >::onEvidenceChanged_ ( const NodeId id,
bool hasChangedSoftHard )
protectedpure virtualinherited

fired after an evidence is changed, in particular when its status (soft/hard) changes

Parameters
nodeIdthe node of the changed evidence
hasChangedSoftHardtrue 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_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onEvidenceErased_()

template<typename GUM_SCALAR>
virtual void gum::GraphicalModelInference< GUM_SCALAR >::onEvidenceErased_ ( const NodeId id,
bool isHardEvidence )
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_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onMarginalTargetAdded_()

template<typename GUM_SCALAR>
virtual void gum::MarginalTargetedMRFInference< GUM_SCALAR >::onMarginalTargetAdded_ ( const NodeId id)
protectedpure virtual

fired after a new marginal target is inserted

Parameters
idThe target variable's id.

Implemented in gum::ShaferShenoyMRFInference< GUM_SCALAR >.

Referenced by addAllTargets(), and addTarget().

Here is the caller graph for this function:

◆ onMarginalTargetErased_()

template<typename GUM_SCALAR>
virtual void gum::MarginalTargetedMRFInference< GUM_SCALAR >::onMarginalTargetErased_ ( const NodeId id)
protectedpure virtual

fired before a marginal target is removed

Parameters
idThe target variable's id.

Implemented in gum::ShaferShenoyMRFInference< GUM_SCALAR >.

Referenced by eraseTarget().

Here is the caller graph for this function:

◆ onModelChanged_()

template<typename GUM_SCALAR>
void gum::MarginalTargetedMRFInference< GUM_SCALAR >::onModelChanged_ ( const GraphicalModel * mn)
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.

77 {
78 _targeted_mode_ = true;
80 }
void _setAllMarginalTargets_()
sets all the nodes of the Markov net as targets

References _setAllMarginalTargets_(), and _targeted_mode_.

Referenced by gum::JointTargetedMRFInference< GUM_SCALAR >::onModelChanged_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onStateChanged_()

template<typename GUM_SCALAR>
virtual void gum::GraphicalModelInference< GUM_SCALAR >::onStateChanged_ ( )
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_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ posterior() [1/2]

template<typename GUM_SCALAR>
const Tensor< GUM_SCALAR > & gum::MarginalTargetedMRFInference< GUM_SCALAR >::posterior ( const std::string & nodeName)
virtual

Computes and returns the posterior of a node.

Returns
a const ref to the posterior probability of the node.
Parameters
nodeNamethe anme of the node for which we need a posterior probability
Warning
for efficiency reasons, the tensor is stored into the inference engine and is returned by reference. In order to ensure that the tensor may still exist even if the Inference object is destroyed, the user has to copy it explicitly.
prepareInference and makeInference may be applied if needed by the posterior method.
Exceptions
UndefinedElementif node is not in the set of targets

Reimplemented in gum::JointTargetedMRFInference< GUM_SCALAR >.

Definition at line 252 of file marginalTargetedMRFInference_tpl.h.

252 {
253 return posterior(this->MRF().idFromName(nodeName));
254 }

References gum::MRFInference< GUM_SCALAR >::MRF(), and posterior().

Here is the call graph for this function:

◆ posterior() [2/2]

template<typename GUM_SCALAR>
const Tensor< GUM_SCALAR > & gum::MarginalTargetedMRFInference< GUM_SCALAR >::posterior ( NodeId node)
virtual

Computes and returns the posterior of a node.

Returns
a const ref to the posterior probability of the node.
Parameters
nodethe node for which we need a posterior probability
Warning
for efficiency reasons, the tensor is stored into the inference engine and is returned by reference. In order to ensure that the tensor may still exist even if the Inference object is destroyed, the user has to copy it explicitly.
prepareInference and makeInference may be applied if needed by the posterior method.
Exceptions
UndefinedElementif node is not in the set of targets

Reimplemented in gum::JointTargetedMRFInference< GUM_SCALAR >.

Definition at line 236 of file marginalTargetedMRFInference_tpl.h.

236 {
237 if (this->hardEvidenceNodes().contains(node)) { return *(this->evidence()[node]); }
238
239 if (!isTarget(node)) {
240 // throws UndefinedElement if var is not a target
241 GUM_ERROR(UndefinedElement, node << " is not a target node")
242 }
243
244 if (!this->isInferenceDone()) { this->makeInference(); }
245
246 return posterior_(node);
247 }
const NodeSet & hardEvidenceNodes() const
returns the set of nodes with hard evidence
const NodeProperty< const Tensor< GUM_SCALAR > * > & evidence() const
returns the set of evidence
virtual const Tensor< GUM_SCALAR > & posterior_(NodeId id)=0
asks derived classes for the posterior of a given variable

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ posterior_()

template<typename GUM_SCALAR>
virtual const Tensor< GUM_SCALAR > & gum::MarginalTargetedMRFInference< GUM_SCALAR >::posterior_ ( NodeId id)
protectedpure virtual

asks derived classes for the posterior of a given variable

Parameters
idThe variable's id.

Implemented in gum::ShaferShenoyMRFInference< GUM_SCALAR >.

Referenced by posterior().

Here is the caller graph for this function:

◆ prepareInference()

template<typename GUM_SCALAR>
INLINE void gum::GraphicalModelInference< GUM_SCALAR >::prepareInference ( )
finalvirtualinherited

prepare the internal inference structures for the next inference

Definition at line 622 of file graphicalModelInference_tpl.h.

622 {
623 if (isInferenceReady() || isInferenceDone()) { return; }
624
625 if (_model_ == nullptr)
627 "No model been assigned to the "
628 "inference algorithm");
629
632
634 }
virtual void updateOutdatedTensors_()=0
prepares inference when the latter is in OutdatedTensors state
virtual void updateOutdatedStructure_()=0
prepares inference when the latter is in OutdatedStructure state

References _model_, _state_, GUM_ERROR, isInferenceDone(), isInferenceReady(), OutdatedStructure, ReadyForInference, setState_(), updateOutdatedStructure_(), and updateOutdatedTensors_().

Referenced by makeInference(), and gum::SamplingInference< GUM_SCALAR >::samplingBN().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setModel_()

template<typename GUM_SCALAR>
void gum::GraphicalModelInference< GUM_SCALAR >::setModel_ ( const GraphicalModel * model)
protectedinherited

Definition at line 136 of file graphicalModelInference_tpl.h.

136 {
137 clear();
138 _model_ = model;
142 }
void _computeDomainSizes_()
computes the domain sizes of the random variables
virtual void onModelChanged_(const GraphicalModel *model)=0
fired after a new Bayes net has been assigned to the engine
virtual void clear()
clears all the data structures allocated for the last inference

References _computeDomainSizes_(), _model_, clear(), model(), onModelChanged_(), OutdatedStructure, and setState_().

Referenced by gum::BayesNetInference< GUM_SCALAR >::setBN(), and gum::MRFInference< GUM_SCALAR >::setMRF().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setModelDuringConstruction_()

template<typename GUM_SCALAR>
void gum::GraphicalModelInference< GUM_SCALAR >::setModelDuringConstruction_ ( const GraphicalModel * model)
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_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setMRF()

template<typename GUM_SCALAR>
void gum::MRFInference< GUM_SCALAR >::setMRF ( const IMarkovRandomField< GUM_SCALAR > * mrf)
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.

Warning
By default, all the nodes of the Markov net are targets.
note that, by aGrUM's rule, the mn is not copied into the inference engine but only referenced.

Definition at line 81 of file MRFInference_tpl.h.

81 {
82 this->setModel_(mrf);
83 }
void setModel_(const GraphicalModel *model)

References gum::GraphicalModelInference< GUM_SCALAR >::setModel_().

Here is the call graph for this function:

◆ setOutdatedStructureState_()

template<typename GUM_SCALAR>
INLINE void gum::GraphicalModelInference< GUM_SCALAR >::setOutdatedStructureState_ ( )
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_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setOutdatedTensorsState_()

template<typename GUM_SCALAR>
INLINE void gum::GraphicalModelInference< GUM_SCALAR >::setOutdatedTensorsState_ ( )
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_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setState_()

template<typename GUM_SCALAR>
INLINE void gum::GraphicalModelInference< GUM_SCALAR >::setState_ ( const StateOfInference state)
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.

117 {
118 if (_state_ != state) {
119 _state_ = state;
121 }
122 }
virtual void onStateChanged_()=0
fired when the stage is changed
virtual StateOfInference state() const noexcept final
returns the state of the inference engine

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_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setTargetedMode_()

template<typename GUM_SCALAR>
INLINE void gum::MarginalTargetedMRFInference< GUM_SCALAR >::setTargetedMode_ ( )
protected

Definition at line 325 of file marginalTargetedMRFInference_tpl.h.

325 {
326 if (!_targeted_mode_) {
327 _targets_.clear();
328 _targeted_mode_ = true;
329 }
330 }

References _targeted_mode_, and _targets_.

Referenced by addAllTargets(), gum::JointTargetedMRFInference< GUM_SCALAR >::addJointTarget(), addTarget(), and eraseAllTargets().

Here is the caller graph for this function:

◆ softEvidenceNodes()

template<typename GUM_SCALAR>
INLINE const NodeSet & gum::GraphicalModelInference< GUM_SCALAR >::softEvidenceNodes ( ) const
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.

593 {
595 }

References _soft_evidence_nodes_.

Referenced by gum::SamplingInference< GUM_SCALAR >::contextualize().

Here is the caller graph for this function:

◆ state()

template<typename GUM_SCALAR>
INLINE GraphicalModelInference< GUM_SCALAR >::StateOfInference gum::GraphicalModelInference< GUM_SCALAR >::state ( ) const
finalvirtualnoexceptinherited

returns the state of the inference engine

Definition at line 111 of file graphicalModelInference_tpl.h.

111 {
112 return _state_;
113 }

References _state_.

Referenced by setState_().

Here is the caller graph for this function:

◆ targets()

template<typename GUM_SCALAR>
INLINE const NodeSet & gum::MarginalTargetedMRFInference< GUM_SCALAR >::targets ( ) const
finalvirtualnoexcept

returns the list of marginal targets

Definition at line 210 of file marginalTargetedMRFInference_tpl.h.

210 {
211 return _targets_;
212 }

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().

Here is the caller graph for this function:

◆ updateOutdatedStructure_()

template<typename GUM_SCALAR>
virtual void gum::GraphicalModelInference< GUM_SCALAR >::updateOutdatedStructure_ ( )
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_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateOutdatedTensors_()

template<typename GUM_SCALAR>
virtual void gum::GraphicalModelInference< GUM_SCALAR >::updateOutdatedTensors_ ( )
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_().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _domain_sizes_

template<typename GUM_SCALAR>
NodeProperty< Size > gum::GraphicalModelInference< GUM_SCALAR >::_domain_sizes_
privateinherited

the domain sizes of the random variables

Definition at line 507 of file graphicalModelInference.h.

Referenced by _computeDomainSizes_(), and domainSizes().

◆ _evidence_

template<typename GUM_SCALAR>
NodeProperty< const Tensor< GUM_SCALAR >* > gum::GraphicalModelInference< GUM_SCALAR >::_evidence_
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().

◆ _hard_evidence_

template<typename GUM_SCALAR>
NodeProperty< Idx > gum::GraphicalModelInference< GUM_SCALAR >::_hard_evidence_
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().

◆ _hard_evidence_nodes_

template<typename GUM_SCALAR>
NodeSet gum::GraphicalModelInference< GUM_SCALAR >::_hard_evidence_nodes_
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().

◆ _model_

template<typename GUM_SCALAR>
const GraphicalModel* gum::GraphicalModelInference< GUM_SCALAR >::_model_ {nullptr}
privateinherited

◆ _soft_evidence_nodes_

template<typename GUM_SCALAR>
NodeSet gum::GraphicalModelInference< GUM_SCALAR >::_soft_evidence_nodes_
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().

◆ _state_

template<typename GUM_SCALAR>
StateOfInference gum::GraphicalModelInference< GUM_SCALAR >::_state_ {StateOfInference::OutdatedStructure}
privateinherited

◆ _targeted_mode_

template<typename GUM_SCALAR>
bool gum::MarginalTargetedMRFInference< GUM_SCALAR >::_targeted_mode_
private

whether the actual targets are default

Definition at line 259 of file marginalTargetedMRFInference.h.

Referenced by MarginalTargetedMRFInference(), eraseTarget(), isTargetedMode_(), onModelChanged_(), and setTargetedMode_().

◆ _targets_

template<typename GUM_SCALAR>
NodeSet gum::MarginalTargetedMRFInference< GUM_SCALAR >::_targets_
private

◆ EvidenceMRFInference< GUM_SCALAR >

template<typename GUM_SCALAR>
friend gum::MRFInference< GUM_SCALAR >::EvidenceMRFInference< GUM_SCALAR >
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.

Warning
By default, all the nodes of the Markov net are targets.
note that, by aGrUM's rule, the mn is not copied into the inference engine but only referenced.

Definition at line 223 of file MRFInference.h.

◆ JointTargetedMRFInference< GUM_SCALAR >

template<typename GUM_SCALAR>
friend gum::MRFInference< GUM_SCALAR >::JointTargetedMRFInference< GUM_SCALAR >
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.

Warning
By default, all the nodes of the Markov net are targets.
note that, by aGrUM's rule, the mn is not copied into the inference engine but only referenced.

Definition at line 222 of file MRFInference.h.

◆ MarginalTargetedMRFInference< GUM_SCALAR >

template<typename GUM_SCALAR>
friend gum::MRFInference< GUM_SCALAR >::MarginalTargetedMRFInference< GUM_SCALAR >
privateinherited

allow JointInference to access the single targets and inference states

Definition at line 221 of file MRFInference.h.


The documentation for this class was generated from the following files: