aGrUM  0.13.2
gum::prm::PRMInstance< GUM_SCALAR > Class Template Reference

An PRMInstance is a Bayesian Network fragment defined by a Class and used in a PRMSystem. More...

#include <PRMInstance.h>

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

Public Member Functions

Constructors & private operators.
 PRMInstance (const std::string &name, PRMClass< GUM_SCALAR > &type)
 Default constructor of an PRMInstance<GUM_SCALAR>. More...
 
virtual ~PRMInstance ()
 Destructor. More...
 
Getters & setters.
virtual prm_type obj_type () const
 Returns the PRM type of this object. More...
 
PRMClass< GUM_SCALAR > & type ()
 Returns the type of this instance. More...
 
const PRMClass< GUM_SCALAR > & type () const
 Returns the type of this instance. More...
 
bool exists (NodeId id) const
 Returns true if id matches an PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>. More...
 
bool exists (const std::string &name) const
 Returns true if name matches an PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>. More...
 
PRMAttribute< GUM_SCALAR > & get (NodeId id)
 Getter on an PRMAttribute<GUM_SCALAR> of this PRMInstance<GUM_SCALAR>. More...
 
PRMAttribute< GUM_SCALAR > & get (const std::string &name)
 Given a name returns the related PRMAttribute<GUM_SCALAR>. More...
 
const PRMAttribute< GUM_SCALAR > & get (NodeId id) const
 Getter on an PRMAttribute<GUM_SCALAR> of this PRMInstance<GUM_SCALAR>. More...
 
const PRMAttribute< GUM_SCALAR > & get (const std::string &name) const
 Given a name returns the related PRMClassElement. More...
 
Size size () const
 Returns the number of attributes in this PRMInstance<GUM_SCALAR>. More...
 
Instantiation methods.
void instantiate ()
 Instantiate all nodes which requires it. More...
 
const Bijection< const DiscreteVariable *, const DiscreteVariable * > & bijection () const
 Returns a mapping between DiscreteVariable used in this and the ones used in this PRMInstance<GUM_SCALAR>'s Class<GUM_SCALAR>. More...
 
Reference handling.
void add (NodeId id, PRMInstance< GUM_SCALAR > &instance)
 Add an PRMInstance<GUM_SCALAR> to a given PRMReferenceSlot, PRMSlotChain<GUM_SCALAR> or output node. More...
 
const PRMInstance< GUM_SCALAR > & getInstance (NodeId id) const
 Fast access to the first instance in a PRMReferenceSlot or PRMSlotChain<GUM_SCALAR>. More...
 
const Set< PRMInstance< GUM_SCALAR > * > & getInstances (NodeId id) const
 Returns the Set of PRMInstance<GUM_SCALAR> referenced by id. More...
 
bool hasRefAttr (NodeId id) const
 Returns true if id has at least one referring PRMAttribute<GUM_SCALAR>. More...
 
std::vector< std::pair< PRMInstance< GUM_SCALAR > *, std::string > > & getRefAttr (NodeId id)
 Returns a vector of pairs of refering attributes of id. More...
 
const std::vector< std::pair< PRMInstance< GUM_SCALAR > *, std::string > > & getRefAttr (NodeId id) const
 Returns a vector of pairs of refering attributes of id. 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...
 

Classes

class  RefConstIterator
 Nested class to iterate over PRMReferenceSlot and PRMSlotChain<GUM_SCALAR> instantiations. More...
 
class  RefIterator
 Nested class to iterate over PRMReferenceSlot and PRMSlotChain<GUM_SCALAR> instantiations. More...
 

Iterators

typedef NodeProperty< PRMAttribute< GUM_SCALAR > * >::iterator iterator
 Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>. More...
 
typedef NodeProperty< PRMAttribute< GUM_SCALAR > * >::const_iterator const_iterator
 Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>. More...
 
typedef NodeProperty< std::vector< std::pair< PRMInstance< GUM_SCALAR > *, std::string > > * >::iterator InvRefIterator
 Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>. More...
 
typedef NodeProperty< std::vector< std::pair< PRMInstance< GUM_SCALAR > *, std::string > > * >::const_iterator InvRefConstIterator
 Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>. More...
 
iterator begin ()
 Returns an iterator at the begining of the list of gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>. More...
 
const iteratorend ()
 Returns a reference over the iterator at the end of the list of gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>. More...
 
const_iterator begin () const
 Returns an iterator at the beginning of the list of gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>. More...
 
const const_iteratorend () const
 Returns a reference over the iterator at the end of the list of gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>. More...
 
RefIterator begin (NodeId id)
 Returns an iterator at the beginning of the set of PRMInstance<GUM_SCALAR> associated to a given gum::prm::PRMReferenceSlot or gum::prm::PRMSlotChain<GUM_SCALAR>. More...
 
RefConstIterator begin (NodeId id) const
 Returns an iterator at the beginning of the set of PRMInstance<GUM_SCALAR> associated to a given gum::prm::PRMReferenceSlot or gum::prm::PRMSlotChain<GUM_SCALAR>. More...
 
InvRefIterator beginInvRef ()
 Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>. More...
 
const InvRefIteratorendInvRef ()
 Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>. More...
 
InvRefConstIterator beginInvRef () const
 Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>. More...
 
const InvRefConstIteratorendInvRef () const
 Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>. More...
 

Private members.

typedef std::pair< PRMInstance< GUM_SCALAR > *, std::string > pair
 Code alias. More...
 
bool __instantiated
 True if this instance has been instantiated. More...
 
PRMClass< GUM_SCALAR > * __type
 The type of this PRMInstance<GUM_SCALAR>. More...
 
NodeProperty< PRMAttribute< GUM_SCALAR > * > __nodeIdMap
 The gum::prm::PRMAttribute<GUM_SCALAR> and gum::prm::PRMAggregate<GUM_SCALAR> of this PRMInstance<GUM_SCALAR>. More...
 
NodeProperty< Set< PRMInstance< GUM_SCALAR > * > * > __referenceMap
 Mapping between the gum::prm::PRMReferenceSlot and gum::prm::PRMSlotChain<GUM_SCALAR> in __type / and the PRMInstance<GUM_SCALAR> associated with it. More...
 
NodeProperty< std::vector< pair > * > __referingAttr
 The set of pair (instance, attribute) referring an attribute of this instance. More...
 
Bijection< const DiscreteVariable *, const DiscreteVariable * > __bijection
 A bijection used for MultiDim handling. 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...
 

Detailed Description

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

An PRMInstance is a Bayesian Network fragment defined by a Class and used in a PRMSystem.

Before using an PRMInstance for inference YOU MUST call PRMInstance::instantiateSlotChains() and PRMInstance::instantiate() on it before, otherwise DiscreteVariable pointers will be inconsistent and inference will be erroneous. Of course, this must be done once you have set all reference in the current system.

See also
PRMClass PRM PRMClassElement

Definition at line 60 of file PRMInstance.h.

Member Typedef Documentation

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

Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.

Definition at line 326 of file PRMInstance.h.

template<typename GUM_SCALAR>
typedef NodeProperty< std::vector< std::pair< PRMInstance< GUM_SCALAR >*, std::string > >* >::const_iterator gum::prm::PRMInstance< GUM_SCALAR >::InvRefConstIterator

Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.

Definition at line 444 of file PRMInstance.h.

template<typename GUM_SCALAR>
typedef NodeProperty< std::vector< std::pair< PRMInstance< GUM_SCALAR >*, std::string > >* >::iterator gum::prm::PRMInstance< GUM_SCALAR >::InvRefIterator

Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.

Definition at line 441 of file PRMInstance.h.

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

Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.

Definition at line 312 of file PRMInstance.h.

template<typename GUM_SCALAR>
typedef std::pair< PRMInstance< GUM_SCALAR >*, std::string > gum::prm::PRMInstance< GUM_SCALAR >::pair
private

Code alias.

Definition at line 519 of file PRMInstance.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::PRMInstance< GUM_SCALAR >::PRMInstance ( const std::string &  name,
PRMClass< GUM_SCALAR > &  type 
)

Default constructor of an PRMInstance<GUM_SCALAR>.

When you create an PRMInstance<GUM_SCALAR> all gum::prm::PRMAttribute<GUM_SCALAR> in it's type are added, except for gum::prm::PRMAggregate<GUM_SCALAR> and parameters which are instantiated.

However neither of their children or parents are updated (i.e. DiscreteVariable pointers are inconsistent).

Definition at line 34 of file PRMInstance_tpl.h.

References gum::prm::PRMInstance< GUM_SCALAR >::__copyAggregates(), gum::prm::PRMInstance< GUM_SCALAR >::__copyAttribute(), and gum::prm::PRMInstance< GUM_SCALAR >::__type.

35  :
36  PRMObject(name),
37  __instantiated(false), __type(&type) {
38  GUM_CONSTRUCTOR(PRMInstance);
39 
40  // First we create attributes for each aggregate in type
41  for (const auto agg : __type->aggregates())
42  __copyAggregates(agg);
43 
44  // We add attributes in type by reference for inner ones and by copy for
45  // output ones
46  for (const auto attr : __type->attributes())
47  __copyAttribute(attr);
48  }
PRMClass< GUM_SCALAR > * __type
The type of this PRMInstance<GUM_SCALAR>.
Definition: PRMInstance.h:507
PRMInstance(const std::string &name, PRMClass< GUM_SCALAR > &type)
Default constructor of an PRMInstance<GUM_SCALAR>.
PRMClass< GUM_SCALAR > & type()
Returns the type of this instance.
bool __instantiated
True if this instance has been instantiated.
Definition: PRMInstance.h:504
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
void __copyAttribute(PRMAttribute< GUM_SCALAR > *source)
Used at construction to instantiate attributes.
void __copyAggregates(PRMAggregate< GUM_SCALAR > *source)
Used at construction to instantiate aggregates.
PRMObject(const std::string &name)
Constructor.
Definition: PRMObject.cpp:40

+ Here is the call graph for this function:

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

Destructor.

Definition at line 51 of file PRMInstance_tpl.h.

References gum::prm::PRMInstance< GUM_SCALAR >::__nodeIdMap, gum::prm::PRMInstance< GUM_SCALAR >::__referenceMap, and gum::prm::PRMInstance< GUM_SCALAR >::__referingAttr.

51  {
52  GUM_DESTRUCTOR(PRMInstance);
53 
54  for (const auto& elt : __nodeIdMap)
55  delete elt.second;
56 
57  for (const auto& elt : __referenceMap)
58  delete elt.second;
59 
60  for (const auto& elt : __referingAttr)
61  delete elt.second;
62  }
PRMInstance(const std::string &name, PRMClass< GUM_SCALAR > &type)
Default constructor of an PRMInstance<GUM_SCALAR>.
NodeProperty< std::vector< pair > * > __referingAttr
The set of pair (instance, attribute) referring an attribute of this instance.
Definition: PRMInstance.h:523
NodeProperty< Set< PRMInstance< GUM_SCALAR > * > * > __referenceMap
Mapping between the gum::prm::PRMReferenceSlot and gum::prm::PRMSlotChain<GUM_SCALAR> in __type / and...
Definition: PRMInstance.h:516
NodeProperty< PRMAttribute< GUM_SCALAR > * > __nodeIdMap
The gum::prm::PRMAttribute<GUM_SCALAR> and gum::prm::PRMAggregate<GUM_SCALAR> of this PRMInstance<GUM...
Definition: PRMInstance.h:511
template<typename GUM_SCALAR >
INLINE gum::prm::PRMInstance< GUM_SCALAR >::PRMInstance ( const PRMInstance< GUM_SCALAR > &  source)
private

Copy constructor.

Definition at line 251 of file PRMInstance_tpl.h.

References GUM_ERROR.

252  :
253  PRMObject(source),
254  __type(source.__type) {
255  GUM_CONS_CPY(PRMInstance);
256  GUM_ERROR(FatalError, "do not copy Instance");
257  }
PRMClass< GUM_SCALAR > * __type
The type of this PRMInstance<GUM_SCALAR>.
Definition: PRMInstance.h:507
PRMInstance(const std::string &name, PRMClass< GUM_SCALAR > &type)
Default constructor of an PRMInstance<GUM_SCALAR>.
PRMObject(const std::string &name)
Constructor.
Definition: PRMObject.cpp:40
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66

Member Function Documentation

template<typename GUM_SCALAR >
INLINE void gum::prm::PRMInstance< GUM_SCALAR >::__addReferingInstance ( PRMSlotChain< GUM_SCALAR > *  sc,
PRMInstance< GUM_SCALAR > *  i 
)
private

Add this as a referring instance over the attribute pointed by sc in i.

Parameters
scA slot chain pointing over an attribute in i.
iAn instance holding an attribute pointed by sc.

Definition at line 330 of file PRMInstance_tpl.h.

References gum::prm::PRMInstance< GUM_SCALAR >::__referenceMap, gum::prm::PRMInstance< GUM_SCALAR >::__referingAttr, gum::prm::PRMInstance< GUM_SCALAR >::get(), gum::prm::PRMSlotChain< GUM_SCALAR >::lastElt(), and gum::prm::PRMObject::name().

Referenced by gum::prm::PRMInstance< GUM_SCALAR >::__instantiateSlotChain().

331  {
332  NodeId id = i->get(sc->lastElt().safeName()).id();
333  std::string name = sc->lastElt().safeName();
334 
335  try {
336  i->__referenceMap[id]->insert(this);
337  i->__referingAttr[id]->push_back(
338  std::make_pair(this, sc->lastElt().safeName()));
339  } catch (NotFound&) {
340  i->__referenceMap.insert(id, new Set< PRMInstance< GUM_SCALAR >* >());
341  i->__referenceMap[id]->insert(this);
342  i->__referingAttr.insert(id, new std::vector< pair >());
343  i->__referingAttr[id]->push_back(
344  std::make_pair(this, sc->lastElt().safeName()));
345  }
346  }
unsigned int NodeId
Type for node ids.
Definition: graphElements.h:97
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename GUM_SCALAR >
INLINE void gum::prm::PRMInstance< GUM_SCALAR >::__copyAggregates ( PRMAggregate< GUM_SCALAR > *  source)
private

Used at construction to instantiate aggregates.

Definition at line 227 of file PRMInstance_tpl.h.

References gum::prm::PRMInstance< GUM_SCALAR >::__bijection, gum::prm::PRMInstance< GUM_SCALAR >::__nodeIdMap, gum::prm::PRMAggregate< GUM_SCALAR >::buildImpl(), gum::prm::PRMClassElement< GUM_SCALAR >::id(), gum::prm::PRMObject::name(), and gum::prm::PRMAggregate< GUM_SCALAR >::type().

Referenced by gum::prm::PRMInstance< GUM_SCALAR >::PRMInstance().

228  {
229  auto attr = new PRMScalarAttribute< GUM_SCALAR >(
230  source->name(), source->type(), source->buildImpl());
231  GUM_ASSERT(&(attr->type().variable()) != &(source->type().variable()));
232  attr->setId(source->id());
233  __nodeIdMap.insert(attr->id(), attr);
234  __bijection.insert(&(source->type().variable()), &(attr->type().variable()));
235  }
Bijection< const DiscreteVariable *, const DiscreteVariable * > __bijection
A bijection used for MultiDim handling.
Definition: PRMInstance.h:526
NodeProperty< PRMAttribute< GUM_SCALAR > * > __nodeIdMap
The gum::prm::PRMAttribute<GUM_SCALAR> and gum::prm::PRMAggregate<GUM_SCALAR> of this PRMInstance<GUM...
Definition: PRMInstance.h:511

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename GUM_SCALAR >
INLINE void gum::prm::PRMInstance< GUM_SCALAR >::__copyAttribute ( PRMAttribute< GUM_SCALAR > *  source)
private

Used at construction to instantiate attributes.

Parameters
sourceAn attribute in __type.

Definition at line 238 of file PRMInstance_tpl.h.

References gum::prm::PRMInstance< GUM_SCALAR >::__bijection, gum::prm::PRMInstance< GUM_SCALAR >::__nodeIdMap, gum::prm::PRMClassElement< GUM_SCALAR >::id(), gum::prm::PRMObject::name(), and gum::prm::PRMAttribute< GUM_SCALAR >::type().

Referenced by gum::prm::PRMInstance< GUM_SCALAR >::PRMInstance().

239  {
240  auto attr =
241  new PRMScalarAttribute< GUM_SCALAR >(source->name(), source->type());
242  GUM_ASSERT(&(attr->type().variable()) != &(source->type().variable()));
243  // The potential is copied when instantiate() is called
244  attr->cpf().fill((GUM_SCALAR)0);
245  attr->setId(source->id());
246  __bijection.insert(&(source->type().variable()), &(attr->type().variable()));
247  __nodeIdMap.insert(attr->id(), attr);
248  }
Bijection< const DiscreteVariable *, const DiscreteVariable * > __bijection
A bijection used for MultiDim handling.
Definition: PRMInstance.h:526
NodeProperty< PRMAttribute< GUM_SCALAR > * > __nodeIdMap
The gum::prm::PRMAttribute<GUM_SCALAR> and gum::prm::PRMAggregate<GUM_SCALAR> of this PRMInstance<GUM...
Definition: PRMInstance.h:511

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename GUM_SCALAR >
INLINE void gum::prm::PRMInstance< GUM_SCALAR >::__copyAttributeCPF ( PRMAttribute< GUM_SCALAR > *  attr)
private

Copy the content of an PRMAttribute<GUM_SCALAR> from its Class<GUM_SCALAR> counterpart.

Parameters
attrAn PRMAttribute<GUM_SCALAR> of this PRMInstance<GUM_SCALAR>.
Exceptions
OperationNotAllowedIf the MultiDimImplementation is of an unknown type.

Definition at line 599 of file PRMInstance_tpl.h.

References gum::prm::PRMInstance< GUM_SCALAR >::bijection(), gum::prm::PRMAttribute< GUM_SCALAR >::copyCpf(), gum::prm::PRMAttribute< GUM_SCALAR >::cpf(), gum::prm::PRMClassElement< GUM_SCALAR >::safeName(), gum::prm::PRMAttribute< GUM_SCALAR >::type(), and gum::prm::PRMInstance< GUM_SCALAR >::type().

Referenced by gum::prm::PRMInstance< GUM_SCALAR >::__doInstantiate().

600  {
601  const auto& type_attr = static_cast< const PRMAttribute< GUM_SCALAR >& >(
602  type().get(attr->safeName()));
603  attr->copyCpf(bijection(), type_attr);
604  GUM_ASSERT(attr->cpf().contains(attr->type().variable()));
605  }
PRMClass< GUM_SCALAR > & type()
Returns the type of this instance.
const Bijection< const DiscreteVariable *, const DiscreteVariable * > & bijection() const
Returns a mapping between DiscreteVariable used in this and the ones used in this PRMInstance<GUM_SCA...

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename GUM_SCALAR >
void gum::prm::PRMInstance< GUM_SCALAR >::__doInstantiate ( )
private

Starts this instance instantiations.

Definition at line 73 of file PRMInstance_tpl.h.

References gum::prm::PRMInstance< GUM_SCALAR >::__copyAttributeCPF(), gum::prm::PRMInstance< GUM_SCALAR >::__instantiateSlotChain(), gum::prm::PRMInstance< GUM_SCALAR >::__nodeIdMap, gum::prm::PRMAttribute< GUM_SCALAR >::addParent(), gum::prm::PRMInstance< GUM_SCALAR >::getInstances(), and gum::prm::PRMInstance< GUM_SCALAR >::type().

Referenced by gum::prm::PRMInstance< GUM_SCALAR >::instantiate().

73  {
74  // First retrieving any referenced instance
75  for (const auto chain : type().slotChains()) {
77  }
78 
79  // Now we need to add referred instance to each input node
80  // For Attributes we first add parents, then we initialize CPF
81  for (const auto attr : type().attributes()) {
82  __copyAttributeCPF(__nodeIdMap[(*attr).id()]);
83  }
84 
85  // For PRMAggregate<GUM_SCALAR> we add parents
86  for (const auto agg : type().aggregates()) {
87  PRMAttribute< GUM_SCALAR >& attr = get(agg->safeName());
88 
89  for (const auto node : type().containerDag().parents(agg->id())) {
90  try {
91  attr.addParent(get(node));
92  } catch (NotFound&) {
93  auto elt = &(type().get(node));
94  auto sc = static_cast< PRMSlotChain< GUM_SCALAR >* >(elt);
95  const auto& instances = getInstances(sc->id());
96 
97  for (const auto inst : instances) {
98  attr.addParent(inst->get(sc->lastElt().safeName()));
99  }
100  }
101  }
102  }
103  }
const Set< PRMInstance< GUM_SCALAR > * > & getInstances(NodeId id) const
Returns the Set of PRMInstance<GUM_SCALAR> referenced by id.
PRMClass< GUM_SCALAR > & type()
Returns the type of this instance.
void __copyAttributeCPF(PRMAttribute< GUM_SCALAR > *attr)
Copy the content of an PRMAttribute<GUM_SCALAR> from its Class<GUM_SCALAR> counterpart.
void __instantiateSlotChain(PRMSlotChain< GUM_SCALAR > *sc)
Retrieve all instances referred by sc.
NodeProperty< PRMAttribute< GUM_SCALAR > * > __nodeIdMap
The gum::prm::PRMAttribute<GUM_SCALAR> and gum::prm::PRMAggregate<GUM_SCALAR> of this PRMInstance<GUM...
Definition: PRMInstance.h:511

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename GUM_SCALAR >
void gum::prm::PRMInstance< GUM_SCALAR >::__instantiateSlotChain ( PRMSlotChain< GUM_SCALAR > *  sc)
private

Retrieve all instances referred by sc.

Parameters
scA slot chain of this instance's type.
Exceptions
NotFoundRaised if a reference in sc is not instantiated.

Definition at line 106 of file PRMInstance_tpl.h.

References gum::prm::PRMInstance< GUM_SCALAR >::__addReferingInstance(), gum::prm::PRMInstance< GUM_SCALAR >::__bijection, gum::prm::PRMInstance< GUM_SCALAR >::__referenceMap, gum::prm::PRMSlotChain< GUM_SCALAR >::chain(), gum::prm::PRMClassElement< GUM_SCALAR >::id(), gum::Set< Key, Alloc >::insert(), gum::prm::PRMSlotChain< GUM_SCALAR >::isMultiple(), gum::prm::PRMSlotChain< GUM_SCALAR >::lastElt(), and gum::prm::PRMSlotChain< GUM_SCALAR >::type().

Referenced by gum::prm::PRMInstance< GUM_SCALAR >::__doInstantiate().

107  {
108  auto first_id = sc->chain()[0]->id();
109  auto set =
110  new Set< PRMInstance< GUM_SCALAR >* >(*(__referenceMap[first_id]));
111  // We proceed with a width-first run of the slot chain
112  for (Size idx = 1; idx < sc->chain().size() - 1; ++idx) {
113  auto temp = new Set< PRMInstance< GUM_SCALAR >* >();
114  for (auto current : *set) {
115  auto& ref = current->type().get(sc->chain()[idx]->name());
116  for (auto next : *(current->__referenceMap[ref.id()])) {
117  temp->insert(next);
118  }
119  }
120  delete set;
121  set = temp;
122  }
123  GUM_ASSERT(set->size() > 0);
124  // set contains all the instances references by sc
125  if (__referenceMap.exists(sc->id())) {
126  delete __referenceMap[sc->id()];
127  __referenceMap[sc->id()] = set;
128  } else {
129  __referenceMap.insert(sc->id(), set);
130  }
131 
132  // Add refering instances
133  for (auto i : *set) {
134  __addReferingInstance(sc, i);
135  }
136 
137  // If sc is not multiple so it can be added as a parent of an attribute
138  if (!sc->isMultiple()) {
139  // We should have only one instance
140  // Less ugly way to get the single instance in set
141  for (auto instance : *set) {
142  auto& attr = instance->get(sc->lastElt().safeName());
143  __bijection.insert(&(sc->type().variable()), &(attr.type().variable()));
144  }
145  }
146  }
unsigned long Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:50
void __addReferingInstance(PRMSlotChain< GUM_SCALAR > *sc, PRMInstance< GUM_SCALAR > *i)
Add this as a referring instance over the attribute pointed by sc in i.
Bijection< const DiscreteVariable *, const DiscreteVariable * > __bijection
A bijection used for MultiDim handling.
Definition: PRMInstance.h:526
NodeProperty< Set< PRMInstance< GUM_SCALAR > * > * > __referenceMap
Mapping between the gum::prm::PRMReferenceSlot and gum::prm::PRMSlotChain<GUM_SCALAR> in __type / and...
Definition: PRMInstance.h:516

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename GUM_SCALAR >
void gum::prm::PRMInstance< GUM_SCALAR >::add ( NodeId  id,
PRMInstance< GUM_SCALAR > &  instance 
)

Add an PRMInstance<GUM_SCALAR> to a given PRMReferenceSlot, PRMSlotChain<GUM_SCALAR> or output node.

Three type of nodes can be associated with an PRMInstance<GUM_SCALAR>. When an PRMInstance<GUM_SCALAR> is associated with a PRMReferenceSlot, it represents an arc in the relational skeleton. For a PRMSlotChain<GUM_SCALAR>, it is a placeholder of referenced PRMClassElement by this PRMInstance<GUM_SCALAR>. Finally, for an output node it indicates that an PRMInstance<GUM_SCALAR> has an PRMClassElement referring it.

Parameters
idThe NodeId of a PRMReferenceSlot of this PRMInstance<GUM_SCALAR>.
instanceThe instance added as references by id in this PRMInstance<GUM_SCALAR>.
Exceptions
WrongClassElementRaised if id is not a valid PRMClassElement.
OutOfUpperBoundRaised if no more PRMInstance<GUM_SCALAR> can be added to id.
TypeErrorRaised if instance's type isn't compatible with the reference's type.
NotFoundIf there is no PRMClassElement given id.

Definition at line 149 of file PRMInstance_tpl.h.

References gum::prm::PRMInstance< GUM_SCALAR >::__referenceMap, gum::prm::PRMClassElement< GUM_SCALAR >::elt_type(), gum::prm::PRMSlotChain< GUM_SCALAR >::end(), GUM_ERROR, gum::prm::PRMInstance< GUM_SCALAR >::size(), gum::prm::PRMReferenceSlot< GUM_SCALAR >::slotType(), and gum::prm::PRMInstance< GUM_SCALAR >::type().

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

150  {
151  PRMClassElement< GUM_SCALAR >* elt = 0;
152 
153  try {
154  elt = &(type().get(id));
155  } catch (NotFound&) {
156  GUM_ERROR(NotFound, "no ClassElement<GUM_SCALAR> matches the given id");
157  }
158 
159  switch (elt->elt_type()) {
161  PRMReferenceSlot< GUM_SCALAR >* ref =
162  static_cast< PRMReferenceSlot< GUM_SCALAR >* >(elt);
163 
164  // Checking if instance's type is legal
165  if (!instance.type().isSubTypeOf(ref->slotType())) {
166  GUM_ERROR(TypeError,
167  "given Instance type is not a proper "
168  "subclass of the ReferenceSlot<GUM_SCALAR> slot type");
169  }
170 
171  // Checking the reference's size limit
172  if (__referenceMap.exists(id)
173  && (!static_cast< PRMReferenceSlot< GUM_SCALAR >& >(type().get(id))
174  .isArray())
175  && (__referenceMap[id]->size() == 1)) {
176  GUM_ERROR(OutOfUpperBound,
177  "ReferenceSlot<GUM_SCALAR> size limit reached");
178  }
179 
180  break;
181  }
182 
184  PRMSlotChain< GUM_SCALAR >& sc =
185  static_cast< PRMSlotChain< GUM_SCALAR >& >(type().get(id));
186 
187  // Checking if instance's type is legal
188  if (!instance.type().isSubTypeOf(sc.end())) {
189  GUM_ERROR(TypeError,
190  "given Instance type is not a proper "
191  "subclass of the ClassElementContainer pointed"
192  " by the SlotChain<GUM_SCALAR>");
193  }
194 
195  // Checking the reference's size limit
196  if (__referenceMap.exists(id)
197  && (!static_cast< PRMSlotChain< GUM_SCALAR >& >(type().get(id))
198  .isMultiple())
199  && (__referenceMap[id]->size() == 1)) {
200  GUM_ERROR(OutOfUpperBound, "SlotChain<GUM_SCALAR> size limit reached");
201  }
202 
203  break;
204  }
205 
206  default: {
207  if (!type().isOutputNode(*elt)) {
208  GUM_ERROR(WrongClassElement,
209  "given ClassElement<GUM_SCALAR> is not an output node");
210  }
211  }
212  }
213 
214  if (!__referenceMap.exists(id)) {
215  __referenceMap.insert(id, new Set< PRMInstance< GUM_SCALAR >* >());
216  }
217 
218  __referenceMap[id]->insert(&instance);
219  }
Size size() const
Returns the number of attributes in this PRMInstance<GUM_SCALAR>.
PRMClass< GUM_SCALAR > & type()
Returns the type of this instance.
NodeProperty< Set< PRMInstance< GUM_SCALAR > * > * > __referenceMap
Mapping between the gum::prm::PRMReferenceSlot and gum::prm::PRMSlotChain<GUM_SCALAR> in __type / and...
Definition: PRMInstance.h:516
#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 PRMInstance< GUM_SCALAR >::iterator gum::prm::PRMInstance< GUM_SCALAR >::begin ( )

Returns an iterator at the begining of the list of gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.

Definition at line 385 of file PRMInstance_tpl.h.

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

Referenced by gum::prm::SVE< GUM_SCALAR >::__eliminateNodes(), gum::prm::StructuredInference< GUM_SCALAR >::__reduceAloneInstances(), and gum::prm::StructuredInference< GUM_SCALAR >::searchPatterns().

385  {
386  return __nodeIdMap.begin();
387  }
NodeProperty< PRMAttribute< GUM_SCALAR > * > __nodeIdMap
The gum::prm::PRMAttribute<GUM_SCALAR> and gum::prm::PRMAggregate<GUM_SCALAR> of this PRMInstance<GUM...
Definition: PRMInstance.h:511

+ Here is the caller graph for this function:

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

Returns an iterator at the beginning of the list of gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.

Definition at line 397 of file PRMInstance_tpl.h.

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

397  {
398  return __nodeIdMap.begin();
399  }
NodeProperty< PRMAttribute< GUM_SCALAR > * > __nodeIdMap
The gum::prm::PRMAttribute<GUM_SCALAR> and gum::prm::PRMAggregate<GUM_SCALAR> of this PRMInstance<GUM...
Definition: PRMInstance.h:511
template<typename GUM_SCALAR >
INLINE PRMInstance< GUM_SCALAR >::RefIterator gum::prm::PRMInstance< GUM_SCALAR >::begin ( NodeId  id)

Returns an iterator at the beginning of the set of PRMInstance<GUM_SCALAR> associated to a given gum::prm::PRMReferenceSlot or gum::prm::PRMSlotChain<GUM_SCALAR>.

Parameters
idA gum::prm::PRMReferenceSlot or gum::prm::PRMSlotChain<GUM_SCALAR> in this PRMInstance<GUM_SCALAR> type.
Exceptions
NotFoundRaised if no gum::prm::PRMClassElement in this PRMInstance<GUM_SCALAR> type matches id.
WrongClassElementRaised if id is neither a PRMReferenceSlot or PRMSlotChain<GUM_SCALAR>.

Definition at line 409 of file PRMInstance_tpl.h.

References gum::prm::PRMInstance< GUM_SCALAR >::__referenceMap, and GUM_ERROR.

409  {
410  try {
411  return PRMInstance< GUM_SCALAR >::RefIterator(*(__referenceMap[id]));
412  } catch (NotFound&) {
413  GUM_ERROR(NotFound, "no referred instances from this NodeId");
414  }
415  }
NodeProperty< Set< PRMInstance< GUM_SCALAR > * > * > __referenceMap
Mapping between the gum::prm::PRMReferenceSlot and gum::prm::PRMSlotChain<GUM_SCALAR> in __type / and...
Definition: PRMInstance.h:516
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66
template<typename GUM_SCALAR >
INLINE PRMInstance< GUM_SCALAR >::RefConstIterator gum::prm::PRMInstance< GUM_SCALAR >::begin ( NodeId  id) const

Returns an iterator at the beginning of the set of PRMInstance<GUM_SCALAR> associated to a given gum::prm::PRMReferenceSlot or gum::prm::PRMSlotChain<GUM_SCALAR>.

Parameters
idA gum::prm::PRMReferenceSlot or gum::prm::PRMSlotChain<GUM_SCALAR> in this PRMInstance<GUM_SCALAR> type.
Exceptions
NotFoundRaised if no gum::prm::PRMClassElement in this PRMInstance<GUM_SCALAR> type matches id.
WrongClassElementRaised if id is neither a PRMReferenceSlot or PRMSlotChain<GUM_SCALAR>.

Definition at line 419 of file PRMInstance_tpl.h.

References gum::prm::PRMInstance< GUM_SCALAR >::__referenceMap, and GUM_ERROR.

419  {
420  try {
421  return PRMInstance< GUM_SCALAR >::RefConstIterator(*(__referenceMap[id]));
422  } catch (NotFound&) {
423  GUM_ERROR(NotFound, "no referred instances from this NodeId");
424  }
425  }
NodeProperty< Set< PRMInstance< GUM_SCALAR > * > * > __referenceMap
Mapping between the gum::prm::PRMReferenceSlot and gum::prm::PRMSlotChain<GUM_SCALAR> in __type / and...
Definition: PRMInstance.h:516
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66
template<typename GUM_SCALAR >
INLINE PRMInstance< GUM_SCALAR >::InvRefIterator gum::prm::PRMInstance< GUM_SCALAR >::beginInvRef ( )

Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.

Definition at line 558 of file PRMInstance_tpl.h.

References gum::prm::PRMInstance< GUM_SCALAR >::__referingAttr.

Referenced by gum::prm::SVE< GUM_SCALAR >::__eliminateNodes(), gum::prm::SVE< GUM_SCALAR >::__eliminateNodesDownward(), and gum::prm::SVE< GUM_SCALAR >::__eliminateNodesUpward().

558  {
559  return __referingAttr.begin();
560  }
NodeProperty< std::vector< pair > * > __referingAttr
The set of pair (instance, attribute) referring an attribute of this instance.
Definition: PRMInstance.h:523

+ Here is the caller graph for this function:

template<typename GUM_SCALAR >
INLINE PRMInstance< GUM_SCALAR >::InvRefConstIterator gum::prm::PRMInstance< GUM_SCALAR >::beginInvRef ( ) const

Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.

Definition at line 570 of file PRMInstance_tpl.h.

References gum::prm::PRMInstance< GUM_SCALAR >::__referingAttr.

570  {
571  return __referingAttr.begin();
572  }
NodeProperty< std::vector< pair > * > __referingAttr
The set of pair (instance, attribute) referring an attribute of this instance.
Definition: PRMInstance.h:523
template<typename GUM_SCALAR >
INLINE const Bijection< const DiscreteVariable *, const DiscreteVariable * > & gum::prm::PRMInstance< GUM_SCALAR >::bijection ( ) const

Returns a mapping between DiscreteVariable used in this and the ones used in this PRMInstance<GUM_SCALAR>'s Class<GUM_SCALAR>.

MultiDims require distinctive DiscreteVariable pointers, thus interface attributes are always instantiated to prevent multiple insertion of the same DiscreteVariable pointer in a MultiDim.

Returns
Returns a bijection in which first elements are DiscreteVariable in this->type() and the second are in this.

Definition at line 350 of file PRMInstance_tpl.h.

References gum::prm::PRMInstance< GUM_SCALAR >::__bijection.

Referenced by gum::prm::PRMInstance< GUM_SCALAR >::__copyAttributeCPF(), gum::prm::SVED< GUM_SCALAR >::__insertLiftedNodes(), gum::prm::SVE< GUM_SCALAR >::__insertLiftedNodes(), and gum::prm::StructuredInference< GUM_SCALAR >::__reduceAloneInstances().

350  {
351  return __bijection;
352  }
Bijection< const DiscreteVariable *, const DiscreteVariable * > __bijection
A bijection used for MultiDim handling.
Definition: PRMInstance.h:526

+ Here is the caller graph for this function:

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

Returns a reference over the iterator at the end of the list of gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.

Definition at line 391 of file PRMInstance_tpl.h.

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

Referenced by gum::prm::SVE< GUM_SCALAR >::__eliminateNodes(), and gum::prm::StructuredInference< GUM_SCALAR >::__reduceAloneInstances().

391  {
392  return __nodeIdMap.end();
393  }
NodeProperty< PRMAttribute< GUM_SCALAR > * > __nodeIdMap
The gum::prm::PRMAttribute<GUM_SCALAR> and gum::prm::PRMAggregate<GUM_SCALAR> of this PRMInstance<GUM...
Definition: PRMInstance.h:511

+ Here is the caller graph for this function:

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

Returns a reference over the iterator at the end of the list of gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.

Definition at line 403 of file PRMInstance_tpl.h.

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

403  {
404  return __nodeIdMap.end();
405  }
NodeProperty< PRMAttribute< GUM_SCALAR > * > __nodeIdMap
The gum::prm::PRMAttribute<GUM_SCALAR> and gum::prm::PRMAggregate<GUM_SCALAR> of this PRMInstance<GUM...
Definition: PRMInstance.h:511
template<typename GUM_SCALAR >
INLINE const PRMInstance< GUM_SCALAR >::InvRefIterator & gum::prm::PRMInstance< GUM_SCALAR >::endInvRef ( )

Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.

Definition at line 564 of file PRMInstance_tpl.h.

References gum::prm::PRMInstance< GUM_SCALAR >::__referingAttr.

Referenced by gum::prm::SVE< GUM_SCALAR >::__eliminateNodes(), gum::prm::SVE< GUM_SCALAR >::__eliminateNodesDownward(), and gum::prm::SVE< GUM_SCALAR >::__eliminateNodesUpward().

564  {
565  return __referingAttr.end();
566  }
NodeProperty< std::vector< pair > * > __referingAttr
The set of pair (instance, attribute) referring an attribute of this instance.
Definition: PRMInstance.h:523

+ Here is the caller graph for this function:

template<typename GUM_SCALAR >
INLINE const PRMInstance< GUM_SCALAR >::InvRefConstIterator & gum::prm::PRMInstance< GUM_SCALAR >::endInvRef ( ) const

Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.

Definition at line 576 of file PRMInstance_tpl.h.

References gum::prm::PRMInstance< GUM_SCALAR >::__referingAttr.

576  {
577  return __referingAttr.end();
578  }
NodeProperty< std::vector< pair > * > __referingAttr
The set of pair (instance, attribute) referring an attribute of this instance.
Definition: PRMInstance.h:523
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::PRMInstance< GUM_SCALAR >::exists ( NodeId  id) const

Returns true if id matches an PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.

Definition at line 281 of file PRMInstance_tpl.h.

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

Referenced by gum::prm::PRMInstance< GUM_SCALAR >::exists(), and gum::prm::o3prmr::O3prmrInterpreter::findAttributeName().

281  {
282  return __nodeIdMap.exists(id);
283  }
NodeProperty< PRMAttribute< GUM_SCALAR > * > __nodeIdMap
The gum::prm::PRMAttribute<GUM_SCALAR> and gum::prm::PRMAggregate<GUM_SCALAR> of this PRMInstance<GUM...
Definition: PRMInstance.h:511

+ Here is the caller graph for this function:

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

Returns true if name matches an PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.

Definition at line 286 of file PRMInstance_tpl.h.

References gum::prm::PRMInstance< GUM_SCALAR >::__type, and gum::prm::PRMInstance< GUM_SCALAR >::exists().

286  {
287  return __type->exists(name) && exists(__type->get(name).id());
288  }
PRMClass< GUM_SCALAR > * __type
The type of this PRMInstance<GUM_SCALAR>.
Definition: PRMInstance.h:507
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:32
bool exists(NodeId id) const
Returns true if id matches an PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.

+ Here is the call graph for this function:

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

Getter on an PRMAttribute<GUM_SCALAR> of this PRMInstance<GUM_SCALAR>.

Recall that PRMAggregate<GUM_SCALAR> are instantiated as PRMAttribute<GUM_SCALAR> when an PRMInstance<GUM_SCALAR> is created. Thus any random variable contained in this PRMInstance<GUM_SCALAR> is mapped to an PRMAttribute<GUM_SCALAR>.

Parameters
idThe PRMAttribute<GUM_SCALAR> id.
Returns
Returns a constant reference on an PRMAttribute<GUM_SCALAR>.
Exceptions
NotFoundRaised if no PRMAttribute<GUM_SCALAR> matches name.

Definition at line 291 of file PRMInstance_tpl.h.

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

Referenced by gum::prm::SVE< GUM_SCALAR >::__addDelayedVariable(), gum::prm::PRMInstance< GUM_SCALAR >::__addReferingInstance(), gum::prm::SVED< GUM_SCALAR >::__eliminateNodes(), gum::prm::SVE< GUM_SCALAR >::__eliminateNodesWithEvidence(), gum::prm::SVED< GUM_SCALAR >::__getAggPotential(), gum::prm::SVE< GUM_SCALAR >::__getAggPotential(), gum::prm::PRMSystem< GUM_SCALAR >::__groundAttr(), gum::prm::PRMSystem< GUM_SCALAR >::__groundPotential(), gum::prm::InstanceBayesNet< GUM_SCALAR >::__init(), gum::prm::StructuredInference< GUM_SCALAR >::__insertNodeInElimLists(), gum::prm::StructuredBayesBall< GUM_SCALAR >::__isHardEvidence(), gum::prm::StructuredInference< GUM_SCALAR >::__reduceAloneInstances(), gum::prm::o3prmr::O3prmrInterpreter::checkObserve(), gum::prm::o3prmr::O3prmrInterpreter::checkQuery(), and gum::prm::o3prmr::O3prmrInterpreter::checkUnobserve().

291  {
292  try {
293  return *(__nodeIdMap[id]);
294  } catch (NotFound&) {
295  GUM_ERROR(NotFound, "no PRMAttribute<GUM_SCALAR> with the given NodeId");
296  }
297  }
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66
NodeProperty< PRMAttribute< GUM_SCALAR > * > __nodeIdMap
The gum::prm::PRMAttribute<GUM_SCALAR> and gum::prm::PRMAggregate<GUM_SCALAR> of this PRMInstance<GUM...
Definition: PRMInstance.h:511

+ Here is the caller graph for this function:

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

Given a name returns the related PRMAttribute<GUM_SCALAR>.

Parameters
nameThe PRMAttribute<GUM_SCALAR>'s name.
Returns
Returns a reference over the PRMAttribute<GUM_SCALAR>.
Exceptions
NotFoundRaised if there is no PRMAttribute<GUM_SCALAR> named n.

Definition at line 311 of file PRMInstance_tpl.h.

References gum::prm::PRMInstance< GUM_SCALAR >::__nodeIdMap, GUM_ERROR, and gum::prm::PRMInstance< GUM_SCALAR >::type().

311  {
312  try {
313  return *(__nodeIdMap[type().get(name).id()]);
314  } catch (NotFound&) {
315  GUM_ERROR(NotFound, "no PRMAttribute<GUM_SCALAR> with the given name");
316  }
317  }
PRMClass< GUM_SCALAR > & type()
Returns the type of this instance.
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
NodeProperty< PRMAttribute< GUM_SCALAR > * > __nodeIdMap
The gum::prm::PRMAttribute<GUM_SCALAR> and gum::prm::PRMAggregate<GUM_SCALAR> of this PRMInstance<GUM...
Definition: PRMInstance.h:511

+ Here is the call graph for this function:

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

Getter on an PRMAttribute<GUM_SCALAR> of this PRMInstance<GUM_SCALAR>.

Recall that PRMAggregate<GUM_SCALAR> are instantiated has PRMAttribute<GUM_SCALAR> when an PRMInstance<GUM_SCALAR> is created. Thus any random variable contained in this PRMInstance<GUM_SCALAR> is mapped to an PRMAttribute<GUM_SCALAR>.

Parameters
idThe PRMAttribute<GUM_SCALAR> id.
Returns
Returns a constant reference on an PRMAttribute<GUM_SCALAR>.
Exceptions
NotFoundRaised if no PRMAttribute<GUM_SCALAR> matches name.

Definition at line 301 of file PRMInstance_tpl.h.

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

301  {
302  try {
303  return *(__nodeIdMap[id]);
304  } catch (NotFound&) {
305  GUM_ERROR(NotFound, "no PRMAttribute<GUM_SCALAR> with the given NodeId");
306  }
307  }
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66
NodeProperty< PRMAttribute< GUM_SCALAR > * > __nodeIdMap
The gum::prm::PRMAttribute<GUM_SCALAR> and gum::prm::PRMAggregate<GUM_SCALAR> of this PRMInstance<GUM...
Definition: PRMInstance.h:511
template<typename GUM_SCALAR >
INLINE const PRMAttribute< GUM_SCALAR > & gum::prm::PRMInstance< GUM_SCALAR >::get ( const std::string &  name) const

Given a name returns the related PRMClassElement.

Parameters
nameThe PRMClassElement's name.
Returns
Returns a constant reference over the PRMClassElement.
Exceptions
NotFoundRaised if there is no PRMClassElement named n.

Definition at line 321 of file PRMInstance_tpl.h.

References gum::prm::PRMInstance< GUM_SCALAR >::__nodeIdMap, GUM_ERROR, and gum::prm::PRMInstance< GUM_SCALAR >::type().

321  {
322  try {
323  return *(__nodeIdMap[type().get(name).id()]);
324  } catch (NotFound&) {
325  GUM_ERROR(NotFound, "no PRMAttribute<GUM_SCALAR> with the given name");
326  }
327  }
PRMClass< GUM_SCALAR > & type()
Returns the type of this instance.
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
NodeProperty< PRMAttribute< GUM_SCALAR > * > __nodeIdMap
The gum::prm::PRMAttribute<GUM_SCALAR> and gum::prm::PRMAggregate<GUM_SCALAR> of this PRMInstance<GUM...
Definition: PRMInstance.h:511

+ Here is the call graph for this function:

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

Fast access to the first instance in a PRMReferenceSlot or PRMSlotChain<GUM_SCALAR>.

This is equivalent to **(this->getInstance(id).begin()) and should be use when dealing with non multiple PRMReferenceSlot or PRMSlotChain<GUM_SCALAR>.

Parameters
idThe NodeId of a PRMReferenceSlot or PRMSlotChain<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.
Exceptions
NotFoundRaised if there is no PRMClassElement given id.
UndefinedElementRaised if no PRMInstance<GUM_SCALAR> are referenced by id.

Definition at line 356 of file PRMInstance_tpl.h.

References gum::prm::PRMInstance< GUM_SCALAR >::__referenceMap, GUM_ERROR, and gum::prm::PRMInstance< GUM_SCALAR >::size().

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

356  {
357  try {
358  if (__referenceMap[id]->size() > 0) {
359  return **(__referenceMap[id]->begin());
360  } else {
361  GUM_ERROR(UndefinedElement,
362  "no Instance associated with the given NodeId");
363  }
364  } catch (NotFound&) {
365  GUM_ERROR(NotFound,
366  "no ReferenceSlot<GUM_SCALAR> or SlotChain<GUM_SCALAR> "
367  "matches the given NodeId");
368  }
369  }
Size size() const
Returns the number of attributes in this PRMInstance<GUM_SCALAR>.
NodeProperty< Set< PRMInstance< GUM_SCALAR > * > * > __referenceMap
Mapping between the gum::prm::PRMReferenceSlot and gum::prm::PRMSlotChain<GUM_SCALAR> in __type / and...
Definition: PRMInstance.h:516
#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 const Set< PRMInstance< GUM_SCALAR > * > & gum::prm::PRMInstance< GUM_SCALAR >::getInstances ( NodeId  id) const

Returns the Set of PRMInstance<GUM_SCALAR> referenced by id.

Parameters
idThe NodeId of a PRMReferenceSlot or PRMSlotChain<GUM_SCALAR> in this.
Returns
Returns the Set of PRMInstance<GUM_SCALAR> referenced by id.
Exceptions
NotFoundIf there is no PRMClassElement given id.

Definition at line 373 of file PRMInstance_tpl.h.

References gum::prm::PRMInstance< GUM_SCALAR >::__referenceMap, and GUM_ERROR.

Referenced by gum::prm::PRMInstance< GUM_SCALAR >::__doInstantiate(), gum::prm::SVED< GUM_SCALAR >::__eliminateNodes(), gum::prm::SVE< GUM_SCALAR >::__eliminateNodes(), gum::prm::SVED< GUM_SCALAR >::__eliminateNodesDownward(), gum::prm::SVE< GUM_SCALAR >::__eliminateNodesDownward(), gum::prm::SVED< GUM_SCALAR >::__eliminateNodesUpward(), gum::prm::SVE< GUM_SCALAR >::__eliminateNodesUpward(), and gum::prm::StructuredBayesBall< GUM_SCALAR >::__fromChild().

373  {
374  try {
375  return *(__referenceMap[id]);
376  } catch (NotFound&) {
377  GUM_ERROR(NotFound,
378  "no ReferenceSlot<GUM_SCALAR> or SlotChain<GUM_SCALAR> "
379  "matches the given NodeId");
380  }
381  }
NodeProperty< Set< PRMInstance< GUM_SCALAR > * > * > __referenceMap
Mapping between the gum::prm::PRMReferenceSlot and gum::prm::PRMSlotChain<GUM_SCALAR> in __type / and...
Definition: PRMInstance.h:516
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66

+ Here is the caller graph for this function:

template<typename GUM_SCALAR >
INLINE std::vector< std::pair< PRMInstance< GUM_SCALAR > *, std::string > > & gum::prm::PRMInstance< GUM_SCALAR >::getRefAttr ( NodeId  id)

Returns a vector of pairs of refering attributes of id.

Definition at line 582 of file PRMInstance_tpl.h.

References gum::prm::PRMInstance< GUM_SCALAR >::__referingAttr.

Referenced by gum::prm::SVED< GUM_SCALAR >::__eliminateNodes(), gum::prm::SVED< GUM_SCALAR >::__eliminateNodesDownward(), gum::prm::SVED< GUM_SCALAR >::__eliminateNodesUpward(), gum::prm::StructuredBayesBall< GUM_SCALAR >::__fromChild(), gum::prm::StructuredBayesBall< GUM_SCALAR >::__fromParent(), and gum::prm::StructuredInference< GUM_SCALAR >::__insertNodeInElimLists().

582  {
583  return *(__referingAttr[id]);
584  }
NodeProperty< std::vector< pair > * > __referingAttr
The set of pair (instance, attribute) referring an attribute of this instance.
Definition: PRMInstance.h:523

+ Here is the caller graph for this function:

template<typename GUM_SCALAR >
INLINE const std::vector< std::pair< PRMInstance< GUM_SCALAR > *, std::string > > & gum::prm::PRMInstance< GUM_SCALAR >::getRefAttr ( NodeId  id) const

Returns a vector of pairs of refering attributes of id.

Definition at line 589 of file PRMInstance_tpl.h.

References gum::prm::PRMInstance< GUM_SCALAR >::__referingAttr.

589  {
590  return *(__referingAttr[id]);
591  }
NodeProperty< std::vector< pair > * > __referingAttr
The set of pair (instance, attribute) referring an attribute of this instance.
Definition: PRMInstance.h:523
template<typename GUM_SCALAR >
INLINE bool gum::prm::PRMInstance< GUM_SCALAR >::hasRefAttr ( NodeId  id) const

Returns true if id has at least one referring PRMAttribute<GUM_SCALAR>.

Parameters
idA NodeId.
Returns
returns true if is has at least one referring PRMAttribute<GUM_SCALAR>.

Definition at line 594 of file PRMInstance_tpl.h.

References gum::prm::PRMInstance< GUM_SCALAR >::__referingAttr.

594  {
595  return __referingAttr.exists(id) && (!__referingAttr[id]->empty());
596  }
NodeProperty< std::vector< pair > * > __referingAttr
The set of pair (instance, attribute) referring an attribute of this instance.
Definition: PRMInstance.h:523
template<typename GUM_SCALAR >
void gum::prm::PRMInstance< GUM_SCALAR >::instantiate ( )

Instantiate all nodes which requires it.

All attributes are now instantiated, which means they have a different DiscreteVariable pointer. This methods however still connects attributes of different instance together.

Warning
Be aware that this method will delete a large part of this instance attribute's CPF. Furthermore, the instantiated attribute's type will change (but will not be deleted).

Definition at line 65 of file PRMInstance_tpl.h.

References gum::prm::PRMInstance< GUM_SCALAR >::__doInstantiate(), and gum::prm::PRMInstance< GUM_SCALAR >::__instantiated.

65  {
66  if (!__instantiated) {
67  __instantiated = true;
69  }
70  }
void __doInstantiate()
Starts this instance instantiations.
bool __instantiated
True if this instance has been instantiated.
Definition: PRMInstance.h:504

+ Here is the call 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:

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::PRMInstance< GUM_SCALAR >::obj_type ( ) const
virtual

Returns the PRM type of this object.

Implements gum::prm::PRMObject.

Definition at line 266 of file PRMInstance_tpl.h.

References gum::prm::PRMObject::INSTANCE.

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 >
INLINE PRMInstance< GUM_SCALAR > & gum::prm::PRMInstance< GUM_SCALAR >::operator= ( const PRMClass< GUM_SCALAR > &  from)
private

Copy operator. Don't use it.

Definition at line 261 of file PRMInstance_tpl.h.

References GUM_ERROR.

261  {
262  GUM_ERROR(FatalError, "do not copy Instance");
263  }
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66
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::PRMInstance< GUM_SCALAR >::size ( ) const

Returns the number of attributes in this PRMInstance<GUM_SCALAR>.

Returns
the number of attributes in this PRMInstance<GUM_SCALAR>.

Definition at line 222 of file PRMInstance_tpl.h.

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

Referenced by gum::prm::StructuredInference< GUM_SCALAR >::__reduceAloneInstances(), gum::prm::PRMInstance< GUM_SCALAR >::add(), and gum::prm::PRMInstance< GUM_SCALAR >::getInstance().

222  {
223  return __nodeIdMap.size();
224  }
NodeProperty< PRMAttribute< GUM_SCALAR > * > __nodeIdMap
The gum::prm::PRMAttribute<GUM_SCALAR> and gum::prm::PRMAggregate<GUM_SCALAR> of this PRMInstance<GUM...
Definition: PRMInstance.h:511

+ Here is the caller graph for this function:

template<typename GUM_SCALAR >
INLINE PRMClass< GUM_SCALAR > & gum::prm::PRMInstance< GUM_SCALAR >::type ( )

Returns the type of this instance.

Definition at line 271 of file PRMInstance_tpl.h.

References gum::prm::PRMInstance< GUM_SCALAR >::__type.

Referenced by gum::prm::StructuredBayesBall< GUM_SCALAR >::__buildHashKey(), gum::prm::SVED< GUM_SCALAR >::__checkElimOrder(), gum::prm::SVE< GUM_SCALAR >::__checkElimOrder(), gum::prm::PRMInstance< GUM_SCALAR >::__copyAttributeCPF(), gum::prm::PRMInstance< GUM_SCALAR >::__doInstantiate(), gum::prm::SVE< GUM_SCALAR >::__eliminateNodes(), gum::prm::SVED< GUM_SCALAR >::__eliminateNodesDownward(), gum::prm::SVE< GUM_SCALAR >::__eliminateNodesDownward(), gum::prm::SVED< GUM_SCALAR >::__eliminateNodesUpward(), gum::prm::SVE< GUM_SCALAR >::__eliminateNodesUpward(), gum::prm::SVE< GUM_SCALAR >::__eliminateNodesWithEvidence(), gum::prm::StructuredBayesBall< GUM_SCALAR >::__fromChild(), gum::prm::StructuredBayesBall< GUM_SCALAR >::__fromParent(), gum::prm::StructuredBayesBall< GUM_SCALAR >::__getSC(), gum::prm::PRMSystem< GUM_SCALAR >::__groundAttr(), gum::prm::PRMSystem< GUM_SCALAR >::__groundPotential(), gum::prm::InstanceBayesNet< GUM_SCALAR >::__init(), gum::prm::SVED< GUM_SCALAR >::__initLiftedNodes(), gum::prm::SVED< GUM_SCALAR >::__initReqSets(), gum::prm::SVE< GUM_SCALAR >::__insertLiftedNodes(), gum::prm::StructuredInference< GUM_SCALAR >::__insertNodeInElimLists(), gum::prm::__print_attribute__(), gum::prm::StructuredInference< GUM_SCALAR >::__reduceAloneInstances(), gum::prm::SVE< GUM_SCALAR >::__variableElimination(), gum::prm::PRMSystem< GUM_SCALAR >::add(), gum::prm::PRMInstance< GUM_SCALAR >::add(), and gum::prm::PRMInstance< GUM_SCALAR >::get().

271  {
272  return *__type;
273  }
PRMClass< GUM_SCALAR > * __type
The type of this PRMInstance<GUM_SCALAR>.
Definition: PRMInstance.h:507

+ Here is the caller graph for this function:

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

Returns the type of this instance.

Definition at line 276 of file PRMInstance_tpl.h.

References gum::prm::PRMInstance< GUM_SCALAR >::__type.

276  {
277  return *__type;
278  }
PRMClass< GUM_SCALAR > * __type
The type of this PRMInstance<GUM_SCALAR>.
Definition: PRMInstance.h:507

Member Data Documentation

template<typename GUM_SCALAR>
bool gum::prm::PRMInstance< GUM_SCALAR >::__instantiated
private

True if this instance has been instantiated.

Definition at line 504 of file PRMInstance.h.

Referenced by gum::prm::PRMInstance< GUM_SCALAR >::instantiate().

template<typename GUM_SCALAR>
PRMClass< GUM_SCALAR >* gum::prm::PRMInstance< GUM_SCALAR >::__type
private

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