Pendulum Class Reference

Implementation of Pendulum task. More...

Classes

struct  Action
 Implementation of action of Pendulum. More...

 
class  State
 Implementation of state of Pendulum. More...

 

Public Member Functions

 Pendulum (const double maxAngularVelocity=8, const double maxTorque=2.0, const double dt=0.05)
 Construct a Pendulum instance using the given values. More...

 
double AngleNormalize (double theta) const
 This function calculates the normalized anlge for a particular theta. More...

 
State InitialSample () const
 Initial theta is randomly generated within [-pi, pi]. More...

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

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

 

Detailed Description

Implementation of Pendulum task.

The inverted pendulum swingup problem is a classic problem in the control literature. In this version of the problem, the pendulum starts in a random position, and the goal is to swing it up so it stays upright

Definition at line 30 of file pendulum.hpp.

Constructor & Destructor Documentation

◆ Pendulum()

Pendulum ( const double  maxAngularVelocity = 8,
const double  maxTorque = 2.0,
const double  dt = 0.05 
)
inline

Construct a Pendulum instance using the given values.

Parameters
maxAngularVelocityMaximum angular velocity.
maxTorqueMaximum torque.
dtThe differential value.

Definition at line 97 of file pendulum.hpp.

Member Function Documentation

◆ AngleNormalize()

double AngleNormalize ( double  theta) const
inline

This function calculates the normalized anlge for a particular theta.

Parameters
thetaThe un-normalized angle.

Definition at line 180 of file pendulum.hpp.

References M_PI.

Referenced by Pendulum::Sample().

◆ InitialSample()

State InitialSample ( ) const
inline

Initial theta is randomly generated within [-pi, pi].

Initial angular velocity is randomly generated within [-1, 1].

Returns
Initial state for each episode.

Definition at line 167 of file pendulum.hpp.

References Pendulum::State::AngularVelocity(), M_PI, mlpack::math::Random(), and Pendulum::State::Theta().

◆ Sample() [1/2]

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

Dynamics of Pendulum.

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

Parameters
stateThe current state.
actionThe current action.
nextStateThe next state.
Returns
reward, The reward for taking the action taken for current state.

Definition at line 114 of file pendulum.hpp.

References Pendulum::Action::action, Pendulum::AngleNormalize(), Pendulum::State::AngularVelocity(), M_PI, and Pendulum::State::Theta().

Referenced by Pendulum::Sample().

◆ Sample() [2/2]

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

Dynamics of Pendulum.

Get reward based on current state and current action

Parameters
stateThe current state.
actionThe current action.
Returns
reward, The reward.

Definition at line 155 of file pendulum.hpp.

References Pendulum::Sample().


The documentation for this class was generated from the following file:
  • src/mlpack/methods/reinforcement_learning/environment/pendulum.hpp