aGrUM  0.16.0
SVE.h
Go to the documentation of this file.
1 
30 #ifndef GUM_SVE_H
31 #define GUM_SVE_H
32 
33 #include <vector>
34 
35 #include <agrum/core/set.h>
36 
39 
41 
46 
47 #include <agrum/PRM/utils_prm.h>
48 
50 
53 
54 namespace gum {
55  namespace prm {
56 
65  template < typename GUM_SCALAR >
66  class SVE : public PRMInference< GUM_SCALAR > {
67  public:
68  // ========================================================================
70  // ========================================================================
72 
74  SVE(const PRM< GUM_SCALAR >& prm, const PRMSystem< GUM_SCALAR >& system);
75 
77  ~SVE();
78 
80  // ========================================================================
82  // ========================================================================
84 
86  virtual std::string name() const;
87 
89  protected:
90  // ========================================================================
92  // ========================================================================
94 
97 
99  virtual void _evidenceAdded(const Chain& chain);
100 
102  virtual void _evidenceRemoved(const Chain& chain);
103 
105  virtual void _marginal(const Chain& chain, Potential< GUM_SCALAR >& m);
106 
108  virtual void _joint(const std::vector< Chain >& queries,
110 
112  private:
116  typedef
118 
120  typedef typename Set< MultiDimArray< GUM_SCALAR >* >::iterator_safe
122 
123  HashTable< const PRMClass< GUM_SCALAR >*, std::vector< NodeId >* >
125 
127 
129 
133 
140 
141  BucketSet __lifted_trash;
142 
144 
146 
148  NodeId id,
149  BucketSet& pool,
150  BucketSet& trash);
151 
153  const PRMInstance< GUM_SCALAR >* from,
154  const PRMInstance< GUM_SCALAR >* i,
155  BucketSet& pool,
156  BucketSet& trash,
157  List< const PRMInstance< GUM_SCALAR >* >& elim_list,
158  Set< const PRMInstance< GUM_SCALAR >* >& ignore,
159  Set< const PRMInstance< GUM_SCALAR >* >& eliminated);
160 
162  const PRMInstance< GUM_SCALAR >* i,
163  BucketSet& pool,
164  BucketSet& trash,
165  List< const PRMInstance< GUM_SCALAR >* >& elim_list,
166  Set< const PRMInstance< GUM_SCALAR >* >& ignore,
167  Set< const PRMInstance< GUM_SCALAR >* >& eliminated);
168 
170  BucketSet& pool,
171  BucketSet& trash,
172  Set< NodeId >* delayedVars = 0);
173 
175  BucketSet& pool,
176  BucketSet& trash);
177 
179  BucketSet& pool,
180  BucketSet& trash);
181 
183  BucketSet& pool,
184  BucketSet& trash,
185  Set< NodeId >* delayedVars = 0);
186 
189  const PRMInstance< GUM_SCALAR >* second);
190 
191  void __initElimOrder();
192 
193  void __insertEvidence(const PRMInstance< GUM_SCALAR >* i, BucketSet& pool);
194 
202  const PRMInstance< GUM_SCALAR >* j,
203  NodeId id);
204 
205  std::vector< NodeId >& __getElimOrder(const PRMClass< GUM_SCALAR >& c);
206 
209  const PRMAggregate< GUM_SCALAR >* agg);
210 
212  std::string __trim(const std::string& s);
213 
215  };
216 
217 
218 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
219  extern template class SVE< double >;
220 #endif
221 
222 
223  } /* namespace prm */
224 } /* namespace gum */
225 
227 
228 #endif /* GUM_SVE_H */
Set< MultiDimArray< GUM_SCALAR > *>::iterator_safe ArraySetIterator
Code alias.
Definition: SVE.h:121
aGrUM&#39;s Potential is a multi-dimensional array with tensor operators.
Definition: potential.h:60
Set< Potential< GUM_SCALAR > *> BucketSet
Code alias.
Definition: SVE.h:114
void __addDelayedVariable(const PRMInstance< GUM_SCALAR > *i, const PRMInstance< GUM_SCALAR > *j, NodeId id)
When there is a loop in the references some variable elimination must be delayed, this methods add su...
Definition: SVE_tpl.h:678
~SVE()
Destructor.
Definition: SVE_tpl.h:108
HashTable< std::string, Size > __delayedVariablesCounters
Some variable must be delayed for more than one PRMInstance<GUM_SCALAR>, when the delayed variable co...
Definition: SVE.h:139
void __insertEvidence(const PRMInstance< GUM_SCALAR > *i, BucketSet &pool)
Returns true if second can be eliminated before first.
Definition: SVE_tpl.h:629
BucketSet __lifted_trash
Definition: SVE.h:141
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
std::vector< NodeId > & __getElimOrder(const PRMClass< GUM_SCALAR > &c)
Returns true if second can be eliminated before first.
Definition: SVE_tpl.h:637
void __initLiftedNodes(const PRMClass< GUM_SCALAR > &c)
Returns true if second can be eliminated before first.
Definition: SVE_tpl.h:490
An PRMInstance is a Bayesian Network fragment defined by a Class and used in a PRMSystem.
Definition: PRMInstance.h:63
void __eliminateNodesUpward(const PRMInstance< GUM_SCALAR > *i, BucketSet &pool, BucketSet &trash, List< const PRMInstance< GUM_SCALAR > * > &elim_list, Set< const PRMInstance< GUM_SCALAR > * > &ignore, Set< const PRMInstance< GUM_SCALAR > * > &eliminated)
Returns true if second can be eliminated before first.
Definition: SVE_tpl.h:331
virtual void _marginal(const Chain &chain, Potential< GUM_SCALAR > &m)
See PRMInference<GUM_SCALAR>::_marginal().
Definition: SVE_tpl.h:581
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
bool __checkElimOrder(const PRMInstance< GUM_SCALAR > *first, const PRMInstance< GUM_SCALAR > *second)
Returns true if second can be eliminated before first.
Definition: SVE_tpl.h:649
Sequence< std::string > * __class_elim_order
Definition: SVE.h:128
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
void __eliminateNodes(const PRMInstance< GUM_SCALAR > *query, NodeId id, BucketSet &pool, BucketSet &trash)
Returns true if second can be eliminated before first.
Definition: SVE_tpl.h:128
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Potential< GUM_SCALAR > * __getAggPotential(const PRMInstance< GUM_SCALAR > *i, const PRMAggregate< GUM_SCALAR > *agg)
Returns true if second can be eliminated before first.
Definition: SVE_tpl.h:661
The class for generic Hash Tables.
Definition: hashTable.h:679
HashTable< const PRMClass< GUM_SCALAR > *, std::vector< NodeId > *> __elim_orders
Definition: SVE.h:124
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Representation of a setA Set is a structure that contains arbitrary elements.
Definition: set.h:165
PRMInference< GUM_SCALAR >::Chain Chain
Code alias.
Definition: SVE.h:96
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual void _evidenceRemoved(const Chain &chain)
See PRMInference<GUM_SCALAR>::_evidenceRemoved().
Definition: SVE_tpl.h:672
void __insertLiftedNodes(const PRMInstance< GUM_SCALAR > *i, BucketSet &pool, BucketSet &trash)
Returns true if second can be eliminated before first.
Definition: SVE_tpl.h:470
SVE(const PRM< GUM_SCALAR > &prm, const PRMSystem< GUM_SCALAR > &system)
Default Constructor.
Definition: SVE_tpl.h:620
void __variableElimination(const PRMInstance< GUM_SCALAR > *i, BucketSet &pool, BucketSet &trash, Set< NodeId > *delayedVars=0)
Returns true if second can be eliminated before first.
Definition: SVE_tpl.h:289
void __eliminateNodesDownward(const PRMInstance< GUM_SCALAR > *from, const PRMInstance< GUM_SCALAR > *i, BucketSet &pool, BucketSet &trash, List< const PRMInstance< GUM_SCALAR > * > &elim_list, Set< const PRMInstance< GUM_SCALAR > * > &ignore, Set< const PRMInstance< GUM_SCALAR > * > &eliminated)
Returns true if second can be eliminated before first.
Definition: SVE_tpl.h:236
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
A PRMSystem is a container of PRMInstance and describe a relational skeleton.
Definition: PRMObject.h:229
void __initElimOrder()
Returns true if second can be eliminated before first.
Definition: SVE_tpl.h:544
virtual void _evidenceAdded(const Chain &chain)
See PRMInference<GUM_SCALAR>::_evidenceAdded().
Definition: SVE_tpl.h:667
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.
std::pair< const PRMInstance< GUM_SCALAR > *, const PRMAttribute< GUM_SCALAR > *> Chain
Code alias.
Definition: PRMInference.h:57
virtual std::string name() const
Returns the name of the current inference algorithm.
Definition: SVE_tpl.h:701
void __eliminateNodesWithEvidence(const PRMInstance< GUM_SCALAR > *i, BucketSet &pool, BucketSet &trash, Set< NodeId > *delayedVars=0)
Returns true if second can be eliminated before first.
Definition: SVE_tpl.h:382
This abstract class is used as base class for all inference class on PRM<GUM_SCALAR>.
Definition: PRMInference.h:52
This class represents a Probabilistic Relational PRMSystem<GUM_SCALAR>.
Definition: PRM.h:66
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void __eliminateDelayedVariables(const PRMInstance< GUM_SCALAR > *i, BucketSet &pool, BucketSet &trash)
Returns true if second can be eliminated before first.
Definition: SVE_tpl.h:210
A PRMClass is an object of a PRM representing a fragment of a Bayesian Network which can be instantia...
Definition: PRMClass.h:66
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.
HashTable< const PRMClass< GUM_SCALAR > *, BucketSet *> __lifted_pools
Definition: SVE.h:126
std::string __trim(const std::string &s)
Returns true if second can be eliminated before first.
Definition: SVE_tpl.h:642
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
HashTable< const PRMInstance< GUM_SCALAR > *, Set< const DiscreteVariable *> *> __delayedVariables
Definition: SVE.h:132
virtual void _joint(const std::vector< Chain > &queries, Potential< GUM_SCALAR > &j)
See PRMInference<GUM_SCALAR>::_joint().
Definition: SVE_tpl.h:614
This class is an implementation of the Structured Variable Elimination algorithm on PRM<GUM_SCALAR>...
Definition: SVE.h:66
Set< Potential< GUM_SCALAR > *>::iterator_safe BucketSetIterator
Code alias.
Definition: SVE.h:117