aGrUM  0.20.2
a C++ library for (probabilistic) graphical models
factorySimulator.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright 2005-2020 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
151  return FactoryActions__.beginSafe();
152  }
153  SequenceIteratorSafe< Idx > endActions() { return FactoryActions__.endSafe(); }
154 
155 
156  /// @}
157 
158 
159  private:
160  void goNorth__();
161  void goEast__();
162  void goSouth__();
163  void goWest__();
164  void pickUp__();
165  void putDown__();
166  void fillUp__();
167 
168  /// Variables data structures
176 
177  /// Actions
179  HashTable< Idx, std::string* > actionMap__; //__actionMap.insert ( actionId,
180  // new std::string ( action ) );
182  };
183 
184 } /* namespace gum */
185 
186 
187 #endif // GUM_FACTORY_SIMULATOR_H
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.
Sequence< Idx > FactoryActions__
Actions.
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:669
HashTable< Idx, std::string *> actionMap__
const DiscreteVariable * primeVar(const DiscreteVariable *mainVar)
Iteration over the variables of the simulated probleme.
Instantiation randomState_()
Choses a random state as the first test for a run.
FactorySimulationLandmarkX
~FactorySimulator()
Default destructor.
DiscreteVariable * fuelLevel__
DiscreteVariable * xPos__
FactorySimulationAction lastAction__
FactorySimulationAction
FactorySimulationLandmarkY
A class to simulate the Factory problem.
DiscreteVariable * yPos__
DiscreteVariable * passengerDest__
Sequence< const DiscreteVariable *> FactoryVars__
Variables data structures.
Bijection< const DiscreteVariable *, const DiscreteVariable *> primeMap__
FactorySimulator()
Default constructor.
SequenceIteratorSafe< const DiscreteVariable *> endVariables()
Iteration over the variables of the simulated probleme.
SequenceIteratorSafe< Idx > beginActions()
Iteration over the variables of the simulated probleme.
bool hasReachEnd()
Choses a random state as the first test for a run.
DiscreteVariable * passengerPos__
double reward()
Choses a random state as the first test for a run.