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

Classes

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

Public Member Functions

Constructors & private operators.
 PRMInstance (const std::string &name, PRMClass< GUM_SCALAR > &type)
 Default constructor of an PRMInstance<GUM_SCALAR>.
virtual ~PRMInstance ()
 Destructor.
Getters & setters.
virtual prm_type obj_type () const
 Returns the PRM type of this object.
PRMClass< GUM_SCALAR > & type ()
 Returns the type of this instance.
const PRMClass< GUM_SCALAR > & type () const
 Returns the type of this instance.
bool exists (NodeId id) const
 Returns true if id matches an PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.
bool exists (const std::string &name) const
 Returns true if name matches an PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.
PRMAttribute< GUM_SCALAR > & get (NodeId id)
 Getter on an PRMAttribute<GUM_SCALAR> of this PRMInstance<GUM_SCALAR>.
PRMAttribute< GUM_SCALAR > & get (const std::string &name)
 Given a name returns the related PRMAttribute<GUM_SCALAR>.
const PRMAttribute< GUM_SCALAR > & get (NodeId id) const
 Getter on an PRMAttribute<GUM_SCALAR> of this PRMInstance<GUM_SCALAR>.
const PRMAttribute< GUM_SCALAR > & get (const std::string &name) const
 Given a name returns the related PRMClassElement.
Size size () const
 Returns the number of attributes in this PRMInstance<GUM_SCALAR>.
Instantiation methods.
void instantiate ()
 Instantiate all nodes which requires it.
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>.
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.
const PRMInstance< GUM_SCALAR > & getInstance (NodeId id) const
 Fast access to the first instance in a PRMReferenceSlot or PRMSlotChain<GUM_SCALAR>.
const Set< PRMInstance< GUM_SCALAR > * > & getInstances (NodeId id) const
 Returns the Set of PRMInstance<GUM_SCALAR> referenced by id.
bool hasRefAttr (NodeId id) const
 Returns true if id has at least one referring PRMAttribute<GUM_SCALAR>.
std::vector< std::pair< PRMInstance< GUM_SCALAR > *, std::string > > & getRefAttr (NodeId id)
 Returns a vector of pairs of refering attributes of id.
const std::vector< std::pair< PRMInstance< GUM_SCALAR > *, std::string > > & getRefAttr (NodeId id) const
 Returns a vector of pairs of refering attributes of id.
Getters & setters.
const std::string & name () const
 Returns the name of this object.
void name (const std::string &name)
 Change the name of the PRM Object.
Operators
bool operator== (const PRMObject &obj) const
 To PRMObject are equal if they have the same name (which is unique).
bool operator!= (const PRMObject &obj) const
 To PRMObject are equal if they have the same name (which is unique).

Private Member Functions

 PRMInstance (const PRMInstance< GUM_SCALAR > &source)
 Copy constructor.
PRMInstance< GUM_SCALAR > & operator= (const PRMClass< GUM_SCALAR > &from)
 Copy operator. Don't use it.
Private instantiation methods.
void _copyAggregates_ (PRMAggregate< GUM_SCALAR > *source)
 Used at construction to instantiate aggregates.
void _copyAttribute_ (PRMAttribute< GUM_SCALAR > *source)
 Used at construction to instantiate attributes.
void _doInstantiate_ ()
 Starts this instance instantiations.
void _instantiateSlotChain_ (PRMSlotChain< GUM_SCALAR > *sc)
 Retrieve all instances referred by sc.
void _copyAttributeCPF_ (PRMAttribute< GUM_SCALAR > *attr)
 Copy the content of an PRMAttribute<GUM_SCALAR> from its Class<GUM_SCALAR> counterpart.
void _addReferingInstance_ (PRMSlotChain< GUM_SCALAR > *sc, PRMInstance< GUM_SCALAR > *i)
 Add this as a referring instance over the attribute pointed by sc in i.

Private Attributes

Private members.
std::string _name_

Iterators

using iterator = typename NodeProperty< PRMAttribute< GUM_SCALAR >* >::iterator
 Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.
using const_iterator = typename NodeProperty< PRMAttribute< GUM_SCALAR >* >::const_iterator
 Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.
using InvRefIterator
 Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.
using InvRefConstIterator
 Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.
iterator begin ()
 Returns an iterator at the begining of the list of gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.
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>.
const_iterator begin () const
 Returns an iterator at the beginning of the list of gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.
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>.
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>.
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>.
InvRefIterator beginInvRef ()
 Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.
const InvRefIteratorendInvRef ()
 Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.
InvRefConstIterator beginInvRef () const
 Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.
const InvRefConstIteratorendInvRef () const
 Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.

Built-in types.

enum class  prm_type : char {
  ALL , CLASS , PRM_INTERFACE , CLASS_ELT ,
  TYPE , SYSTEM , 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.
static std::string RIGHT_CAST ()
 Enumeration of the different types of objects handled by a PRM.
static std::string enum2str (prm_type type)
 Returns the string representation of a PRMObject.
static INLINE bool isClass (const PRMObject &obj)
 Returns true if obj_ptr is of type Class.
static INLINE bool isInterface (const PRMObject &obj)
 Returns true if obj_ptr is of type PRMInterface.
static INLINE bool isInstance (const PRMObject &obj)
 Returns true if obj_ptr is of type PRMInstance.

Private members.

using pair = std::pair< PRMInstance< GUM_SCALAR >*, std::string >
 Code alias.
bool _instantiated_
 True if this instance has been instantiated.
PRMClass< GUM_SCALAR > * _type_
 The type of this PRMInstance<GUM_SCALAR>.
NodeProperty< PRMAttribute< GUM_SCALAR > * > _nodeIdMap_
 The gum::prm::PRMAttribute<GUM_SCALAR> and gum::prm::PRMAggregate<GUM_SCALAR> of 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 the PRMInstance<GUM_SCALAR> associated with it.
NodeProperty< std::vector< pair > * > _referingAttr_
 The set of pair (instance, attribute) referring an attribute of this instance.
Bijection< const DiscreteVariable *, const DiscreteVariable * > _bijection_
 A bijection used for MultiDim handling.

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

Member Typedef Documentation

◆ const_iterator

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

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

Definition at line 340 of file PRMInstance.h.

◆ InvRefConstIterator

template<typename GUM_SCALAR>
using gum::prm::PRMInstance< GUM_SCALAR >::InvRefConstIterator
Initial value:
typename NodeProperty<
std::vector< std::pair< PRMInstance< GUM_SCALAR >*, std::string > >* >::const_iterator
typename NodeProperty< PRMAttribute< GUM_SCALAR > * >::const_iterator const_iterator
Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.
HashTable< NodeId, VAL > NodeProperty
Property on graph elements.

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

Definition at line 455 of file PRMInstance.h.

◆ InvRefIterator

template<typename GUM_SCALAR>
using gum::prm::PRMInstance< GUM_SCALAR >::InvRefIterator
Initial value:
typename NodeProperty<
std::vector< std::pair< PRMInstance< GUM_SCALAR >*, std::string > >* >::iterator
typename NodeProperty< PRMAttribute< GUM_SCALAR > * >::iterator iterator
Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.

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

Definition at line 453 of file PRMInstance.h.

◆ iterator

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

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

Definition at line 327 of file PRMInstance.h.

◆ pair

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

Code alias.

Definition at line 531 of file PRMInstance.h.

Member Enumeration Documentation

◆ prm_type

enum class 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 88 of file PRMObject.h.

88: char { ALL, CLASS, PRM_INTERFACE, CLASS_ELT, TYPE, SYSTEM, INSTANCE };

Constructor & Destructor Documentation

◆ PRMInstance() [1/2]

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 56 of file PRMInstance_tpl.h.

56 :
59
60 // First we create attributes for each aggregate in type
61 for (const auto agg: _type_->aggregates())
63
64 // We add attributes in type by reference for inner ones and by copy for
65 // output ones
66 for (const auto attr: _type_->attributes())
68 }
An PRMInstance is a Bayesian network fragment defined by a Class and used in a PRMSystem.
Definition PRMInstance.h:79
bool _instantiated_
True if this instance has been instantiated.
PRMClass< GUM_SCALAR > & type()
Returns the type of this instance.
PRMClass< GUM_SCALAR > * _type_
The type of this PRMInstance<GUM_SCALAR>.
void _copyAttribute_(PRMAttribute< GUM_SCALAR > *source)
Used at construction to instantiate attributes.
PRMInstance(const std::string &name, PRMClass< GUM_SCALAR > &type)
Default constructor of an PRMInstance<GUM_SCALAR>.
void _copyAggregates_(PRMAggregate< GUM_SCALAR > *source)
Used at construction to instantiate aggregates.
const std::string & name() const
Returns the name of this object.
PRMObject(const std::string &name)
Constructor.
Definition PRMObject.cpp:62

References PRMInstance(), gum::prm::PRMObject::PRMObject(), _copyAggregates_(), _copyAttribute_(), _instantiated_, _type_, gum::prm::PRMObject::name(), and type().

Referenced by PRMInstance(), gum::prm::PRMInstance< GUM_SCALAR >::RefIterator::RefIterator(), gum::prm::PRMInstance< GUM_SCALAR >::RefIterator::RefIterator(), ~PRMInstance(), _addReferingInstance_(), add(), gum::prm::PRMInstance< GUM_SCALAR >::RefIterator::operator*(), and gum::prm::PRMInstance< GUM_SCALAR >::RefIterator::operator->().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~PRMInstance()

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

Destructor.

Definition at line 71 of file PRMInstance_tpl.h.

71 {
73
74 for (const auto& elt: _nodeIdMap_)
75 delete elt.second;
76
77 for (const auto& elt: _referenceMap_)
78 delete elt.second;
79
80 for (const auto& elt: _referingAttr_)
81 delete elt.second;
82 }
NodeProperty< PRMAttribute< GUM_SCALAR > * > _nodeIdMap_
The gum::prm::PRMAttribute<GUM_SCALAR> and gum::prm::PRMAggregate<GUM_SCALAR> of this PRMInstance<GUM...
NodeProperty< Set< PRMInstance< GUM_SCALAR > * > * > _referenceMap_
Mapping between the gum::prm::PRMReferenceSlot and gum::prm::PRMSlotChain<GUM_SCALAR> in type / and t...
NodeProperty< std::vector< pair > * > _referingAttr_
The set of pair (instance, attribute) referring an attribute of this instance.

References PRMInstance(), _nodeIdMap_, _referenceMap_, and _referingAttr_.

Here is the call graph for this function:

◆ PRMInstance() [2/2]

template<typename GUM_SCALAR>
INLINE gum::prm::PRMInstance< GUM_SCALAR >::PRMInstance ( const PRMInstance< GUM_SCALAR > & source)
private

Copy constructor.

Definition at line 267 of file PRMInstance_tpl.h.

267 :
270 GUM_ERROR(FatalError, "do not copy Instance")
271 }
#define GUM_ERROR(type, msg)
Definition exceptions.h:72

Member Function Documentation

◆ _addReferingInstance_()

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 342 of file PRMInstance_tpl.h.

343 {
344 NodeId id = i->get(sc->lastElt().safeName()).id();
345 std::string name = sc->lastElt().safeName();
346
347 try {
348 i->_referenceMap_[id]->insert(this);
349 i->_referingAttr_[id]->push_back(std::make_pair(this, sc->lastElt().safeName()));
350 } catch (NotFound const&) {
351 i->_referenceMap_.insert(id, new Set< PRMInstance< GUM_SCALAR >* >());
352 i->_referenceMap_[id]->insert(this);
353 i->_referingAttr_.insert(id, new std::vector< pair >());
354 i->_referingAttr_[id]->push_back(std::make_pair(this, sc->lastElt().safeName()));
355 }
356 }
PRMAttribute< GUM_SCALAR > & get(NodeId id)
Getter on an PRMAttribute<GUM_SCALAR> of this PRMInstance<GUM_SCALAR>.

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

Here is the call graph for this function:

◆ _copyAggregates_()

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 245 of file PRMInstance_tpl.h.

245 {
247 source->type(),
248 source->buildImpl());
249 GUM_ASSERT(&(attr->type().variable()) != &(source->type().variable()));
250 attr->setId(source->id());
251 _nodeIdMap_.insert(attr->id(), attr);
252 _bijection_.insert(&(source->type().variable()), &(attr->type().variable()));
253 }
Bijection< const DiscreteVariable *, const DiscreteVariable * > _bijection_
A bijection used for MultiDim handling.

References _bijection_, _nodeIdMap_, gum::prm::PRMAggregate< GUM_SCALAR >::buildImpl(), gum::prm::PRMClassElement< GUM_SCALAR >::id(), gum::prm::PRMObject::name(), gum::prm::PRMClassElement< GUM_SCALAR >::setId(), gum::prm::PRMAggregate< GUM_SCALAR >::type(), gum::prm::PRMAttribute< GUM_SCALAR >::type(), and gum::prm::PRMType::variable().

Referenced by PRMInstance().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _copyAttribute_()

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 256 of file PRMInstance_tpl.h.

256 {
258 GUM_ASSERT(&(attr->type().variable()) != &(source->type().variable()));
259 // The tensor is copied when instantiate() is called
260 attr->cpf().fill((GUM_SCALAR)0);
261 attr->setId(source->id());
262 _bijection_.insert(&(source->type().variable()), &(attr->type().variable()));
263 _nodeIdMap_.insert(attr->id(), attr);
264 }

References _bijection_, _nodeIdMap_, gum::prm::PRMAttribute< GUM_SCALAR >::cpf(), gum::prm::PRMClassElement< GUM_SCALAR >::id(), gum::prm::PRMObject::name(), gum::prm::PRMClassElement< GUM_SCALAR >::setId(), gum::prm::PRMAttribute< GUM_SCALAR >::type(), and gum::prm::PRMType::variable().

Referenced by PRMInstance().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _copyAttributeCPF_()

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 588 of file PRMInstance_tpl.h.

588 {
589 const auto& type_attr
590 = static_cast< const PRMAttribute< GUM_SCALAR >& >(type().get(attr->safeName()));
591 attr->copyCpf(bijection(), type_attr);
592 GUM_ASSERT(attr->cpf().contains(attr->type().variable()));
593 }
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...

References 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(), type(), and gum::prm::PRMType::variable().

Here is the call graph for this function:

◆ _doInstantiate_()

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

Starts this instance instantiations.

Definition at line 93 of file PRMInstance_tpl.h.

93 {
94 // First retrieving any referenced instance
95 for (const auto chain: type().slotChains()) {
97 }
98
99 // Now we need to add referred instance to each input node
100 // For Attributes we first add parents, then we initialize CPF
101 for (const auto attr: type().attributes()) {
102 _copyAttributeCPF_(_nodeIdMap_[(*attr).id()]);
103 }
104
105 // For PRMAggregate<GUM_SCALAR> we add parents
106 for (const auto agg: type().aggregates()) {
107 PRMAttribute< GUM_SCALAR >& attr = get(agg->safeName());
108
109 for (const auto node: type().containerDag().parents(agg->id())) {
110 try {
111 attr.addParent(get(node));
112 } catch (NotFound const&) {
113 auto elt = &(type().get(node));
114 auto sc = static_cast< PRMSlotChain< GUM_SCALAR >* >(elt);
115
116 try {
117 const auto& instances = getInstances(sc->id());
118
119 for (const auto inst: instances) {
120 attr.addParent(inst->get(sc->lastElt().safeName()));
121 }
122 } catch (NotFound const&) { // there is no parents for this agg
123 }
124 }
125 }
126 }
127 }
void _copyAttributeCPF_(PRMAttribute< GUM_SCALAR > *attr)
Copy the content of an PRMAttribute<GUM_SCALAR> from its Class<GUM_SCALAR> counterpart.
const Set< PRMInstance< GUM_SCALAR > * > & getInstances(NodeId id) const
Returns the Set of PRMInstance<GUM_SCALAR> referenced by id.
void _instantiateSlotChain_(PRMSlotChain< GUM_SCALAR > *sc)
Retrieve all instances referred by sc.

References _instantiateSlotChain_(), and type().

Referenced by instantiate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _instantiateSlotChain_()

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 130 of file PRMInstance_tpl.h.

130 {
131 auto first_id = sc->chain()[0]->id();
132 if (!_referenceMap_.exists(first_id)) { return; }
134 // We proceed with a width-first run of the slot chain
135 for (Size idx = 1; idx < sc->chain().size() - 1; ++idx) {
136 auto temp = new Set< PRMInstance< GUM_SCALAR >* >();
137 for (auto current: *set) {
138 auto& ref = current->type().get(sc->chain()[idx]->name());
139 for (auto next: *(current->_referenceMap_[ref.id()])) {
140 temp->insert(next);
141 }
142 }
143 delete set;
144 set = temp;
145 }
146
147 GUM_ASSERT(set->size() > 0);
148 // set contains all the instances references by sc
149 if (_referenceMap_.exists(sc->id())) {
150 delete _referenceMap_[sc->id()];
151 _referenceMap_[sc->id()] = set;
152 } else {
153 _referenceMap_.insert(sc->id(), set);
154 }
155
156 // Add refering instances
157 for (auto i: *set) {
159 }
160
161 // If sc is not multiple so it can be added as a parent of an attribute
162 if (!sc->isMultiple()) {
163 // We should have only one instance
164 // Less ugly way to get the single instance in set
165 for (auto instance: *set) {
166 auto& attr = instance->get(sc->lastElt().safeName());
167 _bijection_.insert(&(sc->type().variable()), &(attr.type().variable()));
168 }
169 }
170 }
void _addReferingInstance_(PRMSlotChain< GUM_SCALAR > *sc, PRMInstance< GUM_SCALAR > *i)
Add this as a referring instance over the attribute pointed by sc in i.
Size size() const
Returns the number of attributes in this PRMInstance<GUM_SCALAR>.

References _referenceMap_, gum::prm::PRMSlotChain< GUM_SCALAR >::chain(), gum::prm::PRMClassElement< GUM_SCALAR >::id(), and size().

Referenced by _doInstantiate_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add()

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.
OutOfBoundsRaised if no more PRMInstance<GUM_SCALAR> can be added to id.
PRMTypeErrorRaised if instance's type isn't compatible with the reference's type.
NotFoundIf there is no PRMClassElement given id.

Definition at line 173 of file PRMInstance_tpl.h.

173 {
175
176 try {
177 elt = &(type().get(id));
178 } catch (NotFound const&) {
179 GUM_ERROR(NotFound, "no ClassElement<GUM_SCALAR> matches the given id")
180 }
181
182 switch (elt->elt_type()) {
185
186 // Checking if instance's type is legal
187 if (!instance.type().isSubTypeOf(ref->slotType())) {
189 "given Instance type is not a proper "
190 "subclass of the ReferenceSlot<GUM_SCALAR> slot type");
191 }
192
193 // Checking the reference's size limit
194 if (_referenceMap_.exists(id)
195 && (!static_cast< PRMReferenceSlot< GUM_SCALAR >& >(type().get(id)).isArray())
196 && (_referenceMap_[id]->size() == 1)) {
197 GUM_ERROR(OutOfBounds, "ReferenceSlot<GUM_SCALAR> size limit reached")
198 }
199
200 break;
201 }
202
205 = static_cast< PRMSlotChain< GUM_SCALAR >& >(type().get(id));
206
207 // Checking if instance's type is legal
208 if (!instance.type().isSubTypeOf(sc.end())) {
210 "given Instance type is not a proper "
211 "subclass of the ClassElementContainer pointed"
212 " by the SlotChain<GUM_SCALAR>");
213 }
214
215 // Checking the reference's size limit
216 if (_referenceMap_.exists(id)
217 && (!static_cast< PRMSlotChain< GUM_SCALAR >& >(type().get(id)).isMultiple())
218 && (_referenceMap_[id]->size() == 1)) {
219 GUM_ERROR(OutOfBounds, "SlotChain<GUM_SCALAR> size limit reached")
220 }
221
222 break;
223 }
224
225 default : {
226 if (!type().isOutputNode(*elt)) {
227 GUM_ERROR(WrongClassElement, "given ClassElement<GUM_SCALAR> is not an output node")
228 }
229 }
230 }
231
232 if (!_referenceMap_.exists(id)) {
233 _referenceMap_.insert(id, new Set< PRMInstance< GUM_SCALAR >* >());
234 }
235
236 _referenceMap_[id]->insert(&instance);
237 }
const iterator & end()
Returns a reference over the iterator at the end of the list of gum::prm::PRMAttribute<GUM_SCALAR> in...

References PRMInstance(), _referenceMap_, gum::prm::PRMClassElement< GUM_SCALAR >::elt_type(), get(), GUM_ERROR, gum::prm::PRMClassElement< GUM_SCALAR >::prm_refslot, size(), gum::prm::PRMReferenceSlot< GUM_SCALAR >::slotType(), and type().

Here is the call graph for this function:

◆ begin() [1/4]

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 393 of file PRMInstance_tpl.h.

393 {
394 return _nodeIdMap_.begin();
395 }

References _nodeIdMap_.

Referenced by gum::prm::PRMInstance< GUM_SCALAR >::RefIterator::RefIterator(), gum::prm::SVE< GUM_SCALAR >::_eliminateNodes_(), gum::prm::StructuredInference< GUM_SCALAR >::_reduceAloneInstances_(), and gum::prm::StructuredInference< GUM_SCALAR >::searchPatterns().

Here is the caller graph for this function:

◆ begin() [2/4]

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 404 of file PRMInstance_tpl.h.

404 {
405 return _nodeIdMap_.begin();
406 }

References _nodeIdMap_.

◆ begin() [3/4]

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 416 of file PRMInstance_tpl.h.

416 {
417 try {
419 } catch (NotFound const&) { GUM_ERROR(NotFound, "no referred instances from this NodeId") }
420 }

◆ begin() [4/4]

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 424 of file PRMInstance_tpl.h.

424 {
425 try {
427 } catch (NotFound const&) { GUM_ERROR(NotFound, "no referred instances from this NodeId") }
428 }

◆ beginInvRef() [1/2]

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 548 of file PRMInstance_tpl.h.

548 {
549 return _referingAttr_.begin();
550 }

References _referingAttr_.

Referenced by gum::prm::SVE< GUM_SCALAR >::_eliminateNodes_(), gum::prm::SVE< GUM_SCALAR >::_eliminateNodesDownward_(), and gum::prm::SVE< GUM_SCALAR >::_eliminateNodesUpward_().

Here is the caller graph for this function:

◆ beginInvRef() [2/2]

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 560 of file PRMInstance_tpl.h.

560 {
561 return _referingAttr_.begin();
562 }

References _referingAttr_.

◆ bijection()

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 360 of file PRMInstance_tpl.h.

360 {
361 return _bijection_;
362 }

References _bijection_.

Referenced by _copyAttributeCPF_(), gum::prm::SVE< GUM_SCALAR >::_insertLiftedNodes_(), gum::prm::SVED< GUM_SCALAR >::_insertLiftedNodes_(), and gum::prm::StructuredInference< GUM_SCALAR >::_reduceAloneInstances_().

Here is the caller graph for this function:

◆ end() [1/2]

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 398 of file PRMInstance_tpl.h.

398 {
399 return _nodeIdMap_.end();
400 }

References _nodeIdMap_.

Referenced by gum::prm::SVE< GUM_SCALAR >::_eliminateNodes_(), gum::prm::StructuredInference< GUM_SCALAR >::_reduceAloneInstances_(), and gum::prm::PRMInference< GUM_SCALAR >::posterior().

Here is the caller graph for this function:

◆ end() [2/2]

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

410 {
411 return _nodeIdMap_.end();
412 }

References _nodeIdMap_.

◆ endInvRef() [1/2]

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 554 of file PRMInstance_tpl.h.

554 {
555 return _referingAttr_.end();
556 }

References _referingAttr_.

Referenced by gum::prm::SVE< GUM_SCALAR >::_eliminateNodes_(), gum::prm::SVE< GUM_SCALAR >::_eliminateNodesDownward_(), and gum::prm::SVE< GUM_SCALAR >::_eliminateNodesUpward_().

Here is the caller graph for this function:

◆ endInvRef() [2/2]

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

566 {
567 return _referingAttr_.end();
568 }

References _referingAttr_.

◆ enum2str()

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

Returns the string representation of a PRMObject.

Definition at line 95 of file PRMObject.h.

95 {
96 switch (type) {
97 case prm_type::CLASS : return "PRMType::CLASS";
98
99 case prm_type::CLASS_ELT : return "PRMType::CLASS_ELT";
100
101 case prm_type::TYPE : return "PRMType::TYPE";
102
103 case prm_type::SYSTEM : return "PRMType::SYSTEM";
104
105 case prm_type::INSTANCE : return "PRMType::INSTANCE";
106
107 case prm_type::PRM_INTERFACE : return "PRMType::PRM_INTERFACE";
108
109 default : return "unknown";
110 }
111 }

References CLASS, CLASS_ELT, INSTANCE, PRM_INTERFACE, SYSTEM, and TYPE.

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

Here is the caller graph for this function:

◆ exists() [1/2]

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 300 of file PRMInstance_tpl.h.

300 {
301 return _type_->exists(name) && exists(_type_->get(name).id());
302 }
bool exists(NodeId id) const
Returns true if id matches an PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.

References _type_, exists(), and gum::prm::PRMObject::name().

Here is the call graph for this function:

◆ exists() [2/2]

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 295 of file PRMInstance_tpl.h.

295 {
296 return _nodeIdMap_.exists(id);
297 }

References _nodeIdMap_.

Referenced by exists(), and gum::prm::o3prmr::O3prmrInterpreter::findAttributeName().

Here is the caller graph for this function:

◆ get() [1/4]

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 323 of file PRMInstance_tpl.h.

323 {
324 try {
325 return *(_nodeIdMap_[type().get(name).id()]);
326 } catch (NotFound const&) {
327 GUM_ERROR(NotFound, "no PRMAttribute<GUM_SCALAR> with the given name")
328 }
329 }

References _nodeIdMap_, GUM_ERROR, gum::prm::PRMObject::name(), and type().

Here is the call graph for this function:

◆ get() [2/4]

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

333 {
334 try {
335 return *(_nodeIdMap_[type().get(name).id()]);
336 } catch (NotFound const&) {
337 GUM_ERROR(NotFound, "no PRMAttribute<GUM_SCALAR> with the given name")
338 }
339 }

References _nodeIdMap_, gum::prm::PRMObject::name(), and type().

Here is the call graph for this function:

◆ get() [3/4]

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 305 of file PRMInstance_tpl.h.

305 {
306 try {
307 return *(_nodeIdMap_[id]);
308 } catch (NotFound const&) {
309 GUM_ERROR(NotFound, "no PRMAttribute<GUM_SCALAR> with the given NodeId")
310 }
311 }

Referenced by gum::prm::SVE< GUM_SCALAR >::_addDelayedVariable_(), _addReferingInstance_(), gum::prm::SVED< GUM_SCALAR >::_eliminateNodes_(), gum::prm::SVE< GUM_SCALAR >::_eliminateNodesWithEvidence_(), gum::prm::SVED< GUM_SCALAR >::_eliminateNodesWithEvidence_(), gum::prm::SVE< GUM_SCALAR >::_getAggTensor_(), gum::prm::SVED< GUM_SCALAR >::_getAggTensor_(), gum::prm::PRMSystem< double >::_groundAgg_(), gum::prm::PRMSystem< GUM_SCALAR >::_groundRef_(), gum::prm::InstanceBayesNet< GUM_SCALAR >::_init_(), gum::prm::StructuredInference< GUM_SCALAR >::_insertNodeInElimLists_(), gum::prm::StructuredBayesBall< GUM_SCALAR >::_isHardEvidence_(), gum::prm::StructuredInference< GUM_SCALAR >::_reduceAloneInstances_(), add(), gum::prm::o3prmr::O3prmrInterpreter::checkObserve(), gum::prm::o3prmr::O3prmrInterpreter::checkQuery(), and gum::prm::o3prmr::O3prmrInterpreter::checkUnobserve().

Here is the caller graph for this function:

◆ get() [4/4]

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 314 of file PRMInstance_tpl.h.

314 {
315 try {
316 return *(_nodeIdMap_[id]);
317 } catch (NotFound const&) {
318 GUM_ERROR(NotFound, "no PRMAttribute<GUM_SCALAR> with the given NodeId")
319 }
320 }

References _nodeIdMap_, and GUM_ERROR.

◆ getInstance()

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 366 of file PRMInstance_tpl.h.

366 {
367 try {
368 if (_referenceMap_[id]->size() > 0) {
369 return **(_referenceMap_[id]->begin());
370 } else {
371 GUM_ERROR(UndefinedElement, "no Instance associated with the given NodeId")
372 }
373 } catch (NotFound const&) {
375 "no ReferenceSlot<GUM_SCALAR> or SlotChain<GUM_SCALAR> "
376 "matches the given NodeId");
377 }
378 }

◆ getInstances()

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 382 of file PRMInstance_tpl.h.

382 {
383 try {
384 return *(_referenceMap_[id]);
385 } catch (NotFound const&) {
387 "no ReferenceSlot<GUM_SCALAR> or SlotChain<GUM_SCALAR> "
388 "matches the given NodeId");
389 }
390 }

References _referenceMap_, and GUM_ERROR.

Referenced by gum::prm::SVE< GUM_SCALAR >::_eliminateNodes_(), gum::prm::SVED< GUM_SCALAR >::_eliminateNodes_(), gum::prm::SVE< GUM_SCALAR >::_eliminateNodesDownward_(), gum::prm::SVED< GUM_SCALAR >::_eliminateNodesDownward_(), gum::prm::SVE< GUM_SCALAR >::_eliminateNodesUpward_(), gum::prm::SVED< GUM_SCALAR >::_eliminateNodesUpward_(), gum::prm::StructuredBayesBall< GUM_SCALAR >::_fromChild_(), and gum::prm::PRMSystem< GUM_SCALAR >::_groundRef_().

Here is the caller graph for this function:

◆ getRefAttr() [1/2]

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 572 of file PRMInstance_tpl.h.

572 {
573 return *(_referingAttr_[id]);
574 }

References _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_().

Here is the caller graph for this function:

◆ getRefAttr() [2/2]

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 578 of file PRMInstance_tpl.h.

578 {
579 return *(_referingAttr_[id]);
580 }

References _referingAttr_.

◆ hasRefAttr()

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 583 of file PRMInstance_tpl.h.

583 {
584 return _referingAttr_.exists(id) && (!_referingAttr_[id]->empty());
585 }

References _referingAttr_.

◆ instantiate()

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 85 of file PRMInstance_tpl.h.

85 {
86 if (!_instantiated_) {
87 _instantiated_ = true;
89 }
90 }
void _doInstantiate_()
Starts this instance instantiations.

References _doInstantiate_(), and _instantiated_.

Here is the call graph for this function:

◆ isClass()

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

Returns true if obj_ptr is of type Class.

Definition at line 114 of file PRMObject.h.

114{ return obj.obj_type() == prm_type::CLASS; }

References PRMObject(), CLASS, and obj_type().

Referenced by gum::prm::PRMClass< GUM_SCALAR >::scope(), and gum::prm::PRMFactory< GUM_SCALAR >::startAttribute().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isInstance()

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

Returns true if obj_ptr is of type PRMInstance.

Definition at line 122 of file PRMObject.h.

122 {
123 return obj.obj_type() == prm_type::INSTANCE;
124 }

References PRMObject(), INSTANCE, and obj_type().

Here is the call graph for this function:

◆ isInterface()

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

Returns true if obj_ptr is of type PRMInterface.

Definition at line 117 of file PRMObject.h.

117 {
118 return obj.obj_type() == prm_type::PRM_INTERFACE;
119 }

References PRMObject(), obj_type(), and PRM_INTERFACE.

Here is the call graph for this function:

◆ LEFT_CAST()

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 90 of file PRMObject.h.

90{ return "("; }

Referenced by gum::prm::PRMAggregate< GUM_SCALAR >::PRMAggregate(), gum::prm::PRMAggregate< GUM_SCALAR >::PRMAggregate(), gum::prm::PRMFormAttribute< GUM_SCALAR >::PRMFormAttribute(), gum::prm::PRMReferenceSlot< GUM_SCALAR >::PRMReferenceSlot(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::PRMScalarAttribute(), gum::prm::PRMSlotChain< GUM_SCALAR >::PRMSlotChain(), gum::prm::PRMClassElement< GUM_SCALAR >::cast(), and gum::prm::decomposePath().

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

54{ return _name_; }
std::string _name_
Definition PRMObject.h:211

References _name_.

Referenced by gum::prm::PRMAggregate< GUM_SCALAR >::PRMAggregate(), gum::prm::PRMAggregate< GUM_SCALAR >::PRMAggregate(), gum::prm::PRMAttribute< GUM_SCALAR >::PRMAttribute(), gum::prm::PRMClass< GUM_SCALAR >::PRMClass(), gum::prm::PRMClass< GUM_SCALAR >::PRMClass(), gum::prm::PRMClass< GUM_SCALAR >::PRMClass(), gum::prm::PRMClass< GUM_SCALAR >::PRMClass(), gum::prm::PRMClassElement< GUM_SCALAR >::PRMClassElement(), gum::prm::PRMClassElement< GUM_SCALAR >::PRMClassElement(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::PRMClassElementContainer(), gum::prm::PRMFormAttribute< GUM_SCALAR >::PRMFormAttribute(), gum::prm::PRMFormAttribute< GUM_SCALAR >::PRMFormAttribute(), gum::prm::PRMFuncAttribute< GUM_SCALAR >::PRMFuncAttribute(), gum::prm::PRMInstance< GUM_SCALAR >::PRMInstance(), gum::prm::PRMInterface< GUM_SCALAR >::PRMInterface(), gum::prm::PRMInterface< GUM_SCALAR >::PRMInterface(), gum::prm::PRMInterface< GUM_SCALAR >::PRMInterface(), PRMObject(), gum::prm::PRMParameter< GUM_SCALAR >::PRMParameter(), 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::PRMSlotChain< GUM_SCALAR >::PRMSlotChain(), gum::prm::PRMSlotChain< GUM_SCALAR >::PRMSlotChain(), gum::prm::PRMSlotChain< double >::PRMSlotChain(), gum::prm::PRMSystem< GUM_SCALAR >::PRMSystem(), gum::prm::__print_attribute__(), gum::prm::__print_instance__(), 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::PRMSystem< GUM_SCALAR >::_groundAgg_(), gum::prm::PRMSystem< double >::_groundAgg_(), gum::prm::PRMSystem< GUM_SCALAR >::_groundRef_(), gum::prm::PRMSystem< double >::_groundTensor_(), 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::gspan::StrictSearch< GUM_SCALAR >::_str_(), gum::prm::gspan::StrictSearch< GUM_SCALAR >::_str_(), gum::prm::gspan::StrictSearch< GUM_SCALAR >::_str_(), gum::prm::StructuredInference< GUM_SCALAR >::_str_(), gum::prm::StructuredInference< GUM_SCALAR >::_str_(), gum::prm::StructuredInference< GUM_SCALAR >::_str_(), gum::prm::PRMClass< GUM_SCALAR >::add(), gum::prm::PRMInterface< GUM_SCALAR >::add(), gum::prm::PRMSystem< 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::PRMInstance< GUM_SCALAR >::exists(), gum::prm::PRMSystem< GUM_SCALAR >::exists(), gum::prm::o3prmr::O3prmrInterpreter::findAttributeName(), gum::prm::o3prmr::O3prmrInterpreter::findInstanceName(), gum::prm::PRMClass< GUM_SCALAR >::get(), gum::prm::PRMClass< GUM_SCALAR >::get(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::get(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::get(), gum::prm::PRMInstance< GUM_SCALAR >::get(), gum::prm::PRMInstance< GUM_SCALAR >::get(), gum::prm::PRMInterface< GUM_SCALAR >::get(), gum::prm::PRMInterface< GUM_SCALAR >::get(), gum::prm::PRMSystem< GUM_SCALAR >::get(), gum::prm::PRMSystem< GUM_SCALAR >::get(), gum::prm::PRMSystem< GUM_SCALAR >::getArray(), gum::prm::PRMSystem< GUM_SCALAR >::getArrayType(), gum::prm::PRMSystem< GUM_SCALAR >::getArrayType(), gum::prm::PRMFormAttribute< GUM_SCALAR >::getCastDescendant(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::getCastDescendant(), gum::prm::PRMSystem< GUM_SCALAR >::groundedBN(), gum::prm::PRMClass< GUM_SCALAR >::inheritAggregates(), gum::prm::PRMSystem< double >::instantiate(), gum::prm::PRMSystem< GUM_SCALAR >::isArray(), gum::prm::PRMClass< GUM_SCALAR >::isCastDescendant(), gum::prm::PRMSystem< GUM_SCALAR >::isInstance(), name(), gum::prm::PRMType::name(), gum::prm::PRMFormAttribute< GUM_SCALAR >::newFactory(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::newFactory(), operator!=(), gum::prm::PRMClass< GUM_SCALAR >::operator=(), operator==(), gum::prm::PRMType::operator==(), gum::prm::PRMClass< GUM_SCALAR >::operator[](), gum::prm::PRMClass< GUM_SCALAR >::operator[](), gum::prm::PRMClassElementContainer< GUM_SCALAR >::operator[](), gum::prm::PRMClassElementContainer< GUM_SCALAR >::operator[](), gum::prm::PRMInterface< GUM_SCALAR >::operator[](), gum::prm::PRMClass< GUM_SCALAR >::overload(), gum::prm::PRMInterface< GUM_SCALAR >::overload(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::PRMClassElementContainterConstIterator, gum::prm::PRMClassElementContainer< GUM_SCALAR >::setInputNode(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::setOutputNode(), gum::prm::PRMFactory< GUM_SCALAR >::startClass(), gum::prm::PRMFactory< GUM_SCALAR >::startInterface(), and gum::prm::PRMFactory< GUM_SCALAR >::startSystem().

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

58{ _name_ = name; }

References _name_, and name().

Here is the call graph for this function:

◆ obj_type()

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 280 of file PRMInstance_tpl.h.

280 {
282 }

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

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

66{ return _name_ != obj.name(); }

References PRMObject(), _name_, and name().

Here is the call graph for this function:

◆ operator=()

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 275 of file PRMInstance_tpl.h.

275 {
276 GUM_ERROR(FatalError, "do not copy Instance")
277 }

References GUM_ERROR.

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

62{ return _name_ == obj.name(); }

References PRMObject(), _name_, and name().

Here is the call graph for this function:

◆ RIGHT_CAST()

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 92 of file PRMObject.h.

92{ return ")"; }

Referenced by gum::prm::PRMAggregate< GUM_SCALAR >::PRMAggregate(), gum::prm::PRMAggregate< GUM_SCALAR >::PRMAggregate(), gum::prm::PRMFormAttribute< GUM_SCALAR >::PRMFormAttribute(), gum::prm::PRMReferenceSlot< GUM_SCALAR >::PRMReferenceSlot(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::PRMScalarAttribute(), gum::prm::PRMSlotChain< GUM_SCALAR >::PRMSlotChain(), gum::prm::PRMClassElement< GUM_SCALAR >::cast(), and gum::prm::decomposePath().

Here is the caller graph for this function:

◆ size()

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 240 of file PRMInstance_tpl.h.

240 {
241 return _nodeIdMap_.size();
242 }

References _nodeIdMap_.

Referenced by _instantiateSlotChain_(), gum::prm::StructuredInference< GUM_SCALAR >::_reduceAloneInstances_(), and add().

Here is the caller graph for this function:

◆ type() [1/2]

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

Returns the type of this instance.

Definition at line 285 of file PRMInstance_tpl.h.

285 {
286 return *_type_;
287 }

Referenced by PRMInstance(), gum::prm::__print_attribute__(), gum::prm::__print_instance__(), gum::prm::StructuredBayesBall< GUM_SCALAR >::_buildHashKey_(), gum::prm::SVE< GUM_SCALAR >::_checkElimOrder_(), gum::prm::SVED< GUM_SCALAR >::_checkElimOrder_(), _copyAttributeCPF_(), _doInstantiate_(), gum::prm::SVE< GUM_SCALAR >::_eliminateNodes_(), gum::prm::SVE< GUM_SCALAR >::_eliminateNodesDownward_(), gum::prm::SVED< GUM_SCALAR >::_eliminateNodesDownward_(), gum::prm::SVE< GUM_SCALAR >::_eliminateNodesUpward_(), gum::prm::SVED< 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 >::_groundRef_(), gum::prm::PRMSystem< double >::_groundTensor_(), 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::StructuredInference< GUM_SCALAR >::_reduceAloneInstances_(), gum::prm::SVE< GUM_SCALAR >::_variableElimination_(), add(), gum::prm::PRMSystem< GUM_SCALAR >::add(), get(), get(), and gum::prm::PRMSystem< double >::instantiate().

◆ type() [2/2]

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 290 of file PRMInstance_tpl.h.

290 {
291 return *_type_;
292 }

References _type_.

Member Data Documentation

◆ _bijection_

template<typename GUM_SCALAR>
Bijection< const DiscreteVariable*, const DiscreteVariable* > gum::prm::PRMInstance< GUM_SCALAR >::_bijection_
private

A bijection used for MultiDim handling.

Definition at line 538 of file PRMInstance.h.

Referenced by _copyAggregates_(), _copyAttribute_(), and bijection().

◆ _instantiated_

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

True if this instance has been instantiated.

Definition at line 516 of file PRMInstance.h.

Referenced by PRMInstance(), and instantiate().

◆ _name_

std::string gum::prm::PRMObject::_name_
privateinherited

◆ _nodeIdMap_

template<typename GUM_SCALAR>
NodeProperty< PRMAttribute< GUM_SCALAR >* > gum::prm::PRMInstance< GUM_SCALAR >::_nodeIdMap_
private

◆ _referenceMap_

template<typename GUM_SCALAR>
NodeProperty< Set< PRMInstance< GUM_SCALAR >* >* > gum::prm::PRMInstance< GUM_SCALAR >::_referenceMap_
private

Mapping between the gum::prm::PRMReferenceSlot and gum::prm::PRMSlotChain<GUM_SCALAR> in type / and the PRMInstance<GUM_SCALAR> associated with it.

Definition at line 528 of file PRMInstance.h.

Referenced by ~PRMInstance(), _addReferingInstance_(), _instantiateSlotChain_(), add(), and getInstances().

◆ _referingAttr_

template<typename GUM_SCALAR>
NodeProperty< std::vector< pair >* > gum::prm::PRMInstance< GUM_SCALAR >::_referingAttr_
private

The set of pair (instance, attribute) referring an attribute of this instance.

Definition at line 535 of file PRMInstance.h.

Referenced by ~PRMInstance(), _addReferingInstance_(), beginInvRef(), beginInvRef(), endInvRef(), endInvRef(), getRefAttr(), getRefAttr(), and hasRefAttr().

◆ _type_

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

The type of this PRMInstance<GUM_SCALAR>.

Definition at line 519 of file PRMInstance.h.

Referenced by PRMInstance(), exists(), and type().


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