aGrUM  0.14.1
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 226 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 233 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 247 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 222 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 211 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 290 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 66 of file PRMObject.h.

66  : char {
67  ALL,
68  CLASS,
69  PRM_INTERFACE,
70  CLASS_ELT,
71  TYPE,
72  SYSTEM,
73  INSTANCE
74  };

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 37 of file PRMSystem_tpl.h.

37  : PRMObject(name) {
38  GUM_CONSTRUCTOR(PRMSystem);
39  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
PRMSystem(const std::string &name)
Default constructor.
Definition: PRMSystem_tpl.h:37
PRMObject(const std::string &name)
Constructor.
Definition: PRMObject.cpp:40

◆ ~PRMSystem()

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

Destructor.

Definition at line 42 of file PRMSystem_tpl.h.

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

◆ 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 136 of file PRMSystem_tpl.h.

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

◆ __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 99 of file PRMSystem_tpl.h.

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

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

◆ __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 215 of file PRMSystem_tpl.h.

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

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

470  {
471  try {
472  if (i->type().isSubTypeOf(*(__arrayMap[array].first))) {
473  NodeId id = add(i);
474  __arrayMap[array].second->insert(i);
475  return id;
476  } else {
477  GUM_ERROR(TypeError,
478  "the given Instance<GUM_SCALAR> is of an incorrect "
479  "Class<GUM_SCALAR> type");
480  }
481  } catch (NotFound&) {
482  GUM_ERROR(NotFound, "found no array matching the given name");
483  }
484  }
NodeId add(PRMInstance< GUM_SCALAR > *i)
Add an PRMInstance to this system.
Definition: PRMSystem_tpl.h:56
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:294
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:97
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52

◆ 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 331 of file PRMSystem_tpl.h.

332  {
333  return add(array, &i);
334  }
NodeId add(PRMInstance< GUM_SCALAR > *i)
Add an PRMInstance to this system.
Definition: PRMSystem_tpl.h:56

◆ 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 487 of file PRMSystem_tpl.h.

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

488  {
489  if (__arrayMap.exists(array)) {
490  GUM_ERROR(DuplicateElement,
491  "an array '" << array << "' is already in this System");
492  }
493 
494  __arrayMap.insert(array,
496  &type, new Sequence< PRMInstance< GUM_SCALAR >* >()));
497  }
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:290
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:294
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:52
+ 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 501 of file PRMSystem_tpl.h.

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

501  {
502  return __nodeIdMap.begin();
503  }
NodeProperty< PRMInstance< GUM_SCALAR > *> __nodeIdMap
The maping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:277
+ 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 513 of file PRMSystem_tpl.h.

513  {
514  return __nodeIdMap.begin();
515  }
NodeProperty< PRMInstance< GUM_SCALAR > *> __nodeIdMap
The maping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:277

◆ 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 525 of file PRMSystem_tpl.h.

525  {
526  try {
527  return __arrayMap[a].second->begin();
528  } catch (NotFound&) {
529  GUM_ERROR(NotFound, "found no array matching the given name");
530  }
531  }
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:294
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52

◆ 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 545 of file PRMSystem_tpl.h.

545  {
546  try {
547  return __arrayMap[a].second->begin();
548  } catch (NotFound&) {
549  GUM_ERROR(NotFound, "found no array matching the given name");
550  }
551  }
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:294
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52

◆ 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 507 of file PRMSystem_tpl.h.

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

507  {
508  return __nodeIdMap.end();
509  }
NodeProperty< PRMInstance< GUM_SCALAR > *> __nodeIdMap
The maping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:277
+ 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 519 of file PRMSystem_tpl.h.

519  {
520  return __nodeIdMap.end();
521  }
NodeProperty< PRMInstance< GUM_SCALAR > *> __nodeIdMap
The maping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:277

◆ 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 535 of file PRMSystem_tpl.h.

535  {
536  try {
537  return __arrayMap[a].second->end();
538  } catch (NotFound&) {
539  GUM_ERROR(NotFound, "found no array matching the given name");
540  }
541  }
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:294
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52

◆ 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 555 of file PRMSystem_tpl.h.

555  {
556  try {
557  return __arrayMap[a].second->end();
558  } catch (NotFound&) {
559  GUM_ERROR(NotFound, "found no array matching the given name");
560  }
561  }
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:294
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52

◆ enum2str()

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

Returns the string representation of a PRMObject.

Definition at line 80 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<<().

80  {
81  switch (type) {
82  case prm_type::CLASS: return "PRMType::CLASS";
83 
84  case prm_type::CLASS_ELT: return "PRMType::CLASS_ELT";
85 
86  case prm_type::TYPE: return "PRMType::TYPE";
87 
88  case prm_type::SYSTEM: return "PRMType::SYSTEM";
89 
90  case prm_type::INSTANCE: return "PRMType::INSTANCE";
91 
92  case prm_type::PRM_INTERFACE: return "PRMType::PRM_INTERFACE";
93 
94  default: return "unknown";
95  }
96  }
+ 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 564 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().

564  {
565  return __nameMap.exists(name) || __arrayMap.exists(name);
566  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
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:280
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:294
+ 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 342 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().

342  {
343  try {
344  return *(__nodeIdMap[id]);
345  } catch (NotFound&) {
346  GUM_ERROR(NotFound, "found no Instance<GUM_SCALAR> matching the given id");
347  }
348  }
NodeProperty< PRMInstance< GUM_SCALAR > *> __nodeIdMap
The maping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:277
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52
+ 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 352 of file PRMSystem_tpl.h.

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

◆ 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 362 of file PRMSystem_tpl.h.

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

◆ 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 406 of file PRMSystem_tpl.h.

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

◆ 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 417 of file PRMSystem_tpl.h.

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

◆ 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 428 of file PRMSystem_tpl.h.

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

◆ 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 440 of file PRMSystem_tpl.h.

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

◆ 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 450 of file PRMSystem_tpl.h.

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

◆ 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 460 of file PRMSystem_tpl.h.

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

◆ 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 79 of file PRMSystem_tpl.h.

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

80  {
81  factory.startNetworkDeclaration();
82  factory.addNetworkProperty("name", name());
83  factory.endNetworkDeclaration();
84 
85  // Adding nodes
86  for (PRMSystem< GUM_SCALAR >::const_iterator iter = begin(); iter != end();
87  ++iter) {
88  __groundAttr(*(iter.val()), factory);
89  }
90 
91  // Adding arcs and filling CPTs
92  for (PRMSystem< GUM_SCALAR >::const_iterator iter = begin(); iter != end();
93  ++iter) {
94  __groundRef(*(iter.val()), factory);
95  }
96  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
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:222
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.
Definition: PRMSystem_tpl.h:99
+ 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 398 of file PRMSystem_tpl.h.

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

398  {
399  for (auto iter = begin(); iter != end(); ++iter) {
400  (*(iter.val())).instantiate();
401  }
402  }
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 393 of file PRMSystem_tpl.h.

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

393  {
394  return __arrayMap.exists(name);
395  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
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:294
+ 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 99 of file PRMObject.h.

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

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

99  {
100  return obj.obj_type() == prm_type::CLASS;
101  }
+ 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 109 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().

109  {
110  return obj.obj_type() == prm_type::INSTANCE;
111  }
+ 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 388 of file PRMSystem_tpl.h.

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

388  {
389  return __nameMap.exists(name);
390  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
HashTable< std::string, PRMInstance< GUM_SCALAR > *> __nameMap
The mapping between PRMInstance and their names.
Definition: PRMSystem.h:280
+ 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 381 of file PRMSystem_tpl.h.

382  {
383  return __instanceMap.exists(const_cast< PRMClass< GUM_SCALAR >* >(&c));
384  }
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:284

◆ isInterface()

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

Returns true if obj_ptr is of type PRMInterface.

Definition at line 104 of file PRMObject.h.

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

104  {
105  return obj.obj_type() == prm_type::PRM_INTERFACE;
106  }
+ 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 76 of file PRMObject.h.

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

76 { 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 32 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().

32 { return __name; }
std::string __name
Definition: PRMObject.h:197

◆ 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 36 of file PRMObject_inl.h.

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

36 { __name = name; }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
std::string __name
Definition: PRMObject.h:197
+ 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 371 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 46 of file PRMObject_inl.h.

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

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

46  {
47  return __name != obj.name();
48  }
std::string __name
Definition: PRMObject.h:197
+ 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 40 of file PRMObject_inl.h.

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

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

40  {
41  return __name == obj.name();
42  }
std::string __name
Definition: PRMObject.h:197
+ 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 77 of file PRMObject.h.

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

77 { 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 376 of file PRMSystem_tpl.h.

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

376  {
377  return __nodeIdMap.size();
378  }
NodeProperty< PRMInstance< GUM_SCALAR > *> __nodeIdMap
The maping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:277
+ 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 337 of file PRMSystem_tpl.h.

337  {
338  return __skeleton;
339  }
DiGraph __skeleton
The relational skeleton of this PRMSystem.
Definition: PRMSystem.h:273

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 294 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 284 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 280 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 277 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 273 of file PRMSystem.h.


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