HERBuffer

Struct HERBuffer 

Source
pub struct HERBuffer { /* private fields */ }
Expand description

Hindsight Experience Replay buffer.

Stores transitions with goal information and performs goal relabeling during sampling. The obs vector layout is: [obs_core | achieved_goal | desired_goal | ...]

Implementations§

Source§

impl HERBuffer

Source

pub fn new( capacity: usize, obs_dim: usize, act_dim: usize, goal_dim: usize, achieved_goal_start: usize, desired_goal_start: usize, strategy: HERStrategy, goal_tolerance: f32, ) -> Self

Create a new HER buffer.

§Arguments
  • capacity - maximum transitions
  • obs_dim - full observation dimension (includes goal components)
  • act_dim - action dimension
  • goal_dim - goal vector dimension
  • achieved_goal_start - index within obs where achieved goal starts
  • desired_goal_start - index within obs where desired goal starts
  • strategy - relabeling strategy
  • goal_tolerance - tolerance for sparse reward computation
Source

pub fn push_slices( &mut self, obs: &[f32], next_obs: &[f32], action: &[f32], reward: f32, terminated: bool, truncated: bool, ) -> Result<(), RloxError>

Push a single transition, notifying the episode tracker.

Source

pub fn sample_with_relabeling( &self, batch_size: usize, her_ratio: f32, seed: u64, ) -> Result<SampledBatch, RloxError>

Sample a batch with HER relabeling.

her_ratio controls the fraction of samples that get relabeled goals. The remaining samples use their original goals.

Source

pub fn compute_relabel_indices( &self, episode: &EpisodeMeta, transition_offset: usize, seed: u64, ) -> Vec<usize>

Compute relabeling indices for a given episode and transition.

Returns indices (offsets within the episode) to use as substitute goals.

Source

pub fn len(&self) -> usize

Number of valid transitions currently stored.

Source

pub fn is_empty(&self) -> bool

Whether the buffer is empty.

Source

pub fn num_complete_episodes(&self) -> usize

Number of complete episodes currently tracked.

Trait Implementations§

Source§

impl Debug for HERBuffer

Source§

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

Formats the value using the given formatter. Read more

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
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.
§

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

§

fn vzip(self) -> V