aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
gum::Observation Class Reference

#include <agrum/FMDP/learning/observation.h>

Collaboration diagram for gum::Observation:

Public Member Functions

std::string toString () const
Constructor & destructor.
 Observation ()
 Default constructor.
 ~Observation ()
 Default destructor.
void * operator new (size_t s)
 Allocators and Deallocators redefinition.
void operator delete (void *p)
 Default constructor.
Observation Handlers
Idx modality (const DiscreteVariable *var) const
 Returns the modality assumed by the given variable in this observation.
Idx rModality (const DiscreteVariable *var) const
 Returns the modality assumed by the given variable in this observation.
void setModality (const DiscreteVariable *var, Idx modality)
 Sets the modality assumed by the given variable in this observation.
void setRModality (const DiscreteVariable *var, Idx modality)
 Returns the modality assumed by the given variable in this observation.
double reward () const
 Returns the modality assumed by the given variable in this observation.
void setReward (double reward)
 Returns the modality assumed by the given variable in this observation.
Iterators on Variables
HashTableConstIteratorSafe< const DiscreteVariable *, IdxcbeginVariablesSafe () const
 Returns an const safe iterator on the beginning of the list of variables in this observation.
HashTableConstIteratorSafe< const DiscreteVariable *, IdxcendVariablesSafe () const
 Returns an const safe iterator on the end of the list of variables in this observation.

Private Attributes

HashTable< const DiscreteVariable *, Idx_varInst_
 Table giving for every variables its instantiation.
HashTable< const DiscreteVariable *, Idx_rInst_
double _reward_
 The reward associated to this transition.

Detailed Description

Definition at line 73 of file observation.h.

Constructor & Destructor Documentation

◆ Observation()

INLINE gum::Observation::Observation ( )

Default constructor.

Definition at line 48 of file observation_inl.h.

48 {
49 GUM_CONSTRUCTOR(Observation);
50 ;
51 }
Observation()
Default constructor.

References Observation().

Referenced by Observation(), ~Observation(), and operator delete().

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

◆ ~Observation()

INLINE gum::Observation::~Observation ( )

Default destructor.

Definition at line 53 of file observation_inl.h.

53 {
54 GUM_DESTRUCTOR(Observation);
55 ;
56 }

References Observation().

Here is the call graph for this function:

Member Function Documentation

◆ cbeginVariablesSafe()

INLINE HashTableConstIteratorSafe< const DiscreteVariable *, Idx > gum::Observation::cbeginVariablesSafe ( ) const

Returns an const safe iterator on the beginning of the list of variables in this observation.

Definition at line 83 of file observation_inl.h.

83 {
84 return _varInst_.cbeginSafe();
85 }
HashTable< const DiscreteVariable *, Idx > _varInst_
Table giving for every variables its instantiation.

References _varInst_.

◆ cendVariablesSafe()

INLINE HashTableConstIteratorSafe< const DiscreteVariable *, Idx > gum::Observation::cendVariablesSafe ( ) const

Returns an const safe iterator on the end of the list of variables in this observation.

Definition at line 88 of file observation_inl.h.

88 {
89 return _varInst_.cendSafe();
90 }

References _varInst_.

◆ modality()

INLINE Idx gum::Observation::modality ( const DiscreteVariable * var) const

Returns the modality assumed by the given variable in this observation.

Exceptions
NotFoundif variable is not in this observation

Definition at line 66 of file observation_inl.h.

66{ return _varInst_[var]; }

References _varInst_.

Referenced by gum::NodeDatabase< AttributeSelection, isScalar >::_addObservation_(), gum::IncrementalGraphLearner< AttributeSelection, isScalar >::_assumeValue_(), gum::IncrementalGraphLearner< AttributeSelection, isScalar >::_branchObs_(), setModality(), and setRModality().

Here is the caller graph for this function:

◆ operator delete()

INLINE void gum::Observation::operator delete ( void * p)

Default constructor.

Definition at line 62 of file observation_inl.h.

62 {
64 }
static SmallObjectAllocator & instance()
void deallocate(void *pDeallocatedObject, const size_t &objectSize)
Deallocates an object.

References Observation(), gum::SmallObjectAllocator::deallocate(), and gum::SmallObjectAllocator::instance().

Here is the call graph for this function:

◆ operator new()

INLINE void * gum::Observation::operator new ( size_t s)

Allocators and Deallocators redefinition.

Definition at line 58 of file observation_inl.h.

58 {
60 }
void * allocate(const size_t &objectSize)
Allocates a block.

References gum::SmallObjectAllocator::allocate(), and gum::SmallObjectAllocator::instance().

Here is the call graph for this function:

◆ reward()

INLINE double gum::Observation::reward ( ) const

Returns the modality assumed by the given variable in this observation.

Exceptions
NotFoundif variable is not in this observation

Definition at line 78 of file observation_inl.h.

78{ return _reward_; }
double _reward_
The reward associated to this transition.

References _reward_.

Referenced by gum::NodeDatabase< AttributeSelection, isScalar >::_addObservation_(), gum::IncrementalGraphLearner< AttributeSelection, isScalar >::_assumeValue_(), gum::FMDPLearner< VariableAttributeSelection, RewardAttributeSelection, LearnerSelection >::addObservation(), and setReward().

Here is the caller graph for this function:

◆ rModality()

INLINE Idx gum::Observation::rModality ( const DiscreteVariable * var) const

Returns the modality assumed by the given variable in this observation.

Exceptions
NotFoundif variable is not in this observation

Definition at line 68 of file observation_inl.h.

68{ return _rInst_[var]; }
HashTable< const DiscreteVariable *, Idx > _rInst_

References _rInst_.

Referenced by gum::NodeDatabase< AttributeSelection, isScalar >::_addObservation_(), and gum::IncrementalGraphLearner< AttributeSelection, isScalar >::_branchObs_().

Here is the caller graph for this function:

◆ setModality()

INLINE void gum::Observation::setModality ( const DiscreteVariable * var,
Idx modality )

Sets the modality assumed by the given variable in this observation.

Exceptions
DuplicateElementif a value has already be assigned to this variable

Definition at line 70 of file observation_inl.h.

70 {
71 _varInst_.insert(var, modality);
72 }
Idx modality(const DiscreteVariable *var) const
Returns the modality assumed by the given variable in this observation.

References _varInst_, and modality().

Referenced by gum::SDYNA::feedback().

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

◆ setReward()

INLINE void gum::Observation::setReward ( double reward)

Returns the modality assumed by the given variable in this observation.

Exceptions
NotFoundif variable is not in this observation

Definition at line 80 of file observation_inl.h.

80{ _reward_ = reward; }
double reward() const
Returns the modality assumed by the given variable in this observation.

References _reward_, and reward().

Referenced by gum::SDYNA::feedback().

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

◆ setRModality()

INLINE void gum::Observation::setRModality ( const DiscreteVariable * var,
Idx modality )

Returns the modality assumed by the given variable in this observation.

Exceptions
NotFoundif variable is not in this observation

Definition at line 74 of file observation_inl.h.

74 {
75 _rInst_.insert(var, modality);
76 }

References _rInst_, and modality().

Referenced by gum::SDYNA::feedback().

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

◆ toString()

std::string gum::Observation::toString ( ) const

Definition at line 50 of file observation.cpp.

50 {
51 std::string status;
52 for (auto varIter = _varInst_.beginSafe(); varIter != _varInst_.endSafe(); ++varIter)
53 if (_rInst_.exists(varIter.key()))
54 status += std::format("| {} : {} -> {} |",
55 varIter.key()->name(),
56 varIter.val(),
57 _rInst_[varIter.key()]);
58 status += "\n";
59 return status;
60 }

References _rInst_, and _varInst_.

Member Data Documentation

◆ _reward_

double gum::Observation::_reward_
private

The reward associated to this transition.

Definition at line 166 of file observation.h.

Referenced by reward(), and setReward().

◆ _rInst_

HashTable< const DiscreteVariable*, Idx > gum::Observation::_rInst_
private

Definition at line 163 of file observation.h.

Referenced by rModality(), setRModality(), and toString().

◆ _varInst_

HashTable< const DiscreteVariable*, Idx > gum::Observation::_varInst_
private

Table giving for every variables its instantiation.

Definition at line 162 of file observation.h.

Referenced by cbeginVariablesSafe(), cendVariablesSafe(), modality(), setModality(), and toString().


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