aGrUM 3.2.0
a C++ library for (probabilistic) graphical models
adaptiveRMaxPlaner.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
49
50// =========================================================================
51#ifndef GUM_ADAPTIVE_RMAX_PLANER_H
52#define GUM_ADAPTIVE_RMAX_PLANER_H
53// =========================================================================
58
59// =========================================================================
60
61namespace gum {
62
73 class GUM_PUBLIC_FMDP AdaptiveRMaxPlaner:
74 public StructuredPlaner< double >,
75 public IDecisionStrategy {
76 // ###################################################################
78 // ###################################################################
80
81 public:
82 // ==========================================================================
84 // ==========================================================================
86 double discountFactor = 0.9,
87 double epsilon = 0.00001,
88 bool verbose = true);
89
90 // ==========================================================================
92 // ==========================================================================
94 double discountFactor = 0.9,
95 double epsilon = 0.00001,
96 bool verbose = true);
97
99
100 // ###################################################################
102 // ###################################################################
104
105 private:
106 // ==========================================================================
108 // ==========================================================================
110 double discountFactor,
111 double epsilon,
112 const ILearningStrategy* learner,
113 bool verbose);
114
115 // ==========================================================================
117 // ==========================================================================
118
119 public:
120 ~AdaptiveRMaxPlaner() override;
121
123
124
125 // ###################################################################
127 // ###################################################################
129
130 public:
131 // ==========================================================================
137 // ==========================================================================
138 void initialize(const FMDP< double >* fmdp) override;
139
140
141 // ==========================================================================
150 // ==========================================================================
151 void makePlanning(Idx nbStep = 1000000) override;
152
154
155
156 // ###################################################################
158 // ###################################################################
160
161 protected:
162 // ==========================================================================
164 // ==========================================================================
165 void initVFunction_() override;
166
167 // ==========================================================================
169 // ==========================================================================
171
173
174
175 // ###################################################################
177 // ###################################################################
179
180 protected:
181 // ==========================================================================
183 // ==========================================================================
184 void evalPolicy_() override;
185
187
188 private:
190
191 std::pair< NodeId, NodeId > _visitLearner_(const IVisitableGraphLearner*,
192 NodeId currentNodeId,
195 void _clearTables_();
196
197 private:
201
203 double _rmax_;
204
205
206 // ###################################################################
208 // ###################################################################
210
211 public:
212 void checkState(const Instantiation& newState, Idx actionId) override;
213
214 private:
217
220 };
221
222} /* namespace gum */
223
224#ifndef GUM_NO_INLINE
226#endif // GUM_NO_INLINE
227#endif // GUM_ADAPTIVE_RMAX_PLANER_H
Headers of the Decision Strategy interface.
void checkState(const Instantiation &newState, Idx actionId) override
static AdaptiveRMaxPlaner * TreeInstance(const ILearningStrategy *learner, double discountFactor=0.9, double epsilon=0.00001, bool verbose=true)
HashTable< Idx, bool > _initializedTable_
const ILearningStrategy * _fmdpLearner_
HashTable< Idx, MultiDimFunctionGraph< double > * > _actionsBoolTable_
HashTable< Idx, StatesCounter * > _counterTable_
void evalPolicy_() override
Perform the required tasks to extract an optimal policy.
void makePlanning(Idx nbStep=1000000) override
Performs a value iteration.
void initVFunction_() override
Performs a single step of value iteration.
void initialize(const FMDP< double > *fmdp) override
Initializes data structure needed for making the planning.
AdaptiveRMaxPlaner(IOperatorStrategy< double > *opi, double discountFactor, double epsilon, const ILearningStrategy *learner, bool verbose)
Default constructor.
MultiDimFunctionGraph< double > * valueIteration_() override
Performs a single step of value iteration.
static AdaptiveRMaxPlaner * ReducedAndOrderedInstance(const ILearningStrategy *learner, double discountFactor=0.9, double epsilon=0.00001, bool verbose=true)
HashTable< Idx, MultiDimFunctionGraph< double > * > _actionsRMaxTable_
std::pair< NodeId, NodeId > _visitLearner_(const IVisitableGraphLearner *, NodeId currentNodeId, MultiDimFunctionGraph< double > *, MultiDimFunctionGraph< double > *)
The class for generic Hash Tables.
Definition hashTable.h:640
<agrum/FMDP/SDyna/IDecisionStrategy.h>
<agrum/FMDP/SDyna/ILearningStrategy.h>
<agrum/FMDP/SDyna/IVisitableGraphLearner.h>
Class for assigning/browsing values to tuples of discrete variables.
StructuredPlaner(IOperatorStrategy< double > *opi, double discountFactor, double epsilon, bool verbose)
Headers of the FMDPLearner class.
Size Idx
Type for indexes.
Definition types.h:79
Size NodeId
Type for node ids.
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
Headers of the States Counter class.
Headers of the StructuredPlaner planer class.