aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
factorySimulator.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 markov decision process.
25  *
26  * @author Pierre-Henri WUILLEMIN(@LIP6) and Jean-Christophe MAGNAN and Christophe
27  * GONZALES(@AMU)
28  */
29 #ifndef GUM_FACTORY_SIMULATOR_H
30 #define GUM_FACTORY_SIMULATOR_H
31 //======================================================================
32 #include <agrum/tools/multidim/instantiation.h>
33 //======================================================================
34 #include <agrum/FMDP/fmdp.h>
35 //======================================================================
36 #include <agrum/FMDP/simulation/abstractSimulator.h>
37 //======================================================================
38 #include <agrum/tools/variables/discreteVariable.h>
39 //======================================================================
40 
41 namespace gum {
42 
43 
45  {
46  HOME = 0,
47  WORK = 1,
48  THEATER = 2,
49  CLUB = 3,
50  Factory = 4
51  };
53  {
54  HOMEX = 0,
55  WORKX = 0,
56  THEATERX = 3,
57  CLUBX = 4,
59  };
61  {
62  HOMEY = 0,
63  WORKY = 4,
64  THEATERY = 0,
65  CLUBY = 4,
67  };
69  {
70  GoNorth = 0,
71  GoEast = 1,
72  GoSouth = 2,
73  GoWest = 3,
74  PickUp = 4,
75  PutDown = 5,
76  FillUp = 6
77  };
78 
79  // clang-format off
80  /**
81 * @class FactorySimulator
82 * @headerfile factorySimulator.h <agrum/FMDP/simulation/factorySimulator.h>
83  * @brief A class to simulate the Factory problem
84  * @ingroup fmdp_group
85  */
86  // clang-format on
88  public:
89  // ===========================================================================
90  /// @name Constructors, Destructors.
91  // ===========================================================================
92  /// @{
93 
94  /**
95  * Default constructor.
96  */
98 
99  /**
100  * Default destructor.
101  */
102  ~FactorySimulator();
103 
104  /// @}
105 
106  // ===========================================================================
107  /// @name
108  // ===========================================================================
109  /// @{
110 
111  protected:
112  /// Choses a random state as the first test for a run
114 
115  public:
116  bool hasReachEnd();
117  ///
118  double reward();
119  void perform(Idx);
120 
121  /// @}
122 
123  // ===========================================================================
124  /// @name Variables
125  // ===========================================================================
126  /// @{
127 
129  return _primeMap_.second(mainVar);
130  }
131 
132  /// Iteration over the variables of the simulated probleme
134  return _FactoryVars_.beginSafe();
135  }
137  return _FactoryVars_.endSafe();
138  }
139 
140  /// @}
141 
142  // ===========================================================================
143  /// @name Actions
144  // ===========================================================================
145  /// @{
146 
147  const std::string& actionName(Idx actionId) { return *_actionMap_[actionId]; }
148 
149  /// Iteration over the variables of the simulated probleme
150  SequenceIteratorSafe< Idx > beginActions() { return _FactoryActions_.beginSafe(); }
151  SequenceIteratorSafe< Idx > endActions() { return _FactoryActions_.endSafe(); }
152 
153 
154  /// @}
155 
156 
157  private:
158  void _goNorth_();
159  void _goEast_();
160  void _goSouth_();
161  void _goWest_();
162  void _pickUp_();
163  void _putDown_();
164  void _fillUp_();
165 
166  /// Variables data structures
174 
175  /// Actions
177  HashTable< Idx, std::string* > _actionMap_; // __actionMap.insert ( actionId,
178  // new std::string ( action ) );
180  };
181 
182 } /* namespace gum */
183 
184 
185 #endif // GUM_FACTORY_SIMULATOR_H
DiscreteVariable * _xPos_
void perform(Idx)
Choses a random state as the first test for a run.
FactorySimulationLandmark
const std::string & actionName(Idx actionId)
Iteration over the variables of the simulated probleme.
SequenceIteratorSafe< Idx > endActions()
Iteration over the variables of the simulated probleme.
SequenceIteratorSafe< const DiscreteVariable *> beginVariables()
Iteration over the variables of the simulated probleme.
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643
const DiscreteVariable * primeVar(const DiscreteVariable *mainVar)
Iteration over the variables of the simulated probleme.
Sequence< Idx > _FactoryActions_
Actions.
Instantiation randomState_()
Choses a random state as the first test for a run.
FactorySimulationLandmarkX
~FactorySimulator()
Default destructor.
Bijection< const DiscreteVariable *, const DiscreteVariable *> _primeMap_
FactorySimulationAction
DiscreteVariable * _passengerPos_
HashTable< Idx, std::string *> _actionMap_
FactorySimulationLandmarkY
DiscreteVariable * _fuelLevel_
A class to simulate the Factory problem.
DiscreteVariable * _yPos_
FactorySimulator()
Default constructor.
SequenceIteratorSafe< const DiscreteVariable *> endVariables()
Iteration over the variables of the simulated probleme.
Sequence< const DiscreteVariable *> _FactoryVars_
Variables data structures.
DiscreteVariable * _passengerDest_
SequenceIteratorSafe< Idx > beginActions()
Iteration over the variables of the simulated probleme.
bool hasReachEnd()
Choses a random state as the first test for a run.
FactorySimulationAction _lastAction_
double reward()
Choses a random state as the first test for a run.