Skip to main content

ActionSpace

Enum ActionSpace 

Source
pub enum ActionSpace {
    Discrete(usize),
    MultiDiscrete(Vec<usize>),
    Box {
        low: Vec<f32>,
        high: Vec<f32>,
        shape: Vec<usize>,
    },
}
Expand description

The actions of an environment (gymnax’s action_space).

Variants§

§

Discrete(usize)

Integers 0..n (I32).

§

MultiDiscrete(Vec<usize>)

Arrays of i32 of shape [nvec.len()], component k in 0..nvec[k] (Jumanji’s MultiDiscreteArray).

§

Box

Arrays of f32 of shape, each element between low and high (one bound per element, in row-major order).

Fields

§low: Vec<f32>

The lower bounds.

§high: Vec<f32>

The upper bounds.

§shape: Vec<usize>

The shape of an action.

Implementations§

Source§

impl ActionSpace

Source

pub fn uniform_box(low: f32, high: f32, shape: &[usize]) -> Self

A box with the same bounds for every element.

Source

pub fn num_actions(&self) -> usize

The number of discrete actions (0 for a box).

Source

pub fn num_joint_actions(&self) -> usize

The number of joint discrete actions (the size of a legal action mask): n, or the product of nvec; 0 for a box.

Source

pub fn mask_len(&self) -> usize

The size of a legal action mask: the number of joint actions, or 0 when there are more than MAX_MASK_ACTIONS (an environment with that many joint actions, such as Jumanji’s JobShop with 21^10, has no mask: crate::Environment::legal_action_mask gives None).

§Examples
use ruxla_env::ActionSpace;

assert_eq!(ActionSpace::MultiDiscrete(vec![40, 20]).mask_len(), 800);
assert_eq!(ActionSpace::MultiDiscrete(vec![21; 10]).mask_len(), 0);
Source

pub fn flat_len(&self) -> usize

The number of elements of an action in a flat buffer (1 for a discrete action).

Trait Implementations§

Source§

impl Clone for ActionSpace

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 Debug for ActionSpace

Source§

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

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

impl PartialEq for ActionSpace

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ActionSpace

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.