aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
abstractSimulator.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright (c) 2005-2021 by Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
4  * info_at_agrum_dot_org
5  *
6  * This library is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 
22 /**
23  * @file
24  * @brief Class for simulating a discrete time stochastic process.
25  *
26  * @author Jean-Christophe MAGNAN
27  */
28 #ifndef GUM_ABSTRACT_SIMULATOR_H
29 #define GUM_ABSTRACT_SIMULATOR_H
30 //======================================================================
31 #include <agrum/tools/multidim/instantiation.h>
32 //======================================================================
33 #include <agrum/FMDP/fmdp.h>
34 //======================================================================
35 //======================================================================
36 
37 namespace gum {
38  /**
39  * @class AbstractSimulator abstractSimulator.h
40  * <agrum/FMDP/simulation/abstractSimulator.h>
41  * @brief A class to simulate a reinforcement learning problem.
42  * @ingroup fmdp_group
43  *
44  *
45  *
46  */
48  public:
49  // ===========================================================================
50  /// @name Constructors, Destructors.
51  // ===========================================================================
52  /// @{
53 
54  /**
55  * Default constructor.
56  */
58 
59  /**
60  * Default destructor.
61  */
62  virtual ~AbstractSimulator();
63 
64  /// @}
65 
66  // ===========================================================================
67  /// @name
68  // ===========================================================================
69  /// @{
70 
71  /// Sets the intial statefrom which we begun the simulation
74 
75  protected:
76  /// Choses a random state as the first test for a run
77  virtual Instantiation randomState_();
78 
79  public:
80  /// Sets the final states upon which a run is over
82 
83  /// Tests if end state has been reached
84  virtual bool hasReachEnd();
85 
86  ///
88 
89  ///
90  virtual double reward() = 0;
91 
92  ///
93  virtual void perform(Idx) = 0;
94 
95  /// @}
96 
97  // ===========================================================================
98  /// @name Variables
99  // ===========================================================================
100  /// @{
101 
102  virtual const DiscreteVariable* primeVar(const DiscreteVariable* mainVar) = 0;
103 
104  /// Iteration over the variables of the simulated probleme
105  virtual SequenceIteratorSafe< const DiscreteVariable* > beginVariables() = 0;
106  virtual SequenceIteratorSafe< const DiscreteVariable* > endVariables() = 0;
107 
108  /// @}
109 
110  // ===========================================================================
111  /// @name Actions
112  // ===========================================================================
113  /// @{
114 
115  virtual const std::string& actionName(Idx) = 0;
116 
117  /// Iteration over the variables of the simulated probleme
118  virtual SequenceIteratorSafe< Idx > beginActions() = 0;
119  virtual SequenceIteratorSafe< Idx > endActions() = 0;
120 
121 
122  /// @}
123 
124  /// Tha state in which the system currently is
126  };
127 
128 } /* namespace gum */
129 
130 
131 #endif // _GUM_ABSTRACT_SIMULATOR_H
virtual double reward()=0
Sets the intial statefrom which we begun the simulation.
virtual Instantiation randomState_()
Choses a random state as the first test for a run.
virtual SequenceIteratorSafe< Idx > endActions()=0
Iteration over the variables of the simulated probleme.
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643
virtual void perform(Idx)=0
Sets the intial statefrom which we begun the simulation.
Instantiation currentState_
Tha state in which the system currently is.
virtual ~AbstractSimulator()
Default destructor.
virtual const DiscreteVariable * primeVar(const DiscreteVariable *mainVar)=0
Iteration over the variables of the simulated probleme.
virtual SequenceIteratorSafe< const DiscreteVariable *> beginVariables()=0
Iteration over the variables of the simulated probleme.
virtual SequenceIteratorSafe< const DiscreteVariable *> endVariables()=0
Iteration over the variables of the simulated probleme.
virtual const std::string & actionName(Idx)=0
Iteration over the variables of the simulated probleme.
virtual SequenceIteratorSafe< Idx > beginActions()=0
Iteration over the variables of the simulated probleme.
AbstractSimulator()
Default constructor.