aGrUM  0.16.0
structuredBayesBall.h
Go to the documentation of this file.
1 
30 #include <sstream>
31 #include <string>
32 #include <utility>
33 
34 #include <agrum/core/hashTable.h>
35 #include <agrum/core/set.h>
36 
37 #include <agrum/PRM/PRM.h>
39 
40 #ifndef GUM_STRUCTURED_BB_H
41 # define GUM_STRUCTURED_BB_H
42 namespace gum {
43  namespace prm {
44 
50  template < typename GUM_SCALAR >
52  public:
53  // ========================================================================
55  // ========================================================================
57 
60 
63 
65  // ========================================================================
67  // ========================================================================
69 
71  const std::string& key(const PRMInstance< GUM_SCALAR >* i) const;
72 
74  const std::string& key(const PRMInstance< GUM_SCALAR >& i) const;
75 
77  const Set< NodeId >&
79 
81  const Set< NodeId >&
83 
86  Size occurrence(const std::string& key) const;
87 
90  float liftRatio() const;
91 
93  bool exists(const PRMInstance< GUM_SCALAR >* i) const;
94 
96  bool exists(const PRMInstance< GUM_SCALAR >& i) const;
97 
99 
103  void compute(const PRMInstance< GUM_SCALAR >* i, NodeId n);
104 
108  void compute(const PRMInstance< GUM_SCALAR >& i, NodeId n);
109 
112 
113  private:
116 
119 
125  std::pair< bool, bool >& __getMark(InstanceMap& marks,
126  const PRMInstance< GUM_SCALAR >* i,
127  NodeId n);
130  NodeId n);
131 
133  void __clean();
134 
136  void __compute(const PRMInstance< GUM_SCALAR >* i, NodeId n);
137 
140  NodeId n,
141  InstanceMap& marks);
142 
145  NodeId n,
146  InstanceMap& marks);
147 
149  void __fillMaps(InstanceMap& marks);
150 
152  std::string __buildHashKey(const PRMInstance< GUM_SCALAR >* i,
153  Set< NodeId >& req_nodes);
154 
157 
162  HashTable< const PRMInstance< GUM_SCALAR >*,
163  std::pair< std::string, Set< NodeId >* > >
165 
169  };
170 
171 
172 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
173  extern template class StructuredBayesBall< double >;
174 # endif
175 
176 
177  } /* namespace prm */
178 } /* namespace gum */
179 
181 
182 #endif /* GUM_STRUCTURED_BB_H */
<agrum/PRM/structuredBayesBall.h>
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
const Set< NodeId > & requisiteNodes(const PRMInstance< GUM_SCALAR > *i) const
Returns the set of requisite nodes w.r.t. d-separation for i.
An PRMInstance is a Bayesian Network fragment defined by a Class and used in a PRMSystem.
Definition: PRMInstance.h:63
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
std::pair< bool, bool > & __getMark(InstanceMap &marks, const PRMInstance< GUM_SCALAR > *i, NodeId n)
Code alias.
void compute(const PRMInstance< GUM_SCALAR > *i, NodeId n)
Compute the set or requisite nodes for each required instance given the current set of observations...
bool __isHardEvidence(const PRMInstance< GUM_SCALAR > *i, NodeId n)
Returns true if there is a hard evidence on i->get(n).
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
HashTable< const PRMInstance< GUM_SCALAR > *, std::pair< std::string, Set< NodeId > *> > __keyMap
Associate an PRMInstance<GUM_SCALAR> with a unique key w.r.t. d-separation and the set of requisite n...
The class for generic Hash Tables.
Definition: hashTable.h:679
HashTable< std::string, std::pair< Set< NodeId > *, Size > > __reqMap
Associate a Key with the set of requisite nodes associated with it. The Size value is the number of i...
void __fillMaps(InstanceMap &marks)
Fill __keyMap and __reqMap.
bool exists(const PRMInstance< GUM_SCALAR > *i) const
Returns true if i has requisite nodes.
HashTable< NodeId, std::pair< bool, bool > > MarkMap
Code alias.
void __fromChild(const PRMInstance< GUM_SCALAR > *i, NodeId n, InstanceMap &marks)
When the ball is received on i->get(n) from a child.
Size occurrence(const std::string &key) const
Returns the number of occurrence of the given key, which is the number of PRMInstance<GUM_SCALAR> sha...
StructuredBayesBall & operator=(const StructuredBayesBall &source)
Copy operator.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
std::string __buildHashKey(const PRMInstance< GUM_SCALAR > *i, Set< NodeId > &req_nodes)
Builds the HashKey for the given instance and requisite nodes set.
A PRMSlotChain represents a sequence of gum::prm::PRMClassElement<GUM_SCALAR> where the n-1 first gum...
Definition: PRMObject.h:221
const std::string & key(const PRMInstance< GUM_SCALAR > *i) const
Returns a unique key w.r.t. d-separation for i.
void __clean()
Cleans this before a new computation.
const PRMSlotChain< GUM_SCALAR > & __getSC(const PRMInstance< GUM_SCALAR > *i, NodeId n)
Code alias.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
This abstract class is used as base class for all inference class on PRM<GUM_SCALAR>.
Definition: PRMInference.h:52
StructuredBayesBall(const PRMInference< GUM_SCALAR > &inference)
Default Constructor.
const PRMInference< GUM_SCALAR > * __inf
The PRM at which __model belongs.
void __compute(const PRMInstance< GUM_SCALAR > *i, NodeId n)
The real compute method.
HashTable< const PRMInstance< GUM_SCALAR > *, MarkMap *> InstanceMap
Code alias.
float liftRatio() const
Returns the ratio between the total number of instances and the number of instances with the same con...
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
void __fromParent(const PRMInstance< GUM_SCALAR > *i, NodeId n, InstanceMap &marks)
When the ball is receive on i->get(n) from a parent.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Size NodeId
Type for node ids.
Definition: graphElements.h:98