aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
gum::AbstractSimulator Class Referenceabstract

<agrum/FMDP/simulation/abstractSimulator.h> More...

#include <abstractSimulator.h>

Inheritance diagram for gum::AbstractSimulator:
Collaboration diagram for gum::AbstractSimulator:

Public Member Functions

Constructors, Destructors.
 AbstractSimulator ()
 Default constructor.
virtual ~AbstractSimulator ()
 Default destructor.
Variables
virtual const DiscreteVariableprimeVar (const DiscreteVariable *mainVar)=0
 Iteration over the variables of the simulated probleme.
virtual SequenceIteratorSafe< const DiscreteVariable * > beginVariables ()=0
 Iteration over the variables of the simulated probleme.
virtual SequenceIteratorSafe< const DiscreteVariable * > endVariables ()=0
 Iteration over the variables of the simulated probleme.
Actions
virtual const std::string & actionName (Idx)=0
 Iteration over the variables of the simulated probleme.
virtual SequenceIteratorSafe< IdxbeginActions ()=0
 Iteration over the variables of the simulated probleme.
virtual SequenceIteratorSafe< IdxendActions ()=0
 Iteration over the variables of the simulated probleme.

Public Attributes

Instantiation currentState_
 Tha state in which the system currently is.
Instantiation endState_
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.
virtual bool hasReachEnd ()
 Tests if end state has been reached.
INLINE const InstantiationcurrentState ()
 Sets the intial statefrom which we begun the simulation.
virtual double reward ()=0
 Sets the intial statefrom which we begun the simulation.
virtual void perform (Idx)=0
 Sets the intial statefrom which we begun the simulation.
virtual Instantiation randomState_ ()
 Choses a random state as the first test for a run.

Detailed Description

<agrum/FMDP/simulation/abstractSimulator.h>

A class to simulate a reinforcement learning problem.

Definition at line 67 of file abstractSimulator.h.

Constructor & Destructor Documentation

◆ AbstractSimulator()

gum::AbstractSimulator::AbstractSimulator ( )

Default constructor.

Definition at line 65 of file abstractSimulator.cpp.

65 {
66 GUM_CONSTRUCTOR(AbstractSimulator);
67 ;
68 }
AbstractSimulator()
Default constructor.

References AbstractSimulator().

Referenced by AbstractSimulator(), gum::FMDPSimulator::FMDPSimulator(), gum::FMDPSimulator::FMDPSimulator(), gum::TaxiSimulator::TaxiSimulator(), and ~AbstractSimulator().

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

◆ ~AbstractSimulator()

gum::AbstractSimulator::~AbstractSimulator ( )
virtual

Default destructor.

Definition at line 73 of file abstractSimulator.cpp.

73 {
74 GUM_DESTRUCTOR(AbstractSimulator);
75 ;
76 }

References AbstractSimulator().

Here is the call graph for this function:

Member Function Documentation

◆ actionName()

virtual const std::string & gum::AbstractSimulator::actionName ( Idx )
pure virtual

Iteration over the variables of the simulated probleme.

Implemented in gum::FactorySimulator, gum::FMDPSimulator, and gum::TaxiSimulator.

◆ beginActions()

virtual SequenceIteratorSafe< Idx > gum::AbstractSimulator::beginActions ( )
pure virtual

Iteration over the variables of the simulated probleme.

Implemented in gum::FactorySimulator, gum::FMDPSimulator, and gum::TaxiSimulator.

◆ beginVariables()

virtual SequenceIteratorSafe< const DiscreteVariable * > gum::AbstractSimulator::beginVariables ( )
pure virtual

Iteration over the variables of the simulated probleme.

Implemented in gum::FactorySimulator, gum::FMDPSimulator, and gum::TaxiSimulator.

Referenced by randomState_().

Here is the caller graph for this function:

◆ currentState()

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

Sets the intial statefrom which we begun the simulation.

Definition at line 108 of file abstractSimulator.h.

108{ return currentState_; }
Instantiation currentState_
Tha state in which the system currently is.

References currentState_.

◆ endActions()

virtual SequenceIteratorSafe< Idx > gum::AbstractSimulator::endActions ( )
pure virtual

Iteration over the variables of the simulated probleme.

Implemented in gum::FactorySimulator, gum::FMDPSimulator, and gum::TaxiSimulator.

◆ endVariables()

virtual SequenceIteratorSafe< const DiscreteVariable * > gum::AbstractSimulator::endVariables ( )
pure virtual

Iteration over the variables of the simulated probleme.

Implemented in gum::FactorySimulator, gum::FMDPSimulator, and gum::TaxiSimulator.

Referenced by randomState_().

Here is the caller graph for this function:

◆ hasReachEnd()

bool gum::AbstractSimulator::hasReachEnd ( )
virtual

Tests if end state has been reached.

Reimplemented in gum::FactorySimulator, and gum::TaxiSimulator.

Definition at line 100 of file abstractSimulator.cpp.

100 {
101 if (endState_.empty()) return false;
102
103 for (auto varIter = endState_.variablesSequence().beginSafe();
104 varIter != endState_.variablesSequence().endSafe();
105 ++varIter)
106 if (endState_.val(**varIter) != currentState_.val(**varIter)) return false;
107 return true;
108 }

References currentState_, and endState_.

Referenced by setInitialStateRandomly().

Here is the caller graph for this function:

◆ perform()

virtual void gum::AbstractSimulator::perform ( Idx )
pure virtual

Sets the intial statefrom which we begun the simulation.

Implemented in gum::FactorySimulator, gum::FMDPSimulator, and gum::TaxiSimulator.

◆ primeVar()

virtual const DiscreteVariable * gum::AbstractSimulator::primeVar ( const DiscreteVariable * mainVar)
pure virtual

Iteration over the variables of the simulated probleme.

Implemented in gum::FactorySimulator, gum::FMDPSimulator, and gum::TaxiSimulator.

◆ randomState_()

Instantiation gum::AbstractSimulator::randomState_ ( )
protectedvirtual

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

Reimplemented in gum::FactorySimulator, and gum::TaxiSimulator.

Definition at line 90 of file abstractSimulator.cpp.

90 {
91 Instantiation retState;
92 for (auto varIter = this->beginVariables(); varIter != this->endVariables(); ++varIter) {
93 retState.add(**varIter);
94 retState.chgVal(**varIter, randomValue((*varIter)->domainSize()));
95 }
96 return retState;
97 }
virtual SequenceIteratorSafe< const DiscreteVariable * > endVariables()=0
Iteration over the variables of the simulated probleme.
virtual SequenceIteratorSafe< const DiscreteVariable * > beginVariables()=0
Iteration over the variables of the simulated probleme.
Idx randomValue(const Size max=2)
Returns a random Idx between 0 and max-1 included.

References gum::Instantiation::add(), beginVariables(), gum::Instantiation::chgVal(), endVariables(), and gum::randomValue().

Referenced by gum::TaxiSimulator::randomState_(), and setInitialStateRandomly().

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

◆ reward()

virtual double gum::AbstractSimulator::reward ( )
pure virtual

Sets the intial statefrom which we begun the simulation.

Implemented in gum::FactorySimulator, gum::FMDPSimulator, and gum::TaxiSimulator.

◆ setEndState()

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

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

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

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 Instantiation randomState_()
Choses a random state as the first test for a run.
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

◆ currentState_

◆ endState_

Instantiation gum::AbstractSimulator::endState_

Definition at line 146 of file abstractSimulator.h.

Referenced by hasReachEnd(), and setEndState().


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