aGrUM  0.16.0
influenceDiagramInference.h
Go to the documentation of this file.
1 
29 #ifndef GUM_INFLUENCE_DIAGRAM_INFERENCE_H
30 #define GUM_INFLUENCE_DIAGRAM_INFERENCE_H
31 
32 #include <iostream>
33 #include <string>
34 #include <utility>
35 #include <vector>
36 
37 #include <agrum/agrum.h>
38 
39 #include <agrum/core/list.h>
40 
42 
45 
47 
48 namespace gum {
49 
50  template < typename GUM_SCALAR >
52 
63  template < typename GUM_SCALAR >
65  : public IInfluenceDiagramInference< GUM_SCALAR > {
66  public:
67  // ====================================================================
69  // ====================================================================
71 
77  const InfluenceDiagram< GUM_SCALAR >& infDiag);
78 
83 
85  // ====================================================================
87  // ====================================================================
89 
91  virtual void makeInference();
92 
94  GUM_SCALAR getMEU();
95 
98  Idx getBestDecisionChoice(NodeId decisionId);
99 
101  std::string displayResult();
102 
104  // ====================================================================
106  // ====================================================================
108 
110  virtual void
111  insertEvidence(const List< const Potential< GUM_SCALAR >* >& evidenceList);
112 
114  virtual void eraseEvidence(const Potential< GUM_SCALAR >* evidence);
115 
117  virtual void eraseAllEvidence();
118 
120  // ====================================================================
122  // ====================================================================
124 
127 
130  void displayStrongJunctionTree(std::ostream& stream = std::cout);
131 
132  private:
133  // ====================================================================
135  // ====================================================================
137 
140 
143 
146 
149 
152 
154  // ====================================================================
156  // ====================================================================
158 
161 
163 
165 
167 
169 
171  // ====================================================================
173  // ====================================================================
175 
177  const NodeSet& __getSeparator(NodeId clique_1, NodeId clique_2);
178 
180  NodeId __getClique(const std::vector< NodeId >& eliminationOrder, NodeId id);
181 
183  // ====================================================================
185  // ====================================================================
187 
192 
195 
197  void __cleanUp();
198 
200  void __collectChild(NodeId parent, NodeId child);
201 
203  void __absorbClique(NodeId absorbedCliqueId, NodeId absorbingCliqueId);
204 
206  void __reduceClique(CliqueProperties< GUM_SCALAR >* absorbedClique,
207  NodeSet& separator,
208  Potential< GUM_SCALAR >*& potentialMarginal,
209  Potential< GUM_SCALAR >*& utilityMarginal);
210 
217 
226 
228  bool __IsEliminatedAfter(NodeId observedNode, NodeId currentNode);
229 
231  };
232 
233 #ifndef DOXYGEN_SHOULD_SKIP_THIS
234  template < typename GUM_SCALAR >
238  class CliqueProperties {
239  public:
243 
245  ~CliqueProperties();
246 
249  void addVariable(const DiscreteVariable& v);
250 
253  void makeEliminationOrder(const std::vector< NodeId >& elim,
254  const InfluenceDiagram< GUM_SCALAR >& infDiag);
255 
261  void addPotential(const Potential< GUM_SCALAR >& cpt, bool removable = false);
262 
268  void addUtility(const Potential< GUM_SCALAR >& ut, bool removable = false);
269 
271  void cleanFromInference();
272 
280  void addEvidence(const Potential< GUM_SCALAR >& evidence);
281 
283  void removeEvidence(const DiscreteVariable& v);
284 
286  void removeAllEvidence();
287 
291  evidences() const;
292 
295  potentialBucket();
296 
299  utilityBucket();
300 
302  const Sequence< NodeId >& cliqueEliminationOrder();
303 
305  const Sequence< const DiscreteVariable* >& cliqueVariables();
306 
308  Instantiation& cliqueInstantiation();
309 
310  private:
313  __evidences;
314 
317 
320 
322  Sequence< NodeId > __eliminationOrder;
323 
325  Instantiation __allVarsInst;
326 
328  List< const DiscreteVariable* > __removableVarList;
329 
331  List< const Potential< GUM_SCALAR >* > __removablePotentialList;
332 
334  List< const Potential< GUM_SCALAR >* > __removableUtilityList;
335  };
336 
337 #endif // DOXYGEN_SHOULD_SKIP_THIS
338 
339 } /* namespace gum */
340 
342 
343 #endif /* GUM_INFLUENCE_DIAGRAM_INFERENCE_H */
aGrUM&#39;s Potential is a multi-dimensional array with tensor operators.
Definition: potential.h:60
Potential< GUM_SCALAR > * __makeDummyPotential(NodeId cliqueId)
Returns a pointer over a "dummy" potential, which is a CPT filled with one MultiDimSparse filled with...
Set< Potential< GUM_SCALAR > *> __utilityDummies
The set of dummies sparse utilities matrix created.
Set< Potential< GUM_SCALAR > *> __potentialDummies
The set of dummies sparse potential matrix created.
<agrum/ID/inference/influenceDiagramInference.h>
bool __IsEliminatedAfter(NodeId observedNode, NodeId currentNode)
Returns true if observed node is eliminated after current node.
Idx getBestDecisionChoice(NodeId decisionId)
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
NodeProperty< NodeId > __nodeToCliqueMap
Mapping of the nodes with the clique used to put their CPT.
Triangulation & getTriangulation()
Returns the Triangulation used by this class.
NodeId __getClique(const std::vector< NodeId > &eliminationOrder, NodeId id)
Potential< GUM_SCALAR > * __inferenceUtility
The resulting utility from inference.
Base class for discrete random variable.
Generic doubly linked lists.
Definition: list.h:372
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
The class for generic Hash Tables.
Definition: hashTable.h:679
Triangulation * __triangulation
The triangulation algorithm.
Representation of a setA Set is a structure that contains arbitrary elements.
Definition: set.h:165
void __cleanUp()
Cleans Up remaining stuff due to inference.
std::string displayResult()
displays the result of an inference
void __reduceClique(CliqueProperties< GUM_SCALAR > *absorbedClique, NodeSet &separator, Potential< GUM_SCALAR > *&potentialMarginal, Potential< GUM_SCALAR > *&utilityMarginal)
Reduces a clique down to her separator from another clique elements.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void __makeCliquePropertiesMap()
Builds the cliques tables Uses __getCliquesTable to initialize the cliques table, and multiply the ta...
HashTable< Size, NodeId > __cliqueEliminationMap
Mapping of the nodes with the clique used to put their CPT.
void __collectChild(NodeId parent, NodeId child)
collect child clique for inferences
void __absorbClique(NodeId absorbedCliqueId, NodeId absorbingCliqueId)
Performs the operation of absorption of a clique by another.
InfluenceDiagramInference(const InfluenceDiagram< GUM_SCALAR > &infDiag)
Default constructor.
Potential< GUM_SCALAR > * __inferencePotential
The resulting potential from inference.
Class for assigning/browsing values to tuples of discrete variables.
Definition: instantiation.h:83
virtual ~InfluenceDiagramInference()
Destructor.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
NodeProperty< CliqueProperties< GUM_SCALAR > *> __cliquePropertiesMap
Mapping of the nodes with the clique used to put their CPT.
bool __inferenceMade
Mapping of the nodes with the clique used to put their CPT.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Size Idx
Type for indexes.
Definition: types.h:53
<agrum/ID/inference/IInfluenceDiagramInference.h>
void displayStrongJunctionTree(std::ostream &stream=std::cout)
Displays on terminal the result of strong junction tree computation for test purpose only...
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual void insertEvidence(const List< const Potential< GUM_SCALAR > * > &evidenceList)
Interface for all the triangulation methods.
Definition: triangulation.h:47
HashTable< NodeId, Idx > __utakenDecisionMap
Mapping of the nodes with the clique used to put their CPT.
const NodeSet & __getSeparator(NodeId clique_1, NodeId clique_2)
virtual void eraseEvidence(const Potential< GUM_SCALAR > *evidence)
Potential< GUM_SCALAR > * __makeDummyUtility(NodeId cliqueId)
Returns a pointer over a "dummy" utility, which is a utility table filled with one MultiDimSparse fil...
Size NodeId
Type for node ids.
Definition: graphElements.h:98
void __makeStrongJunctionTree()
Makes a strong junction tree that make easier elimination.
Class representing an Influence Diagram.