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

<agrum/ID/inference/influenceDiagramInference.h> More...

#include <influenceDiagramInference.h>

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

Public Types

enum class  StateOfInference { OutdatedStructure , OutdatedTensors , ReadyForInference , Done }
 current state of the inference More...

Public Member Functions

 InfluenceDiagramInference (const InfluenceDiagram< GUM_SCALAR > *infDiag)
 Default constructor.
virtual ~InfluenceDiagramInference ()
 Destructor.
virtual void setInfluenceDiagram (const InfluenceDiagram< GUM_SCALAR > *infdiag)
 assigns a new influence diagram to the inference engine
virtual const InfluenceDiagram< GUM_SCALAR > & influenceDiagram () const final
 Returns a constant reference over the IBayesNet referenced by this class.
virtual gum::Tensor< GUM_SCALAR > optimalDecision (NodeId decisionId)=0
virtual gum::Tensor< GUM_SCALAR > optimalDecision (std::string_view nodename)=0
virtual const Tensor< GUM_SCALAR > & posterior (NodeId node)=0
virtual const Tensor< GUM_SCALAR > & posterior (std::string_view nodename)=0
virtual const Tensor< GUM_SCALAR > & posteriorUtility (NodeId node)=0
virtual const Tensor< GUM_SCALAR > & posteriorUtility (std::string_view nodename)=0
virtual std::pair< GUM_SCALAR, GUM_SCALAR > meanVar (NodeId node)=0
virtual std::pair< GUM_SCALAR, GUM_SCALAR > meanVar (std::string_view nodename)=0
virtual std::pair< GUM_SCALAR, GUM_SCALAR > MEU ()=0
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 (std::string_view nodeName, const Idx val) final
 adds a new hard evidence on node named nodeName
virtual void addEvidence (NodeId id, std::string_view label) final
 adds a new hard evidence on node id
virtual void addEvidence (std::string_view nodeName, std::string_view 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 (std::string_view 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 (std::string_view nodeName, const Idx val) final
 change the value of an already existing hard evidence
virtual void chgEvidence (NodeId id, std::string_view label) final
 change the value of an already existing hard evidence
virtual void chgEvidence (std::string_view nodeName, std::string_view 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 (std::string_view 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 (std::string_view 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 (std::string_view 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 (std::string_view 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 (std::string_view 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 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 onModelChanged_ (const GraphicalModel *model)=0
 fired after a new Bayes net has been assigned to the engine
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 _setIDDuringConstruction_ (const InfluenceDiagram< GUM_SCALAR > *infdiag)
 assigns a influence diagram during the inference engine construction
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

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

Detailed Description

template<GUM_Numeric GUM_SCALAR>
class gum::InfluenceDiagramInference< GUM_SCALAR >

<agrum/ID/inference/influenceDiagramInference.h>

This class implements an algorithm for inference in influence diagrams based upon Shaffer-Shenoy's one for bayes net inferences

The class used for the triangulation is partialOrderedTriangulation.

Abstract base class for inference engines in influence diagrams.

Definition at line 68 of file influenceDiagramInference.h.

Member Enumeration Documentation

◆ StateOfInference

template<GUM_Numeric 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

◆ InfluenceDiagramInference()

template<GUM_Numeric GUM_SCALAR>
gum::InfluenceDiagramInference< GUM_SCALAR >::InfluenceDiagramInference ( const InfluenceDiagram< GUM_SCALAR > * infDiag)
explicit

Default constructor.

◆ ~InfluenceDiagramInference()

template<GUM_Numeric GUM_SCALAR>
virtual gum::InfluenceDiagramInference< GUM_SCALAR >::~InfluenceDiagramInference ( )
virtual

Destructor.

Member Function Documentation

◆ _computeDomainSizes_()

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

computes the domain sizes of the random variables

Definition at line 163 of file graphicalModelInference_tpl.h.

163 {
164 _domain_sizes_.clear();
165 if (!hasNoModel_()) {
166 for (auto node: _model_->nodes()) {
167 _domain_sizes_.insert(node, _model_->variable(node).domainSize());
168 }
169 }
170 }
<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<GUM_Numeric 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 185 of file graphicalModelInference_tpl.h.

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

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<GUM_Numeric 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 204 of file graphicalModelInference_tpl.h.

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

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:

◆ _setIDDuringConstruction_()

template<GUM_Numeric GUM_SCALAR>
void gum::InfluenceDiagramInference< GUM_SCALAR >::_setIDDuringConstruction_ ( const InfluenceDiagram< GUM_SCALAR > * infdiag)
private

assigns a influence diagram during the inference engine construction

References _setIDDuringConstruction_().

Referenced by _setIDDuringConstruction_().

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

◆ addEvidence() [1/8]

template<GUM_Numeric GUM_SCALAR>
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.

323 {
326 }
virtual void addEvidence(NodeId id, const Idx val) final
adds a new hard evidence on node id

References addEvidence().

Here is the call graph for this function:

◆ addEvidence() [2/8]

template<GUM_Numeric GUM_SCALAR>
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 230 of file graphicalModelInference_tpl.h.

230 {
232 }
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::Counterfactual< GUM_ELEMENT >::counterFactualModel(), gum::Counterfactual< GUM_ELEMENT >::counterFactualModel(), gum::counterfactualModel(), 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() [3/8]

template<GUM_Numeric 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() [4/8]

template<GUM_Numeric GUM_SCALAR>
void gum::GraphicalModelInference< GUM_SCALAR >::addEvidence ( NodeId id,
std::string_view 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 243 of file graphicalModelInference_tpl.h.

243 {
244 addEvidence(id, this->model().variable(id)[label]);
245 }
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() [5/8]

template<GUM_Numeric GUM_SCALAR>
void gum::GraphicalModelInference< GUM_SCALAR >::addEvidence ( std::string_view 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 236 of file graphicalModelInference_tpl.h.

237 {
239 }

References addEvidence(), and model().

Here is the call graph for this function:

◆ addEvidence() [6/8]

template<GUM_Numeric GUM_SCALAR>
void gum::GraphicalModelInference< GUM_SCALAR >::addEvidence ( std::string_view 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() [7/8]

template<GUM_Numeric GUM_SCALAR>
void gum::GraphicalModelInference< GUM_SCALAR >::addEvidence ( std::string_view nodeName,
std::string_view 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(std::string_view name) const =0
Getter by name.

References addEvidence(), and model().

Here is the call graph for this function:

◆ addEvidence() [8/8]

template<GUM_Numeric 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 }
virtual bool hasEvidence() const final
indicates whether some node(s) have received evidence
virtual void setState_(const StateOfInference state) final
set the state of the inference engine and call the notification onStateChanged_ when necessary (i....
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 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<GUM_Numeric GUM_SCALAR>
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<GUM_Numeric GUM_SCALAR>
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:

◆ chgEvidence() [1/7]

template<GUM_Numeric 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 446 of file graphicalModelInference_tpl.h.

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

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() [2/7]

template<GUM_Numeric GUM_SCALAR>
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 388 of file graphicalModelInference_tpl.h.

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

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() [3/7]

template<GUM_Numeric GUM_SCALAR>
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 415 of file graphicalModelInference_tpl.h.

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

References _model_, chgEvidence(), and GUM_ERROR.

Here is the call graph for this function:

◆ chgEvidence() [4/7]

template<GUM_Numeric GUM_SCALAR>
void gum::GraphicalModelInference< GUM_SCALAR >::chgEvidence ( NodeId id,
std::string_view 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 401 of file graphicalModelInference_tpl.h.

401 {
402 chgEvidence(id, this->model().variable(id)[label]);
403 }

References chgEvidence(), and model().

Here is the call graph for this function:

◆ chgEvidence() [5/7]

template<GUM_Numeric GUM_SCALAR>
void gum::GraphicalModelInference< GUM_SCALAR >::chgEvidence ( std::string_view 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 394 of file graphicalModelInference_tpl.h.

395 {
397 }

References chgEvidence(), and model().

Here is the call graph for this function:

◆ chgEvidence() [6/7]

template<GUM_Numeric GUM_SCALAR>
void gum::GraphicalModelInference< GUM_SCALAR >::chgEvidence ( std::string_view 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 439 of file graphicalModelInference_tpl.h.

440 {
442 }

References chgEvidence(), and model().

Here is the call graph for this function:

◆ chgEvidence() [7/7]

template<GUM_Numeric GUM_SCALAR>
void gum::GraphicalModelInference< GUM_SCALAR >::chgEvidence ( std::string_view nodeName,
std::string_view 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 407 of file graphicalModelInference_tpl.h.

408 {
409 NodeId id = this->model().idFromName(nodeName);
410 chgEvidence(id, this->model().variable(id)[label]);
411 }

References chgEvidence(), and model().

Here is the call graph for this function:

◆ clear()

template<GUM_Numeric GUM_SCALAR>
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 156 of file graphicalModelInference_tpl.h.

156 {
159 }
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<GUM_Numeric GUM_SCALAR>
const NodeProperty< Size > & gum::GraphicalModelInference< GUM_SCALAR >::domainSizes ( ) const
finalvirtualinherited

get the domain sizes of the random variables of the model

Definition at line 174 of file graphicalModelInference_tpl.h.

174 {
175 return _domain_sizes_;
176 }

References _domain_sizes_.

◆ eraseAllEvidence()

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

removes all the evidence entered into the network

Definition at line 534 of file graphicalModelInference_tpl.h.

534 {
535 bool has_hard_evidence = !_hard_evidence_.empty();
537
538 for (const auto& pair: _evidence_) {
539 if (pair.second != nullptr) { delete (pair.second); }
540 }
541
542 _evidence_.clear();
543 _hard_evidence_.clear();
544 _hard_evidence_nodes_.clear();
545 _soft_evidence_nodes_.clear();
546
547 if (has_hard_evidence) {
549 } else {
551 }
552 }
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:

◆ eraseEvidence() [1/2]

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

removed the evidence, if any, corresponding to node id

Definition at line 508 of file graphicalModelInference_tpl.h.

508 {
509 if (hasEvidence(id)) {
510 if (hasHardEvidence(id)) {
511 onEvidenceErased_(id, true);
512 _hard_evidence_.erase(id);
513 _hard_evidence_nodes_.erase(id);
515 } else {
516 onEvidenceErased_(id, false);
517 _soft_evidence_nodes_.erase(id);
519 }
520
521 delete (_evidence_[id]);
522 _evidence_.erase(id);
523 }
524 }
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:

◆ eraseEvidence() [2/2]

template<GUM_Numeric GUM_SCALAR>
void gum::GraphicalModelInference< GUM_SCALAR >::eraseEvidence ( std::string_view nodeName)
finalvirtualinherited

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

Definition at line 528 of file graphicalModelInference_tpl.h.

528 {
530 }
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:

◆ evidence()

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

returns the set of evidence

Definition at line 581 of file graphicalModelInference_tpl.h.

581 {
582 return _evidence_;
583 }

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:

◆ hardEvidence()

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

indicate for each node with hard evidence which value it took

Definition at line 574 of file graphicalModelInference_tpl.h.

574 {
575 return _hard_evidence_;
576 }

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<GUM_Numeric GUM_SCALAR>
const NodeSet & gum::GraphicalModelInference< GUM_SCALAR >::hardEvidenceNodes ( ) const
inherited

◆ hasEvidence() [1/3]

template<GUM_Numeric GUM_SCALAR>
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<GUM_Numeric GUM_SCALAR>
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_.

◆ hasEvidence() [3/3]

template<GUM_Numeric GUM_SCALAR>
bool gum::GraphicalModelInference< GUM_SCALAR >::hasEvidence ( std::string_view nodeName) const
finalvirtualinherited

indicates whether node id has received an evidence

Definition at line 370 of file graphicalModelInference_tpl.h.

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

References hasEvidence(), and model().

Here is the call graph for this function:

◆ hasHardEvidence() [1/2]

template<GUM_Numeric GUM_SCALAR>
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:

◆ hasHardEvidence() [2/2]

template<GUM_Numeric GUM_SCALAR>
bool gum::GraphicalModelInference< GUM_SCALAR >::hasHardEvidence ( std::string_view nodeName) const
finalvirtualinherited

indicates whether node id has received a hard evidence

Definition at line 376 of file graphicalModelInference_tpl.h.

376 {
377 return hasHardEvidence(this->model().idFromName(nodeName));
378 }

References hasHardEvidence(), and model().

Here is the call graph for this function:

◆ hasNoModel_()

template<GUM_Numeric GUM_SCALAR>
bool gum::GraphicalModelInference< GUM_SCALAR >::hasNoModel_ ( ) const
protectedinherited

Definition at line 643 of file graphicalModelInference_tpl.h.

643 {
644 return _model_ == nullptr;
645 }

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<GUM_Numeric GUM_SCALAR>
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:

◆ hasSoftEvidence() [2/2]

template<GUM_Numeric GUM_SCALAR>
bool gum::GraphicalModelInference< GUM_SCALAR >::hasSoftEvidence ( std::string_view nodeName) const
finalvirtualinherited

indicates whether node id has received a soft evidence

Definition at line 382 of file graphicalModelInference_tpl.h.

382 {
383 return hasSoftEvidence(this->model().idFromName(nodeName));
384 }
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:

◆ influenceDiagram()

template<GUM_Numeric GUM_SCALAR>
virtual const InfluenceDiagram< GUM_SCALAR > & gum::InfluenceDiagramInference< GUM_SCALAR >::influenceDiagram ( ) const
finalvirtual

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

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

◆ isInferenceDone()

template<GUM_Numeric GUM_SCALAR>
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 105 of file graphicalModelInference_tpl.h.

105 {
107 }
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<GUM_Numeric GUM_SCALAR>
bool gum::GraphicalModelInference< GUM_SCALAR >::isInferenceOutdatedStructure ( ) const
finalvirtualnoexceptinherited

returns whether the inference object is in a OutdatedStructure state

Definition at line 93 of file graphicalModelInference_tpl.h.

93 {
95 }

References _state_, and OutdatedStructure.

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

Here is the caller graph for this function:

◆ isInferenceOutdatedTensors()

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

returns whether the inference object is in a OutdatedTensor state

Definition at line 99 of file graphicalModelInference_tpl.h.

99 {
101 }

References _state_, and OutdatedTensors.

◆ isInferenceReady()

template<GUM_Numeric GUM_SCALAR>
bool gum::GraphicalModelInference< GUM_SCALAR >::isInferenceReady ( ) const
finalvirtualnoexceptinherited

returns whether the inference object is in a ready state

Definition at line 87 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:

◆ makeInference()

template<GUM_Numeric GUM_SCALAR>
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 632 of file graphicalModelInference_tpl.h.

632 {
633 if (isInferenceDone()) { return; }
634
636
638
640 }
virtual void prepareInference() final
prepare the internal inference structures for the next inference
virtual bool isInferenceDone() const noexcept final
returns whether the inference object is in a InferenceDone state
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

References Done, isInferenceDone(), isInferenceReady(), makeInference_(), prepareInference(), and setState_().

Referenced by gum::Counterfactual< GUM_ELEMENT >::counterFactualModel(), gum::Counterfactual< GUM_ELEMENT >::counterFactualModel(), gum::counterfactualModel(), gum::ASTjointProba< GUM_SCALAR >::eval(), gum::ASTposteriorProba< GUM_SCALAR >::eval(), 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<GUM_Numeric 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:

◆ meanVar() [1/2]

template<GUM_Numeric GUM_SCALAR>
virtual std::pair< GUM_SCALAR, GUM_SCALAR > gum::InfluenceDiagramInference< GUM_SCALAR >::meanVar ( NodeId node)
pure virtual

Implemented in gum::ShaferShenoyLIMIDInference< GUM_SCALAR >.

References meanVar().

Referenced by meanVar(), and meanVar().

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

◆ meanVar() [2/2]

template<GUM_Numeric GUM_SCALAR>
virtual std::pair< GUM_SCALAR, GUM_SCALAR > gum::InfluenceDiagramInference< GUM_SCALAR >::meanVar ( std::string_view nodename)
pure virtual

Implemented in gum::ShaferShenoyLIMIDInference< GUM_SCALAR >.

References meanVar().

Here is the call graph for this function:

◆ MEU()

template<GUM_Numeric GUM_SCALAR>
virtual std::pair< GUM_SCALAR, GUM_SCALAR > gum::InfluenceDiagramInference< GUM_SCALAR >::MEU ( )
pure virtual

Implemented in gum::ShaferShenoyLIMIDInference< GUM_SCALAR >.

References MEU().

Referenced by MEU().

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

◆ model()

template<GUM_Numeric GUM_SCALAR>
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 127 of file graphicalModelInference_tpl.h.

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

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:

◆ nbrEvidence()

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

returns the number of evidence entered into the Bayesian network

Definition at line 556 of file graphicalModelInference_tpl.h.

556 {
557 return _evidence_.size();
558 }

References _evidence_.

◆ nbrHardEvidence()

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

returns the number of hard evidence entered into the Bayesian network

Definition at line 562 of file graphicalModelInference_tpl.h.

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

References _hard_evidence_nodes_.

◆ nbrSoftEvidence()

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

returns the number of soft evidence entered into the Bayesian network

Definition at line 568 of file graphicalModelInference_tpl.h.

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

References _soft_evidence_nodes_.

◆ onAllEvidenceErased_()

template<GUM_Numeric 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:

◆ onEvidenceAdded_()

template<GUM_Numeric 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<GUM_Numeric 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<GUM_Numeric 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:

◆ onModelChanged_()

template<GUM_Numeric GUM_SCALAR>
virtual void gum::GraphicalModelInference< GUM_SCALAR >::onModelChanged_ ( const GraphicalModel * model)
protectedpure virtualinherited

fired after a new Bayes net has been assigned to the engine

Implemented in gum::JointTargetedInference< GUM_SCALAR >, gum::JointTargetedMRFInference< GUM_SCALAR >, gum::LazyPropagation< GUM_SCALAR >, gum::LoopyBeliefPropagation< GUM_SCALAR >, gum::MarginalTargetedInference< GUM_SCALAR >, gum::MarginalTargetedMRFInference< GUM_SCALAR >, gum::SamplingInference< GUM_SCALAR >, gum::ShaferShenoyInference< GUM_SCALAR >, gum::ShaferShenoyLIMIDInference< GUM_SCALAR >, gum::ShaferShenoyMRFInference< GUM_SCALAR >, and gum::VariableElimination< GUM_SCALAR >.

References model(), and onModelChanged_().

Referenced by onModelChanged_(), and setModel_().

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

◆ onStateChanged_()

template<GUM_Numeric 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:

◆ optimalDecision() [1/2]

template<GUM_Numeric GUM_SCALAR>
virtual gum::Tensor< GUM_SCALAR > gum::InfluenceDiagramInference< GUM_SCALAR >::optimalDecision ( NodeId decisionId)
pure virtual

Implemented in gum::ShaferShenoyLIMIDInference< GUM_SCALAR >.

References optimalDecision().

Referenced by optimalDecision(), and optimalDecision().

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

◆ optimalDecision() [2/2]

template<GUM_Numeric GUM_SCALAR>
virtual gum::Tensor< GUM_SCALAR > gum::InfluenceDiagramInference< GUM_SCALAR >::optimalDecision ( std::string_view nodename)
pure virtual

Implemented in gum::ShaferShenoyLIMIDInference< GUM_SCALAR >.

References optimalDecision().

Here is the call graph for this function:

◆ posterior() [1/2]

template<GUM_Numeric GUM_SCALAR>
virtual const Tensor< GUM_SCALAR > & gum::InfluenceDiagramInference< GUM_SCALAR >::posterior ( NodeId node)
pure virtual

Implemented in gum::ShaferShenoyLIMIDInference< GUM_SCALAR >.

References posterior().

Referenced by posterior(), and posterior().

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

◆ posterior() [2/2]

template<GUM_Numeric GUM_SCALAR>
virtual const Tensor< GUM_SCALAR > & gum::InfluenceDiagramInference< GUM_SCALAR >::posterior ( std::string_view nodename)
pure virtual

Implemented in gum::ShaferShenoyLIMIDInference< GUM_SCALAR >.

References posterior().

Here is the call graph for this function:

◆ posteriorUtility() [1/2]

template<GUM_Numeric GUM_SCALAR>
virtual const Tensor< GUM_SCALAR > & gum::InfluenceDiagramInference< GUM_SCALAR >::posteriorUtility ( NodeId node)
pure virtual

Implemented in gum::ShaferShenoyLIMIDInference< GUM_SCALAR >.

References posteriorUtility().

Referenced by posteriorUtility(), and posteriorUtility().

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

◆ posteriorUtility() [2/2]

template<GUM_Numeric GUM_SCALAR>
virtual const Tensor< GUM_SCALAR > & gum::InfluenceDiagramInference< GUM_SCALAR >::posteriorUtility ( std::string_view nodename)
pure virtual

Implemented in gum::ShaferShenoyLIMIDInference< GUM_SCALAR >.

References posteriorUtility().

Here is the call graph for this function:

◆ prepareInference()

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

prepare the internal inference structures for the next inference

Definition at line 616 of file graphicalModelInference_tpl.h.

616 {
617 if (isInferenceReady() || isInferenceDone()) { return; }
618
619 if (_model_ == nullptr)
621 "No model been assigned to the "
622 "inference algorithm");
623
626
628 }
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:

◆ setInfluenceDiagram()

template<GUM_Numeric GUM_SCALAR>
virtual void gum::InfluenceDiagramInference< GUM_SCALAR >::setInfluenceDiagram ( const InfluenceDiagram< GUM_SCALAR > * infdiag)
virtual

assigns a new influence diagram to the inference engine

Assigns a new influence diagram to the inference engine and sends messages to the descendants of ShaferShenoyLIMIDInference to inform them that the ID has changed.

Warning
note that, by aGrUM's rule, the influence Diagram is not copied into the inference engine but only referenced.

◆ setModel_()

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

Definition at line 137 of file graphicalModelInference_tpl.h.

137 {
138 clear();
139 _model_ = model;
143 }
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<GUM_Numeric GUM_SCALAR>
void gum::GraphicalModelInference< GUM_SCALAR >::setModelDuringConstruction_ ( const GraphicalModel * model)
protectedinherited

assigns a model during the inference engine construction

Definition at line 147 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:

◆ setOutdatedStructureState_()

template<GUM_Numeric GUM_SCALAR>
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 603 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<GUM_Numeric GUM_SCALAR>
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 610 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<GUM_Numeric GUM_SCALAR>
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 118 of file graphicalModelInference_tpl.h.

118 {
119 if (_state_ != state) {
120 _state_ = state;
122 }
123 }
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:

◆ softEvidenceNodes()

template<GUM_Numeric GUM_SCALAR>
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 587 of file graphicalModelInference_tpl.h.

587 {
589 }

References _soft_evidence_nodes_.

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

Here is the caller graph for this function:

◆ state()

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

returns the state of the inference engine

Definition at line 112 of file graphicalModelInference_tpl.h.

112 {
113 return _state_;
114 }

References _state_.

Referenced by setState_().

Here is the caller graph for this function:

◆ updateOutdatedStructure_()

template<GUM_Numeric 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<GUM_Numeric 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<GUM_Numeric 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<GUM_Numeric 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<GUM_Numeric 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<GUM_Numeric 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<GUM_Numeric GUM_SCALAR>
const GraphicalModel* gum::GraphicalModelInference< GUM_SCALAR >::_model_ {nullptr}
privateinherited

◆ _soft_evidence_nodes_

template<GUM_Numeric 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<GUM_Numeric GUM_SCALAR>
StateOfInference gum::GraphicalModelInference< GUM_SCALAR >::_state_ {StateOfInference::OutdatedStructure}
privateinherited

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