aGrUM 2.3.2
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-2025 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-2025 *
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
58namespace gum {
59
78
101
103 public:
104 // ==========================================================================
106 // ==========================================================================
108
109 //~ /**
110 //~ * @brief Copy constructor.
111 //~ * The copy will have an exact copy of the constructed Factored markov
112 // Decision Process in source.
113 //~ * @warning You can only copy a factory if its current state is NONE or
114 //~ * NETWORK.
115 //~ * @throw OperationNotAllowed Raised if the state of source is not NONE
116 // or
117 //~ * NETWORK.
118 //~ */
119 //~ FMDPFactory ( const FMDPFactory<GUM_SCALAR>& source );
120
131
133 // ==========================================================================
135 // ==========================================================================
137
139 virtual FMDPfactory_state state() const = 0;
140
143 virtual const DiscreteVariable* variable(const std::string& name) const = 0;
144
146 // ==========================================================================
148 // ==========================================================================
150
152 virtual void startVariableDeclaration() = 0;
153
157 virtual void variableName(const std::string& name) = 0;
158
160 virtual void variableDescription(const std::string& desc) = 0;
161
163 virtual void addModality(const std::string& name) = 0;
164
168 virtual void endVariableDeclaration() = 0;
169
171 // ==========================================================================
173 // ==========================================================================
175
177 virtual void startActionDeclaration() = 0;
178
180 virtual void addAction(const std::string& action) = 0;
181
183 virtual void endActionDeclaration() = 0;
184
186 // ==========================================================================
188 // ==========================================================================
190
192 virtual void startTransitionDeclaration() = 0;
193
195 virtual void addTransition(const std::string& var, const MultiDimAdressable* transition) = 0;
196
200 virtual void addTransition(const std::string& var) = 0;
201
203 virtual void endTransitionDeclaration() = 0;
204
206 // ==========================================================================
208 // ==========================================================================
210
212 virtual void startCostDeclaration() = 0;
213
215 virtual void addCost(const MultiDimAdressable* cost) = 0;
216
219 virtual void addCost() = 0;
220
222 virtual void endCostDeclaration() = 0;
223
225 // ==========================================================================
227 // ==========================================================================
229
231 virtual void startRewardDeclaration() = 0;
232
236 virtual void setOperationModeOn(std::string operationType) = 0;
237
239 virtual void addReward(const MultiDimAdressable* reward) = 0;
240
243 virtual void addReward() = 0;
244
246 virtual void endRewardDeclaration() = 0;
247
249 // ==========================================================================
251 // ==========================================================================
253
255 virtual void startDiscountDeclaration() = 0;
256
258 virtual void addDiscount(float discount) = 0;
259
261 virtual void endDiscountDeclaration() = 0;
262
264 // ==========================================================================
266 // ==========================================================================
268
270 virtual NodeId addInternalNode(std::string name_of_var) = 0;
271
273 virtual NodeId addTerminalNode(float value) = 0;
274
276 virtual void addArc(NodeId from, NodeId to, Idx modality) = 0;
277
279 virtual void setRoot(NodeId rootId) = 0;
280
282
287 void setVerbose() { _verbose_ = true; }
288
289 void resetVerbose() { _verbose_ = false; }
290
291 bool isVerbose() { return _verbose_; }
292
294
295 private:
297 };
298} /* namespace gum */
299
300
301#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 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 const DiscreteVariable * variable(const std::string &name) const =0
Returns a constant reference on a variable given it's name.
virtual void variableName(const std::string &name)=0
Tells the factory the current variable's name.
virtual void startRewardDeclaration()=0
Tells the factory that we're in a cost declaration.
virtual NodeId addInternalNode(std::string name_of_var)=0
Insert in diagram a non terminal node.
virtual void addReward(const MultiDimAdressable *reward)=0
Tells the factory to add a reward table to the current fmdp.
virtual void addTransition(const std::string &var)=0
Tells the factory to add a transition table to the current fmdp. This transition table will be extrac...
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 addModality(const std::string &name)=0
Adds a modality to the current variable.
virtual void addTransition(const std::string &var, const MultiDimAdressable *transition)=0
Tells the factory to add a transition table to the current fmdp.
virtual void addAction(const std::string &action)=0
Tells the factory to add an action to the current fmdp.
virtual ~AbstractFMDPFactory()
Destructor.
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 variableDescription(const std::string &desc)=0
Tells the factory the current variable's description.
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 void endRewardDeclaration()=0
Tells the factory that we're out of a cost declaration.
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 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.