aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
gum::TaxiSimulator Class Reference

A class to simulate the Taxi problem. More...

#include <agrum/FMDP/simulation/taxiSimulator.h>

Inheritance diagram for gum::TaxiSimulator:
Collaboration diagram for gum::TaxiSimulator:

Public Member Functions

Constructors, Destructors.
 TaxiSimulator ()
 Default constructor.
 ~TaxiSimulator ()
 Default destructor.
Variables
const DiscreteVariableprimeVar (const DiscreteVariable *mainVar)
 Iteration over the variables of the simulated probleme.
SequenceIteratorSafe< const DiscreteVariable * > beginVariables ()
 Iteration over the variables of the simulated probleme.
SequenceIteratorSafe< const DiscreteVariable * > endVariables ()
 Iteration over the variables of the simulated probleme.
INLINE void setInitialState (const Instantiation &initialState)
 Sets the intial statefrom which we begun the simulation.
void setInitialStateRandomly ()
 Sets the intial statefrom which we begun the simulation.
INLINE void setEndState (const Instantiation &endState)
 Sets the final states upon which a run is over.
INLINE const InstantiationcurrentState ()
 Sets the intial statefrom which we begun the simulation.

Public Attributes

Instantiation currentState_
 Tha state in which the system currently is.
Instantiation endState_

Private Attributes

Sequence< const DiscreteVariable * > _taxiVars_
 Variables data structures.
Bijection< const DiscreteVariable *, const DiscreteVariable * > _primeMap_
LabelizedVariable_xPos_
LabelizedVariable_yPos_
LabelizedVariable_passengerPos_
LabelizedVariable_passengerDest_
LabelizedVariable_fuelLevel_
Sequence< Idx_taxiActions_
 Actions.
HashTable< Idx, std::string * > _actionMap_
TaxiSimulationAction _lastAction_
double _reward_
 Reward.

States

bool hasReachEnd ()
 Choses a random state as the first test for a run.
Instantiation randomState_ ()
 Choses a random state as the first test for a run.

Actions

const std::string & actionName (Idx actionId)
 Iteration over the variables of the simulated probleme.
SequenceIteratorSafe< IdxbeginActions ()
 Iteration over the variables of the simulated probleme.
SequenceIteratorSafe< IdxendActions ()
 Iteration over the variables of the simulated probleme.
void perform (Idx)
 Iteration over the variables of the simulated probleme.
void _performGoNorth_ ()
 Iteration over the variables of the simulated probleme.
void _performGoEast_ ()
 Iteration over the variables of the simulated probleme.
void _performGoSouth_ ()
 Iteration over the variables of the simulated probleme.
void _performGoWest_ ()
 Iteration over the variables of the simulated probleme.
void _performPickUp_ ()
 Iteration over the variables of the simulated probleme.
void _performPutDown_ ()
 Iteration over the variables of the simulated probleme.
void _performFillUp_ ()
 Iteration over the variables of the simulated probleme.

Rewards

double reward ()
 Sets the intial statefrom which we begun the simulation.
void _evalReward_ ()
bool _isAtDestination_ (TaxiSimulationLandmark passDest, TaxiSimulationLandmarkX xCurPos, TaxiSimulationLandmarkY yCurPos)
bool _isAtMeetPoint_ (TaxiSimulationLandmark passpos, TaxiSimulationLandmarkX xCurPos, TaxiSimulationLandmarkY yCurPos)

Detailed Description

A class to simulate the Taxi problem.

Definition at line 100 of file taxiSimulator.h.

Constructor & Destructor Documentation

◆ TaxiSimulator()

gum::TaxiSimulator::TaxiSimulator ( )

Default constructor.

Definition at line 57 of file taxiSimulator.cpp.

58 GUM_CONSTRUCTOR(TaxiSimulator);
59
60 // *****************************************************************************************
61 // Défintion des variables du problème
62
63 // Position TaxiSimulator
64 _xPos_ = new LabelizedVariable("xPos", "Position horizontale du TaxiSimulator");
65 _yPos_ = new LabelizedVariable("yPos", "Position verticale du TaxiSimulator");
66 _xPos_->eraseLabels();
67 _yPos_->eraseLabels();
68 for (Idx pos = 0; pos < 5; pos++) {
69 std::stringstream ss;
70 ss << pos;
71 _xPos_->addLabel(ss.str());
72 _yPos_->addLabel(ss.str());
73 }
74
75 // Position et destination passager
76 _passengerPos_ = new LabelizedVariable("PassengerPos", "Position du Passager", 5);
77 _passengerDest_ = new LabelizedVariable("PassengerDest", "Destination du Passager", 4);
78 _passengerPos_->changeLabel(HOME, "Home");
79 _passengerDest_->changeLabel(HOME, "Home");
80 _passengerPos_->changeLabel(WORK, "Work");
81 _passengerDest_->changeLabel(WORK, "Work");
82 _passengerPos_->changeLabel(THEATER, "Theater");
83 _passengerDest_->changeLabel(THEATER, "Theater");
84 _passengerPos_->changeLabel(CLUB, "Club");
85 _passengerDest_->changeLabel(CLUB, "Club");
86 _passengerPos_->changeLabel(TAXI, "Taxi");
87
88 _fuelLevel_ = new LabelizedVariable("FuelLevel", "Niveau du réservoir", 14);
89
90 // Ajout à séquence
91 _taxiVars_.insert(_xPos_);
92 _taxiVars_.insert(_yPos_);
95 _taxiVars_.insert(_fuelLevel_);
96
97 // Prime version creation
98 for (SequenceIteratorSafe< const DiscreteVariable* > varIter
100 varIter != this->TaxiSimulator::endVariables();
101 ++varIter) {
102 DiscreteVariable* primeVar = (*varIter)->clone();
103 primeVar->setName((*varIter)->name() + "'");
104 _primeMap_.insert((*varIter), primeVar);
105 }
106
107 // *****************************************************************************************
108
109 // *****************************************************************************************
110 // Défintion des actions du problème
111 _taxiActions_.insert(GoNorth);
112 _actionMap_.insert(GoNorth, new std::string("Go North"));
113 _taxiActions_.insert(GoEast);
114 _actionMap_.insert(GoEast, new std::string("Go East"));
115 _taxiActions_.insert(GoSouth);
116 _actionMap_.insert(GoSouth, new std::string("Go South"));
117 _taxiActions_.insert(GoWest);
118 _actionMap_.insert(GoWest, new std::string("Go West"));
119 _taxiActions_.insert(PickUp);
120 _actionMap_.insert(PickUp, new std::string("Pick Up"));
121 _taxiActions_.insert(PutDown);
122 _actionMap_.insert(PutDown, new std::string("Put Down"));
123 _taxiActions_.insert(FillUp);
124 _actionMap_.insert(FillUp, new std::string("FillUp"));
125 }
AbstractSimulator()
Default constructor.
Sequence< Idx > _taxiActions_
Actions.
LabelizedVariable * _yPos_
Bijection< const DiscreteVariable *, const DiscreteVariable * > _primeMap_
SequenceIteratorSafe< const DiscreteVariable * > endVariables()
Iteration over the variables of the simulated probleme.
LabelizedVariable * _xPos_
TaxiSimulator()
Default constructor.
Sequence< const DiscreteVariable * > _taxiVars_
Variables data structures.
LabelizedVariable * _passengerDest_
const DiscreteVariable * primeVar(const DiscreteVariable *mainVar)
Iteration over the variables of the simulated probleme.
LabelizedVariable * _passengerPos_
LabelizedVariable * _fuelLevel_
HashTable< Idx, std::string * > _actionMap_
SequenceIteratorSafe< const DiscreteVariable * > beginVariables()
Iteration over the variables of the simulated probleme.
Size Idx
Type for indexes.
Definition types.h:79

References gum::AbstractSimulator::AbstractSimulator(), TaxiSimulator(), _actionMap_, _fuelLevel_, _passengerDest_, _passengerPos_, _primeMap_, _taxiActions_, _taxiVars_, _xPos_, _yPos_, beginVariables(), gum::CLUB, endVariables(), gum::FillUp, gum::GoEast, gum::GoNorth, gum::GoSouth, gum::GoWest, gum::HOME, gum::PickUp, primeVar(), gum::PutDown, gum::TAXI, gum::THEATER, and gum::WORK.

Referenced by TaxiSimulator(), and ~TaxiSimulator().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~TaxiSimulator()

gum::TaxiSimulator::~TaxiSimulator ( )

Default destructor.

Definition at line 127 of file taxiSimulator.cpp.

127 {
128 GUM_DESTRUCTOR(TaxiSimulator);
129
130 for (BijectionIteratorSafe< const DiscreteVariable*, const DiscreteVariable* > varIter
131 = _primeMap_.beginSafe();
132 varIter != _primeMap_.endSafe();
133 ++varIter) {
134 delete varIter.first();
135 delete varIter.second();
136 }
137 }

References TaxiSimulator(), and _primeMap_.

Here is the call graph for this function:

Member Function Documentation

◆ _evalReward_()

void gum::TaxiSimulator::_evalReward_ ( )
private

Definition at line 333 of file taxiSimulator.cpp.

333 {
335 = (TaxiSimulationLandmarkX)this->currentState_.valFromPtr(_xPos_);
337 = (TaxiSimulationLandmarkY)this->currentState_.valFromPtr(_yPos_);
342
343 if (_lastAction_ == PutDown) {
344 if (passPos == TAXI) {
345 if (_isAtDestination_(passDest, xCurPos, yCurPos)) _reward_ = 30.0;
346 else _reward_ = 0.0;
347 return;
348 }
349 _reward_ = 0;
350 return;
351 }
352
353 if (_lastAction_ == PickUp) {
354 if (_isAtMeetPoint_(passPos, xCurPos, yCurPos)) _reward_ = 20.0;
355 else _reward_ = 0.0;
356 return;
357 }
358
359 if (currentState_.valFromPtr(_fuelLevel_) == 0 && _lastAction_ != FillUp) {
360 _reward_ = 0.0;
361 return;
362 }
363
364 if (_lastAction_ == FillUp && (xCurPos != STATIONX || yCurPos != STATIONY)) {
365 _reward_ = 0.0;
366 return;
367 }
368
369 _reward_ = 10.0; //-1.0;
370 }
Instantiation currentState_
Tha state in which the system currently is.
bool _isAtDestination_(TaxiSimulationLandmark passDest, TaxiSimulationLandmarkX xCurPos, TaxiSimulationLandmarkY yCurPos)
TaxiSimulationAction _lastAction_
double _reward_
Reward.
bool _isAtMeetPoint_(TaxiSimulationLandmark passpos, TaxiSimulationLandmarkX xCurPos, TaxiSimulationLandmarkY yCurPos)
TaxiSimulationLandmarkX
TaxiSimulationLandmark
TaxiSimulationLandmarkY

References _fuelLevel_, _isAtDestination_(), _isAtMeetPoint_(), _lastAction_, _passengerDest_, _passengerPos_, _reward_, _xPos_, _yPos_, gum::AbstractSimulator::currentState_, gum::FillUp, gum::PickUp, gum::PutDown, gum::STATIONX, gum::STATIONY, and gum::TAXI.

Referenced by perform().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _isAtDestination_()

bool gum::TaxiSimulator::_isAtDestination_ ( TaxiSimulationLandmark passDest,
TaxiSimulationLandmarkX xCurPos,
TaxiSimulationLandmarkY yCurPos )
private

Definition at line 372 of file taxiSimulator.cpp.

374 {
375 switch (passDest) {
376 case HOME : {
377 if (xCurPos == HOMEX && yCurPos == HOMEY) return true;
378 break;
379 }
380 case WORK : {
381 if (xCurPos == WORKX && yCurPos == WORKY) return true;
382 break;
383 }
384 case THEATER : {
385 if (xCurPos == THEATERX && yCurPos == THEATERY) return true;
386 break;
387 }
388 case CLUB : {
389 if (xCurPos == CLUBX && yCurPos == CLUBY) return true;
390 break;
391 }
392 case TAXI : return false;
393 }
394 return false;
395 }

References gum::CLUB, gum::CLUBX, gum::CLUBY, gum::HOME, gum::HOMEX, gum::HOMEY, gum::TAXI, gum::THEATER, gum::THEATERX, gum::THEATERY, gum::WORK, gum::WORKX, and gum::WORKY.

Referenced by _evalReward_().

Here is the caller graph for this function:

◆ _isAtMeetPoint_()

bool gum::TaxiSimulator::_isAtMeetPoint_ ( TaxiSimulationLandmark passpos,
TaxiSimulationLandmarkX xCurPos,
TaxiSimulationLandmarkY yCurPos )
private

Definition at line 397 of file taxiSimulator.cpp.

399 {
400 switch (passPos) {
401 case HOME : {
402 if (xCurPos == HOMEX && yCurPos == HOMEY) return true;
403 break;
404 }
405 case WORK : {
406 if (xCurPos == WORKX && yCurPos == WORKY) return true;
407 break;
408 }
409 case THEATER : {
410 if (xCurPos == THEATERX && yCurPos == THEATERY) return true;
411 break;
412 }
413 case CLUB : {
414 if (xCurPos == CLUBX && yCurPos == CLUBY) return true;
415 break;
416 }
417 case TAXI : return false;
418 }
419 return false;
420 }

References gum::CLUB, gum::CLUBX, gum::CLUBY, gum::HOME, gum::HOMEX, gum::HOMEY, gum::TAXI, gum::THEATER, gum::THEATERX, gum::THEATERY, gum::WORK, gum::WORKX, and gum::WORKY.

Referenced by _evalReward_().

Here is the caller graph for this function:

◆ _performFillUp_()

void gum::TaxiSimulator::_performFillUp_ ( )
private

Iteration over the variables of the simulated probleme.

Definition at line 321 of file taxiSimulator.cpp.

321 {
323 = (TaxiSimulationLandmarkX)this->currentState_.valFromPtr(_xPos_);
325 = (TaxiSimulationLandmarkY)this->currentState_.valFromPtr(_yPos_);
326
327 if (xCurPos == STATIONX && yCurPos == STATIONY) currentState_.chgVal(*_fuelLevel_, 13);
328 }

References _fuelLevel_, _xPos_, _yPos_, gum::AbstractSimulator::currentState_, gum::STATIONX, and gum::STATIONY.

Referenced by perform().

Here is the caller graph for this function:

◆ _performGoEast_()

void gum::TaxiSimulator::_performGoEast_ ( )
private

Iteration over the variables of the simulated probleme.

Definition at line 214 of file taxiSimulator.cpp.

214 {
215 Idx xCurPos = this->currentState_.valFromPtr(_xPos_);
216 Idx yCurPos = this->currentState_.valFromPtr(_yPos_);
217
218 if (xCurPos == 4) return;
219 if (xCurPos == 0 || xCurPos == 2)
220 if (yCurPos == 0 || yCurPos == 1) return;
221 if (xCurPos == 1)
222 if (yCurPos == 3 || yCurPos == 4) return;
223
224 currentState_.chgVal(*_xPos_, ++xCurPos);
225 }

References _xPos_, _yPos_, and gum::AbstractSimulator::currentState_.

Referenced by perform().

Here is the caller graph for this function:

◆ _performGoNorth_()

void gum::TaxiSimulator::_performGoNorth_ ( )
private

Iteration over the variables of the simulated probleme.

Definition at line 206 of file taxiSimulator.cpp.

206 {
207 Idx curPos = this->currentState_.valFromPtr(_yPos_);
208 if (curPos < 4) currentState_.chgVal(*_yPos_, ++curPos);
209 }

References _yPos_, and gum::AbstractSimulator::currentState_.

Referenced by perform().

Here is the caller graph for this function:

◆ _performGoSouth_()

void gum::TaxiSimulator::_performGoSouth_ ( )
private

Iteration over the variables of the simulated probleme.

Definition at line 230 of file taxiSimulator.cpp.

230 {
231 Idx curPos = this->currentState_.valFromPtr(_yPos_);
232 if (curPos > 0) currentState_.chgVal(*_yPos_, --curPos);
233 }

References _yPos_, and gum::AbstractSimulator::currentState_.

Referenced by perform().

Here is the caller graph for this function:

◆ _performGoWest_()

void gum::TaxiSimulator::_performGoWest_ ( )
private

Iteration over the variables of the simulated probleme.

Definition at line 238 of file taxiSimulator.cpp.

238 {
239 Idx xCurPos = this->currentState_.valFromPtr(_xPos_);
240 Idx yCurPos = this->currentState_.valFromPtr(_yPos_);
241
242 if (xCurPos == 0) return;
243 if (xCurPos == 1 || xCurPos == 3)
244 if (yCurPos == 0 || yCurPos == 1) return;
245 if (xCurPos == 2)
246 if (yCurPos == 3 || yCurPos == 4) return;
247
248 currentState_.chgVal(*_xPos_, --xCurPos);
249 }

References _xPos_, _yPos_, and gum::AbstractSimulator::currentState_.

Referenced by perform().

Here is the caller graph for this function:

◆ _performPickUp_()

void gum::TaxiSimulator::_performPickUp_ ( )
private

Iteration over the variables of the simulated probleme.

Definition at line 254 of file taxiSimulator.cpp.

254 {
256 = (TaxiSimulationLandmarkX)this->currentState_.valFromPtr(_xPos_);
258 = (TaxiSimulationLandmarkY)this->currentState_.valFromPtr(_yPos_);
261 switch (passPos) {
262 case HOME : {
263 if (xCurPos == HOMEX && yCurPos == HOMEY) currentState_.chgVal(*_passengerPos_, TAXI);
264 return;
265 }
266 case WORK : {
267 if (xCurPos == WORKX && yCurPos == WORKY) currentState_.chgVal(*_passengerPos_, TAXI);
268 return;
269 }
270 case THEATER : {
271 if (xCurPos == THEATERX && yCurPos == THEATERY) currentState_.chgVal(*_passengerPos_, TAXI);
272 return;
273 }
274 case CLUB : {
275 if (xCurPos == CLUBX && yCurPos == CLUBY) currentState_.chgVal(*_passengerPos_, TAXI);
276 return;
277 }
278 case TAXI : return;
279 }
280 }

References _passengerPos_, _xPos_, _yPos_, gum::CLUB, gum::CLUBX, gum::CLUBY, gum::AbstractSimulator::currentState_, gum::HOME, gum::HOMEX, gum::HOMEY, gum::TAXI, gum::THEATER, gum::THEATERX, gum::THEATERY, gum::WORK, gum::WORKX, and gum::WORKY.

Referenced by perform().

Here is the caller graph for this function:

◆ _performPutDown_()

void gum::TaxiSimulator::_performPutDown_ ( )
private

Iteration over the variables of the simulated probleme.

Definition at line 285 of file taxiSimulator.cpp.

285 {
287 = (TaxiSimulationLandmarkX)this->currentState_.valFromPtr(_xPos_);
289 = (TaxiSimulationLandmarkY)this->currentState_.valFromPtr(_yPos_);
294 if (passPos == TAXI) {
295 switch (passDest) {
296 case HOME : {
297 if (xCurPos == HOMEX && yCurPos == HOMEY) currentState_.chgVal(*_passengerPos_, HOME);
298 return;
299 }
300 case WORK : {
301 if (xCurPos == WORKX && yCurPos == WORKY) currentState_.chgVal(*_passengerPos_, WORK);
302 return;
303 }
304 case THEATER : {
305 if (xCurPos == THEATERX && yCurPos == THEATERY)
307 return;
308 }
309 case CLUB : {
310 if (xCurPos == CLUBX && yCurPos == CLUBY) currentState_.chgVal(*_passengerPos_, CLUB);
311 return;
312 }
313 case TAXI : return;
314 }
315 }
316 }

References _passengerDest_, _passengerPos_, _xPos_, _yPos_, gum::CLUB, gum::CLUBX, gum::CLUBY, gum::AbstractSimulator::currentState_, gum::HOME, gum::HOMEX, gum::HOMEY, gum::TAXI, gum::THEATER, gum::THEATERX, gum::THEATERY, gum::WORK, gum::WORKX, and gum::WORKY.

Referenced by perform().

Here is the caller graph for this function:

◆ actionName()

const std::string & gum::TaxiSimulator::actionName ( Idx actionId)
inlinevirtual

Iteration over the variables of the simulated probleme.

Implements gum::AbstractSimulator.

Definition at line 156 of file taxiSimulator.h.

156{ return *_actionMap_[actionId]; }

References _actionMap_.

◆ beginActions()

SequenceIteratorSafe< Idx > gum::TaxiSimulator::beginActions ( )
inlinevirtual

Iteration over the variables of the simulated probleme.

Implements gum::AbstractSimulator.

Definition at line 159 of file taxiSimulator.h.

159{ return _taxiActions_.beginSafe(); }

References _taxiActions_.

◆ beginVariables()

SequenceIteratorSafe< const DiscreteVariable * > gum::TaxiSimulator::beginVariables ( )
inlinevirtual

Iteration over the variables of the simulated probleme.

Implements gum::AbstractSimulator.

Definition at line 143 of file taxiSimulator.h.

143 {
144 return _taxiVars_.beginSafe();
145 }

References _taxiVars_.

Referenced by TaxiSimulator().

Here is the caller graph for this function:

◆ currentState()

INLINE const Instantiation & gum::AbstractSimulator::currentState ( )
inlineinherited

Sets the intial statefrom which we begun the simulation.

Definition at line 108 of file abstractSimulator.h.

108{ return currentState_; }

References currentState_.

◆ endActions()

SequenceIteratorSafe< Idx > gum::TaxiSimulator::endActions ( )
inlinevirtual

Iteration over the variables of the simulated probleme.

Implements gum::AbstractSimulator.

Definition at line 161 of file taxiSimulator.h.

161{ return _taxiActions_.endSafe(); }

References _taxiActions_.

◆ endVariables()

SequenceIteratorSafe< const DiscreteVariable * > gum::TaxiSimulator::endVariables ( )
inlinevirtual

Iteration over the variables of the simulated probleme.

Implements gum::AbstractSimulator.

Definition at line 147 of file taxiSimulator.h.

147{ return _taxiVars_.endSafe(); }

References _taxiVars_.

Referenced by TaxiSimulator().

Here is the caller graph for this function:

◆ hasReachEnd()

bool gum::TaxiSimulator::hasReachEnd ( )
virtual

Choses a random state as the first test for a run.

Reimplemented from gum::AbstractSimulator.

Definition at line 165 of file taxiSimulator.cpp.

165 {
166 // if( currentState_.valFromPtr( _passengerPos_) ==
167 // currentState_.valFromPtr( _passengerDest_) )
168 // return true;
169
170 // if( currentState_.valFromPtr( _fuelLevel_) == 0 )
171 // return true;
172
173 return false;
174 }

◆ perform()

void gum::TaxiSimulator::perform ( Idx actionId)
virtual

Iteration over the variables of the simulated probleme.

Implements gum::AbstractSimulator.

Definition at line 184 of file taxiSimulator.cpp.

184 {
186
187 _evalReward_();
188
189 Idx curFuelLevel = currentState_.valFromPtr(_fuelLevel_);
190 if (curFuelLevel > 0) currentState_.chgVal(*_fuelLevel_, --curFuelLevel);
191
192 switch (actionId) {
193 case GoNorth : return _performGoNorth_();
194 case GoEast : return _performGoEast_();
195 case GoSouth : return _performGoSouth_();
196 case GoWest : return _performGoWest_();
197 case PickUp : return _performPickUp_();
198 case PutDown : return _performPutDown_();
199 case FillUp : return _performFillUp_();
200 }
201 }
void _performFillUp_()
Iteration over the variables of the simulated probleme.
void _performGoEast_()
Iteration over the variables of the simulated probleme.
void _performGoWest_()
Iteration over the variables of the simulated probleme.
void _performGoSouth_()
Iteration over the variables of the simulated probleme.
void _performGoNorth_()
Iteration over the variables of the simulated probleme.
void _performPickUp_()
Iteration over the variables of the simulated probleme.
void _performPutDown_()
Iteration over the variables of the simulated probleme.
TaxiSimulationAction

References _evalReward_(), _fuelLevel_, _lastAction_, _performFillUp_(), _performGoEast_(), _performGoNorth_(), _performGoSouth_(), _performGoWest_(), _performPickUp_(), _performPutDown_(), gum::AbstractSimulator::currentState_, gum::FillUp, gum::GoEast, gum::GoNorth, gum::GoSouth, gum::GoWest, gum::PickUp, and gum::PutDown.

Here is the call graph for this function:

◆ primeVar()

const DiscreteVariable * gum::TaxiSimulator::primeVar ( const DiscreteVariable * mainVar)
inlinevirtual

Iteration over the variables of the simulated probleme.

Implements gum::AbstractSimulator.

Definition at line 138 of file taxiSimulator.h.

138 {
139 return _primeMap_.second(mainVar);
140 }

References _primeMap_.

Referenced by TaxiSimulator().

Here is the caller graph for this function:

◆ randomState_()

Instantiation gum::TaxiSimulator::randomState_ ( )
protectedvirtual

Choses a random state as the first test for a run.

Reimplemented from gum::AbstractSimulator.

Definition at line 142 of file taxiSimulator.cpp.

142 {
143 Instantiation randy = AbstractSimulator::randomState_();
144 // Idx curFuelLevel = randy.valFromPtr( _fuelLevel_);
145 // while(curFuelLevel > 12 || curFuelLevel < 5)
146 // curFuelLevel = (Idx)(((double)std::rand( ) / (double)RAND_MAX) *
147 // 7.0) + 5;
148 // randy.chgVal( _fuelLevel_, curFuelLevel);
149
150 // TaxiSimulationLandmark passPos = (TaxiSimulationLandmark)
151 // randy.valFromPtr( _passengerPos_);
152 // TaxiSimulationLandmark passDest = (TaxiSimulationLandmark)
153 // randy.valFromPtr( _passengerDest_);
154 // while( passPos == passDest || passPos == TAXI )
155 // passPos = (TaxiSimulationLandmark) (((double)std::rand( ) /
156 // (double)RAND_MAX) * 3.0);
157 // randy.chgVal( _passengerPos_, passPos);
158
159 return randy;
160 }
virtual Instantiation randomState_()
Choses a random state as the first test for a run.

References gum::AbstractSimulator::randomState_().

Here is the call graph for this function:

◆ reward()

double gum::TaxiSimulator::reward ( )
virtual

Sets the intial statefrom which we begun the simulation.

Implements gum::AbstractSimulator.

Definition at line 179 of file taxiSimulator.cpp.

179{ return _reward_; }

References _reward_.

◆ setEndState()

INLINE void gum::AbstractSimulator::setEndState ( const Instantiation & endState)
inlineinherited

Sets the final states upon which a run is over.

Definition at line 102 of file abstractSimulator.h.

102{ endState_ = endState; }

References endState_.

◆ setInitialState()

INLINE void gum::AbstractSimulator::setInitialState ( const Instantiation & initialState)
inlineinherited

Sets the intial statefrom which we begun the simulation.

Definition at line 92 of file abstractSimulator.h.

92{ currentState_ = initialState; }

References currentState_.

◆ setInitialStateRandomly()

void gum::AbstractSimulator::setInitialStateRandomly ( )
inherited

Sets the intial statefrom which we begun the simulation.

Definition at line 82 of file abstractSimulator.cpp.

82 {
83 bool hre = true;
84 while (hre) {
86 hre = hasReachEnd();
87 }
88 }
virtual bool hasReachEnd()
Tests if end state has been reached.

References currentState_, hasReachEnd(), and randomState_().

Here is the call graph for this function:

Member Data Documentation

◆ _actionMap_

HashTable< Idx, std::string* > gum::TaxiSimulator::_actionMap_
private

Definition at line 206 of file taxiSimulator.h.

Referenced by TaxiSimulator(), and actionName().

◆ _fuelLevel_

LabelizedVariable* gum::TaxiSimulator::_fuelLevel_
private

Definition at line 202 of file taxiSimulator.h.

Referenced by TaxiSimulator(), _evalReward_(), _performFillUp_(), and perform().

◆ _lastAction_

TaxiSimulationAction gum::TaxiSimulator::_lastAction_
private

Definition at line 208 of file taxiSimulator.h.

Referenced by _evalReward_(), and perform().

◆ _passengerDest_

LabelizedVariable* gum::TaxiSimulator::_passengerDest_
private

Definition at line 201 of file taxiSimulator.h.

Referenced by TaxiSimulator(), _evalReward_(), and _performPutDown_().

◆ _passengerPos_

LabelizedVariable* gum::TaxiSimulator::_passengerPos_
private

Definition at line 200 of file taxiSimulator.h.

Referenced by TaxiSimulator(), _evalReward_(), _performPickUp_(), and _performPutDown_().

◆ _primeMap_

Bijection< const DiscreteVariable*, const DiscreteVariable* > gum::TaxiSimulator::_primeMap_
private

Definition at line 197 of file taxiSimulator.h.

Referenced by TaxiSimulator(), ~TaxiSimulator(), and primeVar().

◆ _reward_

double gum::TaxiSimulator::_reward_
private

Reward.

Definition at line 211 of file taxiSimulator.h.

Referenced by _evalReward_(), and reward().

◆ _taxiActions_

Sequence< Idx > gum::TaxiSimulator::_taxiActions_
private

Actions.

Definition at line 205 of file taxiSimulator.h.

Referenced by TaxiSimulator(), beginActions(), and endActions().

◆ _taxiVars_

Sequence< const DiscreteVariable* > gum::TaxiSimulator::_taxiVars_
private

Variables data structures.

Definition at line 196 of file taxiSimulator.h.

Referenced by TaxiSimulator(), beginVariables(), and endVariables().

◆ _xPos_

LabelizedVariable* gum::TaxiSimulator::_xPos_
private

◆ _yPos_

◆ currentState_

◆ endState_

Instantiation gum::AbstractSimulator::endState_
inherited

Definition at line 146 of file abstractSimulator.h.

Referenced by hasReachEnd(), and setEndState().


The documentation for this class was generated from the following files: