Implementation of Cart Pole task. More...
Classes | |
| class | Action |
| Implementation of action of Cart Pole. More... | |
| class | State |
| Implementation of the state of Cart Pole. More... | |
Public Member Functions | |
| CartPole (const size_t maxSteps=200, const double gravity=9.8, const double massCart=1.0, const double massPole=0.1, const double length=0.5, const double forceMag=10.0, const double tau=0.02, const double thetaThresholdRadians=12 *2 *3.1416/360, const double xThreshold=2.4, const double doneReward=1.0) | |
| Construct a Cart Pole instance using the given constants. More... | |
| State | InitialSample () |
| Initial state representation is randomly generated within [-0.05, 0.05]. More... | |
| bool | IsTerminal (const State &state) const |
| This function checks if the cart 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 Cart Pole instance. More... | |
| double | Sample (const State &state, const Action &action) |
| Dynamics of Cart Pole. More... | |
| size_t | StepsPerformed () const |
| Get the number of steps performed. More... | |
Implementation of Cart Pole task.
Definition at line 26 of file cart_pole.hpp.
|
inline |
Construct a Cart Pole instance using the given constants.
| maxSteps | The number of steps after which the episode terminates. If the value is 0, there is no limit. |
| gravity | The gravity constant. |
| massCart | The mass of the cart. |
| massPole | The mass of the pole. |
| length | The length of the pole. |
| forceMag | The magnitude of the applied force. |
| tau | The time interval. |
| thetaThresholdRadians | The maximum angle. |
| xThreshold | The maximum position. |
| doneReward | Reward recieved by agent on success. |
Definition at line 117 of file cart_pole.hpp.
|
inline |
Initial state representation is randomly generated within [-0.05, 0.05].
Definition at line 207 of file cart_pole.hpp.
References CartPole::State::State().
|
inline |
This function checks if the cart has reached the terminal state.
| state | The desired state. |
Definition at line 219 of file cart_pole.hpp.
References CartPole::State::Angle(), Log::Info, and CartPole::State::Position().
Referenced by CartPole::Sample().
|
inline |
Get the maximum number of steps allowed.
Definition at line 240 of file cart_pole.hpp.
|
inline |
Set the maximum number of steps allowed.
Definition at line 242 of file cart_pole.hpp.
Dynamics of Cart Pole instance.
Get reward and next state based on current state and current action.
| state | The current state. |
| action | The current action. |
| nextState | The next state. |
When done is false, it means that the cartpole has fallen down. For this case the reward is 1.0.
Definition at line 151 of file cart_pole.hpp.
References CartPole::Action::action, CartPole::State::Angle(), CartPole::State::AngularVelocity(), CartPole::IsTerminal(), CartPole::State::Position(), and CartPole::State::Velocity().
Referenced by CartPole::Sample().
Dynamics of Cart Pole.
Get reward based on current state and current action.
| state | The current state. |
| action | The current action. |
Definition at line 196 of file cart_pole.hpp.
References CartPole::Sample().
|
inline |
Get the number of steps performed.
Definition at line 237 of file cart_pole.hpp.