aGrUM  0.16.0
observation.h
Go to the documentation of this file.
1 
30 // #define TRACE_ALGO
31 // =========================================================================
32 #ifndef GUM_OBSERVATION_H
33 #define GUM_OBSERVATION_H
34 // =========================================================================
35 #include <agrum/core/hashTable.h>
37 // =========================================================================
39 // =========================================================================
40 
41 namespace gum {
42 
53  class Observation {
54  public:
55  // ==========================================================================
57  // ==========================================================================
59 
60  // ###################################################################
62  // ###################################################################
63  Observation() { GUM_CONSTRUCTOR(Observation); }
64 
65  // ###################################################################
67  // ###################################################################
68  ~Observation() { GUM_DESTRUCTOR(Observation); }
69 
70  // ============================================================================
72  // ============================================================================
73  void* operator new(size_t s) {
75  }
76  void operator delete(void* p) {
78  }
79 
81 
82  // ==========================================================================
84  // ==========================================================================
86 
87  // ###################################################################
93  // ###################################################################
94  INLINE Idx modality(const DiscreteVariable* var) const {
95  return __varInst[var];
96  }
97  INLINE Idx rModality(const DiscreteVariable* var) const {
98  return __rInst[var];
99  }
100 
101  // ###################################################################
108  // ###################################################################
109  INLINE void setModality(const DiscreteVariable* var, Idx modality) {
110  __varInst.insert(var, modality);
111  }
112  INLINE void setRModality(const DiscreteVariable* var, Idx modality) {
113  __rInst.insert(var, modality);
114  }
115 
116  // ###################################################################
117  // Returns the reward obtained during this observation
118  // ###################################################################
119  double reward() const { return __reward; }
120 
121  // ###################################################################
122  // Sets the reward obtained during this observation
123  // ###################################################################
124  void setReward(double reward) { __reward = reward; }
125 
128  std::string toString() const;
129 
130  // ==========================================================================
132  // ==========================================================================
134 
135  // ###################################################################
138  // ###################################################################
141  return __varInst.cbeginSafe();
142  }
143 
144  // ###################################################################
147  // ###################################################################
150  return __varInst.cendSafe();
151  }
152 
154 
155  private:
159 
161  double __reward;
162  };
163 
164 } /* namespace gum */
165 
166 
167 #endif // GUM_OBSERVATION_H
double __reward
The reward associated to this transition.
Definition: observation.h:161
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Safe Const Iterators for hashtables.
Definition: hashTable.h:1918
~Observation()
Default destructor.
Definition: observation.h:68
HashTableConstIteratorSafe< const DiscreteVariable *, Idx > cendVariablesSafe() const
Returns an const safe iterator on the end of the list of variables in this observation.
Definition: observation.h:149
Base class for discrete random variable.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
The class for generic Hash Tables.
Definition: hashTable.h:679
Observation()
Default constructor.
Definition: observation.h:63
HashTableConstIteratorSafe< const DiscreteVariable *, Idx > cbeginVariablesSafe() const
Returns an const safe iterator on the beginning of the list of variables in this observation.
Definition: observation.h:140
void setReward(double reward)
Returns the modality assumed by the given variable in this observation.
Definition: observation.h:124
double reward() const
Returns the modality assumed by the given variable in this observation.
Definition: observation.h:119
INLINE void setRModality(const DiscreteVariable *var, Idx modality)
Returns the modality assumed by the given variable in this observation.
Definition: observation.h:112
INLINE Idx rModality(const DiscreteVariable *var) const
Returns the modality assumed by the given variable in this observation.
Definition: observation.h:97
std::string toString() const
Definition: observation.cpp:27
HashTable< const DiscreteVariable *, Idx > __rInst
Definition: observation.h:158
INLINE Idx modality(const DiscreteVariable *var) const
Returns the modality assumed by the given variable in this observation.
Definition: observation.h:94
void deallocate(void *pDeallocatedObject, const size_t &objectSize)
Deallocates an object.
Size Idx
Type for indexes.
Definition: types.h:53
void * allocate(const size_t &objectSize)
Allocates a block.
static SmallObjectAllocator & instance()
HashTable< const DiscreteVariable *, Idx > __varInst
Table giving for every variables its instantiation.
Definition: observation.h:157
INLINE void setModality(const DiscreteVariable *var, Idx modality)
Sets the modality assumed by the given variable in this observation.
Definition: observation.h:109
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.