MountainCar Class Reference

Implementation of Mountain Car task. More...

Classes

class  Action
 Implementation of action of Mountain Car. More...

 
class  State
 Implementation of state of Mountain Car. More...

 

Public Member Functions

 MountainCar (const size_t maxSteps=200, const double positionMin=-1.2, const double positionMax=0.6, const double positionGoal=0.5, const double velocityMin=-0.07, const double velocityMax=0.07, const double doneReward=0)
 Construct a Mountain Car instance using the given constant. More...

 
State InitialSample ()
 Initial position is randomly generated within [-0.6, -0.4]. More...

 
bool IsTerminal (const State &state) const
 This function checks if the car has reached the terminal state. More...

 
size_t MaxSteps () const
 Get the maximum number of steps allowed. More...

 
size_t & MaxSteps ()
 Set the maximum number of steps allowed. More...

 
double Sample (const State &state, const Action &action, State &nextState)
 Dynamics of Mountain Car. More...

 
double Sample (const State &state, const Action &action)
 Dynamics of Mountain Car. More...

 
size_t StepsPerformed () const
 Get the number of steps performed. More...

 

Detailed Description

Implementation of Mountain Car task.

Definition at line 28 of file mountain_car.hpp.

Constructor & Destructor Documentation

◆ MountainCar()

MountainCar ( const size_t  maxSteps = 200,
const double  positionMin = -1.2,
const double  positionMax = 0.6,
const double  positionGoal = 0.5,
const double  velocityMin = -0.07,
const double  velocityMax = 0.07,
const double  doneReward = 0 
)
inline

Construct a Mountain Car instance using the given constant.

Parameters
maxStepsThe number of steps after which the episode terminates. If the value is 0, there is no limit.
positionMinMinimum legal position.
positionMaxMaximum legal position.
positionGoalFinal target position.
velocityMinMinimum legal velocity.
velocityMaxMaximum legal velocity.
doneRewardThe reward recieved by the agent on success.

Definition at line 107 of file mountain_car.hpp.

Member Function Documentation

◆ InitialSample()

State InitialSample ( )
inline

Initial position is randomly generated within [-0.6, -0.4].

Initial velocity is 0.

Returns
Initial state for each episode.

Definition at line 187 of file mountain_car.hpp.

References MountainCar::State::Position(), and MountainCar::State::Velocity().

◆ IsTerminal()

bool IsTerminal ( const State state) const
inline

This function checks if the car has reached the terminal state.

Parameters
statedesired state.
Returns
true if state is a terminal state, otherwise false.

Definition at line 202 of file mountain_car.hpp.

References Log::Info, and MountainCar::State::Position().

Referenced by MountainCar::Sample().

◆ MaxSteps() [1/2]

size_t MaxSteps ( ) const
inline

Get the maximum number of steps allowed.

Definition at line 222 of file mountain_car.hpp.

◆ MaxSteps() [2/2]

size_t& MaxSteps ( )
inline

Set the maximum number of steps allowed.

Definition at line 224 of file mountain_car.hpp.

◆ Sample() [1/2]

double Sample ( const State state,
const Action action,
State nextState 
)
inline

Dynamics of Mountain Car.

Get reward and next state based on current state and current action.

Parameters
stateThe current state.
actionThe current action.
nextStateThe next state.
Returns
reward, it's always -1.0.

Definition at line 133 of file mountain_car.hpp.

References MountainCar::Action::action, mlpack::math::ClampRange(), MountainCar::IsTerminal(), MountainCar::State::Position(), and MountainCar::State::Velocity().

Referenced by MountainCar::Sample().

◆ Sample() [2/2]

double Sample ( const State state,
const Action action 
)
inline

Dynamics of Mountain Car.

Get reward based on current state and current action.

Parameters
stateThe current state.
actionThe current action.
Returns
reward, it's always -1.0.

Definition at line 175 of file mountain_car.hpp.

References MountainCar::Sample().

◆ StepsPerformed()

size_t StepsPerformed ( ) const
inline

Get the number of steps performed.

Definition at line 219 of file mountain_car.hpp.


The documentation for this class was generated from the following file:
  • /home/jenkins-mlpack/mlpack.org/_src/mlpack-git/src/mlpack/methods/reinforcement_learning/environment/mountain_car.hpp