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

Protected Attributes

std::string _safeName
 The safe name of this PRMClassElement. More...
 

Protected Member Functions

virtual PRMType_type ()
 
virtual void _type (PRMType *t)
 

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. More...
 
static INLINE bool isReferenceSlot (const PRMClassElement< GUM_SCALAR > &elt)
 Returns true if obj_ptr is of type PRMReferenceSlot. More...
 
static INLINE bool isAttribute (const PRMClassElement< GUM_SCALAR > &elt)
 Returns true if obj_ptr is of type PRMAttribute. More...
 
static INLINE bool isAggregate (const PRMClassElement< GUM_SCALAR > &elt)
 Return true if obj is of type PRMAggregate. More...
 
static INLINE bool isSlotChain (const PRMClassElement< GUM_SCALAR > &elt)
 Return true if obj is of type PRMSlotChain. More...
 
static INLINE bool isParameter (const PRMClassElement< GUM_SCALAR > &elt)
 Return true if obj is of type PRMParameter. More...
 

Built-in types.

enum  prm_type : char {
  prm_type::ALL, prm_type::CLASS, prm_type::PRM_INTERFACE, prm_type::CLASS_ELT,
  prm_type::TYPE, prm_type::SYSTEM, prm_type::INSTANCE
}
 Enumeration of the different types of objects handled by a PRM. More...
 
static std::string enum2str (prm_type type)
 Returns the string representation of a PRMObject. More...
 
static std::string LEFT_CAST ()
 Enumeration of the different types of objects handled by a PRM. More...
 
static std::string RIGHT_CAST ()
 Enumeration of the different types of objects handled by a PRM. More...
 
static INLINE bool isClass (const PRMObject &obj)
 Returns true if obj_ptr is of type Class. More...
 
static INLINE bool isInterface (const PRMObject &obj)
 Returns true if obj_ptr is of type PRMInterface. More...
 
static INLINE bool isInstance (const PRMObject &obj)
 Returns true if obj_ptr is of type PRMInstance. More...
 

Detailed Description

template<typename GUM_SCALAR>
class gum::prm::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> Potential PRMAttribute

Definition at line 50 of file PRMFormAttribute.h.

Member Enumeration Documentation

◆ ClassElementType

template<typename 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 95 of file PRMClassElement.h.

◆ prm_type

enum gum::prm::PRMObject::prm_type : char
stronginherited

Enumeration of the different types of objects handled by a PRM.

The "all" type is used to tell that we want any kind of PRMType (useful with iterators for example). No PRMObject will ever have "all" as type.

Enumerator
ALL 
CLASS 
PRM_INTERFACE 
CLASS_ELT 
TYPE 
SYSTEM 
INSTANCE 

Definition at line 69 of file PRMObject.h.

69  : char {
70  ALL,
71  CLASS,
72  PRM_INTERFACE,
73  CLASS_ELT,
74  TYPE,
75  SYSTEM,
76  INSTANCE
77  };

Constructor & Destructor Documentation

◆ PRMFormAttribute() [1/2]

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

Definition at line 43 of file PRMFormAttribute_tpl.h.

References gum::prm::PRMFormAttribute< GUM_SCALAR >::__formulas, gum::prm::PRMFormAttribute< GUM_SCALAR >::__type, gum::prm::PRMClassElement< GUM_SCALAR >::_safeName, gum::MultiDimImplementation< GUM_SCALAR >::add(), gum::prm::PRMObject::LEFT_CAST(), gum::Variable::name(), gum::prm::PRMObject::name(), and gum::prm::PRMObject::RIGHT_CAST().

47  :
48  PRMAttribute< GUM_SCALAR >(name),
49  __type(new PRMType(type)), __cpf(0), __formulas(impl), __class(&c) {
50  GUM_CONSTRUCTOR(PRMFormAttribute);
51  __formulas->add(__type->variable());
52  this->_safeName =
54  }
Potential< GUM_SCALAR > * __cpf
A pointer on the Potential of this attribute.
MultiDimImplementation< std::string > * __formulas
A pointer on the Potential of this attribute.
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
PRMFormAttribute(const PRMClass< GUM_SCALAR > &c, const std::string &name, const PRMType &type, MultiDimImplementation< std::string > *impl=new MultiDimArray< std::string >())
virtual void add(const DiscreteVariable &v) override
Adds a new var to the variables of the multidimensional matrix.
PRMType * __type
The random variable type of this attribute.
static std::string LEFT_CAST()
Enumeration of the different types of objects handled by a PRM.
Definition: PRMObject.h:79
const PRMClass< GUM_SCALAR > * __class
A pointe toward the class of this attribute.
const std::string & name() const
returns the name of the variable
static std::string RIGHT_CAST()
Enumeration of the different types of objects handled by a PRM.
Definition: PRMObject.h:80
virtual PRMType & type()
See gum::prm::PRMAttribute.
std::string _safeName
The safe name of this PRMClassElement.
+ Here is the call graph for this function:

◆ ~PRMFormAttribute()

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

Definition at line 57 of file PRMFormAttribute_tpl.h.

References gum::prm::PRMFormAttribute< GUM_SCALAR >::__cpf, gum::prm::PRMFormAttribute< GUM_SCALAR >::__formulas, and gum::prm::PRMFormAttribute< GUM_SCALAR >::__type.

57  {
58  GUM_DESTRUCTOR(PRMFormAttribute);
59  delete __type;
60  delete __cpf;
61  delete __formulas;
62  }
Potential< GUM_SCALAR > * __cpf
A pointer on the Potential of this attribute.
MultiDimImplementation< std::string > * __formulas
A pointer on the Potential of this attribute.
PRMFormAttribute(const PRMClass< GUM_SCALAR > &c, const std::string &name, const PRMType &type, MultiDimImplementation< std::string > *impl=new MultiDimArray< std::string >())
PRMType * __type
The random variable type of this attribute.

◆ PRMFormAttribute() [2/2]

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

Definition at line 257 of file PRMFormAttribute_tpl.h.

References GUM_ERROR, and gum::prm::PRMFormAttribute< GUM_SCALAR >::operator=().

258  :
259  PRMAttribute< GUM_SCALAR >(source.name()) {
260  GUM_CONS_CPY(PRMFormAttribute);
261  GUM_ERROR(OperationNotAllowed, "Cannot copy FormAttribute");
262  }
PRMFormAttribute(const PRMClass< GUM_SCALAR > &c, const std::string &name, const PRMType &type, MultiDimImplementation< std::string > *impl=new MultiDimArray< std::string >())
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the call graph for this function:

Member Function Documentation

◆ __fillCpf()

template<typename GUM_SCALAR >
void gum::prm::PRMFormAttribute< GUM_SCALAR >::__fillCpf ( ) const
private

Definition at line 271 of file PRMFormAttribute_tpl.h.

References gum::prm::PRMFormAttribute< GUM_SCALAR >::__class, gum::prm::PRMFormAttribute< GUM_SCALAR >::__cpf, gum::prm::PRMFormAttribute< GUM_SCALAR >::__formulas, gum::prm::PRMFormAttribute< GUM_SCALAR >::__type, gum::MultiDimImplementation< GUM_SCALAR >::contains(), gum::Instantiation::end(), gum::MultiDimContainer< GUM_SCALAR >::get(), GUM_ERROR, gum::Instantiation::inc(), gum::HashTable< Key, Val, Alloc >::insert(), gum::Formula::result(), gum::Instantiation::setFirst(), gum::Formula::variables(), and gum::MultiDimImplementation< GUM_SCALAR >::variablesSequence().

Referenced by gum::prm::PRMFormAttribute< GUM_SCALAR >::cpf().

271  {
272  try {
273  if (__cpf) { delete __cpf; }
274 
275  __cpf = new Potential< GUM_SCALAR >();
276 
277  for (auto var : __formulas->variablesSequence()) {
278  __cpf->add(*var);
279  }
280 
281  auto params = __class->scope();
282 
283  Instantiation inst(__formulas);
284  Instantiation jnst(__cpf);
285 
286  for (inst.setFirst(), jnst.setFirst(); !(inst.end() || jnst.end());
287  inst.inc(), jnst.inc()) {
288  // With CPT defined using rules, empty values can appear
289  auto val = __formulas->get(inst);
290  if (val == "") { val = "0.0"; }
291 
292  Formula f(val);
293 
294  for (auto item : params) {
295  f.variables().insert(item.first, item.second->value());
296  }
297 
298  __cpf->set(jnst, (GUM_SCALAR)f.result());
299  }
300 
301  GUM_ASSERT(inst.end() && jnst.end());
302 
303  } catch (Exception&) { GUM_ERROR(NotFound, "undefined value in cpt"); }
304  GUM_ASSERT(__formulas->contains(__type->variable()));
305  }
Potential< GUM_SCALAR > * __cpf
A pointer on the Potential of this attribute.
MultiDimImplementation< std::string > * __formulas
A pointer on the Potential of this attribute.
PRMType * __type
The random variable type of this attribute.
virtual const Sequence< const DiscreteVariable *> & variablesSequence() const override
Returns a const ref to the sequence of DiscreteVariable*.
const PRMClass< GUM_SCALAR > * __class
A pointe toward the class of this attribute.
virtual GUM_SCALAR get(const Instantiation &i) const
Returns the value pointed by i.
virtual bool contains(const DiscreteVariable &v) const override
Returns true if var is in *this.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _type() [1/2]

template<typename GUM_SCALAR >
PRMType * gum::prm::PRMFormAttribute< GUM_SCALAR >::_type ( )
protectedvirtual

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

Definition at line 370 of file PRMFormAttribute_tpl.h.

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

370  {
371  return __type;
372  }
PRMType * __type
The random variable type of this attribute.

◆ _type() [2/2]

template<typename GUM_SCALAR >
void gum::prm::PRMFormAttribute< GUM_SCALAR >::_type ( PRMType t)
protectedvirtual

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

Definition at line 375 of file PRMFormAttribute_tpl.h.

References gum::prm::PRMFormAttribute< GUM_SCALAR >::__cpf, gum::prm::PRMFormAttribute< GUM_SCALAR >::__formulas, gum::prm::PRMFormAttribute< GUM_SCALAR >::__type, gum::MultiDimImplementation< GUM_SCALAR >::add(), gum::MultiDimImplementation< GUM_SCALAR >::contains(), gum::DiscreteVariable::domainSize(), gum::Instantiation::end(), GUM_ERROR, gum::Instantiation::inc(), gum::MultiDimContainer< GUM_SCALAR >::set(), and gum::Instantiation::setFirst().

375  {
376  if (__type->variable().domainSize() != t->variable().domainSize()) {
377  GUM_ERROR(OperationNotAllowed,
378  "Cannot replace types with difference domain size");
379  }
380  auto old = __formulas;
381 
382  __formulas = new MultiDimArray< std::string >();
383 
384  for (auto var : old->variablesSequence()) {
385  if (var != &(__type->variable())) {
386  __formulas->add(*var);
387  } else {
388  __formulas->add(t->variable());
389  }
390  }
391 
392  Instantiation inst(__formulas), jnst(old);
393 
394  for (inst.setFirst(), jnst.setFirst(); !(inst.end() || jnst.end());
395  inst.inc(), jnst.inc()) {
396  __formulas->set(inst, old->get(jnst));
397  }
398 
399  delete old;
400 
401  __type = t;
402 
403  if (__cpf) {
404  delete __cpf;
405  __cpf = 0;
406  }
407 
408  GUM_ASSERT(__formulas->contains(__type->variable()));
409  GUM_ASSERT(inst.end() && jnst.end());
410  }
Potential< GUM_SCALAR > * __cpf
A pointer on the Potential of this attribute.
MultiDimImplementation< std::string > * __formulas
A pointer on the Potential of this attribute.
virtual Size domainSize() const =0
virtual void set(const Instantiation &i, const GUM_SCALAR &value) const
Changes the value pointed by i.
virtual void add(const DiscreteVariable &v) override
Adds a new var to the variables of the multidimensional matrix.
PRMType * __type
The random variable type of this attribute.
virtual bool contains(const DiscreteVariable &v) const override
Returns true if var is in *this.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the call graph for this function:

◆ addChild()

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

See gum::prm::PRMAttribute.

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

Definition at line 180 of file PRMFormAttribute_tpl.h.

181  {}

◆ addParent()

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

See gum::prm::PRMAttribute.

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

Definition at line 160 of file PRMFormAttribute_tpl.h.

References gum::prm::PRMFormAttribute< GUM_SCALAR >::__cpf, gum::prm::PRMFormAttribute< GUM_SCALAR >::__formulas, gum::prm::PRMFormAttribute< GUM_SCALAR >::__type, gum::MultiDimImplementation< GUM_SCALAR >::add(), gum::MultiDimImplementation< GUM_SCALAR >::contains(), GUM_ERROR, gum::prm::PRMObject::name(), and gum::prm::PRMClassElement< GUM_SCALAR >::type().

161  {
162  try {
163  if (__cpf) {
164  delete __cpf;
165  __cpf = 0;
166  }
167  __formulas->add(elt.type().variable());
168  } catch (DuplicateElement&) {
169  GUM_ERROR(DuplicateElement,
170  elt.name() << " as parent of " << this->name());
171  } catch (OperationNotAllowed&) {
172  GUM_ERROR(OperationNotAllowed,
173  elt.name() << " of wrong type as parent of " << this->name(););
174  }
175 
176  GUM_ASSERT(__formulas->contains(__type->variable()));
177  }
Potential< GUM_SCALAR > * __cpf
A pointer on the Potential of this attribute.
MultiDimImplementation< std::string > * __formulas
A pointer on the Potential of this attribute.
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
virtual void add(const DiscreteVariable &v) override
Adds a new var to the variables of the multidimensional matrix.
PRMType * __type
The random variable type of this attribute.
virtual bool contains(const DiscreteVariable &v) const override
Returns true if var is in *this.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the call graph for this function:

◆ becomeCastDescendant()

template<typename GUM_SCALAR >
void gum::prm::PRMFormAttribute< GUM_SCALAR >::becomeCastDescendant ( PRMType subtype)
virtual

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

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

Definition at line 232 of file PRMFormAttribute_tpl.h.

References gum::prm::PRMFormAttribute< GUM_SCALAR >::__cpf, gum::prm::PRMFormAttribute< GUM_SCALAR >::__formulas, gum::MultiDimImplementation< GUM_SCALAR >::add(), gum::Instantiation::end(), gum::Instantiation::inc(), gum::prm::PRMType::label_map(), gum::Instantiation::pos(), gum::MultiDimContainer< GUM_SCALAR >::set(), gum::Instantiation::setFirst(), gum::prm::PRMFormAttribute< GUM_SCALAR >::type(), and gum::prm::PRMType::variable().

232  {
233  delete __formulas;
234 
235  __formulas = new MultiDimArray< std::string >();
236  __formulas->add(type().variable());
237  __formulas->add(subtype.variable());
238 
239  Instantiation inst(__formulas);
240 
241  for (inst.setFirst(); !inst.end(); inst.inc()) {
242  auto my_pos = inst.pos(subtype.variable());
243  if (subtype.label_map()[my_pos] == inst.pos(type().variable())) {
244  __formulas->set(inst, "1");
245  } else {
246  __formulas->set(inst, "0");
247  }
248  }
249 
250  if (__cpf) {
251  delete __cpf;
252  __cpf = nullptr;
253  }
254  }
Potential< GUM_SCALAR > * __cpf
A pointer on the Potential of this attribute.
MultiDimImplementation< std::string > * __formulas
A pointer on the Potential of this attribute.
virtual void set(const Instantiation &i, const GUM_SCALAR &value) const
Changes the value pointed by i.
virtual void add(const DiscreteVariable &v) override
Adds a new var to the variables of the multidimensional matrix.
virtual PRMType & type()
See gum::prm::PRMAttribute.
+ Here is the call graph for this function:

◆ cast()

template<typename GUM_SCALAR >
INLINE 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 76 of file PRMClassElement_tpl.h.

Referenced by gum::prm::PRMFactory< GUM_SCALAR >::addNoisyOrCompound(), gum::prm::PRMFormAttribute< GUM_SCALAR >::getCastDescendant(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::getCastDescendant(), and gum::prm::PRMClassElement< double >::isParameter().

76  {
77  if (type().isSubTypeOf(t)) {
78  return PRMObject::LEFT_CAST() + t.name() + PRMObject::RIGHT_CAST()
79  + name();
80  } else {
81  GUM_ERROR(OperationNotAllowed, "illegal cast");
82  }
83  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
virtual PRMType & type()=0
Return a reference over the gum::PRMType of this class element.
static std::string LEFT_CAST()
Enumeration of the different types of objects handled by a PRM.
Definition: PRMObject.h:79
static std::string RIGHT_CAST()
Enumeration of the different types of objects handled by a PRM.
Definition: PRMObject.h:80
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the caller graph for this function:

◆ copy()

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

See gum::prm::PRMAttribute.

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

Definition at line 74 of file PRMFormAttribute_tpl.h.

References gum::prm::PRMFormAttribute< GUM_SCALAR >::__class, gum::prm::PRMFormAttribute< GUM_SCALAR >::__formulas, gum::prm::PRMFormAttribute< GUM_SCALAR >::__type, gum::Instantiation::end(), gum::MultiDimContainer< GUM_SCALAR >::get(), gum::Instantiation::inc(), gum::prm::PRMObject::name(), gum::Instantiation::setFirst(), gum::prm::PRMFormAttribute< GUM_SCALAR >::type(), and gum::MultiDimImplementation< GUM_SCALAR >::variablesSequence().

75  {
76  auto copy =
77  new PRMFormAttribute< GUM_SCALAR >(*__class, this->name(), this->type());
78  for (auto var : __formulas->variablesSequence()) {
79  if (var != &(__type->variable())) { copy->__formulas->add(*var); }
80  }
81 
82  Instantiation inst(*(copy->__formulas)), jnst(*__formulas);
83  for (inst.setFirst(), jnst.setFirst(); !(inst.end() || jnst.end());
84  inst.inc(), jnst.inc()) {
85  copy->__formulas->set(inst, __formulas->get(jnst));
86  }
87 
88  GUM_ASSERT(copy->__formulas->contains(copy->__type->variable()));
89  return copy;
90  }
MultiDimImplementation< std::string > * __formulas
A pointer on the Potential of this attribute.
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
virtual PRMAttribute< GUM_SCALAR > * copy(Bijection< const DiscreteVariable *, const DiscreteVariable * > bij) const
See gum::prm::PRMAttribute.
PRMType * __type
The random variable type of this attribute.
virtual const Sequence< const DiscreteVariable *> & variablesSequence() const override
Returns a const ref to the sequence of DiscreteVariable*.
const PRMClass< GUM_SCALAR > * __class
A pointe toward the class of this attribute.
virtual GUM_SCALAR get(const Instantiation &i) const
Returns the value pointed by i.
virtual PRMType & type()
See gum::prm::PRMAttribute.
+ Here is the call graph for this function:

◆ copyCpf()

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

See gum::prm::PRMAttribute.

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

Definition at line 93 of file PRMFormAttribute_tpl.h.

References gum::prm::PRMFormAttribute< GUM_SCALAR >::__cpf, gum::prm::PRMFormAttribute< GUM_SCALAR >::__formulas, gum::prm::PRMFormAttribute< GUM_SCALAR >::__type, gum::MultiDimImplementation< GUM_SCALAR >::add(), gum::MultiDimImplementation< GUM_SCALAR >::contains(), gum::prm::PRMAttribute< GUM_SCALAR >::cpf(), gum::BijectionImplementation< T1, T2, Alloc, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::second(), gum::MultiDimContainer< GUM_SCALAR >::set(), gum::to_string(), and gum::prm::PRMAttribute< GUM_SCALAR >::type().

95  {
96  delete __formulas;
97  __formulas = new MultiDimArray< std::string >();
98 
99  for (const auto& var : source.cpf().variablesSequence()) {
100  __formulas->add(*(bij.second(var)));
101  }
102 
103  if (dynamic_cast< const PRMFormAttribute< GUM_SCALAR >* >(&source)) {
104  const auto& src =
105  static_cast< const PRMFormAttribute< GUM_SCALAR >& >(source);
106 
107  Instantiation inst(__formulas), jnst(src.__formulas);
108 
109  for (inst.setFirst(), jnst.setFirst(); !(inst.end() || jnst.end());
110  inst.inc(), jnst.inc()) {
111  __formulas->set(inst, src.__formulas->get(jnst));
112  }
113 
114  GUM_ASSERT(inst.end() && jnst.end());
115 
116  } else {
117  Instantiation inst(__formulas), jnst(source.cpf());
118 
119  for (inst.setFirst(), jnst.setFirst(); !(inst.end() || jnst.end());
120  inst.inc(), jnst.inc()) {
121  auto val = std::to_string(source.cpf().get(jnst));
122  __formulas->set(inst, val);
123  }
124 
125  GUM_ASSERT(inst.end() && jnst.end());
126  }
127 
128  if (__cpf) {
129  delete __cpf;
130  __cpf = 0;
131  }
132 
133  GUM_ASSERT(__formulas->contains(__type->variable()));
134  GUM_ASSERT(!__formulas->contains(source.type().variable()));
135  }
Potential< GUM_SCALAR > * __cpf
A pointer on the Potential of this attribute.
MultiDimImplementation< std::string > * __formulas
A pointer on the Potential of this attribute.
virtual void set(const Instantiation &i, const GUM_SCALAR &value) const
Changes the value pointed by i.
std::string to_string(const Formula &f)
Definition: formula_inl.h:499
virtual void add(const DiscreteVariable &v) override
Adds a new var to the variables of the multidimensional matrix.
PRMType * __type
The random variable type of this attribute.
virtual bool contains(const DiscreteVariable &v) const override
Returns true if var is in *this.
+ Here is the call graph for this function:

◆ cpf()

template<typename GUM_SCALAR >
const Potential< GUM_SCALAR > & gum::prm::PRMFormAttribute< GUM_SCALAR >::cpf ( ) const
virtual

See gum::prm::PRMAttribute.

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

Definition at line 154 of file PRMFormAttribute_tpl.h.

References gum::prm::PRMFormAttribute< GUM_SCALAR >::__cpf, and gum::prm::PRMFormAttribute< GUM_SCALAR >::__fillCpf().

154  {
155  if (__cpf == 0) { __fillCpf(); }
156  return *__cpf;
157  }
Potential< GUM_SCALAR > * __cpf
A pointer on the Potential of this attribute.
+ Here is the call graph for this function:

◆ elt_type()

template<typename GUM_SCALAR >
PRMClassElement< GUM_SCALAR >::ClassElementType gum::prm::PRMFormAttribute< GUM_SCALAR >::elt_type ( ) const
virtual

◆ enum2str() [1/2]

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

Returns the string representation of a PRMObject.

Definition at line 83 of file PRMObject.h.

References gum::prm::PRMObject::CLASS, gum::prm::PRMObject::CLASS_ELT, gum::prm::PRMObject::INSTANCE, gum::prm::PRMObject::PRM_INTERFACE, gum::prm::PRMObject::SYSTEM, and gum::prm::PRMObject::TYPE.

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

83  {
84  switch (type) {
85  case prm_type::CLASS: return "PRMType::CLASS";
86 
87  case prm_type::CLASS_ELT: return "PRMType::CLASS_ELT";
88 
89  case prm_type::TYPE: return "PRMType::TYPE";
90 
91  case prm_type::SYSTEM: return "PRMType::SYSTEM";
92 
93  case prm_type::INSTANCE: return "PRMType::INSTANCE";
94 
95  case prm_type::PRM_INTERFACE: return "PRMType::PRM_INTERFACE";
96 
97  default: return "unknown";
98  }
99  }
+ Here is the caller graph for this function:

◆ enum2str() [2/2]

template<typename GUM_SCALAR>
static std::string gum::prm::PRMClassElement< GUM_SCALAR >::enum2str ( ClassElementType  type)
inlinestaticinherited

Returns true if obj_ptr is of type PRMReferenceSlot.

Definition at line 103 of file PRMClassElement.h.

103  {
104  switch (type) {
105  case prm_attribute: return "prm_attribute";
106 
107  case prm_aggregate: return "prm_aggregate";
108 
109  case prm_refslot: return "prm_refslot";
110 
111  case prm_slotchain: return "prm_slotchain";
112 
113  case prm_parameter: return "prm_parameter";
114 
115  default: return "unknown";
116  }
117  }
virtual PRMType & type()=0
Return a reference over the gum::PRMType of this class element.

◆ formulas() [1/2]

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

Definition at line 309 of file PRMFormAttribute_tpl.h.

References gum::prm::PRMFormAttribute< GUM_SCALAR >::__cpf, and gum::prm::PRMFormAttribute< GUM_SCALAR >::__formulas.

309  {
310  if (__cpf) {
311  delete __cpf;
312  __cpf = 0;
313  }
314  return *__formulas;
315  }
Potential< GUM_SCALAR > * __cpf
A pointer on the Potential of this attribute.
MultiDimImplementation< std::string > * __formulas
A pointer on the Potential of this attribute.

◆ formulas() [2/2]

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

Definition at line 319 of file PRMFormAttribute_tpl.h.

References gum::prm::PRMFormAttribute< GUM_SCALAR >::__formulas.

319  {
320  return *__formulas;
321  }
MultiDimImplementation< std::string > * __formulas
A pointer on the Potential of this attribute.

◆ getCastDescendant()

template<typename GUM_SCALAR >
PRMAttribute< GUM_SCALAR > * gum::prm::PRMFormAttribute< GUM_SCALAR >::getCastDescendant ( ) const
virtual

See gum::prm::PRMAttribute.

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

Definition at line 185 of file PRMFormAttribute_tpl.h.

References gum::prm::PRMFormAttribute< GUM_SCALAR >::__formulas, gum::prm::PRMFormAttribute< GUM_SCALAR >::__type, gum::prm::PRMScalarAttribute< GUM_SCALAR >::addParent(), gum::prm::PRMClassElement< GUM_SCALAR >::cast(), gum::MultiDimImplementation< GUM_SCALAR >::contains(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::cpf(), GUM_ERROR, gum::prm::PRMType::label_map(), gum::prm::PRMObject::name(), gum::prm::PRMType::superType(), gum::prm::PRMFormAttribute< GUM_SCALAR >::type(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::type(), and gum::prm::PRMType::variable().

185  {
186  PRMScalarAttribute< GUM_SCALAR >* cast = 0;
187 
188  try {
189  cast =
190  new PRMScalarAttribute< GUM_SCALAR >(this->name(), type().superType());
191  } catch (NotFound&) {
192  GUM_ERROR(OperationNotAllowed,
193  "this ScalarAttribute can not have cast descendant");
194  }
195 
196  cast->addParent(*this);
197 
198  const DiscreteVariable& my_var = type().variable();
199  DiscreteVariable& cast_var = cast->type().variable();
200  Instantiation inst(cast->cpf());
201 
202  for (inst.setFirst(); !inst.end(); inst.inc()) {
203  if (type().label_map()[inst.val(my_var)] == inst.val(cast_var)) {
204  cast->cpf().set(inst, 1);
205  } else {
206  cast->cpf().set(inst, 0);
207  }
208  }
209 
210  GUM_ASSERT(__formulas->contains(__type->variable()));
211  return cast;
212  }
PRMType & superType()
Returns the super type of this type.
Definition: PRMType_inl.h:36
MultiDimImplementation< std::string > * __formulas
A pointer on the Potential of this attribute.
DiscreteVariable & variable()
Return a reference on the DiscreteVariable contained in this.
Definition: PRMType_inl.h:45
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
virtual std::string cast(const PRMType &t) const
Returns the name of the cast descendant with PRMType t of this PRMClassElement.
PRMType * __type
The random variable type of this attribute.
const std::vector< Idx > & label_map() const
Returns the vector in which the i-th element is the Idx of the super type&#39;s label for the i-th label ...
Definition: PRMType_inl.h:94
virtual bool contains(const DiscreteVariable &v) const override
Returns true if var is in *this.
virtual PRMType & type()
See gum::prm::PRMAttribute.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the call graph for this function:

◆ id()

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

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

Definition at line 55 of file PRMClassElement_tpl.h.

Referenced by gum::prm::PRMClass< double >::__addCastDescendants(), gum::prm::PRMInterface< double >::__addCastDescendants(), gum::prm::PRMClass< double >::__checkInterface(), gum::prm::PRMClass< double >::__checkRefInterface(), gum::prm::PRMInstance< GUM_SCALAR >::__copyAggregates(), gum::prm::PRMInstance< GUM_SCALAR >::__copyAttribute(), gum::prm::PRMSlotChain< double >::__copyLastElt(), gum::prm::SVE< GUM_SCALAR >::__getAggPotential(), gum::prm::PRMSystem< double >::__groundPotential(), gum::prm::PRMClass< double >::__inheritClass(), gum::prm::InstanceBayesNet< GUM_SCALAR >::__init(), gum::prm::ClassBayesNet< GUM_SCALAR >::__init(), gum::prm::PRMInstance< GUM_SCALAR >::__instantiateSlotChain(), gum::prm::PRMInterface< double >::__overloadAttribute(), gum::prm::PRMClass< double >::__overloadAttribute(), gum::prm::PRMClass< double >::__overloadParameter(), gum::prm::PRMClass< double >::__overloadReference(), gum::prm::PRMInterface< double >::__overloadReferenceSlot(), gum::prm::SVED< GUM_SCALAR >::_marginal(), gum::prm::SVE< GUM_SCALAR >::_marginal(), gum::prm::PRMInterface< double >::add(), gum::prm::PRMClass< double >::add(), gum::prm::PRMClass< double >::addArc(), gum::prm::PRMClass< double >::inheritAggregates(), gum::prm::PRMClassElement< double >::isParameter(), gum::prm::PRMClass< double >::overload(), gum::prm::PRMInterface< double >::overload(), and gum::prm::PRMFactory< GUM_SCALAR >::startAttribute().

55  {
56  return __id;
57  }
NodeId __id
The node&#39;s id of this element.
+ Here is the caller graph for this function:

◆ isAggregate()

template<typename GUM_SCALAR>
static INLINE bool gum::prm::PRMClassElement< GUM_SCALAR >::isAggregate ( const PRMClassElement< GUM_SCALAR > &  elt)
inlinestaticinherited

Return true if obj is of type PRMAggregate.

Definition at line 131 of file PRMClassElement.h.

Referenced by gum::prm::StructuredInference< GUM_SCALAR >::CData::CData().

131  {
132  return elt.elt_type() == prm_aggregate;
133  }
+ Here is the caller graph for this function:

◆ isAttribute()

template<typename GUM_SCALAR>
static INLINE bool gum::prm::PRMClassElement< GUM_SCALAR >::isAttribute ( const PRMClassElement< GUM_SCALAR > &  elt)
inlinestaticinherited

Returns true if obj_ptr is of type PRMAttribute.

Definition at line 126 of file PRMClassElement.h.

126  {
127  return elt.elt_type() == prm_attribute;
128  }

◆ isClass()

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

Returns true if obj_ptr is of type Class.

Definition at line 102 of file PRMObject.h.

References gum::prm::PRMObject::CLASS, and gum::prm::PRMObject::obj_type().

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

102  {
103  return obj.obj_type() == prm_type::CLASS;
104  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isInstance()

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

Returns true if obj_ptr is of type PRMInstance.

Definition at line 112 of file PRMObject.h.

References gum::prm::PRMObject::INSTANCE, gum::prm::PRMObject::name(), gum::prm::PRMObject::obj_type(), gum::prm::PRMObject::operator!=(), gum::prm::PRMObject::operator=(), gum::prm::PRMObject::operator==(), gum::prm::PRMObject::PRMObject(), and gum::prm::PRMObject::~PRMObject().

112  {
113  return obj.obj_type() == prm_type::INSTANCE;
114  }
+ Here is the call graph for this function:

◆ isInterface()

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

Returns true if obj_ptr is of type PRMInterface.

Definition at line 107 of file PRMObject.h.

References gum::prm::PRMObject::obj_type(), and gum::prm::PRMObject::PRM_INTERFACE.

107  {
108  return obj.obj_type() == prm_type::PRM_INTERFACE;
109  }
+ Here is the call graph for this function:

◆ isParameter()

template<typename GUM_SCALAR>
static INLINE bool gum::prm::PRMClassElement< GUM_SCALAR >::isParameter ( const PRMClassElement< GUM_SCALAR > &  elt)
inlinestaticinherited

Return true if obj is of type PRMParameter.

Definition at line 141 of file PRMClassElement.h.

141  {
142  return elt.elt_type() == prm_parameter;
143  }

◆ isReferenceSlot()

template<typename GUM_SCALAR>
static INLINE bool gum::prm::PRMClassElement< GUM_SCALAR >::isReferenceSlot ( const PRMClassElement< GUM_SCALAR > &  elt)
inlinestaticinherited

Returns true if obj_ptr is of type PRMReferenceSlot.

Definition at line 121 of file PRMClassElement.h.

121  {
122  return elt.elt_type() == prm_refslot;
123  }

◆ isSlotChain()

template<typename GUM_SCALAR>
static INLINE bool gum::prm::PRMClassElement< GUM_SCALAR >::isSlotChain ( const PRMClassElement< GUM_SCALAR > &  elt)
inlinestaticinherited

Return true if obj is of type PRMSlotChain.

Definition at line 136 of file PRMClassElement.h.

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

136  {
137  return elt.elt_type() == prm_slotchain;
138  }
+ Here is the caller graph for this function:

◆ LEFT_CAST()

static std::string gum::prm::PRMObject::LEFT_CAST ( )
inlinestaticinherited

Enumeration of the different types of objects handled by a PRM.

The "all" type is used to tell that we want any kind of PRMType (useful with iterators for example). No PRMObject will ever have "all" as type.

Definition at line 79 of file PRMObject.h.

Referenced by gum::prm::decomposePath(), gum::prm::PRMFormAttribute< GUM_SCALAR >::PRMFormAttribute(), and gum::prm::PRMScalarAttribute< GUM_SCALAR >::PRMScalarAttribute().

79 { return "("; }
+ 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 35 of file PRMObject_inl.h.

References gum::prm::PRMObject::__name.

Referenced by gum::prm::SVE< GUM_SCALAR >::__addDelayedVariable(), gum::prm::PRMClass< double >::__addIOInterfaceFlags(), gum::prm::PRMFactory< GUM_SCALAR >::__addParent(), gum::prm::PRMInstance< GUM_SCALAR >::__addReferingInstance(), gum::prm::PRMClass< double >::__checkInterface(), gum::prm::PRMFactory< GUM_SCALAR >::__checkInterfaceImplementation(), gum::prm::PRMClass< double >::__checkInterfaces(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::__checkRawCPT(), gum::prm::PRMClass< double >::__checkRefInterface(), gum::prm::PRMClass< double >::__checkRefInterfaces(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::__checkRuleCPTSumsTo1(), gum::prm::PRMInstance< GUM_SCALAR >::__copyAggregates(), gum::prm::PRMInstance< GUM_SCALAR >::__copyAttribute(), gum::prm::PRMSlotChain< double >::__copyLastElt(), gum::prm::PRMSystem< double >::__groundAttr(), gum::prm::PRMSystem< double >::__groundPotential(), gum::prm::PRMSystem< double >::__groundRef(), gum::prm::PRMClass< double >::__inheritClass(), gum::prm::PRMInterface< double >::__overloadAttribute(), gum::prm::PRMClass< double >::__overloadAttribute(), gum::prm::PRMClass< double >::__overloadParameter(), gum::prm::PRMClass< double >::__overloadReference(), gum::prm::PRMInterface< double >::__overloadReferenceSlot(), gum::prm::__print_attribute__(), gum::prm::__print_instance__(), gum::prm::gspan::StrictSearch< GUM_SCALAR >::__str(), gum::prm::StructuredInference< GUM_SCALAR >::__str(), gum::prm::PRMInterface< double >::add(), gum::prm::PRMSystem< double >::add(), gum::prm::PRMClass< double >::add(), gum::prm::PRMFactory< GUM_SCALAR >::addAggregator(), gum::prm::PRMFormAttribute< GUM_SCALAR >::addParent(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::addParent(), gum::prm::PRMFormAttribute< GUM_SCALAR >::copy(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::copy(), gum::prm::o3prmr::O3prmrInterpreter::findAttributeName(), gum::prm::o3prmr::O3prmrInterpreter::findInstanceName(), gum::prm::PRMFormAttribute< GUM_SCALAR >::getCastDescendant(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::getCastDescendant(), gum::prm::PRMClass< double >::inheritAggregates(), gum::prm::PRMClass< double >::isCastDescendant(), gum::prm::PRMObject::isInstance(), gum::prm::PRMObject::name(), gum::prm::PRMType::name(), gum::prm::PRMFormAttribute< GUM_SCALAR >::newFactory(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::newFactory(), gum::prm::PRMType::operator!=(), gum::prm::PRMObject::operator!=(), operator<<(), gum::prm::PRMType::operator==(), gum::prm::PRMObject::operator==(), gum::prm::PRMClass< double >::overload(), gum::prm::PRMInterface< double >::overload(), gum::prm::PRMFormAttribute< GUM_SCALAR >::PRMFormAttribute(), gum::prm::PRMReferenceSlot< double >::PRMReferenceSlot(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::PRMScalarAttribute(), gum::prm::PRMFactory< GUM_SCALAR >::startClass(), gum::prm::PRMFactory< GUM_SCALAR >::startInterface(), gum::prm::PRMFactory< GUM_SCALAR >::startSystem(), and gum::prm::PRMAggregate< double >::str2enum().

35 { return __name; }
std::string __name
Definition: PRMObject.h:200

◆ name() [2/2]

INLINE void gum::prm::PRMObject::name ( const std::string &  name)
inherited

Change the name of the PRM Object.

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

Definition at line 39 of file PRMObject_inl.h.

References gum::prm::PRMObject::__name, and gum::prm::PRMObject::name().

39 { __name = name; }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
std::string __name
Definition: PRMObject.h:200
+ Here is the call graph for this function:

◆ newFactory()

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

See gum::prm::PRMAttribute.

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

Definition at line 65 of file PRMFormAttribute_tpl.h.

References gum::prm::PRMFormAttribute< GUM_SCALAR >::__formulas, gum::prm::PRMObject::name(), gum::MultiDimImplementation< GUM_SCALAR >::newFactory(), and gum::prm::PRMFormAttribute< GUM_SCALAR >::type().

66  {
67  auto impl = static_cast< MultiDimImplementation< std::string >* >(
68  this->__formulas->newFactory());
69  return new PRMFormAttribute< GUM_SCALAR >(
70  c, this->name(), this->type(), impl);
71  }
MultiDimImplementation< std::string > * __formulas
A pointer on the Potential of this attribute.
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:35
virtual MultiDimContainer< GUM_SCALAR > * newFactory() const override=0
Creates an empty clone of this MultiDimContainer.
virtual PRMType & type()
See gum::prm::PRMAttribute.
+ Here is the call graph for this function:

◆ obj_type()

template<typename GUM_SCALAR >
INLINE PRMObject::prm_type gum::prm::PRMClassElement< GUM_SCALAR >::obj_type ( ) const
virtualinherited
See also
gum::PRMObject::obj_type().

Implements gum::prm::PRMObject.

Definition at line 60 of file PRMClassElement_tpl.h.

Referenced by gum::prm::PRMClassElement< double >::isParameter().

+ Here is the caller 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 49 of file PRMObject_inl.h.

References gum::prm::PRMObject::__name, and gum::prm::PRMObject::name().

Referenced by gum::prm::PRMObject::isInstance().

49  {
50  return __name != obj.name();
51  }
std::string __name
Definition: PRMObject.h:200
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=()

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

Definition at line 266 of file PRMFormAttribute_tpl.h.

References GUM_ERROR.

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

266  {
267  GUM_ERROR(OperationNotAllowed, "Cannot copy FormAttribute");
268  }
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the caller 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 43 of file PRMObject_inl.h.

References gum::prm::PRMObject::__name, and gum::prm::PRMObject::name().

Referenced by gum::prm::PRMObject::isInstance().

43  {
44  return __name == obj.name();
45  }
std::string __name
Definition: PRMObject.h:200
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ overload()

template<typename 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 53 of file PRMAttribute_tpl.h.

Referenced by gum::prm::PRMInterface< double >::__overloadAttribute(), and gum::prm::PRMClass< double >::__overloadAttribute().

53  {
54  auto old_type = this->_type();
55  this->_type(source->_type());
56  source->_type(old_type);
57  }
virtual PRMType * _type()=0
+ Here is the caller graph for this function:

◆ RIGHT_CAST()

static std::string gum::prm::PRMObject::RIGHT_CAST ( )
inlinestaticinherited

Enumeration of the different types of objects handled by a PRM.

The "all" type is used to tell that we want any kind of PRMType (useful with iterators for example). No PRMObject will ever have "all" as type.

Definition at line 80 of file PRMObject.h.

Referenced by gum::prm::decomposePath(), gum::prm::PRMFormAttribute< GUM_SCALAR >::PRMFormAttribute(), and gum::prm::PRMScalarAttribute< GUM_SCALAR >::PRMScalarAttribute().

80 { return ")"; }
+ Here is the caller graph for this function:

◆ safeName()

template<typename GUM_SCALAR >
INLINE 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 70 of file PRMClassElement_tpl.h.

Referenced by gum::prm::PRMClass< double >::__addCastDescendants(), gum::prm::PRMInterface< double >::__addCastDescendants(), gum::prm::PRMFactory< GUM_SCALAR >::__addParent(), gum::prm::PRMInstance< GUM_SCALAR >::__copyAttributeCPF(), gum::prm::SVED< GUM_SCALAR >::__getAggPotential(), gum::prm::PRMSystem< double >::__groundPotential(), gum::prm::PRMSystem< double >::__groundRef(), gum::prm::PRMClass< double >::__inheritClass(), gum::prm::PRMClass< double >::__overloadAggregate(), gum::prm::PRMInterface< double >::__overloadAttribute(), gum::prm::PRMClass< double >::__overloadAttribute(), gum::prm::PRMClass< double >::__overloadParameter(), gum::prm::PRMClass< double >::__overloadReference(), gum::prm::PRMInterface< double >::__overloadReferenceSlot(), gum::prm::__print_attribute__(), gum::prm::gspan::StrictSearch< GUM_SCALAR >::__str(), gum::prm::StructuredInference< GUM_SCALAR >::__str(), gum::prm::PRMClassElementContainer< double >::_getIOFlag(), gum::prm::PRMClassElementContainer< double >::_setIOFlag(), gum::prm::PRMInterface< double >::add(), gum::prm::PRMClass< double >::add(), gum::prm::PRMFactory< GUM_SCALAR >::addAggregator(), gum::prm::PRMFactory< GUM_SCALAR >::addAttribute(), gum::prm::PRMClassElementContainer< double >::belongsTo(), gum::prm::PRMClass< double >::inheritAggregates(), gum::prm::PRMClassElement< double >::isParameter(), gum::prm::PRMClassElementContainer< double >::setInputNode(), and gum::prm::PRMClassElementContainer< double >::setOutputNode().

70  {
71  return _safeName;
72  }
std::string _safeName
The safe name of this PRMClassElement.
+ Here is the caller graph for this function:

◆ setAsCastDescendant()

template<typename GUM_SCALAR >
void gum::prm::PRMFormAttribute< GUM_SCALAR >::setAsCastDescendant ( PRMAttribute< GUM_SCALAR > *  attr)
virtual

See gum::prm::PRMAttribute.

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

Definition at line 215 of file PRMFormAttribute_tpl.h.

References gum::prm::PRMAttribute< GUM_SCALAR >::becomeCastDescendant(), GUM_ERROR, gum::prm::PRMType::name(), gum::prm::PRMType::setSuper(), gum::prm::PRMFormAttribute< GUM_SCALAR >::type(), and gum::prm::PRMAttribute< GUM_SCALAR >::type().

216  {
217  try {
218  type().setSuper(cast->type());
219  } catch (OperationNotAllowed&) {
220  GUM_ERROR(OperationNotAllowed,
221  "this ScalarAttribute can not have cast descendant");
222  } catch (WrongType&) {
223  std::stringstream msg;
224  msg << type().name() << " is not a subtype of " << cast->type().name();
225  GUM_ERROR(WrongType, msg.str());
226  }
227 
228  cast->becomeCastDescendant(type());
229  }
const std::string & name() const
Returns the name of this object.
Definition: PRMType_inl.h:68
void setSuper(PRMType &t)
Changes the PRMType of this PRMType super.
Definition: PRMType_inl.h:80
virtual std::string cast(const PRMType &t) const
Returns the name of the cast descendant with PRMType t of this PRMClassElement.
virtual PRMType & type()
See gum::prm::PRMAttribute.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the call graph for this function:

◆ setId()

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

Used to assign the id of this element.

Definition at line 65 of file PRMClassElement_tpl.h.

Referenced by gum::prm::PRMClass< double >::__addCastDescendants(), gum::prm::PRMInterface< double >::__addCastDescendants(), gum::prm::PRMClass< double >::__checkInterface(), gum::prm::PRMClass< double >::__checkRefInterface(), gum::prm::PRMSlotChain< double >::__copyLastElt(), gum::prm::PRMClass< double >::__inheritClass(), gum::prm::PRMInterface< double >::__inheritInterface(), gum::prm::PRMInterface< double >::__overloadAttribute(), gum::prm::PRMClass< double >::__overloadAttribute(), gum::prm::PRMClass< double >::__overloadParameter(), gum::prm::PRMClass< double >::__overloadReference(), gum::prm::PRMInterface< double >::__overloadReferenceSlot(), gum::prm::PRMInterface< double >::add(), gum::prm::PRMClass< double >::add(), gum::prm::PRMClass< double >::inheritAggregates(), gum::prm::PRMClass< double >::inheritParameters(), gum::prm::PRMClass< double >::inheritReferenceSlots(), gum::prm::PRMClass< double >::inheritSlotChains(), and gum::prm::PRMClassElement< double >::isParameter().

65  {
66  __id = id;
67  }
NodeId id() const
Returns the NodeId of this element in it&#39;s class DAG.
NodeId __id
The node&#39;s id of this element.
+ Here is the caller graph for this function:

◆ swap()

template<typename GUM_SCALAR >
void gum::prm::PRMFormAttribute< GUM_SCALAR >::swap ( const PRMType old_type,
const PRMType new_type 
)
virtual

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.

References gum::prm::PRMFormAttribute< GUM_SCALAR >::__cpf, gum::prm::PRMFormAttribute< GUM_SCALAR >::__formulas, gum::prm::PRMFormAttribute< GUM_SCALAR >::__type, gum::MultiDimImplementation< GUM_SCALAR >::add(), gum::MultiDimImplementation< GUM_SCALAR >::contains(), gum::DiscreteVariable::domainSize(), gum::Instantiation::end(), GUM_ERROR, gum::Instantiation::inc(), gum::prm::PRMType::name(), gum::MultiDimContainer< GUM_SCALAR >::set(), gum::Instantiation::setFirst(), and gum::prm::PRMType::variable().

325  {
326  if (&(old_type) == __type) {
327  GUM_ERROR(OperationNotAllowed, "Cannot replace attribute own type");
328  }
329  if (old_type->domainSize() != new_type->domainSize()) {
330  GUM_ERROR(OperationNotAllowed,
331  "Cannot replace types with difference domain size");
332  }
333  if (!__formulas->contains(old_type.variable())) {
334  GUM_ERROR(NotFound, "could not find variable " + old_type.name());
335  }
336 
337  auto old = __formulas;
338 
339  __formulas = new MultiDimArray< std::string >();
340 
341  for (auto var : old->variablesSequence()) {
342  if (var != &(old_type.variable())) {
343  __formulas->add(*var);
344  } else {
345  __formulas->add(new_type.variable());
346  }
347  }
348 
349  Instantiation inst(__formulas), jnst(old);
350 
351  for (inst.setFirst(), jnst.setFirst(); !(inst.end() || jnst.end());
352  inst.inc(), jnst.inc()) {
353  __formulas->set(inst, old->get(jnst));
354  }
355 
356  delete old;
357 
358  if (__cpf) {
359  delete __cpf;
360  __cpf = 0;
361  }
362 
363  GUM_ASSERT(inst.end() && jnst.end());
364  GUM_ASSERT(__formulas->contains(__type->variable()));
365  GUM_ASSERT(!__formulas->contains(new_type.variable()));
366  GUM_ASSERT(__formulas->contains(new_type.variable()));
367  }
Potential< GUM_SCALAR > * __cpf
A pointer on the Potential of this attribute.
MultiDimImplementation< std::string > * __formulas
A pointer on the Potential of this attribute.
virtual void set(const Instantiation &i, const GUM_SCALAR &value) const
Changes the value pointed by i.
virtual void add(const DiscreteVariable &v) override
Adds a new var to the variables of the multidimensional matrix.
PRMType * __type
The random variable type of this attribute.
virtual bool contains(const DiscreteVariable &v) const override
Returns true if var is in *this.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the call graph for this function:

◆ type() [1/2]

template<typename GUM_SCALAR >
PRMType & gum::prm::PRMFormAttribute< GUM_SCALAR >::type ( )
virtual

See gum::prm::PRMAttribute.

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

Definition at line 144 of file PRMFormAttribute_tpl.h.

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

Referenced by gum::prm::PRMFormAttribute< GUM_SCALAR >::becomeCastDescendant(), gum::prm::PRMFormAttribute< GUM_SCALAR >::copy(), gum::prm::PRMFormAttribute< GUM_SCALAR >::getCastDescendant(), gum::prm::PRMFormAttribute< GUM_SCALAR >::newFactory(), and gum::prm::PRMFormAttribute< GUM_SCALAR >::setAsCastDescendant().

144  {
145  return *__type;
146  }
PRMType * __type
The random variable type of this attribute.
+ Here is the caller graph for this function:

◆ type() [2/2]

template<typename GUM_SCALAR >
const PRMType & gum::prm::PRMFormAttribute< GUM_SCALAR >::type ( ) const
virtual

See gum::prm::PRMAttribute.

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

Definition at line 149 of file PRMFormAttribute_tpl.h.

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

149  {
150  return *__type;
151  }
PRMType * __type
The random variable type of this attribute.

Member Data Documentation

◆ __class

template<typename GUM_SCALAR>
const PRMClass< GUM_SCALAR >* gum::prm::PRMFormAttribute< GUM_SCALAR >::__class
private

A pointe toward the class of this attribute.

Definition at line 123 of file PRMFormAttribute.h.

Referenced by gum::prm::PRMFormAttribute< GUM_SCALAR >::__fillCpf(), and gum::prm::PRMFormAttribute< GUM_SCALAR >::copy().

◆ __cpf

◆ __formulas

◆ __type

◆ _safeName

template<typename GUM_SCALAR>
std::string gum::prm::PRMClassElement< GUM_SCALAR >::_safeName
protectedinherited

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