pub struct ReplayBuffer { /* private fields */ }Expand description
Fixed-capacity FIFO replay buffer for off-policy training.
Stores (obs, action, reward, next_obs, done) transitions and supports
uniform random sampling via sampling::sample. The buffer is allocated
once at construction (vec![0.0; capacity * obs_dim] etc.); no further
allocations occur during push.
Implementations§
Source§impl ReplayBuffer
impl ReplayBuffer
Sourcepub fn push(
&mut self,
obs: &[f32],
action: i64,
reward: f32,
next_obs: &[f32],
done: bool,
)
pub fn push( &mut self, obs: &[f32], action: i64, reward: f32, next_obs: &[f32], done: bool, )
Push a single transition into the buffer.
When the buffer is at capacity, this overwrites the oldest transition (FIFO eviction).
§Arguments
obs- Current observation; must have lengthobs_dim.action- Discrete action taken.reward- Reward received.next_obs- Resulting observation; must have lengthobs_dim.done-trueif the episode terminated (used to mask the bootstrap term in the TD target).
§Panics
Panics in debug builds if obs.len() != obs_dim or
next_obs.len() != obs_dim.
Trait Implementations§
Source§impl Clone for ReplayBuffer
impl Clone for ReplayBuffer
Source§fn clone(&self) -> ReplayBuffer
fn clone(&self) -> ReplayBuffer
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ReplayBuffer
impl RefUnwindSafe for ReplayBuffer
impl Send for ReplayBuffer
impl Sync for ReplayBuffer
impl Unpin for ReplayBuffer
impl UnsafeUnpin for ReplayBuffer
impl UnwindSafe for ReplayBuffer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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