Skip to main content

Pendulum

Struct Pendulum 

Source
pub struct Pendulum;
Expand description

gymnax’s Pendulum (Pendulum-v1): swing up a pendulum and keep it upright by applying a torque, an action of shape [1] in [-max_torque, max_torque] (clipped as gymnax does).

It reproduces gymnax 1.0 with the same operations, so the same keys and actions give the same trajectories. gymnax computes the step on the action of shape [1] and squeezes the results; here the action is reshaped to a scalar first (the same values).

Trait Implementations§

Source§

impl Clone for Pendulum

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Pendulum

Source§

impl Debug for Pendulum

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Pendulum

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Environment for Pendulum

Source§

type State<B: Backend> = PendulumState<B>

The state of an episode.
Source§

type Params<B: Backend> = PendulumParams<B>

The parameters of the environment.
Source§

type Obs<B: Backend> = Array<B, f32>

An observation.
Source§

type Action<B: Backend> = Array<B, f32>

An action: I32<B> for discrete actions, Array<B, f32> for continuous ones.
Source§

fn name(&self) -> &str

The name, such as "CartPole-v1".
Source§

fn action_space(&self) -> ActionSpace

The actions (gymnax’s action_space).
Source§

fn default_params<B: Backend>(&self) -> PendulumParams<B>

The default parameters.
Source§

fn reset<B: Backend>( &self, key: Key<B>, _params: &PendulumParams<B>, ) -> (Array<B, f32>, PendulumState<B>)

Starts an episode (gymnax’s reset_env).
Source§

fn step_env<B: Backend>( &self, _key: Key<B>, s: &PendulumState<B>, action: Array<B, f32>, p: &PendulumParams<B>, ) -> Transition<B, PendulumState<B>, Array<B, f32>>

Advances an episode by one step, without resetting.
Source§

fn step_env_uses_key(&self) -> bool

Whether step_env uses its key (the default). An environment whose steps are deterministic returns false, so that step natively splits the key only when the episode ends and the reset needs it; the results are the same (testing::check_backends compares the native results with the traced ones, which always split).
Source§

fn is_truncated<B: Backend>( &self, s: &PendulumState<B>, p: &PendulumParams<B>, ) -> Bool<B>

Whether the episode reached its time limit.
Source§

fn num_actions(&self) -> usize

The number of discrete actions (0 for continuous actions).
Source§

fn legal_action_mask<B: Backend>( &self, state: &Self::State<B>, ) -> Option<Array<B, bool>>

The legal actions in state, for environments that have them (board games, Jumanji): a mask over the joint actions (shape [n], or nvec for multi-discrete actions); None (the default) if every action is legal. Tests and benchmarks take legal actions with choose_legal. Environments with more joint actions than MAX_MASK_ACTIONS have no mask (ActionSpace::mask_len is 0).
Source§

fn step<B: Backend>( &self, key: Key<B>, state: &Self::State<B>, action: Self::Action<B>, params: &Self::Params<B>, ) -> Step<B, Self::State<B>, Self::Obs<B>>

Advances an episode by one step and starts a new one if it ended, as gymnax’s Environment.step does: the key is split in two, both step_env and reset are computed, and the reset state and observation are selected where the episode ended. Natively, the reset is computed only when the episode ends (lax::select_with), with the same results.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.