aGrUM  0.21.0
a C++ library for (probabilistic) graphical models
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...
 

Protected Member Functions

 PRMSystem (const PRMSystem< GUM_SCALAR > &from)
 Copy constructor. Don't use it. More...
 
PRMSystem< GUM_SCALAR > & operator= (const PRMSystem< GUM_SCALAR > &from)=delete
 Copy operator. Don't use it. More...
 
Ground BN private methods.
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. More...
 
void _groundAttr_ (const PRMInstance< GUM_SCALAR > &instance, BayesNetFactory< GUM_SCALAR > &factory) const
 Method which ground Atttributes and Aggregators of an PRMInstance. More...
 
void _groundPotential_ (const PRMInstance< GUM_SCALAR > &instance, const PRMAttribute< GUM_SCALAR > &attr, BayesNetFactory< GUM_SCALAR > &factory) const
 Method which copy node's Potential of an PRMInstance to the grounded Bayesian network. More...
 
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. 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 mapping 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_pairarrayMap_
 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 234 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 224 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 237 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 214 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 204 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
protected

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

Definition at line 279 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 68 of file PRMObject.h.

68  : char
69  {
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 41 of file PRMSystem_tpl.h.

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

◆ ~PRMSystem()

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

Destructor.

Definition at line 46 of file PRMSystem_tpl.h.

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

◆ PRMSystem() [2/2]

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

Copy constructor. Don't use it.

Definition at line 60 of file PRMSystem_tpl.h.

60  :
61  PRMObject(from), skeleton_(from.skeleton_), nodeIdMap_(from.nodeIdMap_),
62  nameMap_(from.nameMap_), instanceMap_(from.instanceMap_), arrayMap_(from.arrayMap_) {
63  GUM_CONS_CPY(PRMSystem);
64  }
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:283
PRMSystem(const std::string &name)
Default constructor.
Definition: PRMSystem_tpl.h:41
DiGraph skeleton_
The relational skeleton of this PRMSystem.
Definition: PRMSystem.h:263
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:267
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:273
HashTable< std::string, PRMInstance< GUM_SCALAR > *> nameMap_
The mapping between PRMInstance and their names.
Definition: PRMSystem.h:270
PRMObject(const std::string &name)
Constructor.
Definition: PRMObject.cpp:42

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
protected

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.

141  {
142  factory.startVariableDeclaration();
143  factory.variableName(name);
144 
145  const DiscreteVariable& agg_var = elt.type().variable();
146 
147  VarType var_type = agg_var.varType();
148 
149  factory.variableType(var_type);
150 
151  switch (var_type) {
152  case VarType::Labelized: {
153  const auto l = static_cast< const LabelizedVariable& >(agg_var);
154  for (Idx i = 0; i < l.domainSize(); ++i) {
155  factory.addModality(l.label(i));
156  }
157  break;
158  }
159  case VarType::Integer: {
160  const auto l = static_cast< const IntegerVariable& >(agg_var);
161  for (Idx i = 0; i < l.domainSize(); ++i) {
162  factory.addModality(l.label(i));
163  }
164  break;
165  }
166  case VarType::Discretized: {
167  const auto d = static_cast< const DiscretizedVariable< GUM_SCALAR >& >(agg_var);
168  for (Idx i = 0; i < d.domainSize(); ++i) {
169  factory.addTick(d.tick(i));
170  }
171  break;
172  }
173  case VarType::Range: {
174  const auto r = static_cast< const RangeVariable& >(agg_var);
175  factory.addMin(r.minVal());
176  factory.addMax(r.maxVal());
177  break;
178  }
179  default:
180  GUM_ERROR(NotImplementedYet,
181  "PRM aggregator grounding does not support yet such variables");
182  break;
183  }
184 
185  const PRMAggregate< GUM_SCALAR >& agg = static_cast< const PRMAggregate< GUM_SCALAR >& >(elt);
186 
187  switch (agg.agg_type()) {
189  factory.setVariableCPTImplementation(new aggregator::Min< GUM_SCALAR >());
190  break;
191  }
192 
194  factory.setVariableCPTImplementation(new aggregator::Max< GUM_SCALAR >());
195  break;
196  }
197 
199  factory.setVariableCPTImplementation(new aggregator::Exists< GUM_SCALAR >(agg.label()));
200  break;
201  }
202 
204  factory.setVariableCPTImplementation(new aggregator::Forall< GUM_SCALAR >(agg.label()));
205  break;
206  }
207 
209  factory.setVariableCPTImplementation(new aggregator::Count< GUM_SCALAR >(agg.label()));
210  break;
211  }
212 
214  factory.setVariableCPTImplementation(new aggregator::Median< GUM_SCALAR >());
215  break;
216  }
217 
219  factory.setVariableCPTImplementation(new aggregator::Amplitude< GUM_SCALAR >());
220  break;
221  }
222 
224  factory.setVariableCPTImplementation(new aggregator::Or< GUM_SCALAR >());
225  break;
226  }
227 
229  factory.setVariableCPTImplementation(new aggregator::And< GUM_SCALAR >());
230  break;
231  }
232 
234  factory.setVariableCPTImplementation(new aggregator::Sum< GUM_SCALAR >());
235  break;
236  }
237 
238  default:
239  GUM_ERROR(OperationNotAllowed, "Aggregator not handled yet for " << agg.name())
240  }
241 
242  factory.endVariableDeclaration();
243  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
VarType
Definition: variable.h:40
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ _groundAttr_()

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

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

106  {
107  for (const auto node: instance.type().containerDag()) {
108  // Working a Class<GUM_SCALAR> level because PRMAggregate<GUM_SCALAR>
109  // are
110  // instantiated as PRMAttribute<GUM_SCALAR> in an
111  // PRMInstance<GUM_SCALAR>
112  switch (instance.type().get(node).elt_type()) {
114  // TODO: make a special case for noisy-or
115  std::stringstream elt_name;
116  elt_name << instance.name() << "." << instance.type().get(node).safeName();
117  DiscreteVariable* var = instance.get(node).type().variable().clone();
118  var->setName(elt_name.str());
119  factory.setVariable(*var); // var is copied by the factory
120  delete var;
121  break;
122  }
123 
125  std::stringstream elt_name;
126  elt_name << instance.name() << "." << 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
protected

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

301  {
302  Bijection< const DiscreteVariable*, const DiscreteVariable* > bijection;
303  std::stringstream var_name;
304  var_name << instance.name() << "." << attr.safeName();
305  bijection.insert(&(attr.type().variable()), &(factory.variable(var_name.str())));
306 
307  for (const auto parent: instance.type().containerDag().parents(attr.id())) {
308  switch (instance.type().get(parent).elt_type()) {
311  std::stringstream parent_name;
312  parent_name << instance.name() << "." << instance.get(parent).safeName();
313  bijection.insert(&(instance.get(parent).type().variable()),
314  &(factory.variable(parent_name.str())));
315  break;
316  }
317 
319  std::stringstream parent_name;
320  const PRMSlotChain< GUM_SCALAR >& sc
321  = static_cast< const PRMSlotChain< GUM_SCALAR >& >(instance.type().get(parent));
322  parent_name << instance.getInstance(sc.id()).name() << "." << sc.lastElt().safeName();
323  bijection.insert(
324  &(instance.getInstance(sc.id()).get(sc.lastElt().safeName()).type().variable()),
325  &(factory.variable(parent_name.str())));
326  break;
327  }
328 
329  default: {
330  GUM_ERROR(FatalError, "invalid ClassElement<GUM_SCALAR> type as parent.")
331  break;
332  }
333  }
334  }
335 
336  // Copy Potential
337  // DO NOT USE MultiDimBijArray as they will wreck havok if you delete
338  // the prm befor its grounded BN (happens a lot in pyAgrum)
339  Potential< GUM_SCALAR >* p = new Potential< GUM_SCALAR >();
340  for (auto var: attr.cpf().variablesSequence()) {
341  p->add(*(bijection.second(var)));
342  }
343  Instantiation inst(attr.cpf()), jnst(*p);
344  for (inst.setFirst(), jnst.setFirst(); !(inst.end() || jnst.end()); inst.inc(), jnst.inc()) {
345  p->set(jnst, attr.cpf().get(inst));
346  }
347  GUM_ASSERT(inst.end() && jnst.end());
348  factory.setVariableCPT(var_name.str(), p, false);
349  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ _groundRef_()

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

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

247  {
248  for (const auto& elt: instance) {
249  std::stringstream elt_name;
250  elt_name << instance.name() << "." << elt.second->safeName();
251  factory.startParentsDeclaration(elt_name.str());
252 
253  for (const auto par: instance.type().containerDag().parents(elt.second->id())) {
254  switch (instance.type().get(par).elt_type()) {
257  std::stringstream parent_name;
258  parent_name << instance.name() << "." << instance.get(par).safeName();
259  factory.addParent(parent_name.str());
260  break;
261  }
262 
264  std::string parent_name
265  = static_cast< const PRMSlotChain< GUM_SCALAR >& >(instance.type().get(par))
266  .lastElt()
267  .safeName();
268 
269  try {
270  for (const auto ref: instance.getInstances(par)) {
271  std::stringstream sBuff;
272  sBuff << ref->name() << "." << parent_name;
273  factory.addParent(sBuff.str());
274  }
275  } catch (NotFound&) {
276  // No instances for this slotchain
277  }
278 
279  break;
280  }
281 
282  default:
283  break;
284  /* nothing to do by default */
285  }
286  }
287 
288  factory.endParentsDeclaration();
289 
290  // Checking if we need to ground the Potential (only for class level
291  // attributes since
292  // aggregates Potentials are generated)
293  if (PRMClassElement< GUM_SCALAR >::isAttribute(instance.type().get(elt.second->safeName())))
294  _groundPotential_(instance, *elt.second, factory);
295  }
296  }
static INLINE bool isAttribute(const PRMClassElement< GUM_SCALAR > &elt)
Returns true if obj_ptr is of type PRMAttribute.
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.

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

67  {
68  if (nameMap_.exists(i->name())) {
69  GUM_ERROR(DuplicateElement,
70  "an Instance<GUM_SCALAR> with the same is already in this System");
71  }
72 
73  NodeId id = skeleton_.addNode();
74  nodeIdMap_.insert(id, i);
75  nameMap_.insert(i->name(), i);
76 
77  try {
78  instanceMap_[&(i->type())]->insert(i);
79  } catch (NotFound&) {
80  instanceMap_.insert(&(i->type()), new Set< PRMInstance< GUM_SCALAR >* >());
81  instanceMap_[&(i->type())]->insert(i);
82  }
83 
84  return id;
85  }
virtual NodeId addNode()
insert a new node and return its id
DiGraph skeleton_
The relational skeleton of this PRMSystem.
Definition: PRMSystem.h:263
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:267
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:273
HashTable< std::string, PRMInstance< GUM_SCALAR > *> nameMap_
The mapping between PRMInstance and their names.
Definition: PRMSystem.h:270
Size NodeId
Type for node ids.
Definition: graphElements.h:97
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ 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
PRMTypeErrorRaised if i is not of the good type.
DuplicateElementRaised if an PRMInstance with same name already exists.

Definition at line 477 of file PRMSystem_tpl.h.

478  {
479  try {
480  if (i->type().isSubTypeOf(*(arrayMap_[array].first))) {
481  NodeId id = add(i);
482  arrayMap_[array].second->insert(i);
483  return id;
484  } else {
485  GUM_ERROR(PRMTypeError,
486  "the given Instance<GUM_SCALAR> is of an incorrect "
487  "Class<GUM_SCALAR> type");
488  }
489  } catch (NotFound&) { GUM_ERROR(NotFound, "found no array matching the given name") }
490  }
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:283
NodeId add(PRMInstance< GUM_SCALAR > *i)
Add an PRMInstance to this system.
Definition: PRMSystem_tpl.h:67
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:51

◆ 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
PRMTypeErrorRaised if i is not of the good type.
DuplicateElementRaised if an PRMInstance with same name already exists.

Definition at line 352 of file PRMSystem_tpl.h.

353  {
354  return add(array, &i);
355  }
NodeId add(PRMInstance< GUM_SCALAR > *i)
Add an PRMInstance to this system.
Definition: PRMSystem_tpl.h:67

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

494  {
495  if (arrayMap_.exists(array)) {
496  GUM_ERROR(DuplicateElement, "an array '" << array << "' is already in this System")
497  }
498 
500  array,
501  PRMSystem< GUM_SCALAR >::model_pair(&type, new Sequence< PRMInstance< GUM_SCALAR >* >()));
502  }
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:283
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:279
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:51

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

505  {
506  return nodeIdMap_.begin();
507  }
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:267

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

515  {
516  return nodeIdMap_.begin();
517  }
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:267

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

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

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

543  {
544  try {
545  return arrayMap_[a].second->begin();
546  } catch (NotFound&) { GUM_ERROR(NotFound, "found no array matching the given name") }
547  }
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:283
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ 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.

510  {
511  return nodeIdMap_.end();
512  }
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:267

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

521  {
522  return nodeIdMap_.end();
523  }
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:267

◆ 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&) { GUM_ERROR(NotFound, "found no array matching the given name") }
539  }
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:283
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

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

551  {
552  try {
553  return arrayMap_[a].second->end();
554  } catch (NotFound&) { GUM_ERROR(NotFound, "found no array matching the given name") }
555  }
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:283
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ 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.

83  {
84  switch (type) {
85  case prm_type::CLASS:
86  return "PRMType::CLASS";
87 
89  return "PRMType::CLASS_ELT";
90 
91  case prm_type::TYPE:
92  return "PRMType::TYPE";
93 
94  case prm_type::SYSTEM:
95  return "PRMType::SYSTEM";
96 
97  case prm_type::INSTANCE:
98  return "PRMType::INSTANCE";
99 
101  return "PRMType::PRM_INTERFACE";
102 
103  default:
104  return "unknown";
105  }
106  }

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

558  {
559  return nameMap_.exists(name) || arrayMap_.exists(name);
560  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
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:283
HashTable< std::string, PRMInstance< GUM_SCALAR > *> nameMap_
The mapping between PRMInstance and their names.
Definition: PRMSystem.h:270

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

363  {
364  try {
365  return *(nodeIdMap_[id]);
366  } catch (NotFound&) {
367  GUM_ERROR(NotFound, "found no Instance<GUM_SCALAR> matching the given id")
368  }
369  }
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:267
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

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

372  {
373  try {
374  return *(nodeIdMap_[id]);
375  } catch (NotFound&) {
376  GUM_ERROR(NotFound, "found no Instance<GUM_SCALAR> matching the given id")
377  }
378  }
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:267
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

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

381  {
382  try {
383  return nodeIdMap_.keyByVal(const_cast< PRMInstance< GUM_SCALAR >* >(&i));
384  } catch (NotFound&) {
385  GUM_ERROR(NotFound, "found no Instance<GUM_SCALAR> matching the given id")
386  }
387  }
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:267
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

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

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

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

432  {
433  try {
434  return *(nameMap_[name]);
435  } catch (NotFound&) {
436  GUM_ERROR(NotFound, "found no Instance<GUM_SCALAR> matching the given name")
437  }
438  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
HashTable< std::string, PRMInstance< GUM_SCALAR > *> nameMap_
The mapping between PRMInstance and their names.
Definition: PRMSystem.h:270
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

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

443  {
444  try {
445  return *(instanceMap_[const_cast< PRMClass< GUM_SCALAR >* >(&type)]);
446  } catch (NotFound&) {
447  GUM_ERROR(NotFound, "the given Class<GUM_SCALAR> has no instantiation in this System");
448  }
449  }
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:273
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

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

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

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

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

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

470  {
471  try {
472  return *(arrayMap_[name].first);
473  } catch (NotFound&) { GUM_ERROR(NotFound, "found no array matching the given name") }
474  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
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:283
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

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

88  {
89  factory.startNetworkDeclaration();
90  factory.addNetworkProperty("name", name());
91  factory.endNetworkDeclaration();
92 
93  // Adding nodes
94  for (PRMSystem< GUM_SCALAR >::const_iterator iter = begin(); iter != end(); ++iter) {
95  _groundAttr_(*(iter.val()), factory);
96  }
97 
98  // Adding arcs and filling CPTs
99  for (PRMSystem< GUM_SCALAR >::const_iterator iter = begin(); iter != end(); ++iter) {
100  _groundRef_(*(iter.val()), factory);
101  }
102  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
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:214
void _groundAttr_(const PRMInstance< GUM_SCALAR > &instance, BayesNetFactory< GUM_SCALAR > &factory) const
Method which ground Atttributes and Aggregators of an PRMInstance.
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.

◆ instantiate()

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

Instantiate all the PRMInstance in this PRMSystem.

Definition at line 415 of file PRMSystem_tpl.h.

415  {
416  for (auto iter = begin(); iter != end(); ++iter) {
417  (*(iter.val())).instantiate();
418  }
419  }
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.

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

410  {
411  return arrayMap_.exists(name);
412  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
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:283

◆ isClass()

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

Returns true if obj_ptr is of type Class.

Definition at line 109 of file PRMObject.h.

References gum::prm::PRMObject::PRMObject().

109 { return obj.obj_type() == prm_type::CLASS; }
+ Here is the call 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 117 of file PRMObject.h.

References gum::prm::PRMObject::PRMObject().

117  {
118  return obj.obj_type() == prm_type::INSTANCE;
119  }
+ 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 405 of file PRMSystem_tpl.h.

405  {
406  return nameMap_.exists(name);
407  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
HashTable< std::string, PRMInstance< GUM_SCALAR > *> nameMap_
The mapping between PRMInstance and their names.
Definition: PRMSystem.h:270

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

400  {
401  return instanceMap_.exists(const_cast< PRMClass< GUM_SCALAR >* >(&c));
402  }
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:273

◆ isInterface()

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

Returns true if obj_ptr is of type PRMInterface.

Definition at line 112 of file PRMObject.h.

References gum::prm::PRMObject::PRMObject().

112  {
113  return obj.obj_type() == prm_type::PRM_INTERFACE;
114  }
+ 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.

79 { return "("; }

◆ name() [1/2]

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

Returns the name of this object.

Definition at line 34 of file PRMObject_inl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

34 { return _name_; }
std::string _name_
Definition: PRMObject.h:205
+ Here is the call graph for this function:

◆ 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 what you are doing !

Definition at line 38 of file PRMObject_inl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

38 { _name_ = name; }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
std::string _name_
Definition: PRMObject.h:205
+ 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 390 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::ParamScopeData< GUM_SCALAR >::ParamScopeData().

46 { return _name_ != obj.name(); }
std::string _name_
Definition: PRMObject.h:205
+ Here is the call graph for this function:

◆ operator=()

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

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

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

42 { return _name_ == obj.name(); }
std::string _name_
Definition: PRMObject.h:205
+ Here is the call 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.

80 { return ")"; }

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

395  {
396  return nodeIdMap_.size();
397  }
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:267

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

358  {
359  return skeleton_;
360  }
DiGraph skeleton_
The relational skeleton of this PRMSystem.
Definition: PRMSystem.h:263

Member Data Documentation

◆ arrayMap_

template<typename GUM_SCALAR>
HashTable< std::string, model_pair > gum::prm::PRMSystem< GUM_SCALAR >::arrayMap_
protected

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

Definition at line 283 of file PRMSystem.h.

◆ instanceMap_

template<typename GUM_SCALAR>
HashTable< PRMClass< GUM_SCALAR >*, Set< PRMInstance< GUM_SCALAR >* >* > gum::prm::PRMSystem< GUM_SCALAR >::instanceMap_
protected

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

Definition at line 273 of file PRMSystem.h.

◆ nameMap_

template<typename GUM_SCALAR>
HashTable< std::string, PRMInstance< GUM_SCALAR >* > gum::prm::PRMSystem< GUM_SCALAR >::nameMap_
protected

The mapping between PRMInstance and their names.

Definition at line 270 of file PRMSystem.h.

◆ nodeIdMap_

template<typename GUM_SCALAR>
NodeProperty< PRMInstance< GUM_SCALAR >* > gum::prm::PRMSystem< GUM_SCALAR >::nodeIdMap_
protected

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

Definition at line 267 of file PRMSystem.h.

◆ skeleton_

template<typename GUM_SCALAR>
DiGraph gum::prm::PRMSystem< GUM_SCALAR >::skeleton_
protected

The relational skeleton of this PRMSystem.

Definition at line 263 of file PRMSystem.h.


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