aGrUM  0.14.2
SVED.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
26 #ifndef GUM_SVED_H
27 #define GUM_SVED_H
28 
29 #include <vector>
30 
31 #include <agrum/core/set.h>
32 
35 
37 
41 
44 
48 namespace gum {
49  namespace prm {
50 
59  template < typename GUM_SCALAR >
60  class SVED : public PRMInference< GUM_SCALAR > {
61  public:
62  // ========================================================================
64  // ========================================================================
66 
68  SVED(const PRM< GUM_SCALAR >& prm, const PRMSystem< GUM_SCALAR >& model);
69 
71  ~SVED();
72 
74  // ========================================================================
76  // ========================================================================
78 
80  virtual std::string name() const;
81 
83  protected:
84  // ========================================================================
86  // ========================================================================
88 
91 
93  virtual void _evidenceAdded(const Chain& chain);
94 
96  virtual void _evidenceRemoved(const Chain& chain);
97 
99  virtual void _marginal(const Chain& chain, Potential< GUM_SCALAR >& m);
100 
102  virtual void _joint(const std::vector< Chain >& queries,
104 
106  private:
110  typedef
112 
114  typedef typename Set< MultiDimArray< GUM_SCALAR >* >::iterator_safe
116 
117  HashTable< const PRMClass< GUM_SCALAR >*, std::vector< NodeId >* >
119 
126 
128 
130 
134  std::pair< Set< NodeId >*, Set< NodeId >* > >
136 
138 
140 
142  NodeId id,
143  BucketSet& pool,
144  BucketSet& trash);
145 
147  const PRMInstance< GUM_SCALAR >* from,
148  const PRMInstance< GUM_SCALAR >* i,
149  BucketSet& pool,
150  BucketSet& trash,
151  List< const PRMInstance< GUM_SCALAR >* >& elim_list,
152  Set< const PRMInstance< GUM_SCALAR >* >& ignore);
153 
155  const PRMInstance< GUM_SCALAR >* i,
156  BucketSet& pool,
157  BucketSet& trash,
158  List< const PRMInstance< GUM_SCALAR >* >& elim_list,
159  Set< const PRMInstance< GUM_SCALAR >* >& ignore);
160 
162  BucketSet& pool,
163  BucketSet& trash);
164 
166  BucketSet& pool,
167  BucketSet& trash);
168 
171  const PRMInstance< GUM_SCALAR >* second);
172 
173  void __initElimOrder();
174 
175  void __insertEvidence(const PRMInstance< GUM_SCALAR >* i, BucketSet& pool);
176 
177  std::vector< NodeId >& __getElimOrder(const PRMClass< GUM_SCALAR >& c);
178 
181  const PRMAggregate< GUM_SCALAR >* agg);
182 
183  void __initLiftedNodes(const PRMInstance< GUM_SCALAR >* i, BucketSet& trash);
184 
186 
188 
190 
192  List< const PRMInstance< GUM_SCALAR >* >& elim_list,
193  List< const PRMInstance< GUM_SCALAR >* >& reduced_list,
194  Set< const PRMInstance< GUM_SCALAR >* >& ignore,
195  BucketSet& pool,
196  BucketSet& trash);
197 
198  std::string __trim(const std::string& s);
200  };
201 
202 
203 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
204  extern template class SVED< double >;
205 #endif
206 
207 
208  } /* namespace prm */
209 } /* namespace gum */
210 
212 
213 #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:135
aGrUM&#39;s Potential is a multi-dimensional array with tensor operators.
Definition: potential.h:57
Inline implementation of SVED.
virtual std::string name() const
Returns the name of the current inference algorithm.
Definition: SVED_tpl.h:600
void __insertEvidence(const PRMInstance< GUM_SCALAR > *i, BucketSet &pool)
Returns true if second can be eliminated before first.
Definition: SVED_tpl.h:504
virtual void _marginal(const Chain &chain, Potential< GUM_SCALAR > &m)
See PRMInference::_marginal().
Definition: SVED_tpl.h:405
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:43
<agrum/PRM/structuredBayesBall.h>
Sets of elements (i.e.
virtual void _evidenceRemoved(const Chain &chain)
See PRMInference::_evidenceRemoved().
Definition: SVED_tpl.h:549
SVED(const PRM< GUM_SCALAR > &prm, const PRMSystem< GUM_SCALAR > &model)
Default Constructor.
Definition: SVED_tpl.h:494
Set< NodeId > & __getSCSet(const PRMInstance< GUM_SCALAR > *i)
Returns true if second can be eliminated before first.
Definition: SVED_tpl.h:567
An PRMInstance is a Bayesian Network fragment defined by a Class and used in a PRMSystem.
Definition: PRMInstance.h:60
void __initElimOrder()
Returns true if second can be eliminated before first.
Definition: SVED_tpl.h:368
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:536
Set< Potential< GUM_SCALAR > *> BucketSet
Code alias.
Definition: SVED.h:108
void __initReqSets(const PRMInstance< GUM_SCALAR > *i)
Returns true if second can be eliminated before first.
Definition: SVED_tpl.h:463
Generic doubly linked lists.
Definition: list.h:369
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
Implementation of a variable elimination algorithm for inference in Bayesian Networks.
Headers of ClassDependencyGraph<GUM_SCALAR>.
The class for generic Hash Tables.
Definition: hashTable.h:676
void __initLiftedNodes(const PRMInstance< GUM_SCALAR > *i, BucketSet &trash)
Returns true if second can be eliminated before first.
Definition: SVED_tpl.h:299
Headers of ClassBayesNet<GUM_SCALAR>.
Representation of a setA Set is a structure that contains arbitrary elements.
Definition: set.h:162
PRMInference< GUM_SCALAR >::Chain Chain
Code alias.
Definition: SVED.h:90
std::vector< NodeId > & __getElimOrder(const PRMClass< GUM_SCALAR > &c)
Returns true if second can be eliminated before first.
Definition: SVED_tpl.h:512
Header of the Potential class.
void __insertLiftedNodes(const PRMInstance< GUM_SCALAR > *i, BucketSet &pool, BucketSet &trash)
Returns true if second can be eliminated before first.
Definition: SVED_tpl.h:280
This class is an implementation of the Structured Value Elimination algorithm on PRM<GUM_SCALAR>.
Definition: SVED.h:60
Headers of StructuredBayesBall.
Sequence< std::string > * __class_elim_order
Definition: SVED.h:127
Headers of PRMInference.
A PRMSystem is a container of PRMInstance and describe a relational skeleton.
Definition: PRMObject.h:226
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:113
StructuredBayesBall< GUM_SCALAR > __bb
Definition: SVED.h:129
std::string __trim(const std::string &s)
Returns true if second can be eliminated before first.
Definition: SVED_tpl.h:517
Headers of InstanceBayesNet.
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:524
std::pair< const PRMInstance< GUM_SCALAR > *, const PRMAttribute< GUM_SCALAR > *> Chain
Code alias.
Definition: PRMInference.h:54
This abstract class is used as base class for all inference class on PRM<GUM_SCALAR>.
Definition: PRMInference.h:49
This class represents a Probabilistic Relational PRMSystem<GUM_SCALAR>.
Definition: PRM.h:63
class for graph triangulations for which we enforce a given partial ordering on the nodes elimination...
A PRMClass is an object of a PRM representing a fragment of a Bayesian Network which can be instantia...
Definition: PRMClass.h:63
virtual void _joint(const std::vector< Chain > &queries, Potential< GUM_SCALAR > &j)
See PRMInference::_joint().
Definition: SVED_tpl.h:457
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:125
void __eliminateNodesWithEvidence(const PRMInstance< GUM_SCALAR > *i, BucketSet &pool, BucketSet &trash)
Returns true if second can be eliminated before first.
Definition: SVED_tpl.h:259
Headers of the MultiDimBucket class.
Class for computing default triangulations of graphs.
HashTable< const PRMClass< GUM_SCALAR > *, std::vector< NodeId > *> __elim_orders
Definition: SVED.h:118
Set< Potential< GUM_SCALAR > *>::iterator_safe BucketSetIterator
Code alias.
Definition: SVED.h:111
Set< MultiDimArray< GUM_SCALAR > *>::iterator_safe ArraySetIterator
Code alias.
Definition: SVED.h:115
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:186
virtual void _evidenceAdded(const Chain &chain)
See PRMInference::_evidenceAdded().
Definition: SVED_tpl.h:543
Header of the MultiDimArray class.
Set< NodeId > & __getAttrSet(const PRMInstance< GUM_SCALAR > *i)
Returns true if second can be eliminated before first.
Definition: SVED_tpl.h:556
~SVED()
Destructor.
Definition: SVED_tpl.h:32
Size NodeId
Type for node ids.
Definition: graphElements.h:97
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:577