27 #ifndef GUM_VARIABLE_ELIMINATION_H 28 #define GUM_VARIABLE_ELIMINATION_H 43 template <
typename GUM_SCALAR >
44 INLINE
static Potential< GUM_SCALAR >*
51 template <
typename GUM_SCALAR >
66 template <
typename GUM_SCALAR >
215 const NodeSet& declared_target)
final;
248 Potential< GUM_SCALAR >* (*__combination_op)(
const Potential< GUM_SCALAR >&,
249 const Potential< GUM_SCALAR >&){
292 const Potential< GUM_SCALAR >&,
const Potential< GUM_SCALAR >&));
340 std::pair< __PotentialSet, __PotentialSet >&& incoming_messages);
350 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
void __setProjectionFunction(Potential< GUM_SCALAR > *(*proj)(const Potential< GUM_SCALAR > &, const Set< const DiscreteVariable * > &))
sets the operator for performing the projections
aGrUM's Potential is a multi-dimensional array with tensor operators.
NodeId __targets2clique
indicate a clique that contains all the nodes of the target
VariableElimination(const IBayesNet< GUM_SCALAR > *BN, RelevantPotentialsFinderType relevant_type=RelevantPotentialsFinderType::DSEP_BAYESBALL_POTENTIALS, FindBarrenNodesType=FindBarrenNodesType::FIND_BARREN_NODES)
default constructor
void _onAllTargetsErased() final
fired before a all single and joint_targets are removed
__PotentialSet __removeBarrenVariables(__PotentialSet &pot_list, Set< const DiscreteVariable * > &del_vars)
static INLINE Potential< GUM_SCALAR > * VENewprojPotential(const Potential< GUM_SCALAR > &t1, const Set< const DiscreteVariable * > &del_vars)
void __setCombinationFunction(Potential< GUM_SCALAR > *(*comb)(const Potential< GUM_SCALAR > &, const Potential< GUM_SCALAR > &))
sets the operator for performing the combinations
Safe iterators for the Set classDevelopers may consider using Set<x>::iterator_safe instead of SetIte...
Implementation of Variable Elimination for inference in Bayesian Networks.
const Potential< GUM_SCALAR > & _posterior(NodeId id) final
returns the posterior of a given variable
This file contains the abstract inference class definition for computing (incrementally) joint poster...
JunctionTree * __JT
the junction tree used to answer the last inference query
RelevantPotentialsFinderType __find_relevant_potential_type
the type of relevant potential finding algorithm to be used
void __findRelevantPotentialsXX(__PotentialSet &pot_list, Set< const DiscreteVariable * > &kept_vars)
update a set of potentials: the remaining are those to be combined to produce a message on a separato...
static INLINE Potential< GUM_SCALAR > * VENewmultiPotential(const Potential< GUM_SCALAR > &t1, const Potential< GUM_SCALAR > &t2)
void setFindBarrenNodesType(FindBarrenNodesType type)
sets how we determine barren nodes
void _onEvidenceErased(const NodeId id, bool isHardEvidence) final
fired before an evidence is removed
std::pair< __PotentialSet, __PotentialSet > __collectMessage(NodeId id, NodeId from)
actually perform the collect phase
Set< const Potential< GUM_SCALAR > *> __PotentialSet
void _makeInference() final
called when the inference has to be performed effectively
SetIteratorSafe< const Potential< GUM_SCALAR > *> __PotentialSetIterator
Potential< GUM_SCALAR > * __target_posterior
the posterior computed during the last inference
Triangulation * __triangulation
the triangulation class creating the junction tree used for inference
<agrum/BN/inference/variableElimination.h>
void _updateOutdatedBNPotentials() final
prepares inference when the latter is in OutdatedBNPotentials state
the type of algorithm to use to perform relevant reasoning in Bayes net inference ...
Class representing the minimal interface for Bayesian Network.
gum is the global namespace for all aGrUM entities
const Potential< GUM_SCALAR > & _jointPosterior(const NodeSet &set) final
returns the posterior of a declared target set
void __findRelevantPotentialsGetAll(__PotentialSet &pot_list, Set< const DiscreteVariable * > &kept_vars)
update a set of potentials: the remaining are those to be combined to produce a message on a separato...
void __findRelevantPotentialsWithdSeparation(__PotentialSet &pot_list, Set< const DiscreteVariable * > &kept_vars)
update a set of potentials: the remaining are those to be combined to produce a message on a separato...
RelevantPotentialsFinderType
type of algorithm for determining the relevant potentials for combinations using some d-separation an...
const JunctionTree * junctionTree(NodeId id)
returns the join tree used for compute the posterior of node id
void _onMarginalTargetErased(const NodeId id) final
fired before a single target is removed
void _onAllMarginalTargetsErased() final
fired before a all the single targets are removed
void __findRelevantPotentialsWithdSeparation3(__PotentialSet &pot_list, Set< const DiscreteVariable * > &kept_vars)
update a set of potentials: the remaining are those to be combined to produce a message on a separato...
VariableElimination< GUM_SCALAR > & operator=(const VariableElimination< GUM_SCALAR > &)=delete
avoid copy operators
Representation of a setA Set is a structure that contains arbitrary elements.
FindBarrenNodesType
type of algorithm to determine barren nodes
UndiGraph __graph
the undigraph extracted from the BN and used to construct the join tree
void _onAllEvidenceErased(bool contains_hard_evidence) final
fired before all the evidence are erased
void __findRelevantPotentialsWithdSeparation2(__PotentialSet &pot_list, Set< const DiscreteVariable * > &kept_vars)
update a set of potentials: the remaining are those to be combined to produce a message on a separato...
<agrum/BN/inference/jointTargetedInference.h>
HashTable< NodeId, NodeSet > __clique_potentials
for each BN node, indicate in which clique its CPT will be stored
void _onJointTargetErased(const NodeSet &set) final
fired before a joint target is removed
void _onJointTargetAdded(const NodeSet &set) final
fired after a new joint target is inserted
FindBarrenNodesType __barren_nodes_type
the type of barren nodes computation we wish
void _onAllJointTargetsErased() final
fired before a all the joint targets are removed
void setTriangulation(const Triangulation &new_triangulation)
use a new triangulation algorithm
void setRelevantPotentialsFinderType(RelevantPotentialsFinderType type)
sets how we determine the relevant potentials to combine
Potential< GUM_SCALAR > margSumOut(const Set< const DiscreteVariable * > &del_vars) const
Projection using sum as operation (and implementation-optimized operations)
void _onStateChanged() final
fired when the stage is changed
HashTable< NodeId, NodeId > __node_to_clique
for each node of __graph (~ in the Bayes net), associate an ID in the JT
Potential< GUM_SCALAR > * _unnormalizedJointPosterior(NodeId id) final
returns a fresh potential equal to P(argument,evidence)
Detect barren nodes for inference in Bayesian networks.
__PotentialSet __marginalizeOut(__PotentialSet pot_list, Set< const DiscreteVariable * > &del_vars, Set< const DiscreteVariable * > &kept_vars)
removes variables del_vars from a list of potentials and returns the resulting list ...
std::pair< __PotentialSet, __PotentialSet > __NodePotentials(NodeId node)
returns the CPT + evidence of a node projected w.r.t. hard evidence
void _updateOutdatedBNStructure() final
prepares inference when the latter is in OutdatedBNStructure state
void _onAllMarginalTargetsAdded() final
fired after all the nodes of the BN are added as single targets
Class for computing default triangulations of graphs.
std::pair< __PotentialSet, __PotentialSet > __produceMessage(NodeId from_id, NodeId to_id, std::pair< __PotentialSet, __PotentialSet > &&incoming_messages)
creates the message sent by clique from_id to clique to_id
Base class for undirected graphs.
virtual const NodeSet & targets() const noexcept final
returns the list of marginal targets
void __createNewJT(const NodeSet &targets)
create a new junction tree as well as its related data structures
~VariableElimination() final
destructor
Interface for all the triangulation methods.
const GUM_SCALAR __1_minus_epsilon
for comparisons with 1 - epsilon
void _onMarginalTargetAdded(const NodeId id) final
fired after a new single target is inserted
virtual const IBayesNet< GUM_SCALAR > & BN() const final
Returns a constant reference over the IBayesNet referenced by this class.
Size NodeId
Type for node ids.
void _onEvidenceChanged(const NodeId id, bool hasChangedSoftHard) final
fired after an evidence is changed, in particular when its status (soft/hard) changes ...
void(VariableElimination< GUM_SCALAR >::* __findRelevantPotentials)(Set< const Potential< GUM_SCALAR > * > &pot_list, Set< const DiscreteVariable * > &kept_vars)
update a set of potentials: the remaining are those to be combined to produce a message on a separato...
void _onEvidenceAdded(const NodeId id, bool isHardEvidence) final
fired after a new evidence is inserted
virtual void _onBayesNetChanged(const IBayesNet< GUM_SCALAR > *bn) final
fired after a new Bayes net has been assigned to the engine