aGrUM 3.1.1
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-2026 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-2026 *
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
115 ~TaxiSimulator() override;
116
118
119 // ===========================================================================
121 // ===========================================================================
123
124 protected:
126 Instantiation randomState_() override;
127
128 public:
129 bool hasReachEnd() override;
130
132
133 // ===========================================================================
135 // ===========================================================================
137
138 const DiscreteVariable* primeVar(const DiscreteVariable* mainVar) override;
139
142
144
146
147 // ===========================================================================
149 // ===========================================================================
151
152 const std::string& actionName(Idx actionId) override;
153
155
157
158 void perform(Idx) override;
159
160 private:
161 void _performGoNorth_();
162 void _performGoEast_();
163 void _performGoSouth_();
164 void _performGoWest_();
165 void _performPickUp_();
166 void _performPutDown_();
167 void _performFillUp_();
168
170
171 // ===========================================================================
173 // ===========================================================================
175
176 public:
177 double reward() override;
178
179 private:
180 void _evalReward_();
187
189
198
201 HashTable< Idx, std::string* > _actionMap_; // __actionMap.insert ( actionId,
202 // new std::string ( action ) );
204
206 double _reward_;
207 };
208
209} /* namespace gum */
210
211#ifndef GUM_NO_INLINE
213#endif // GUM_NO_INLINE
214#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:1640
Base class for discrete random variable.
The class for generic Hash Tables.
Definition hashTable.h:640
Class for assigning/browsing values to tuples of discrete variables.
class LabelizedVariable
Safe iterators for Sequence.
Definition sequence.h:1148
The generic class for storing (ordered) sequences of objects.
Definition sequence.h:994
const std::string & actionName(Idx actionId) override
Iteration over the variables of the simulated probleme.
Sequence< Idx > _taxiActions_
Actions.
bool _isAtDestination_(TaxiSimulationLandmark passDest, TaxiSimulationLandmarkX xCurPos, TaxiSimulationLandmarkY yCurPos)
LabelizedVariable * _yPos_
Bijection< const DiscreteVariable *, const DiscreteVariable * > _primeMap_
LabelizedVariable * _xPos_
TaxiSimulator()
Default constructor.
double reward() override
Sets the intial statefrom which we begun the simulation.
void perform(Idx) override
Sets the intial statefrom which we begun the simulation.
bool hasReachEnd() override
Choses a random state as the first test for a run.
Sequence< const DiscreteVariable * > _taxiVars_
Variables data structures.
const DiscreteVariable * primeVar(const DiscreteVariable *mainVar) override
Iteration over the variables of the simulated probleme.
TaxiSimulationAction _lastAction_
SequenceIteratorSafe< Idx > beginActions() override
Iteration over the variables of the simulated probleme.
LabelizedVariable * _passengerDest_
LabelizedVariable * _passengerPos_
~TaxiSimulator() override
Default destructor.
SequenceIteratorSafe< const DiscreteVariable * > beginVariables() override
Iteration over the variables of the simulated probleme.
SequenceIteratorSafe< const DiscreteVariable * > endVariables() override
Iteration over the variables of the simulated probleme.
double _reward_
Reward.
LabelizedVariable * _fuelLevel_
HashTable< Idx, std::string * > _actionMap_
Instantiation randomState_() override
Choses a random state as the first test for a run.
SequenceIteratorSafe< Idx > endActions() override
Iteration over the variables of the simulated probleme.
bool _isAtMeetPoint_(TaxiSimulationLandmark passpos, TaxiSimulationLandmarkX xCurPos, TaxiSimulationLandmarkY yCurPos)
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