aGrUM  0.14.2
observation.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
27 // #define TRACE_ALGO
28 // =========================================================================
29 #ifndef GUM_OBSERVATION_H
30 #define GUM_OBSERVATION_H
31 // =========================================================================
32 #include <agrum/core/hashTable.h>
34 // =========================================================================
36 // =========================================================================
37 
38 namespace gum {
39 
50  class Observation {
51  public:
52  // ==========================================================================
54  // ==========================================================================
56 
57  // ###################################################################
59  // ###################################################################
60  Observation() { GUM_CONSTRUCTOR(Observation); }
61 
62  // ###################################################################
64  // ###################################################################
65  ~Observation() { GUM_DESTRUCTOR(Observation); }
66 
67  // ============================================================================
69  // ============================================================================
70  void* operator new(size_t s) {
72  }
73  void operator delete(void* p) {
75  }
76 
78 
79  // ==========================================================================
81  // ==========================================================================
83 
84  // ###################################################################
90  // ###################################################################
91  INLINE Idx modality(const DiscreteVariable* var) const {
92  return __varInst[var];
93  }
94  INLINE Idx rModality(const DiscreteVariable* var) const {
95  return __rInst[var];
96  }
97 
98  // ###################################################################
105  // ###################################################################
106  INLINE void setModality(const DiscreteVariable* var, Idx modality) {
107  __varInst.insert(var, modality);
108  }
109  INLINE void setRModality(const DiscreteVariable* var, Idx modality) {
110  __rInst.insert(var, modality);
111  }
112 
113  // ###################################################################
114  // Returns the reward obtained during this observation
115  // ###################################################################
116  double reward() const { return __reward; }
117 
118  // ###################################################################
119  // Sets the reward obtained during this observation
120  // ###################################################################
121  void setReward(double reward) { __reward = reward; }
122 
125  std::string toString() const;
126 
127  // ==========================================================================
129  // ==========================================================================
131 
132  // ###################################################################
135  // ###################################################################
138  return __varInst.cbeginSafe();
139  }
140 
141  // ###################################################################
144  // ###################################################################
147  return __varInst.cendSafe();
148  }
149 
151 
152  private:
156 
158  double __reward;
159  };
160 
161 } /* namespace gum */
162 
163 
164 #endif // GUM_OBSERVATION_H
double __reward
The reward associated to this transition.
Definition: observation.h:158
Headers of gum::SmallObjectAllocator.
Base class for discrete random variable.
Safe Const Iterators for hashtables.
Definition: hashTable.h:1915
~Observation()
Default destructor.
Definition: observation.h:65
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:146
Base class for discrete random variable.
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
The class for generic Hash Tables.
Definition: hashTable.h:676
Observation()
Default constructor.
Definition: observation.h:60
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:137
void setReward(double reward)
Returns the modality assumed by the given variable in this observation.
Definition: observation.h:121
double reward() const
Returns the modality assumed by the given variable in this observation.
Definition: observation.h:116
INLINE void setRModality(const DiscreteVariable *var, Idx modality)
Returns the modality assumed by the given variable in this observation.
Definition: observation.h:109
INLINE Idx rModality(const DiscreteVariable *var) const
Returns the modality assumed by the given variable in this observation.
Definition: observation.h:94
std::string toString() const
Definition: observation.cpp:25
HashTable< const DiscreteVariable *, Idx > __rInst
Definition: observation.h:155
INLINE Idx modality(const DiscreteVariable *var) const
Returns the modality assumed by the given variable in this observation.
Definition: observation.h:91
void deallocate(void *pDeallocatedObject, const size_t &objectSize)
Deallocates an object.
Size Idx
Type for indexes.
Definition: types.h:50
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:154
INLINE void setModality(const DiscreteVariable *var, Idx modality)
Sets the modality assumed by the given variable in this observation.
Definition: observation.h:106
Class hash tables iterators.