aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
fmdpLearner.h
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of the aGrUM/pyAgrum library. *
3 * *
4 * Copyright (c) 2005-2026 by *
5 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
6 * - Christophe GONZALES(_at_AMU) *
7 * *
8 * The aGrUM/pyAgrum library is free software; you can redistribute it *
9 * and/or modify it under the terms of either : *
10 * *
11 * - the GNU Lesser General Public License as published by *
12 * the Free Software Foundation, either version 3 of the License, *
13 * or (at your option) any later version, *
14 * - the MIT license (MIT), *
15 * - or both in dual license, as here. *
16 * *
17 * (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18 * *
19 * This aGrUM/pyAgrum library is distributed in the hope that it will be *
20 * useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26 * OTHER DEALINGS IN THE SOFTWARE. *
27 * *
28 * See LICENCES for more details. *
29 * *
30 * SPDX-FileCopyrightText: Copyright 2005-2026 *
31 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
32 * - Christophe GONZALES(_at_AMU) *
33 * SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34 * *
35 * Contact : info_at_agrum_dot_org *
36 * homepage : http://agrum.gitlab.io *
37 * gitlab : https://gitlab.com/agrumery/agrum *
38 * *
39 ****************************************************************************/
40
41
48
49// =========================================================================
50#ifndef GUM_FMDP_LEARNER_H
51#define GUM_FMDP_LEARNER_H
52// =========================================================================
53// =========================================================================
57
58// =========================================================================
59// =========================================================================
60
61namespace gum {
62
72
73 template < TESTNAME VariableAttributeSelection,
74 TESTNAME RewardAttributeSelection,
75 LEARNERNAME LearnerSelection >
78 typename LearnerSelect< LearnerSelection,
81
82 using RewardLearnerType = typename LearnerSelect< LearnerSelection,
85
87
88 public:
89 // ==========================================================================
91 // ==========================================================================
93
94 // ###################################################################
96 // ###################################################################
97 FMDPLearner(double learningThreshold, bool actionReward, double similarityThreshold = 0.05);
98
99 // ###################################################################
101 // ###################################################################
102 ~FMDPLearner() override;
103
105
106 // ###################################################################
108 // ###################################################################
110
111 public:
112 // ==========================================================================
114 // ==========================================================================
115 void initialize(FMDP< double >* fmdp) override;
116
117 // ==========================================================================
119 // ==========================================================================
121
123
125
126 // ==========================================================================
128 // ==========================================================================
130 gum::VariableSet& mainVariables,
131 const DiscreteVariable* learnedVar);
132
134 gum::VariableSet& mainVariables,
135 const DiscreteVariable* learnedVar,
137
139 gum::VariableSet& mainVariables,
140 const DiscreteVariable* learnedVar,
142
143 // ==========================================================================
145 // ==========================================================================
147 gum::VariableSet& mainVariables);
148
150 gum::VariableSet& mainVariables,
152
154 gum::VariableSet& mainVariables,
156
158
159
160 // ###################################################################
162 // ###################################################################
164
165 public:
166 // ==========================================================================
174 // ==========================================================================
175 bool addObservation(Idx actionId, const Observation* obs) override;
176
177
178 // ==========================================================================
182 // ==========================================================================
183 void updateFMDP() override;
184
186
187
188 // ###################################################################
190 // ###################################################################
192
193 public:
194 // ==========================================================================
199 // ==========================================================================
200 Size size() override;
201
202 // ==========================================================================
204 // ==========================================================================
205 const IVisitableGraphLearner* varLearner(Idx actionId,
206 const DiscreteVariable* var) const override;
207
208 double rMax() const override;
209
210 private:
211 double _rmax_;
212
213 public:
214 double modaMax() const override;
215
216 private:
217 double _modaMax_;
218
220
221
222 private:
225
227
231
234 };
235
236
237} /* namespace gum */
238
240
241#endif // GUM_FMDP_LEARNER_H
Headers of the Learning Strategy interface.
Base class for discrete random variable.
double rMax() const override
learnerSize
RewardLearnerType * _instantiateRewardLearner_(MultiDimFunctionGraph< double > *target, gum::VariableSet &mainVariables)
Initializes the learner.
typename LearnerSelect< LearnerSelection, IMDDI< RewardAttributeSelection, true >, ITI< RewardAttributeSelection, true > >::type RewardLearnerType
Definition fmdpLearner.h:82
HashTable< Idx, RewardLearnerType * > _actionRewardLearners_
const double _similarityThreshold_
void initialize(FMDP< double > *fmdp) override
Initializes the learner.
MultiDimFunctionGraph< double > * _instantiateFunctionGraph_()
Initializes the learner.
double _modaMax_
learnerSize
FMDP< double > * _fmdp_
The FMDP to store the learned model.
double _rmax_
learnerSize
bool addObservation(Idx actionId, const Observation *obs) override
Gives to the learner a new transition.
HashTable< const DiscreteVariable *, VariableLearnerType * > VarLearnerTable
Definition fmdpLearner.h:86
~FMDPLearner() override
Default destructor.
const double _learningThreshold_
RewardLearnerType * _rewardLearner_
VariableLearnerType * _instantiateVarLearner_(MultiDimFunctionGraph< double > *target, gum::VariableSet &mainVariables, const DiscreteVariable *learnedVar)
Initializes the learner.
FMDPLearner(double learningThreshold, bool actionReward, double similarityThreshold=0.05)
Default constructor.
void updateFMDP() override
Starts an update of datastructure in the associated FMDP.
HashTable< Idx, VarLearnerTable * > _actionLearners_
typename LearnerSelect< LearnerSelection, IMDDI< VariableAttributeSelection, false >, ITI< VariableAttributeSelection, false > >::type VariableLearnerType
Definition fmdpLearner.h:77
const IVisitableGraphLearner * varLearner(Idx actionId, const DiscreteVariable *var) const override
extractCount
Size size() override
learnerSize
double modaMax() const override
learnerSize
The class for generic Hash Tables.
Definition hashTable.h:640
<agrum/FMDP/SDyna/ILearningStrategy.h>
Learn a graphical representation of a function as a decision tree.
Definition iti.h:79
<agrum/FMDP/SDyna/IVisitableGraphLearner.h>
Template Implementations of the FMDPLearner class.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74
Size Idx
Type for indexes.
Definition types.h:79
Headers of the IMDDI class.
Headers of the ITI class.
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
Set< const DiscreteVariable * > VariableSet