aGrUM 3.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-2026 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-2026 *
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
41#pragma once
42
43
50
53
54namespace gum {
55 namespace prm {
56 template < GUM_Numeric GUM_SCALAR >
59 GUM_CONSTRUCTOR(PRMInstance);
60
61 // First we create attributes for each aggregate in type
62 for (const auto agg: _type_->aggregates())
64
65 // We add attributes in type by reference for inner ones and by copy for
66 // output ones
67 for (const auto attr: _type_->attributes())
68 _copyAttribute_(attr);
69 }
70
71 template < GUM_Numeric GUM_SCALAR >
73 GUM_DESTRUCTOR(PRMInstance);
74
75 for (const auto& elt: _nodeIdMap_)
76 delete elt.second;
77
78 for (const auto& elt: _referenceMap_)
79 delete elt.second;
80
81 for (const auto& elt: _referingAttr_)
82 delete elt.second;
83 }
84
85 template < GUM_Numeric GUM_SCALAR >
92
93 template < GUM_Numeric GUM_SCALAR >
95 // First retrieving any referenced instance
96 for (const auto chain: type().slotChains()) {
98 }
99
100 // Now we need to add referred instance to each input node
101 // For Attributes we first add parents, then we initialize CPF
102 for (const auto attr: type().attributes()) {
103 _copyAttributeCPF_(_nodeIdMap_[(*attr).id()]);
104 }
105
106 // For PRMAggregate<GUM_SCALAR> we add parents
107 for (const auto agg: type().aggregates()) {
108 PRMAttribute< GUM_SCALAR >& attr = get(agg->safeName());
109
110 for (const auto node: type().containerDag().parents(agg->id())) {
111 if (auto p_node = _nodeIdMap_.tryGet(node)) {
112 attr.addParent(*(*p_node));
113 } else {
114 auto elt = &(type().get(node));
115 auto sc = static_cast< PRMSlotChain< GUM_SCALAR >* >(elt);
116
117 if (auto p_ref = _referenceMap_.tryGet(sc->id())) {
118 for (const auto inst: *(*p_ref)) {
119 attr.addParent(inst->get(sc->lastElt().safeName()));
120 }
121 }
122 }
123 }
124 }
125 }
126
127 template < GUM_Numeric GUM_SCALAR >
129 auto first_id = sc->chain()[0]->id();
130 auto p_first = _referenceMap_.tryGet(first_id);
131 if (!p_first) { return; }
132 auto set = new Set< PRMInstance< GUM_SCALAR >* >(*(*p_first));
133 // We proceed with a width-first run of the slot chain
134 for (Size idx = 1; idx < sc->chain().size() - 1; ++idx) {
135 auto temp = new Set< PRMInstance< GUM_SCALAR >* >();
136 for (auto current: *set) {
137 auto& ref = current->type().get(sc->chain()[idx]->name());
138 auto p_next = current->_referenceMap_.tryGet(ref.id());
139 if (!p_next) {
140 delete temp;
141 delete set;
143 "the reference slot " << ref.name() << " of " << current->name()
144 << " is not assigned")
145 }
146 for (auto next: *(*p_next)) {
147 temp->insert(next);
148 }
149 }
150 delete set;
151 set = temp;
152 }
153
154 GUM_ASSERT(set->size() > 0);
155 // set contains all the instances references by sc
156 if (auto p_ref = _referenceMap_.tryGet(sc->id())) {
157 delete *p_ref;
158 *p_ref = set;
159 } else {
160 _referenceMap_.insert(sc->id(), set);
161 }
162
163 // Add refering instances
164 for (auto i: *set) {
166 }
167
168 // If sc is not multiple so it can be added as a parent of an attribute
169 if (!sc->isMultiple()) {
170 // We should have only one instance
171 // Less ugly way to get the single instance in set
172 for (auto instance: *set) {
173 auto& attr = instance->get(sc->lastElt().safeName());
174 _bijection_.insert(&(sc->type().variable()), &(attr.type().variable()));
175 }
176 }
177 }
178
179 template < GUM_Numeric GUM_SCALAR >
181 if (!type().exists(id))
182 GUM_ERROR(NotFound, "no ClassElement<GUM_SCALAR> matches the given id")
183 PRMClassElement< GUM_SCALAR >* elt = &(type().get(id));
184
185 switch (elt->elt_type()) {
188
189 // Checking if instance's type is legal
190 if (!instance.type().isSubTypeOf(ref->slotType())) {
192 "given Instance type is not a proper "
193 "subclass of the ReferenceSlot<GUM_SCALAR> slot type");
194 }
195
196 // Checking the reference's size limit
197 if (auto p_ref_slot = _referenceMap_.tryGet(id);
198 p_ref_slot
199 && (!static_cast< PRMReferenceSlot< GUM_SCALAR >& >(type().get(id)).isArray())
200 && ((*p_ref_slot)->size() == 1)) {
201 GUM_ERROR(OutOfBounds, "ReferenceSlot<GUM_SCALAR> size limit reached")
202 }
203
204 break;
205 }
206
209 = static_cast< PRMSlotChain< GUM_SCALAR >& >(type().get(id));
210
211 // Checking if instance's type is legal
212 if (!instance.type().isSubTypeOf(sc.end())) {
214 "given Instance type is not a proper "
215 "subclass of the ClassElementContainer pointed"
216 " by the SlotChain<GUM_SCALAR>");
217 }
218
219 // Checking the reference's size limit
220 if (auto p_ref_sc = _referenceMap_.tryGet(id);
221 p_ref_sc && (!static_cast< PRMSlotChain< GUM_SCALAR >& >(type().get(id)).isMultiple())
222 && ((*p_ref_sc)->size() == 1)) {
223 GUM_ERROR(OutOfBounds, "SlotChain<GUM_SCALAR> size limit reached")
224 }
225
226 break;
227 }
228
229 default : {
230 if (!type().isOutputNode(*elt)) {
231 GUM_ERROR(WrongClassElement, "given ClassElement<GUM_SCALAR> is not an output node")
232 }
233 }
234 }
235
236 auto p_ref_add = _referenceMap_.tryGet(id);
237 if (!p_ref_add) {
238 _referenceMap_.insert(id, new Set< PRMInstance< GUM_SCALAR >* >());
239 p_ref_add = _referenceMap_.tryGet(id);
240 }
241
242 (*p_ref_add)->insert(&instance);
243 }
244
245 template < GUM_Numeric GUM_SCALAR >
247 return _nodeIdMap_.size();
248 }
249
250 template < GUM_Numeric GUM_SCALAR >
252 auto attr = new PRMScalarAttribute< GUM_SCALAR >(source->name(),
253 source->type(),
254 source->buildImpl());
255 GUM_ASSERT(&(attr->type().variable()) != &(source->type().variable()));
256 attr->setId(source->id());
257 _nodeIdMap_.insert(attr->id(), attr);
258 _bijection_.insert(&(source->type().variable()), &(attr->type().variable()));
259 }
260
261 template < GUM_Numeric GUM_SCALAR >
263 auto attr = new PRMScalarAttribute< GUM_SCALAR >(source->name(), source->type());
264 GUM_ASSERT(&(attr->type().variable()) != &(source->type().variable()));
265 // The tensor is copied when instantiate() is called
266 attr->cpf().fill((GUM_SCALAR)0);
267 attr->setId(source->id());
268 _bijection_.insert(&(source->type().variable()), &(attr->type().variable()));
269 _nodeIdMap_.insert(attr->id(), attr);
270 }
271
272 template < GUM_Numeric GUM_SCALAR >
274 PRMObject(source), _type_(source._type_) {
275 GUM_CONS_CPY(PRMInstance);
276 GUM_ERROR(FatalError, "do not copy Instance")
277 }
278
279 template < GUM_Numeric GUM_SCALAR >
282 GUM_ERROR(FatalError, "do not copy Instance")
283 }
284
285 template < GUM_Numeric GUM_SCALAR >
289
290 template < GUM_Numeric GUM_SCALAR >
294
295 template < GUM_Numeric GUM_SCALAR >
299
300 template < GUM_Numeric GUM_SCALAR >
302 return _nodeIdMap_.exists(id);
303 }
304
305 template < GUM_Numeric GUM_SCALAR >
306 bool PRMInstance< GUM_SCALAR >::exists(std::string_view name) const {
307 return _type_->exists(name) && exists(_type_->get(name).id());
308 }
309
310 template < GUM_Numeric GUM_SCALAR >
312 auto p = _nodeIdMap_.tryGet(id);
313 if (!p) GUM_ERROR(NotFound, "no PRMAttribute<GUM_SCALAR> with the given NodeId")
314 return *(*p);
315 }
316
317 template < GUM_Numeric GUM_SCALAR >
319 auto p = _nodeIdMap_.tryGet(id);
320 if (!p) GUM_ERROR(NotFound, "no PRMAttribute<GUM_SCALAR> with the given NodeId")
321 return *(*p);
322 }
323
324 template < GUM_Numeric GUM_SCALAR >
326 if (!exists(name)) GUM_ERROR(NotFound, "no PRMAttribute<GUM_SCALAR> with the given name")
327 return *(_nodeIdMap_[type().get(name).id()]);
328 }
329
330 template < GUM_Numeric GUM_SCALAR >
332 if (!exists(name)) GUM_ERROR(NotFound, "no PRMAttribute<GUM_SCALAR> with the given name")
333 return *(_nodeIdMap_[type().get(name).id()]);
334 }
335
336 template < GUM_Numeric GUM_SCALAR >
339 NodeId id = i->get(sc->lastElt().safeName()).id();
340 std::string name = sc->name();
341
342 auto p_rm = i->_referenceMap_.tryGet(id);
343 if (!p_rm) {
344 i->_referenceMap_.insert(id, new Set< PRMInstance< GUM_SCALAR >* >());
345 i->_referingAttr_.insert(id, new std::vector< pair >());
346 p_rm = i->_referenceMap_.tryGet(id);
347 }
348 (*p_rm)->insert(this);
349 (*i->_referingAttr_.tryGet(id))->push_back(std::make_pair(this, name));
350 }
351
352 template < GUM_Numeric GUM_SCALAR >
357
358 template < GUM_Numeric GUM_SCALAR >
360 auto p = _referenceMap_.tryGet(id);
361 if (!p)
363 "no ReferenceSlot<GUM_SCALAR> or SlotChain<GUM_SCALAR> "
364 "matches the given NodeId")
365 if ((*p)->size() > 0) {
366 return **((*p)->begin());
367 } else {
368 GUM_ERROR(UndefinedElement, "no Instance associated with the given NodeId")
369 }
370 }
371
372 template < GUM_Numeric GUM_SCALAR >
375 auto p = _referenceMap_.tryGet(id);
376 if (!p)
378 "no ReferenceSlot<GUM_SCALAR> or SlotChain<GUM_SCALAR> "
379 "matches the given NodeId")
380 return *(*p);
381 }
382
383 template < GUM_Numeric GUM_SCALAR >
387
388 template < GUM_Numeric GUM_SCALAR >
392
393 template < GUM_Numeric GUM_SCALAR >
397
398 template < GUM_Numeric GUM_SCALAR >
401 return _nodeIdMap_.end();
402 }
403
404 template < GUM_Numeric GUM_SCALAR >
406 auto p = _referenceMap_.tryGet(id);
407 if (!p) GUM_ERROR(NotFound, "no referred instances from this NodeId")
409 }
410
411 template < GUM_Numeric GUM_SCALAR >
414 auto p = _referenceMap_.tryGet(id);
415 if (!p) GUM_ERROR(NotFound, "no referred instances from this NodeId")
417 }
418
419 template < GUM_Numeric GUM_SCALAR >
424
425 template < GUM_Numeric GUM_SCALAR >
427 _set_(const_cast< Set< PRMInstance< GUM_SCALAR >* >& >(from._set_)), _iter_(from._iter_) {
429 }
430
431 template < GUM_Numeric GUM_SCALAR >
435
436 template < GUM_Numeric GUM_SCALAR >
439 _iter_ = from._iter_;
440 return *this;
441 }
442
443 template < GUM_Numeric GUM_SCALAR >
449
450 template < GUM_Numeric GUM_SCALAR >
452 return _iter_ == _set_.end();
453 }
454
455 template < GUM_Numeric GUM_SCALAR >
457 return _iter_ != from._iter_;
458 }
459
460 template < GUM_Numeric GUM_SCALAR >
462 return _iter_ == from._iter_;
463 }
464
465 template < GUM_Numeric GUM_SCALAR >
469
470 template < GUM_Numeric GUM_SCALAR >
474
475 template < GUM_Numeric GUM_SCALAR >
480
481 template < GUM_Numeric GUM_SCALAR >
486
487 template < GUM_Numeric GUM_SCALAR >
491
492 template < GUM_Numeric GUM_SCALAR >
498
499 template < GUM_Numeric GUM_SCALAR >
505
506 template < GUM_Numeric GUM_SCALAR >
508 return _iter_ == _set_.end();
509 }
510
511 template < GUM_Numeric GUM_SCALAR >
513 const RefConstIterator& from) const {
514 return _iter_ != from._iter_;
515 }
516
517 template < GUM_Numeric GUM_SCALAR >
519 const RefConstIterator& from) const {
520 return _iter_ == from._iter_;
521 }
522
523 template < GUM_Numeric GUM_SCALAR >
528
529 template < GUM_Numeric GUM_SCALAR >
534
535 template < GUM_Numeric GUM_SCALAR >
539
540 template < GUM_Numeric GUM_SCALAR >
545
546 template < GUM_Numeric GUM_SCALAR >
549 return _referingAttr_.begin();
550 }
551
552 template < GUM_Numeric GUM_SCALAR >
555 return _referingAttr_.end();
556 }
557
558 template < GUM_Numeric GUM_SCALAR >
559 std::vector< std::pair< PRMInstance< GUM_SCALAR >*, std::string > >&
563
564 template < GUM_Numeric GUM_SCALAR >
565 const std::vector< std::pair< PRMInstance< GUM_SCALAR >*, std::string > >&
567 return *(_referingAttr_[id]);
568 }
569
570 template < GUM_Numeric GUM_SCALAR >
572 auto p = _referingAttr_.tryGet(id);
573 return p && (!(*p)->empty());
574 }
575
576 template < GUM_Numeric GUM_SCALAR >
578 const auto& type_attr
579 = static_cast< const PRMAttribute< GUM_SCALAR >& >(type().get(attr->safeName()));
580 try {
581 attr->copyCpf(bijection(), type_attr);
582 } catch (NotFound const&) {
583 // a parent reached through a reference slot is missing from the bijection
585 "cannot build the CPT of " << name() << "." << attr->name()
586 << ": a reference slot of " << name()
587 << " is probably not assigned")
588 }
589 GUM_ASSERT(attr->cpf().contains(attr->type().variable()));
590 }
591
592 } /* namespace prm */
593} /* namespace gum */
Headers of gum::prm::PRMInstance<GUM_SCALAR>.
Set of pairs of elements with fast search for both elements.
Definition bijection.h:1640
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:129
Exception : a looked-for element could not be found.
Exception: wrong PRMClassElement for this operation.
PRMType & type() override
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 void copyCpf(const Bijection< const DiscreteVariable *, const DiscreteVariable * > &bif, const PRMAttribute< GUM_SCALAR > &source)=0
See gum::PRMClassElement::elt_type().
const Tensor< GUM_SCALAR > & cpf() const override=0
See gum::PRMClassElement::cpf().
PRMType & type() override=0
See gum::PRMClassElement::type().
void addParent(const PRMClassElement< GUM_SCALAR > &elt) override=0
See gum::PRMClassElement::addParent_().
Abstract class representing an element of PRM class.
virtual ClassElementType elt_type() const =0
Return the type of class element this object is.
NodeId id() const
Returns the NodeId of this element in it's class DAG.
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:77
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
Set< PRMInstance< GUM_SCALAR > * >::const_iterator _iter_
RefConstIterator & operator=(const RefConstIterator &from)
bool operator!=(const RefConstIterator &from) const
RefConstIterator(const Set< PRMInstance< GUM_SCALAR > * > &set)
const PRMInstance< GUM_SCALAR > * operator->() const
Nested class to iterate over PRMReferenceSlot and PRMSlotChain<GUM_SCALAR> instantiations.
PRMInstance< GUM_SCALAR > & operator*() const
Set< PRMInstance< GUM_SCALAR > * >::iterator _iter_
Set< PRMInstance< GUM_SCALAR > * > & _set_
RefIterator(Set< PRMInstance< GUM_SCALAR > * > &set)
bool operator==(const RefIterator &from) const
PRMInstance< GUM_SCALAR > * operator->() const
RefIterator & operator=(const RefIterator &from)
bool operator!=(const RefIterator &from) 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...
const PRMInstance< GUM_SCALAR > & getInstance(NodeId id) const
Fast access to the first instance in a PRMReferenceSlot or PRMSlotChain<GUM_SCALAR>.
void instantiate()
Instantiate all nodes which requires it.
PRMInstance< GUM_SCALAR > & operator=(const PRMClass< GUM_SCALAR > &from)
Copy operator. Don't use it.
bool exists(NodeId id) const
Returns true if id matches an PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.
const iterator & end()
Returns a reference over the iterator at the end of the list of gum::prm::PRMAttribute<GUM_SCALAR> in...
typename NodeProperty< PRMAttribute< GUM_SCALAR > * >::const_iterator const_iterator
Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.
void _copyAttribute_(PRMAttribute< GUM_SCALAR > *source)
Used at construction to instantiate attributes.
NodeProperty< Set< PRMInstance< GUM_SCALAR > * > * > _referenceMap_
Mapping between the gum::prm::PRMReferenceSlot and gum::prm::PRMSlotChain<GUM_SCALAR> in type / and t...
prm_type obj_type() const override
Returns the PRM type of this object.
bool _instantiated_
True if this instance has been instantiated.
void _copyAggregates_(PRMAggregate< GUM_SCALAR > *source)
Used at construction to instantiate aggregates.
Bijection< const DiscreteVariable *, const DiscreteVariable * > _bijection_
A bijection used for MultiDim handling.
Size size() const
Returns the number of attributes in this PRMInstance<GUM_SCALAR>.
~PRMInstance() override
Destructor.
PRMClass< GUM_SCALAR > * _type_
The type of this PRMInstance<GUM_SCALAR>.
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>.
PRMAttribute< GUM_SCALAR > & get(NodeId id)
Getter on an PRMAttribute<GUM_SCALAR> of 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>.
bool hasRefAttr(NodeId id) const
Returns true if id has at least one referring PRMAttribute<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>.
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.
InvRefIterator beginInvRef()
Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.
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...
void _copyAttributeCPF_(PRMAttribute< GUM_SCALAR > *attr)
Copy the content of an PRMAttribute<GUM_SCALAR> from its Class<GUM_SCALAR> counterpart.
const InvRefIterator & endInvRef()
Alias to iterate over the gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.
PRMClass< GUM_SCALAR > & type()
Returns the type of this instance.
PRMInstance(std::string_view name, PRMClass< GUM_SCALAR > &type)
Default constructor of an 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.
void _addReferingInstance_(PRMSlotChain< GUM_SCALAR > *sc, PRMInstance< GUM_SCALAR > *i)
Add this as a referring instance over the attribute pointed by sc in i.
void _doInstantiate_()
Starts this instance instantiations.
iterator begin()
Returns an iterator at the begining of the list of gum::prm::PRMAttribute<GUM_SCALAR> in this PRMInst...
const Set< PRMInstance< GUM_SCALAR > * > & getInstances(NodeId id) const
Returns the Set of PRMInstance<GUM_SCALAR> referenced by id.
PRMObject(std::string_view name)
Constructor.
Definition PRMObject.cpp:62
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:90
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).
PRMScalarAttribute(std::string_view name, const PRMType &type, MultiDimImplementation< GUM_SCALAR > *impl=new MultiDimArray< GUM_SCALAR >())
Constructor used by gum::Class.
A PRMSlotChain represents a sequence of gum::prm::PRMClassElement<GUM_SCALAR> where the n-1 first gum...
PRMType & type() override
This is similar to the following call: this->lastElt().type().
PRMClassElement< GUM_SCALAR > & lastElt()
Returns the last element of the slot chain, typically this is an gum::PRMAttribute or a gum::PRMAggre...
Sequence< PRMClassElement< GUM_SCALAR > * > & chain()
Return the sequence representing the chain of elements in this PRMSlotChain.
bool isMultiple() const
Return true if this slot chain contains at least one multiple reference slot.
PRMClassElementContainer< GUM_SCALAR > & end()
Returns the PRMClassElement<GUM_SCALAR>Container over which this slot chain ends.
DiscreteVariable & variable()
Return a reference on the DiscreteVariable contained in this.
Definition PRMType_inl.h:65
#define GUM_ERROR(type, msg)
Definition exceptions.h:76
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