aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
taxiSimulator.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#ifndef GUM_TAXI_SIMULATOR_H
50#define GUM_TAXI_SIMULATOR_H
51//======================================================================
52//======================================================================
53//======================================================================
55//======================================================================
57
58//======================================================================
59
60namespace gum {
61
62
63 enum TaxiSimulationLandmark : Idx { HOME = 0, WORK = 1, THEATER = 2, CLUB = 3, TAXI = 4 };
64
66 HOMEX = 0,
67 WORKX = 0,
68 THEATERX = 3,
69 CLUBX = 4,
70 STATIONX = 2
71 };
72
74 HOMEY = 0,
75 WORKY = 4,
76 THEATERY = 0,
77 CLUBY = 4,
78 STATIONY = 1
79 };
80
82 GoNorth = 1,
83 GoEast = 2,
84 GoSouth = 3,
85 GoWest = 4,
86 PickUp = 5,
87 PutDown = 6,
88 FillUp = 7
89 };
90
91 // clang-format off
98 // clang-format on
99
101 public:
102 // ===========================================================================
104 // ===========================================================================
106
111
116
118
119 // ===========================================================================
121 // ===========================================================================
123
124 protected:
127
128 public:
129 bool hasReachEnd();
130
132
133 // ===========================================================================
135 // ===========================================================================
137
139 return _primeMap_.second(mainVar);
140 }
141
146
148
150
151 // ===========================================================================
153 // ===========================================================================
155
156 const std::string& actionName(Idx actionId) { return *_actionMap_[actionId]; }
157
160
162
163 void perform(Idx);
164
165 private:
166 void _performGoNorth_();
167 void _performGoEast_();
168 void _performGoSouth_();
169 void _performGoWest_();
170 void _performPickUp_();
171 void _performPutDown_();
172 void _performFillUp_();
173
175
176 // ===========================================================================
178 // ===========================================================================
180
181 public:
182 double reward();
183
184 private:
185 void _evalReward_();
192
194
203
206 HashTable< Idx, std::string* > _actionMap_; // __actionMap.insert ( actionId,
207 // new std::string ( action ) );
209
211 double _reward_;
212 };
213
214} /* namespace gum */
215
216
217#endif // GUM_TAXI_SIMULATOR_H
Class for simulating a discrete time stochastic process.
AbstractSimulator()
Default constructor.
Set of pairs of elements with fast search for both elements.
Definition bijection.h:1594
Base class for discrete random variable.
The class for generic Hash Tables.
Definition hashTable.h:637
Class for assigning/browsing values to tuples of discrete variables.
class LabelizedVariable
Safe iterators for Sequence.
Definition sequence.h:1134
The generic class for storing (ordered) sequences of objects.
Definition sequence.h:972
Sequence< Idx > _taxiActions_
Actions.
const std::string & actionName(Idx actionId)
Iteration over the variables of the simulated probleme.
bool _isAtDestination_(TaxiSimulationLandmark passDest, TaxiSimulationLandmarkX xCurPos, TaxiSimulationLandmarkY yCurPos)
LabelizedVariable * _yPos_
double reward()
Sets the intial statefrom which we begun the simulation.
Bijection< const DiscreteVariable *, const DiscreteVariable * > _primeMap_
void _performFillUp_()
Iteration over the variables of the simulated probleme.
void _performGoEast_()
Iteration over the variables of the simulated probleme.
SequenceIteratorSafe< const DiscreteVariable * > endVariables()
Iteration over the variables of the simulated probleme.
void _performGoWest_()
Iteration over the variables of the simulated probleme.
LabelizedVariable * _xPos_
TaxiSimulator()
Default constructor.
Sequence< const DiscreteVariable * > _taxiVars_
Variables data structures.
SequenceIteratorSafe< Idx > beginActions()
Iteration over the variables of the simulated probleme.
TaxiSimulationAction _lastAction_
LabelizedVariable * _passengerDest_
void _performGoSouth_()
Iteration over the variables of the simulated probleme.
Instantiation randomState_()
Choses a random state as the first test for a run.
const DiscreteVariable * primeVar(const DiscreteVariable *mainVar)
Iteration over the variables of the simulated probleme.
void _performGoNorth_()
Iteration over the variables of the simulated probleme.
LabelizedVariable * _passengerPos_
void _performPickUp_()
Iteration over the variables of the simulated probleme.
double _reward_
Reward.
LabelizedVariable * _fuelLevel_
HashTable< Idx, std::string * > _actionMap_
bool hasReachEnd()
Choses a random state as the first test for a run.
SequenceIteratorSafe< Idx > endActions()
Iteration over the variables of the simulated probleme.
SequenceIteratorSafe< const DiscreteVariable * > beginVariables()
Iteration over the variables of the simulated probleme.
~TaxiSimulator()
Default destructor.
void _performPutDown_()
Iteration over the variables of the simulated probleme.
bool _isAtMeetPoint_(TaxiSimulationLandmark passpos, TaxiSimulationLandmarkX xCurPos, TaxiSimulationLandmarkY yCurPos)
void perform(Idx)
Iteration over the variables of the simulated probleme.
Size Idx
Type for indexes.
Definition types.h:79
Base class for labelized discrete random variables.
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
TaxiSimulationLandmarkX
TaxiSimulationLandmark
TaxiSimulationLandmarkY
TaxiSimulationAction