aGrUM  0.20.2
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);
55  this->type__->variable().setName(name);
56  }
void setName(const std::string &theValue)
sets the name of the variable
AggregateType agg_type__
The AggregateType of this aggregate.
Definition: PRMAggregate.h:269
std::shared_ptr< Idx > label__
Some aggregators applies only on a given label. This attribute must have the concerned Idx...
Definition: PRMAggregate.h:278
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
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
PRMType * type__
The random variable type of this aggregate It is deleted with the aggregate.
Definition: PRMAggregate.h:273
Size Idx
Type for indexes.
Definition: types.h:52
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

◆ 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 59 of file PRMAggregate_tpl.h.

62  :
63  PRMClassElement< GUM_SCALAR >(name),
64  agg_type__(aggType), type__(new PRMType(rvType)),
65  label__(std::shared_ptr< Idx >(new Idx(label))) {
66  GUM_CONSTRUCTOR(PRMAggregate);
69  this->type__->variable().setName(name);
70  }
void setName(const std::string &theValue)
sets the name of the variable
AggregateType agg_type__
The AggregateType of this aggregate.
Definition: PRMAggregate.h:269
std::shared_ptr< Idx > label__
Some aggregators applies only on a given label. This attribute must have the concerned Idx...
Definition: PRMAggregate.h:278
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
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
PRMType * type__
The random variable type of this aggregate It is deleted with the aggregate.
Definition: PRMAggregate.h:273
Size Idx
Type for indexes.
Definition: types.h:52
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

◆ ~PRMAggregate()

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

Destructor.

Definition at line 73 of file PRMAggregate_tpl.h.

73  {
74  GUM_DESTRUCTOR(PRMAggregate);
75  delete type__;
76  }
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:273

◆ 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 79 of file PRMAggregate_tpl.h.

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

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 238 of file PRMAggregate_tpl.h.

239  {}

◆ 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 233 of file PRMAggregate_tpl.h.

234  {}

◆ 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 100 of file PRMAggregate_tpl.h.

100  {
101  return agg_type__;
102  }
AggregateType agg_type__
The AggregateType of this aggregate.
Definition: PRMAggregate.h:269

◆ 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 191 of file PRMAggregate_tpl.h.

191  {
192  switch (agg_type()) {
193  case AggregateType::MIN: {
194  return new aggregator::Min< GUM_SCALAR >();
195  }
196  case AggregateType::MAX: {
197  return new aggregator::Max< GUM_SCALAR >();
198  }
199  case AggregateType::OR: {
200  return new aggregator::Or< GUM_SCALAR >();
201  }
202  case AggregateType::AND: {
203  return new aggregator::And< GUM_SCALAR >();
204  }
206  return new aggregator::Amplitude< GUM_SCALAR >();
207  }
208  case AggregateType::MEDIAN: {
209  return new aggregator::Median< GUM_SCALAR >();
210  }
211  case AggregateType::EXISTS: {
212  return new aggregator::Exists< GUM_SCALAR >(label());
213  }
214  case AggregateType::FORALL: {
215  return new aggregator::Forall< GUM_SCALAR >(label());
216  }
217  case AggregateType::COUNT: {
218  return new aggregator::Count< GUM_SCALAR >(label());
219  }
220  case AggregateType::SUM: {
221  return new aggregator::Sum< GUM_SCALAR >();
222  }
223  default: {
224  GUM_ERROR(OperationNotAllowed, "Unknown aggregator.");
225  }
226  }
227  return nullptr;
228  }
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:54

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

75  {
76  if (type().isSubTypeOf(t)) {
77  return PRMObject::LEFT_CAST() + t.name() + PRMObject::RIGHT_CAST()
78  + name();
79  } else {
80  GUM_ERROR(OperationNotAllowed, "illegal cast");
81  }
82  }
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:54

◆ 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 180 of file PRMAggregate_tpl.h.

180  {
181  GUM_ERROR(OperationNotAllowed, "This is an aggregate.");
182  }
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54

◆ 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 185 of file PRMAggregate_tpl.h.

185  {
186  GUM_ERROR(OperationNotAllowed, "This is an aggregate.");
187  }
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54

◆ 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 94 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 243 of file PRMAggregate_tpl.h.

243  {
244  PRMScalarAttribute< GUM_SCALAR >* cast = 0;
245 
246  try {
247  cast = new PRMScalarAttribute< GUM_SCALAR >(this->name(),
248  type().superType());
249  } catch (NotFound&) {
250  GUM_ERROR(OperationNotAllowed,
251  "this PRMAggregate can not have cast descendant");
252  }
253 
254  cast->addParent(*this);
255  const DiscreteVariable& my_var = type().variable();
256  DiscreteVariable& cast_var = cast->type().variable();
257  Instantiation inst(cast->cpf());
258 
259  for (inst.setFirst(); !inst.end(); inst.inc()) {
260  if (type().label_map()[inst.val(my_var)] == inst.val(cast_var)) {
261  cast->cpf().set(inst, 1);
262  } else {
263  cast->cpf().set(inst, 0);
264  }
265  }
266 
267  return cast;
268  }
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:93
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54

◆ hasLabel()

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

Returns true if the label is defined.

Definition at line 126 of file PRMAggregate_tpl.h.

126  {
127  return *label__ != INT_MAX;
128  }
std::shared_ptr< Idx > label__
Some aggregators applies only on a given label. This attribute must have the concerned Idx...
Definition: PRMAggregate.h:278

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

54  {
55  return id__;
56  }
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 137 of file PRMClassElement.h.

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

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

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

◆ 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  {
110  return obj.obj_type() == prm_type::CLASS;
111  }
+ 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 131 of file PRMAggregate_tpl.h.

131  {
132  switch (agg_type()) {
133  case AggregateType::MIN: {
134  return aggregator::Min< GUM_SCALAR >().isDecomposable();
135  }
136  case AggregateType::MAX: {
137  return aggregator::Max< GUM_SCALAR >().isDecomposable();
138  }
139  case AggregateType::OR: {
140  return aggregator::Or< GUM_SCALAR >().isDecomposable();
141  }
142  case AggregateType::AND: {
143  return aggregator::And< GUM_SCALAR >().isDecomposable();
144  }
146  return aggregator::Amplitude< GUM_SCALAR >().isDecomposable();
147  }
148  case AggregateType::MEDIAN: {
149  return aggregator::Median< GUM_SCALAR >().isDecomposable();
150  }
151  case AggregateType::EXISTS: {
152  return aggregator::Exists< GUM_SCALAR >(label()).isDecomposable();
153  }
154  case AggregateType::FORALL: {
155  return aggregator::Forall< GUM_SCALAR >(label()).isDecomposable();
156  }
157  case AggregateType::COUNT: {
158  return aggregator::Count< GUM_SCALAR >(label()).isDecomposable();
159  }
160  case AggregateType::SUM: {
161  return aggregator::Sum< GUM_SCALAR >().isDecomposable();
162  }
163  default: {
164  GUM_ERROR(OperationNotAllowed, "Unknown aggregator.");
165  }
166  }
167  }
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:54

◆ isInstance()

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

Returns true if obj_ptr is of type PRMInstance.

Definition at line 119 of file PRMObject.h.

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

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

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

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

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

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

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

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

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

◆ 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 105 of file PRMAggregate_tpl.h.

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

◆ labelValue()

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

See gum::PRMClassElement::elt_type().

Definition at line 111 of file PRMAggregate_tpl.h.

111  {
112  return label_value__;
113  }
std::string label_value__
The AggregateType of this aggregate.
Definition: PRMAggregate.h:280

◆ 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:207
+ 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; }
std::string name__
Definition: PRMObject.h:207
const std::string & name() const
Returns the name of this object.
Definition: PRMObject_inl.h:34
+ 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 59 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 48 of file PRMObject_inl.h.

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

48  {
49  return name__ != obj.name();
50  }
std::string name__
Definition: PRMObject.h:207
+ 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 87 of file PRMAggregate_tpl.h.

88  {
89  GUM_ERROR(FatalError, "illegal call to gum::PRMAggregate copy operator.");
90  }
#define GUM_ERROR(type, msg)
Definition: exceptions.h:54

◆ 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  {
43  return name__ == obj.name();
44  }
std::string name__
Definition: PRMObject.h:207
+ 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 69 of file PRMClassElement_tpl.h.

69  {
70  return safeName_;
71  }
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 64 of file PRMClassElement_tpl.h.

64  {
65  id__ = id;
66  }
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 116 of file PRMAggregate_tpl.h.

116  {
117  (*label__) = idx;
118  }

◆ 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 121 of file PRMAggregate_tpl.h.

121  {
122  label_value__ = value;
123  }
std::string label_value__
The AggregateType of this aggregate.
Definition: PRMAggregate.h:280

◆ 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 271 of file PRMAggregate_tpl.h.

271  {
272  return label__;
273  }
std::shared_ptr< Idx > label__
Some aggregators applies only on a given label. This attribute must have the concerned Idx...
Definition: PRMAggregate.h:278

◆ 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 277 of file PRMAggregate_tpl.h.

277  {
278  this->label__ = label;
279  }
std::shared_ptr< Idx > label__
Some aggregators applies only on a given label. This attribute must have the concerned Idx...
Definition: PRMAggregate.h:278
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:54

◆ 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 170 of file PRMAggregate_tpl.h.

170  {
171  return *type__;
172  }
PRMType * type__
The random variable type of this aggregate It is deleted with the aggregate.
Definition: PRMAggregate.h:273

◆ 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 175 of file PRMAggregate_tpl.h.

175  {
176  return *type__;
177  }
PRMType * type__
The random variable type of this aggregate It is deleted with the aggregate.
Definition: PRMAggregate.h:273

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 269 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 278 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 280 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 266 of file PRMClassElement.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 273 of file PRMAggregate.h.


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