Skip to main content

Experience

Struct Experience 

Source
pub struct Experience<O, A> {
    pub observation: O,
    pub action: A,
    pub reward: f64,
    pub next_observation: O,
    pub status: EpisodeStatus,
}
Expand description

A single transition: (s, a, r, s', status).

The fundamental unit of experience stored in replay buffers and used for agent updates. Corresponds to one (s, a, r, s’, done) tuple in classical RL literature, but with a richer status field that distinguishes natural termination from truncation.

Fields§

§observation: O

The observation at the start of this transition.

§action: A

The action taken.

§reward: f64

The scalar reward received.

§next_observation: O

The observation after taking the action.

§status: EpisodeStatus

Whether the episode ended and why.

Algorithms that bootstrap value estimates (DQN, PPO, SAC) must inspect this to handle terminal states correctly:

  • Terminated: bootstrap with zero value
  • Truncated: bootstrap with V(next_observation)
  • Continuing: bootstrap with V(next_observation)

Implementations§

Source§

impl<O, A> Experience<O, A>

Source

pub fn new( observation: O, action: A, reward: f64, next_observation: O, status: EpisodeStatus, ) -> Self

Source

pub fn is_done(&self) -> bool

Returns true if this transition ends an episode.

Source

pub fn bootstrap_mask(&self) -> f64

Returns the bootstrap mask: 1.0 if the episode continues or was truncated (i.e. the next state has non-zero value), 0.0 if terminated.

Multiply value estimates by this mask when computing TD targets: target = reward + gamma * bootstrap_mask() * V(next_obs)

Source

pub fn map_obs<O2>(self, f: impl Fn(O) -> O2) -> Experience<O2, A>

Map the observation to a different type.

Useful for observation-wrapping layers that preprocess before storage.

Source

pub fn map_action<A2>(self, f: impl Fn(A) -> A2) -> Experience<O, A2>

Map the action to a different type.

Trait Implementations§

Source§

impl<O: Clone, A: Clone> Clone for Experience<O, A>

Source§

fn clone(&self) -> Experience<O, A>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<O: Debug, A: Debug> Debug for Experience<O, A>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<O, A> UnsafeUnpin for Experience<O, A>
where O: UnsafeUnpin, A: UnsafeUnpin,

§

impl<O, A> UnwindSafe for Experience<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> 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.

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