aGrUM 3.0.0
a C++ library for (probabilistic) graphical models
gum::prm::PRMFormAttribute< GUM_SCALAR > Class Template Reference

<agrum/PRM/elements/formAttribute.h> More...

#include <PRMFormAttribute.h>

Inheritance diagram for gum::prm::PRMFormAttribute< GUM_SCALAR >:
Collaboration diagram for gum::prm::PRMFormAttribute< GUM_SCALAR >:

Public Member Functions

 PRMFormAttribute (const PRMClass< GUM_SCALAR > &c, std::string_view name, const PRMType &type, MultiDimImplementation< std::string > *impl=new MultiDimArray< std::string >())
 ~PRMFormAttribute () override
PRMAttribute< GUM_SCALAR > * newFactory (const PRMClass< GUM_SCALAR > &c) const override
 See gum::prm::PRMAttribute.
PRMAttribute< GUM_SCALAR > * copy (Bijection< const DiscreteVariable *, const DiscreteVariable * > bij) const override
 See gum::prm::PRMAttribute.
void copyCpf (const Bijection< const DiscreteVariable *, const DiscreteVariable * > &bif, const PRMAttribute< GUM_SCALAR > &source) override
 See gum::prm::PRMAttribute.
PRMClassElement< GUM_SCALAR >::ClassElementType elt_type () const override
 See gum::prm::PRMAttribute.
PRMTypetype () override
 See gum::prm::PRMAttribute.
const PRMTypetype () const override
 See gum::prm::PRMAttribute.
const Tensor< GUM_SCALAR > & cpf () const override
 See gum::prm::PRMAttribute.
void addParent (const PRMClassElement< GUM_SCALAR > &elt) override
 See gum::prm::PRMAttribute.
void addChild (const PRMClassElement< GUM_SCALAR > &elt) override
 See gum::prm::PRMAttribute.
PRMAttribute< GUM_SCALAR > * getCastDescendant () const override
 See gum::prm::PRMAttribute.
void setAsCastDescendant (PRMAttribute< GUM_SCALAR > *attr) override
 See gum::prm::PRMAttribute.
void becomeCastDescendant (PRMType &subtype) override
 Change this attribute to be a cast descendant of a an attribute with type subtype.
virtual MultiDimImplementation< std::string > & formulas ()
virtual const MultiDimImplementation< std::string > & formulas () const
void swap (const PRMType &old_type, const PRMType &new_type) override
 Swap old_type with new_type in the PRMClassElement cpt.
Getters & setters
virtual void overload (PRMAttribute< GUM_SCALAR > *source)
 Set this as overload of source (necessayr to preserver internal pointers for MultiDims).
Getters & setters
NodeId id () const
 Returns the NodeId of this element in it's class DAG.
virtual void setId (NodeId id)
 Used to assign the id of this element.
PRMObject::prm_type obj_type () const override
Fast access to random variable's properties
const std::string & safeName () const
 Returns the safe name of this PRMClassElement, if any.
virtual std::string cast (const PRMType &t) const
 Returns the name of the cast descendant with PRMType t of this PRMClassElement.
Getters & setters.
const std::string & name () const
 Returns the name of this object.
void name (std::string_view 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).

Protected Member Functions

PRMTypetype_ () override
void type_ (PRMType *t) override

Protected Attributes

std::string safeName_
 The safe name of this PRMClassElement.

Private Member Functions

 PRMFormAttribute (const PRMFormAttribute &source)
PRMFormAttributeoperator= (const PRMFormAttribute &source)
void _fillCpf_ () const

Private Attributes

PRMType_type_
 The random variable type of this attribute.
Tensor< GUM_SCALAR > * _cpf_
 A pointer on the Tensor of this attribute.
MultiDimImplementation< std::string > * _formulas_
 A pointer on the Tensor of this attribute.
const PRMClass< GUM_SCALAR > * _class_
 A pointe toward the class of this attribute.
NodeId _id_
 The node's id of this element.
Private members.
std::string _name_

Built-in type

enum  ClassElementType {
  prm_attribute , prm_aggregate , prm_refslot , prm_slotchain ,
  prm_parameter
}
 Returns true if obj_ptr is of type PRMReferenceSlot. More...
static std::string enum2str (ClassElementType type)
 Returns true if obj_ptr is of type PRMReferenceSlot.
static INLINE bool isReferenceSlot (const PRMClassElement< GUM_SCALAR > &elt)
 Returns true if obj_ptr is of type PRMReferenceSlot.
static INLINE bool isAttribute (const PRMClassElement< GUM_SCALAR > &elt)
 Returns true if obj_ptr is of type PRMAttribute.
static INLINE bool isAggregate (const PRMClassElement< GUM_SCALAR > &elt)
 Return true if obj is of type PRMAggregate.
static INLINE bool isSlotChain (const PRMClassElement< GUM_SCALAR > &elt)
 Return true if obj is of type PRMSlotChain.
static INLINE bool isParameter (const PRMClassElement< GUM_SCALAR > &elt)
 Return true if obj is of type PRMParameter.

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 enum2str (prm_type type)
 Returns the string representation of a PRMObject.
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 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.

Detailed Description

template<GUM_Numeric GUM_SCALAR>
class gum::prm::PRMFormAttribute< GUM_SCALAR >

<agrum/PRM/elements/formAttribute.h>

PRMFormAttribute is a member of a Class in a PRM.

See also
PRM PRMFactory Class PRMClassElement PRMType<GUM_SCALAR> Tensor PRMAttribute

Definition at line 70 of file PRMFormAttribute.h.

Member Enumeration Documentation

◆ ClassElementType

template<GUM_Numeric GUM_SCALAR>
enum gum::prm::PRMClassElement::ClassElementType
inherited

Returns true if obj_ptr is of type PRMReferenceSlot.

Enumerator
prm_attribute 
prm_aggregate 
prm_refslot 
prm_slotchain 
prm_parameter 

Definition at line 109 of file PRMClassElement.h.

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

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

Constructor & Destructor Documentation

◆ PRMFormAttribute() [1/2]

template<GUM_Numeric GUM_SCALAR>
gum::prm::PRMFormAttribute< GUM_SCALAR >::PRMFormAttribute ( const PRMClass< GUM_SCALAR > & c,
std::string_view name,
const PRMType & type,
MultiDimImplementation< std::string > * impl = new MultiDimArray< std::string >() )

Definition at line 63 of file PRMFormAttribute_tpl.h.

66 :
68 _class_(&c) {
70 _formulas_->add(_type_->variable());
71 this->safeName_
73 }
PRMAttribute(std::string_view name)
Destructor.
std::string safeName_
The safe name of this PRMClassElement.
<agrum/PRM/elements/formAttribute.h>
const PRMClass< GUM_SCALAR > * _class_
A pointe toward the class of this attribute.
PRMType & type() override
See gum::prm::PRMAttribute.
Tensor< GUM_SCALAR > * _cpf_
A pointer on the Tensor of this attribute.
MultiDimImplementation< std::string > * _formulas_
A pointer on the Tensor of this attribute.
PRMFormAttribute(const PRMClass< GUM_SCALAR > &c, std::string_view name, const PRMType &type, MultiDimImplementation< std::string > *impl=new MultiDimArray< std::string >())
PRMType * _type_
The random variable type of this attribute.
const std::string & name() const
Returns the name of this object.
static std::string RIGHT_CAST()
Enumeration of the different types of objects handled by a PRM.
static std::string LEFT_CAST()
Enumeration of the different types of objects handled by a PRM.

References gum::prm::PRMAttribute< GUM_SCALAR >::PRMAttribute(), PRMFormAttribute(), _class_, _cpf_, _formulas_, _type_, gum::prm::PRMObject::LEFT_CAST(), gum::prm::PRMObject::name(), gum::prm::PRMObject::RIGHT_CAST(), gum::prm::PRMClassElement< GUM_SCALAR >::safeName_, and type().

Referenced by PRMFormAttribute(), PRMFormAttribute(), ~PRMFormAttribute(), copy(), copyCpf(), newFactory(), and operator=().

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

◆ ~PRMFormAttribute()

template<GUM_Numeric GUM_SCALAR>
gum::prm::PRMFormAttribute< GUM_SCALAR >::~PRMFormAttribute ( )
override

Definition at line 76 of file PRMFormAttribute_tpl.h.

76 {
78 delete _type_;
79 delete _cpf_;
80 delete _formulas_;
81 }

References PRMFormAttribute(), _cpf_, _formulas_, and _type_.

Here is the call graph for this function:

◆ PRMFormAttribute() [2/2]

template<GUM_Numeric GUM_SCALAR>
gum::prm::PRMFormAttribute< GUM_SCALAR >::PRMFormAttribute ( const PRMFormAttribute< GUM_SCALAR > & source)
private

Definition at line 260 of file PRMFormAttribute_tpl.h.

260 :
263 GUM_ERROR(OperationNotAllowed, "Cannot copy FormAttribute")
264 }
#define GUM_ERROR(type, msg)
Definition exceptions.h:76

References gum::prm::PRMAttribute< GUM_SCALAR >::PRMAttribute(), PRMFormAttribute(), GUM_ERROR, and gum::prm::PRMObject::name().

Here is the call graph for this function:

Member Function Documentation

◆ _fillCpf_()

template<GUM_Numeric GUM_SCALAR>
void gum::prm::PRMFormAttribute< GUM_SCALAR >::_fillCpf_ ( ) const
private

Definition at line 273 of file PRMFormAttribute_tpl.h.

273 {
274 try {
275 if (_cpf_) { delete _cpf_; }
276
278
279 for (auto var: _formulas_->variablesSequence()) {
280 _cpf_->add(*var);
281 }
282
283 auto params = _class_->scope();
284
287
288 for (inst.setFirst(), jnst.setFirst(); !(inst.end() || jnst.end());
289 inst.inc(), jnst.inc()) {
290 // With CPT defined using rules, empty values can appear
291 auto val = _formulas_->get(inst);
292 if (val.empty()) { val = "0.0"; }
293
294 Formula f(val);
295
296 for (auto item: params) {
297 f.variables().insert(item.first, item.second->value());
298 }
299
300 _cpf_->set(jnst, (GUM_SCALAR)f.result());
301 }
302
303 GUM_ASSERT(inst.end() && jnst.end());
304
305 } catch (Exception const&) { GUM_ERROR(NotFound, "undefined value in cpt") }
306 GUM_ASSERT(_formulas_->contains(_type_->variable()))
307 }

References _class_, _cpf_, _formulas_, _type_, gum::Instantiation::end(), GUM_ERROR, gum::Instantiation::inc(), gum::HashTable< Key, Val >::insert(), gum::Formula::result(), gum::Instantiation::setFirst(), and gum::Formula::variables().

Referenced by cpf().

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

◆ addChild()

template<GUM_Numeric GUM_SCALAR>
void gum::prm::PRMFormAttribute< GUM_SCALAR >::addChild ( const PRMClassElement< GUM_SCALAR > & elt)
overridevirtual

See gum::prm::PRMAttribute.

Implements gum::prm::PRMAttribute< GUM_SCALAR >.

Definition at line 193 of file PRMFormAttribute_tpl.h.

193{}

◆ addParent()

template<GUM_Numeric GUM_SCALAR>
void gum::prm::PRMFormAttribute< GUM_SCALAR >::addParent ( const PRMClassElement< GUM_SCALAR > & elt)
overridevirtual

See gum::prm::PRMAttribute.

Implements gum::prm::PRMAttribute< GUM_SCALAR >.

Definition at line 175 of file PRMFormAttribute_tpl.h.

175 {
176 try {
177 if (_cpf_) {
178 delete _cpf_;
179 _cpf_ = 0;
180 }
181 _formulas_->add(elt.type().variable());
182 } catch (DuplicateElement const&) {
183 GUM_ERROR(DuplicateElement, elt.name() << " as parent of " << this->name())
184 } catch (OperationNotAllowed const&) {
186 elt.name() << " of wrong type as parent of " << this->name();)
187 }
188
189 GUM_ASSERT(_formulas_->contains(_type_->variable()));
190 }
DiscreteVariable & variable()
Return a reference on the DiscreteVariable contained in this.
Definition PRMType_inl.h:65

References _cpf_, _formulas_, _type_, GUM_ERROR, gum::prm::PRMObject::name(), gum::prm::PRMClassElement< GUM_SCALAR >::type(), and gum::prm::PRMType::variable().

Here is the call graph for this function:

◆ becomeCastDescendant()

template<GUM_Numeric GUM_SCALAR>
void gum::prm::PRMFormAttribute< GUM_SCALAR >::becomeCastDescendant ( PRMType & subtype)
overridevirtual

Change this attribute to be a cast descendant of a an attribute with type subtype.

Implements gum::prm::PRMAttribute< GUM_SCALAR >.

Definition at line 235 of file PRMFormAttribute_tpl.h.

235 {
236 delete _formulas_;
237
239 _formulas_->add(type().variable());
240 _formulas_->add(subtype.variable());
241
243
244 for (inst.setFirst(); !inst.end(); inst.inc()) {
245 auto my_pos = inst.pos(subtype.variable());
246 if (subtype.label_map()[my_pos] == inst.pos(type().variable())) {
247 _formulas_->set(inst, "1");
248 } else {
249 _formulas_->set(inst, "0");
250 }
251 }
252
253 if (_cpf_) {
254 delete _cpf_;
255 _cpf_ = nullptr;
256 }
257 }

References _cpf_, _formulas_, gum::Instantiation::end(), gum::Instantiation::inc(), gum::prm::PRMType::label_map(), gum::Instantiation::pos(), gum::Instantiation::setFirst(), type(), and gum::prm::PRMType::variable().

Here is the call graph for this function:

◆ cast()

template<GUM_Numeric GUM_SCALAR>
std::string gum::prm::PRMClassElement< GUM_SCALAR >::cast ( const PRMType & t) const
virtualinherited

Returns the name of the cast descendant with PRMType t of this PRMClassElement.

Parameters
tThe type in which we want to cast this PRMClassElement.
Exceptions
OperationNotAllowedIf the cast is impossible.

Definition at line 93 of file PRMClassElement_tpl.h.

93 {
94 if (type().isSubTypeOf(t)) {
96 } else {
97 GUM_ERROR(OperationNotAllowed, "illegal cast")
98 }
99 }
Abstract class representing an element of PRM class.
virtual PRMType & type()=0
Return a reference over the gum::PRMType of this class element.

References GUM_ERROR, gum::prm::PRMObject::LEFT_CAST(), gum::prm::PRMObject::name(), gum::prm::PRMType::name(), gum::prm::PRMObject::RIGHT_CAST(), and type().

Referenced by gum::prm::PRMFactory< GUM_SCALAR >::addNoisyOrCompound(), gum::prm::PRMAggregate< GUM_SCALAR >::getCastDescendant(), gum::prm::PRMFormAttribute< GUM_SCALAR >::getCastDescendant(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::getCastDescendant(), gum::prm::PRMFormAttribute< GUM_SCALAR >::setAsCastDescendant(), and gum::prm::PRMScalarAttribute< GUM_SCALAR >::setAsCastDescendant().

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

◆ copy()

template<GUM_Numeric GUM_SCALAR>
PRMAttribute< GUM_SCALAR > * gum::prm::PRMFormAttribute< GUM_SCALAR >::copy ( Bijection< const DiscreteVariable *, const DiscreteVariable * > bij) const
overridevirtual

See gum::prm::PRMAttribute.

Implements gum::prm::PRMAttribute< GUM_SCALAR >.

Definition at line 92 of file PRMFormAttribute_tpl.h.

93 {
94 auto copy = new PRMFormAttribute< GUM_SCALAR >(*_class_, this->name(), this->type());
95 for (auto var: _formulas_->variablesSequence()) {
96 if (var != &(_type_->variable())) { copy->_formulas_->add(*var); }
97 }
98
99 Instantiation inst(*(copy->_formulas_)), jnst(*_formulas_);
100 for (inst.setFirst(), jnst.setFirst(); !(inst.end() || jnst.end()); inst.inc(), jnst.inc()) {
101 copy->_formulas_->set(inst, _formulas_->get(jnst));
102 }
103
104 GUM_ASSERT(copy->_formulas_->contains(copy->_type_->variable()));
105 return copy;
106 }
PRMAttribute< GUM_SCALAR > * copy(Bijection< const DiscreteVariable *, const DiscreteVariable * > bij) const override
See gum::prm::PRMAttribute.

References gum::prm::PRMAttribute< GUM_SCALAR >::PRMAttribute(), PRMFormAttribute(), _class_, _formulas_, _type_, copy(), gum::Instantiation::end(), gum::Instantiation::inc(), gum::prm::PRMObject::name(), gum::Instantiation::setFirst(), and type().

Referenced by copy().

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

◆ copyCpf()

template<GUM_Numeric GUM_SCALAR>
void gum::prm::PRMFormAttribute< GUM_SCALAR >::copyCpf ( const Bijection< const DiscreteVariable *, const DiscreteVariable * > & bif,
const PRMAttribute< GUM_SCALAR > & source )
overridevirtual

See gum::prm::PRMAttribute.

Implements gum::prm::PRMAttribute< GUM_SCALAR >.

Definition at line 109 of file PRMFormAttribute_tpl.h.

111 {
112 delete _formulas_;
114
115 for (const auto& var: source.cpf().variablesSequence()) {
116 _formulas_->add(*(bij.second(var)));
117 }
118
119 if (dynamic_cast< const PRMFormAttribute< GUM_SCALAR >* >(&source)) {
120 const auto& src = static_cast< const PRMFormAttribute< GUM_SCALAR >& >(source);
121
123
124 for (inst.setFirst(), jnst.setFirst(); !(inst.end() || jnst.end());
125 inst.inc(), jnst.inc()) {
127 }
128
129 GUM_ASSERT(inst.end() && jnst.end());
130
131 } else {
133
134 for (inst.setFirst(), jnst.setFirst(); !(inst.end() || jnst.end());
135 inst.inc(), jnst.inc()) {
136 auto val = std::to_string(source.cpf().get(jnst));
137 _formulas_->set(inst, val);
138 }
139
140 GUM_ASSERT(inst.end() && jnst.end());
141 }
142
143 if (_cpf_) {
144 delete _cpf_;
145 _cpf_ = 0;
146 }
147
148 GUM_ASSERT(_formulas_->contains(_type_->variable()));
149 GUM_ASSERT(!_formulas_->contains(source.type().variable()));
150 }
virtual GUM_ELEMENT get(const Instantiation &i) const
Returns the value pointed by i.
const Tensor< GUM_SCALAR > & cpf() const override
See gum::prm::PRMAttribute.

References gum::prm::PRMAttribute< GUM_SCALAR >::PRMAttribute(), PRMFormAttribute(), _cpf_, _formulas_, _type_, gum::prm::PRMAttribute< GUM_SCALAR >::cpf(), gum::Instantiation::end(), gum::Instantiation::inc(), gum::BijectionImplementation< T1, T2, Gen >::second(), gum::Instantiation::setFirst(), gum::prm::PRMAttribute< GUM_SCALAR >::type(), and gum::prm::PRMType::variable().

Here is the call graph for this function:

◆ cpf()

template<GUM_Numeric GUM_SCALAR>
const Tensor< GUM_SCALAR > & gum::prm::PRMFormAttribute< GUM_SCALAR >::cpf ( ) const
overridevirtual

See gum::prm::PRMAttribute.

Implements gum::prm::PRMAttribute< GUM_SCALAR >.

Definition at line 169 of file PRMFormAttribute_tpl.h.

169 {
170 if (_cpf_ == 0) { _fillCpf_(); }
171 return *_cpf_;
172 }

References _cpf_, and _fillCpf_().

Here is the call graph for this function:

◆ elt_type()

template<GUM_Numeric GUM_SCALAR>
PRMClassElement< GUM_SCALAR >::ClassElementType gum::prm::PRMFormAttribute< GUM_SCALAR >::elt_type ( ) const
overridevirtual

◆ enum2str() [1/2]

template<GUM_Numeric GUM_SCALAR>
std::string gum::prm::PRMClassElement< GUM_SCALAR >::enum2str ( ClassElementType type)
staticinherited

Returns true if obj_ptr is of type PRMReferenceSlot.

Definition at line 102 of file PRMClassElement_tpl.h.

102 {
103 switch (type) {
104 case prm_attribute : return "prm_attribute";
105
106 case prm_aggregate : return "prm_aggregate";
107
108 case prm_refslot : return "prm_refslot";
109
110 case prm_slotchain : return "prm_slotchain";
111
112 case prm_parameter : return "prm_parameter";
113
114 default : return "unknown";
115 }
116 }

References prm_aggregate, prm_attribute, prm_parameter, prm_refslot, prm_slotchain, and type().

Here is the call graph for this function:

◆ enum2str() [2/2]

INLINE std::string gum::prm::PRMObject::enum2str ( prm_type type)
staticinherited

Returns the string representation of a PRMObject.

Definition at line 75 of file PRMObject_inl.h.

75 {
76 switch (type) {
77 case prm_type::CLASS : return "PRMType::CLASS";
78
79 case prm_type::CLASS_ELT : return "PRMType::CLASS_ELT";
80
81 case prm_type::TYPE : return "PRMType::TYPE";
82
83 case prm_type::SYSTEM : return "PRMType::SYSTEM";
84
85 case prm_type::INSTANCE : return "PRMType::INSTANCE";
86
87 case prm_type::PRM_INTERFACE : return "PRMType::PRM_INTERFACE";
88
89 default : return "unknown";
90 }
91 }

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

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

Here is the caller graph for this function:

◆ formulas() [1/2]

template<GUM_Numeric GUM_SCALAR>
MultiDimImplementation< std::string > & gum::prm::PRMFormAttribute< GUM_SCALAR >::formulas ( )
virtual

Definition at line 310 of file PRMFormAttribute_tpl.h.

310 {
311 if (_cpf_) {
312 delete _cpf_;
313 _cpf_ = 0;
314 }
315 return *_formulas_;
316 }

References _cpf_, and _formulas_.

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

Here is the caller graph for this function:

◆ formulas() [2/2]

template<GUM_Numeric GUM_SCALAR>
const MultiDimImplementation< std::string > & gum::prm::PRMFormAttribute< GUM_SCALAR >::formulas ( ) const
virtual

Definition at line 319 of file PRMFormAttribute_tpl.h.

319 {
320 return *_formulas_;
321 }

References _formulas_.

◆ getCastDescendant()

template<GUM_Numeric GUM_SCALAR>
PRMAttribute< GUM_SCALAR > * gum::prm::PRMFormAttribute< GUM_SCALAR >::getCastDescendant ( ) const
overridevirtual

See gum::prm::PRMAttribute.

Implements gum::prm::PRMAttribute< GUM_SCALAR >.

Definition at line 196 of file PRMFormAttribute_tpl.h.

196 {
197 if (!type().isSubType()) {
198 GUM_ERROR(OperationNotAllowed, "this ScalarAttribute can not have cast descendant")
199 }
201
202 cast->addParent(*this);
203
205 DiscreteVariable& cast_var = cast->type().variable();
206 Instantiation inst(cast->cpf());
207
208 for (inst.setFirst(); !inst.end(); inst.inc()) {
209 if (type().label_map()[inst.val(my_var)] == inst.val(cast_var)) {
210 cast->cpf().set(inst, 1);
211 } else {
212 cast->cpf().set(inst, 0);
213 }
214 }
215
216 GUM_ASSERT(_formulas_->contains(_type_->variable()));
217 return cast;
218 }
virtual std::string cast(const PRMType &t) const
Returns the name of the cast descendant with PRMType t of this PRMClassElement.

References gum::prm::PRMAttribute< GUM_SCALAR >::PRMAttribute(), _formulas_, _type_, gum::prm::PRMClassElement< GUM_SCALAR >::cast(), gum::Instantiation::end(), GUM_ERROR, gum::Instantiation::inc(), gum::prm::PRMObject::name(), gum::Instantiation::setFirst(), type(), and gum::Instantiation::val().

Here is the call graph for this function:

◆ id()

template<GUM_Numeric GUM_SCALAR>
NodeId gum::prm::PRMClassElement< GUM_SCALAR >::id ( ) const
inherited

Returns the NodeId of this element in it's class DAG.

Definition at line 73 of file PRMClassElement_tpl.h.

73 {
74 return _id_;
75 }
NodeId _id_
The node's id of this element.

References _id_.

Referenced by PRMClassElement(), gum::prm::PRMClass< GUM_SCALAR >::_addCastDescendants_(), gum::prm::PRMClass< GUM_SCALAR >::_addCastDescendants_(), gum::prm::PRMInterface< GUM_SCALAR >::_addCastDescendants_(), gum::prm::PRMClass< GUM_SCALAR >::_checkInterface_(), gum::prm::PRMClass< GUM_SCALAR >::_checkRefInterface_(), gum::prm::PRMInstance< GUM_SCALAR >::_copyAggregates_(), gum::prm::PRMInstance< GUM_SCALAR >::_copyAttribute_(), gum::prm::PRMSlotChain< GUM_SCALAR >::_copyLastElt_(), gum::prm::SVE< GUM_SCALAR >::_getAggTensor_(), gum::prm::PRMSystem< GUM_SCALAR >::_groundRef_(), gum::prm::PRMClass< GUM_SCALAR >::_inheritClass_(), gum::prm::ClassBayesNet< GUM_SCALAR >::_init_(), gum::prm::InstanceBayesNet< GUM_SCALAR >::_init_(), gum::prm::PRMInstance< GUM_SCALAR >::_instantiateSlotChain_(), gum::prm::PRMClass< GUM_SCALAR >::_overloadAttribute_(), gum::prm::PRMInterface< GUM_SCALAR >::_overloadAttribute_(), gum::prm::PRMClass< GUM_SCALAR >::_overloadParameter_(), gum::prm::PRMClass< GUM_SCALAR >::_overloadReference_(), gum::prm::PRMInterface< GUM_SCALAR >::_overloadReferenceSlot_(), gum::prm::PRMClass< GUM_SCALAR >::add(), gum::prm::PRMInterface< GUM_SCALAR >::add(), gum::prm::PRMClass< GUM_SCALAR >::addArc(), gum::prm::PRMClass< GUM_SCALAR >::inheritAggregates(), gum::prm::PRMClass< GUM_SCALAR >::overload(), gum::prm::PRMInterface< GUM_SCALAR >::overload(), gum::prm::SVE< GUM_SCALAR >::posterior_(), gum::prm::SVED< GUM_SCALAR >::posterior_(), setId(), and gum::prm::PRMFactory< GUM_SCALAR >::startAttribute().

◆ isAggregate()

template<GUM_Numeric GUM_SCALAR>
bool gum::prm::PRMClassElement< GUM_SCALAR >::isAggregate ( const PRMClassElement< GUM_SCALAR > & elt)
staticinherited

Return true if obj is of type PRMAggregate.

Definition at line 129 of file PRMClassElement_tpl.h.

129 {
130 return elt.elt_type() == prm_aggregate;
131 }
virtual ClassElementType elt_type() const =0
Return the type of class element this object is.

References PRMClassElement(), elt_type(), and prm_aggregate.

Referenced by gum::prm::StructuredInference< GUM_SCALAR >::CData::CData(), gum::prm::PRMClass< GUM_SCALAR >::_checkInterface_(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_checkLocalParent_(), gum::prm::ClassBayesNet< GUM_SCALAR >::_init_(), gum::prm::SVE< GUM_SCALAR >::_initLiftedNodes_(), gum::prm::SVED< GUM_SCALAR >::_initLiftedNodes_(), gum::prm::PRMClass< GUM_SCALAR >::completeInheritance(), gum::prm::PRMFactory< GUM_SCALAR >::continueAggregator(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::setInputNode(), and gum::prm::PRMClassElementContainer< GUM_SCALAR >::setOutputNode().

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

◆ isAttribute()

◆ isClass()

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

Returns true if obj_ptr is of type Class.

Definition at line 93 of file PRMObject_inl.h.

93 {
94 return obj.obj_type() == prm_type::CLASS;
95 }

References PRMObject().

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)
staticinherited

Returns true if obj_ptr is of type PRMInstance.

Definition at line 101 of file PRMObject_inl.h.

101 {
102 return obj.obj_type() == prm_type::INSTANCE;
103 }

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

Here is the call graph for this function:

◆ isInterface()

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

Returns true if obj_ptr is of type PRMInterface.

Definition at line 97 of file PRMObject_inl.h.

97 {
98 return obj.obj_type() == prm_type::PRM_INTERFACE;
99 }

◆ isParameter()

template<GUM_Numeric GUM_SCALAR>
bool gum::prm::PRMClassElement< GUM_SCALAR >::isParameter ( const PRMClassElement< GUM_SCALAR > & elt)
staticinherited

Return true if obj is of type PRMParameter.

Definition at line 139 of file PRMClassElement_tpl.h.

139 {
140 return elt.elt_type() == prm_parameter;
141 }

References PRMClassElement(), elt_type(), and prm_parameter.

Referenced by gum::prm::o3prm::O3SystemFactory< GUM_SCALAR >::_checkParameters_(), and gum::prm::PRMClass< GUM_SCALAR >::add().

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

◆ isReferenceSlot()

template<GUM_Numeric GUM_SCALAR>
bool gum::prm::PRMClassElement< GUM_SCALAR >::isReferenceSlot ( const PRMClassElement< GUM_SCALAR > & elt)
staticinherited

Returns true if obj_ptr is of type PRMReferenceSlot.

Definition at line 119 of file PRMClassElement_tpl.h.

119 {
120 return elt.elt_type() == prm_refslot;
121 }

References PRMClassElement(), elt_type(), and prm_refslot.

Referenced by gum::prm::o3prm::O3SystemFactory< GUM_SCALAR >::_checkAssignments_(), gum::prm::o3prm::O3SystemFactory< GUM_SCALAR >::_checkIncrements_(), gum::prm::o3prm::O3InterfaceFactory< GUM_SCALAR >::_checkOverloadLegality_(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_checkReferenceSlot_(), gum::prm::PRMInterface< GUM_SCALAR >::add(), and gum::prm::PRMFactory< GUM_SCALAR >::setReferenceSlot().

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

◆ isSlotChain()

template<GUM_Numeric GUM_SCALAR>
bool gum::prm::PRMClassElement< GUM_SCALAR >::isSlotChain ( const PRMClassElement< GUM_SCALAR > & elt)
staticinherited

Return true if obj is of type PRMSlotChain.

Definition at line 134 of file PRMClassElement_tpl.h.

134 {
135 return elt.elt_type() == prm_slotchain;
136 }

References PRMClassElement(), elt_type(), and prm_slotchain.

Referenced by gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::_checkLocalParent_(), gum::prm::PRMFactory< GUM_SCALAR >::_retrieveInputs_(), gum::prm::PRMClass< GUM_SCALAR >::add(), and gum::prm::PRMFactory< GUM_SCALAR >::addNoisyOrCompound().

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

◆ LEFT_CAST()

INLINE std::string gum::prm::PRMObject::LEFT_CAST ( )
staticinherited

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

71{ 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 57 of file PRMObject_inl.h.

57{ return _name_; }
std::string _name_
Definition PRMObject.h:193

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::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::PRMSlotChain< GUM_SCALAR >::_copyLastElt_(), gum::prm::PRMSystem< GUM_SCALAR >::_groundAgg_(), gum::prm::PRMSystem< GUM_SCALAR >::_groundRef_(), gum::prm::PRMSystem< GUM_SCALAR >::_groundTensor_(), gum::prm::PRMSystem< double >::_groundTensor_(), gum::prm::PRMClass< GUM_SCALAR >::_inheritClass_(), gum::prm::PRMClass< GUM_SCALAR >::_overloadAttribute_(), gum::prm::PRMInterface< 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::PRMAggregate< GUM_SCALAR >::getCastDescendant(), 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< 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!=(), 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::PRMInterface< GUM_SCALAR >::operator[](), gum::prm::PRMClass< GUM_SCALAR >::overload(), gum::prm::PRMInterface< GUM_SCALAR >::overload(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::PRMClassElementContainterConstIterator, gum::prm::PRMFormAttribute< GUM_SCALAR >::setAsCastDescendant(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::setAsCastDescendant(), 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 ( std::string_view name)
inherited

Change the name of the PRM Object.

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

Definition at line 61 of file PRMObject_inl.h.

61{ _name_ = name; }

References _name_, and name().

Here is the call graph for this function:

◆ newFactory()

template<GUM_Numeric GUM_SCALAR>
PRMAttribute< GUM_SCALAR > * gum::prm::PRMFormAttribute< GUM_SCALAR >::newFactory ( const PRMClass< GUM_SCALAR > & c) const
overridevirtual

See gum::prm::PRMAttribute.

Implements gum::prm::PRMAttribute< GUM_SCALAR >.

Definition at line 85 of file PRMFormAttribute_tpl.h.

85 {
86 auto impl
87 = static_cast< MultiDimImplementation< std::string >* >(this->_formulas_->newFactory());
88 return new PRMFormAttribute< GUM_SCALAR >(c, this->name(), this->type(), impl);
89 }

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

Here is the call graph for this function:

◆ obj_type()

template<GUM_Numeric GUM_SCALAR>
PRMObject::prm_type gum::prm::PRMClassElement< GUM_SCALAR >::obj_type ( ) const
overridevirtualinherited
See also
gum::PRMObject::obj_type().

Implements gum::prm::PRMObject.

Definition at line 78 of file PRMClassElement_tpl.h.

78 {
80 }

References gum::prm::PRMObject::CLASS_ELT.

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

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

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

Here is the call graph for this function:

◆ operator=()

template<GUM_Numeric GUM_SCALAR>
PRMFormAttribute< GUM_SCALAR > & gum::prm::PRMFormAttribute< GUM_SCALAR >::operator= ( const PRMFormAttribute< GUM_SCALAR > & source)
private

Definition at line 268 of file PRMFormAttribute_tpl.h.

268 {
269 GUM_ERROR(OperationNotAllowed, "Cannot copy FormAttribute")
270 }

References PRMFormAttribute(), and GUM_ERROR.

Here is the call graph for this function:

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

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

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

Here is the call graph for this function:

◆ overload()

template<GUM_Numeric GUM_SCALAR>
void gum::prm::PRMAttribute< GUM_SCALAR >::overload ( PRMAttribute< GUM_SCALAR > * source)
virtualinherited

Set this as overload of source (necessayr to preserver internal pointers for MultiDims).

Definition at line 74 of file PRMAttribute_tpl.h.

74 {
75 auto old_type = this->type_();
76 this->type_(source->type_());
78 }
PRMAttribute is a member of a Class in a PRM.
virtual PRMType * type_()=0

References PRMAttribute(), and type_().

Referenced by gum::prm::PRMClass< GUM_SCALAR >::_overloadAttribute_(), and gum::prm::PRMInterface< GUM_SCALAR >::_overloadAttribute_().

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

◆ RIGHT_CAST()

INLINE std::string gum::prm::PRMObject::RIGHT_CAST ( )
staticinherited

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

73{ 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:

◆ safeName()

template<GUM_Numeric GUM_SCALAR>
const std::string & gum::prm::PRMClassElement< GUM_SCALAR >::safeName ( ) const
inherited

Returns the safe name of this PRMClassElement, if any.

This will only work if this PRMClassElement is an PRMAttribute or an PRMAggregate.

Returns
Returns the safe name of this PRMClassElement.
Exceptions
NotFound&Raised if this PRMClassElement does not have any safe name.

Definition at line 88 of file PRMClassElement_tpl.h.

88 {
89 return safeName_;
90 }

References safeName_.

Referenced by gum::prm::__print_attribute__(), gum::prm::PRMClass< GUM_SCALAR >::_addCastDescendants_(), gum::prm::PRMClass< GUM_SCALAR >::_addCastDescendants_(), gum::prm::PRMInterface< GUM_SCALAR >::_addCastDescendants_(), gum::prm::PRMFactory< GUM_SCALAR >::_addParent_(), gum::prm::PRMInstance< GUM_SCALAR >::_copyAttributeCPF_(), gum::prm::SVED< GUM_SCALAR >::_getAggTensor_(), gum::prm::PRMSystem< GUM_SCALAR >::_groundRef_(), gum::prm::PRMSystem< GUM_SCALAR >::_groundTensor_(), gum::prm::PRMClass< GUM_SCALAR >::_inheritClass_(), gum::prm::PRMClass< GUM_SCALAR >::_overloadAggregate_(), gum::prm::PRMClass< GUM_SCALAR >::_overloadAttribute_(), gum::prm::PRMInterface< 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::StructuredInference< GUM_SCALAR >::_str_(), gum::prm::StructuredInference< GUM_SCALAR >::_str_(), gum::prm::PRMClass< GUM_SCALAR >::add(), gum::prm::PRMInterface< GUM_SCALAR >::add(), gum::prm::PRMFactory< GUM_SCALAR >::addAggregator(), gum::prm::PRMFactory< GUM_SCALAR >::addAttribute(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::belongsTo(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::getIOFlag_(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::getIOFlag_(), gum::prm::PRMClass< GUM_SCALAR >::inheritAggregates(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::isInnerNode(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::isInputNode(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::setInputNode(), gum::prm::PRMClassElementContainer< GUM_SCALAR >::setIOFlag_(), and gum::prm::PRMClassElementContainer< GUM_SCALAR >::setOutputNode().

◆ setAsCastDescendant()

template<GUM_Numeric GUM_SCALAR>
void gum::prm::PRMFormAttribute< GUM_SCALAR >::setAsCastDescendant ( PRMAttribute< GUM_SCALAR > * attr)
overridevirtual

See gum::prm::PRMAttribute.

Implements gum::prm::PRMAttribute< GUM_SCALAR >.

Definition at line 221 of file PRMFormAttribute_tpl.h.

221 {
222 try {
223 type().setSuper(cast->type());
224 } catch (OperationNotAllowed const&) {
225 GUM_ERROR(OperationNotAllowed, "this ScalarAttribute can not have cast descendant")
226 } catch (TypeError const&) {
228 std::format("{} is not a subtype of {}", type().name(), cast->type().name()))
229 }
230
231 cast->becomeCastDescendant(type());
232 }
void setSuper(PRMType &t)
Changes the PRMType of this PRMType super.
Definition PRMType_inl.h:89

References gum::prm::PRMAttribute< GUM_SCALAR >::PRMAttribute(), gum::prm::PRMClassElement< GUM_SCALAR >::cast(), GUM_ERROR, gum::prm::PRMObject::name(), and type().

Here is the call graph for this function:

◆ setId()

template<GUM_Numeric GUM_SCALAR>
void gum::prm::PRMClassElement< GUM_SCALAR >::setId ( NodeId id)
virtualinherited

◆ swap()

template<GUM_Numeric GUM_SCALAR>
void gum::prm::PRMFormAttribute< GUM_SCALAR >::swap ( const PRMType & old_type,
const PRMType & new_type )
overridevirtual

Swap old_type with new_type in the PRMClassElement cpt.

Implements gum::prm::PRMAttribute< GUM_SCALAR >.

Definition at line 324 of file PRMFormAttribute_tpl.h.

324 {
325 if (&(old_type) == _type_) {
326 GUM_ERROR(OperationNotAllowed, "Cannot replace attribute own type")
327 }
328 if (old_type->domainSize() != new_type->domainSize()) {
329 GUM_ERROR(OperationNotAllowed, "Cannot replace types with difference domain size")
330 }
331 if (!_formulas_->contains(old_type.variable())) {
332 GUM_ERROR(NotFound, "could not find variable " + old_type.name())
333 }
334
335 auto old = _formulas_;
336
338
339 for (auto var: old->variablesSequence()) {
340 if (var != &(old_type.variable())) {
341 _formulas_->add(*var);
342 } else {
343 _formulas_->add(new_type.variable());
344 }
345 }
346
348
349 for (inst.setFirst(), jnst.setFirst(); !(inst.end() || jnst.end()); inst.inc(), jnst.inc()) {
350 _formulas_->set(inst, old->get(jnst));
351 }
352
353 delete old;
354
355 if (_cpf_) {
356 delete _cpf_;
357 _cpf_ = 0;
358 }
359
360 GUM_ASSERT(inst.end() && jnst.end());
361 GUM_ASSERT(_formulas_->contains(_type_->variable()));
362 GUM_ASSERT(!_formulas_->contains(new_type.variable()));
363 GUM_ASSERT(_formulas_->contains(new_type.variable()));
364 }

References _cpf_, _formulas_, _type_, gum::DiscreteVariable::domainSize(), gum::Instantiation::end(), GUM_ERROR, gum::Instantiation::inc(), gum::prm::PRMType::name(), gum::Instantiation::setFirst(), and gum::prm::PRMType::variable().

Here is the call graph for this function:

◆ type() [1/2]

template<GUM_Numeric GUM_SCALAR>
const PRMType & gum::prm::PRMFormAttribute< GUM_SCALAR >::type ( ) const
overridevirtual

See gum::prm::PRMAttribute.

Implements gum::prm::PRMAttribute< GUM_SCALAR >.

Definition at line 164 of file PRMFormAttribute_tpl.h.

164 {
165 return *_type_;
166 }

References _type_.

◆ type() [2/2]

template<GUM_Numeric GUM_SCALAR>
PRMType & gum::prm::PRMFormAttribute< GUM_SCALAR >::type ( )
overridevirtual

See gum::prm::PRMAttribute.

Implements gum::prm::PRMAttribute< GUM_SCALAR >.

Definition at line 159 of file PRMFormAttribute_tpl.h.

159 {
160 return *_type_;
161 }

References _type_.

Referenced by PRMFormAttribute(), becomeCastDescendant(), copy(), getCastDescendant(), newFactory(), and setAsCastDescendant().

Here is the caller graph for this function:

◆ type_() [1/2]

template<GUM_Numeric GUM_SCALAR>
PRMType * gum::prm::PRMFormAttribute< GUM_SCALAR >::type_ ( )
overrideprotectedvirtual

Implements gum::prm::PRMAttribute< GUM_SCALAR >.

Definition at line 367 of file PRMFormAttribute_tpl.h.

367 {
368 return _type_;
369 }

References _type_.

◆ type_() [2/2]

template<GUM_Numeric GUM_SCALAR>
void gum::prm::PRMFormAttribute< GUM_SCALAR >::type_ ( PRMType * t)
overrideprotectedvirtual

Implements gum::prm::PRMAttribute< GUM_SCALAR >.

Definition at line 372 of file PRMFormAttribute_tpl.h.

372 {
373 if (_type_->variable().domainSize() != t->variable().domainSize()) {
374 GUM_ERROR(OperationNotAllowed, "Cannot replace types with difference domain size")
375 }
376 auto old = _formulas_;
377
379
380 for (auto var: old->variablesSequence()) {
381 if (var != &(_type_->variable())) {
382 _formulas_->add(*var);
383 } else {
384 _formulas_->add(t->variable());
385 }
386 }
387
389
390 for (inst.setFirst(), jnst.setFirst(); !(inst.end() || jnst.end()); inst.inc(), jnst.inc()) {
391 _formulas_->set(inst, old->get(jnst));
392 }
393
394 delete old;
395
396 _type_ = t;
397
398 if (_cpf_) {
399 delete _cpf_;
400 _cpf_ = 0;
401 }
402
403 GUM_ASSERT(_formulas_->contains(_type_->variable()));
404 GUM_ASSERT(inst.end() && jnst.end());
405 }

References _cpf_, _formulas_, _type_, gum::DiscreteVariable::domainSize(), gum::Instantiation::end(), GUM_ERROR, gum::Instantiation::inc(), and gum::Instantiation::setFirst().

Here is the call graph for this function:

Member Data Documentation

◆ _class_

template<GUM_Numeric GUM_SCALAR>
const PRMClass< GUM_SCALAR >* gum::prm::PRMFormAttribute< GUM_SCALAR >::_class_
private

A pointe toward the class of this attribute.

Definition at line 140 of file PRMFormAttribute.h.

Referenced by PRMFormAttribute(), _fillCpf_(), and copy().

◆ _cpf_

template<GUM_Numeric GUM_SCALAR>
Tensor< GUM_SCALAR >* gum::prm::PRMFormAttribute< GUM_SCALAR >::_cpf_
mutableprivate

A pointer on the Tensor of this attribute.

Definition at line 134 of file PRMFormAttribute.h.

Referenced by PRMFormAttribute(), ~PRMFormAttribute(), _fillCpf_(), addParent(), becomeCastDescendant(), copyCpf(), cpf(), formulas(), swap(), and type_().

◆ _formulas_

template<GUM_Numeric GUM_SCALAR>
MultiDimImplementation< std::string >* gum::prm::PRMFormAttribute< GUM_SCALAR >::_formulas_
private

◆ _id_

template<GUM_Numeric GUM_SCALAR>
NodeId gum::prm::PRMClassElement< GUM_SCALAR >::_id_
privateinherited

The node's id of this element.

Definition at line 254 of file PRMClassElement.h.

Referenced by PRMClassElement(), id(), and setId().

◆ _name_

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

Definition at line 193 of file PRMObject.h.

Referenced by PRMObject(), PRMObject(), PRMObject(), name(), name(), operator!=(), operator=(), and operator==().

◆ _type_

template<GUM_Numeric GUM_SCALAR>
PRMType* gum::prm::PRMFormAttribute< GUM_SCALAR >::_type_
private

The random variable type of this attribute.

Definition at line 131 of file PRMFormAttribute.h.

Referenced by PRMFormAttribute(), ~PRMFormAttribute(), _fillCpf_(), addParent(), copy(), copyCpf(), getCastDescendant(), swap(), type(), type(), type_(), and type_().

◆ safeName_


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