aGrUM  0.20.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 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__
47  = new LabelizedVariable("xPos", "Position horizontale du TaxiSimulator");
48  yPos__ = new LabelizedVariable("yPos", "Position verticale du TaxiSimulator");
51  for (Idx pos = 0; pos < 5; pos++) {
52  std::stringstream ss;
53  ss << pos;
54  xPos__->addLabel(ss.str());
55  yPos__->addLabel(ss.str());
56  }
57 
58  // Position et destination passager
60  = new LabelizedVariable("PassengerPos", "Position du Passager", 5);
62  = new LabelizedVariable("PassengerDest", "Destination du Passager", 4);
67  passengerPos__->changeLabel(THEATER, "Theater");
68  passengerDest__->changeLabel(THEATER, "Theater");
72 
73  fuelLevel__ = new LabelizedVariable("FuelLevel", "Niveau du réservoir", 14);
74 
75  // Ajout à séquence
76  taxiVars__.insert(xPos__);
77  taxiVars__.insert(yPos__);
78  taxiVars__.insert(passengerPos__);
80  taxiVars__.insert(fuelLevel__);
81 
82  // Prime version creation
83  for (SequenceIteratorSafe< const DiscreteVariable* > varIter
84  = this->beginVariables();
85  varIter != this->endVariables();
86  ++varIter) {
87  DiscreteVariable* primeVar = (*varIter)->clone();
88  primeVar->setName((*varIter)->name() + "'");
89  primeMap__.insert((*varIter), primeVar);
90  }
91 
92  // *****************************************************************************************
93 
94  // *****************************************************************************************
95  // Défintion des actions du problème
97  actionMap__.insert(GoNorth, new std::string("Go North"));
99  actionMap__.insert(GoEast, new std::string("Go East"));
101  actionMap__.insert(GoSouth, new std::string("Go South"));
103  actionMap__.insert(GoWest, new std::string("Go West"));
105  actionMap__.insert(PickUp, new std::string("Pick Up"));
107  actionMap__.insert(PutDown, new std::string("Put Down"));
109  actionMap__.insert(FillUp, new std::string("FillUp"));
110  }
void setName(const std::string &theValue)
sets the name of the variable
void changeLabel(Idx pos, const std::string &aLabel) const
change a label for this index
Bijection< const DiscreteVariable *, const DiscreteVariable *> primeMap__
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.
LabelizedVariable * passengerDest__
SequenceIteratorSafe< const DiscreteVariable *> endVariables()
Iteration over the variables of the simulated probleme.
virtual DiscreteVariable * clone() const =0
Copy Factory.
LabelizedVariable * yPos__
void eraseLabels()
erase all the labels
LabelizedVariable * fuelLevel__
LabelizedVariable * xPos__
HashTable< Idx, std::string *> actionMap__
Sequence< Idx > taxiActions__
Actions.
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)
Sequence< const DiscreteVariable *> taxiVars__
Variables data structures.
AbstractSimulator()
Default constructor.
LabelizedVariable * passengerPos__
void insert(const Key &k)
Insert an element at the end of the sequence.
Definition: sequence_tpl.h:409
+ Here is the call graph for this function:

◆ ~TaxiSimulator()

gum::TaxiSimulator::~TaxiSimulator ( )

Default destructor.

Definition at line 112 of file taxiSimulator.cpp.

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

112  {
113  GUM_DESTRUCTOR(TaxiSimulator);
114 
115  for (BijectionIteratorSafe< const DiscreteVariable*, const DiscreteVariable* >
116  varIter
117  = primeMap__.beginSafe();
118  varIter != primeMap__.endSafe();
119  ++varIter) {
120  delete varIter.first();
121  delete varIter.second();
122  }
123  }
Bijection< const DiscreteVariable *, const DiscreteVariable *> primeMap__
TaxiSimulator()
Default constructor.
+ Here is the call graph for this function:

Member Function Documentation

◆ actionName()

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

Iteration over the variables of the simulated probleme.

Implements gum::AbstractSimulator.

Definition at line 144 of file taxiSimulator.h.

144 { 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 147 of file taxiSimulator.h.

147  {
148  return taxiActions__.beginSafe();
149  }
iterator_safe beginSafe() const
Returns a safe begin iterator.
Definition: sequence_tpl.h:628
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 91 of file abstractSimulator.h.

References gum::AbstractSimulator::reward().

91 { 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 150 of file taxiSimulator.h.

150 { return taxiActions__.endSafe(); }
const iterator_safe & endSafe() const noexcept
Returns the safe end iterator.
Definition: sequence_tpl.h:635
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  {
134  return taxiVars__.endSafe();
135  }
Sequence< const DiscreteVariable *> taxiVars__
Variables data structures.

◆ evalReward__()

void gum::TaxiSimulator::evalReward__ ( )
private

Definition at line 347 of file taxiSimulator.cpp.

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

347  {
352  TaxiSimulationLandmark passPos
354  TaxiSimulationLandmark passDest
356 
357  if (lastAction__ == PutDown) {
358  if (passPos == TAXI) {
359  if (isAtDestination__(passDest, xCurPos, yCurPos))
360  reward__ = 30.0;
361  else
362  reward__ = 0.0;
363  return;
364  }
365  reward__ = 0;
366  return;
367  }
368 
369  if (lastAction__ == PickUp) {
370  if (isAtMeetPoint__(passPos, xCurPos, yCurPos))
371  reward__ = 20.0;
372  else
373  reward__ = 0.0;
374  return;
375  }
376 
378  reward__ = 0.0;
379  return;
380  }
381 
382  if (lastAction__ == FillUp && (xCurPos != STATIONX || yCurPos != STATIONY)) {
383  reward__ = 0.0;
384  return;
385  }
386 
387  reward__ = 10.0; //-1.0;
388  }
TaxiSimulationAction lastAction__
double reward__
Reward.
Idx valFromPtr(const DiscreteVariable *pvar) const
Returns the current value of a given variable.
TaxiSimulationLandmarkX
Definition: taxiSimulator.h:52
LabelizedVariable * passengerDest__
LabelizedVariable * yPos__
Instantiation currentState_
Tha state in which the system currently is.
bool isAtMeetPoint__(TaxiSimulationLandmark passpos, TaxiSimulationLandmarkX xCurPos, TaxiSimulationLandmarkY yCurPos)
TaxiSimulationLandmark
Definition: taxiSimulator.h:44
TaxiSimulationLandmarkY
Definition: taxiSimulator.h:60
LabelizedVariable * fuelLevel__
LabelizedVariable * xPos__
bool isAtDestination__(TaxiSimulationLandmark passDest, TaxiSimulationLandmarkX xCurPos, TaxiSimulationLandmarkY yCurPos)
LabelizedVariable * passengerPos__
+ Here is the call 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 153 of file taxiSimulator.cpp.

153  {
154  // if( currentState_.valFromPtr(passengerPos__) ==
155  // currentState_.valFromPtr(passengerDest__) )
156  // return true;
157 
158  // if( currentState_.valFromPtr(fuelLevel__) == 0 )
159  // return true;
160 
161  return false;
162  }

◆ isAtDestination__()

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

Definition at line 390 of file taxiSimulator.cpp.

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

392  {
393  switch (passDest) {
394  case HOME: {
395  if (xCurPos == HOMEX && yCurPos == HOMEY) return true;
396  break;
397  }
398  case WORK: {
399  if (xCurPos == WORKX && yCurPos == WORKY) return true;
400  break;
401  }
402  case THEATER: {
403  if (xCurPos == THEATERX && yCurPos == THEATERY) return true;
404  break;
405  }
406  case CLUB: {
407  if (xCurPos == CLUBX && yCurPos == CLUBY) return true;
408  break;
409  }
410  case TAXI:
411  return false;
412  }
413  return false;
414  }
+ Here is the call graph for this function:

◆ isAtMeetPoint__()

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

Definition at line 416 of file taxiSimulator.cpp.

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

418  {
419  switch (passPos) {
420  case HOME: {
421  if (xCurPos == HOMEX && yCurPos == HOMEY) return true;
422  break;
423  }
424  case WORK: {
425  if (xCurPos == WORKX && yCurPos == WORKY) return true;
426  break;
427  }
428  case THEATER: {
429  if (xCurPos == THEATERX && yCurPos == THEATERY) return true;
430  break;
431  }
432  case CLUB: {
433  if (xCurPos == CLUBX && yCurPos == CLUBY) return true;
434  break;
435  }
436  case TAXI:
437  return false;
438  }
439  return false;
440  }
+ Here is the call graph for this function:

◆ perform()

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

Iteration over the variables of the simulated probleme.

Implements gum::AbstractSimulator.

Definition at line 173 of file taxiSimulator.cpp.

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

173  {
175 
176  evalReward__();
177 
178  Idx curFuelLevel = currentState_.valFromPtr(fuelLevel__);
179  if (curFuelLevel > 0) currentState_.chgVal(fuelLevel__, --curFuelLevel);
180 
181  switch (actionId) {
182  case GoNorth:
183  return performGoNorth__();
184  case GoEast:
185  return performGoEast__();
186  case GoSouth:
187  return performGoSouth__();
188  case GoWest:
189  return performGoWest__();
190  case PickUp:
191  return performPickUp__();
192  case PutDown:
193  return performPutDown__();
194  case FillUp:
195  return performFillUp__();
196  }
197  }
TaxiSimulationAction lastAction__
void performPutDown__()
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
void performGoEast__()
Iteration over the variables of the simulated probleme.
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.
LabelizedVariable * fuelLevel__
void performGoWest__()
Iteration over the variables of the simulated probleme.
void performFillUp__()
Iteration over the variables of the simulated probleme.
void performPickUp__()
Iteration over the variables of the simulated probleme.
void performGoNorth__()
Iteration over the variables of the simulated probleme.
void performGoSouth__()
Iteration over the variables of the simulated probleme.
+ 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 333 of file taxiSimulator.cpp.

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

333  {
338 
339  if (xCurPos == STATIONX && yCurPos == STATIONY)
341  }
Idx valFromPtr(const DiscreteVariable *pvar) const
Returns the current value of a given variable.
TaxiSimulationLandmarkX
Definition: taxiSimulator.h:52
LabelizedVariable * yPos__
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__
LabelizedVariable * xPos__
+ 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 212 of file taxiSimulator.cpp.

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

212  {
213  Idx xCurPos = this->currentState_.valFromPtr(xPos__);
214  Idx yCurPos = this->currentState_.valFromPtr(yPos__);
215 
216  if (xCurPos == 4) return;
217  if (xCurPos == 0 || xCurPos == 2)
218  if (yCurPos == 0 || yCurPos == 1) return;
219  if (xCurPos == 1)
220  if (yCurPos == 3 || yCurPos == 4) return;
221 
222  currentState_.chgVal(xPos__, ++xCurPos);
223  }
Idx valFromPtr(const DiscreteVariable *pvar) const
Returns the current value of a given variable.
LabelizedVariable * yPos__
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.
LabelizedVariable * xPos__
+ 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 203 of file taxiSimulator.cpp.

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

203  {
204  Idx curPos = this->currentState_.valFromPtr(yPos__);
205  if (curPos < 4) currentState_.chgVal(yPos__, ++curPos);
206  }
Idx valFromPtr(const DiscreteVariable *pvar) const
Returns the current value of a given variable.
LabelizedVariable * yPos__
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 229 of file taxiSimulator.cpp.

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

229  {
230  Idx curPos = this->currentState_.valFromPtr(yPos__);
231  if (curPos > 0) currentState_.chgVal(yPos__, --curPos);
232  }
Idx valFromPtr(const DiscreteVariable *pvar) const
Returns the current value of a given variable.
LabelizedVariable * yPos__
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 238 of file taxiSimulator.cpp.

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

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  }
Idx valFromPtr(const DiscreteVariable *pvar) const
Returns the current value of a given variable.
LabelizedVariable * yPos__
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.
LabelizedVariable * xPos__
+ 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 255 of file taxiSimulator.cpp.

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

255  {
260  TaxiSimulationLandmark passPos
262  switch (passPos) {
263  case HOME: {
264  if (xCurPos == HOMEX && yCurPos == HOMEY)
266  return;
267  }
268  case WORK: {
269  if (xCurPos == WORKX && yCurPos == WORKY)
271  return;
272  }
273  case THEATER: {
274  if (xCurPos == THEATERX && yCurPos == THEATERY)
276  return;
277  }
278  case CLUB: {
279  if (xCurPos == CLUBX && yCurPos == CLUBY)
281  return;
282  }
283  case TAXI:
284  return;
285  }
286  }
Idx valFromPtr(const DiscreteVariable *pvar) const
Returns the current value of a given variable.
TaxiSimulationLandmarkX
Definition: taxiSimulator.h:52
LabelizedVariable * yPos__
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 * xPos__
LabelizedVariable * passengerPos__
+ 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 292 of file taxiSimulator.cpp.

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

292  {
297  TaxiSimulationLandmark passPos
299  TaxiSimulationLandmark passDest
301  if (passPos == TAXI) {
302  switch (passDest) {
303  case HOME: {
304  if (xCurPos == HOMEX && yCurPos == HOMEY)
306  return;
307  }
308  case WORK: {
309  if (xCurPos == WORKX && yCurPos == WORKY)
311  return;
312  }
313  case THEATER: {
314  if (xCurPos == THEATERX && yCurPos == THEATERY)
316  return;
317  }
318  case CLUB: {
319  if (xCurPos == CLUBX && yCurPos == CLUBY)
321  return;
322  }
323  case TAXI:
324  return;
325  }
326  }
327  }
Idx valFromPtr(const DiscreteVariable *pvar) const
Returns the current value of a given variable.
TaxiSimulationLandmarkX
Definition: taxiSimulator.h:52
LabelizedVariable * passengerDest__
LabelizedVariable * yPos__
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 * xPos__
LabelizedVariable * passengerPos__
+ 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 129 of file taxiSimulator.cpp.

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

129  {
130  Instantiation randy = AbstractSimulator::randomState_();
131  // Idx curFuelLevel = randy.valFromPtr(fuelLevel__);
132  // while(curFuelLevel > 12 || curFuelLevel < 5)
133  // curFuelLevel = (Idx)(((double)std::rand( ) / (double)RAND_MAX) *
134  // 7.0) + 5;
135  // randy.chgVal(fuelLevel__, curFuelLevel);
136 
137  // TaxiSimulationLandmark passPos = (TaxiSimulationLandmark)
138  // randy.valFromPtr(passengerPos__);
139  // TaxiSimulationLandmark passDest = (TaxiSimulationLandmark)
140  // randy.valFromPtr(passengerDest__);
141  // while( passPos == passDest || passPos == TAXI )
142  // passPos = (TaxiSimulationLandmark) (((double)std::rand( ) /
143  // (double)RAND_MAX) * 3.0);
144  // randy.chgVal(passengerPos__, passPos);
145 
146  return randy;
147  }
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 168 of file taxiSimulator.cpp.

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

168 { 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 83 of file abstractSimulator.h.

References gum::AbstractSimulator::reward().

83  {
84  endState_ = endState;
85  }
+ 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  {
73  currentState_ = initialState;
74  }
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 58 of file abstractSimulator.cpp.

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

58  {
59  bool hre = true;
60  while (hre) {
62  hre = hasReachEnd();
63  }
64  }
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 195 of file taxiSimulator.h.

◆ currentState_

Instantiation gum::AbstractSimulator::currentState_
inherited

Tha state in which the system currently is.

Definition at line 129 of file abstractSimulator.h.

◆ endState_

Instantiation gum::AbstractSimulator::endState_
inherited

Definition at line 129 of file abstractSimulator.h.

◆ fuelLevel__

LabelizedVariable* gum::TaxiSimulator::fuelLevel__
private

Definition at line 191 of file taxiSimulator.h.

◆ lastAction__

TaxiSimulationAction gum::TaxiSimulator::lastAction__
private

Definition at line 197 of file taxiSimulator.h.

◆ passengerDest__

LabelizedVariable* gum::TaxiSimulator::passengerDest__
private

Definition at line 190 of file taxiSimulator.h.

◆ passengerPos__

LabelizedVariable* gum::TaxiSimulator::passengerPos__
private

Definition at line 189 of file taxiSimulator.h.

◆ primeMap__

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

Definition at line 186 of file taxiSimulator.h.

◆ reward__

double gum::TaxiSimulator::reward__
private

Reward.

Definition at line 200 of file taxiSimulator.h.

◆ taxiActions__

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

Actions.

Definition at line 194 of file taxiSimulator.h.

◆ taxiVars__

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

Variables data structures.

Definition at line 185 of file taxiSimulator.h.

◆ xPos__

LabelizedVariable* gum::TaxiSimulator::xPos__
private

Definition at line 187 of file taxiSimulator.h.

◆ yPos__

LabelizedVariable* gum::TaxiSimulator::yPos__
private

Definition at line 188 of file taxiSimulator.h.


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