aGrUM  0.16.0
SVED.h
Go to the documentation of this file.
1 
29 #ifndef GUM_SVED_H
30 #define GUM_SVED_H
31 
32 #include <vector>
33 
34 #include <agrum/core/set.h>
35 
38 
40 
44 
47 
51 namespace gum {
52  namespace prm {
53 
62  template < typename GUM_SCALAR >
63  class SVED : public PRMInference< GUM_SCALAR > {
64  public:
65  // ========================================================================
67  // ========================================================================
69 
71  SVED(const PRM< GUM_SCALAR >& prm, const PRMSystem< GUM_SCALAR >& model);
72 
74  ~SVED();
75 
77  // ========================================================================
79  // ========================================================================
81 
83  virtual std::string name() const;
84 
86  protected:
87  // ========================================================================
89  // ========================================================================
91 
94 
96  virtual void _evidenceAdded(const Chain& chain);
97 
99  virtual void _evidenceRemoved(const Chain& chain);
100 
102  virtual void _marginal(const Chain& chain, Potential< GUM_SCALAR >& m);
103 
105  virtual void _joint(const std::vector< Chain >& queries,
107 
109  private:
113  typedef
115 
117  typedef typename Set< MultiDimArray< GUM_SCALAR >* >::iterator_safe
119 
120  HashTable< const PRMClass< GUM_SCALAR >*, std::vector< NodeId >* >
122 
129 
131 
133 
137  std::pair< Set< NodeId >*, Set< NodeId >* > >
139 
141 
143 
145  NodeId id,
146  BucketSet& pool,
147  BucketSet& trash);
148 
150  const PRMInstance< GUM_SCALAR >* from,
151  const PRMInstance< GUM_SCALAR >* i,
152  BucketSet& pool,
153  BucketSet& trash,
154  List< const PRMInstance< GUM_SCALAR >* >& elim_list,
155  Set< const PRMInstance< GUM_SCALAR >* >& ignore);
156 
158  const PRMInstance< GUM_SCALAR >* i,
159  BucketSet& pool,
160  BucketSet& trash,
161  List< const PRMInstance< GUM_SCALAR >* >& elim_list,
162  Set< const PRMInstance< GUM_SCALAR >* >& ignore);
163 
165  BucketSet& pool,
166  BucketSet& trash);
167 
169  BucketSet& pool,
170  BucketSet& trash);
171 
174  const PRMInstance< GUM_SCALAR >* second);
175 
176  void __initElimOrder();
177 
178  void __insertEvidence(const PRMInstance< GUM_SCALAR >* i, BucketSet& pool);
179 
180  std::vector< NodeId >& __getElimOrder(const PRMClass< GUM_SCALAR >& c);
181 
184  const PRMAggregate< GUM_SCALAR >* agg);
185 
186  void __initLiftedNodes(const PRMInstance< GUM_SCALAR >* i, BucketSet& trash);
187 
189 
191 
193 
195  List< const PRMInstance< GUM_SCALAR >* >& elim_list,
196  List< const PRMInstance< GUM_SCALAR >* >& reduced_list,
197  Set< const PRMInstance< GUM_SCALAR >* >& ignore,
198  BucketSet& pool,
199  BucketSet& trash);
200 
201  std::string __trim(const std::string& s);
203  };
204 
205 
206 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
207  extern template class SVED< double >;
208 #endif
209 
210 
211  } /* namespace prm */
212 } /* namespace gum */
213 
215 
216 #endif /* GUM_SVED_H */
HashTable< const Set< NodeId > *, std::pair< Set< NodeId > *, Set< NodeId > *> > __req_set
First pair -> requisite Attributes Second pair -> requisite SlotChains.
Definition: SVED.h:138
aGrUM&#39;s Potential is a multi-dimensional array with tensor operators.
Definition: potential.h:60
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual std::string name() const
Returns the name of the current inference algorithm.
Definition: SVED_tpl.h:603
void __insertEvidence(const PRMInstance< GUM_SCALAR > *i, BucketSet &pool)
Returns true if second can be eliminated before first.
Definition: SVED_tpl.h:507
virtual void _marginal(const Chain &chain, Potential< GUM_SCALAR > &m)
See PRMInference::_marginal().
Definition: SVED_tpl.h:408
void __eliminateNodes(const PRMInstance< GUM_SCALAR > *query, NodeId id, BucketSet &pool, BucketSet &trash)
Returns true if second can be eliminated before first.
Definition: SVED_tpl.h:46
<agrum/PRM/structuredBayesBall.h>
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual void _evidenceRemoved(const Chain &chain)
See PRMInference::_evidenceRemoved().
Definition: SVED_tpl.h:552
SVED(const PRM< GUM_SCALAR > &prm, const PRMSystem< GUM_SCALAR > &model)
Default Constructor.
Definition: SVED_tpl.h:497
Set< NodeId > & __getSCSet(const PRMInstance< GUM_SCALAR > *i)
Returns true if second can be eliminated before first.
Definition: SVED_tpl.h:570
An PRMInstance is a Bayesian Network fragment defined by a Class and used in a PRMSystem.
Definition: PRMInstance.h:63
void __initElimOrder()
Returns true if second can be eliminated before first.
Definition: SVED_tpl.h:371
Potential< GUM_SCALAR > * __getAggPotential(const PRMInstance< GUM_SCALAR > *i, const PRMAggregate< GUM_SCALAR > *agg)
Returns true if second can be eliminated before first.
Definition: SVED_tpl.h:539
Set< Potential< GUM_SCALAR > *> BucketSet
Code alias.
Definition: SVED.h:111
void __initReqSets(const PRMInstance< GUM_SCALAR > *i)
Returns true if second can be eliminated before first.
Definition: SVED_tpl.h:466
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
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.
The class for generic Hash Tables.
Definition: hashTable.h:679
void __initLiftedNodes(const PRMInstance< GUM_SCALAR > *i, BucketSet &trash)
Returns true if second can be eliminated before first.
Definition: SVED_tpl.h:302
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: SVED.h:93
std::vector< NodeId > & __getElimOrder(const PRMClass< GUM_SCALAR > &c)
Returns true if second can be eliminated before first.
Definition: SVED_tpl.h:515
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void __insertLiftedNodes(const PRMInstance< GUM_SCALAR > *i, BucketSet &pool, BucketSet &trash)
Returns true if second can be eliminated before first.
Definition: SVED_tpl.h:283
This class is an implementation of the Structured Value Elimination algorithm on PRM<GUM_SCALAR>.
Definition: SVED.h:63
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Sequence< std::string > * __class_elim_order
Definition: SVED.h:130
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 __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)
Returns true if second can be eliminated before first.
Definition: SVED_tpl.h:116
StructuredBayesBall< GUM_SCALAR > __bb
Definition: SVED.h:132
std::string __trim(const std::string &s)
Returns true if second can be eliminated before first.
Definition: SVED_tpl.h:520
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: SVED_tpl.h:527
std::pair< const PRMInstance< GUM_SCALAR > *, const PRMAttribute< GUM_SCALAR > *> Chain
Code alias.
Definition: PRMInference.h:57
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.
A PRMClass is an object of a PRM representing a fragment of a Bayesian Network which can be instantia...
Definition: PRMClass.h:66
virtual void _joint(const std::vector< Chain > &queries, Potential< GUM_SCALAR > &j)
See PRMInference::_joint().
Definition: SVED_tpl.h:460
HashTable< const Set< NodeId > *, BucketSet *> __lifted_pools
The Set<NodeId> returned by StructuredBayesBall<GUM_SCALAR> is unique for each family of instances wi...
Definition: SVED.h:128
void __eliminateNodesWithEvidence(const PRMInstance< GUM_SCALAR > *i, BucketSet &pool, BucketSet &trash)
Returns true if second can be eliminated before first.
Definition: SVED_tpl.h:262
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 > *, std::vector< NodeId > *> __elim_orders
Definition: SVED.h:121
Set< Potential< GUM_SCALAR > *>::iterator_safe BucketSetIterator
Code alias.
Definition: SVED.h:114
Set< MultiDimArray< GUM_SCALAR > *>::iterator_safe ArraySetIterator
Code alias.
Definition: SVED.h:118
void __eliminateNodesUpward(const PRMInstance< GUM_SCALAR > *i, BucketSet &pool, BucketSet &trash, List< const PRMInstance< GUM_SCALAR > * > &elim_list, Set< const PRMInstance< GUM_SCALAR > * > &ignore)
Returns true if second can be eliminated before first.
Definition: SVED_tpl.h:189
virtual void _evidenceAdded(const Chain &chain)
See PRMInference::_evidenceAdded().
Definition: SVED_tpl.h:546
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Set< NodeId > & __getAttrSet(const PRMInstance< GUM_SCALAR > *i)
Returns true if second can be eliminated before first.
Definition: SVED_tpl.h:559
~SVED()
Destructor.
Definition: SVED_tpl.h:35
Size NodeId
Type for node ids.
Definition: graphElements.h:98
void __reduceElimList(const PRMInstance< GUM_SCALAR > *i, List< const PRMInstance< GUM_SCALAR > * > &elim_list, List< const PRMInstance< GUM_SCALAR > * > &reduced_list, Set< const PRMInstance< GUM_SCALAR > * > &ignore, BucketSet &pool, BucketSet &trash)
Returns true if second can be eliminated before first.
Definition: SVED_tpl.h:580