pub struct ContinuousReplayBuffer { /* private fields */ }Expand description
Fixed-capacity FIFO replay buffer for off-policy continuous-action training.
Stores (obs, action, reward, next_obs, done) transitions with
continuous Vec<f32> actions of width action_dim, and supports uniform
random sampling via super::continuous_sampling::sample. The buffer is
allocated once at construction (vec![0.0; capacity * obs_dim] etc.); no
further allocations occur during push.
This is the continuous-action sibling of
ReplayBuffer; the discrete DQN buffer is
left untouched.
Implementations§
Source§impl ContinuousReplayBuffer
impl ContinuousReplayBuffer
Sourcepub fn new(capacity: usize, obs_dim: usize, action_dim: usize) -> Self
pub fn new(capacity: usize, obs_dim: usize, action_dim: usize) -> Self
Create a new continuous replay buffer with the given capacity, observation dimensionality, and action dimensionality.
§Arguments
capacity- Maximum number of transitions stored. Must be > 0.obs_dim- Length of one observation vector. Must be > 0.action_dim- Length of one action vector. Must be > 0.
§Panics
Panics if capacity == 0, obs_dim == 0, or action_dim == 0.
Sourcepub fn push(
&mut self,
obs: &[f32],
action: &[f32],
reward: f32,
next_obs: &[f32],
done: bool,
)
pub fn push( &mut self, obs: &[f32], action: &[f32], 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- Continuous action taken; must have lengthaction_dim.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,
next_obs.len() != obs_dim, or action.len() != action_dim.
Sourcepub fn action_dim(&self) -> usize
pub fn action_dim(&self) -> usize
Action dimension (length of one action slice).
Trait Implementations§
Source§impl Clone for ContinuousReplayBuffer
impl Clone for ContinuousReplayBuffer
Source§fn clone(&self) -> ContinuousReplayBuffer
fn clone(&self) -> ContinuousReplayBuffer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ContinuousReplayBuffer
impl RefUnwindSafe for ContinuousReplayBuffer
impl Send for ContinuousReplayBuffer
impl Sync for ContinuousReplayBuffer
impl Unpin for ContinuousReplayBuffer
impl UnsafeUnpin for ContinuousReplayBuffer
impl UnwindSafe for ContinuousReplayBuffer
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
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>
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>
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