Implementation of Cart Pole task.
More...
#include <cart_pole.hpp>
|
| | 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...
|
| |
| 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...
|
| |
| 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 | StepsPerformed () const |
| | Get the number of steps performed.
|
| |
|
size_t | MaxSteps () const |
| | Get the maximum number of steps allowed.
|
| |
|
size_t & | MaxSteps () |
| | Set the maximum number of steps allowed.
|
| |
Implementation of Cart Pole task.
◆ CartPole()
| mlpack::rl::CartPole::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 |
|
) |
| |
|
inline |
Construct a Cart Pole instance using the given constants.
- Parameters
-
| 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. |
◆ InitialSample()
| State mlpack::rl::CartPole::InitialSample |
( |
| ) |
|
|
inline |
Initial state representation is randomly generated within [-0.05, 0.05].
- Returns
- Initial state for each episode.
◆ IsTerminal()
| bool mlpack::rl::CartPole::IsTerminal |
( |
const State & |
state | ) |
const |
|
inline |
This function checks if the cart has reached the terminal state.
- Parameters
-
- Returns
- true if state is a terminal state, otherwise false.
◆ Sample() [1/2]
| double mlpack::rl::CartPole::Sample |
( |
const State & |
state, |
|
|
const Action & |
action, |
|
|
State & |
nextState |
|
) |
| |
|
inline |
Dynamics of Cart Pole instance.
Get reward and next state based on current state and current action.
- Parameters
-
| state | The current state. |
| action | The current action. |
| nextState | The next state. |
- Returns
- reward, it's always 1.0.
When done is false, it means that the cartpole has fallen down. For this case the reward is 1.0.
◆ Sample() [2/2]
| double mlpack::rl::CartPole::Sample |
( |
const State & |
state, |
|
|
const Action & |
action |
|
) |
| |
|
inline |
Dynamics of Cart Pole.
Get reward based on current state and current action.
- Parameters
-
| state | The current state. |
| action | The current action. |
- Returns
- reward, it's always 1.0.
The documentation for this class was generated from the following file:
- src/mlpack/methods/reinforcement_learning/environment/cart_pole.hpp