aGrUM  0.18.1
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 229 of file PRMObject.h.

Member Typedef Documentation

◆ array_iterator

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

Iterator over the PRMInstance in an array in this PRMSystem.

Definition at line 231 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 245 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 220 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 209 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 289 of file PRMSystem.h.

Member Enumeration Documentation

◆ prm_type

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

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

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

Enumerator
ALL 
CLASS 
PRM_INTERFACE 
CLASS_ELT 
TYPE 
SYSTEM 
INSTANCE 

Definition at line 69 of file PRMObject.h.

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

Constructor & Destructor Documentation

◆ PRMSystem() [1/2]

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

Default constructor.

Definition at line 42 of file PRMSystem_tpl.h.

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

◆ ~PRMSystem()

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

Destructor.

Definition at line 47 of file PRMSystem_tpl.h.

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

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

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

Member Function Documentation

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

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

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

◆ add() [2/3]

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

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

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

Definition at line 521 of file PRMSystem_tpl.h.

522  {
523  try {
524  if (i->type().isSubTypeOf(*(arrayMap_[array].first))) {
525  NodeId id = add(i);
526  arrayMap_[array].second->insert(i);
527  return id;
528  } else {
529  GUM_ERROR(TypeError,
530  "the given Instance<GUM_SCALAR> is of an incorrect "
531  "Class<GUM_SCALAR> type");
532  }
533  } catch (NotFound&) {
534  GUM_ERROR(NotFound, "found no array matching the given name");
535  }
536  }
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:293
NodeId add(PRMInstance< GUM_SCALAR > *i)
Add an PRMInstance to this system.
Definition: PRMSystem_tpl.h:69
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
Size NodeId
Type for node ids.
Definition: graphElements.h:98
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ add() [3/3]

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

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

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

Definition at line 381 of file PRMSystem_tpl.h.

382  {
383  return add(array, &i);
384  }
NodeId add(PRMInstance< GUM_SCALAR > *i)
Add an PRMInstance to this system.
Definition: PRMSystem_tpl.h:69

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

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

540  {
541  if (arrayMap_.exists(array)) {
542  GUM_ERROR(DuplicateElement,
543  "an array '" << array << "' is already in this System");
544  }
545 
546  arrayMap_.insert(array,
548  &type, new Sequence< PRMInstance< GUM_SCALAR >* >()));
549  }
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:293
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:289
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the caller graph for this function:

◆ begin() [1/4]

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

Returns an iterator over the instances in this system.

Definition at line 553 of file PRMSystem_tpl.h.

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

553  {
554  return nodeIdMap_.begin();
555  }
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:276
+ Here is the caller graph for this function:

◆ begin() [2/4]

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

Returns a constant iterator over the instances in this system.

Definition at line 565 of file PRMSystem_tpl.h.

565  {
566  return nodeIdMap_.begin();
567  }
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:276

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

577  {
578  try {
579  return arrayMap_[a].second->begin();
580  } catch (NotFound&) {
581  GUM_ERROR(NotFound, "found no array matching the given name");
582  }
583  }
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:293
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ begin() [4/4]

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

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

Exceptions
NotFoundRaised if no array matches a.

Definition at line 597 of file PRMSystem_tpl.h.

597  {
598  try {
599  return arrayMap_[a].second->begin();
600  } catch (NotFound&) {
601  GUM_ERROR(NotFound, "found no array matching the given name");
602  }
603  }
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:293
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ end() [1/4]

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

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

Definition at line 559 of file PRMSystem_tpl.h.

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

559  {
560  return nodeIdMap_.end();
561  }
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:276
+ Here is the caller graph for this function:

◆ end() [2/4]

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

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

Definition at line 571 of file PRMSystem_tpl.h.

571  {
572  return nodeIdMap_.end();
573  }
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:276

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

587  {
588  try {
589  return arrayMap_[a].second->end();
590  } catch (NotFound&) {
591  GUM_ERROR(NotFound, "found no array matching the given name");
592  }
593  }
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:293
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ end() [4/4]

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

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

Exceptions
NotFoundRaised if no array matches a.

Definition at line 607 of file PRMSystem_tpl.h.

607  {
608  try {
609  return arrayMap_[a].second->end();
610  } catch (NotFound&) {
611  GUM_ERROR(NotFound, "found no array matching the given name");
612  }
613  }
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:293
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ enum2str()

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

Returns the string representation of a PRMObject.

Definition at line 83 of file PRMObject.h.

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

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

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

◆ exists()

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

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

Definition at line 616 of file PRMSystem_tpl.h.

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

616  {
617  return nameMap_.exists(name) || arrayMap_.exists(name);
618  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
bool exists(const Key &key) const
Checks whether there exists an element with a given key in the hashtable.
HashTable< std::string, model_pair > arrayMap_
Mapping between arrays and their name. The first element of the pair is the type of the array...
Definition: PRMSystem.h:293
HashTable< std::string, PRMInstance< GUM_SCALAR > *> nameMap_
The mapping between PRMInstance and their names.
Definition: PRMSystem.h:279
+ Here is the caller graph for this function:

◆ get() [1/6]

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

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

Exceptions
NotFoundRaised if no PRMInstance matches the given NodeId.

Definition at line 392 of file PRMSystem_tpl.h.

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

392  {
393  try {
394  return *(nodeIdMap_[id]);
395  } catch (NotFound&) {
396  GUM_ERROR(NotFound, "found no Instance<GUM_SCALAR> matching the given id");
397  }
398  }
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:276
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the caller graph for this function:

◆ get() [2/6]

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

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

Exceptions
NotFoundRaised if no PRMInstance matches the given NodeId.

Definition at line 402 of file PRMSystem_tpl.h.

402  {
403  try {
404  return *(nodeIdMap_[id]);
405  } catch (NotFound&) {
406  GUM_ERROR(NotFound, "found no Instance<GUM_SCALAR> matching the given id");
407  }
408  }
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:276
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ get() [3/6]

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

Returns the relation skeleton of this PRMSystem.

Definition at line 412 of file PRMSystem_tpl.h.

412  {
413  try {
414  return nodeIdMap_.keyByVal(const_cast< PRMInstance< GUM_SCALAR >* >(&i));
415  } catch (NotFound&) {
416  GUM_ERROR(NotFound, "found no Instance<GUM_SCALAR> matching the given id");
417  }
418  }
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:276
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ get() [4/6]

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

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

Exceptions
NotFoundRaised if the no PRMInstance matches name.

Definition at line 456 of file PRMSystem_tpl.h.

456  {
457  try {
458  return *(nameMap_[name]);
459  } catch (NotFound&) {
460  GUM_ERROR(NotFound,
461  "found no Instance<GUM_SCALAR> matching the given name");
462  }
463  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
HashTable< std::string, PRMInstance< GUM_SCALAR > *> nameMap_
The mapping between PRMInstance and their names.
Definition: PRMSystem.h:279
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ get() [5/6]

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

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

Exceptions
NotFoundRaised if the no PRMInstance matches name.

Definition at line 467 of file PRMSystem_tpl.h.

467  {
468  try {
469  return *(nameMap_[name]);
470  } catch (NotFound&) {
471  GUM_ERROR(NotFound,
472  "found no Instance<GUM_SCALAR> matching the given name");
473  }
474  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
HashTable< std::string, PRMInstance< GUM_SCALAR > *> nameMap_
The mapping between PRMInstance and their names.
Definition: PRMSystem.h:279
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ get() [6/6]

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

Returns the sequence of all instances of the given type.

Exceptions
NotFoundRaised if there is instantiation of type.

Definition at line 479 of file PRMSystem_tpl.h.

479  {
480  try {
481  return *(instanceMap_[const_cast< PRMClass< GUM_SCALAR >* >(&type)]);
482  } catch (NotFound&) {
483  GUM_ERROR(
484  NotFound,
485  "the given Class<GUM_SCALAR> has no instantiation in this System");
486  }
487  }
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:283
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ getArray()

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

Returns the sequence of instances of a given array.

Exceptions
NotFoundRaised if no array matches name.

Definition at line 492 of file PRMSystem_tpl.h.

492  {
493  try {
494  return *(arrayMap_[name].second);
495  } catch (NotFound&) {
496  GUM_ERROR(NotFound, "found no array matching the given name");
497  }
498  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
HashTable< std::string, model_pair > arrayMap_
Mapping between arrays and their name. The first element of the pair is the type of the array...
Definition: PRMSystem.h:293
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ getArrayType() [1/2]

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

Returns the type of the given array.

Exceptions
NotFoundRaised if no array matches name.

Definition at line 502 of file PRMSystem_tpl.h.

502  {
503  try {
504  return *(arrayMap_[name].first);
505  } catch (NotFound&) {
506  GUM_ERROR(NotFound, "found no array matching the given name");
507  }
508  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
HashTable< std::string, model_pair > arrayMap_
Mapping between arrays and their name. The first element of the pair is the type of the array...
Definition: PRMSystem.h:293
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ getArrayType() [2/2]

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

Returns the type of the given array.

Exceptions
NotFoundRaised if no array matches name.

Definition at line 512 of file PRMSystem_tpl.h.

512  {
513  try {
514  return *(arrayMap_[name].first);
515  } catch (NotFound&) {
516  GUM_ERROR(NotFound, "found no array matching the given name");
517  }
518  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
HashTable< std::string, model_pair > arrayMap_
Mapping between arrays and their name. The first element of the pair is the type of the array...
Definition: PRMSystem.h:293
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

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

151  {
152  factory.startVariableDeclaration();
153  factory.variableName(name);
154 
155  const DiscreteVariable& agg_var = elt.type().variable();
156 
157  VarType var_type = agg_var.varType();
158 
159  factory.variableType(var_type);
160 
161  switch (var_type) {
162  case VarType::Labelized: {
163  const auto l = static_cast< const LabelizedVariable& >(agg_var);
164  for (Idx i = 0; i < l.domainSize(); ++i) {
165  factory.addModality(l.label(i));
166  }
167  break;
168  }
169  case VarType::Discretized: {
170  const auto d =
171  static_cast< const DiscretizedVariable< GUM_SCALAR >& >(agg_var);
172  for (Idx i = 0; i < d.domainSize(); ++i) {
173  factory.addTick(d.tick(i));
174  }
175  break;
176  }
177  case VarType::Range: {
178  const auto r = static_cast< const RangeVariable& >(agg_var);
179  factory.addMin(r.minVal());
180  factory.addMax(r.maxVal());
181  break;
182  }
183  case VarType::Continuous:
184  // Todo Error
185  break;
186  }
187 
188  const PRMAggregate< GUM_SCALAR >& agg =
189  static_cast< const PRMAggregate< GUM_SCALAR >& >(elt);
190 
191  switch (agg.agg_type()) {
193  factory.setVariableCPTImplementation(
194  new aggregator::Min< GUM_SCALAR >());
195  break;
196  }
197 
199  factory.setVariableCPTImplementation(
200  new aggregator::Max< GUM_SCALAR >());
201  break;
202  }
203 
205  factory.setVariableCPTImplementation(
206  new aggregator::Exists< GUM_SCALAR >(agg.label()));
207  break;
208  }
209 
211  factory.setVariableCPTImplementation(
212  new aggregator::Forall< GUM_SCALAR >(agg.label()));
213  break;
214  }
215 
217  factory.setVariableCPTImplementation(
218  new aggregator::Count< GUM_SCALAR >(agg.label()));
219  break;
220  }
221 
223  factory.setVariableCPTImplementation(
224  new aggregator::Median< GUM_SCALAR >());
225  break;
226  }
227 
229  factory.setVariableCPTImplementation(
230  new aggregator::Amplitude< GUM_SCALAR >());
231  break;
232  }
233 
235  factory.setVariableCPTImplementation(new aggregator::Or< GUM_SCALAR >());
236  break;
237  }
238 
240  factory.setVariableCPTImplementation(
241  new aggregator::And< GUM_SCALAR >());
242  break;
243  }
244 
246  factory.setVariableCPTImplementation(
247  new aggregator::Sum< GUM_SCALAR >());
248  break;
249  }
250 
251  default: {
252  GUM_ERROR(OperationNotAllowed, "Aggregator not handled yet");
253  break;
254  }
255  }
256 
257  factory.endVariableDeclaration();
258  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
VarType
Definition: variable.h:41
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ groundAttr__()

template<typename GUM_SCALAR>
void gum::prm::PRMSystem< GUM_SCALAR >::groundAttr__ ( const PRMInstance< GUM_SCALAR > &  instance,
BayesNetFactory< GUM_SCALAR > &  factory 
) const
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 111 of file PRMSystem_tpl.h.

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

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

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

92  {
93  factory.startNetworkDeclaration();
94  factory.addNetworkProperty("name", name());
95  factory.endNetworkDeclaration();
96 
97  // Adding nodes
98  for (PRMSystem< GUM_SCALAR >::const_iterator iter = begin(); iter != end();
99  ++iter) {
100  groundAttr__(*(iter.val()), factory);
101  }
102 
103  // Adding arcs and filling CPTs
104  for (PRMSystem< GUM_SCALAR >::const_iterator iter = begin(); iter != end();
105  ++iter) {
106  groundRef__(*(iter.val()), factory);
107  }
108  }
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 std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
iterator begin()
Returns an iterator over the instances in this system.
NodeProperty< PRMInstance< GUM_SCALAR > *>::const_iterator const_iterator
Constant Iterator over the PRMInstance of this PRMSystem.
Definition: PRMSystem.h:220
void groundAttr__(const PRMInstance< GUM_SCALAR > &instance, BayesNetFactory< GUM_SCALAR > &factory) const
Method which ground Atttributes and Aggregators of an PRMInstance.
const iterator & end()
Returns a iterator at the end of the set of PRMInstance in this PRMSystem.
+ Here is the caller graph for this function:

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

322  {
323  Bijection< const DiscreteVariable*, const DiscreteVariable* > bijection;
324  std::stringstream var_name;
325  var_name << instance.name() << "." << attr.safeName();
326  bijection.insert(&(attr.type().variable()),
327  &(factory.variable(var_name.str())));
328 
329  for (const auto parent: instance.type().containerDag().parents(attr.id())) {
330  switch (instance.type().get(parent).elt_type()) {
333  std::stringstream parent_name;
334  parent_name << instance.name() << "."
335  << instance.get(parent).safeName();
336  bijection.insert(&(instance.get(parent).type().variable()),
337  &(factory.variable(parent_name.str())));
338  break;
339  }
340 
342  std::stringstream parent_name;
343  const PRMSlotChain< GUM_SCALAR >& sc =
344  static_cast< const PRMSlotChain< GUM_SCALAR >& >(
345  instance.type().get(parent));
346  parent_name << instance.getInstance(sc.id()).name() << "."
347  << sc.lastElt().safeName();
348  bijection.insert(&(instance.getInstance(sc.id())
349  .get(sc.lastElt().safeName())
350  .type()
351  .variable()),
352  &(factory.variable(parent_name.str())));
353  break;
354  }
355 
356  default: {
357  GUM_ERROR(FatalError,
358  "invalid ClassElement<GUM_SCALAR> type as parent.");
359  break;
360  }
361  }
362  }
363 
364  // Copy Potential
365  // DO NOT USE MultiDimBijArray as they will wreck havok if you delete
366  // the prm befor its grounded BN (happens a lot in pyAgrum)
367  Potential< GUM_SCALAR >* p = new Potential< GUM_SCALAR >();
368  for (auto var: attr.cpf().variablesSequence()) {
369  p->add(*(bijection.second(var)));
370  }
371  Instantiation inst(attr.cpf()), jnst(*p);
372  for (inst.setFirst(), jnst.setFirst(); !(inst.end() || jnst.end());
373  inst.inc(), jnst.inc()) {
374  p->set(jnst, attr.cpf().get(inst));
375  }
376  GUM_ASSERT(inst.end() && jnst.end());
377  factory.setVariableCPT(var_name.str(), p, false);
378  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ groundRef__()

template<typename GUM_SCALAR>
void gum::prm::PRMSystem< GUM_SCALAR >::groundRef__ ( const PRMInstance< GUM_SCALAR > &  instance,
BayesNetFactory< GUM_SCALAR > &  factory 
) const
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 261 of file PRMSystem_tpl.h.

263  {
264  for (const auto& elt: instance) {
265  std::stringstream elt_name;
266  elt_name << instance.name() << "." << elt.second->safeName();
267  factory.startParentsDeclaration(elt_name.str());
268 
269  for (const auto par:
270  instance.type().containerDag().parents(elt.second->id())) {
271  switch (instance.type().get(par).elt_type()) {
274  std::stringstream parent_name;
275  parent_name << instance.name() << "."
276  << instance.get(par).safeName();
277  factory.addParent(parent_name.str());
278  break;
279  }
280 
282  std::string parent_name =
283  static_cast< const PRMSlotChain< GUM_SCALAR >& >(
284  instance.type().get(par))
285  .lastElt()
286  .safeName();
287 
288  try {
289  for (const auto ref: instance.getInstances(par)) {
290  std::stringstream sBuff;
291  sBuff << ref->name() << "." << parent_name;
292  factory.addParent(sBuff.str());
293  }
294  } catch (NotFound&) {
295  // No instances for this slotchain
296  }
297 
298  break;
299  }
300 
301  default:
302  break;
303  /* nothing to do by default */
304  }
305  }
306 
307  factory.endParentsDeclaration();
308 
309  // Checking if we need to ground the Potential (only for class level
310  // attributes since
311  // aggregates Potentials are generated)
313  instance.type().get(elt.second->safeName())))
314  groundPotential__(instance, *elt.second, factory);
315  }
316  }
void groundPotential__(const PRMInstance< GUM_SCALAR > &instance, const PRMAttribute< GUM_SCALAR > &attr, BayesNetFactory< GUM_SCALAR > &factory) const
Method which copy node&#39;s Potential of an PRMInstance to the grounded Bayesian Network.
static INLINE bool isAttribute(const PRMClassElement< GUM_SCALAR > &elt)
Returns true if obj_ptr is of type PRMAttribute.

◆ instantiate()

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

Instantiate all the PRMInstance in this PRMSystem.

Definition at line 448 of file PRMSystem_tpl.h.

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

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

◆ isArray()

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

Returns true if an array with the given name exists.

Definition at line 443 of file PRMSystem_tpl.h.

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

443  {
444  return arrayMap_.exists(name);
445  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
bool exists(const Key &key) const
Checks whether there exists an element with a given key in the hashtable.
HashTable< std::string, model_pair > arrayMap_
Mapping between arrays and their name. The first element of the pair is the type of the array...
Definition: PRMSystem.h:293
+ Here is the caller graph for this function:

◆ isClass()

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

Returns true if obj_ptr is of type Class.

Definition at line 102 of file PRMObject.h.

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

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

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

◆ isInstance() [1/2]

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

Returns true if obj_ptr is of type PRMInstance.

Definition at line 112 of file PRMObject.h.

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

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

◆ isInstance() [2/2]

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

Returns true if an PRMInstance with the given name exists.

Definition at line 438 of file PRMSystem_tpl.h.

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

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

◆ isInstantiated()

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

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

Definition at line 431 of file PRMSystem_tpl.h.

432  {
433  return instanceMap_.exists(const_cast< PRMClass< GUM_SCALAR >* >(&c));
434  }
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:283

◆ isInterface()

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

Returns true if obj_ptr is of type PRMInterface.

Definition at line 107 of file PRMObject.h.

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

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

◆ LEFT_CAST()

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

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

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

Definition at line 79 of file PRMObject.h.

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

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

◆ name() [1/2]

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

Returns the name of this object.

Definition at line 35 of file PRMObject_inl.h.

References gum::prm::PRMObject::name__.

Referenced by gum::prm::__print_attribute__(), gum::prm::__print_instance__(), gum::prm::PRMSystem< double >::add(), gum::prm::PRMInterface< double >::add(), gum::prm::PRMClass< double >::add(), gum::prm::PRMFactory< GUM_SCALAR >::addAggregator(), gum::prm::SVE< GUM_SCALAR >::addDelayedVariable__(), gum::prm::PRMClass< double >::addIOInterfaceFlags__(), gum::prm::PRMFormAttribute< GUM_SCALAR >::addParent(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::addParent(), gum::prm::PRMFactory< GUM_SCALAR >::addParent__(), gum::prm::PRMInstance< GUM_SCALAR >::addReferingInstance__(), gum::prm::PRMClass< double >::checkInterface__(), gum::prm::PRMFactory< GUM_SCALAR >::checkInterfaceImplementation__(), gum::prm::PRMClass< double >::checkInterfaces__(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::checkRawCPT__(), gum::prm::PRMClass< double >::checkRefInterface__(), gum::prm::PRMClass< double >::checkRefInterfaces__(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::checkRuleCPTSumsTo1__(), gum::prm::PRMFormAttribute< GUM_SCALAR >::copy(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::copy(), gum::prm::PRMInstance< GUM_SCALAR >::copyAggregates__(), gum::prm::PRMInstance< GUM_SCALAR >::copyAttribute__(), gum::prm::PRMSlotChain< double >::copyLastElt__(), gum::prm::o3prmr::O3prmrInterpreter::findAttributeName(), gum::prm::o3prmr::O3prmrInterpreter::findInstanceName(), gum::prm::PRMFormAttribute< GUM_SCALAR >::getCastDescendant(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::getCastDescendant(), gum::prm::PRMSystem< double >::groundAttr__(), gum::prm::PRMSystem< double >::groundPotential__(), gum::prm::PRMSystem< double >::groundRef__(), gum::prm::PRMClass< double >::inheritAggregates(), gum::prm::PRMClass< double >::inheritClass__(), gum::prm::PRMClass< double >::isCastDescendant(), gum::prm::PRMObject::isInstance(), gum::prm::PRMObject::name(), gum::prm::PRMType::name(), gum::prm::PRMFormAttribute< GUM_SCALAR >::newFactory(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::newFactory(), gum::prm::PRMType::operator!=(), gum::prm::PRMObject::operator!=(), operator<<(), gum::prm::PRMType::operator==(), gum::prm::PRMObject::operator==(), gum::prm::PRMClass< double >::overload(), gum::prm::PRMInterface< double >::overload(), gum::prm::PRMInterface< double >::overloadAttribute__(), gum::prm::PRMClass< double >::overloadAttribute__(), gum::prm::PRMClass< double >::overloadParameter__(), gum::prm::PRMClass< double >::overloadReference__(), gum::prm::PRMInterface< double >::overloadReferenceSlot__(), gum::prm::PRMFormAttribute< GUM_SCALAR >::PRMFormAttribute(), gum::prm::PRMReferenceSlot< double >::PRMReferenceSlot(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::PRMScalarAttribute(), gum::prm::PRMFactory< GUM_SCALAR >::startClass(), gum::prm::PRMFactory< GUM_SCALAR >::startInterface(), gum::prm::PRMFactory< GUM_SCALAR >::startSystem(), gum::prm::PRMAggregate< double >::str2enum(), gum::prm::gspan::StrictSearch< GUM_SCALAR >::str__(), and gum::prm::StructuredInference< GUM_SCALAR >::str__().

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

◆ name() [2/2]

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

Change the name of the PRM Object.

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

Definition at line 39 of file PRMObject_inl.h.

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

39 { name__ = name; }
std::string name__
Definition: PRMObject.h:200
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
+ 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 421 of file PRMSystem_tpl.h.

◆ operator!=()

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

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

Definition at line 49 of file PRMObject_inl.h.

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

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

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

◆ operator=()

template<typename GUM_SCALAR>
PRMSystem< GUM_SCALAR >& gum::prm::PRMSystem< GUM_SCALAR >::operator= ( const PRMSystem< GUM_SCALAR > &  from)
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 43 of file PRMObject_inl.h.

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

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

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

◆ RIGHT_CAST()

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

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

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

Definition at line 80 of file PRMObject.h.

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

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

◆ size()

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

Returns the number of PRMInstance in this PRMSystem.

Definition at line 426 of file PRMSystem_tpl.h.

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

426  {
427  return nodeIdMap_.size();
428  }
NodeProperty< PRMInstance< GUM_SCALAR > *> nodeIdMap_
The mapping between PRMInstance and their NodeId in the relational skeleton of this PRMSystem...
Definition: PRMSystem.h:276
+ Here is the caller graph for this function:

◆ skeleton()

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

Returns the relation skeleton of this PRMSystem.

Definition at line 387 of file PRMSystem_tpl.h.

387  {
388  return skeleton_;
389  }
DiGraph skeleton_
The relational skeleton of this PRMSystem.
Definition: PRMSystem.h:272

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 293 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 283 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 279 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 276 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 272 of file PRMSystem.h.


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