aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
IfmdpFactory.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#ifndef GUM_ABSTRACT_FMDP_FACTORY_H
51#define GUM_ABSTRACT_FMDP_FACTORY_H
52
53#include <string>
54#include <vector>
55
56#include <agrum/FMDP/fmdp.h>
57
58#include <string_view>
59
60namespace gum {
61
80
103
105 public:
106 // ==========================================================================
108 // ==========================================================================
110
111 //~ /**
112 //~ * @brief Copy constructor.
113 //~ * The copy will have an exact copy of the constructed Factored markov
114 // Decision Process in source.
115 //~ * @warning You can only copy a factory if its current state is NONE or
116 //~ * NETWORK.
117 //~ * @throw OperationNotAllowed Raised if the state of source is not NONE
118 // or
119 //~ * NETWORK.
120 //~ */
121 //~ FMDPFactory ( const FMDPFactory<GUM_SCALAR>& source );
122
132 virtual ~AbstractFMDPFactory() = default;
133
135 // ==========================================================================
137 // ==========================================================================
139
141 virtual FMDPfactory_state state() const = 0;
142
145 virtual const DiscreteVariable* variable(std::string_view name) const = 0;
146
148 // ==========================================================================
150 // ==========================================================================
152
154 virtual void startVariableDeclaration() = 0;
155
159 virtual void variableName(std::string_view name) = 0;
160
162 virtual void variableDescription(std::string_view desc) = 0;
163
165 virtual void addModality(std::string_view name) = 0;
166
170 virtual void endVariableDeclaration() = 0;
171
173 // ==========================================================================
175 // ==========================================================================
177
179 virtual void startActionDeclaration() = 0;
180
182 virtual void addAction(std::string_view action) = 0;
183
185 virtual void endActionDeclaration() = 0;
186
188 // ==========================================================================
190 // ==========================================================================
192
194 virtual void startTransitionDeclaration() = 0;
195
197 virtual void addTransition(std::string_view var, const MultiDimAdressable* transition) = 0;
198
202 virtual void addTransition(std::string_view var) = 0;
203
205 virtual void endTransitionDeclaration() = 0;
206
208 // ==========================================================================
210 // ==========================================================================
212
214 virtual void startCostDeclaration() = 0;
215
217 virtual void addCost(const MultiDimAdressable* cost) = 0;
218
221 virtual void addCost() = 0;
222
224 virtual void endCostDeclaration() = 0;
225
227 // ==========================================================================
229 // ==========================================================================
231
233 virtual void startRewardDeclaration() = 0;
234
238 virtual void setOperationModeOn(std::string_view operationType) = 0;
239
241 virtual void addReward(const MultiDimAdressable* reward) = 0;
242
245 virtual void addReward() = 0;
246
248 virtual void endRewardDeclaration() = 0;
249
251 // ==========================================================================
253 // ==========================================================================
255
257 virtual void startDiscountDeclaration() = 0;
258
260 virtual void addDiscount(float discount) = 0;
261
263 virtual void endDiscountDeclaration() = 0;
264
266 // ==========================================================================
268 // ==========================================================================
270
272 virtual NodeId addInternalNode(std::string_view name_of_var) = 0;
273
275 virtual NodeId addTerminalNode(float value) = 0;
276
278 virtual void addArc(NodeId from, NodeId to, Idx modality) = 0;
279
281 virtual void setRoot(NodeId rootId) = 0;
282
284
289 void setVerbose();
290
291 void resetVerbose();
292
293 bool isVerbose();
294
296
297 private:
299 };
300} /* namespace gum */
301
302#ifndef GUM_NO_INLINE
304#endif // GUM_NO_INLINE
305#endif // GUM_ABSTRACT_FMDP_FACTORY_H
A factory class to ease Factored Markov Decision Process construction.
virtual void endActionDeclaration()=0
Tells the factory that we're out of an action declaration.
virtual void startVariableDeclaration()=0
Tells the factory that we're in a variable declaration.
virtual void endTransitionDeclaration()=0
Tells the factory that we're out of a transition declaration.
virtual void startCostDeclaration()=0
Tells the factory that we're in a cost declaration.
virtual void addAction(std::string_view action)=0
Tells the factory to add an action to the current fmdp.
virtual ~AbstractFMDPFactory()=default
Destructor.
virtual void addReward()=0
Tells the factory to add current decision diagram it has as a reward table.
virtual void startActionDeclaration()=0
Tells the factory that we're in an action declaration.
virtual void startRewardDeclaration()=0
Tells the factory that we're in a cost declaration.
virtual void addTransition(std::string_view var, const MultiDimAdressable *transition)=0
Tells the factory to add a transition table to the current fmdp.
virtual void addReward(const MultiDimAdressable *reward)=0
Tells the factory to add a reward table to the current fmdp.
virtual void variableDescription(std::string_view desc)=0
Tells the factory the current variable's description.
virtual void startDiscountDeclaration()=0
Tells the factory that we're in a cost declaration.
virtual void addCost(const MultiDimAdressable *cost)=0
Tells the factory to add a cost table to the current fmdp.
virtual void variableName(std::string_view name)=0
Tells the factory the current variable's name.
virtual void addTransition(std::string_view var)=0
Tells the factory to add a transition table to the current fmdp. This transition table will be extrac...
virtual void addModality(std::string_view name)=0
Adds a modality to the current variable.
virtual NodeId addTerminalNode(float value)=0
Insert in diagram a terminal node.
virtual void addCost()=0
Tells the factory to add current decision diagram it has as a cost table.
virtual void addDiscount(float discount)=0
Tells the factory to add a cost table to the current fmdp.
virtual void endVariableDeclaration()=0
Tells the factory that we're out of a variable declaration.
virtual void addArc(NodeId from, NodeId to, Idx modality)=0
Insert in diagram an arc.
virtual void startTransitionDeclaration()=0
Tells the factory that we're in a transition declaration.
virtual void endDiscountDeclaration()=0
Tells the factory that we're out of a cost declaration.
virtual void setRoot(NodeId rootId)=0
Set the root of the diagram.
virtual const DiscreteVariable * variable(std::string_view name) const =0
Returns a constant reference on a variable given it's name.
virtual void endRewardDeclaration()=0
Tells the factory that we're out of a cost declaration.
virtual NodeId addInternalNode(std::string_view name_of_var)=0
Insert in diagram a non terminal node.
virtual FMDPfactory_state state() const =0
Returns the current state of the factory.
virtual void endCostDeclaration()=0
Tells the factory that we're out of a cost declaration.
virtual void setOperationModeOn(std::string_view operationType)=0
Tells the factory that we're in a reward declaration mode where the global reward diagram is an opera...
Base class for discrete random variable.
Abstract base class for all multi dimensionnal addressable.
Class for implementation of factored markov decision process.
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
FMDPfactory_state
The enumeration of states in which the factory can be in.