aGrUM  0.13.2
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 227 of file PRMObject.h.

Member Typedef Documentation

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 230 of file PRMSystem.h.

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 244 of file PRMSystem.h.

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 219 of file PRMSystem.h.

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 208 of file PRMSystem.h.

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 287 of file PRMSystem.h.

Member Enumeration Documentation

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

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

Default constructor.

Definition at line 39 of file PRMSystem_tpl.h.

39  : PRMObject(name) {
40  GUM_CONSTRUCTOR(PRMSystem);
41  }
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:39
PRMObject(const std::string &name)
Constructor.
Definition: PRMObject.cpp:40
template<typename GUM_SCALAR >
gum::prm::PRMSystem< GUM_SCALAR >::~PRMSystem ( )
virtual

Destructor.

Definition at line 44 of file PRMSystem_tpl.h.

References gum::prm::PRMSystem< GUM_SCALAR >::__arrayMap, and gum::prm::PRMSystem< GUM_SCALAR >::__instanceMap.

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

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

References gum::BayesNetFactory< GUM_SCALAR >::addModality(), gum::prm::PRMAggregate< GUM_SCALAR >::agg_type(), gum::DiscreteVariable::domainSize(), gum::BayesNetFactory< GUM_SCALAR >::endVariableDeclaration(), GUM_ERROR, gum::DiscreteVariable::label(), gum::prm::PRMAggregate< GUM_SCALAR >::label(), gum::BayesNetFactory< GUM_SCALAR >::setVariableCPTImplementation(), gum::BayesNetFactory< GUM_SCALAR >::startVariableDeclaration(), gum::prm::PRMClassElement< GUM_SCALAR >::type(), and gum::BayesNetFactory< GUM_SCALAR >::variableName().

Referenced by gum::prm::PRMSystem< GUM_SCALAR >::__groundAttr().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

References gum::prm::PRMSystem< GUM_SCALAR >::__groundAgg(), gum::prm::PRMInstance< GUM_SCALAR >::get(), gum::prm::PRMObject::name(), gum::Variable::setName(), gum::BayesNetFactory< GUM_SCALAR >::setVariable(), and gum::prm::PRMInstance< GUM_SCALAR >::type().

Referenced by gum::prm::PRMSystem< GUM_SCALAR >::groundedBN().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

References gum::MultiDimDecorator< GUM_SCALAR >::add(), gum::prm::PRMAttribute< GUM_SCALAR >::cpf(), gum::Instantiation::end(), gum::prm::PRMInstance< GUM_SCALAR >::get(), gum::prm::PRMInstance< GUM_SCALAR >::getInstance(), GUM_ERROR, gum::prm::PRMClassElement< GUM_SCALAR >::id(), gum::Instantiation::inc(), gum::BijectionImplementation< T1, T2, Alloc, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::insert(), gum::prm::PRMSlotChain< GUM_SCALAR >::lastElt(), gum::prm::PRMObject::name(), gum::prm::PRMClassElement< GUM_SCALAR >::safeName(), gum::BijectionImplementation< T1, T2, Alloc, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::second(), gum::MultiDimDecorator< GUM_SCALAR >::set(), gum::Instantiation::setFirst(), gum::BayesNetFactory< GUM_SCALAR >::setVariableCPT(), gum::prm::PRMAttribute< GUM_SCALAR >::type(), gum::prm::PRMInstance< GUM_SCALAR >::type(), and gum::BayesNetFactory< GUM_SCALAR >::variable().

Referenced by gum::prm::PRMSystem< GUM_SCALAR >::__groundRef().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

References gum::prm::PRMSystem< GUM_SCALAR >::__groundPotential(), gum::BayesNetFactory< GUM_SCALAR >::addParent(), gum::BayesNetFactory< GUM_SCALAR >::endParentsDeclaration(), gum::prm::PRMObject::name(), gum::prm::PRMClassElement< GUM_SCALAR >::safeName(), and gum::BayesNetFactory< GUM_SCALAR >::startParentsDeclaration().

Referenced by gum::prm::PRMSystem< GUM_SCALAR >::groundedBN().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

References gum::prm::PRMSystem< GUM_SCALAR >::__instanceMap, gum::prm::PRMSystem< GUM_SCALAR >::__nameMap, gum::prm::PRMSystem< GUM_SCALAR >::__nodeIdMap, gum::prm::PRMSystem< GUM_SCALAR >::__skeleton, gum::NodeGraphPart::addNode(), GUM_ERROR, gum::prm::PRMObject::name(), and gum::prm::PRMInstance< GUM_SCALAR >::type().

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

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

References gum::prm::PRMSystem< GUM_SCALAR >::__arrayMap, gum::prm::PRMSystem< GUM_SCALAR >::add(), GUM_ERROR, gum::HashTable< Key, Val, Alloc >::insert(), and gum::prm::PRMInstance< GUM_SCALAR >::type().

472  {
473  try {
474  if (i->type().isSubTypeOf(*(__arrayMap[array].first))) {
475  NodeId id = add(i);
476  __arrayMap[array].second->insert(i);
477  return id;
478  } else {
479  GUM_ERROR(TypeError,
480  "the given Instance<GUM_SCALAR> is of an incorrect "
481  "Class<GUM_SCALAR> type");
482  }
483  } catch (NotFound&) {
484  GUM_ERROR(NotFound, "found no array matching the given name");
485  }
486  }
unsigned int NodeId
Type for node ids.
Definition: graphElements.h:97
NodeId add(PRMInstance< GUM_SCALAR > *i)
Add an PRMInstance to this system.
Definition: PRMSystem_tpl.h:58
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:291
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:66

+ Here is the call graph for this function:

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

References gum::prm::PRMSystem< GUM_SCALAR >::add().

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

+ Here is the call graph for this function:

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

References gum::prm::PRMSystem< GUM_SCALAR >::__arrayMap, gum::HashTable< Key, Val, Alloc >::exists(), GUM_ERROR, and gum::HashTable< Key, Val, Alloc >::insert().

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

490  {
491  if (__arrayMap.exists(array)) {
492  GUM_ERROR(DuplicateElement,
493  "an array with the same is already in this System");
494  }
495 
496  __arrayMap.insert(array,
498  &type, new Sequence< PRMInstance< GUM_SCALAR >* >()));
499  }
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:287
HashTable< std::string, model_pair > __arrayMap
Mapping between arrays and their name. The first element of the pair is the type of the array...
Definition: PRMSystem.h:291
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:66

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

References gum::prm::PRMSystem< GUM_SCALAR >::__nodeIdMap.

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

503  {
504  return __nodeIdMap.begin();
505  }
NodeProperty< PRMInstance< GUM_SCALAR > * > __nodeIdMap
The maping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:274

+ Here is the caller graph for this function:

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.

References gum::prm::PRMSystem< GUM_SCALAR >::__nodeIdMap.

515  {
516  return __nodeIdMap.begin();
517  }
NodeProperty< PRMInstance< GUM_SCALAR > * > __nodeIdMap
The maping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:274
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.

References gum::prm::PRMSystem< GUM_SCALAR >::__arrayMap, gum::HashTable< Key, Val, Alloc >::begin(), and GUM_ERROR.

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

+ Here is the call graph for this function:

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

References gum::prm::PRMSystem< GUM_SCALAR >::__arrayMap, gum::HashTable< Key, Val, Alloc >::begin(), and GUM_ERROR.

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

+ Here is the call graph for this function:

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

References gum::prm::PRMSystem< GUM_SCALAR >::__nodeIdMap.

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

509  {
510  return __nodeIdMap.end();
511  }
NodeProperty< PRMInstance< GUM_SCALAR > * > __nodeIdMap
The maping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:274

+ Here is the caller graph for this function:

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.

References gum::prm::PRMSystem< GUM_SCALAR >::__nodeIdMap.

521  {
522  return __nodeIdMap.end();
523  }
NodeProperty< PRMInstance< GUM_SCALAR > * > __nodeIdMap
The maping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:274
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 537 of file PRMSystem_tpl.h.

References gum::prm::PRMSystem< GUM_SCALAR >::__arrayMap, gum::HashTable< Key, Val, Alloc >::end(), and GUM_ERROR.

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

+ Here is the call graph for this function:

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

References gum::prm::PRMSystem< GUM_SCALAR >::__arrayMap, gum::HashTable< Key, Val, Alloc >::end(), and GUM_ERROR.

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

+ Here is the call graph for this function:

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:

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

References gum::prm::PRMSystem< GUM_SCALAR >::__arrayMap, gum::prm::PRMSystem< GUM_SCALAR >::__nameMap, and gum::HashTable< Key, Val, Alloc >::exists().

Referenced by gum::prm::o3prmr::O3prmrInterpreter::findInstanceName().

566  {
567  return __nameMap.exists(name) || __arrayMap.exists(name);
568  }
bool exists(const Key &key) const
Checks whether there exists an element with a given key in the hashtable.
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:277
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:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

References gum::prm::PRMSystem< GUM_SCALAR >::__nodeIdMap, and GUM_ERROR.

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

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

+ Here is the caller graph for this function:

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

References gum::prm::PRMSystem< GUM_SCALAR >::__nodeIdMap, and GUM_ERROR.

354  {
355  try {
356  return *(__nodeIdMap[id]);
357  } catch (NotFound&) {
358  GUM_ERROR(NotFound, "found no Instance<GUM_SCALAR> matching the given id");
359  }
360  }
NodeProperty< PRMInstance< GUM_SCALAR > * > __nodeIdMap
The maping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:274
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66
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 364 of file PRMSystem_tpl.h.

References gum::prm::PRMSystem< GUM_SCALAR >::__nodeIdMap, and GUM_ERROR.

364  {
365  try {
366  return __nodeIdMap.keyByVal(const_cast< PRMInstance< GUM_SCALAR >* >(&i));
367  } catch (NotFound&) {
368  GUM_ERROR(NotFound, "found no Instance<GUM_SCALAR> matching the given id");
369  }
370  }
NodeProperty< PRMInstance< GUM_SCALAR > * > __nodeIdMap
The maping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:274
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66
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 408 of file PRMSystem_tpl.h.

References gum::prm::PRMSystem< GUM_SCALAR >::__nameMap, GUM_ERROR, and gum::prm::PRMObject::name().

408  {
409  try {
410  return *(__nameMap[name]);
411  } catch (NotFound&) {
412  GUM_ERROR(NotFound,
413  "found no Instance<GUM_SCALAR> matching the given name");
414  }
415  }
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:277
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66

+ Here is the call graph for this function:

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

References gum::prm::PRMSystem< GUM_SCALAR >::__nameMap, GUM_ERROR, and gum::prm::PRMObject::name().

419  {
420  try {
421  return *(__nameMap[name]);
422  } catch (NotFound&) {
423  GUM_ERROR(NotFound,
424  "found no Instance<GUM_SCALAR> matching the given name");
425  }
426  }
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:277
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66

+ Here is the call graph for this function:

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

References gum::prm::PRMSystem< GUM_SCALAR >::__instanceMap, and GUM_ERROR.

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

References gum::prm::PRMSystem< GUM_SCALAR >::__arrayMap, GUM_ERROR, and gum::prm::PRMObject::name().

442  {
443  try {
444  return *(__arrayMap[name].second);
445  } catch (NotFound&) {
446  GUM_ERROR(NotFound, "found no array matching the given name");
447  }
448  }
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:291
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66

+ Here is the call graph for this function:

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

References gum::prm::PRMSystem< GUM_SCALAR >::__arrayMap, GUM_ERROR, and gum::prm::PRMObject::name().

452  {
453  try {
454  return *(__arrayMap[name].first);
455  } catch (NotFound&) {
456  GUM_ERROR(NotFound, "found no array matching the given name");
457  }
458  }
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:291
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66

+ Here is the call graph for this function:

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

References gum::prm::PRMSystem< GUM_SCALAR >::__arrayMap, GUM_ERROR, and gum::prm::PRMObject::name().

462  {
463  try {
464  return *(__arrayMap[name].first);
465  } catch (NotFound&) {
466  GUM_ERROR(NotFound, "found no array matching the given name");
467  }
468  }
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:291
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66

+ Here is the call graph for this function:

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

References gum::prm::PRMSystem< GUM_SCALAR >::__groundAttr(), gum::prm::PRMSystem< GUM_SCALAR >::__groundRef(), gum::BayesNetFactory< GUM_SCALAR >::addNetworkProperty(), gum::prm::PRMSystem< GUM_SCALAR >::begin(), gum::prm::PRMSystem< GUM_SCALAR >::end(), gum::BayesNetFactory< GUM_SCALAR >::endNetworkDeclaration(), gum::prm::PRMObject::name(), and gum::BayesNetFactory< GUM_SCALAR >::startNetworkDeclaration().

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

82  {
83  factory.startNetworkDeclaration();
84  factory.addNetworkProperty("name", name());
85  factory.endNetworkDeclaration();
86 
87  // Adding nodes
88  for (PRMSystem< GUM_SCALAR >::const_iterator iter = begin(); iter != end();
89  ++iter) {
90  __groundAttr(*(iter.val()), factory);
91  }
92 
93  // Adding arcs and filling CPTs
94  for (PRMSystem< GUM_SCALAR >::const_iterator iter = begin(); iter != end();
95  ++iter) {
96  __groundRef(*(iter.val()), factory);
97  }
98  }
iterator begin()
Returns an iterator over the instances in this system.
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.
void __groundAttr(const PRMInstance< GUM_SCALAR > &instance, BayesNetFactory< GUM_SCALAR > &factory) const
Method which ground Atttributes and Aggregators of an PRMInstance.
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
NodeProperty< PRMInstance< GUM_SCALAR > * >::const_iterator const_iterator
Constant Iterator over the PRMInstance of this PRMSystem.
Definition: PRMSystem.h:219
const iterator & end()
Returns a iterator at the end of the set of PRMInstance in this PRMSystem.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Instantiate all the PRMInstance in this PRMSystem.

Definition at line 400 of file PRMSystem_tpl.h.

References gum::prm::PRMSystem< GUM_SCALAR >::begin(), and gum::prm::PRMSystem< GUM_SCALAR >::end().

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

400  {
401  for (auto iter = begin(); iter != end(); ++iter) {
402  (*(iter.val())).instantiate();
403  }
404  }
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 call graph for this function:

+ Here is the caller graph for this function:

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

References gum::prm::PRMSystem< GUM_SCALAR >::__arrayMap, and gum::HashTable< Key, Val, Alloc >::exists().

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

395  {
396  return __arrayMap.exists(name);
397  }
bool exists(const Key &key) const
Checks whether there exists an element with a given key in the hashtable.
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:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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::PRMClass< GUM_SCALAR >::scope(), and 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:

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:

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

References gum::prm::PRMSystem< GUM_SCALAR >::__nameMap.

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

390  {
391  return __nameMap.exists(name);
392  }
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:277

+ Here is the caller graph for this function:

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

References gum::prm::PRMSystem< GUM_SCALAR >::__instanceMap.

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

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::PRMClassElement< GUM_SCALAR >::cast(), gum::prm::decomposePath(), gum::prm::PRMAggregate< GUM_SCALAR >::PRMAggregate(), gum::prm::PRMFormAttribute< GUM_SCALAR >::PRMFormAttribute(), gum::prm::PRMReferenceSlot< GUM_SCALAR >::PRMReferenceSlot(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::PRMScalarAttribute(), and gum::prm::PRMSlotChain< GUM_SCALAR >::PRMSlotChain().

76 { return "("; }

+ Here is the caller graph for this function:

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< GUM_SCALAR >::__addIOInterfaceFlags(), gum::prm::PRMFactory< GUM_SCALAR >::__addParent(), gum::prm::PRMInstance< GUM_SCALAR >::__addReferingInstance(), gum::prm::PRMClass< GUM_SCALAR >::__checkInterface(), gum::prm::PRMFactory< GUM_SCALAR >::__checkInterfaceImplementation(), gum::prm::PRMClass< GUM_SCALAR >::__checkInterfaces(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::__checkRawCPT(), gum::prm::PRMClass< GUM_SCALAR >::__checkRefInterface(), gum::prm::PRMClass< GUM_SCALAR >::__checkRefInterfaces(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::__checkRuleCPTSumsTo1(), gum::prm::PRMInstance< GUM_SCALAR >::__copyAggregates(), gum::prm::PRMInstance< GUM_SCALAR >::__copyAttribute(), gum::prm::PRMSlotChain< GUM_SCALAR >::__copyLastElt(), gum::prm::PRMSystem< GUM_SCALAR >::__groundAttr(), gum::prm::PRMSystem< GUM_SCALAR >::__groundPotential(), gum::prm::PRMSystem< GUM_SCALAR >::__groundRef(), gum::prm::PRMClass< GUM_SCALAR >::__inheritClass(), gum::prm::PRMInterface< GUM_SCALAR >::__overloadAttribute(), gum::prm::PRMClass< GUM_SCALAR >::__overloadAttribute(), gum::prm::PRMClass< GUM_SCALAR >::__overloadParameter(), gum::prm::PRMClass< GUM_SCALAR >::__overloadReference(), gum::prm::PRMInterface< GUM_SCALAR >::__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< GUM_SCALAR >::add(), gum::prm::PRMSystem< GUM_SCALAR >::add(), gum::prm::PRMClass< GUM_SCALAR >::add(), gum::prm::PRMFactory< GUM_SCALAR >::addAggregator(), gum::prm::PRMFormAttribute< GUM_SCALAR >::addParent(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::addParent(), gum::prm::PRMClassElement< GUM_SCALAR >::cast(), gum::prm::PRMClass< GUM_SCALAR >::completeInheritance(), gum::prm::PRMFormAttribute< GUM_SCALAR >::copy(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::copy(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::exists(), gum::prm::o3prmr::O3prmrInterpreter::findAttributeName(), gum::prm::o3prmr::O3prmrInterpreter::findInstanceName(), gum::prm::PRMInterface< GUM_SCALAR >::get(), gum::prm::PRMSystem< GUM_SCALAR >::get(), gum::prm::PRMClass< GUM_SCALAR >::get(), gum::prm::PRMSystem< GUM_SCALAR >::getArray(), gum::prm::PRMSystem< GUM_SCALAR >::getArrayType(), gum::prm::PRMFormAttribute< GUM_SCALAR >::getCastDescendant(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::getCastDescendant(), gum::prm::PRMAggregate< GUM_SCALAR >::getCastDescendant(), gum::prm::PRMSystem< GUM_SCALAR >::groundedBN(), gum::prm::PRMClass< GUM_SCALAR >::inheritAggregates(), gum::prm::PRMClass< GUM_SCALAR >::isCastDescendant(), gum::prm::PRMObject::isInstance(), gum::prm::PRMObject::name(), gum::prm::PRMType< GUM_SCALAR >::name(), gum::prm::PRMFormAttribute< GUM_SCALAR >::newFactory(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::newFactory(), gum::prm::PRMType< GUM_SCALAR >::operator!=(), gum::prm::PRMObject::operator!=(), operator<<(), gum::prm::PRMType< GUM_SCALAR >::operator==(), gum::prm::PRMObject::operator==(), gum::prm::PRMInterface< GUM_SCALAR >::operator[](), gum::prm::PRMClass< GUM_SCALAR >::operator[](), gum::prm::PRMInterface< GUM_SCALAR >::overload(), gum::prm::PRMClass< GUM_SCALAR >::overload(), gum::prm::PRMAggregate< GUM_SCALAR >::PRMAggregate(), gum::prm::PRMFormAttribute< GUM_SCALAR >::PRMFormAttribute(), gum::prm::PRMParameter< GUM_SCALAR >::PRMParameter(), gum::prm::PRMReferenceSlot< GUM_SCALAR >::PRMReferenceSlot(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::PRMScalarAttribute(), gum::prm::PRMSlotChain< GUM_SCALAR >::PRMSlotChain(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::setInputNode(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::setOutputNode(), and gum::prm::PRMAggregate< double >::str2enum().

32 { return __name; }
std::string __name
Definition: PRMObject.h:197
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:

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

References gum::prm::PRMObject::SYSTEM.

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:

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

Copy operator. Don't use it.

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:

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::PRMClassElement< GUM_SCALAR >::cast(), gum::prm::decomposePath(), gum::prm::PRMAggregate< GUM_SCALAR >::PRMAggregate(), gum::prm::PRMFormAttribute< GUM_SCALAR >::PRMFormAttribute(), gum::prm::PRMReferenceSlot< GUM_SCALAR >::PRMReferenceSlot(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::PRMScalarAttribute(), and gum::prm::PRMSlotChain< GUM_SCALAR >::PRMSlotChain().

77 { return ")"; }

+ Here is the caller graph for this function:

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

Returns the number of PRMInstance in this PRMSystem.

Definition at line 378 of file PRMSystem_tpl.h.

References gum::prm::PRMSystem< GUM_SCALAR >::__nodeIdMap.

378  {
379  return __nodeIdMap.size();
380  }
NodeProperty< PRMInstance< GUM_SCALAR > * > __nodeIdMap
The maping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:274
template<typename GUM_SCALAR >
INLINE const DiGraph & gum::prm::PRMSystem< GUM_SCALAR >::skeleton ( ) const

Returns the relation skeleton of this PRMSystem.

Definition at line 339 of file PRMSystem_tpl.h.

References gum::prm::PRMSystem< GUM_SCALAR >::__skeleton.

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

Member Data Documentation

template<typename GUM_SCALAR>
HashTable< PRMClass< GUM_SCALAR >*, Set< PRMInstance< GUM_SCALAR >* >* > gum::prm::PRMSystem< GUM_SCALAR >::__instanceMap
private
template<typename GUM_SCALAR>
HashTable< std::string, PRMInstance< GUM_SCALAR >* > gum::prm::PRMSystem< GUM_SCALAR >::__nameMap
private
template<typename GUM_SCALAR>
NodeProperty< PRMInstance< GUM_SCALAR >* > gum::prm::PRMSystem< GUM_SCALAR >::__nodeIdMap
private
template<typename GUM_SCALAR>
DiGraph gum::prm::PRMSystem< GUM_SCALAR >::__skeleton
private

The relational skeleton of this PRMSystem.

Definition at line 270 of file PRMSystem.h.

Referenced by gum::prm::PRMSystem< GUM_SCALAR >::add(), and gum::prm::PRMSystem< GUM_SCALAR >::skeleton().


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