aGrUM  0.20.3
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 Attributes

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

Public Member Functions

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

States

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

Actions

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

Rewards

double reward ()
 Sets the intial statefrom which we begun the simulation. More...
 
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 87 of file taxiSimulator.h.

Constructor & Destructor Documentation

◆ TaxiSimulator()

gum::TaxiSimulator::TaxiSimulator ( )

Default constructor.

Definition at line 39 of file taxiSimulator.cpp.

References gum::Set< Key, Alloc >::emplace().

39  : AbstractSimulator() {
40  GUM_CONSTRUCTOR(TaxiSimulator);
41 
42  // *****************************************************************************************
43  // Défintion des variables du problème
44 
45  // Position TaxiSimulator
46  _xPos_ = new LabelizedVariable("xPos", "Position horizontale du TaxiSimulator");
47  _yPos_ = new LabelizedVariable("yPos", "Position verticale du TaxiSimulator");
50  for (Idx pos = 0; pos < 5; pos++) {
51  std::stringstream ss;
52  ss << pos;
53  _xPos_->addLabel(ss.str());
54  _yPos_->addLabel(ss.str());
55  }
56 
57  // Position et destination passager
58  _passengerPos_ = new LabelizedVariable("PassengerPos", "Position du Passager", 5);
59  _passengerDest_ = new LabelizedVariable("PassengerDest", "Destination du Passager", 4);
64  _passengerPos_->changeLabel(THEATER, "Theater");
65  _passengerDest_->changeLabel(THEATER, "Theater");
69 
70  _fuelLevel_ = new LabelizedVariable("FuelLevel", "Niveau du réservoir", 14);
71 
72  // Ajout à séquence
73  _taxiVars_.insert(_xPos_);
74  _taxiVars_.insert(_yPos_);
75  _taxiVars_.insert(_passengerPos_);
77  _taxiVars_.insert(_fuelLevel_);
78 
79  // Prime version creation
80  for (SequenceIteratorSafe< const DiscreteVariable* > varIter = this->beginVariables();
81  varIter != this->endVariables();
82  ++varIter) {
83  DiscreteVariable* primeVar = (*varIter)->clone();
84  primeVar->setName((*varIter)->name() + "'");
85  _primeMap_.insert((*varIter), primeVar);
86  }
87 
88  // *****************************************************************************************
89 
90  // *****************************************************************************************
91  // Défintion des actions du problème
93  _actionMap_.insert(GoNorth, new std::string("Go North"));
95  _actionMap_.insert(GoEast, new std::string("Go East"));
97  _actionMap_.insert(GoSouth, new std::string("Go South"));
99  _actionMap_.insert(GoWest, new std::string("Go West"));
101  _actionMap_.insert(PickUp, new std::string("Pick Up"));
103  _actionMap_.insert(PutDown, new std::string("Put Down"));
105  _actionMap_.insert(FillUp, new std::string("FillUp"));
106  }
void setName(const std::string &theValue)
sets the name of the variable
LabelizedVariable * _passengerPos_
LabelizedVariable * _yPos_
void changeLabel(Idx pos, const std::string &aLabel) const
change a label for this index
SequenceIteratorSafe< const DiscreteVariable *> beginVariables()
Iteration over the variables of the simulated probleme.
const DiscreteVariable * primeVar(const DiscreteVariable *mainVar)
Iteration over the variables of the simulated probleme.
SequenceIteratorSafe< const DiscreteVariable *> endVariables()
Iteration over the variables of the simulated probleme.
virtual DiscreteVariable * clone() const =0
Copy Factory.
void eraseLabels()
erase all the labels
LabelizedVariable * _xPos_
Sequence< const DiscreteVariable *> _taxiVars_
Variables data structures.
LabelizedVariable * _passengerDest_
Sequence< Idx > _taxiActions_
Actions.
Bijection< const DiscreteVariable *, const DiscreteVariable *> _primeMap_
HashTable< Idx, std::string *> _actionMap_
LabelizedVariable * _fuelLevel_
TaxiSimulator()
Default constructor.
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
LabelizedVariable & addLabel(const std::string &aLabel)
add a label with a new index (we assume that we will NEVER remove a label)
AbstractSimulator()
Default constructor.
void insert(const Key &k)
Insert an element at the end of the sequence.
Definition: sequence_tpl.h:393
+ Here is the call graph for this function:

◆ ~TaxiSimulator()

gum::TaxiSimulator::~TaxiSimulator ( )

Default destructor.

Definition at line 108 of file taxiSimulator.cpp.

References gum::Set< Key, Alloc >::emplace().

108  {
109  GUM_DESTRUCTOR(TaxiSimulator);
110 
111  for (BijectionIteratorSafe< const DiscreteVariable*, const DiscreteVariable* > varIter
112  = _primeMap_.beginSafe();
113  varIter != _primeMap_.endSafe();
114  ++varIter) {
115  delete varIter.first();
116  delete varIter.second();
117  }
118  }
Bijection< const DiscreteVariable *, const DiscreteVariable *> _primeMap_
TaxiSimulator()
Default constructor.
+ Here is the call graph for this function:

Member Function Documentation

◆ _evalReward_()

void gum::TaxiSimulator::_evalReward_ ( )
private

Definition at line 334 of file taxiSimulator.cpp.

References gum::Set< Key, Alloc >::emplace().

334  {
339  TaxiSimulationLandmark passPos
341  TaxiSimulationLandmark passDest
343 
344  if (_lastAction_ == PutDown) {
345  if (passPos == TAXI) {
346  if (_isAtDestination_(passDest, xCurPos, yCurPos))
347  _reward_ = 30.0;
348  else
349  _reward_ = 0.0;
350  return;
351  }
352  _reward_ = 0;
353  return;
354  }
355 
356  if (_lastAction_ == PickUp) {
357  if (_isAtMeetPoint_(passPos, xCurPos, yCurPos))
358  _reward_ = 20.0;
359  else
360  _reward_ = 0.0;
361  return;
362  }
363 
365  _reward_ = 0.0;
366  return;
367  }
368 
369  if (_lastAction_ == FillUp && (xCurPos != STATIONX || yCurPos != STATIONY)) {
370  _reward_ = 0.0;
371  return;
372  }
373 
374  _reward_ = 10.0; //-1.0;
375  }
LabelizedVariable * _passengerPos_
LabelizedVariable * _yPos_
double _reward_
Reward.
Idx valFromPtr(const DiscreteVariable *pvar) const
Returns the current value of a given variable.
bool _isAtDestination_(TaxiSimulationLandmark passDest, TaxiSimulationLandmarkX xCurPos, TaxiSimulationLandmarkY yCurPos)
TaxiSimulationAction _lastAction_
TaxiSimulationLandmarkX
Definition: taxiSimulator.h:52
LabelizedVariable * _xPos_
Instantiation currentState_
Tha state in which the system currently is.
TaxiSimulationLandmark
Definition: taxiSimulator.h:44
bool _isAtMeetPoint_(TaxiSimulationLandmark passpos, TaxiSimulationLandmarkX xCurPos, TaxiSimulationLandmarkY yCurPos)
TaxiSimulationLandmarkY
Definition: taxiSimulator.h:60
LabelizedVariable * _passengerDest_
LabelizedVariable * _fuelLevel_
+ Here is the call graph for this function:

◆ _isAtDestination_()

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

Definition at line 377 of file taxiSimulator.cpp.

References gum::Set< Key, Alloc >::emplace().

379  {
380  switch (passDest) {
381  case HOME: {
382  if (xCurPos == HOMEX && yCurPos == HOMEY) return true;
383  break;
384  }
385  case WORK: {
386  if (xCurPos == WORKX && yCurPos == WORKY) return true;
387  break;
388  }
389  case THEATER: {
390  if (xCurPos == THEATERX && yCurPos == THEATERY) return true;
391  break;
392  }
393  case CLUB: {
394  if (xCurPos == CLUBX && yCurPos == CLUBY) return true;
395  break;
396  }
397  case TAXI:
398  return false;
399  }
400  return false;
401  }
+ Here is the call graph for this function:

◆ _isAtMeetPoint_()

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

Definition at line 403 of file taxiSimulator.cpp.

References gum::Set< Key, Alloc >::emplace().

405  {
406  switch (passPos) {
407  case HOME: {
408  if (xCurPos == HOMEX && yCurPos == HOMEY) return true;
409  break;
410  }
411  case WORK: {
412  if (xCurPos == WORKX && yCurPos == WORKY) return true;
413  break;
414  }
415  case THEATER: {
416  if (xCurPos == THEATERX && yCurPos == THEATERY) return true;
417  break;
418  }
419  case CLUB: {
420  if (xCurPos == CLUBX && yCurPos == CLUBY) return true;
421  break;
422  }
423  case TAXI:
424  return false;
425  }
426  return false;
427  }
+ Here is the call 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.

References gum::Set< Key, Alloc >::emplace().

321  {
326 
327  if (xCurPos == STATIONX && yCurPos == STATIONY) currentState_.chgVal(_fuelLevel_, 13);
328  }
LabelizedVariable * _yPos_
Idx valFromPtr(const DiscreteVariable *pvar) const
Returns the current value of a given variable.
TaxiSimulationLandmarkX
Definition: taxiSimulator.h:52
LabelizedVariable * _xPos_
Instantiation currentState_
Tha state in which the system currently is.
Instantiation & chgVal(const DiscreteVariable &v, Idx newval)
Assign newval to variable v in the Instantiation.
TaxiSimulationLandmarkY
Definition: taxiSimulator.h:60
LabelizedVariable * _fuelLevel_
+ Here is the call graph for this function:

◆ _performGoEast_()

void gum::TaxiSimulator::_performGoEast_ ( )
private

Iteration over the variables of the simulated probleme.

Definition at line 207 of file taxiSimulator.cpp.

References gum::Set< Key, Alloc >::emplace().

207  {
208  Idx xCurPos = this->currentState_.valFromPtr(_xPos_);
209  Idx yCurPos = this->currentState_.valFromPtr(_yPos_);
210 
211  if (xCurPos == 4) return;
212  if (xCurPos == 0 || xCurPos == 2)
213  if (yCurPos == 0 || yCurPos == 1) return;
214  if (xCurPos == 1)
215  if (yCurPos == 3 || yCurPos == 4) return;
216 
217  currentState_.chgVal(_xPos_, ++xCurPos);
218  }
LabelizedVariable * _yPos_
Idx valFromPtr(const DiscreteVariable *pvar) const
Returns the current value of a given variable.
LabelizedVariable * _xPos_
Instantiation currentState_
Tha state in which the system currently is.
Instantiation & chgVal(const DiscreteVariable &v, Idx newval)
Assign newval to variable v in the Instantiation.
+ Here is the call graph for this function:

◆ _performGoNorth_()

void gum::TaxiSimulator::_performGoNorth_ ( )
private

Iteration over the variables of the simulated probleme.

Definition at line 198 of file taxiSimulator.cpp.

References gum::Set< Key, Alloc >::emplace().

198  {
199  Idx curPos = this->currentState_.valFromPtr(_yPos_);
200  if (curPos < 4) currentState_.chgVal(_yPos_, ++curPos);
201  }
LabelizedVariable * _yPos_
Idx valFromPtr(const DiscreteVariable *pvar) const
Returns the current value of a given variable.
Instantiation currentState_
Tha state in which the system currently is.
Instantiation & chgVal(const DiscreteVariable &v, Idx newval)
Assign newval to variable v in the Instantiation.
+ Here is the call graph for this function:

◆ _performGoSouth_()

void gum::TaxiSimulator::_performGoSouth_ ( )
private

Iteration over the variables of the simulated probleme.

Definition at line 224 of file taxiSimulator.cpp.

References gum::Set< Key, Alloc >::emplace().

224  {
225  Idx curPos = this->currentState_.valFromPtr(_yPos_);
226  if (curPos > 0) currentState_.chgVal(_yPos_, --curPos);
227  }
LabelizedVariable * _yPos_
Idx valFromPtr(const DiscreteVariable *pvar) const
Returns the current value of a given variable.
Instantiation currentState_
Tha state in which the system currently is.
Instantiation & chgVal(const DiscreteVariable &v, Idx newval)
Assign newval to variable v in the Instantiation.
+ Here is the call graph for this function:

◆ _performGoWest_()

void gum::TaxiSimulator::_performGoWest_ ( )
private

Iteration over the variables of the simulated probleme.

Definition at line 233 of file taxiSimulator.cpp.

References gum::Set< Key, Alloc >::emplace().

233  {
234  Idx xCurPos = this->currentState_.valFromPtr(_xPos_);
235  Idx yCurPos = this->currentState_.valFromPtr(_yPos_);
236 
237  if (xCurPos == 0) return;
238  if (xCurPos == 1 || xCurPos == 3)
239  if (yCurPos == 0 || yCurPos == 1) return;
240  if (xCurPos == 2)
241  if (yCurPos == 3 || yCurPos == 4) return;
242 
243  currentState_.chgVal(_xPos_, --xCurPos);
244  }
LabelizedVariable * _yPos_
Idx valFromPtr(const DiscreteVariable *pvar) const
Returns the current value of a given variable.
LabelizedVariable * _xPos_
Instantiation currentState_
Tha state in which the system currently is.
Instantiation & chgVal(const DiscreteVariable &v, Idx newval)
Assign newval to variable v in the Instantiation.
+ Here is the call graph for this function:

◆ _performPickUp_()

void gum::TaxiSimulator::_performPickUp_ ( )
private

Iteration over the variables of the simulated probleme.

Definition at line 250 of file taxiSimulator.cpp.

References gum::Set< Key, Alloc >::emplace().

250  {
255  TaxiSimulationLandmark passPos
257  switch (passPos) {
258  case HOME: {
259  if (xCurPos == HOMEX && yCurPos == HOMEY) currentState_.chgVal(_passengerPos_, TAXI);
260  return;
261  }
262  case WORK: {
263  if (xCurPos == WORKX && yCurPos == WORKY) currentState_.chgVal(_passengerPos_, TAXI);
264  return;
265  }
266  case THEATER: {
267  if (xCurPos == THEATERX && yCurPos == THEATERY) currentState_.chgVal(_passengerPos_, TAXI);
268  return;
269  }
270  case CLUB: {
271  if (xCurPos == CLUBX && yCurPos == CLUBY) currentState_.chgVal(_passengerPos_, TAXI);
272  return;
273  }
274  case TAXI:
275  return;
276  }
277  }
LabelizedVariable * _passengerPos_
LabelizedVariable * _yPos_
Idx valFromPtr(const DiscreteVariable *pvar) const
Returns the current value of a given variable.
TaxiSimulationLandmarkX
Definition: taxiSimulator.h:52
LabelizedVariable * _xPos_
Instantiation currentState_
Tha state in which the system currently is.
Instantiation & chgVal(const DiscreteVariable &v, Idx newval)
Assign newval to variable v in the Instantiation.
TaxiSimulationLandmark
Definition: taxiSimulator.h:44
TaxiSimulationLandmarkY
Definition: taxiSimulator.h:60
+ Here is the call graph for this function:

◆ _performPutDown_()

void gum::TaxiSimulator::_performPutDown_ ( )
private

Iteration over the variables of the simulated probleme.

Definition at line 283 of file taxiSimulator.cpp.

References gum::Set< Key, Alloc >::emplace().

283  {
288  TaxiSimulationLandmark passPos
290  TaxiSimulationLandmark passDest
292  if (passPos == TAXI) {
293  switch (passDest) {
294  case HOME: {
295  if (xCurPos == HOMEX && yCurPos == HOMEY) currentState_.chgVal(_passengerPos_, HOME);
296  return;
297  }
298  case WORK: {
299  if (xCurPos == WORKX && yCurPos == WORKY) currentState_.chgVal(_passengerPos_, WORK);
300  return;
301  }
302  case THEATER: {
303  if (xCurPos == THEATERX && yCurPos == THEATERY)
305  return;
306  }
307  case CLUB: {
308  if (xCurPos == CLUBX && yCurPos == CLUBY) currentState_.chgVal(_passengerPos_, CLUB);
309  return;
310  }
311  case TAXI:
312  return;
313  }
314  }
315  }
LabelizedVariable * _passengerPos_
LabelizedVariable * _yPos_
Idx valFromPtr(const DiscreteVariable *pvar) const
Returns the current value of a given variable.
TaxiSimulationLandmarkX
Definition: taxiSimulator.h:52
LabelizedVariable * _xPos_
Instantiation currentState_
Tha state in which the system currently is.
Instantiation & chgVal(const DiscreteVariable &v, Idx newval)
Assign newval to variable v in the Instantiation.
TaxiSimulationLandmark
Definition: taxiSimulator.h:44
TaxiSimulationLandmarkY
Definition: taxiSimulator.h:60
LabelizedVariable * _passengerDest_
+ Here is the call 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 142 of file taxiSimulator.h.

142 { return *_actionMap_[actionId]; }
HashTable< Idx, std::string *> _actionMap_

◆ beginActions()

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

Iteration over the variables of the simulated probleme.

Implements gum::AbstractSimulator.

Definition at line 145 of file taxiSimulator.h.

145 { return _taxiActions_.beginSafe(); }
iterator_safe beginSafe() const
Returns a safe begin iterator.
Definition: sequence_tpl.h:603
Sequence< Idx > _taxiActions_
Actions.

◆ beginVariables()

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

Iteration over the variables of the simulated probleme.

Implements gum::AbstractSimulator.

Definition at line 130 of file taxiSimulator.h.

130  {
131  return _taxiVars_.beginSafe();
132  }
Sequence< const DiscreteVariable *> _taxiVars_
Variables data structures.

◆ currentState()

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

Sets the intial statefrom which we begun the simulation.

Definition at line 87 of file abstractSimulator.h.

References gum::AbstractSimulator::reward().

87 { return currentState_; }
Instantiation currentState_
Tha state in which the system currently is.
+ Here is the call graph for this function:

◆ endActions()

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

Iteration over the variables of the simulated probleme.

Implements gum::AbstractSimulator.

Definition at line 146 of file taxiSimulator.h.

146 { return _taxiActions_.endSafe(); }
const iterator_safe & endSafe() const noexcept
Returns the safe end iterator.
Definition: sequence_tpl.h:610
Sequence< Idx > _taxiActions_
Actions.

◆ endVariables()

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

Iteration over the variables of the simulated probleme.

Implements gum::AbstractSimulator.

Definition at line 133 of file taxiSimulator.h.

133 { return _taxiVars_.endSafe(); }
Sequence< const DiscreteVariable *> _taxiVars_
Variables data structures.

◆ hasReachEnd()

bool gum::TaxiSimulator::hasReachEnd ( )
virtual

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

Reimplemented from gum::AbstractSimulator.

Definition at line 148 of file taxiSimulator.cpp.

148  {
149  // if( currentState_.valFromPtr( _passengerPos_) ==
150  // currentState_.valFromPtr( _passengerDest_) )
151  // return true;
152 
153  // if( currentState_.valFromPtr( _fuelLevel_) == 0 )
154  // return true;
155 
156  return false;
157  }

◆ perform()

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

Iteration over the variables of the simulated probleme.

Implements gum::AbstractSimulator.

Definition at line 168 of file taxiSimulator.cpp.

References gum::Set< Key, Alloc >::emplace().

168  {
170 
171  _evalReward_();
172 
173  Idx curFuelLevel = currentState_.valFromPtr(_fuelLevel_);
174  if (curFuelLevel > 0) currentState_.chgVal(_fuelLevel_, --curFuelLevel);
175 
176  switch (actionId) {
177  case GoNorth:
178  return _performGoNorth_();
179  case GoEast:
180  return _performGoEast_();
181  case GoSouth:
182  return _performGoSouth_();
183  case GoWest:
184  return _performGoWest_();
185  case PickUp:
186  return _performPickUp_();
187  case PutDown:
188  return _performPutDown_();
189  case FillUp:
190  return _performFillUp_();
191  }
192  }
void _performGoSouth_()
Iteration over the variables of the simulated probleme.
void _performFillUp_()
Iteration over the variables of the simulated probleme.
void _performGoEast_()
Iteration over the variables of the simulated probleme.
void _performGoNorth_()
Iteration over the variables of the simulated probleme.
Idx valFromPtr(const DiscreteVariable *pvar) const
Returns the current value of a given variable.
TaxiSimulationAction
Definition: taxiSimulator.h:68
TaxiSimulationAction _lastAction_
Instantiation currentState_
Tha state in which the system currently is.
Instantiation & chgVal(const DiscreteVariable &v, Idx newval)
Assign newval to variable v in the Instantiation.
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.
LabelizedVariable * _fuelLevel_
+ 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 125 of file taxiSimulator.h.

125  {
126  return _primeMap_.second(mainVar);
127  }
Bijection< const DiscreteVariable *, const DiscreteVariable *> _primeMap_

◆ randomState_()

Instantiation gum::TaxiSimulator::randomState_ ( )
protectedvirtual

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

Reimplemented from gum::AbstractSimulator.

Definition at line 124 of file taxiSimulator.cpp.

References gum::Set< Key, Alloc >::emplace().

124  {
125  Instantiation randy = AbstractSimulator::randomState_();
126  // Idx curFuelLevel = randy.valFromPtr( _fuelLevel_);
127  // while(curFuelLevel > 12 || curFuelLevel < 5)
128  // curFuelLevel = (Idx)(((double)std::rand( ) / (double)RAND_MAX) *
129  // 7.0) + 5;
130  // randy.chgVal( _fuelLevel_, curFuelLevel);
131 
132  // TaxiSimulationLandmark passPos = (TaxiSimulationLandmark)
133  // randy.valFromPtr( _passengerPos_);
134  // TaxiSimulationLandmark passDest = (TaxiSimulationLandmark)
135  // randy.valFromPtr( _passengerDest_);
136  // while( passPos == passDest || passPos == TAXI )
137  // passPos = (TaxiSimulationLandmark) (((double)std::rand( ) /
138  // (double)RAND_MAX) * 3.0);
139  // randy.chgVal( _passengerPos_, passPos);
140 
141  return randy;
142  }
virtual Instantiation randomState_()
Choses a random state as the first test for a run.
+ 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 163 of file taxiSimulator.cpp.

References gum::Set< Key, Alloc >::emplace().

163 { return _reward_; }
double _reward_
Reward.
+ Here is the call graph for this function:

◆ setEndState()

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

Sets the final states upon which a run is over.

Definition at line 81 of file abstractSimulator.h.

References gum::AbstractSimulator::reward().

81 { endState_ = endState; }
+ Here is the call graph for this function:

◆ setInitialState()

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

Sets the intial statefrom which we begun the simulation.

Definition at line 72 of file abstractSimulator.h.

References gum::AbstractSimulator::reward().

72 { currentState_ = initialState; }
Instantiation currentState_
Tha state in which the system currently is.
+ Here is the call graph for this function:

◆ setInitialStateRandomly()

void gum::AbstractSimulator::setInitialStateRandomly ( )
inherited

Sets the intial statefrom which we begun the simulation.

Definition at line 64 of file abstractSimulator.cpp.

References gum::Set< Key, Alloc >::emplace().

64  {
65  bool hre = true;
66  while (hre) {
68  hre = hasReachEnd();
69  }
70  }
virtual bool hasReachEnd()
Tests if end state has been reached.
virtual Instantiation randomState_()
Choses a random state as the first test for a run.
Instantiation currentState_
Tha state in which the system currently is.
+ Here is the call graph for this function:

Member Data Documentation

◆ _actionMap_

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

Definition at line 191 of file taxiSimulator.h.

◆ _fuelLevel_

LabelizedVariable* gum::TaxiSimulator::_fuelLevel_
private

Definition at line 187 of file taxiSimulator.h.

◆ _lastAction_

TaxiSimulationAction gum::TaxiSimulator::_lastAction_
private

Definition at line 193 of file taxiSimulator.h.

◆ _passengerDest_

LabelizedVariable* gum::TaxiSimulator::_passengerDest_
private

Definition at line 186 of file taxiSimulator.h.

◆ _passengerPos_

LabelizedVariable* gum::TaxiSimulator::_passengerPos_
private

Definition at line 185 of file taxiSimulator.h.

◆ _primeMap_

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

Definition at line 182 of file taxiSimulator.h.

◆ _reward_

double gum::TaxiSimulator::_reward_
private

Reward.

Definition at line 196 of file taxiSimulator.h.

◆ _taxiActions_

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

Actions.

Definition at line 190 of file taxiSimulator.h.

◆ _taxiVars_

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

Variables data structures.

Definition at line 181 of file taxiSimulator.h.

◆ _xPos_

LabelizedVariable* gum::TaxiSimulator::_xPos_
private

Definition at line 183 of file taxiSimulator.h.

◆ _yPos_

LabelizedVariable* gum::TaxiSimulator::_yPos_
private

Definition at line 184 of file taxiSimulator.h.

◆ currentState_

Instantiation gum::AbstractSimulator::currentState_
inherited

Tha state in which the system currently is.

Definition at line 125 of file abstractSimulator.h.

◆ endState_

Instantiation gum::AbstractSimulator::endState_
inherited

Definition at line 125 of file abstractSimulator.h.


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