aGrUM  0.16.0
gum::prm::PRMSystem< GUM_SCALAR > Class Template Reference

A PRMSystem is a container of PRMInstance and describe a relational skeleton. More...

#include <PRMObject.h>

+ Inheritance diagram for gum::prm::PRMSystem< GUM_SCALAR >:
+ Collaboration diagram for gum::prm::PRMSystem< GUM_SCALAR >:

Public Member Functions

Constructors & destructor.
 PRMSystem (const std::string &name)
 Default constructor. More...
 
virtual ~PRMSystem ()
 Destructor. More...
 
Getters & setters over the relational skeleton.
const DiGraphskeleton () const
 Returns the relation skeleton of this PRMSystem. More...
 
PRMInstance< GUM_SCALAR > & get (NodeId id)
 Returns an PRMInstance given it's NodeId in the relational skeleton. More...
 
const PRMInstance< GUM_SCALAR > & get (NodeId id) const
 Returns an PRMInstance given it's NodeId in the relational skeleton. More...
 
NodeId get (const PRMInstance< GUM_SCALAR > &i) const
 Returns the relation skeleton of this PRMSystem. More...
 
Getters & setters over PRMInstance and array of PRMInstance.
virtual PRMObject::prm_type obj_type () const
 Returns the PRM type of this object. More...
 
Size size () const
 Returns the number of PRMInstance in this PRMSystem. More...
 
bool exists (const std::string &name) const
 Retruns true either if name is an instance or an array in this PRMSystem. More...
 
bool isInstantiated (const PRMClass< GUM_SCALAR > &c) const
 Returns true if the given Class<GUM_SCALAR> has at least one PRMInstance in this PRMSystem. More...
 
bool isInstance (const std::string &name) const
 Returns true if an PRMInstance with the given name exists. More...
 
bool isArray (const std::string &name) const
 Returns true if an array with the given name exists. More...
 
void groundedBN (BayesNetFactory< GUM_SCALAR > &factory) const
 Returns the grounded Bayesian Network of this system. More...
 
void instantiate ()
 Instantiate all the PRMInstance in this PRMSystem. More...
 
PRMInstance handling.
PRMInstance< GUM_SCALAR > & get (const std::string &name)
 Returns a reference over an PRMInstance given it's name. More...
 
const PRMInstance< GUM_SCALAR > & get (const std::string &name) const
 Returns a constant reference over an PRMInstance given it's name. More...
 
const Set< PRMInstance< GUM_SCALAR > *> & get (const PRMClass< GUM_SCALAR > &type) const
 Returns the sequence of all instances of the given type. More...
 
NodeId add (PRMInstance< GUM_SCALAR > *i)
 Add an PRMInstance to this system. More...
 
Array handling.
const Sequence< PRMInstance< GUM_SCALAR > *> & getArray (const std::string &name) const
 Returns the sequence of instances of a given array. More...
 
PRMClassElementContainer< GUM_SCALAR > & getArrayType (const std::string &name)
 Returns the type of the given array. More...
 
const PRMClassElementContainer< GUM_SCALAR > & getArrayType (const std::string &name) const
 Returns the type of the given array. More...
 
NodeId add (const std::string &array, PRMInstance< GUM_SCALAR > *i)
 Add an PRMInstance to an array in this system. If the array doesn't exists it is created. More...
 
NodeId add (const std::string &array, PRMInstance< GUM_SCALAR > &i)
 Add an PRMInstance to an array in this system. If the array doesn't exists it is created. More...
 
void addArray (const std::string &array, PRMClassElementContainer< GUM_SCALAR > &type)
 Add an array of instances in this system. If the array doesn't exists it is created. More...
 
Getters & setters.
const std::string & name () const
 Returns the name of this object. More...
 
void name (const std::string &name)
 Change the name of the PRM Object. More...
 
Operators
bool operator== (const PRMObject &obj) const
 To PRMObject are equal if they have the same name (which is unique). More...
 
bool operator!= (const PRMObject &obj) const
 To PRMObject are equal if they have the same name (which is unique). More...
 

Built-in types.

enum  prm_type : char {
  prm_type::ALL, prm_type::CLASS, prm_type::PRM_INTERFACE, prm_type::CLASS_ELT,
  prm_type::TYPE, prm_type::SYSTEM, prm_type::INSTANCE
}
 Enumeration of the different types of objects handled by a PRM. More...
 
static std::string LEFT_CAST ()
 Enumeration of the different types of objects handled by a PRM. More...
 
static std::string RIGHT_CAST ()
 Enumeration of the different types of objects handled by a PRM. More...
 
static std::string enum2str (prm_type type)
 Returns the string representation of a PRMObject. More...
 
static INLINE bool isClass (const PRMObject &obj)
 Returns true if obj_ptr is of type Class. More...
 
static INLINE bool isInterface (const PRMObject &obj)
 Returns true if obj_ptr is of type PRMInterface. More...
 
static INLINE bool isInstance (const PRMObject &obj)
 Returns true if obj_ptr is of type PRMInstance. More...
 

Iterators.

typedef NodeProperty< PRMInstance< GUM_SCALAR > *>::iterator iterator
 Iterator over the PRMInstance of this PRMSystem. More...
 
typedef NodeProperty< PRMInstance< GUM_SCALAR > *>::const_iterator const_iterator
 Constant Iterator over the PRMInstance of this PRMSystem. More...
 
typedef Sequence< PRMInstance< GUM_SCALAR > *>::iterator array_iterator
 Iterator over the PRMInstance in an array in this PRMSystem. More...
 
typedef Sequence< PRMInstance< GUM_SCALAR > *>::const_iterator const_array_iterator
 Iterator over the PRMInstance in an array in this PRMSystem. More...
 
iterator begin ()
 Returns an iterator over the instances in this system. More...
 
const iteratorend ()
 Returns a iterator at the end of the set of PRMInstance in this PRMSystem. More...
 
const_iterator begin () const
 Returns a constant iterator over the instances in this system. More...
 
const const_iteratorend () const
 Returns a constant iterator at the end of the set of PRMInstance in this PRMSystem. More...
 
array_iterator begin (const std::string &a)
 Returns an iterator at the beginning of the Sequence of PRMInstance in the array named a;. More...
 
const array_iteratorend (const std::string &a)
 Returns an iterator at the end of the Sequence of PRMInstance in the array named a. More...
 
const_array_iterator begin (const std::string &a) const
 Returns an iterator at the beginning of the Sequence of PRMInstance in the array named a;. More...
 
const const_array_iteratorend (const std::string &a) const
 Returns an iterator at the end of the Sequence of PRMInstance in the array named a. More...
 

Private PRMInstance handling methods and members.

typedef 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's instantiation. More...
 
DiGraph __skeleton
 The relational skeleton of this PRMSystem. More...
 
NodeProperty< PRMInstance< GUM_SCALAR > *> __nodeIdMap
 The maping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem. More...
 
HashTable< std::string, PRMInstance< GUM_SCALAR > *> __nameMap
 The mapping between PRMInstance and their names. More...
 
HashTable< PRMClass< GUM_SCALAR > *, Set< PRMInstance< GUM_SCALAR > *> *> __instanceMap
 Mapping between a class and all it's PRMInstance in this system. More...
 
HashTable< std::string, model_pair__arrayMap
 Mapping between arrays and their name. The first element of the pair is the type of the array. More...
 

Detailed Description

template<typename GUM_SCALAR>
class gum::prm::PRMSystem< GUM_SCALAR >

A PRMSystem is a container of PRMInstance and describe a relational skeleton.

Definition at line 229 of file PRMObject.h.

Member Typedef Documentation

◆ array_iterator

template<typename GUM_SCALAR>
typedef Sequence< PRMInstance< GUM_SCALAR >* >::iterator gum::prm::PRMSystem< GUM_SCALAR >::array_iterator

Iterator over the PRMInstance in an array in this PRMSystem.

Definition at line 236 of file PRMSystem.h.

◆ const_array_iterator

template<typename GUM_SCALAR>
typedef Sequence< PRMInstance< GUM_SCALAR >* >::const_iterator gum::prm::PRMSystem< GUM_SCALAR >::const_array_iterator

Iterator over the PRMInstance in an array in this PRMSystem.

Definition at line 250 of file PRMSystem.h.

◆ const_iterator

template<typename GUM_SCALAR>
typedef NodeProperty< PRMInstance< GUM_SCALAR >* >::const_iterator gum::prm::PRMSystem< GUM_SCALAR >::const_iterator

Constant Iterator over the PRMInstance of this PRMSystem.

Definition at line 225 of file PRMSystem.h.

◆ iterator

template<typename GUM_SCALAR>
typedef NodeProperty< PRMInstance< GUM_SCALAR >* >::iterator gum::prm::PRMSystem< GUM_SCALAR >::iterator

Iterator over the PRMInstance of this PRMSystem.

Definition at line 214 of file PRMSystem.h.

◆ model_pair

template<typename GUM_SCALAR>
typedef std::pair< PRMClassElementContainer< GUM_SCALAR >*, Sequence< PRMInstance< GUM_SCALAR >* >* > gum::prm::PRMSystem< GUM_SCALAR >::model_pair
private

Typedef of the pair of a Class<GUM_SCALAR> and the sequence of it's instantiation.

Definition at line 293 of file PRMSystem.h.

Member Enumeration Documentation

◆ prm_type

enum gum::prm::PRMObject::prm_type : char
stronginherited

Enumeration of the different types of objects handled by a PRM.

The "all" type is used to tell that we want any kind of PRMType (useful with iterators for example). No PRMObject will ever have "all" as type.

Enumerator
ALL 
CLASS 
PRM_INTERFACE 
CLASS_ELT 
TYPE 
SYSTEM 
INSTANCE 

Definition at line 69 of file PRMObject.h.

69  : char {
70  ALL,
71  CLASS,
72  PRM_INTERFACE,
73  CLASS_ELT,
74  TYPE,
75  SYSTEM,
76  INSTANCE
77  };

Constructor & Destructor Documentation

◆ PRMSystem() [1/2]

template<typename GUM_SCALAR >
gum::prm::PRMSystem< GUM_SCALAR >::PRMSystem ( const std::string &  name)
explicit

Default constructor.

Definition at line 40 of file PRMSystem_tpl.h.

40  : PRMObject(name) {
41  GUM_CONSTRUCTOR(PRMSystem);
42  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
PRMSystem(const std::string &name)
Default constructor.
Definition: PRMSystem_tpl.h:40
PRMObject(const std::string &name)
Constructor.
Definition: PRMObject.cpp:43

◆ ~PRMSystem()

template<typename GUM_SCALAR >
gum::prm::PRMSystem< GUM_SCALAR >::~PRMSystem ( )
virtual

Destructor.

Definition at line 45 of file PRMSystem_tpl.h.

45  {
46  GUM_DESTRUCTOR(PRMSystem);
47 
48  for (const auto& elt : *this)
49  delete elt.second;
50 
51  for (const auto& elt : __instanceMap)
52  delete elt.second;
53 
54  for (const auto& elt : __arrayMap)
55  delete elt.second.second;
56  }
PRMSystem(const std::string &name)
Default constructor.
Definition: PRMSystem_tpl.h:40
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
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

◆ PRMSystem() [2/2]

template<typename GUM_SCALAR>
gum::prm::PRMSystem< GUM_SCALAR >::PRMSystem ( const PRMSystem< GUM_SCALAR > &  from)
private

Copy constructor. Don't use it.

Member Function Documentation

◆ __groundAgg()

template<typename GUM_SCALAR>
void gum::prm::PRMSystem< GUM_SCALAR >::__groundAgg ( const PRMClassElement< GUM_SCALAR > &  elt,
const std::string &  name,
BayesNetFactory< GUM_SCALAR > &  factory 
) const
private

Ground an aggregator with the given name in the grounded IBayesNet.

Parameters
eltThe aggregator grounded.
nameThe aggregator's name in the grounded IBayesNet.
factoryThe factory used to build the grounded IBayesNet.

Definition at line 139 of file PRMSystem_tpl.h.

142  {
143  factory.startVariableDeclaration();
144  factory.variableName(name);
145  const DiscreteVariable& agg_var = elt.type().variable();
146 
147  for (Idx i = 0; i < agg_var.domainSize(); ++i) {
148  factory.addModality(agg_var.label(i));
149  }
150 
151  const PRMAggregate< GUM_SCALAR >& agg =
152  static_cast< const PRMAggregate< GUM_SCALAR >& >(elt);
153 
154  switch (agg.agg_type()) {
156  factory.setVariableCPTImplementation(
157  new aggregator::Min< GUM_SCALAR >());
158  break;
159  }
160 
162  factory.setVariableCPTImplementation(
163  new aggregator::Max< GUM_SCALAR >());
164  break;
165  }
166 
168  factory.setVariableCPTImplementation(
169  new aggregator::Exists< GUM_SCALAR >(agg.label()));
170  break;
171  }
172 
174  factory.setVariableCPTImplementation(
175  new aggregator::Forall< GUM_SCALAR >(agg.label()));
176  break;
177  }
178 
180  factory.setVariableCPTImplementation(
181  new aggregator::Count< GUM_SCALAR >(agg.label()));
182  break;
183  }
184 
186  factory.setVariableCPTImplementation(
187  new aggregator::Median< GUM_SCALAR >());
188  break;
189  }
190 
192  factory.setVariableCPTImplementation(
193  new aggregator::Amplitude< GUM_SCALAR >());
194  break;
195  }
196 
198  factory.setVariableCPTImplementation(new aggregator::Or< GUM_SCALAR >());
199  break;
200  }
201 
203  factory.setVariableCPTImplementation(
204  new aggregator::And< GUM_SCALAR >());
205  break;
206  }
207 
208  default: {
209  GUM_ERROR(OperationNotAllowed, "Aggregator not handled yet");
210  break;
211  }
212  }
213 
214  factory.endVariableDeclaration();
215  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ __groundAttr()

template<typename GUM_SCALAR>
void gum::prm::PRMSystem< GUM_SCALAR >::__groundAttr ( const PRMInstance< GUM_SCALAR > &  instance,
BayesNetFactory< GUM_SCALAR > &  factory 
) const
private

Method which ground Atttributes and Aggregators of an PRMInstance.

Parameters
instanceThe PRMInstance grounded by this method.
factoryThe factory used to build the grounded IBayesNet.

Definition at line 102 of file PRMSystem_tpl.h.

104  {
105  for (const auto node : instance.type().containerDag()) {
106  // Working a Class<GUM_SCALAR> level because PRMAggregate<GUM_SCALAR>
107  // are
108  // instantiated as PRMAttribute<GUM_SCALAR> in an
109  // PRMInstance<GUM_SCALAR>
110  switch (instance.type().get(node).elt_type()) {
112  // TODO: make a special case for noisy-or
113  std::stringstream elt_name;
114  elt_name << instance.name() << "."
115  << instance.type().get(node).safeName();
116  DiscreteVariable* var = instance.get(node).type().variable().clone();
117  var->setName(elt_name.str());
118  factory.setVariable(*var); // var is copied by the factory
119  delete var;
120  break;
121  }
122 
124  std::stringstream elt_name;
125  elt_name << instance.name() << "."
126  << instance.type().get(node).safeName();
127  __groundAgg(instance.type().get(node), elt_name.str(), factory);
128  break;
129  }
130 
131  default:
132  break;
133  /* Do nothing */;
134  }
135  }
136  }
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.

◆ __groundPotential()

template<typename GUM_SCALAR>
void gum::prm::PRMSystem< GUM_SCALAR >::__groundPotential ( const PRMInstance< GUM_SCALAR > &  instance,
const PRMAttribute< GUM_SCALAR > &  attr,
BayesNetFactory< GUM_SCALAR > &  factory 
) const
private

Method which copy node's Potential of an PRMInstance to the grounded Bayesian Network.

Parameters
instanceThe PRMInstance currently grounded.
attrThe PRMAttribute<GUM_SCALAR> for which the Potential is grounded.
factoryThe factory used to build the grounded IBayesNet.

Definition at line 272 of file PRMSystem_tpl.h.

275  {
276  Bijection< const DiscreteVariable*, const DiscreteVariable* > bijection;
277  std::stringstream var_name;
278  var_name << instance.name() << "." << attr.safeName();
279  bijection.insert(&(attr.type().variable()),
280  &(factory.variable(var_name.str())));
281 
282  for (const auto parent : instance.type().containerDag().parents(attr.id())) {
283  switch (instance.type().get(parent).elt_type()) {
286  std::stringstream parent_name;
287  parent_name << instance.name() << "."
288  << instance.get(parent).safeName();
289  bijection.insert(&(instance.get(parent).type().variable()),
290  &(factory.variable(parent_name.str())));
291  break;
292  }
293 
295  std::stringstream parent_name;
296  const PRMSlotChain< GUM_SCALAR >& sc =
297  static_cast< const PRMSlotChain< GUM_SCALAR >& >(
298  instance.type().get(parent));
299  parent_name << instance.getInstance(sc.id()).name() << "."
300  << sc.lastElt().safeName();
301  bijection.insert(&(instance.getInstance(sc.id())
302  .get(sc.lastElt().safeName())
303  .type()
304  .variable()),
305  &(factory.variable(parent_name.str())));
306  break;
307  }
308 
309  default: {
310  GUM_ERROR(FatalError,
311  "invalid ClassElement<GUM_SCALAR> type as parent.");
312  break;
313  }
314  }
315  }
316 
317  // Copy Potential
318  // DO NOT USE MultiDimBijArray as they will wreck havok if you delete
319  // the prm befor its grounded BN (happens a lot in pyAgrum)
320  Potential< GUM_SCALAR >* p = new Potential< GUM_SCALAR >();
321  for (auto var : attr.cpf().variablesSequence()) {
322  p->add(*(bijection.second(var)));
323  }
324  Instantiation inst(attr.cpf()), jnst(*p);
325  for (inst.setFirst(), jnst.setFirst(); !(inst.end() || jnst.end());
326  inst.inc(), jnst.inc()) {
327  p->set(jnst, attr.cpf().get(inst));
328  }
329  GUM_ASSERT(inst.end() && jnst.end());
330  factory.setVariableCPT(var_name.str(), p, false);
331  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ __groundRef()

template<typename GUM_SCALAR>
void gum::prm::PRMSystem< GUM_SCALAR >::__groundRef ( const PRMInstance< GUM_SCALAR > &  instance,
BayesNetFactory< GUM_SCALAR > &  factory 
) const
private

Method which ground PRMReferenceSlot of an PRMInstance and add arcs in the IBayesNet.

Parameters
instanceThe PRMInstance grounded by this method.
factoryThe factory used to build the grounded IBayesNet.

Definition at line 218 of file PRMSystem_tpl.h.

220  {
221  for (const auto& elt : instance) {
222  std::stringstream elt_name;
223  elt_name << instance.name() << "." << elt.second->safeName();
224  factory.startParentsDeclaration(elt_name.str());
225 
226  for (const auto par :
227  instance.type().containerDag().parents(elt.second->id())) {
228  switch (instance.type().get(par).elt_type()) {
231  std::stringstream parent_name;
232  parent_name << instance.name() << "."
233  << instance.get(par).safeName();
234  factory.addParent(parent_name.str());
235  break;
236  }
237 
239  std::string parent_name =
240  static_cast< const PRMSlotChain< GUM_SCALAR >& >(
241  instance.type().get(par))
242  .lastElt()
243  .safeName();
244 
245  for (const auto ref : instance.getInstances(par)) {
246  std::stringstream sBuff;
247  sBuff << ref->name() << "." << parent_name;
248  factory.addParent(sBuff.str());
249  }
250 
251  break;
252  }
253 
254  default:
255  break;
256  /* nothing to do by default */
257  }
258  }
259 
260  factory.endParentsDeclaration();
261 
262  // Checking if we need to ground the Potential (only for class level
263  // attributes since
264  // aggregates Potentials are generated)
266  instance.type().get(elt.second->safeName())))
267  __groundPotential(instance, *elt.second, factory);
268  }
269  }
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.
static INLINE bool isAttribute(const PRMClassElement< GUM_SCALAR > &elt)
Returns true if obj_ptr is of type PRMAttribute.

◆ add() [1/3]

template<typename GUM_SCALAR>
NodeId gum::prm::PRMSystem< GUM_SCALAR >::add ( PRMInstance< GUM_SCALAR > *  i)

Add an PRMInstance to this system.

Exceptions
DuplicateElementRaised if an PRMInstance with the same name already exists.

Definition at line 59 of file PRMSystem_tpl.h.

Referenced by gum::prm::PRMFactory< GUM_SCALAR >::addArray(), gum::prm::PRMFactory< GUM_SCALAR >::incArray(), and gum::O3prmBNReader< GUM_SCALAR >::proceed().

59  {
60  if (__nameMap.exists(i->name())) {
61  GUM_ERROR(
62  DuplicateElement,
63  "an Instance<GUM_SCALAR> with the same is already in this System");
64  }
65 
66  NodeId id = __skeleton.addNode();
67  __nodeIdMap.insert(id, i);
68  __nameMap.insert(i->name(), i);
69 
70  try {
71  __instanceMap[&(i->type())]->insert(i);
72  } catch (NotFound&) {
73  __instanceMap.insert(&(i->type()),
74  new Set< PRMInstance< GUM_SCALAR >* >());
75  __instanceMap[&(i->type())]->insert(i);
76  }
77 
78  return id;
79  }
virtual NodeId addNode()
insert a new node and return its id
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
DiGraph __skeleton
The relational skeleton of this PRMSystem.
Definition: PRMSystem.h:276
HashTable< std::string, PRMInstance< GUM_SCALAR > *> __nameMap
The mapping between PRMInstance and their names.
Definition: PRMSystem.h:283
NodeProperty< PRMInstance< GUM_SCALAR > *> __nodeIdMap
The maping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:280
Size NodeId
Type for node ids.
Definition: graphElements.h:98
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the caller graph for this function:

◆ add() [2/3]

template<typename GUM_SCALAR>
INLINE NodeId gum::prm::PRMSystem< GUM_SCALAR >::add ( const std::string &  array,
PRMInstance< GUM_SCALAR > *  i 
)

Add an PRMInstance to an array in this system. If the array doesn't exists it is created.

Exceptions
TypeErrorRaised if i is not of the good type.
DuplicateElementRaised if an PRMInstance with same name already exists.

Definition at line 472 of file PRMSystem_tpl.h.

473  {
474  try {
475  if (i->type().isSubTypeOf(*(__arrayMap[array].first))) {
476  NodeId id = add(i);
477  __arrayMap[array].second->insert(i);
478  return id;
479  } else {
480  GUM_ERROR(TypeError,
481  "the given Instance<GUM_SCALAR> is of an incorrect "
482  "Class<GUM_SCALAR> type");
483  }
484  } catch (NotFound&) {
485  GUM_ERROR(NotFound, "found no array matching the given name");
486  }
487  }
NodeId add(PRMInstance< GUM_SCALAR > *i)
Add an PRMInstance to this system.
Definition: PRMSystem_tpl.h:59
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
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
Size NodeId
Type for node ids.
Definition: graphElements.h:98
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ add() [3/3]

template<typename GUM_SCALAR>
INLINE NodeId gum::prm::PRMSystem< GUM_SCALAR >::add ( const std::string &  array,
PRMInstance< GUM_SCALAR > &  i 
)

Add an PRMInstance to an array in this system. If the array doesn't exists it is created.

Exceptions
TypeErrorRaised if i is not of the good type.
DuplicateElementRaised if an PRMInstance with same name already exists.

Definition at line 334 of file PRMSystem_tpl.h.

335  {
336  return add(array, &i);
337  }
NodeId add(PRMInstance< GUM_SCALAR > *i)
Add an PRMInstance to this system.
Definition: PRMSystem_tpl.h:59

◆ addArray()

template<typename GUM_SCALAR>
INLINE void gum::prm::PRMSystem< GUM_SCALAR >::addArray ( const std::string &  array,
PRMClassElementContainer< GUM_SCALAR > &  type 
)

Add an array of instances in this system. If the array doesn't exists it is created.

Exceptions
DuplicateElementRaised if an existing array with the same name already exists.

Definition at line 490 of file PRMSystem_tpl.h.

Referenced by gum::prm::PRMFactory< GUM_SCALAR >::addArray().

491  {
492  if (__arrayMap.exists(array)) {
493  GUM_ERROR(DuplicateElement,
494  "an array '" << array << "' is already in this System");
495  }
496 
497  __arrayMap.insert(array,
499  &type, new Sequence< PRMInstance< GUM_SCALAR >* >()));
500  }
bool exists(const Key &key) const
Checks whether there exists an element with a given key in the hashtable.
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
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
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the caller graph for this function:

◆ begin() [1/4]

template<typename GUM_SCALAR >
INLINE PRMSystem< GUM_SCALAR >::iterator gum::prm::PRMSystem< GUM_SCALAR >::begin ( )

Returns an iterator over the instances in this system.

Definition at line 504 of file PRMSystem_tpl.h.

Referenced by gum::prm::PRMSystem< double >::begin(), and gum::prm::gspan::InterfaceGraph< GUM_SCALAR >::InterfaceGraph().

504  {
505  return __nodeIdMap.begin();
506  }
NodeProperty< PRMInstance< GUM_SCALAR > *> __nodeIdMap
The maping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:280
+ Here is the caller graph for this function:

◆ begin() [2/4]

template<typename GUM_SCALAR >
INLINE PRMSystem< GUM_SCALAR >::const_iterator gum::prm::PRMSystem< GUM_SCALAR >::begin ( ) const

Returns a constant iterator over the instances in this system.

Definition at line 516 of file PRMSystem_tpl.h.

516  {
517  return __nodeIdMap.begin();
518  }
NodeProperty< PRMInstance< GUM_SCALAR > *> __nodeIdMap
The maping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:280

◆ begin() [3/4]

template<typename GUM_SCALAR >
INLINE PRMSystem< GUM_SCALAR >::array_iterator gum::prm::PRMSystem< GUM_SCALAR >::begin ( const std::string &  a)

Returns an iterator at the beginning of the Sequence of PRMInstance in the array named a;.

Exceptions
NotFoundRaised if no array matches a.

Definition at line 528 of file PRMSystem_tpl.h.

528  {
529  try {
530  return __arrayMap[a].second->begin();
531  } catch (NotFound&) {
532  GUM_ERROR(NotFound, "found no array matching the given name");
533  }
534  }
iterator begin()
Returns an unsafe iterator pointing to the beginning of the hashtable.
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
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ begin() [4/4]

template<typename GUM_SCALAR >
INLINE PRMSystem< GUM_SCALAR >::const_array_iterator gum::prm::PRMSystem< GUM_SCALAR >::begin ( const std::string &  a) const

Returns an iterator at the beginning of the Sequence of PRMInstance in the array named a;.

Exceptions
NotFoundRaised if no array matches a.

Definition at line 548 of file PRMSystem_tpl.h.

548  {
549  try {
550  return __arrayMap[a].second->begin();
551  } catch (NotFound&) {
552  GUM_ERROR(NotFound, "found no array matching the given name");
553  }
554  }
iterator begin()
Returns an unsafe iterator pointing to the beginning of the hashtable.
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
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ end() [1/4]

template<typename GUM_SCALAR >
INLINE const PRMSystem< GUM_SCALAR >::iterator & gum::prm::PRMSystem< GUM_SCALAR >::end ( )

Returns a iterator at the end of the set of PRMInstance in this PRMSystem.

Definition at line 510 of file PRMSystem_tpl.h.

Referenced by gum::prm::PRMSystem< double >::end(), and gum::prm::gspan::InterfaceGraph< GUM_SCALAR >::InterfaceGraph().

510  {
511  return __nodeIdMap.end();
512  }
NodeProperty< PRMInstance< GUM_SCALAR > *> __nodeIdMap
The maping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:280
+ Here is the caller graph for this function:

◆ end() [2/4]

template<typename GUM_SCALAR >
INLINE const PRMSystem< GUM_SCALAR >::const_iterator & gum::prm::PRMSystem< GUM_SCALAR >::end ( ) const

Returns a constant iterator at the end of the set of PRMInstance in this PRMSystem.

Definition at line 522 of file PRMSystem_tpl.h.

522  {
523  return __nodeIdMap.end();
524  }
NodeProperty< PRMInstance< GUM_SCALAR > *> __nodeIdMap
The maping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:280

◆ end() [3/4]

template<typename GUM_SCALAR >
INLINE const PRMSystem< GUM_SCALAR >::array_iterator & gum::prm::PRMSystem< GUM_SCALAR >::end ( const std::string &  a)

Returns an iterator at the end of the Sequence of PRMInstance in the array named a.

Exceptions
NotFoundRaised if no array matches a.

Definition at line 538 of file PRMSystem_tpl.h.

538  {
539  try {
540  return __arrayMap[a].second->end();
541  } catch (NotFound&) {
542  GUM_ERROR(NotFound, "found no array matching the given name");
543  }
544  }
const iterator & end() noexcept
Returns the unsafe iterator pointing to the end of the hashtable.
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
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ end() [4/4]

template<typename GUM_SCALAR >
INLINE const PRMSystem< GUM_SCALAR >::const_array_iterator & gum::prm::PRMSystem< GUM_SCALAR >::end ( const std::string &  a) const

Returns an iterator at the end of the Sequence of PRMInstance in the array named a.

Exceptions
NotFoundRaised if no array matches a.

Definition at line 558 of file PRMSystem_tpl.h.

558  {
559  try {
560  return __arrayMap[a].second->end();
561  } catch (NotFound&) {
562  GUM_ERROR(NotFound, "found no array matching the given name");
563  }
564  }
const iterator & end() noexcept
Returns the unsafe iterator pointing to the end of the hashtable.
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
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ enum2str()

static std::string gum::prm::PRMObject::enum2str ( prm_type  type)
inlinestaticinherited

Returns the string representation of a PRMObject.

Definition at line 83 of file PRMObject.h.

References gum::prm::PRMObject::CLASS, gum::prm::PRMObject::CLASS_ELT, gum::prm::PRMObject::INSTANCE, gum::prm::PRMObject::PRM_INTERFACE, gum::prm::PRMObject::SYSTEM, and gum::prm::PRMObject::TYPE.

Referenced by gum::prm::operator<<().

83  {
84  switch (type) {
85  case prm_type::CLASS: return "PRMType::CLASS";
86 
87  case prm_type::CLASS_ELT: return "PRMType::CLASS_ELT";
88 
89  case prm_type::TYPE: return "PRMType::TYPE";
90 
91  case prm_type::SYSTEM: return "PRMType::SYSTEM";
92 
93  case prm_type::INSTANCE: return "PRMType::INSTANCE";
94 
95  case prm_type::PRM_INTERFACE: return "PRMType::PRM_INTERFACE";
96 
97  default: return "unknown";
98  }
99  }
+ Here is the caller graph for this function:

◆ exists()

template<typename GUM_SCALAR >
INLINE bool gum::prm::PRMSystem< GUM_SCALAR >::exists ( const std::string &  name) const

Retruns true either if name is an instance or an array in this PRMSystem.

Definition at line 567 of file PRMSystem_tpl.h.

Referenced by gum::prm::PRMSystem< double >::exists(), gum::prm::o3prmr::O3prmrInterpreter::findInstanceName(), gum::prm::PRMSystem< double >::isArray(), gum::prm::PRMSystem< double >::isInstance(), and gum::prm::PRMSystem< double >::isInstantiated().

567  {
568  return __nameMap.exists(name) || __arrayMap.exists(name);
569  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
bool exists(const Key &key) const
Checks whether there exists an element with a given key in the hashtable.
HashTable< std::string, PRMInstance< GUM_SCALAR > *> __nameMap
The mapping between PRMInstance and their names.
Definition: PRMSystem.h:283
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
+ Here is the caller graph for this function:

◆ get() [1/6]

template<typename GUM_SCALAR >
INLINE PRMInstance< GUM_SCALAR > & gum::prm::PRMSystem< GUM_SCALAR >::get ( NodeId  id)

Returns an PRMInstance given it's NodeId in the relational skeleton.

Exceptions
NotFoundRaised if no PRMInstance matches the given NodeId.

Definition at line 345 of file PRMSystem_tpl.h.

Referenced by gum::prm::o3prmr::O3prmrInterpreter::checkObserve(), gum::prm::o3prmr::O3prmrInterpreter::checkQuery(), gum::prm::o3prmr::O3prmrInterpreter::checkUnobserve(), and gum::prm::PRMFactory< GUM_SCALAR >::incArray().

345  {
346  try {
347  return *(__nodeIdMap[id]);
348  } catch (NotFound&) {
349  GUM_ERROR(NotFound, "found no Instance<GUM_SCALAR> matching the given id");
350  }
351  }
NodeProperty< PRMInstance< GUM_SCALAR > *> __nodeIdMap
The maping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:280
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the caller graph for this function:

◆ get() [2/6]

template<typename GUM_SCALAR >
INLINE const PRMInstance< GUM_SCALAR > & gum::prm::PRMSystem< GUM_SCALAR >::get ( NodeId  id) const

Returns an PRMInstance given it's NodeId in the relational skeleton.

Exceptions
NotFoundRaised if no PRMInstance matches the given NodeId.

Definition at line 355 of file PRMSystem_tpl.h.

355  {
356  try {
357  return *(__nodeIdMap[id]);
358  } catch (NotFound&) {
359  GUM_ERROR(NotFound, "found no Instance<GUM_SCALAR> matching the given id");
360  }
361  }
NodeProperty< PRMInstance< GUM_SCALAR > *> __nodeIdMap
The maping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:280
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ get() [3/6]

template<typename GUM_SCALAR>
INLINE NodeId gum::prm::PRMSystem< GUM_SCALAR >::get ( const PRMInstance< GUM_SCALAR > &  i) const

Returns the relation skeleton of this PRMSystem.

Definition at line 365 of file PRMSystem_tpl.h.

365  {
366  try {
367  return __nodeIdMap.keyByVal(const_cast< PRMInstance< GUM_SCALAR >* >(&i));
368  } catch (NotFound&) {
369  GUM_ERROR(NotFound, "found no Instance<GUM_SCALAR> matching the given id");
370  }
371  }
NodeProperty< PRMInstance< GUM_SCALAR > *> __nodeIdMap
The maping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:280
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ get() [4/6]

template<typename GUM_SCALAR>
INLINE PRMInstance< GUM_SCALAR > & gum::prm::PRMSystem< GUM_SCALAR >::get ( const std::string &  name)

Returns a reference over an PRMInstance given it's name.

Exceptions
NotFoundRaised if the no PRMInstance matches name.

Definition at line 409 of file PRMSystem_tpl.h.

409  {
410  try {
411  return *(__nameMap[name]);
412  } catch (NotFound&) {
413  GUM_ERROR(NotFound,
414  "found no Instance<GUM_SCALAR> matching the given name");
415  }
416  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
HashTable< std::string, PRMInstance< GUM_SCALAR > *> __nameMap
The mapping between PRMInstance and their names.
Definition: PRMSystem.h:283
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ get() [5/6]

template<typename GUM_SCALAR>
INLINE const PRMInstance< GUM_SCALAR > & gum::prm::PRMSystem< GUM_SCALAR >::get ( const std::string &  name) const

Returns a constant reference over an PRMInstance given it's name.

Exceptions
NotFoundRaised if the no PRMInstance matches name.

Definition at line 420 of file PRMSystem_tpl.h.

420  {
421  try {
422  return *(__nameMap[name]);
423  } catch (NotFound&) {
424  GUM_ERROR(NotFound,
425  "found no Instance<GUM_SCALAR> matching the given name");
426  }
427  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
HashTable< std::string, PRMInstance< GUM_SCALAR > *> __nameMap
The mapping between PRMInstance and their names.
Definition: PRMSystem.h:283
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ get() [6/6]

template<typename GUM_SCALAR>
INLINE const Set< PRMInstance< GUM_SCALAR > *> & gum::prm::PRMSystem< GUM_SCALAR >::get ( const PRMClass< GUM_SCALAR > &  type) const

Returns the sequence of all instances of the given type.

Exceptions
NotFoundRaised if there is instantiation of type.

Definition at line 431 of file PRMSystem_tpl.h.

431  {
432  try {
433  return *(__instanceMap[const_cast< PRMClass< GUM_SCALAR >* >(&type)]);
434  } catch (NotFound&) {
435  GUM_ERROR(
436  NotFound,
437  "the given Class<GUM_SCALAR> has no instantiation in this System");
438  }
439  }
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
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ getArray()

template<typename GUM_SCALAR >
INLINE const Sequence< PRMInstance< GUM_SCALAR > *> & gum::prm::PRMSystem< GUM_SCALAR >::getArray ( const std::string &  name) const

Returns the sequence of instances of a given array.

Exceptions
NotFoundRaised if no array matches name.

Definition at line 443 of file PRMSystem_tpl.h.

443  {
444  try {
445  return *(__arrayMap[name].second);
446  } catch (NotFound&) {
447  GUM_ERROR(NotFound, "found no array matching the given name");
448  }
449  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
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
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ getArrayType() [1/2]

template<typename GUM_SCALAR >
INLINE PRMClassElementContainer< GUM_SCALAR > & gum::prm::PRMSystem< GUM_SCALAR >::getArrayType ( const std::string &  name)

Returns the type of the given array.

Exceptions
NotFoundRaised if no array matches name.

Definition at line 453 of file PRMSystem_tpl.h.

453  {
454  try {
455  return *(__arrayMap[name].first);
456  } catch (NotFound&) {
457  GUM_ERROR(NotFound, "found no array matching the given name");
458  }
459  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
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
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ getArrayType() [2/2]

template<typename GUM_SCALAR >
INLINE const PRMClassElementContainer< GUM_SCALAR > & gum::prm::PRMSystem< GUM_SCALAR >::getArrayType ( const std::string &  name) const

Returns the type of the given array.

Exceptions
NotFoundRaised if no array matches name.

Definition at line 463 of file PRMSystem_tpl.h.

463  {
464  try {
465  return *(__arrayMap[name].first);
466  } catch (NotFound&) {
467  GUM_ERROR(NotFound, "found no array matching the given name");
468  }
469  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
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
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ groundedBN()

template<typename GUM_SCALAR>
void gum::prm::PRMSystem< GUM_SCALAR >::groundedBN ( BayesNetFactory< GUM_SCALAR > &  factory) const

Returns the grounded Bayesian Network of this system.

Parameters
factoryThe factory used to build the grounded Bayesian Network.

Definition at line 82 of file PRMSystem_tpl.h.

Referenced by gum::O3prmBNReader< GUM_SCALAR >::__generateBN(), and gum::prm::o3prmr::O3prmrInterpreter::generateInfEngine().

83  {
84  factory.startNetworkDeclaration();
85  factory.addNetworkProperty("name", name());
86  factory.endNetworkDeclaration();
87 
88  // Adding nodes
89  for (PRMSystem< GUM_SCALAR >::const_iterator iter = begin(); iter != end();
90  ++iter) {
91  __groundAttr(*(iter.val()), factory);
92  }
93 
94  // Adding arcs and filling CPTs
95  for (PRMSystem< GUM_SCALAR >::const_iterator iter = begin(); iter != end();
96  ++iter) {
97  __groundRef(*(iter.val()), factory);
98  }
99  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
iterator begin()
Returns an iterator over the instances in this system.
NodeProperty< PRMInstance< GUM_SCALAR > *>::const_iterator const_iterator
Constant Iterator over the PRMInstance of this PRMSystem.
Definition: PRMSystem.h:225
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.
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.
+ Here is the caller graph for this function:

◆ instantiate()

template<typename GUM_SCALAR >
INLINE void gum::prm::PRMSystem< GUM_SCALAR >::instantiate ( )

Instantiate all the PRMInstance in this PRMSystem.

Definition at line 401 of file PRMSystem_tpl.h.

Referenced by gum::O3prmBNReader< GUM_SCALAR >::__generateBN(), gum::prm::PRMFactory< GUM_SCALAR >::endSystem(), and gum::prm::PRMSystem< double >::instantiate().

401  {
402  for (auto iter = begin(); iter != end(); ++iter) {
403  (*(iter.val())).instantiate();
404  }
405  }
iterator begin()
Returns an iterator over the instances in this system.
const iterator & end()
Returns a iterator at the end of the set of PRMInstance in this PRMSystem.
+ Here is the caller graph for this function:

◆ isArray()

template<typename GUM_SCALAR >
INLINE bool gum::prm::PRMSystem< GUM_SCALAR >::isArray ( const std::string &  name) const

Returns true if an array with the given name exists.

Definition at line 396 of file PRMSystem_tpl.h.

Referenced by gum::prm::PRMFactory< GUM_SCALAR >::incArray(), and gum::prm::PRMFactory< GUM_SCALAR >::isArrayInCurrentSystem().

396  {
397  return __arrayMap.exists(name);
398  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
bool exists(const Key &key) const
Checks whether there exists an element with a given key in the hashtable.
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
+ Here is the caller graph for this function:

◆ isClass()

static INLINE bool gum::prm::PRMObject::isClass ( const PRMObject obj)
inlinestaticinherited

Returns true if obj_ptr is of type Class.

Definition at line 102 of file PRMObject.h.

References gum::prm::PRMObject::CLASS, and gum::prm::PRMObject::obj_type().

Referenced by gum::prm::PRMFactory< GUM_SCALAR >::startAttribute().

102  {
103  return obj.obj_type() == prm_type::CLASS;
104  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isInstance() [1/2]

static INLINE bool gum::prm::PRMObject::isInstance ( const PRMObject obj)
inlinestaticinherited

Returns true if obj_ptr is of type PRMInstance.

Definition at line 112 of file PRMObject.h.

References gum::prm::PRMObject::INSTANCE, gum::prm::PRMObject::name(), gum::prm::PRMObject::obj_type(), gum::prm::PRMObject::operator!=(), gum::prm::PRMObject::operator=(), gum::prm::PRMObject::operator==(), gum::prm::PRMObject::PRMObject(), and gum::prm::PRMObject::~PRMObject().

112  {
113  return obj.obj_type() == prm_type::INSTANCE;
114  }
+ Here is the call graph for this function:

◆ isInstance() [2/2]

template<typename GUM_SCALAR >
INLINE bool gum::prm::PRMSystem< GUM_SCALAR >::isInstance ( const std::string &  name) const

Returns true if an PRMInstance with the given name exists.

Definition at line 391 of file PRMSystem_tpl.h.

Referenced by gum::prm::PRMFactory< GUM_SCALAR >::incArray().

391  {
392  return __nameMap.exists(name);
393  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
HashTable< std::string, PRMInstance< GUM_SCALAR > *> __nameMap
The mapping between PRMInstance and their names.
Definition: PRMSystem.h:283
+ Here is the caller graph for this function:

◆ isInstantiated()

template<typename GUM_SCALAR>
INLINE bool gum::prm::PRMSystem< GUM_SCALAR >::isInstantiated ( const PRMClass< GUM_SCALAR > &  c) const

Returns true if the given Class<GUM_SCALAR> has at least one PRMInstance in this PRMSystem.

Definition at line 384 of file PRMSystem_tpl.h.

385  {
386  return __instanceMap.exists(const_cast< PRMClass< GUM_SCALAR >* >(&c));
387  }
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

◆ isInterface()

static INLINE bool gum::prm::PRMObject::isInterface ( const PRMObject obj)
inlinestaticinherited

Returns true if obj_ptr is of type PRMInterface.

Definition at line 107 of file PRMObject.h.

References gum::prm::PRMObject::obj_type(), and gum::prm::PRMObject::PRM_INTERFACE.

107  {
108  return obj.obj_type() == prm_type::PRM_INTERFACE;
109  }
+ Here is the call graph for this function:

◆ LEFT_CAST()

static std::string gum::prm::PRMObject::LEFT_CAST ( )
inlinestaticinherited

Enumeration of the different types of objects handled by a PRM.

The "all" type is used to tell that we want any kind of PRMType (useful with iterators for example). No PRMObject will ever have "all" as type.

Definition at line 79 of file PRMObject.h.

Referenced by gum::prm::decomposePath(), gum::prm::PRMFormAttribute< GUM_SCALAR >::PRMFormAttribute(), and gum::prm::PRMScalarAttribute< GUM_SCALAR >::PRMScalarAttribute().

79 { return "("; }
+ Here is the caller graph for this function:

◆ name() [1/2]

INLINE const std::string & gum::prm::PRMObject::name ( ) const
inherited

Returns the name of this object.

Definition at line 35 of file PRMObject_inl.h.

References gum::prm::PRMObject::__name.

Referenced by gum::prm::SVE< GUM_SCALAR >::__addDelayedVariable(), gum::prm::PRMClass< double >::__addIOInterfaceFlags(), gum::prm::PRMFactory< GUM_SCALAR >::__addParent(), gum::prm::PRMInstance< GUM_SCALAR >::__addReferingInstance(), gum::prm::PRMClass< double >::__checkInterface(), gum::prm::PRMFactory< GUM_SCALAR >::__checkInterfaceImplementation(), gum::prm::PRMClass< double >::__checkInterfaces(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::__checkRawCPT(), gum::prm::PRMClass< double >::__checkRefInterface(), gum::prm::PRMClass< double >::__checkRefInterfaces(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::__checkRuleCPTSumsTo1(), gum::prm::PRMInstance< GUM_SCALAR >::__copyAggregates(), gum::prm::PRMInstance< GUM_SCALAR >::__copyAttribute(), gum::prm::PRMSlotChain< double >::__copyLastElt(), gum::prm::PRMSystem< double >::__groundAttr(), gum::prm::PRMSystem< double >::__groundPotential(), gum::prm::PRMSystem< double >::__groundRef(), gum::prm::PRMClass< double >::__inheritClass(), gum::prm::PRMInterface< double >::__overloadAttribute(), gum::prm::PRMClass< double >::__overloadAttribute(), gum::prm::PRMClass< double >::__overloadParameter(), gum::prm::PRMClass< double >::__overloadReference(), gum::prm::PRMInterface< double >::__overloadReferenceSlot(), gum::prm::__print_attribute__(), gum::prm::__print_instance__(), gum::prm::gspan::StrictSearch< GUM_SCALAR >::__str(), gum::prm::StructuredInference< GUM_SCALAR >::__str(), gum::prm::PRMInterface< double >::add(), gum::prm::PRMSystem< double >::add(), gum::prm::PRMClass< double >::add(), gum::prm::PRMFactory< GUM_SCALAR >::addAggregator(), gum::prm::PRMFormAttribute< GUM_SCALAR >::addParent(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::addParent(), gum::prm::PRMFormAttribute< GUM_SCALAR >::copy(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::copy(), gum::prm::o3prmr::O3prmrInterpreter::findAttributeName(), gum::prm::o3prmr::O3prmrInterpreter::findInstanceName(), gum::prm::PRMFormAttribute< GUM_SCALAR >::getCastDescendant(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::getCastDescendant(), gum::prm::PRMClass< double >::inheritAggregates(), gum::prm::PRMClass< double >::isCastDescendant(), gum::prm::PRMObject::isInstance(), gum::prm::PRMObject::name(), gum::prm::PRMType::name(), gum::prm::PRMFormAttribute< GUM_SCALAR >::newFactory(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::newFactory(), gum::prm::PRMType::operator!=(), gum::prm::PRMObject::operator!=(), operator<<(), gum::prm::PRMType::operator==(), gum::prm::PRMObject::operator==(), gum::prm::PRMClass< double >::overload(), gum::prm::PRMInterface< double >::overload(), gum::prm::PRMFormAttribute< GUM_SCALAR >::PRMFormAttribute(), gum::prm::PRMReferenceSlot< double >::PRMReferenceSlot(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::PRMScalarAttribute(), gum::prm::PRMFactory< GUM_SCALAR >::startClass(), gum::prm::PRMFactory< GUM_SCALAR >::startInterface(), gum::prm::PRMFactory< GUM_SCALAR >::startSystem(), and gum::prm::PRMAggregate< double >::str2enum().

35 { return __name; }
std::string __name
Definition: PRMObject.h:200

◆ name() [2/2]

INLINE void gum::prm::PRMObject::name ( const std::string &  name)
inherited

Change the name of the PRM Object.

Warning
Don't do this unless you know wath you are doing !

Definition at line 39 of file PRMObject_inl.h.

References gum::prm::PRMObject::__name, and gum::prm::PRMObject::name().

39 { __name = name; }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
std::string __name
Definition: PRMObject.h:200
+ Here is the call graph for this function:

◆ obj_type()

template<typename GUM_SCALAR >
INLINE PRMObject::prm_type gum::prm::PRMSystem< GUM_SCALAR >::obj_type ( ) const
virtual

Returns the PRM type of this object.

Implements gum::prm::PRMObject.

Definition at line 374 of file PRMSystem_tpl.h.

◆ operator!=()

INLINE bool gum::prm::PRMObject::operator!= ( const PRMObject obj) const
inherited

To PRMObject are equal if they have the same name (which is unique).

Definition at line 49 of file PRMObject_inl.h.

References gum::prm::PRMObject::__name, and gum::prm::PRMObject::name().

Referenced by gum::prm::PRMObject::isInstance().

49  {
50  return __name != obj.name();
51  }
std::string __name
Definition: PRMObject.h:200
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=()

template<typename GUM_SCALAR>
PRMSystem< GUM_SCALAR >& gum::prm::PRMSystem< GUM_SCALAR >::operator= ( const PRMSystem< GUM_SCALAR > &  from)
private

Copy operator. Don't use it.

◆ operator==()

INLINE bool gum::prm::PRMObject::operator== ( const PRMObject obj) const
inherited

To PRMObject are equal if they have the same name (which is unique).

Definition at line 43 of file PRMObject_inl.h.

References gum::prm::PRMObject::__name, and gum::prm::PRMObject::name().

Referenced by gum::prm::PRMObject::isInstance().

43  {
44  return __name == obj.name();
45  }
std::string __name
Definition: PRMObject.h:200
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RIGHT_CAST()

static std::string gum::prm::PRMObject::RIGHT_CAST ( )
inlinestaticinherited

Enumeration of the different types of objects handled by a PRM.

The "all" type is used to tell that we want any kind of PRMType (useful with iterators for example). No PRMObject will ever have "all" as type.

Definition at line 80 of file PRMObject.h.

Referenced by gum::prm::decomposePath(), gum::prm::PRMFormAttribute< GUM_SCALAR >::PRMFormAttribute(), and gum::prm::PRMScalarAttribute< GUM_SCALAR >::PRMScalarAttribute().

80 { return ")"; }
+ Here is the caller graph for this function:

◆ size()

template<typename GUM_SCALAR >
INLINE Size gum::prm::PRMSystem< GUM_SCALAR >::size ( ) const

Returns the number of PRMInstance in this PRMSystem.

Definition at line 379 of file PRMSystem_tpl.h.

Referenced by gum::prm::PRMSystem< double >::size().

379  {
380  return __nodeIdMap.size();
381  }
NodeProperty< PRMInstance< GUM_SCALAR > *> __nodeIdMap
The maping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:280
+ Here is the caller graph for this function:

◆ skeleton()

template<typename GUM_SCALAR >
INLINE const DiGraph & gum::prm::PRMSystem< GUM_SCALAR >::skeleton ( ) const

Returns the relation skeleton of this PRMSystem.

Definition at line 340 of file PRMSystem_tpl.h.

340  {
341  return __skeleton;
342  }
DiGraph __skeleton
The relational skeleton of this PRMSystem.
Definition: PRMSystem.h:276

Member Data Documentation

◆ __arrayMap

template<typename GUM_SCALAR>
HashTable< std::string, model_pair > gum::prm::PRMSystem< GUM_SCALAR >::__arrayMap
private

Mapping between arrays and their name. The first element of the pair is the type of the array.

Definition at line 297 of file PRMSystem.h.

◆ __instanceMap

template<typename GUM_SCALAR>
HashTable< PRMClass< GUM_SCALAR >*, Set< PRMInstance< GUM_SCALAR >* >* > gum::prm::PRMSystem< GUM_SCALAR >::__instanceMap
private

Mapping between a class and all it's PRMInstance in this system.

Definition at line 287 of file PRMSystem.h.

◆ __nameMap

template<typename GUM_SCALAR>
HashTable< std::string, PRMInstance< GUM_SCALAR >* > gum::prm::PRMSystem< GUM_SCALAR >::__nameMap
private

The mapping between PRMInstance and their names.

Definition at line 283 of file PRMSystem.h.

◆ __nodeIdMap

template<typename GUM_SCALAR>
NodeProperty< PRMInstance< GUM_SCALAR >* > gum::prm::PRMSystem< GUM_SCALAR >::__nodeIdMap
private

The maping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem.

Definition at line 280 of file PRMSystem.h.

◆ __skeleton

template<typename GUM_SCALAR>
DiGraph gum::prm::PRMSystem< GUM_SCALAR >::__skeleton
private

The relational skeleton of this PRMSystem.

Definition at line 276 of file PRMSystem.h.


The documentation for this class was generated from the following files: