Implementation of Pendulum task. More...
Classes | |
class | Action |
Implementation of action of Pendulum. More... | |
class | State |
Implementation of state of Pendulum. More... | |
Public Member Functions | |
Pendulum (const size_t maxSteps=200, const double maxAngularVelocity=8, const double maxTorque=2.0, const double dt=0.05, const double doneReward=0.0) | |
Construct a Pendulum instance using the given values. More... | |
double | AngleNormalize (double theta) const |
This function calculates the normalized angle for a particular theta. More... | |
State | InitialSample () |
Initial theta is randomly generated within [-pi, pi]. More... | |
bool | IsTerminal (const State &) const |
This function checks if the pendulum has reaches a 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 Pendulum. More... | |
double | Sample (const State &state, const Action &action) |
Dynamics of Pendulum. More... | |
size_t | StepsPerformed () const |
Get the number of steps performed. More... | |
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 31 of file pendulum.hpp.
|
inline |
Construct a Pendulum instance using the given values.
maxSteps | The number of steps after which the episode terminates. If the value is 0, there is no limit (Default: 200 steps). |
maxAngularVelocity | Maximum angular velocity. |
maxTorque | Maximum torque. |
dt | The differential value. |
doneReward | The reward recieved by the agent on success. |
Definition at line 118 of file pendulum.hpp.
|
inline |
This function calculates the normalized angle for a particular theta.
theta | The un-normalized angle. |
Definition at line 212 of file pendulum.hpp.
References M_PI.
Referenced by Pendulum::Sample().
|
inline |
Initial theta is randomly generated within [-pi, pi].
Initial angular velocity is randomly generated within [-1, 1].
Definition at line 197 of file pendulum.hpp.
References Pendulum::State::AngularVelocity(), M_PI, mlpack::math::Random(), Pendulum::State::SetState(), and Pendulum::State::Theta().
|
inline |
This function checks if the pendulum has reaches a terminal state.
* | (state) desired state. |
Definition at line 227 of file pendulum.hpp.
References Log::Info.
|
inline |
Get the maximum number of steps allowed.
Definition at line 242 of file pendulum.hpp.
|
inline |
Set the maximum number of steps allowed.
Definition at line 244 of file pendulum.hpp.
Dynamics of Pendulum.
Get reward and next state based on current state and current action.
state | The current state. |
action | The current action. |
nextState | The next state. |
Definition at line 140 of file pendulum.hpp.
References Pendulum::Action::action, Pendulum::AngleNormalize(), Pendulum::State::AngularVelocity(), mlpack::math::ClampRange(), M_PI, Pendulum::State::SetState(), and Pendulum::State::Theta().
Referenced by Pendulum::Sample().
Dynamics of Pendulum.
Get reward based on current state and current action
state | The current state. |
action | The current action. |
Definition at line 185 of file pendulum.hpp.
References Pendulum::Sample().
|
inline |
Get the number of steps performed.
Definition at line 239 of file pendulum.hpp.