aGrUM 3.1.1
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 AdaptiveRMaxPlaner: public StructuredPlaner< double >, public IDecisionStrategy {
74 // ###################################################################
76 // ###################################################################
78
79 public:
80 // ==========================================================================
82 // ==========================================================================
84 double discountFactor = 0.9,
85 double epsilon = 0.00001,
86 bool verbose = true);
87
88 // ==========================================================================
90 // ==========================================================================
92 double discountFactor = 0.9,
93 double epsilon = 0.00001,
94 bool verbose = true);
95
97
98 // ###################################################################
100 // ###################################################################
102
103 private:
104 // ==========================================================================
106 // ==========================================================================
108 double discountFactor,
109 double epsilon,
110 const ILearningStrategy* learner,
111 bool verbose);
112
113 // ==========================================================================
115 // ==========================================================================
116
117 public:
118 ~AdaptiveRMaxPlaner() override;
119
121
122
123 // ###################################################################
125 // ###################################################################
127
128 public:
129 // ==========================================================================
135 // ==========================================================================
136 void initialize(const FMDP< double >* fmdp) override;
137
138
139 // ==========================================================================
148 // ==========================================================================
149 void makePlanning(Idx nbStep = 1000000) override;
150
152
153
154 // ###################################################################
156 // ###################################################################
158
159 protected:
160 // ==========================================================================
162 // ==========================================================================
163 void initVFunction_() override;
164
165 // ==========================================================================
167 // ==========================================================================
169
171
172
173 // ###################################################################
175 // ###################################################################
177
178 protected:
179 // ==========================================================================
181 // ==========================================================================
182 void evalPolicy_() override;
183
185
186 private:
188
189 std::pair< NodeId, NodeId > _visitLearner_(const IVisitableGraphLearner*,
190 NodeId currentNodeId,
193 void _clearTables_();
194
195 private:
199
201 double _rmax_;
202
203
204 // ###################################################################
206 // ###################################################################
208
209 public:
210 void checkState(const Instantiation& newState, Idx actionId) override;
211
212 private:
215
218 };
219
220} /* namespace gum */
221
222#ifndef GUM_NO_INLINE
224#endif // GUM_NO_INLINE
225#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)
~AdaptiveRMaxPlaner() override
Default destructor.
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.