aGrUM 3.1.1
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 () override
 Default destructor.
Variables
const DiscreteVariableprimeVar (const DiscreteVariable *mainVar) override
 Iteration over the variables of the simulated probleme.
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.
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.
void setEndState (const Instantiation &endState)
 Sets the final states upon which a run is over.
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 () override
 Choses a random state as the first test for a run.
Instantiation randomState_ () override
 Choses a random state as the first test for a run.

Actions

const std::string & actionName (Idx actionId) override
 Iteration over the variables of the simulated probleme.
SequenceIteratorSafe< IdxbeginActions () override
 Iteration over the variables of the simulated probleme.
SequenceIteratorSafe< IdxendActions () override
 Iteration over the variables of the simulated probleme.
void perform (Idx) override
 Sets the intial statefrom which we begun the simulation.
void _performGoNorth_ ()
void _performGoEast_ ()
void _performGoSouth_ ()
void _performGoWest_ ()
void _performPickUp_ ()
void _performPutDown_ ()
void _performFillUp_ ()

Rewards

double reward () override
 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 61 of file taxiSimulator.cpp.

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

Default destructor.

Definition at line 129 of file taxiSimulator.cpp.

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

References TaxiSimulator(), and _primeMap_.

Here is the call graph for this function:

Member Function Documentation

◆ _evalReward_()

void gum::TaxiSimulator::_evalReward_ ( )
private

Definition at line 335 of file taxiSimulator.cpp.

335 {
337 = (TaxiSimulationLandmarkX)this->currentState_.valFromPtr(_xPos_);
339 = (TaxiSimulationLandmarkY)this->currentState_.valFromPtr(_yPos_);
344
345 if (_lastAction_ == PutDown) {
346 if (passPos == TAXI) {
347 if (_isAtDestination_(passDest, xCurPos, yCurPos)) _reward_ = 30.0;
348 else _reward_ = 0.0;
349 return;
350 }
351 _reward_ = 0;
352 return;
353 }
354
355 if (_lastAction_ == PickUp) {
356 if (_isAtMeetPoint_(passPos, xCurPos, yCurPos)) _reward_ = 20.0;
357 else _reward_ = 0.0;
358 return;
359 }
360
361 if (currentState_.valFromPtr(_fuelLevel_) == 0 && _lastAction_ != FillUp) {
362 _reward_ = 0.0;
363 return;
364 }
365
366 if (_lastAction_ == FillUp && (xCurPos != STATIONX || yCurPos != STATIONY)) {
367 _reward_ = 0.0;
368 return;
369 }
370
371 _reward_ = 10.0; //-1.0;
372 }
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 374 of file taxiSimulator.cpp.

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

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 399 of file taxiSimulator.cpp.

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

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

Definition at line 323 of file taxiSimulator.cpp.

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

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

Definition at line 216 of file taxiSimulator.cpp.

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

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

Referenced by perform().

Here is the caller graph for this function:

◆ _performGoNorth_()

void gum::TaxiSimulator::_performGoNorth_ ( )
private

Definition at line 208 of file taxiSimulator.cpp.

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

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

Referenced by perform().

Here is the caller graph for this function:

◆ _performGoSouth_()

void gum::TaxiSimulator::_performGoSouth_ ( )
private

Definition at line 232 of file taxiSimulator.cpp.

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

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

Referenced by perform().

Here is the caller graph for this function:

◆ _performGoWest_()

void gum::TaxiSimulator::_performGoWest_ ( )
private

Definition at line 240 of file taxiSimulator.cpp.

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

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

Referenced by perform().

Here is the caller graph for this function:

◆ _performPickUp_()

void gum::TaxiSimulator::_performPickUp_ ( )
private

Definition at line 256 of file taxiSimulator.cpp.

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

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

Definition at line 287 of file taxiSimulator.cpp.

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

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()

INLINE const std::string & gum::TaxiSimulator::actionName ( Idx )
overridevirtual

Iteration over the variables of the simulated probleme.

Implements gum::AbstractSimulator.

Definition at line 60 of file taxiSimulator_inl.h.

60 {
61 return *_actionMap_[actionId];
62 }

References _actionMap_.

◆ beginActions()

INLINE SequenceIteratorSafe< Idx > gum::TaxiSimulator::beginActions ( )
overridevirtual

Iteration over the variables of the simulated probleme.

Implements gum::AbstractSimulator.

Definition at line 64 of file taxiSimulator_inl.h.

64 {
65 return _taxiActions_.beginSafe();
66 }

References _taxiActions_.

◆ beginVariables()

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

Iteration over the variables of the simulated probleme.

Implements gum::AbstractSimulator.

Definition at line 52 of file taxiSimulator_inl.h.

52 {
53 return _taxiVars_.beginSafe();
54 }

References _taxiVars_.

Referenced by TaxiSimulator().

Here is the caller graph for this function:

◆ currentState()

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

Sets the intial statefrom which we begun the simulation.

Definition at line 56 of file abstractSimulator_inl.h.

56{ return currentState_; }

References currentState_.

◆ endActions()

INLINE SequenceIteratorSafe< Idx > gum::TaxiSimulator::endActions ( )
overridevirtual

Iteration over the variables of the simulated probleme.

Implements gum::AbstractSimulator.

Definition at line 68 of file taxiSimulator_inl.h.

68{ return _taxiActions_.endSafe(); }

References _taxiActions_.

◆ endVariables()

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

Iteration over the variables of the simulated probleme.

Implements gum::AbstractSimulator.

Definition at line 56 of file taxiSimulator_inl.h.

56 {
57 return _taxiVars_.endSafe();
58 }

References _taxiVars_.

Referenced by TaxiSimulator().

Here is the caller graph for this function:

◆ hasReachEnd()

bool gum::TaxiSimulator::hasReachEnd ( )
overridevirtual

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

Reimplemented from gum::AbstractSimulator.

Definition at line 167 of file taxiSimulator.cpp.

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

◆ perform()

void gum::TaxiSimulator::perform ( Idx )
overridevirtual

Sets the intial statefrom which we begun the simulation.

Implements gum::AbstractSimulator.

Definition at line 186 of file taxiSimulator.cpp.

186 {
188
189 _evalReward_();
190
191 Idx curFuelLevel = currentState_.valFromPtr(_fuelLevel_);
192 if (curFuelLevel > 0) currentState_.chgVal(*_fuelLevel_, --curFuelLevel);
193
194 switch (actionId) {
195 case GoNorth : return _performGoNorth_();
196 case GoEast : return _performGoEast_();
197 case GoSouth : return _performGoSouth_();
198 case GoWest : return _performGoWest_();
199 case PickUp : return _performPickUp_();
200 case PutDown : return _performPutDown_();
201 case FillUp : return _performFillUp_();
202 }
203 }
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()

INLINE const DiscreteVariable * gum::TaxiSimulator::primeVar ( const DiscreteVariable * mainVar)
overridevirtual

Iteration over the variables of the simulated probleme.

Implements gum::AbstractSimulator.

Definition at line 48 of file taxiSimulator_inl.h.

48 {
49 return _primeMap_.second(mainVar);
50 }

References _primeMap_.

Referenced by TaxiSimulator().

Here is the caller graph for this function:

◆ randomState_()

Instantiation gum::TaxiSimulator::randomState_ ( )
overrideprotectedvirtual

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

Reimplemented from gum::AbstractSimulator.

Definition at line 144 of file taxiSimulator.cpp.

144 {
145 Instantiation randy = AbstractSimulator::randomState_();
146 // Idx curFuelLevel = randy.valFromPtr( _fuelLevel_);
147 // while(curFuelLevel > 12 || curFuelLevel < 5)
148 // curFuelLevel = (Idx)(((double)std::rand( ) / (double)RAND_MAX) *
149 // 7.0) + 5;
150 // randy.chgVal( _fuelLevel_, curFuelLevel);
151
152 // TaxiSimulationLandmark passPos = (TaxiSimulationLandmark)
153 // randy.valFromPtr( _passengerPos_);
154 // TaxiSimulationLandmark passDest = (TaxiSimulationLandmark)
155 // randy.valFromPtr( _passengerDest_);
156 // while( passPos == passDest || passPos == TAXI )
157 // passPos = (TaxiSimulationLandmark) (((double)std::rand( ) /
158 // (double)RAND_MAX) * 3.0);
159 // randy.chgVal( _passengerPos_, passPos);
160
161 return randy;
162 }
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 ( )
overridevirtual

Sets the intial statefrom which we begun the simulation.

Implements gum::AbstractSimulator.

Definition at line 181 of file taxiSimulator.cpp.

181{ return _reward_; }

References _reward_.

◆ setEndState()

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

Sets the final states upon which a run is over.

Definition at line 52 of file abstractSimulator_inl.h.

52 {
53 endState_ = endState;
54 }

References endState_.

◆ setInitialState()

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

Sets the intial statefrom which we begun the simulation.

Definition at line 48 of file abstractSimulator_inl.h.

48 {
49 currentState_ = initialState;
50 }

References currentState_.

◆ setInitialStateRandomly()

void gum::AbstractSimulator::setInitialStateRandomly ( )
inherited

Sets the intial statefrom which we begun the simulation.

Definition at line 86 of file abstractSimulator.cpp.

86 {
87 bool hre = true;
88 while (hre) {
90 hre = hasReachEnd();
91 }
92 }
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 201 of file taxiSimulator.h.

Referenced by TaxiSimulator(), and actionName().

◆ _fuelLevel_

LabelizedVariable* gum::TaxiSimulator::_fuelLevel_
private

Definition at line 197 of file taxiSimulator.h.

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

◆ _lastAction_

TaxiSimulationAction gum::TaxiSimulator::_lastAction_
private

Definition at line 203 of file taxiSimulator.h.

Referenced by _evalReward_(), and perform().

◆ _passengerDest_

LabelizedVariable* gum::TaxiSimulator::_passengerDest_
private

Definition at line 196 of file taxiSimulator.h.

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

◆ _passengerPos_

LabelizedVariable* gum::TaxiSimulator::_passengerPos_
private

Definition at line 195 of file taxiSimulator.h.

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

◆ _primeMap_

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

Definition at line 192 of file taxiSimulator.h.

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

◆ _reward_

double gum::TaxiSimulator::_reward_
private

Reward.

Definition at line 206 of file taxiSimulator.h.

Referenced by _evalReward_(), and reward().

◆ _taxiActions_

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

Actions.

Definition at line 200 of file taxiSimulator.h.

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

◆ _taxiVars_

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

Variables data structures.

Definition at line 191 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: