Struct GenericTransitionBatch

Source
pub struct GenericTransitionBatch<O, A>
where O: BatchBase, A: BatchBase,
{ pub obs: O, pub act: A, pub next_obs: O, pub reward: Vec<f32>, pub is_terminated: Vec<i8>, pub is_truncated: Vec<i8>, pub weight: Option<Vec<f32>>, pub ix_sample: Option<Vec<usize>>, }
Expand description

A generic structure representing transitions in reinforcement learning.

This structure efficiently manages reinforcement learning transitions (observations, actions, rewards, etc.). It also includes support for prioritized experience replay (PER).

§Type Parameters

  • O - Observation type, must implement BatchBase
  • A - Action type, must implement BatchBase

§Examples

let batch = GenericTransitionBatch::<Tensor, Tensor>::with_capacity(32);

Fields§

§obs: O

Current observations

§act: A

Selected actions

§next_obs: O

Next state observations

§reward: Vec<f32>

Transition rewards

§is_terminated: Vec<i8>

Episode termination flags

§is_truncated: Vec<i8>

Episode truncation flags

§weight: Option<Vec<f32>>

Weights for prioritized experience replay

§ix_sample: Option<Vec<usize>>

Indices of sampled transitions

Implementations§

Source§

impl<O, A> GenericTransitionBatch<O, A>
where O: BatchBase, A: BatchBase,

Source

pub fn with_capacity(capacity: usize) -> Self

Creates a new batch with the specified capacity.

§Arguments
  • capacity - Initial capacity of the batch
§Returns

A new GenericTransitionBatch instance

Trait Implementations§

Source§

impl<O, A> TransitionBatch for GenericTransitionBatch<O, A>
where O: BatchBase, A: BatchBase,

Source§

fn unpack( self, ) -> (Self::ObsBatch, Self::ActBatch, Self::ObsBatch, Vec<f32>, Vec<i8>, Vec<i8>, Option<Vec<usize>>, Option<Vec<f32>>)

Decomposes the batch into its individual components.

§Returns

A tuple containing the following elements:

  1. Observations
  2. Actions
  3. Next observations
  4. Rewards
  5. Termination flags
  6. Truncation flags
  7. Sample indices
  8. Weights
Source§

fn len(&self) -> usize

Returns the number of transitions in the batch.

Source§

fn obs(&self) -> &Self::ObsBatch

Returns a reference to the batch of observations.

Source§

fn act(&self) -> &Self::ActBatch

Returns a reference to the batch of actions.

Source§

type ObsBatch = O

The type used to store batches of observations. Read more
Source§

type ActBatch = A

The type used to store batches of actions. Read more

Auto Trait Implementations§

§

impl<O, A> Freeze for GenericTransitionBatch<O, A>
where O: Freeze, A: Freeze,

§

impl<O, A> RefUnwindSafe for GenericTransitionBatch<O, A>

§

impl<O, A> Send for GenericTransitionBatch<O, A>
where O: Send, A: Send,

§

impl<O, A> Sync for GenericTransitionBatch<O, A>
where O: Sync, A: Sync,

§

impl<O, A> Unpin for GenericTransitionBatch<O, A>
where O: Unpin, A: Unpin,

§

impl<O, A> UnwindSafe for GenericTransitionBatch<O, A>
where O: UnwindSafe, A: UnwindSafe,

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
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.

Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V