aGrUM  0.16.0
fmdpLearner.h
Go to the documentation of this file.
1 
30 // =========================================================================
31 #ifndef GUM_FMDP_LEARNER_H
32 #define GUM_FMDP_LEARNER_H
33 // =========================================================================
34 #include <agrum/core/hashTable.h>
35 // =========================================================================
37 #include <agrum/FMDP/fmdp.h>
41 // =========================================================================
43 // =========================================================================
44 
45 namespace gum {
46 
57  template < TESTNAME VariableAttributeSelection,
58  TESTNAME RewardAttributeSelection,
59  LEARNERNAME LearnerSelection >
60  class FMDPLearner : public ILearningStrategy {
61  typedef
62  typename LearnerSelect< LearnerSelection,
66 
67  typedef typename LearnerSelect< LearnerSelection,
71 
74 
75  public:
76  // ==========================================================================
78  // ==========================================================================
80 
81  // ###################################################################
83  // ###################################################################
84  FMDPLearner(double learningThreshold,
85  bool actionReward,
86  double similarityThreshold = 0.05);
87 
88  // ###################################################################
90  // ###################################################################
91  ~FMDPLearner();
92 
94 
95  // ###################################################################
97  // ###################################################################
99  public:
100  // ==========================================================================
102  // ==========================================================================
103  void initialize(FMDP< double >* fmdp);
104 
105  // ==========================================================================
107  // ==========================================================================
110  }
111 
116  }
117 
121  ExactTerminalNodePolicy >::getTreeInstance();
122  }
123 
124 
125  // ==========================================================================
127  // ==========================================================================
130  Set< const DiscreteVariable* >& mainVariables,
131  const DiscreteVariable* learnedVar) {
133  target, mainVariables, learnedVar, Int2Type< LearnerSelection >());
134  }
135 
138  Set< const DiscreteVariable* >& mainVariables,
139  const DiscreteVariable* learnedVar,
141  return new VariableLearnerType(target,
144  mainVariables,
145  learnedVar);
146  }
147 
150  Set< const DiscreteVariable* >& mainVariables,
151  const DiscreteVariable* learnedVar,
153  return new VariableLearnerType(
154  target, __learningThreshold, mainVariables, learnedVar);
155  }
156 
157 
158  // ==========================================================================
160  // ==========================================================================
163  Set< const DiscreteVariable* >& mainVariables) {
165  target, mainVariables, Int2Type< LearnerSelection >());
166  }
167 
170  Set< const DiscreteVariable* >& mainVariables,
172  return new RewardLearnerType(
173  target, __learningThreshold, __similarityThreshold, mainVariables);
174  }
175 
178  Set< const DiscreteVariable* >& mainVariables,
180  return new RewardLearnerType(target, __learningThreshold, mainVariables);
181  }
182 
184 
185 
186  // ###################################################################
188  // ###################################################################
190  public:
191  // ==========================================================================
199  // ==========================================================================
200  bool addObservation(Idx actionId, const Observation* obs);
201 
202 
203  // ==========================================================================
207  // ==========================================================================
208  void updateFMDP();
209 
211 
212 
213  // ###################################################################
215  // ###################################################################
217  public:
218  // ==========================================================================
223  // ==========================================================================
224  Size size();
225 
226  // ==========================================================================
228  // ==========================================================================
230  const DiscreteVariable* var) const {
231  return __actionLearners[actionId]->getWithDefault(var, nullptr);
232  }
233 
234  virtual double rMax() const { return __rmax; }
235 
236  private:
237  double __rmax;
238 
239  public:
240  virtual double modaMax() const { return __modaMax; }
241 
242  private:
243  double __modaMax;
244 
246 
247 
248  private:
251 
253 
257 
258  const double __learningThreshold;
259  const double __similarityThreshold;
260  };
261 
262 
263 } /* namespace gum */
264 
266 
267 #endif // GUM_FMDP_LEARNER_H
MultiDimFunctionGraph< double > * __instantiateFunctionGraph(Int2Type< IMDDILEARNER >)
Initializes the learner.
Definition: fmdpLearner.h:113
Learn a graphical representation of a function as a decision tree.
Definition: iti.h:62
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
MultiDimFunctionGraph< double > * __instantiateFunctionGraph()
Initializes the learner.
Definition: fmdpLearner.h:108
void initialize(FMDP< double > *fmdp)
Initializes the learner.
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.
HashTable< Idx, VarLearnerTable *> __actionLearners
Definition: fmdpLearner.h:252
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
const IVisitableGraphLearner * varLearner(Idx actionId, const DiscreteVariable *var) const
extractCount
Definition: fmdpLearner.h:229
<agrum/FMDP/SDyna/IVisitableGraphLearner.h>
LearnerSelect< LearnerSelection, IMDDI< VariableAttributeSelection, false >, ITI< VariableAttributeSelection, false > >::type VariableLearnerType
Definition: fmdpLearner.h:65
FMDPLearner(double learningThreshold, bool actionReward, double similarityThreshold=0.05)
Default constructor.
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
~FMDPLearner()
Default destructor.
bool addObservation(Idx actionId, const Observation *obs)
Gives to the learner a new transition.
The class for generic Hash Tables.
Definition: hashTable.h:679
const double __learningThreshold
Definition: fmdpLearner.h:258
virtual double modaMax() const
learnerSize
Definition: fmdpLearner.h:240
double __rmax
learnerSize
Definition: fmdpLearner.h:237
FMDP< double > * __fmdp
The FMDP to store the learned model.
Definition: fmdpLearner.h:250
RewardLearnerType * __instantiateRewardLearner(MultiDimFunctionGraph< double > *target, Set< const DiscreteVariable * > &mainVariables)
Initializes the learner.
Definition: fmdpLearner.h:162
Representation of a setA Set is a structure that contains arbitrary elements.
Definition: set.h:165
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Size size()
learnerSize
<agrum/FMDP/SDyna/ILearningStrategy.h>
HashTable< const DiscreteVariable *, VariableLearnerType *> VarLearnerTable
Definition: fmdpLearner.h:73
HashTable< Idx, RewardLearnerType *> __actionRewardLearners
Definition: fmdpLearner.h:255
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
RewardLearnerType * __instantiateRewardLearner(MultiDimFunctionGraph< double > *target, Set< const DiscreteVariable * > &mainVariables, Int2Type< ITILEARNER >)
Initializes the learner.
Definition: fmdpLearner.h:177
LearnerSelect< LearnerSelection, IMDDI< RewardAttributeSelection, true >, ITI< RewardAttributeSelection, true > >::type RewardLearnerType
Definition: fmdpLearner.h:70
void updateFMDP()
Starts an update of datastructure in the associated FMDP.
virtual double rMax() const
learnerSize
Definition: fmdpLearner.h:234
VariableLearnerType * __instantiateVarLearner(MultiDimFunctionGraph< double > *target, Set< const DiscreteVariable * > &mainVariables, const DiscreteVariable *learnedVar, Int2Type< IMDDILEARNER >)
Initializes the learner.
Definition: fmdpLearner.h:137
VariableLearnerType * __instantiateVarLearner(MultiDimFunctionGraph< double > *target, Set< const DiscreteVariable * > &mainVariables, const DiscreteVariable *learnedVar)
Initializes the learner.
Definition: fmdpLearner.h:129
Size Idx
Type for indexes.
Definition: types.h:53
double __modaMax
learnerSize
Definition: fmdpLearner.h:243
RewardLearnerType * __instantiateRewardLearner(MultiDimFunctionGraph< double > *target, Set< const DiscreteVariable * > &mainVariables, Int2Type< IMDDILEARNER >)
Initializes the learner.
Definition: fmdpLearner.h:169
Implementation of a Terminal Node Policy that maps nodeid directly to value.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
MultiDimFunctionGraph< double > * __instantiateFunctionGraph(Int2Type< ITILEARNER >)
Initializes the learner.
Definition: fmdpLearner.h:119
RewardLearnerType * __rewardLearner
Definition: fmdpLearner.h:256
const double __similarityThreshold
Definition: fmdpLearner.h:259
VariableLearnerType * __instantiateVarLearner(MultiDimFunctionGraph< double > *target, Set< const DiscreteVariable * > &mainVariables, const DiscreteVariable *learnedVar, Int2Type< ITILEARNER >)
Initializes the learner.
Definition: fmdpLearner.h:149
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
static MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy > * getReducedAndOrderedInstance()
Returns a reduced and ordered instance.