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

Implementation of Shafer-Shenoy's propagation algorithm for inference in Bayesian networks. More...

#include <agrum/BN/inference/ShaferShenoyInference.h>

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

Public Types

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

Public Member Functions

Tensor< GUM_SCALAR > evidenceJointImpact (const NodeSet &targets, const NodeSet &evs)
 Create a gum::Tensor for P(joint targets|evs) (for all instantiation of targets and evs).
Tensor< GUM_SCALAR > evidenceJointImpact (const std::vector< std::string > &targets, const std::vector< std::string > &evs)
 Create a gum::Tensor for P(joint targets|evs) (for all instantiation of targets and evs).
Tensor< GUM_SCALAR > evidenceImpact (NodeId target, const NodeSet &evs)
 Create a gum::Tensor for P(target|evs) (for all instantiation of target and evs).
Tensor< GUM_SCALAR > evidenceImpact (std::string_view target, const std::vector< std::string > &evs)
 Create a gum::Tensor for P(target|evs) (for all instantiation of target and evs).
Constructors / Destructors
 ShaferShenoyInference (const IBayesNet< GUM_SCALAR > *BN, RelevantTensorsFinderType=RelevantTensorsFinderType::DSEP_BAYESBALL_TENSORS, FindBarrenNodesType barren_type=FindBarrenNodesType::FIND_BARREN_NODES, bool use_binary_join_tree=true)
 default constructor
 ShaferShenoyInference (const ShaferShenoyInference< GUM_SCALAR > &)=delete
 avoid copy constructors
ShaferShenoyInference< GUM_SCALAR > & operator= (const ShaferShenoyInference< GUM_SCALAR > &)=delete
 avoid copy operators
 ~ShaferShenoyInference () override
 destructor
Accessors / Modifiers
void setTriangulation (const Triangulation &new_triangulation)
 use a new triangulation algorithm
void setRelevantTensorsFinderType (RelevantTensorsFinderType type)
 sets how we determine the relevant tensors to combine
void setFindBarrenNodesType (FindBarrenNodesType type)
 sets how we determine barren nodes
const JoinTreejoinTree ()
 returns the current join tree used
const JunctionTreejunctionTree ()
 returns the current junction tree
GUM_SCALAR evidenceProbability () final
 returns the probability of evidence
Probability computations
virtual const Tensor< GUM_SCALAR > & jointPosterior (const NodeSet &nodes) final
 Compute the joint posterior of a set of nodes.
const Tensor< GUM_SCALAR > & posterior (NodeId node) final
 Computes and returns the posterior of a node.
const Tensor< GUM_SCALAR > & posterior (std::string_view nodeName) final
 Computes and returns the posterior of a node.
Targets
void eraseAllTargets () override
 Clear all previously defined targets (marginal and joint targets).
virtual void eraseAllJointTargets () final
 Clear all previously defined joint targets.
virtual void eraseAllMarginalTargets () final
 Clear all the previously defined marginal targets.
virtual void addJointTarget (const NodeSet &joint_target) final
 Add a set of nodes as a new joint target. As a collateral effect, every node is added as a marginal target.
virtual void eraseJointTarget (const NodeSet &joint_target) final
 removes an existing joint target
virtual bool isJointTarget (const NodeSet &vars) const final
 return true if target is a joint target.
virtual const Set< NodeSet > & jointTargets () const noexcept final
 returns the list of joint targets
virtual Size nbrJointTargets () const noexcept final
 returns the number of joint targets
Information Theory related functions
GUM_SCALAR I (NodeId X, NodeId Y)
 Mutual information between X and Y.
GUM_SCALAR I (std::string_view Xname, std::string_view Yname)
 Mutual information between X and Y.
GUM_SCALAR VI (NodeId X, NodeId Y)
 Variation of information between X and Y.
GUM_SCALAR VI (std::string_view Xname, std::string_view Yname)
 Variation of information between X and Y.
GUM_SCALAR jointMutualInformation (const NodeSet &targets)
 Mutual information between targets.
GUM_SCALAR jointMutualInformation (const std::vector< std::string > &targets)
 Mutual information between targets.
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 (std::string_view 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 (std::string_view 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 (std::string_view 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
virtual bool isInTargetMode () const noexcept final
 indicates whether the inference is in a target mode
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 (std::string_view nodeName) final
 Entropy Compute Shanon's entropy of a node given the observation.
Accessors / Modifiers
virtual void setBN (const IBayesNet< GUM_SCALAR > *bn)
 assigns a new BN to the inference engine
virtual const IBayesNet< GUM_SCALAR > & BN () const final
 Returns a constant reference over the IBayesNet referenced by this class.
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
Constructors / Destructors
virtual ScheduledInferenceclone () const
 virtual copy constructor
Accessors/Modifiers
Schedulerscheduler () const
 returns the current scheduler
void setNumberOfThreads (Size nb) final
 sets the number max of threads that can be used
void setMaxMemory (double megabytes)
 sets an upper bound on the memory consumption admissible
virtual double maxMemory () const
 returns the Max memory (in megabytes) available for executing schedules
Accessors/Modifiers
Size getNumberOfThreads () const override
 returns the current max number of threads used by the class containing this ThreadNumberManager
bool isGumNumberOfThreadsOverriden () const override
 indicates whether the class containing this ThreadNumberManager set its own number of threads

Protected Member Functions

void onEvidenceAdded_ (const NodeId id, bool isHardEvidence) final
 fired after a new evidence is inserted
void onEvidenceErased_ (const NodeId id, bool isHardEvidence) final
 fired before an evidence is removed
void onAllEvidenceErased_ (bool has_hard_evidence) final
 fired before all the evidence are erased
void onEvidenceChanged_ (const NodeId id, bool hasChangedSoftHard) final
 fired after an evidence is changed, in particular when its status (soft/hard) changes
void onMarginalTargetAdded_ (const NodeId id) final
 fired after a new single target is inserted
void onMarginalTargetErased_ (const NodeId id) final
 fired before a single target is removed
void onModelChanged_ (const GraphicalModel *bn) final
 fired after a new Bayes net has been assigned to the inference engine
void onJointTargetAdded_ (const NodeSet &set) final
 fired after a new joint target is inserted
void onJointTargetErased_ (const NodeSet &set) final
 fired before a joint target is removed
void onAllMarginalTargetsAdded_ () final
 fired after all the nodes of the BN are added as single targets
void onAllMarginalTargetsErased_ () final
 fired before all the single targets are removed
void onAllJointTargetsErased_ () final
 fired before all the joint targets are removed
void onAllTargetsErased_ () final
 fired before all single and joint targets are removed
void onStateChanged_ () final
 fired when the state of the inference engine is changed
void updateOutdatedStructure_ () final
 prepares inference when the latter is in OutdatedStructure state
void updateOutdatedTensors_ () final
 prepares inference when the latter is in OutdatedTensors state
void makeInference_ () final
 called when the inference has to be performed effectively
const Tensor< GUM_SCALAR > & posterior_ (NodeId id) final
 returns the posterior of a given variable
const Tensor< GUM_SCALAR > & jointPosterior_ (const NodeSet &set) final
 returns the posterior of a declared target set
const Tensor< GUM_SCALAR > & jointPosterior_ (const NodeSet &wanted_target, const NodeSet &declared_target) final
 asks derived classes for the joint posterior of a set of variables not declared as a joint target
Tensor< GUM_SCALAR > * unnormalizedJointPosterior_ (NodeId id) final
 returns a fresh tensor equal to P(argument,evidence)
Tensor< GUM_SCALAR > * unnormalizedJointPosterior_ (const NodeSet &set) final
 returns a fresh tensor equal to P(argument,evidence)
void setTargetedMode_ ()
bool isTargetedMode_ () const
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 Types

enum  EvidenceChangeType { EVIDENCE_ADDED , EVIDENCE_ERASED , EVIDENCE_MODIFIED }
 the possible types of evidence changes More...
using _TensorSet_ = Set< const Tensor< GUM_SCALAR >* >
using _ScheduleMultiDimSet_ = Set< const IScheduleMultiDim* >
using _TensorSetIterator_ = SetIteratorSafe< const Tensor< GUM_SCALAR >* >

Private Member Functions

bool _isNewJTNeeded_ () const
 check whether a new join tree is really needed for the next inference
void _createNewJT_ ()
 create a new junction tree as well as its related data structures
void _initializeJTCliques_ (Schedule &schedule)
 put all the CPTs into the cliques when creating the JT using a schedule
void _initializeJTCliques_ ()
 put all the CPTs into the cliques when creating the JT without using a schedule
void _setProjectionFunction_ (Tensor< GUM_SCALAR >(*proj)(const Tensor< GUM_SCALAR > &, const gum::VariableSet &))
 sets the operator for performing the projections
void _setCombinationFunction_ (Tensor< GUM_SCALAR >(*comb)(const Tensor< GUM_SCALAR > &, const Tensor< GUM_SCALAR > &))
 sets the operator for performing the combinations
void _diffuseMessageInvalidations_ (NodeId from_id, NodeId to_id, NodeSet &invalidated_cliques)
 invalidate all the messages sent from a given clique
void _invalidateAllMessages_ ()
 invalidate all messages, posteriors and created tensors
void _computeJoinTreeRoots_ ()
 compute a root for each connected component of JT
void _findRelevantTensorsWithdSeparation_ (_ScheduleMultiDimSet_ &pot_list, gum::VariableSet &kept_vars)
 update a set of tensors: the remaining are those to be combined to produce a message on a separator
void _findRelevantTensorsWithdSeparation2_ (_ScheduleMultiDimSet_ &pot_list, gum::VariableSet &kept_vars)
 update a set of tensors: the remaining are those to be combined to produce a message on a separator
void _findRelevantTensorsWithdSeparation3_ (_ScheduleMultiDimSet_ &pot_list, gum::VariableSet &kept_vars)
 update a set of tensors: the remaining are those to be combined to produce a message on a separator
void _findRelevantTensorsGetAll_ (_ScheduleMultiDimSet_ &pot_list, gum::VariableSet &kept_vars)
 update a set of tensors: the remaining are those to be combined to produce a message on a separator
void _findRelevantTensorsXX_ (_ScheduleMultiDimSet_ &pot_list, gum::VariableSet &kept_vars)
 update a set of tensors: the remaining are those to be combined to produce a message on a separator
_ScheduleMultiDimSet_ _removeBarrenVariables_ (Schedule &schedule, _ScheduleMultiDimSet_ &pot_list, gum::VariableSet &del_vars)
 remove barren variables and return the newly created projected tensors
_TensorSet_ _removeBarrenVariables_ (_TensorSet_ &pot_list, gum::VariableSet &del_vars)
 remove barren variables without schedules and return the newly created projected tensors
const IScheduleMultiDim_marginalizeOut_ (Schedule &schedule, _ScheduleMultiDimSet_ pot_list, gum::VariableSet &del_vars, gum::VariableSet &kept_vars)
 removes variables del_vars from a list of tensors and returns the resulting list using schedules
const IScheduleMultiDim_marginalizeOut_ (_ScheduleMultiDimSet_ &pot_list, gum::VariableSet &del_vars, gum::VariableSet &kept_vars)
 removes variables del_vars from a list of tensors and returns the resulting list directly without schedules
void _produceMessage_ (Schedule &schedule, NodeId from_id, NodeId to_id)
 creates the message sent by clique from_id to clique to_id using schedules
void _produceMessage_ (NodeId from_id, NodeId to_id)
 creates the message sent by clique from_id to clique to_id without schedules
void _collectMessage_ (Schedule &schedule, NodeId id, NodeId from)
 perform the collect phase using schedules
void _collectMessage_ (NodeId id, NodeId from)
 actually perform the collect phase directly without schedules
Tensor< GUM_SCALAR > * _unnormalizedJointPosterior_ (Schedule &schedule, NodeId id)
 computes the unnormalized posterior of a node using schedules
Tensor< GUM_SCALAR > * _unnormalizedJointPosterior_ (NodeId id)
 computes the unnormalized posterior of a node without using schedules
Tensor< GUM_SCALAR > * _unnormalizedJointPosterior_ (Schedule &schedule, const NodeSet &set)
 returns a fresh tensor equal to P(argument,evidence) using schedules
Tensor< GUM_SCALAR > * _unnormalizedJointPosterior_ (const NodeSet &set)
 returns a fresh tensor equal to P(argument,evidence) without using schedules
void _setAllMarginalTargets_ ()
 sets all the nodes of the Bayes net as targets

Private Attributes

RelevantTensorsFinderType _find_relevant_tensor_type_
 the type of relevant tensor finding algorithm to be used
void(ShaferShenoyInference< GUM_SCALAR >::* _findRelevantTensors_ )(Set< const IScheduleMultiDim * > &pot_list, gum::VariableSet &kept_vars)
 update a set of tensors: the remaining are those to be combined to produce a message on a separator
FindBarrenNodesType _barren_nodes_type_ {FindBarrenNodesType::FIND_BARREN_NODES}
 the type of barren nodes computation we wish
Tensor< GUM_SCALAR >(* _projection_op_ )(const Tensor< GUM_SCALAR > &, const gum::VariableSet &) = SSNewprojTensor
 the operator for performing the projections
Tensor< GUM_SCALAR >(* _combination_op_ )(const Tensor< GUM_SCALAR > &, const Tensor< GUM_SCALAR > &) = SSNewmultiTensor
 the operator for performing the combinations
Triangulation_triangulation_
 the triangulation class creating the junction tree used for inference
bool _use_binary_join_tree_ {true}
 indicates whether we should transform junction trees into binary join trees
UndiGraph _graph_
 the undigraph extracted from the BN and used to construct the join tree
JoinTree_JT_ {nullptr}
 the join (or junction) tree used to answer the last inference query
JunctionTree_junctionTree_ {nullptr}
 the junction tree to answer the last inference query
bool _is_new_jt_needed_ {true}
 indicates whether a new join tree is needed for the next inference
NodeSet _roots_
 a clique node used as a root in each connected component of JT
NodeProperty< NodeId_node_to_clique_
 for each node of graph (~ in the Bayes net), associate an ID in the JT
HashTable< NodeSet, NodeId_joint_target_to_clique_
 for each set target, assign a clique in the JT that contains it
NodeProperty< _ScheduleMultiDimSet__clique_tensors_
 the list of all tensors stored in the cliques
NodeProperty< const IScheduleMultiDim * > _clique_ss_tensor_
 the tensors stored into the cliques by Shafer-Shenoy
ArcProperty< const IScheduleMultiDim * > _separator_tensors_
 the list of all tensors stored in the separators after inferences
ArcProperty< const IScheduleMultiDim * > _arc_to_created_tensors_
 the set of tensors created for the last inference messages
NodeProperty< const Tensor< GUM_SCALAR > * > _target_posteriors_
 the set of single posteriors computed during the last inference
HashTable< NodeSet, const Tensor< GUM_SCALAR > * > _joint_target_posteriors_
 the set of set target posteriors computed during the last inference
NodeProperty< GUM_SCALAR > _constants_
 the constants resulting from the projections of CPTs defined over only hard evidence nodes @TODO remove this constant and insert the notion of a constant into tensors/multidim arrays
ArcProperty< bool_messages_computed_
 indicates whether a message (from one clique to another) has been computed
NodeProperty< const IScheduleMultiDim * > _node_to_soft_evidence_
 the soft evidence stored in the cliques per their assigned node in the BN
NodeProperty< const IScheduleMultiDim * > _node_to_hard_ev_projected_CPTs_
 the CPTs that were projected due to hard evidence nodes
NodeSet _hard_ev_nodes_
 the hard evidence nodes which were projected in CPTs
NodeProperty< EvidenceChangeType_evidence_changes_
 indicates which nodes of the BN have evidence that changed since the last inference
bool _use_schedules_ {false}
 indicates whether we should use schedules for inference
Set< NodeSet_joint_targets_
 the set of joint targets
bool _targeted_mode_
 whether the actual targets are default
NodeSet _targets_
 the set of marginal targets
SchedulerParallel _scheduler_parallel_
SchedulerSequential _scheduler_sequential_
Size _nb_threads_ {0}
 the max number of threads used by the class

Static Private Attributes

static constexpr double _schedule_threshold_ {1000000.0}
 minimal number of operations to perform in the JT to use schedules
static constexpr GUM_SCALAR _one_minus_epsilon_ {GUM_SCALAR(1.0 - 1e-6)}
 for comparisons with 1 - epsilon

Detailed Description

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

Implementation of Shafer-Shenoy's propagation algorithm for inference in Bayesian networks.

Definition at line 84 of file ShaferShenoyInference.h.

Member Typedef Documentation

◆ _ScheduleMultiDimSet_

template<GUM_Numeric GUM_SCALAR>
using gum::ShaferShenoyInference< GUM_SCALAR >::_ScheduleMultiDimSet_ = Set< const IScheduleMultiDim* >
private

Definition at line 259 of file ShaferShenoyInference.h.

◆ _TensorSet_

template<GUM_Numeric GUM_SCALAR>
using gum::ShaferShenoyInference< GUM_SCALAR >::_TensorSet_ = Set< const Tensor< GUM_SCALAR >* >
private

Definition at line 258 of file ShaferShenoyInference.h.

◆ _TensorSetIterator_

template<GUM_Numeric GUM_SCALAR>
using gum::ShaferShenoyInference< GUM_SCALAR >::_TensorSetIterator_ = SetIteratorSafe< const Tensor< GUM_SCALAR >* >
private

Definition at line 261 of file ShaferShenoyInference.h.

Member Enumeration Documentation

◆ EvidenceChangeType

template<GUM_Numeric GUM_SCALAR>
enum gum::ShaferShenoyInference::EvidenceChangeType
private

the possible types of evidence changes

Enumerator
EVIDENCE_ADDED 
EVIDENCE_ERASED 
EVIDENCE_MODIFIED 

Definition at line 399 of file ShaferShenoyInference.h.

◆ 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

◆ ShaferShenoyInference() [1/2]

template<GUM_Numeric GUM_SCALAR>
gum::ShaferShenoyInference< GUM_SCALAR >::ShaferShenoyInference ( const IBayesNet< GUM_SCALAR > * BN,
RelevantTensorsFinderType = RelevantTensorsFinderType::DSEP_BAYESBALL_TENSORS,
FindBarrenNodesType barren_type = FindBarrenNodesType::FIND_BARREN_NODES,
bool use_binary_join_tree = true )
explicit

default constructor

References gum::BayesNetInference< GUM_SCALAR >::BN(), gum::DSEP_BAYESBALL_TENSORS, and gum::FIND_BARREN_NODES.

Referenced by ShaferShenoyInference(), and operator=().

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

◆ ShaferShenoyInference() [2/2]

template<GUM_Numeric GUM_SCALAR>
gum::ShaferShenoyInference< GUM_SCALAR >::ShaferShenoyInference ( const ShaferShenoyInference< GUM_SCALAR > & )
delete

avoid copy constructors

References ShaferShenoyInference().

Here is the call graph for this function:

◆ ~ShaferShenoyInference()

template<GUM_Numeric GUM_SCALAR>
gum::ShaferShenoyInference< GUM_SCALAR >::~ShaferShenoyInference ( )
override

destructor

Member Function Documentation

◆ _collectMessage_() [1/2]

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::_collectMessage_ ( NodeId id,
NodeId from )
private

actually perform the collect phase directly without schedules

◆ _collectMessage_() [2/2]

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::_collectMessage_ ( Schedule & schedule,
NodeId id,
NodeId from )
private

perform the collect phase using schedules

◆ _computeJoinTreeRoots_()

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::_computeJoinTreeRoots_ ( )
private

compute a root for each connected component of JT

◆ _createNewJT_()

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::_createNewJT_ ( )
private

create a new junction tree as well as its related data structures

◆ _diffuseMessageInvalidations_()

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::_diffuseMessageInvalidations_ ( NodeId from_id,
NodeId to_id,
NodeSet & invalidated_cliques )
private

invalidate all the messages sent from a given clique

◆ _findRelevantTensorsGetAll_()

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::_findRelevantTensorsGetAll_ ( _ScheduleMultiDimSet_ & pot_list,
gum::VariableSet & kept_vars )
private

update a set of tensors: the remaining are those to be combined to produce a message on a separator

◆ _findRelevantTensorsWithdSeparation2_()

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::_findRelevantTensorsWithdSeparation2_ ( _ScheduleMultiDimSet_ & pot_list,
gum::VariableSet & kept_vars )
private

update a set of tensors: the remaining are those to be combined to produce a message on a separator

◆ _findRelevantTensorsWithdSeparation3_()

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::_findRelevantTensorsWithdSeparation3_ ( _ScheduleMultiDimSet_ & pot_list,
gum::VariableSet & kept_vars )
private

update a set of tensors: the remaining are those to be combined to produce a message on a separator

◆ _findRelevantTensorsWithdSeparation_()

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::_findRelevantTensorsWithdSeparation_ ( _ScheduleMultiDimSet_ & pot_list,
gum::VariableSet & kept_vars )
private

update a set of tensors: the remaining are those to be combined to produce a message on a separator

◆ _findRelevantTensorsXX_()

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::_findRelevantTensorsXX_ ( _ScheduleMultiDimSet_ & pot_list,
gum::VariableSet & kept_vars )
private

update a set of tensors: the remaining are those to be combined to produce a message on a separator

◆ _initializeJTCliques_() [1/2]

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::_initializeJTCliques_ ( )
private

put all the CPTs into the cliques when creating the JT without using a schedule

◆ _initializeJTCliques_() [2/2]

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::_initializeJTCliques_ ( Schedule & schedule)
private

put all the CPTs into the cliques when creating the JT using a schedule

◆ _invalidateAllMessages_()

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::_invalidateAllMessages_ ( )
private

invalidate all messages, posteriors and created tensors

◆ _isNewJTNeeded_()

template<GUM_Numeric GUM_SCALAR>
bool gum::ShaferShenoyInference< GUM_SCALAR >::_isNewJTNeeded_ ( ) const
private

check whether a new join tree is really needed for the next inference

◆ _marginalizeOut_() [1/2]

template<GUM_Numeric GUM_SCALAR>
const IScheduleMultiDim * gum::ShaferShenoyInference< GUM_SCALAR >::_marginalizeOut_ ( _ScheduleMultiDimSet_ & pot_list,
gum::VariableSet & del_vars,
gum::VariableSet & kept_vars )
private

removes variables del_vars from a list of tensors and returns the resulting list directly without schedules

◆ _marginalizeOut_() [2/2]

template<GUM_Numeric GUM_SCALAR>
const IScheduleMultiDim * gum::ShaferShenoyInference< GUM_SCALAR >::_marginalizeOut_ ( Schedule & schedule,
_ScheduleMultiDimSet_ pot_list,
gum::VariableSet & del_vars,
gum::VariableSet & kept_vars )
private

removes variables del_vars from a list of tensors and returns the resulting list using schedules

◆ _produceMessage_() [1/2]

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::_produceMessage_ ( NodeId from_id,
NodeId to_id )
private

creates the message sent by clique from_id to clique to_id without schedules

◆ _produceMessage_() [2/2]

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::_produceMessage_ ( Schedule & schedule,
NodeId from_id,
NodeId to_id )
private

creates the message sent by clique from_id to clique to_id using schedules

◆ _removeBarrenVariables_() [1/2]

template<GUM_Numeric GUM_SCALAR>
_TensorSet_ gum::ShaferShenoyInference< GUM_SCALAR >::_removeBarrenVariables_ ( _TensorSet_ & pot_list,
gum::VariableSet & del_vars )
private

remove barren variables without schedules and return the newly created projected tensors

◆ _removeBarrenVariables_() [2/2]

template<GUM_Numeric GUM_SCALAR>
_ScheduleMultiDimSet_ gum::ShaferShenoyInference< GUM_SCALAR >::_removeBarrenVariables_ ( Schedule & schedule,
_ScheduleMultiDimSet_ & pot_list,
gum::VariableSet & del_vars )
private

remove barren variables and return the newly created projected tensors

◆ _setAllMarginalTargets_()

template<GUM_Numeric GUM_SCALAR>
void gum::MarginalTargetedInference< GUM_SCALAR >::_setAllMarginalTargets_ ( )
privateinherited

sets all the nodes of the Bayes net as targets

Definition at line 232 of file marginalTargetedInference_tpl.h.

232 {
233 _targets_.clear();
234 if (!this->hasNoModel_()) {
235 _targets_ = this->BN().internalDag().asNodeSet();
237 }
238 }
virtual const IBayesNet< GUM_SCALAR > & BN() const final
Returns a constant reference over the IBayesNet referenced by this class.
NodeSet _targets_
the set of marginal targets
virtual void onAllMarginalTargetsAdded_()=0
fired after all the nodes of the BN are added as marginal targets

References _targets_, gum::BayesNetInference< GUM_SCALAR >::BN(), gum::GraphicalModelInference< GUM_SCALAR >::hasNoModel_(), and onAllMarginalTargetsAdded_().

Referenced by onModelChanged_().

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

◆ _setCombinationFunction_()

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::_setCombinationFunction_ ( Tensor< GUM_SCALAR >(* comb )(const Tensor< GUM_SCALAR > &, const Tensor< GUM_SCALAR > &))
private

sets the operator for performing the combinations

◆ _setProjectionFunction_()

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::_setProjectionFunction_ ( Tensor< GUM_SCALAR >(* proj )(const Tensor< GUM_SCALAR > &, const gum::VariableSet &))
private

sets the operator for performing the projections

◆ _unnormalizedJointPosterior_() [1/4]

template<GUM_Numeric GUM_SCALAR>
Tensor< GUM_SCALAR > * gum::ShaferShenoyInference< GUM_SCALAR >::_unnormalizedJointPosterior_ ( const NodeSet & set)
private

returns a fresh tensor equal to P(argument,evidence) without using schedules

◆ _unnormalizedJointPosterior_() [2/4]

template<GUM_Numeric GUM_SCALAR>
Tensor< GUM_SCALAR > * gum::ShaferShenoyInference< GUM_SCALAR >::_unnormalizedJointPosterior_ ( NodeId id)
private

computes the unnormalized posterior of a node without using schedules

◆ _unnormalizedJointPosterior_() [3/4]

template<GUM_Numeric GUM_SCALAR>
Tensor< GUM_SCALAR > * gum::ShaferShenoyInference< GUM_SCALAR >::_unnormalizedJointPosterior_ ( Schedule & schedule,
const NodeSet & set )
private

returns a fresh tensor equal to P(argument,evidence) using schedules

◆ _unnormalizedJointPosterior_() [4/4]

template<GUM_Numeric GUM_SCALAR>
Tensor< GUM_SCALAR > * gum::ShaferShenoyInference< GUM_SCALAR >::_unnormalizedJointPosterior_ ( Schedule & schedule,
NodeId id )
private

computes the unnormalized posterior of a node using schedules

◆ addAllTargets()

template<GUM_Numeric GUM_SCALAR>
void gum::MarginalTargetedInference< GUM_SCALAR >::addAllTargets ( )
finalvirtualinherited

adds all nodes as targets

Definition at line 147 of file marginalTargetedInference_tpl.h.

147 {
148 // check if the node belongs to the Bayesian network
149 if (this->hasNoModel_())
151 "No Bayes net has been assigned to the "
152 "inference algorithm");
153
154
155 setTargetedMode_(); // does nothing if already in targeted mode
156 for (const auto target: this->BN().internalDag()) {
157 if (!_targets_.contains(target)) {
158 _targets_.insert(target);
161 }
162 }
163 }
virtual void setState_(const StateOfInference state) final
set the state of the inference engine and call the notification onStateChanged_ when necessary (i....
<agrum/BN/inference/marginalTargetedInference.h>
virtual void onMarginalTargetAdded_(const NodeId id)=0
fired after a new marginal target is inserted
#define GUM_ERROR(type, msg)
Definition exceptions.h:76

References _targets_, gum::BayesNetInference< GUM_SCALAR >::BN(), GUM_ERROR, gum::GraphicalModelInference< GUM_SCALAR >::hasNoModel_(), 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<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 }
<agrum/base/graphicalModels/graphicalModel.h>
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 }
const GraphicalModel * _model_
the Bayes net on which we perform inferences

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

◆ addJointTarget()

template<GUM_Numeric GUM_SCALAR>
void gum::JointTargetedInference< GUM_SCALAR >::addJointTarget ( const NodeSet & joint_target)
finalvirtualinherited

Add a set of nodes as a new joint target. As a collateral effect, every node is added as a marginal target.

Exceptions
UndefinedElementif some node(s) do not belong to the Bayes net

Definition at line 127 of file jointTargetedInference_tpl.h.

127 {
128 // check if the nodes in the target belong to the Bayesian network
129 if (this->hasNoModel_())
131 "No Bayes net has been assigned to the "
132 "inference algorithm");
133
134 const auto& dag = this->BN().internalDag();
135 for (const auto node: joint_target) {
136 if (!dag.exists(node)) {
138 "at least one one in " << joint_target << " does not belong to the bn");
139 }
140 }
141
142 // check that the joint_target set does not contain the new target
143 if (_joint_targets_.contains(joint_target)) return;
144
145 // check if joint_target is a subset of an already existing target
146 for (const auto& target: _joint_targets_) {
147 if (target.isStrictSupersetOf(joint_target)) return;
148 }
149
150 // check if joint_target is not a superset of an already existing target
151 // in this case, we need to remove old existing target
152 for (auto iter = _joint_targets_.beginSafe(); iter != _joint_targets_.endSafe(); ++iter) {
153 if (iter->isStrictSubsetOf(joint_target)) eraseJointTarget(*iter);
154 }
155
156 this->setTargetedMode_(); // does nothing if already in targeted mode
160 }
<agrum/BN/inference/jointTargetedInference.h>
Set< NodeSet > _joint_targets_
the set of joint targets
virtual void onJointTargetAdded_(const NodeSet &set)=0
fired after a new joint target is inserted
virtual void eraseJointTarget(const NodeSet &joint_target) final
removes an existing joint target

References _joint_targets_, gum::BayesNetInference< GUM_SCALAR >::BN(), eraseJointTarget(), GUM_ERROR, gum::GraphicalModelInference< GUM_SCALAR >::hasNoModel_(), onJointTargetAdded_(), gum::GraphicalModelInference< GUM_SCALAR >::OutdatedStructure, gum::GraphicalModelInference< GUM_SCALAR >::setState_(), and gum::MarginalTargetedInference< GUM_SCALAR >::setTargetedMode_().

Referenced by gum::ASTjointProba< GUM_SCALAR >::eval(), gum::ASTposteriorProba< GUM_SCALAR >::eval(), evidenceJointImpact(), and jointMutualInformation().

Here is the call graph for this function:
Here is the caller 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:

◆ addTarget() [1/2]

template<GUM_Numeric GUM_SCALAR>
void gum::MarginalTargetedInference< GUM_SCALAR >::addTarget ( NodeId target)
finalvirtualinherited

Add a marginal target to the list of targets.

Exceptions
UndefinedElementif target is not a NodeId in the Bayes net

Definition at line 125 of file marginalTargetedInference_tpl.h.

125 {
126 // check if the node belongs to the Bayesian network
127 if (this->hasNoModel_())
129 "No Bayes net has been assigned to the "
130 "inference algorithm");
131
132 if (!this->BN().internalDag().exists(target)) {
133 GUM_ERROR(UndefinedElement, target << " is not a NodeId in the bn")
134 }
135
136 setTargetedMode_(); // does nothing if already in targeted mode
137 // add the new target
138 if (!_targets_.contains(target)) {
139 _targets_.insert(target);
142 }
143 }

References _targets_, gum::BayesNetInference< GUM_SCALAR >::BN(), GUM_ERROR, gum::GraphicalModelInference< GUM_SCALAR >::hasNoModel_(), onMarginalTargetAdded_(), gum::GraphicalModelInference< GUM_SCALAR >::OutdatedStructure, gum::GraphicalModelInference< GUM_SCALAR >::setState_(), and setTargetedMode_().

Referenced by addTarget(), gum::ASTjointProba< GUM_SCALAR >::eval(), and evidenceImpact().

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

◆ addTarget() [2/2]

template<GUM_Numeric GUM_SCALAR>
void gum::MarginalTargetedInference< GUM_SCALAR >::addTarget ( std::string_view nodeName)
finalvirtualinherited

Add a marginal target to the list of targets.

Exceptions
UndefinedElementif target is not a NodeId in the Bayes net

Definition at line 167 of file marginalTargetedInference_tpl.h.

167 {
168 // check if the node belongs to the Bayesian network
169 if (this->hasNoModel_())
171 "No Bayes net has been assigned to the "
172 "inference algorithm");
173
175 }
virtual void addTarget(NodeId target) final
Add a marginal target to the list of targets.

References addTarget(), gum::BayesNetInference< GUM_SCALAR >::BN(), GUM_ERROR, and gum::GraphicalModelInference< GUM_SCALAR >::hasNoModel_().

Here is the call graph for this function:

◆ BN()

template<GUM_Numeric GUM_SCALAR>
const IBayesNet< GUM_SCALAR > & gum::BayesNetInference< GUM_SCALAR >::BN ( ) 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 76 of file BayesNetInference_tpl.h.

76 {
77 return static_cast< const IBayesNet< GUM_SCALAR >& >(this->model());
78 }
<agrum/BN/inference/BayesNetInference.h>

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

Referenced by gum::LazyPropagation< GUM_SCALAR >::LazyPropagation(), gum::ShaferShenoyInference< GUM_SCALAR >::ShaferShenoyInference(), gum::VariableElimination< GUM_SCALAR >::VariableElimination(), gum::MarginalTargetedInference< GUM_SCALAR >::_setAllMarginalTargets_(), gum::MarginalTargetedInference< GUM_SCALAR >::addAllTargets(), gum::JointTargetedInference< GUM_SCALAR >::addJointTarget(), gum::MarginalTargetedInference< GUM_SCALAR >::addTarget(), gum::MarginalTargetedInference< GUM_SCALAR >::addTarget(), gum::SamplingInference< GUM_SCALAR >::contextualize(), gum::SamplingInference< GUM_SCALAR >::currentPosterior(), gum::SamplingInference< GUM_SCALAR >::currentPosterior(), gum::ImportanceSampling< GUM_SCALAR >::draw_(), gum::MonteCarloSampling< GUM_SCALAR >::draw_(), gum::WeightedSampling< GUM_SCALAR >::draw_(), gum::JointTargetedInference< GUM_SCALAR >::eraseJointTarget(), gum::MarginalTargetedInference< GUM_SCALAR >::eraseTarget(), gum::MarginalTargetedInference< GUM_SCALAR >::eraseTarget(), gum::MarginalTargetedInference< GUM_SCALAR >::evidenceImpact(), gum::MarginalTargetedInference< GUM_SCALAR >::evidenceImpact(), gum::JointTargetedInference< GUM_SCALAR >::evidenceJointImpact(), gum::JointTargetedInference< GUM_SCALAR >::evidenceJointImpact(), gum::MarginalTargetedInference< GUM_SCALAR >::H(), gum::JointTargetedInference< GUM_SCALAR >::isJointTarget(), gum::MarginalTargetedInference< GUM_SCALAR >::isTarget(), gum::MarginalTargetedInference< GUM_SCALAR >::isTarget(), gum::JointTargetedInference< GUM_SCALAR >::jointMutualInformation(), gum::JointTargetedInference< GUM_SCALAR >::jointMutualInformation(), gum::JointTargetedInference< GUM_SCALAR >::posterior(), gum::MarginalTargetedInference< GUM_SCALAR >::posterior(), gum::SamplingInference< GUM_SCALAR >::posterior_(), gum::SamplingInference< GUM_SCALAR >::samplingBN(), and gum::Estimator< GUM_SCALAR >::setFromLBP().

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:

◆ clone()

ScheduledInference * gum::ScheduledInference::clone ( ) const
nodiscardvirtualinherited

virtual copy constructor

Definition at line 104 of file scheduledInference.cpp.

104{ return new ScheduledInference(*this); }
ScheduledInference(Size max_nb_threads=0, double max_megabyte_memory=0.0)
default constructor

References ScheduledInference().

Here is the call 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 }
NodeProperty< Size > _domain_sizes_
the domain sizes of the random variables

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:

◆ eraseAllJointTargets()

template<GUM_Numeric GUM_SCALAR>
void gum::JointTargetedInference< GUM_SCALAR >::eraseAllJointTargets ( )
finalvirtualinherited

Clear all previously defined joint targets.

Definition at line 109 of file jointTargetedInference_tpl.h.

109 {
110 if (_joint_targets_.size() > 0) {
111 // we already are in target mode. So no this->setTargetedMode_(); is needed
113 _joint_targets_.clear();
115 }
116 }
virtual void onAllJointTargetsErased_()=0
fired before a all the joint targets are removed

References _joint_targets_, onAllJointTargetsErased_(), gum::GraphicalModelInference< GUM_SCALAR >::OutdatedStructure, and gum::GraphicalModelInference< GUM_SCALAR >::setState_().

Referenced by eraseAllTargets().

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

◆ eraseAllMarginalTargets()

template<GUM_Numeric GUM_SCALAR>
void gum::JointTargetedInference< GUM_SCALAR >::eraseAllMarginalTargets ( )
finalvirtualinherited

Clear all the previously defined marginal targets.

Definition at line 103 of file jointTargetedInference_tpl.h.

103 {
105 }
virtual void eraseAllTargets()
Clear all previously defined targets.

References gum::MarginalTargetedInference< GUM_SCALAR >::eraseAllTargets().

Referenced by eraseAllTargets().

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

◆ eraseAllTargets()

template<GUM_Numeric GUM_SCALAR>
void gum::JointTargetedInference< GUM_SCALAR >::eraseAllTargets ( )
overridevirtualinherited

Clear all previously defined targets (marginal and joint targets).

Clear all previously defined targets. As a result, no posterior can be computed (since we can only compute the posteriors of the marginal or joint targets that have been added by the user).

Reimplemented from gum::MarginalTargetedInference< GUM_SCALAR >.

Definition at line 120 of file jointTargetedInference_tpl.h.

120 {
123 }
virtual void eraseAllMarginalTargets() final
Clear all the previously defined marginal targets.
virtual void eraseAllJointTargets() final
Clear all previously defined joint targets.

References eraseAllJointTargets(), and eraseAllMarginalTargets().

Referenced by evidenceJointImpact(), and 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:

◆ eraseJointTarget()

template<GUM_Numeric GUM_SCALAR>
void gum::JointTargetedInference< GUM_SCALAR >::eraseJointTarget ( const NodeSet & joint_target)
finalvirtualinherited

removes an existing joint target

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

Definition at line 164 of file jointTargetedInference_tpl.h.

164 {
165 // check if the nodes in the target belong to the Bayesian network
166 if (this->hasNoModel_())
168 "No Bayes net has been assigned to the "
169 "inference algorithm");
170
171 const auto& dag = this->BN().internalDag();
172 for (const auto node: joint_target) {
173 if (!dag.exists(node)) {
175 "at least one one in " << joint_target << " does not belong to the bn");
176 }
177 }
178
179 // check that the joint_target set does not contain the new target
180 if (_joint_targets_.contains(joint_target)) {
181 // note that we have to be in target mode when we are here
182 // so, no this->setTargetedMode_(); is necessary
186 }
187 }
virtual void onJointTargetErased_(const NodeSet &set)=0
fired before a joint target is removed

References _joint_targets_, gum::BayesNetInference< GUM_SCALAR >::BN(), GUM_ERROR, gum::GraphicalModelInference< GUM_SCALAR >::hasNoModel_(), onJointTargetErased_(), gum::GraphicalModelInference< GUM_SCALAR >::OutdatedStructure, and gum::GraphicalModelInference< GUM_SCALAR >::setState_().

Referenced by addJointTarget().

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

◆ eraseTarget() [1/2]

template<GUM_Numeric GUM_SCALAR>
void gum::MarginalTargetedInference< GUM_SCALAR >::eraseTarget ( NodeId target)
finalvirtualinherited

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 179 of file marginalTargetedInference_tpl.h.

179 {
180 // check if the node belongs to the Bayesian network
181 if (this->hasNoModel_())
183 "No Bayes net has been assigned to the "
184 "inference algorithm");
185
186 if (!this->BN().internalDag().exists(target)) {
187 GUM_ERROR(UndefinedElement, target << " is not a NodeId in the bn")
188 }
189
190
191 if (_targets_.contains(target)) {
192 _targeted_mode_ = true; // we do not use setTargetedMode_ because we do not
193 // want to clear the targets
195 _targets_.erase(target);
197 }
198 }
virtual void onMarginalTargetErased_(const NodeId id)=0
fired before a marginal target is removed
bool _targeted_mode_
whether the actual targets are default

References _targeted_mode_, _targets_, gum::BayesNetInference< GUM_SCALAR >::BN(), GUM_ERROR, gum::GraphicalModelInference< GUM_SCALAR >::hasNoModel_(), 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:

◆ eraseTarget() [2/2]

template<GUM_Numeric GUM_SCALAR>
void gum::MarginalTargetedInference< GUM_SCALAR >::eraseTarget ( std::string_view nodeName)
finalvirtualinherited

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 202 of file marginalTargetedInference_tpl.h.

202 {
203 // check if the node belongs to the Bayesian network
204 if (this->hasNoModel_())
206 "No Bayes net has been assigned to the "
207 "inference algorithm");
208
210 }
virtual void eraseTarget(NodeId target) final
removes an existing (marginal) target

References gum::BayesNetInference< GUM_SCALAR >::BN(), eraseTarget(), GUM_ERROR, and gum::GraphicalModelInference< GUM_SCALAR >::hasNoModel_().

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:

◆ evidenceImpact() [1/2]

template<GUM_Numeric GUM_SCALAR>
Tensor< GUM_SCALAR > gum::MarginalTargetedInference< GUM_SCALAR >::evidenceImpact ( NodeId target,
const NodeSet & evs )
inherited

Create a gum::Tensor for P(target|evs) (for all instantiation of target and evs).

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

Definition at line 283 of file marginalTargetedInference_tpl.h.

284 {
285 const auto& vtarget = this->BN().variable(target);
286
287 if (evs.contains(target)) {
289 "Target <" << vtarget.name() << "> (" << target << ") can not be in evs (" << evs
290 << ").");
291 }
292 auto condset = this->BN().minimalCondSet(target, evs);
293
295 this->eraseAllTargets();
296 this->eraseAllEvidence();
297 res.add(this->BN().variable(target));
298 this->addTarget(target);
299 for (const auto& n: condset) {
300 res.add(this->BN().variable(n));
301 this->addEvidence(n, 0);
302 }
303
305 for (inst.setFirst(); !inst.end(); inst.incNotVar(vtarget)) {
306 // inferring
307 for (const auto& n: condset)
308 this->chgEvidence(n, inst.val(this->BN().variable(n)));
309 this->makeInference();
310 // populate res
311 const auto& pot = this->posterior(target);
312 for (inst.setFirstVar(vtarget); !inst.end(); inst.incVar(vtarget)) {
313 res.set(inst, pot[inst]);
314 }
315 inst.setFirstVar(vtarget); // remove inst.end() flag
316 }
317
318 return res;
319 }
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.

References gum::GraphicalModelInference< GUM_SCALAR >::addEvidence(), addTarget(), gum::BayesNetInference< GUM_SCALAR >::BN(), 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(), 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:

◆ evidenceImpact() [2/2]

template<GUM_Numeric GUM_SCALAR>
Tensor< GUM_SCALAR > gum::MarginalTargetedInference< GUM_SCALAR >::evidenceImpact ( std::string_view target,
const std::vector< std::string > & evs )
inherited

Create a gum::Tensor for P(target|evs) (for all instantiation 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 322 of file marginalTargetedInference_tpl.h.

324 {
325 const auto& bn = this->BN();
326 return evidenceImpact(bn.idFromName(target), bn.nodeset(evs));
327 }
Tensor< GUM_SCALAR > evidenceImpact(NodeId target, const NodeSet &evs)
Create a gum::Tensor for P(target|evs) (for all instantiation of target and evs).

References gum::BayesNetInference< GUM_SCALAR >::BN(), and evidenceImpact().

Here is the call graph for this function:

◆ evidenceJointImpact() [1/2]

template<GUM_Numeric GUM_SCALAR>
Tensor< GUM_SCALAR > gum::JointTargetedInference< GUM_SCALAR >::evidenceJointImpact ( const NodeSet & targets,
const NodeSet & evs )
inherited

Create a gum::Tensor for P(joint targets|evs) (for all instantiation of targets and evs).

Warning
If some evs are d-separated, they are not included in the Tensor
Parameters
targetsthe NodeSet of the targeted variables
evsthe NodeSet of observed variables
Returns
a Tensor

Definition at line 253 of file jointTargetedInference_tpl.h.

254 {
255 if (!(evs * targets).empty()) {
257 "Targets (" << targets << ") can not intersect evs (" << evs << ").");
258 }
259 auto condset = this->BN().minimalCondSet(targets, evs);
260
261 this->eraseAllTargets();
262 this->eraseAllEvidence();
263
266 for (const auto& target: targets) {
267 res.add(this->BN().variable(target));
268 iTarget.add(this->BN().variable(target));
269 }
270 this->addJointTarget(targets);
271
272 for (const auto& n: condset) {
273 res.add(this->BN().variable(n));
274 this->addEvidence(n, 0);
275 }
276
278 for (inst.setFirstOut(iTarget); !inst.end(); inst.incOut(iTarget)) {
279 // inferring
280 for (const auto& n: condset)
281 this->chgEvidence(n, inst.val(this->BN().variable(n)));
282 this->makeInference();
283 // populate res
284 for (inst.setFirstIn(iTarget); !inst.end(); inst.incIn(iTarget)) {
285 res.set(inst, this->jointPosterior(targets)[inst]);
286 }
287 inst.setFirstIn(iTarget); // remove inst.end() flag
288 }
289
290 return res;
291 }
virtual void addJointTarget(const NodeSet &joint_target) final
Add a set of nodes as a new joint target. As a collateral effect, every node is added as a marginal t...
void eraseAllTargets() override
Clear all previously defined targets (marginal and joint targets).
virtual const Tensor< GUM_SCALAR > & jointPosterior(const NodeSet &nodes) final
Compute the joint posterior of a set of nodes.
virtual const NodeSet & targets() const noexcept final
returns the list of marginal targets

References gum::Instantiation::add(), gum::GraphicalModelInference< GUM_SCALAR >::addEvidence(), addJointTarget(), gum::BayesNetInference< GUM_SCALAR >::BN(), gum::GraphicalModelInference< GUM_SCALAR >::chgEvidence(), gum::Instantiation::end(), gum::GraphicalModelInference< GUM_SCALAR >::eraseAllEvidence(), eraseAllTargets(), GUM_ERROR, gum::Instantiation::incIn(), gum::Instantiation::incOut(), jointPosterior(), gum::GraphicalModelInference< GUM_SCALAR >::makeInference(), gum::Instantiation::setFirstIn(), gum::Instantiation::setFirstOut(), gum::MarginalTargetedInference< GUM_SCALAR >::targets(), and gum::Instantiation::val().

Referenced by gum::ASTposteriorProba< GUM_SCALAR >::eval(), and evidenceJointImpact().

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

◆ evidenceJointImpact() [2/2]

template<GUM_Numeric GUM_SCALAR>
Tensor< GUM_SCALAR > gum::JointTargetedInference< GUM_SCALAR >::evidenceJointImpact ( const std::vector< std::string > & targets,
const std::vector< std::string > & evs )
inherited

Create a gum::Tensor for P(joint targets|evs) (for all instantiation of targets and evs).

Warning
If some evs are d-separated, they are not included in the Tensor
Parameters
targetsthe vector of std::string of the targeted variables
evsthe vector of std::string of observed variables
Returns
a Tensor

Definition at line 294 of file jointTargetedInference_tpl.h.

296 {
297 const auto& bn = this->BN();
298 return evidenceJointImpact(bn.nodeset(targets), bn.nodeset(evs));
299 }
Tensor< GUM_SCALAR > evidenceJointImpact(const NodeSet &targets, const NodeSet &evs)
Create a gum::Tensor for P(joint targets|evs) (for all instantiation of targets and evs).

References gum::BayesNetInference< GUM_SCALAR >::BN(), evidenceJointImpact(), and gum::MarginalTargetedInference< GUM_SCALAR >::targets().

Here is the call graph for this function:

◆ evidenceProbability()

template<GUM_Numeric GUM_SCALAR>
GUM_SCALAR gum::ShaferShenoyInference< GUM_SCALAR >::evidenceProbability ( )
finalvirtual

returns the probability of evidence

Implements gum::EvidenceInference< GUM_SCALAR >.

◆ getNumberOfThreads()

Size gum::ThreadNumberManager::getNumberOfThreads ( ) const
nodiscardoverridevirtualinherited

◆ H() [1/2]

template<GUM_Numeric GUM_SCALAR>
GUM_SCALAR gum::MarginalTargetedInference< GUM_SCALAR >::H ( NodeId X)
finalvirtualinherited

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

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

Definition at line 270 of file marginalTargetedInference_tpl.h.

270 {
271 return posterior(X).entropy();
272 }

References posterior().

Referenced by H().

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

◆ H() [2/2]

template<GUM_Numeric GUM_SCALAR>
GUM_SCALAR gum::MarginalTargetedInference< GUM_SCALAR >::H ( std::string_view nodeName)
finalvirtualinherited

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

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

Definition at line 278 of file marginalTargetedInference_tpl.h.

278 {
279 return H(this->BN().idFromName(nodeName));
280 }
virtual GUM_SCALAR H(NodeId X) final
Entropy Compute Shanon's entropy of a node given the observation.

References gum::BayesNetInference< GUM_SCALAR >::BN(), and H().

Here is the call 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:

◆ I() [1/2]

template<GUM_Numeric GUM_SCALAR>
GUM_SCALAR gum::JointTargetedInference< GUM_SCALAR >::I ( NodeId X,
NodeId Y )
inherited

Mutual information between X and Y.

See also
http://en.wikipedia.org/wiki/Mutual_information
Warning
Due to limitation of joint, may not be able to compute this value
Exceptions
OperationNotAllowedin these cases

◆ I() [2/2]

template<GUM_Numeric GUM_SCALAR>
GUM_SCALAR gum::JointTargetedInference< GUM_SCALAR >::I ( std::string_view Xname,
std::string_view Yname )
inherited

Mutual information between X and Y.

See also
http://en.wikipedia.org/wiki/Mutual_information
Warning
Due to limitation of joint, may not be able to compute this value
Exceptions
OperationNotAllowedin these cases

◆ isGumNumberOfThreadsOverriden()

bool gum::ThreadNumberManager::isGumNumberOfThreadsOverriden ( ) const
nodiscardoverridevirtualinherited

indicates whether the class containing this ThreadNumberManager set its own number of threads

Implements gum::IThreadNumberManager.

Referenced by gum::learning::IBNLearner::createParamEstimator_(), and gum::learning::IBNLearner::createScore_().

Here is the caller graph for this function:

◆ 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:

◆ isInTargetMode()

template<GUM_Numeric GUM_SCALAR>
bool gum::MarginalTargetedInference< GUM_SCALAR >::isInTargetMode ( ) const
finalvirtualnoexceptinherited

indicates whether the inference is in a target mode

Definition at line 226 of file marginalTargetedInference_tpl.h.

226 {
227 return _targeted_mode_;
228 }

References _targeted_mode_.

◆ isJointTarget()

template<GUM_Numeric GUM_SCALAR>
bool gum::JointTargetedInference< GUM_SCALAR >::isJointTarget ( const NodeSet & vars) const
finalvirtualinherited

return true if target is a joint target.

Definition at line 87 of file jointTargetedInference_tpl.h.

87 {
88 if (this->hasNoModel_())
90 "No Bayes net has been assigned to the "
91 "inference algorithm");
92
93 const auto& dag = this->BN().internalDag();
94 for (const auto var: vars) {
95 if (!dag.exists(var)) { GUM_ERROR(UndefinedElement, var << " is not a NodeId in the bn") }
96 }
97
98 return _joint_targets_.contains(vars);
99 }

References _joint_targets_, gum::BayesNetInference< GUM_SCALAR >::BN(), GUM_ERROR, and gum::GraphicalModelInference< GUM_SCALAR >::hasNoModel_().

Here is the call graph for this function:

◆ isTarget() [1/2]

template<GUM_Numeric GUM_SCALAR>
bool gum::MarginalTargetedInference< GUM_SCALAR >::isTarget ( NodeId node) const
finalvirtualinherited

return true if variable is a (marginal) target

Definition at line 93 of file marginalTargetedInference_tpl.h.

93 {
94 // check that the variable belongs to the bn
95 if (this->hasNoModel_())
97 "No Bayes net has been assigned to the "
98 "inference algorithm");
99 if (!this->BN().internalDag().exists(node)) {
100 GUM_ERROR(UndefinedElement, node << " is not a NodeId in the bn")
101 }
102
103 return _targets_.contains(node);
104 }

References _targets_, gum::BayesNetInference< GUM_SCALAR >::BN(), GUM_ERROR, and gum::GraphicalModelInference< GUM_SCALAR >::hasNoModel_().

Referenced by isTarget(), gum::JointTargetedInference< GUM_SCALAR >::posterior(), and posterior().

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

◆ isTarget() [2/2]

template<GUM_Numeric GUM_SCALAR>
bool gum::MarginalTargetedInference< GUM_SCALAR >::isTarget ( std::string_view nodeName) const
finalvirtualinherited

return true if variable is a (marginal) target

Definition at line 108 of file marginalTargetedInference_tpl.h.

108 {
109 return isTarget(this->BN().idFromName(nodeName));
110 }
virtual bool isTarget(NodeId node) const final
return true if variable is a (marginal) target

References gum::BayesNetInference< GUM_SCALAR >::BN(), and isTarget().

Here is the call graph for this function:

◆ isTargetedMode_()

template<GUM_Numeric GUM_SCALAR>
bool gum::MarginalTargetedInference< GUM_SCALAR >::isTargetedMode_ ( ) const
protectedinherited

Definition at line 330 of file marginalTargetedInference_tpl.h.

330 {
331 return _targeted_mode_;
332 }

References _targeted_mode_.

◆ jointMutualInformation() [1/2]

template<GUM_Numeric GUM_SCALAR>
GUM_SCALAR gum::JointTargetedInference< GUM_SCALAR >::jointMutualInformation ( const NodeSet & targets)
inherited

Mutual information between targets.

See also
https://en.wikipedia.org/wiki/Interaction_information
Parameters
targetsthe NodeSet of the targeted variables

Definition at line 302 of file jointTargetedInference_tpl.h.

302 {
303 const auto& bn = this->BN();
304 const Size siz = targets.size();
305 if (siz <= 1) {
307 "jointMutualInformation needs at least 2 variables (targets=" << targets << ")");
308 }
309
310 this->eraseAllTargets();
311 this->eraseAllEvidence();
312 this->addJointTarget(targets);
313 this->makeInference();
314 const auto po = this->jointPosterior(targets);
315
318 for (const auto nod: targets) {
319 const auto& var = bn.variable(nod);
320 auto pv = new gum::RangeVariable(var.name(), "", 0, 1);
321 caracteristic.add(*pv);
322 variables.add(var);
323 }
324
326
327 const GUM_SCALAR start = (siz % 2 == 0) ? GUM_SCALAR(-1.0) : GUM_SCALAR(1.0);
330
331 caracteristic.setFirst();
332 for (caracteristic.inc(); !caracteristic.end(); caracteristic.inc()) {
333 sov.clear();
334 sign = start;
335 for (Idx i = 0; i < caracteristic.nbrDim(); i++) {
336 if (caracteristic.val(i) == 1) {
337 sign = -sign;
338 sov.insert(&variables.variable(i));
339 }
340 }
341 res += sign * po.sumIn(sov).entropy();
342 }
343
344 for (Idx i = 0; i < caracteristic.nbrDim(); i++) {
345 delete &caracteristic.variable(i);
346 }
347
348 return res;
349 }
virtual void clear()
clears all the data structures allocated for the last inference

References gum::Instantiation::add(), addJointTarget(), gum::BayesNetInference< GUM_SCALAR >::BN(), gum::Set< Key >::clear(), gum::Instantiation::end(), gum::GraphicalModelInference< GUM_SCALAR >::eraseAllEvidence(), eraseAllTargets(), GUM_ERROR, gum::Instantiation::inc(), gum::Set< Key >::insert(), jointPosterior(), gum::GraphicalModelInference< GUM_SCALAR >::makeInference(), gum::Instantiation::nbrDim(), gum::Instantiation::setFirst(), gum::MarginalTargetedInference< GUM_SCALAR >::targets(), gum::Instantiation::val(), and gum::Instantiation::variable().

Referenced by jointMutualInformation().

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

◆ jointMutualInformation() [2/2]

template<GUM_Numeric GUM_SCALAR>
GUM_SCALAR gum::JointTargetedInference< GUM_SCALAR >::jointMutualInformation ( const std::vector< std::string > & targets)
inherited

Mutual information between targets.

See also
https://en.wikipedia.org/wiki/Interaction_information
Parameters
targetsthe vector of std::string of the targeted variables

Definition at line 352 of file jointTargetedInference_tpl.h.

353 {
354 return jointMutualInformation(this->BN().ids(targets));
355 }
GUM_SCALAR jointMutualInformation(const NodeSet &targets)
Mutual information between targets.

References gum::BayesNetInference< GUM_SCALAR >::BN(), jointMutualInformation(), and gum::MarginalTargetedInference< GUM_SCALAR >::targets().

Here is the call graph for this function:

◆ jointPosterior()

template<GUM_Numeric GUM_SCALAR>
const Tensor< GUM_SCALAR > & gum::JointTargetedInference< GUM_SCALAR >::jointPosterior ( const NodeSet & nodes)
finalvirtualinherited

Compute the joint posterior of a set of nodes.

Returns
a const ref to the posterior joint probability of the set of nodes.
Parameters
nodesthe set of nodes whose posterior joint probability is wanted
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.
Exceptions
UndefinedElementif nodes is not in the targets

Definition at line 208 of file jointTargetedInference_tpl.h.

208 {
209 // try to get the smallest set of targets that contains "nodes"
210 NodeSet set;
211 bool found_exact_target = false;
212
213 if (_joint_targets_.contains(nodes)) {
214 set = nodes;
215 found_exact_target = true;
216 } else {
217 for (const auto& target: _joint_targets_) {
218 if (nodes.isStrictSubsetOf(target)) {
219 set = target;
220 break;
221 }
222 }
223 }
224
225 // if (set.empty()) {
226 // GUM_ERROR(UndefinedElement,
227 // " no joint target containing " << nodes << " could be found among "
228 // << _joint_targets_);
229 // }
230
231 if (!this->isInferenceDone()) { this->makeInference(); }
232
233 if (found_exact_target || set.empty()) return jointPosterior_(nodes);
234 else return jointPosterior_(nodes, set);
235 }
virtual bool isInferenceDone() const noexcept final
returns whether the inference object is in a InferenceDone state
virtual const Tensor< GUM_SCALAR > & jointPosterior_(const NodeSet &set)=0
asks derived classes for the joint posterior of a declared target set

References _joint_targets_, gum::Set< Key >::empty(), gum::GraphicalModelInference< GUM_SCALAR >::isInferenceDone(), gum::Set< Key >::isStrictSubsetOf(), jointPosterior_(), and gum::GraphicalModelInference< GUM_SCALAR >::makeInference().

Referenced by gum::ASTjointProba< GUM_SCALAR >::eval(), gum::ASTposteriorProba< GUM_SCALAR >::eval(), evidenceJointImpact(), jointMutualInformation(), and posterior().

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

◆ jointPosterior_() [1/2]

template<GUM_Numeric GUM_SCALAR>
const Tensor< GUM_SCALAR > & gum::ShaferShenoyInference< GUM_SCALAR >::jointPosterior_ ( const NodeSet & set)
finalprotectedvirtual

returns the posterior of a declared target set

Parameters
setThe set of ids of the variables whose joint posterior is looked for.

Implements gum::JointTargetedInference< GUM_SCALAR >.

References jointPosterior_().

Referenced by jointPosterior_(), and jointPosterior_().

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

◆ jointPosterior_() [2/2]

template<GUM_Numeric GUM_SCALAR>
const Tensor< GUM_SCALAR > & gum::ShaferShenoyInference< GUM_SCALAR >::jointPosterior_ ( const NodeSet & wanted_target,
const NodeSet & declared_target )
finalprotectedvirtual

asks derived classes for the joint posterior of a set of variables not declared as a joint target

Parameters
wanted_targetThe set of ids of the variables whose joint posterior is looked for.
declared_targetthe joint target declared by the user that contains set

Implements gum::JointTargetedInference< GUM_SCALAR >.

References jointPosterior_().

Here is the call graph for this function:

◆ joinTree()

template<GUM_Numeric GUM_SCALAR>
const JoinTree * gum::ShaferShenoyInference< GUM_SCALAR >::joinTree ( )

returns the current join tree used

ShaferShenoy does not use a junction tree but a binary join tree because this may enable faster inferences. So do not be surprised to see that some cliques are contained into others in this tree.

◆ jointTargets()

template<GUM_Numeric GUM_SCALAR>
const Set< NodeSet > & gum::JointTargetedInference< GUM_SCALAR >::jointTargets ( ) const
finalvirtualnoexceptinherited

returns the list of joint targets

returns the list of target sets

Definition at line 191 of file jointTargetedInference_tpl.h.

191 {
192 return _joint_targets_;
193 }

References _joint_targets_.

◆ junctionTree()

template<GUM_Numeric GUM_SCALAR>
const JunctionTree * gum::ShaferShenoyInference< GUM_SCALAR >::junctionTree ( )

returns the current junction tree

ShaferShenoy does not use a junction tree but a binary join tree because this may enable faster inferences. This method return the junction tree, before optimizations

◆ 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 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>
void gum::ShaferShenoyInference< GUM_SCALAR >::makeInference_ ( )
finalprotectedvirtual

called when the inference has to be performed effectively

Once the inference is done, fillPosterior_ can be called.

Implements gum::GraphicalModelInference< GUM_SCALAR >.

References makeInference_().

Referenced by makeInference_().

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

◆ maxMemory()

INLINE double gum::ScheduledInference::maxMemory ( ) const
virtualinherited

returns the Max memory (in megabytes) available for executing schedules

Returns
the Max memory (in megabytes) available for executing schedules. 0 means an unlimited amount of memory

Definition at line 69 of file scheduledInference_inl.h.

69{ return _scheduler_parallel_.maxMemory(); }
SchedulerParallel _scheduler_parallel_

References _scheduler_parallel_.

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

◆ nbrJointTargets()

template<GUM_Numeric GUM_SCALAR>
Size gum::JointTargetedInference< GUM_SCALAR >::nbrJointTargets ( ) const
finalvirtualnoexceptinherited

returns the number of joint targets

returns the number of target sets

Definition at line 197 of file jointTargetedInference_tpl.h.

197 {
198 return _joint_targets_.size();
199 }

References _joint_targets_.

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

◆ nbrTargets()

template<GUM_Numeric GUM_SCALAR>
Size gum::MarginalTargetedInference< GUM_SCALAR >::nbrTargets ( ) const
finalvirtualnoexceptinherited

returns the number of marginal targets

Definition at line 220 of file marginalTargetedInference_tpl.h.

220 {
221 return _targets_.size();
222 }

References _targets_.

◆ onAllEvidenceErased_()

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::onAllEvidenceErased_ ( bool has_hard_evidence)
finalprotectedvirtual

fired before all the evidence are erased

Implements gum::GraphicalModelInference< GUM_SCALAR >.

References onAllEvidenceErased_().

Referenced by onAllEvidenceErased_().

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

◆ onAllJointTargetsErased_()

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::onAllJointTargetsErased_ ( )
finalprotectedvirtual

fired before all the joint targets are removed

Implements gum::JointTargetedInference< GUM_SCALAR >.

References onAllJointTargetsErased_().

Referenced by onAllJointTargetsErased_().

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

◆ onAllMarginalTargetsAdded_()

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::onAllMarginalTargetsAdded_ ( )
finalprotectedvirtual

fired after all the nodes of the BN are added as single targets

Implements gum::MarginalTargetedInference< GUM_SCALAR >.

References onAllMarginalTargetsAdded_().

Referenced by onAllMarginalTargetsAdded_().

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

◆ onAllMarginalTargetsErased_()

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::onAllMarginalTargetsErased_ ( )
finalprotectedvirtual

fired before all the single targets are removed

Implements gum::MarginalTargetedInference< GUM_SCALAR >.

References onAllMarginalTargetsErased_().

Referenced by onAllMarginalTargetsErased_().

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

◆ onAllTargetsErased_()

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::onAllTargetsErased_ ( )
finalprotectedvirtual

fired before all single and joint targets are removed

Implements gum::JointTargetedInference< GUM_SCALAR >.

References onAllTargetsErased_().

Referenced by onAllTargetsErased_().

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

◆ onEvidenceAdded_()

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::onEvidenceAdded_ ( const NodeId id,
bool isHardEvidence )
finalprotectedvirtual

fired after a new evidence is inserted

Implements gum::GraphicalModelInference< GUM_SCALAR >.

References onEvidenceAdded_().

Referenced by onEvidenceAdded_().

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

◆ onEvidenceChanged_()

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::onEvidenceChanged_ ( const NodeId id,
bool hasChangedSoftHard )
finalprotectedvirtual

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

Implements gum::GraphicalModelInference< GUM_SCALAR >.

References onEvidenceChanged_().

Referenced by onEvidenceChanged_().

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

◆ onEvidenceErased_()

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::onEvidenceErased_ ( const NodeId id,
bool isHardEvidence )
finalprotectedvirtual

fired before an evidence is removed

Implements gum::GraphicalModelInference< GUM_SCALAR >.

References onEvidenceErased_().

Referenced by onEvidenceErased_().

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

◆ onJointTargetAdded_()

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::onJointTargetAdded_ ( const NodeSet & set)
finalprotectedvirtual

fired after a new joint target is inserted

Parameters
setThe set of target variable's ids.

Implements gum::JointTargetedInference< GUM_SCALAR >.

References onJointTargetAdded_().

Referenced by onJointTargetAdded_().

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

◆ onJointTargetErased_()

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::onJointTargetErased_ ( const NodeSet & set)
finalprotectedvirtual

fired before a joint target is removed

Parameters
setThe set of target variable's ids.

Implements gum::JointTargetedInference< GUM_SCALAR >.

References onJointTargetErased_().

Referenced by onJointTargetErased_().

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

◆ onMarginalTargetAdded_()

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::onMarginalTargetAdded_ ( const NodeId id)
finalprotectedvirtual

fired after a new single target is inserted

Parameters
idThe target variable's id.

Implements gum::MarginalTargetedInference< GUM_SCALAR >.

References onMarginalTargetAdded_().

Referenced by onMarginalTargetAdded_().

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

◆ onMarginalTargetErased_()

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::onMarginalTargetErased_ ( const NodeId id)
finalprotectedvirtual

fired before a single target is removed

Parameters
idThe target variable's id.

Implements gum::MarginalTargetedInference< GUM_SCALAR >.

References onMarginalTargetErased_().

Referenced by onMarginalTargetErased_().

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

◆ onModelChanged_()

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::onModelChanged_ ( const GraphicalModel * bn)
finalprotectedvirtual

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

Reimplemented from gum::JointTargetedInference< GUM_SCALAR >.

References onModelChanged_().

Referenced by onModelChanged_().

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

◆ onStateChanged_()

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::onStateChanged_ ( )
finalprotectedvirtual

fired when the state of the inference engine is changed

Implements gum::GraphicalModelInference< GUM_SCALAR >.

References onStateChanged_().

Referenced by onStateChanged_().

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

◆ operator=()

template<GUM_Numeric GUM_SCALAR>
ShaferShenoyInference< GUM_SCALAR > & gum::ShaferShenoyInference< GUM_SCALAR >::operator= ( const ShaferShenoyInference< GUM_SCALAR > & )
delete

avoid copy operators

References ShaferShenoyInference().

Here is the call graph for this function:

◆ posterior() [1/2]

template<GUM_Numeric GUM_SCALAR>
const Tensor< GUM_SCALAR > & gum::JointTargetedInference< GUM_SCALAR >::posterior ( NodeId node)
finalvirtualinherited

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 from gum::MarginalTargetedInference< GUM_SCALAR >.

Definition at line 239 of file jointTargetedInference_tpl.h.

239 {
241 else return jointPosterior(NodeSet{node});
242 }

References gum::MarginalTargetedInference< GUM_SCALAR >::isTarget(), jointPosterior(), and gum::MarginalTargetedInference< GUM_SCALAR >::posterior().

Referenced by gum::Counterfactual< GUM_ELEMENT >::counterFactualModel(), gum::Counterfactual< GUM_ELEMENT >::counterFactualModel(), gum::counterfactualModel(), gum::ASTjointProba< GUM_SCALAR >::eval(), 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>
const Tensor< GUM_SCALAR > & gum::JointTargetedInference< GUM_SCALAR >::posterior ( std::string_view nodeName)
finalvirtualinherited

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 from gum::MarginalTargetedInference< GUM_SCALAR >.

Definition at line 247 of file jointTargetedInference_tpl.h.

247 {
248 return posterior(this->BN().idFromName(nodeName));
249 }
const Tensor< GUM_SCALAR > & posterior(NodeId node) final
Computes and returns the posterior of a node.

References gum::BayesNetInference< GUM_SCALAR >::BN(), and posterior().

Here is the call graph for this function:

◆ posterior_()

template<GUM_Numeric GUM_SCALAR>
const Tensor< GUM_SCALAR > & gum::ShaferShenoyInference< GUM_SCALAR >::posterior_ ( NodeId id)
finalprotectedvirtual

returns the posterior of a given variable

Parameters
idThe variable's id.

Implements gum::MarginalTargetedInference< GUM_SCALAR >.

References posterior_().

Referenced by posterior_().

Here is the call graph for this function:
Here is the caller 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:

◆ scheduler()

INLINE Scheduler & gum::ScheduledInference::scheduler ( ) const
inherited

returns the current scheduler

Definition at line 49 of file scheduledInference_inl.h.

49 {
51 return const_cast< SchedulerParallel& >(_scheduler_parallel_);
52 else return const_cast< SchedulerSequential& >(_scheduler_sequential_);
53 }
SchedulerSequential _scheduler_sequential_
Size getNumberOfThreads() const override
returns the current max number of threads used by the class containing this ThreadNumberManager

References _scheduler_parallel_, _scheduler_sequential_, and gum::ThreadNumberManager::getNumberOfThreads().

Here is the call graph for this function:

◆ setBN()

template<GUM_Numeric GUM_SCALAR>
void gum::BayesNetInference< GUM_SCALAR >::setBN ( const IBayesNet< GUM_SCALAR > * bn)
virtualinherited

assigns a new BN to the inference engine

Assigns a new BN to the BayesNetInference engine and sends messages to the descendants of BayesNetInference to inform them that the BN has changed.

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

Definition at line 82 of file BayesNetInference_tpl.h.

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

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

Here is the call graph for this function:

◆ setFindBarrenNodesType()

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::setFindBarrenNodesType ( FindBarrenNodesType type)

sets how we determine barren nodes

Barren nodes are unnecessary for probability inference, so they can be safely discarded in this case (type = FIND_BARREN_NODES). This speeds-up inference. However, there are some cases in which we do not want to remove barren nodes, typically when we want to answer queries such as Most Probable Explanations (MPE).

◆ setMaxMemory()

INLINE void gum::ScheduledInference::setMaxMemory ( double megabytes)
inherited

sets an upper bound on the memory consumption admissible

Parameters
megabytesthe number of megabytes that can be used for the execution of the schedule. If this number is equal to 0, then no memory limit is applied.

Definition at line 62 of file scheduledInference_inl.h.

62 {
63 if (megabytes < 0.0) megabytes = 0.0;
64 _scheduler_parallel_.setMaxMemory(megabytes);
65 _scheduler_sequential_.setMaxMemory(megabytes);
66 }

References _scheduler_parallel_, and _scheduler_sequential_.

Referenced by ScheduledInference().

Here is the caller graph for this function:

◆ 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

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:

◆ setNumberOfThreads()

INLINE void gum::ScheduledInference::setNumberOfThreads ( Size nb)
finalvirtualinherited

sets the number max of threads that can be used

Parameters
nbthe number max of threads used for executing schedules. If this number is set to 0, then it is defaulted to aGrUM's number of threads

Implements gum::IThreadNumberManager.

Definition at line 56 of file scheduledInference_inl.h.

56 {
58 _scheduler_parallel_.setNumberOfThreads(nb);
59 }
void setNumberOfThreads(Size nb) override
sets the number max of threads to be used by the class containing this ThreadNumberManager

References _scheduler_parallel_, and gum::ThreadNumberManager::setNumberOfThreads().

Here is the call 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:

◆ setRelevantTensorsFinderType()

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::setRelevantTensorsFinderType ( RelevantTensorsFinderType type)

sets how we determine the relevant tensors to combine

When a clique sends a message to a separator, it first determines the set of the tensors it contains and the tensors contained in the messages it received. If RelevantTensorsFinderType = FIND_ALL, all these tensors are combined and projected to produce the message sent to the separator. If RelevantTensorsFinderType = DSEP_BAYESBALL_NODES, then only the set of tensors d-connected to the variables of the separator are kept for combination and projection.

◆ 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:

◆ setTargetedMode_()

template<GUM_Numeric GUM_SCALAR>
void gum::MarginalTargetedInference< GUM_SCALAR >::setTargetedMode_ ( )
protectedinherited

Definition at line 335 of file marginalTargetedInference_tpl.h.

335 {
336 if (!_targeted_mode_) {
337 _targets_.clear();
338 _targeted_mode_ = true;
339 }
340 }

References _targeted_mode_, and _targets_.

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

Here is the caller graph for this function:

◆ setTriangulation()

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::setTriangulation ( const Triangulation & new_triangulation)

use a new triangulation algorithm

◆ 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:

◆ targets()

◆ unnormalizedJointPosterior_() [1/2]

template<GUM_Numeric GUM_SCALAR>
Tensor< GUM_SCALAR > * gum::ShaferShenoyInference< GUM_SCALAR >::unnormalizedJointPosterior_ ( const NodeSet & set)
finalprotectedvirtual

returns a fresh tensor equal to P(argument,evidence)

Implements gum::JointTargetedInference< GUM_SCALAR >.

References unnormalizedJointPosterior_().

Here is the call graph for this function:

◆ unnormalizedJointPosterior_() [2/2]

template<GUM_Numeric GUM_SCALAR>
Tensor< GUM_SCALAR > * gum::ShaferShenoyInference< GUM_SCALAR >::unnormalizedJointPosterior_ ( NodeId id)
finalprotectedvirtual

returns a fresh tensor equal to P(argument,evidence)

Implements gum::JointTargetedInference< GUM_SCALAR >.

References unnormalizedJointPosterior_().

Referenced by unnormalizedJointPosterior_(), and unnormalizedJointPosterior_().

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

◆ updateOutdatedStructure_()

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::updateOutdatedStructure_ ( )
finalprotectedvirtual

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

Implements gum::GraphicalModelInference< GUM_SCALAR >.

References updateOutdatedStructure_().

Referenced by updateOutdatedStructure_().

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

◆ updateOutdatedTensors_()

template<GUM_Numeric GUM_SCALAR>
void gum::ShaferShenoyInference< GUM_SCALAR >::updateOutdatedTensors_ ( )
finalprotectedvirtual

prepares inference when the latter is in OutdatedTensors state

Note that the values of evidence are not necessarily known and can be changed between updateOutdatedStructure_ and makeInference_.

Implements gum::GraphicalModelInference< GUM_SCALAR >.

References updateOutdatedTensors_().

Referenced by updateOutdatedTensors_().

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

◆ VI() [1/2]

template<GUM_Numeric GUM_SCALAR>
GUM_SCALAR gum::JointTargetedInference< GUM_SCALAR >::VI ( NodeId X,
NodeId Y )
inherited

Variation of information between X and Y.

See also
http://en.wikipedia.org/wiki/Variation_of_information
Warning
Due to limitation of joint, may not be able to compute this value
Exceptions
OperationNotAllowedin these cases

◆ VI() [2/2]

template<GUM_Numeric GUM_SCALAR>
GUM_SCALAR gum::JointTargetedInference< GUM_SCALAR >::VI ( std::string_view Xname,
std::string_view Yname )
inherited

Variation of information between X and Y.

See also
http://en.wikipedia.org/wiki/Variation_of_information
Warning
Due to limitation of joint, may not be able to compute this value
Exceptions
OperationNotAllowedin these cases

References gum::MarginalTargetedInference< GUM_SCALAR >::targets().

Here is the call graph for this function:

Member Data Documentation

◆ _arc_to_created_tensors_

template<GUM_Numeric GUM_SCALAR>
ArcProperty< const IScheduleMultiDim* > gum::ShaferShenoyInference< GUM_SCALAR >::_arc_to_created_tensors_
private

the set of tensors created for the last inference messages

This structure contains some pointer only for the arcs on which a tensor has been created. Arcs for which no tensor was created do not belong to this structure.

Warning
Note that the CPTs that were projected due to hard evidence do not belong to this structure, they are kept in node_to_hard_ev_projected_CPTs.

Definition at line 357 of file ShaferShenoyInference.h.

◆ _barren_nodes_type_

template<GUM_Numeric GUM_SCALAR>
FindBarrenNodesType gum::ShaferShenoyInference< GUM_SCALAR >::_barren_nodes_type_ {FindBarrenNodesType::FIND_BARREN_NODES}
private

the type of barren nodes computation we wish

Definition at line 275 of file ShaferShenoyInference.h.

Implementation of Shafer-Shenoy's propagation algorithm for inference in Bayesian networks.

◆ _clique_ss_tensor_

template<GUM_Numeric GUM_SCALAR>
NodeProperty< const IScheduleMultiDim* > gum::ShaferShenoyInference< GUM_SCALAR >::_clique_ss_tensor_
private

the tensors stored into the cliques by Shafer-Shenoy

For a given clique, there is an entry in clique_ss_tensor even if the clique received no tensor. In this case, the tensor stored is equal to nullptr, else it is equal to the combination of all the corresponding list of tensors in clique_tensors.

Definition at line 342 of file ShaferShenoyInference.h.

◆ _clique_tensors_

template<GUM_Numeric GUM_SCALAR>
NodeProperty< _ScheduleMultiDimSet_ > gum::ShaferShenoyInference< GUM_SCALAR >::_clique_tensors_
private

the list of all tensors stored in the cliques

This structure contains a list for each clique in the join tree. If a clique did not received any tensor, then its list is empty but the entry for the clique does exist. Note that clique tensors contain also soft evidence and the CPTs that were projected to remove their variables that received hard evidence. The product of all these tensors is precisely the tensor stored into clique_ss_tensor

Definition at line 335 of file ShaferShenoyInference.h.

◆ _combination_op_

template<GUM_Numeric GUM_SCALAR>
Tensor< GUM_SCALAR >(* gum::ShaferShenoyInference< GUM_SCALAR >::_combination_op_) (const Tensor< GUM_SCALAR > &, const Tensor< GUM_SCALAR > &) = SSNewmultiTensor
private

the operator for performing the combinations

Definition at line 275 of file ShaferShenoyInference.h.

◆ _constants_

template<GUM_Numeric GUM_SCALAR>
NodeProperty< GUM_SCALAR > gum::ShaferShenoyInference< GUM_SCALAR >::_constants_
private

the constants resulting from the projections of CPTs defined over only hard evidence nodes @TODO remove this constant and insert the notion of a constant into tensors/multidim arrays

Definition at line 371 of file ShaferShenoyInference.h.

◆ _evidence_changes_

template<GUM_Numeric GUM_SCALAR>
NodeProperty< EvidenceChangeType > gum::ShaferShenoyInference< GUM_SCALAR >::_evidence_changes_
private

indicates which nodes of the BN have evidence that changed since the last inference

Definition at line 403 of file ShaferShenoyInference.h.

◆ _find_relevant_tensor_type_

template<GUM_Numeric GUM_SCALAR>
RelevantTensorsFinderType gum::ShaferShenoyInference< GUM_SCALAR >::_find_relevant_tensor_type_
private
Initial value:

the type of relevant tensor finding algorithm to be used

Definition at line 265 of file ShaferShenoyInference.h.

◆ _findRelevantTensors_

template<GUM_Numeric GUM_SCALAR>
void(ShaferShenoyInference< GUM_SCALAR >::* gum::ShaferShenoyInference< GUM_SCALAR >::_findRelevantTensors_) (Set< const IScheduleMultiDim * > &pot_list, gum::VariableSet &kept_vars)
private

update a set of tensors: the remaining are those to be combined to produce a message on a separator

Definition at line 270 of file ShaferShenoyInference.h.

◆ _graph_

template<GUM_Numeric GUM_SCALAR>
UndiGraph gum::ShaferShenoyInference< GUM_SCALAR >::_graph_
private

the undigraph extracted from the BN and used to construct the join tree

If all nodes are targets, this graph corresponds to the moral graph of the BN. Otherwise, it may be a subgraph of this moral graph. For instance if the BN is A->B->C and only B is a target, graph will be equal to A-B if we exploit barren nodes (C is a barren node and, therefore, can be removed for inference).

Definition at line 298 of file ShaferShenoyInference.h.

◆ _hard_ev_nodes_

template<GUM_Numeric GUM_SCALAR>
NodeSet gum::ShaferShenoyInference< GUM_SCALAR >::_hard_ev_nodes_
private

the hard evidence nodes which were projected in CPTs

Definition at line 396 of file ShaferShenoyInference.h.

◆ _is_new_jt_needed_

template<GUM_Numeric GUM_SCALAR>
bool gum::ShaferShenoyInference< GUM_SCALAR >::_is_new_jt_needed_ {true}
private

indicates whether a new join tree is needed for the next inference

when modifying the set of hard evidence, we can determine that the current JT is no more appropriate for inference. This variable enables us to keep track of this.

Definition at line 310 of file ShaferShenoyInference.h.

310{true};

◆ _joint_target_posteriors_

template<GUM_Numeric GUM_SCALAR>
HashTable< NodeSet, const Tensor< GUM_SCALAR >* > gum::ShaferShenoyInference< GUM_SCALAR >::_joint_target_posteriors_
private

the set of set target posteriors computed during the last inference

the posteriors are owned by ShaferShenoyInference.

Definition at line 365 of file ShaferShenoyInference.h.

◆ _joint_target_to_clique_

template<GUM_Numeric GUM_SCALAR>
HashTable< NodeSet, NodeId > gum::ShaferShenoyInference< GUM_SCALAR >::_joint_target_to_clique_
private

for each set target, assign a clique in the JT that contains it

Definition at line 325 of file ShaferShenoyInference.h.

◆ _joint_targets_

template<GUM_Numeric GUM_SCALAR>
Set< NodeSet > gum::JointTargetedInference< GUM_SCALAR >::_joint_targets_
privateinherited

◆ _JT_

template<GUM_Numeric GUM_SCALAR>
JoinTree* gum::ShaferShenoyInference< GUM_SCALAR >::_JT_ {nullptr}
private

the join (or junction) tree used to answer the last inference query

Definition at line 301 of file ShaferShenoyInference.h.

301{nullptr};

◆ _junctionTree_

template<GUM_Numeric GUM_SCALAR>
JunctionTree* gum::ShaferShenoyInference< GUM_SCALAR >::_junctionTree_ {nullptr}
private

the junction tree to answer the last inference query

Definition at line 304 of file ShaferShenoyInference.h.

304{nullptr};

◆ _messages_computed_

template<GUM_Numeric GUM_SCALAR>
ArcProperty< bool > gum::ShaferShenoyInference< GUM_SCALAR >::_messages_computed_
private

indicates whether a message (from one clique to another) has been computed

Here, all the messages, computed or not, are put into the property, only the Boolean makes the difference between messages computed and those that were not computed

Definition at line 377 of file ShaferShenoyInference.h.

◆ _nb_threads_

Size gum::ThreadNumberManager::_nb_threads_ {0}
privateinherited

the max number of threads used by the class

Definition at line 126 of file threadNumberManager.h.

126{0};

◆ _node_to_clique_

template<GUM_Numeric GUM_SCALAR>
NodeProperty< NodeId > gum::ShaferShenoyInference< GUM_SCALAR >::_node_to_clique_
private

for each node of graph (~ in the Bayes net), associate an ID in the JT

Definition at line 322 of file ShaferShenoyInference.h.

◆ _node_to_hard_ev_projected_CPTs_

template<GUM_Numeric GUM_SCALAR>
NodeProperty< const IScheduleMultiDim* > gum::ShaferShenoyInference< GUM_SCALAR >::_node_to_hard_ev_projected_CPTs_
private

the CPTs that were projected due to hard evidence nodes

For each node whose CPT is defined over some nodes that contain some hard evidence, assigns a new projected CPT that does not contain these nodes anymore.

Warning
These tensors are owned by ShaferShenoy.

Definition at line 393 of file ShaferShenoyInference.h.

◆ _node_to_soft_evidence_

template<GUM_Numeric GUM_SCALAR>
NodeProperty< const IScheduleMultiDim* > gum::ShaferShenoyInference< GUM_SCALAR >::_node_to_soft_evidence_
private

the soft evidence stored in the cliques per their assigned node in the BN

This variable is useful for method updateOutdatedTensors_: it enables to know which soft evidence should be removed/added into the cliques of the join tree.

Warning
These tensors are not owned by ShaferShenoyInference, they are only referenced by it. Only the cliques that contain evidence are filled in this structure.

Definition at line 386 of file ShaferShenoyInference.h.

◆ _one_minus_epsilon_

template<GUM_Numeric GUM_SCALAR>
GUM_SCALAR gum::ShaferShenoyInference< GUM_SCALAR >::_one_minus_epsilon_ {GUM_SCALAR(1.0 - 1e-6)}
staticconstexprprivate

for comparisons with 1 - epsilon

Definition at line 412 of file ShaferShenoyInference.h.

412{GUM_SCALAR(1.0 - 1e-6)};

◆ _projection_op_

template<GUM_Numeric GUM_SCALAR>
Tensor< GUM_SCALAR >(* gum::ShaferShenoyInference< GUM_SCALAR >::_projection_op_) (const Tensor< GUM_SCALAR > &, const gum::VariableSet &) = SSNewprojTensor
private

the operator for performing the projections

Definition at line 275 of file ShaferShenoyInference.h.

◆ _roots_

template<GUM_Numeric GUM_SCALAR>
NodeSet gum::ShaferShenoyInference< GUM_SCALAR >::_roots_
private

a clique node used as a root in each connected component of JT

For usual probabilistic inference, roots is useless. This is useful when computing the probability of evidence. In this case, we need to compute this probability in every connected component and multiply them to get the overall probability of evidence.

Warning
roots should be computed only when evidenceProbability is called.

Definition at line 319 of file ShaferShenoyInference.h.

◆ _schedule_threshold_

template<GUM_Numeric GUM_SCALAR>
double gum::ShaferShenoyInference< GUM_SCALAR >::_schedule_threshold_ {1000000.0}
staticconstexprprivate

minimal number of operations to perform in the JT to use schedules

Definition at line 409 of file ShaferShenoyInference.h.

409{1000000.0};

◆ _scheduler_parallel_

SchedulerParallel gum::ScheduledInference::_scheduler_parallel_
privateinherited

◆ _scheduler_sequential_

SchedulerSequential gum::ScheduledInference::_scheduler_sequential_
privateinherited

◆ _separator_tensors_

template<GUM_Numeric GUM_SCALAR>
ArcProperty< const IScheduleMultiDim* > gum::ShaferShenoyInference< GUM_SCALAR >::_separator_tensors_
private

the list of all tensors stored in the separators after inferences

This structure contains all the arcs of the join tree (edges in both directions) whether the arc received any tensor or not. If it did not receive any tensor, then it contains a nullptr pointer.

Definition at line 348 of file ShaferShenoyInference.h.

◆ _target_posteriors_

template<GUM_Numeric GUM_SCALAR>
NodeProperty< const Tensor< GUM_SCALAR >* > gum::ShaferShenoyInference< GUM_SCALAR >::_target_posteriors_
private

the set of single posteriors computed during the last inference

the posteriors are owned by ShaferShenoyInference.

Definition at line 361 of file ShaferShenoyInference.h.

◆ _targeted_mode_

template<GUM_Numeric GUM_SCALAR>
bool gum::MarginalTargetedInference< GUM_SCALAR >::_targeted_mode_
privateinherited

whether the actual targets are default

Definition at line 262 of file marginalTargetedInference.h.

Referenced by MarginalTargetedInference(), eraseTarget(), isInTargetMode(), isTargetedMode_(), onModelChanged_(), and setTargetedMode_().

◆ _targets_

template<GUM_Numeric GUM_SCALAR>
NodeSet gum::MarginalTargetedInference< GUM_SCALAR >::_targets_
privateinherited

◆ _triangulation_

template<GUM_Numeric GUM_SCALAR>
Triangulation* gum::ShaferShenoyInference< GUM_SCALAR >::_triangulation_
private

the triangulation class creating the junction tree used for inference

Definition at line 286 of file ShaferShenoyInference.h.

◆ _use_binary_join_tree_

template<GUM_Numeric GUM_SCALAR>
bool gum::ShaferShenoyInference< GUM_SCALAR >::_use_binary_join_tree_ {true}
private

indicates whether we should transform junction trees into binary join trees

Definition at line 290 of file ShaferShenoyInference.h.

290{true};

◆ _use_schedules_

template<GUM_Numeric GUM_SCALAR>
bool gum::ShaferShenoyInference< GUM_SCALAR >::_use_schedules_ {false}
private

indicates whether we should use schedules for inference

Definition at line 406 of file ShaferShenoyInference.h.

406{false};

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