aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
PRMInstance_tpl.h
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of the aGrUM/pyAgrum library. *
3 * *
4 * Copyright (c) 2005-2025 by *
5 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
6 * - Christophe GONZALES(_at_AMU) *
7 * *
8 * The aGrUM/pyAgrum library is free software; you can redistribute it *
9 * and/or modify it under the terms of either : *
10 * *
11 * - the GNU Lesser General Public License as published by *
12 * the Free Software Foundation, either version 3 of the License, *
13 * or (at your option) any later version, *
14 * - the MIT license (MIT), *
15 * - or both in dual license, as here. *
16 * *
17 * (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18 * *
19 * This aGrUM/pyAgrum library is distributed in the hope that it will be *
20 * useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26 * OTHER DEALINGS IN THE SOFTWARE. *
27 * *
28 * See LICENCES for more details. *
29 * *
30 * SPDX-FileCopyrightText: Copyright 2005-2025 *
31 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
32 * - Christophe GONZALES(_at_AMU) *
33 * SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34 * *
35 * Contact : info_at_agrum_dot_org *
36 * homepage : http://agrum.gitlab.io *
37 * gitlab : https://gitlab.com/agrumery/agrum *
38 * *
39 ****************************************************************************/
40#pragma once
41
42
49
52
53namespace gum {
54 namespace prm {
55 template < typename GUM_SCALAR >
58 GUM_CONSTRUCTOR(PRMInstance);
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())
67 _copyAttribute_(attr);
68 }
69
70 template < typename GUM_SCALAR >
72 GUM_DESTRUCTOR(PRMInstance);
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 }
83
84 template < typename GUM_SCALAR >
91
92 template < typename GUM_SCALAR >
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()) {
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());
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 }
128
129 template < typename GUM_SCALAR >
131 auto first_id = sc->chain()[0]->id();
132 if (!_referenceMap_.exists(first_id)) { return; }
133 auto set = new Set< PRMInstance< GUM_SCALAR >* >(*(_referenceMap_[first_id]));
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) {
158 _addReferingInstance_(sc, i);
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 }
171
172 template < typename GUM_SCALAR >
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
204 PRMSlotChain< GUM_SCALAR >& sc
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 }
232 if (!_referenceMap_.exists(id)) {
233 _referenceMap_.insert(id, new Set< PRMInstance< GUM_SCALAR >* >());
234 }
235
236 _referenceMap_[id]->insert(&instance);
237 }
238
239 template < typename GUM_SCALAR >
241 return _nodeIdMap_.size();
242 }
243
244 template < typename GUM_SCALAR >
246 auto attr = new PRMScalarAttribute< GUM_SCALAR >(source->name(),
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 }
254
255 template < typename GUM_SCALAR >
257 auto attr = new PRMScalarAttribute< GUM_SCALAR >(source->name(), source->type());
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 }
265
266 template < typename GUM_SCALAR >
268 PRMObject(source), _type_(source._type_) {
269 GUM_CONS_CPY(PRMInstance);
270 GUM_ERROR(FatalError, "do not copy Instance")
271 }
272
273 template < typename GUM_SCALAR >
274 INLINE PRMInstance< GUM_SCALAR >& /**/
276 GUM_ERROR(FatalError, "do not copy Instance")
277 }
278
279 template < typename GUM_SCALAR >
283
284 template < typename GUM_SCALAR >
286 return *_type_;
287 }
288
289 template < typename GUM_SCALAR >
291 return *_type_;
292 }
293
294 template < typename GUM_SCALAR >
296 return _nodeIdMap_.exists(id);
297 }
299 template < typename GUM_SCALAR >
300 INLINE bool PRMInstance< GUM_SCALAR >::exists(const std::string& name) const {
301 return _type_->exists(name) && exists(_type_->get(name).id());
302 }
303
304 template < typename GUM_SCALAR >
306 try {
307 return *(_nodeIdMap_[id]);
308 } catch (NotFound const&) {
309 GUM_ERROR(NotFound, "no PRMAttribute<GUM_SCALAR> with the given NodeId")
310 }
312
313 template < typename GUM_SCALAR >
315 try {
316 return *(_nodeIdMap_[id]);
317 } catch (NotFound const&) {
318 GUM_ERROR(NotFound, "no PRMAttribute<GUM_SCALAR> with the given NodeId")
319 }
320 }
321
322 template < typename GUM_SCALAR >
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 }
330
331 template < typename GUM_SCALAR >
333 PRMInstance< GUM_SCALAR >::get(const std::string& name) const {
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 }
340
341 template < typename GUM_SCALAR >
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 }
357
358 template < typename GUM_SCALAR >
363
364 template < typename GUM_SCALAR >
365 INLINE const PRMInstance< GUM_SCALAR >&
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")
373 } catch (NotFound const&) {
375 "no ReferenceSlot<GUM_SCALAR> or SlotChain<GUM_SCALAR> "
376 "matches the given NodeId");
377 }
378 }
379
380 template < typename GUM_SCALAR >
381 INLINE const Set< PRMInstance< GUM_SCALAR >* >&
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 }
391
392 template < typename GUM_SCALAR >
396
397 template < typename GUM_SCALAR >
399 return _nodeIdMap_.end();
400 }
401
402 template < typename GUM_SCALAR >
405 return _nodeIdMap_.begin();
406 }
407
408 template < typename GUM_SCALAR >
411 return _nodeIdMap_.end();
412 }
414 template < typename GUM_SCALAR >
417 try {
419 } catch (NotFound const&) { GUM_ERROR(NotFound, "no referred instances from this NodeId") }
420 }
422 template < typename GUM_SCALAR >
425 try {
427 } catch (NotFound const&) { GUM_ERROR(NotFound, "no referred instances from this NodeId") }
428 }
429
430 template < typename GUM_SCALAR >
435
436 template < typename GUM_SCALAR >
438 _set_(const_cast< Set< PRMInstance< GUM_SCALAR >* >& >(from._set_)), _iter_(from._iter_) {
440 }
441
442 template < typename GUM_SCALAR >
446
447 template < typename GUM_SCALAR >
450 _iter_ = from._iter_;
451 return *this;
452 }
453
454 template < typename GUM_SCALAR >
457 ++_iter_;
458 return *this;
460
461 template < typename GUM_SCALAR >
463 return _iter_ == _set_.end();
464 }
465
466 template < typename GUM_SCALAR >
468 return _iter_ != from._iter_;
469 }
470
471 template < typename GUM_SCALAR >
473 return _iter_ == from._iter_;
474 }
475
476 template < typename GUM_SCALAR >
480
481 template < typename GUM_SCALAR >
483 return *_iter_;
484 }
485
486 template < typename GUM_SCALAR >
488 const Set< PRMInstance< GUM_SCALAR >* >& set) : _set_(set), _iter_(set.begin()) {
490 }
491
492 template < typename GUM_SCALAR >
494 const RefConstIterator& from) : _set_(from._set_), _iter_(from._iter_) {
496 }
497
498 template < typename GUM_SCALAR >
502
503 template < typename GUM_SCALAR >
506 _iter_ = from._iter_;
507 return *this;
508 }
509
510 template < typename GUM_SCALAR >
516
517 template < typename GUM_SCALAR >
519 return _iter_ == _set_.end();
520 }
521
522 template < typename GUM_SCALAR >
524 const RefConstIterator& from) const {
525 return _iter_ != from._iter_;
526 }
527
528 template < typename GUM_SCALAR >
530 const RefConstIterator& from) const {
531 return _iter_ == from._iter_;
532 }
533
534 template < typename GUM_SCALAR >
535 INLINE const PRMInstance< GUM_SCALAR >&
539
540 template < typename GUM_SCALAR >
541 INLINE const PRMInstance< GUM_SCALAR >*
545
546 template < typename GUM_SCALAR >
551
552 template < typename GUM_SCALAR >
553 INLINE const typename PRMInstance< GUM_SCALAR >::InvRefIterator&
557
558 template < typename GUM_SCALAR >
561 return _referingAttr_.begin();
562 }
563
564 template < typename GUM_SCALAR >
567 return _referingAttr_.end();
568 }
569
570 template < typename GUM_SCALAR >
571 INLINE std::vector< std::pair< PRMInstance< GUM_SCALAR >*, std::string > >&
575
576 template < typename GUM_SCALAR >
577 INLINE const std::vector< std::pair< PRMInstance< GUM_SCALAR >*, std::string > >&
579 return *(_referingAttr_[id]);
580 }
581
582 template < typename GUM_SCALAR >
584 return _referingAttr_.exists(id) && (!_referingAttr_[id]->empty());
585 }
586
587 template < typename GUM_SCALAR >
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 }
594
595 } /* namespace prm */
596} /* namespace gum */
Headers of gum::prm::PRMInstance<GUM_SCALAR>.
Set of pairs of elements with fast search for both elements.
Definition bijection.h:1594
Exception : fatal (unknown ?) error.
Exception : the element we looked for cannot be found.
Exception : out of bound.
Exception : wrong subtype or subclass.
Representation of a set.
Definition set.h:131
Exception : a looked-for element could not be found.
Exception: wrong PRMClassElement for this operation.
virtual PRMType & type()
See gum::PRMClassElement::type().
MultiDimImplementation< GUM_SCALAR > * buildImpl() const
Returns a pointer over an empty gum::MultiDimImplementation of the good type for this PRMAggregate.
PRMAttribute is a member of a Class in a PRM.
virtual const Tensor< GUM_SCALAR > & cpf() const =0
See gum::PRMClassElement::cpf().
virtual void copyCpf(const Bijection< const DiscreteVariable *, const DiscreteVariable * > &bif, const PRMAttribute< GUM_SCALAR > &source)=0
See gum::PRMClassElement::elt_type().
virtual void addParent(const PRMClassElement< GUM_SCALAR > &elt)=0
See gum::PRMClassElement::addParent_().
virtual PRMType & type()=0
See gum::PRMClassElement::type().
Abstract class representing an element of PRM class.
virtual void setId(NodeId id)
Used to assign the id of this element.
NodeId id() const
Returns the NodeId of this element in it's class DAG.
virtual ClassElementType elt_type() const =0
Return the type of class element this object is.
const std::string & safeName() const
Returns the safe name of this PRMClassElement, if any.
A PRMClass is an object of a PRM representing a fragment of a Bayesian network which can be instantia...
Definition PRMClass.h:75
Nested class to iterate over PRMReferenceSlot and PRMSlotChain<GUM_SCALAR> instantiations.
const Set< PRMInstance< GUM_SCALAR > * > & _set_
bool operator!=(const RefConstIterator &from) const
const PRMInstance< GUM_SCALAR > * operator->() const
RefConstIterator & operator=(const RefConstIterator &from)
const PRMInstance< GUM_SCALAR > & operator*() const
bool operator==(const RefConstIterator &from) const
RefConstIterator(const Set< PRMInstance< GUM_SCALAR > * > &set)
Set< PRMInstance< GUM_SCALAR > * >::const_iterator _iter_
Nested class to iterate over PRMReferenceSlot and PRMSlotChain<GUM_SCALAR> instantiations.
PRMInstance< GUM_SCALAR > & operator*() const
RefIterator(Set< PRMInstance< GUM_SCALAR > * > &set)
RefIterator & operator=(const RefIterator &from)
Set< PRMInstance< GUM_SCALAR > * >::iterator _iter_
Set< PRMInstance< GUM_SCALAR > * > & _set_
bool operator==(const RefIterator &from) const
bool operator!=(const RefIterator &from) const
PRMInstance< GUM_SCALAR > * operator->() const
An PRMInstance is a Bayesian network fragment defined by a Class and used in a PRMSystem.
Definition PRMInstance.h:79
NodeProperty< PRMAttribute< GUM_SCALAR > * > _nodeIdMap_
The gum::prm::PRMAttribute<GUM_SCALAR> and gum::prm::PRMAggregate<GUM_SCALAR> of this PRMInstance<GUM...
void instantiate()
Instantiate all nodes which requires it.
const iterator & end()
Returns a reference over the iterator at the end of the list of gum::prm::PRMAttribute<GUM_SCALAR> in...
void _copyAttributeCPF_(PRMAttribute< double > *attr)
typename NodeProperty< PRMAttribute< GUM_SCALAR > * >::const_iterator const_iterator
Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> 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 t...
PRMInstance< GUM_SCALAR > & operator=(const PRMClass< GUM_SCALAR > &from)
Copy operator. Don't use it.
virtual prm_type obj_type() const
Returns the PRM type of this object.
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...
InvRefIterator beginInvRef()
Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.
bool _instantiated_
True if this instance has been instantiated.
Bijection< const DiscreteVariable *, const DiscreteVariable * > _bijection_
A bijection used for MultiDim handling.
const InvRefIterator & endInvRef()
Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.
bool exists(NodeId id) const
Returns true if id matches an PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.
std::vector< std::pair< PRMInstance< GUM_SCALAR > *, std::string > > & getRefAttr(NodeId id)
Returns a vector of pairs of refering attributes of id.
PRMClass< GUM_SCALAR > & type()
Returns the type of this instance.
PRMClass< GUM_SCALAR > * _type_
The type of this PRMInstance<GUM_SCALAR>.
const Set< PRMInstance< double > * > & getInstances(NodeId id) const
void _copyAttribute_(PRMAttribute< GUM_SCALAR > *source)
Used at construction to instantiate attributes.
void _instantiateSlotChain_(PRMSlotChain< GUM_SCALAR > *sc)
Retrieve all instances referred by sc.
typename 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>.
typename NodeProperty< PRMAttribute< GUM_SCALAR > * >::iterator iterator
Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.
void _addReferingInstance_(PRMSlotChain< GUM_SCALAR > *sc, PRMInstance< GUM_SCALAR > *i)
Add this as a referring instance over the attribute pointed by sc in i.
bool hasRefAttr(NodeId id) const
Returns true if id has at least one referring PRMAttribute<GUM_SCALAR>.
PRMInstance(const std::string &name, PRMClass< GUM_SCALAR > &type)
Default constructor of an PRMInstance<GUM_SCALAR>.
typename 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>.
PRMAttribute< GUM_SCALAR > & get(NodeId id)
Getter on an PRMAttribute<GUM_SCALAR> of this PRMInstance<GUM_SCALAR>.
const PRMInstance< GUM_SCALAR > & getInstance(NodeId id) const
Fast access to the first instance in a PRMReferenceSlot or PRMSlotChain<GUM_SCALAR>.
iterator begin()
Returns an iterator at the begining of the list of gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInst...
virtual ~PRMInstance()
Destructor.
void add(NodeId id, PRMInstance< GUM_SCALAR > &instance)
Add an PRMInstance<GUM_SCALAR> to a given PRMReferenceSlot, PRMSlotChain<GUM_SCALAR> or output node.
NodeProperty< std::vector< pair > * > _referingAttr_
The set of pair (instance, attribute) referring an attribute of this instance.
Size size() const
Returns the number of attributes in this PRMInstance<GUM_SCALAR>.
void _copyAggregates_(PRMAggregate< GUM_SCALAR > *source)
Used at construction to instantiate aggregates.
void _doInstantiate_()
Starts this instance instantiations.
const std::string & name() const
Returns the name of this object.
prm_type
Enumeration of the different types of objects handled by a PRM.
Definition PRMObject.h:88
PRMObject(const std::string &name)
Constructor.
Definition PRMObject.cpp:62
A PRMReferenceSlot represent a relation between two PRMClassElementContainer.
PRMClassElementContainer< GUM_SCALAR > & slotType()
Returns the type of this slot, which is a PRMClassElementContainer (it is not the type of PRMObject).
<agrum/PRM/elements/scalarAttribute.h>
A PRMSlotChain represents a sequence of gum::prm::PRMClassElement<GUM_SCALAR> where the n-1 first gum...
Sequence< PRMClassElement< GUM_SCALAR > * > & chain()
Return the sequence representing the chain of elements in this PRMSlotChain.
PRMClassElement< GUM_SCALAR > & lastElt()
Returns the last element of the slot chain, typically this is an gum::PRMAttribute or a gum::PRMAggre...
virtual PRMType & type()
This is similar to the following call: this->lastElt().type().
bool isMultiple() const
Return true if this slot chain contains at least one multiple reference slot.
DiscreteVariable & variable()
Return a reference on the DiscreteVariable contained in this.
Definition PRMType_inl.h:64
#define GUM_ERROR(type, msg)
Definition exceptions.h:72
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74
Size NodeId
Type for node ids.
Headers of MultiDimSparse.
namespace for all probabilistic relational models entities
Definition agrum.h:68
gum is the global namespace for all aGrUM entities
Definition agrum.h:46