aGrUM  0.16.0
PRMSystem.h
Go to the documentation of this file.
1 
30 #ifndef GUM_SYSTEM_H
31 #define GUM_SYSTEM_H
32 
33 #include <utility>
34 #include <string>
35 
36 #include <agrum/core/hashTable.h>
37 #include <agrum/core/sequence.h>
38 #include <agrum/core/set.h>
39 
40 #include <agrum/graphs/diGraph.h>
41 
43 
47 
48 namespace gum {
49  namespace prm {
50 
58  template < typename GUM_SCALAR >
59  class PRMSystem : public PRMObject {
60  public:
61  // ========================================================================
63  // ========================================================================
65 
67  explicit PRMSystem(const std::string& name);
68 
70  virtual ~PRMSystem();
71 
73  // ========================================================================
75  // ========================================================================
77 
79  const DiGraph& skeleton() const;
80 
86  PRMInstance< GUM_SCALAR >& get(NodeId id);
87 
93  const PRMInstance< GUM_SCALAR >& get(NodeId id) const;
94 
95  NodeId get(const PRMInstance< GUM_SCALAR >& i) const;
96 
97  /* @todo should be removed ?
98  void addArc( const std::string& u,
99  const std::string& v,
100  const std::string& ref );*/
101 
103  // ========================================================================
105  // ========================================================================
107 
109  virtual PRMObject::prm_type obj_type() const;
110 
112  Size size() const;
113 
116  bool exists(const std::string& name) const;
117 
121  bool isInstantiated(const PRMClass< GUM_SCALAR >& c) const;
122 
124  bool isInstance(const std::string& name) const;
125 
127  bool isArray(const std::string& name) const;
128 
133  void groundedBN(BayesNetFactory< GUM_SCALAR >& factory) const;
134 
136  void instantiate();
137 
139  // ========================================================================
141  // ========================================================================
143 
146  PRMInstance< GUM_SCALAR >& get(const std::string& name);
147 
150  const PRMInstance< GUM_SCALAR >& get(const std::string& name) const;
151 
154  const Set< PRMInstance< GUM_SCALAR >* >&
155  get(const PRMClass< GUM_SCALAR >& type) const;
156 
160  NodeId add(PRMInstance< GUM_SCALAR >* i);
161 
163  // ========================================================================
165  // ========================================================================
167 
170  const Sequence< PRMInstance< GUM_SCALAR >* >&
171  getArray(const std::string& name) const;
172 
175  PRMClassElementContainer< GUM_SCALAR >&
176  getArrayType(const std::string& name);
177 
180  const PRMClassElementContainer< GUM_SCALAR >&
181  getArrayType(const std::string& name) const;
182 
189  NodeId add(const std::string& array, PRMInstance< GUM_SCALAR >* i);
190 
197  NodeId add(const std::string& array, PRMInstance< GUM_SCALAR >& i);
198 
203  void addArray(const std::string& array,
204  PRMClassElementContainer< GUM_SCALAR >& type);
205 
207  // ========================================================================
209  // ========================================================================
211 
213  typedef
215 
217  iterator begin();
218 
221  const iterator& end();
222 
226 
228  const_iterator begin() const;
229 
232  const const_iterator& end() const;
233 
235  typedef
237 
241  array_iterator begin(const std::string& a);
242 
246  const array_iterator& end(const std::string& a);
247 
251 
255  const_array_iterator begin(const std::string& a) const;
256 
260  const const_array_iterator& end(const std::string& a) const;
261 
263  private:
265  PRMSystem(const PRMSystem< GUM_SCALAR >& from);
266 
269 
270  // ========================================================================
272  // ========================================================================
274 
277 
281 
284 
288 
291  typedef std::pair< PRMClassElementContainer< GUM_SCALAR >*,
294 
298 
300  // ========================================================================
302  // ========================================================================
304 
310  void __groundRef(const PRMInstance< GUM_SCALAR >& instance,
311  BayesNetFactory< GUM_SCALAR >& factory) const;
312 
317  void __groundAttr(const PRMInstance< GUM_SCALAR >& instance,
318  BayesNetFactory< GUM_SCALAR >& factory) const;
319 
328  void __groundPotential(const PRMInstance< GUM_SCALAR >& instance,
329  const PRMAttribute< GUM_SCALAR >& attr,
330  BayesNetFactory< GUM_SCALAR >& factory) const;
331 
338  const std::string& name,
339  BayesNetFactory< GUM_SCALAR >& factory) const;
341  };
342 
343 
344 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
345  extern template class PRMSystem< double >;
346 #endif
347 
348 
349  } /* namespace prm */
350 
351 } /* namespace gum */
352 
354 
355 #endif // GUM_SYSTEM_H
void __groundPotential(const PRMInstance< GUM_SCALAR > &instance, const PRMAttribute< GUM_SCALAR > &attr, BayesNetFactory< GUM_SCALAR > &factory) const
Method which copy node&#39;s Potential of an PRMInstance to the grounded Bayesian Network.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Unsafe Const Iterators for hashtablesHashTableConstIterator provides a fast but unsafe way to parse H...
Definition: hashTable.h:2465
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.
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
PRMClassElementContainer< GUM_SCALAR > & getArrayType(const std::string &name)
Returns the type of the given array.
iterator begin()
Returns an iterator over the instances in this system.
virtual ~PRMSystem()
Destructor.
Definition: PRMSystem_tpl.h:45
An PRMInstance is a Bayesian Network fragment defined by a Class and used in a PRMSystem.
Definition: PRMInstance.h:63
NodeProperty< PRMInstance< GUM_SCALAR > *>::iterator iterator
Iterator over the PRMInstance of this PRMSystem.
Definition: PRMSystem.h:214
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Unsafe Iterators for hashtablesHashTableIterator provides a fast but unsafe way to parse HashTables...
Definition: hashTable.h:2750
bool isInstantiated(const PRMClass< GUM_SCALAR > &c) const
Returns true if the given Class<GUM_SCALAR> has at least one PRMInstance in this PRMSystem.
The generic class for storing (ordered) sequences of objects.
Definition: sequence.h:1022
Abstract class representing an element of PRM class.
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
PRMSystem(const std::string &name)
Default constructor.
Definition: PRMSystem_tpl.h:40
NodeId add(PRMInstance< GUM_SCALAR > *i)
Add an PRMInstance to this system.
Definition: PRMSystem_tpl.h:59
Representation of a setA Set is a structure that contains arbitrary elements.
Definition: set.h:165
PRMSystem< GUM_SCALAR > & operator=(const PRMSystem< GUM_SCALAR > &from)
Copy operator. Don&#39;t use it.
const DiGraph & skeleton() const
Returns the relation skeleton of this PRMSystem.
prm_type
Enumeration of the different types of objects handled by a PRM.
Definition: PRMObject.h:69
bool isInstance(const std::string &name) const
Returns true if an PRMInstance with the given name exists.
virtual PRMObject::prm_type obj_type() const
Returns the PRM type of this object.
void __groundAgg(const PRMClassElement< GUM_SCALAR > &elt, const std::string &name, BayesNetFactory< GUM_SCALAR > &factory) const
Ground an aggregator with the given name in the grounded IBayesNet.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
HashTable< PRMClass< GUM_SCALAR > *, Set< PRMInstance< GUM_SCALAR > *> *> __instanceMap
Mapping between a class and all it&#39;s PRMInstance in this system.
Definition: PRMSystem.h:287
NodeProperty< PRMInstance< GUM_SCALAR > *>::const_iterator const_iterator
Constant Iterator over the PRMInstance of this PRMSystem.
Definition: PRMSystem.h:225
void groundedBN(BayesNetFactory< GUM_SCALAR > &factory) const
Returns the grounded Bayesian Network of this system.
Definition: PRMSystem_tpl.h:82
DiGraph __skeleton
The relational skeleton of this PRMSystem.
Definition: PRMSystem.h:276
Base class for all oriented graphs.
Definition: diGraph.h:111
A PRMSystem is a container of PRMInstance and describe a relational skeleton.
Definition: PRMObject.h:229
HashTable< std::string, PRMInstance< GUM_SCALAR > *> __nameMap
The mapping between PRMInstance and their names.
Definition: PRMSystem.h:283
Sequence< PRMInstance< GUM_SCALAR > *>::iterator array_iterator
Iterator over the PRMInstance in an array in this PRMSystem.
Definition: PRMSystem.h:236
void instantiate()
Instantiate all the PRMInstance in this PRMSystem.
std::pair< PRMClassElementContainer< GUM_SCALAR > *, Sequence< PRMInstance< GUM_SCALAR > *> *> model_pair
Typedef of the pair of a Class<GUM_SCALAR> and the sequence of it&#39;s instantiation.
Definition: PRMSystem.h:293
Sequence< PRMInstance< GUM_SCALAR > *>::const_iterator const_array_iterator
Iterator over the PRMInstance in an array in this PRMSystem.
Definition: PRMSystem.h:250
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
bool exists(const std::string &name) const
Retruns true either if name is an instance or an array in this PRMSystem.
void __groundRef(const PRMInstance< GUM_SCALAR > &instance, BayesNetFactory< GUM_SCALAR > &factory) const
Method which ground PRMReferenceSlot of an PRMInstance and add arcs in the IBayesNet.
Size size() const
Returns the number of PRMInstance in this PRMSystem.
bool isArray(const std::string &name) const
Returns true if an array with the given name exists.
const Sequence< PRMInstance< GUM_SCALAR > *> & getArray(const std::string &name) const
Returns the sequence of instances of a given array.
NodeProperty< PRMInstance< GUM_SCALAR > *> __nodeIdMap
The maping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:280
PRMAttribute is a member of a Class in a PRM.
Definition: PRMAttribute.h:61
HashTable< std::string, model_pair > __arrayMap
Mapping between arrays and their name. The first element of the pair is the type of the array...
Definition: PRMSystem.h:297
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
const iterator & end()
Returns a iterator at the end of the set of PRMInstance in this PRMSystem.
void __groundAttr(const PRMInstance< GUM_SCALAR > &instance, BayesNetFactory< GUM_SCALAR > &factory) const
Method which ground Atttributes and Aggregators of an PRMInstance.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void addArray(const std::string &array, PRMClassElementContainer< GUM_SCALAR > &type)
Add an array of instances in this system. If the array doesn&#39;t exists it is created.
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.
Size NodeId
Type for node ids.
Definition: graphElements.h:98
A factory class to ease BayesNet construction.
Definition: BayesNet.h:45