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

#include <PRMAggregate.h>

+ Inheritance diagram for gum::prm::PRMAggregate< GUM_SCALAR >:
+ Collaboration diagram for gum::prm::PRMAggregate< GUM_SCALAR >:

Public Member Functions

Constructor & destructor.
 PRMAggregate (const std::string &name, AggregateType aggType, const PRMType &rvType)
 Default constructor. More...
 
 PRMAggregate (const std::string &name, AggregateType aggType, const PRMType &rvType, Idx label)
 Default constructor. More...
 
virtual ~PRMAggregate ()
 Destructor. More...
 
Getters and Setters.
virtual PRMClassElement< GUM_SCALAR >::ClassElementType elt_type () const
 See gum::PRMClassElement::elt_type(). More...
 
AggregateType agg_type () const
 Returns the aggregate of *this. More...
 
Idx label () const
 Returns the label's index on which this aggregate applies. More...
 
const std::string & labelValue () const
 See gum::PRMClassElement::elt_type(). More...
 
std::shared_ptr< IdxsharedLabel () const
 Returns the shared_ptr holding this Aggregate label. More...
 
void sharedLabel (std::shared_ptr< Idx > label)
 Sets the shared_ptr of this Aggregate. More...
 
void setLabel (Idx idx)
 Set the aggregator's label. More...
 
void setLabel (const std::string &label)
 See gum::PRMClassElement::elt_type(). More...
 
bool hasLabel () const
 Returns true if the label is defined. More...
 
bool isDecomposable () const
 Returns true if the aggregator is decomposable. More...
 
virtual void addParent (const PRMClassElement< GUM_SCALAR > &elt)
 See gum::PRMClassElement::addParent_(). More...
 
virtual void addChild (const PRMClassElement< GUM_SCALAR > &elt)
 See gum::PRMClassElement::addChild_(). More...
 
virtual PRMTypetype ()
 See gum::PRMClassElement::type(). More...
 
virtual const PRMTypetype () const
 See gum::PRMClassElement::type(). More...
 
virtual Potential< GUM_SCALAR > & cpf ()
 Aggregates don't have Potential until they are instantiated as PRMAttribute, so this will raise an OperationNotAllowed exception. More...
 
virtual const Potential< GUM_SCALAR > & cpf () const
 Aggregates don't have Potential until they are instantiated as PRMAttribute, so this will raise an OperationNotAllowed exception. More...
 
MultiDimImplementation< GUM_SCALAR > * buildImpl () const
 Returns a pointer over an empty gum::MultiDimImplementation of the good type for this PRMAggregate. More...
 
virtual PRMAttribute< GUM_SCALAR > * getCastDescendant () const
 See gum::PRMClassElement::elt_type(). 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...
 

Friends

class PRMClass< GUM_SCALAR >
 

Built-in types.

enum  AggregateType : char {
  AggregateType::MIN, AggregateType::MAX, AggregateType::COUNT, AggregateType::EXISTS,
  AggregateType::FORALL, AggregateType::OR, AggregateType::AND, AggregateType::AMPLITUDE,
  AggregateType::MEDIAN, AggregateType::SUM
}
 The different type of aggregates we can have. More...
 
static AggregateType str2enum (const std::string &str)
 Static method which returns the AggregateType given its string representation. More...
 

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::PRMAggregate< GUM_SCALAR >

Definition at line 69 of file PRMAggregate.h.

Member Enumeration Documentation

◆ AggregateType

template<typename GUM_SCALAR>
enum gum::prm::PRMAggregate::AggregateType : char
strong

The different type of aggregates we can have.

Enumerator
MIN 
MAX 
COUNT 
EXISTS 
FORALL 
OR 
AND 
AMPLITUDE 
MEDIAN 
SUM 

Definition at line 79 of file PRMAggregate.h.

79  : char
80  {
81  MIN,
82  MAX,
83  COUNT,
84  EXISTS,
85  FORALL,
86  OR,
87  AND,
88  AMPLITUDE,
89  MEDIAN,
90  SUM
91  };

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

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

Constructor & Destructor Documentation

◆ PRMAggregate() [1/3]

template<typename GUM_SCALAR >
gum::prm::PRMAggregate< GUM_SCALAR >::PRMAggregate ( const std::string &  name,
AggregateType  aggType,
const PRMType rvType 
)

Default constructor.

Parameters
nameThe name of this aggregate.
aggTypeThe aggregate type of this aggregate.
rvTypeThe random variable type of this aggregate, which is copied.

Definition at line 46 of file PRMAggregate_tpl.h.

48  :
49  PRMClassElement< GUM_SCALAR >(name),
50  _agg_type_(aggType), _type_(new PRMType(rvType)),
51  _label_(std::shared_ptr< Idx >(new Idx(INT_MAX))) {
52  GUM_CONSTRUCTOR(PRMAggregate);
54  this->_type_->variable().setName(name);
55  }
void setName(const std::string &theValue)
sets the name of the variable
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
std::shared_ptr< Idx > _label_
Some aggregators applies only on a given label. This attribute must have the concerned Idx...
Definition: PRMAggregate.h:274
std::string safeName_
The safe name of this PRMClassElement.
PRMAggregate(const std::string &name, AggregateType aggType, const PRMType &rvType)
Default constructor.
static std::string LEFT_CAST()
Enumeration of the different types of objects handled by a PRM.
Definition: PRMObject.h:79
Size Idx
Type for indexes.
Definition: types.h:52
PRMType * _type_
The random variable type of this aggregate It is deleted with the aggregate.
Definition: PRMAggregate.h:269
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
AggregateType _agg_type_
The AggregateType of this aggregate.
Definition: PRMAggregate.h:265

◆ PRMAggregate() [2/3]

template<typename GUM_SCALAR >
gum::prm::PRMAggregate< GUM_SCALAR >::PRMAggregate ( const std::string &  name,
AggregateType  aggType,
const PRMType rvType,
Idx  label 
)

Default constructor.

Parameters
nameThe name of this aggregate.
aggTypeThe aggregate type of this aggregate.
rvTypeThe random variable type of this aggregate, which is copied.
labelThe index of the label on which this aggregate applies.

Definition at line 58 of file PRMAggregate_tpl.h.

61  :
62  PRMClassElement< GUM_SCALAR >(name),
63  _agg_type_(aggType), _type_(new PRMType(rvType)),
64  _label_(std::shared_ptr< Idx >(new Idx(label))) {
65  GUM_CONSTRUCTOR(PRMAggregate);
67  this->_type_->variable().setName(name);
68  }
void setName(const std::string &theValue)
sets the name of the variable
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
std::shared_ptr< Idx > _label_
Some aggregators applies only on a given label. This attribute must have the concerned Idx...
Definition: PRMAggregate.h:274
std::string safeName_
The safe name of this PRMClassElement.
PRMAggregate(const std::string &name, AggregateType aggType, const PRMType &rvType)
Default constructor.
static std::string LEFT_CAST()
Enumeration of the different types of objects handled by a PRM.
Definition: PRMObject.h:79
Size Idx
Type for indexes.
Definition: types.h:52
PRMType * _type_
The random variable type of this aggregate It is deleted with the aggregate.
Definition: PRMAggregate.h:269
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
AggregateType _agg_type_
The AggregateType of this aggregate.
Definition: PRMAggregate.h:265

◆ ~PRMAggregate()

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

Destructor.

Definition at line 71 of file PRMAggregate_tpl.h.

71  {
72  GUM_DESTRUCTOR(PRMAggregate);
73  delete _type_;
74  }
PRMAggregate(const std::string &name, AggregateType aggType, const PRMType &rvType)
Default constructor.
PRMType * _type_
The random variable type of this aggregate It is deleted with the aggregate.
Definition: PRMAggregate.h:269

◆ PRMAggregate() [3/3]

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

Copy constructor. Don't use it.

Definition at line 77 of file PRMAggregate_tpl.h.

77  :
78  PRMClassElement< GUM_SCALAR >(source) {
79  GUM_CONS_CPY(PRMAggregate);
80  GUM_ERROR(FatalError, "illegal call to gum::PRMAggregate copy constructor.")
81  }
PRMAggregate(const std::string &name, AggregateType aggType, const PRMType &rvType)
Default constructor.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

Member Function Documentation

◆ addChild()

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

See gum::PRMClassElement::addChild_().

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

Definition at line 233 of file PRMAggregate_tpl.h.

233 {}

◆ addParent()

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

See gum::PRMClassElement::addParent_().

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

Definition at line 229 of file PRMAggregate_tpl.h.

229 {}

◆ agg_type()

template<typename GUM_SCALAR >
INLINE PRMAggregate< GUM_SCALAR >::AggregateType gum::prm::PRMAggregate< GUM_SCALAR >::agg_type ( ) const

Returns the aggregate of *this.

Definition at line 97 of file PRMAggregate_tpl.h.

97  {
98  return _agg_type_;
99  }
AggregateType _agg_type_
The AggregateType of this aggregate.
Definition: PRMAggregate.h:265

◆ buildImpl()

template<typename GUM_SCALAR >
INLINE MultiDimImplementation< GUM_SCALAR > * gum::prm::PRMAggregate< GUM_SCALAR >::buildImpl ( ) const

Returns a pointer over an empty gum::MultiDimImplementation of the good type for this PRMAggregate.

This should be use when manipulating instantiations of aggregates.

Definition at line 187 of file PRMAggregate_tpl.h.

187  {
188  switch (agg_type()) {
189  case AggregateType::MIN: {
190  return new aggregator::Min< GUM_SCALAR >();
191  }
192  case AggregateType::MAX: {
193  return new aggregator::Max< GUM_SCALAR >();
194  }
195  case AggregateType::OR: {
196  return new aggregator::Or< GUM_SCALAR >();
197  }
198  case AggregateType::AND: {
199  return new aggregator::And< GUM_SCALAR >();
200  }
202  return new aggregator::Amplitude< GUM_SCALAR >();
203  }
204  case AggregateType::MEDIAN: {
205  return new aggregator::Median< GUM_SCALAR >();
206  }
207  case AggregateType::EXISTS: {
208  return new aggregator::Exists< GUM_SCALAR >(label());
209  }
210  case AggregateType::FORALL: {
211  return new aggregator::Forall< GUM_SCALAR >(label());
212  }
213  case AggregateType::COUNT: {
214  return new aggregator::Count< GUM_SCALAR >(label());
215  }
216  case AggregateType::SUM: {
217  return new aggregator::Sum< GUM_SCALAR >();
218  }
219  default: {
220  GUM_ERROR(OperationNotAllowed, "Unknown aggregator.")
221  }
222  }
223  return nullptr;
224  }
AggregateType agg_type() const
Returns the aggregate of *this.
Idx label() const
Returns the label&#39;s index on which this aggregate applies.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

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

71  {
72  if (type().isSubTypeOf(t)) {
73  return PRMObject::LEFT_CAST() + t.name() + PRMObject::RIGHT_CAST() + name();
74  } else {
75  GUM_ERROR(OperationNotAllowed, "illegal cast")
76  }
77  }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
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:51

◆ cpf() [1/2]

template<typename GUM_SCALAR >
INLINE Potential< GUM_SCALAR > & gum::prm::PRMAggregate< GUM_SCALAR >::cpf ( )
virtual

Aggregates don't have Potential until they are instantiated as PRMAttribute, so this will raise an OperationNotAllowed exception.

See gum::PRMClassElement::cpf().

Definition at line 177 of file PRMAggregate_tpl.h.

177  {
178  GUM_ERROR(OperationNotAllowed, "This is an aggregate.")
179  }
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ cpf() [2/2]

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

Aggregates don't have Potential until they are instantiated as PRMAttribute, so this will raise an OperationNotAllowed exception.

See gum::PRMClassElement::cpf().

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

Definition at line 182 of file PRMAggregate_tpl.h.

182  {
183  GUM_ERROR(OperationNotAllowed, "This is an aggregate.")
184  }
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ elt_type()

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

See gum::PRMClassElement::elt_type().

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

Definition at line 91 of file PRMAggregate_tpl.h.

◆ 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.

83  {
84  switch (type) {
85  case prm_type::CLASS:
86  return "PRMType::CLASS";
87 
89  return "PRMType::CLASS_ELT";
90 
91  case prm_type::TYPE:
92  return "PRMType::TYPE";
93 
94  case prm_type::SYSTEM:
95  return "PRMType::SYSTEM";
96 
97  case prm_type::INSTANCE:
98  return "PRMType::INSTANCE";
99 
101  return "PRMType::PRM_INTERFACE";
102 
103  default:
104  return "unknown";
105  }
106  }

◆ 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:
106  return "prm_attribute";
107 
108  case prm_aggregate:
109  return "prm_aggregate";
110 
111  case prm_refslot:
112  return "prm_refslot";
113 
114  case prm_slotchain:
115  return "prm_slotchain";
116 
117  case prm_parameter:
118  return "prm_parameter";
119 
120  default:
121  return "unknown";
122  }
123  }
virtual PRMType & type()=0
Return a reference over the gum::PRMType of this class element.

◆ getCastDescendant()

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

See gum::PRMClassElement::elt_type().

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

Definition at line 236 of file PRMAggregate_tpl.h.

236  {
237  PRMScalarAttribute< GUM_SCALAR >* cast = 0;
238 
239  try {
240  cast = new PRMScalarAttribute< GUM_SCALAR >(this->name(), type().superType());
241  } catch (NotFound&) {
242  GUM_ERROR(OperationNotAllowed, "this PRMAggregate can not have cast descendant")
243  }
244 
245  cast->addParent(*this);
246  const DiscreteVariable& my_var = type().variable();
247  DiscreteVariable& cast_var = cast->type().variable();
248  Instantiation inst(cast->cpf());
249 
250  for (inst.setFirst(); !inst.end(); inst.inc()) {
251  if (type().label_map()[inst.val(my_var)] == inst.val(cast_var)) {
252  cast->cpf().set(inst, 1);
253  } else {
254  cast->cpf().set(inst, 0);
255  }
256  }
257 
258  return cast;
259  }
PRMType & superType()
Returns the super type of this type.
Definition: PRMType_inl.h:35
DiscreteVariable & variable()
Return a reference on the DiscreteVariable contained in this.
Definition: PRMType_inl.h:44
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
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::PRMClassElement::type().
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:88
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ hasLabel()

template<typename GUM_SCALAR >
INLINE bool gum::prm::PRMAggregate< GUM_SCALAR >::hasLabel ( ) const

Returns true if the label is defined.

Definition at line 123 of file PRMAggregate_tpl.h.

123  {
124  return *_label_ != INT_MAX;
125  }
std::shared_ptr< Idx > _label_
Some aggregators applies only on a given label. This attribute must have the concerned Idx...
Definition: PRMAggregate.h:274

◆ 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 51 of file PRMClassElement_tpl.h.

51  {
52  return _id_;
53  }
NodeId _id_
The node&#39;s id of this element.

◆ 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 136 of file PRMClassElement.h.

136  {
137  return elt.elt_type() == prm_aggregate;
138  }

◆ 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 131 of file PRMClassElement.h.

131  {
132  return elt.elt_type() == prm_attribute;
133  }

◆ isClass()

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

Returns true if obj_ptr is of type Class.

Definition at line 109 of file PRMObject.h.

References gum::prm::PRMObject::PRMObject().

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

◆ isDecomposable()

template<typename GUM_SCALAR >
INLINE bool gum::prm::PRMAggregate< GUM_SCALAR >::isDecomposable ( ) const

Returns true if the aggregator is decomposable.

Definition at line 128 of file PRMAggregate_tpl.h.

128  {
129  switch (agg_type()) {
130  case AggregateType::MIN: {
131  return aggregator::Min< GUM_SCALAR >().isDecomposable();
132  }
133  case AggregateType::MAX: {
134  return aggregator::Max< GUM_SCALAR >().isDecomposable();
135  }
136  case AggregateType::OR: {
137  return aggregator::Or< GUM_SCALAR >().isDecomposable();
138  }
139  case AggregateType::AND: {
140  return aggregator::And< GUM_SCALAR >().isDecomposable();
141  }
143  return aggregator::Amplitude< GUM_SCALAR >().isDecomposable();
144  }
145  case AggregateType::MEDIAN: {
146  return aggregator::Median< GUM_SCALAR >().isDecomposable();
147  }
148  case AggregateType::EXISTS: {
149  return aggregator::Exists< GUM_SCALAR >(label()).isDecomposable();
150  }
151  case AggregateType::FORALL: {
152  return aggregator::Forall< GUM_SCALAR >(label()).isDecomposable();
153  }
154  case AggregateType::COUNT: {
155  return aggregator::Count< GUM_SCALAR >(label()).isDecomposable();
156  }
157  case AggregateType::SUM: {
158  return aggregator::Sum< GUM_SCALAR >().isDecomposable();
159  }
160  default: {
161  GUM_ERROR(OperationNotAllowed, "Unknown aggregator.")
162  }
163  }
164  }
AggregateType agg_type() const
Returns the aggregate of *this.
bool isDecomposable() const
Returns true if the aggregator is decomposable.
Idx label() const
Returns the label&#39;s index on which this aggregate applies.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ isInstance()

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

Returns true if obj_ptr is of type PRMInstance.

Definition at line 117 of file PRMObject.h.

References gum::prm::PRMObject::PRMObject().

117  {
118  return obj.obj_type() == prm_type::INSTANCE;
119  }
+ 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 112 of file PRMObject.h.

References gum::prm::PRMObject::PRMObject().

112  {
113  return obj.obj_type() == prm_type::PRM_INTERFACE;
114  }
+ 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 146 of file PRMClassElement.h.

146  {
147  return elt.elt_type() == prm_parameter;
148  }

◆ 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 126 of file PRMClassElement.h.

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

◆ 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 141 of file PRMClassElement.h.

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

◆ label()

template<typename GUM_SCALAR >
INLINE Idx gum::prm::PRMAggregate< GUM_SCALAR >::label ( ) const

Returns the label's index on which this aggregate applies.

Exceptions
OperationNotAllowedRaised if the aggregate does not applies on a label.

Definition at line 102 of file PRMAggregate_tpl.h.

102  {
103  if (*_label_ != INT_MAX) return *_label_;
104  GUM_ERROR(OperationNotAllowed, "no label defined for this aggregate")
105  }
std::shared_ptr< Idx > _label_
Some aggregators applies only on a given label. This attribute must have the concerned Idx...
Definition: PRMAggregate.h:274
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ labelValue()

template<typename GUM_SCALAR >
INLINE const std::string & gum::prm::PRMAggregate< GUM_SCALAR >::labelValue ( ) const

See gum::PRMClassElement::elt_type().

Definition at line 108 of file PRMAggregate_tpl.h.

108  {
109  return _label_value_;
110  }
std::string _label_value_
The AggregateType of this aggregate.
Definition: PRMAggregate.h:276

◆ 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.

79 { return "("; }

◆ name() [1/2]

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

Returns the name of this object.

Definition at line 34 of file PRMObject_inl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

34 { return _name_; }
std::string _name_
Definition: PRMObject.h:205
+ Here is the call graph for this function:

◆ name() [2/2]

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

Change the name of the PRM Object.

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

Definition at line 38 of file PRMObject_inl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

38 { _name_ = name; }
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
std::string _name_
Definition: PRMObject.h:205
+ 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 56 of file PRMClassElement_tpl.h.

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

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

46 { return _name_ != obj.name(); }
std::string _name_
Definition: PRMObject.h:205
+ Here is the call graph for this function:

◆ operator=()

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

Copy operator. Don't use it.

Definition at line 85 of file PRMAggregate_tpl.h.

85  {
86  GUM_ERROR(FatalError, "illegal call to gum::PRMAggregate copy operator.")
87  }
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

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

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

42 { return _name_ == obj.name(); }
std::string _name_
Definition: PRMObject.h:205
+ Here is the call 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.

80 { return ")"; }

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

66  {
67  return safeName_;
68  }
std::string safeName_
The safe name of this PRMClassElement.

◆ 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 61 of file PRMClassElement_tpl.h.

61  {
62  _id_ = id;
63  }
NodeId _id_
The node&#39;s id of this element.
NodeId id() const
Returns the NodeId of this element in it&#39;s class DAG.

◆ setLabel() [1/2]

template<typename GUM_SCALAR >
INLINE void gum::prm::PRMAggregate< GUM_SCALAR >::setLabel ( Idx  idx)

Set the aggregator's label.

Definition at line 113 of file PRMAggregate_tpl.h.

113  {
114  (*_label_) = idx;
115  }

◆ setLabel() [2/2]

template<typename GUM_SCALAR >
INLINE void gum::prm::PRMAggregate< GUM_SCALAR >::setLabel ( const std::string &  label)

See gum::PRMClassElement::elt_type().

Definition at line 118 of file PRMAggregate_tpl.h.

118  {
119  _label_value_ = value;
120  }
std::string _label_value_
The AggregateType of this aggregate.
Definition: PRMAggregate.h:276

◆ sharedLabel() [1/2]

template<typename GUM_SCALAR >
INLINE std::shared_ptr< Idx > gum::prm::PRMAggregate< GUM_SCALAR >::sharedLabel ( ) const

Returns the shared_ptr holding this Aggregate label.

This is used for inherited Aggregates to share labels in O3PRM.

Definition at line 262 of file PRMAggregate_tpl.h.

262  {
263  return _label_;
264  }
std::shared_ptr< Idx > _label_
Some aggregators applies only on a given label. This attribute must have the concerned Idx...
Definition: PRMAggregate.h:274

◆ sharedLabel() [2/2]

template<typename GUM_SCALAR >
INLINE void gum::prm::PRMAggregate< GUM_SCALAR >::sharedLabel ( std::shared_ptr< Idx label)

Sets the shared_ptr of this Aggregate.

This is used for inherited aggregates to share labels in O3PRM.

Definition at line 267 of file PRMAggregate_tpl.h.

267  {
268  this->_label_ = label;
269  }
std::shared_ptr< Idx > _label_
Some aggregators applies only on a given label. This attribute must have the concerned Idx...
Definition: PRMAggregate.h:274
Idx label() const
Returns the label&#39;s index on which this aggregate applies.

◆ str2enum()

template<typename GUM_SCALAR>
static AggregateType gum::prm::PRMAggregate< GUM_SCALAR >::str2enum ( const std::string &  str)
inlinestatic

Static method which returns the AggregateType given its string representation.

We suppose that str is given either entirely in lower case or upper case. It will also match if only the first letter is in upper case.

Exceptions
RaiseNotFound exception if no matches is found.

Definition at line 101 of file PRMAggregate.h.

101  {
102  if (toLower(str) == "min") {
103  return AggregateType::MIN;
104  } else if (toLower(str) == "max") {
105  return AggregateType::MAX;
106  } else if (toLower(str) == "count") {
107  return AggregateType::COUNT;
108  } else if (toLower(str) == "exists") {
109  return AggregateType::EXISTS;
110  } else if (toLower(str) == "or") {
111  return AggregateType::OR;
112  } else if (toLower(str) == "and") {
113  return AggregateType::AND;
114  } else if (toLower(str) == "forall") {
115  return AggregateType::FORALL;
116  } else if (toLower(str) == "amplitude") {
118  } else if (toLower(str) == "median") {
119  return AggregateType::MEDIAN;
120  } else if (toLower(str) == "sum") {
121  return AggregateType::SUM;
122  } else {
123  std::string msg = "Unknown aggregate: ";
124  msg.append(str);
125  GUM_ERROR(NotFound, msg)
126  }
127  }
std::string toLower(std::string str)
Returns the lowercase version of str.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51

◆ type() [1/2]

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

See gum::PRMClassElement::type().

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

Definition at line 167 of file PRMAggregate_tpl.h.

167  {
168  return *_type_;
169  }
PRMType * _type_
The random variable type of this aggregate It is deleted with the aggregate.
Definition: PRMAggregate.h:269

◆ type() [2/2]

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

See gum::PRMClassElement::type().

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

Definition at line 172 of file PRMAggregate_tpl.h.

172  {
173  return *_type_;
174  }
PRMType * _type_
The random variable type of this aggregate It is deleted with the aggregate.
Definition: PRMAggregate.h:269

Friends And Related Function Documentation

◆ PRMClass< GUM_SCALAR >

template<typename GUM_SCALAR>
friend class PRMClass< GUM_SCALAR >
friend

Definition at line 70 of file PRMAggregate.h.

Member Data Documentation

◆ _agg_type_

template<typename GUM_SCALAR>
AggregateType gum::prm::PRMAggregate< GUM_SCALAR >::_agg_type_
private

The AggregateType of this aggregate.

Definition at line 265 of file PRMAggregate.h.

◆ _label_

template<typename GUM_SCALAR>
std::shared_ptr< Idx > gum::prm::PRMAggregate< GUM_SCALAR >::_label_
private

Some aggregators applies only on a given label. This attribute must have the concerned Idx. If not initialized the pointer equals 0. It is deleted with the aggregate.

Definition at line 274 of file PRMAggregate.h.

◆ _label_value_

template<typename GUM_SCALAR>
std::string gum::prm::PRMAggregate< GUM_SCALAR >::_label_value_
private

The AggregateType of this aggregate.

Definition at line 276 of file PRMAggregate.h.

◆ _type_

template<typename GUM_SCALAR>
PRMType* gum::prm::PRMAggregate< GUM_SCALAR >::_type_
private

The random variable type of this aggregate It is deleted with the aggregate.

Definition at line 269 of file PRMAggregate.h.

◆ safeName_

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

The safe name of this PRMClassElement.

Definition at line 265 of file PRMClassElement.h.


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