pub struct SimpleBandit { /* private fields */ }Expand description
Simple contextual bandit for testing PPO correctness.
§Snapshot semantics
clone_state / restore_state capture the current context and step
counter, so the next step(action) produces the same reward and
terminated flag it would have at snapshot time. The bandit’s internal
StdRng is not captured: the next state sampled inside step will
differ between the snapshotted run and the restored run, so the
observation returned by step is not reproduced bit-for-bit. The reward
for the action taken at the snapshot point is still deterministic.
Implementations§
Source§impl SimpleBandit
impl SimpleBandit
Trait Implementations§
Source§impl Debug for SimpleBandit
impl Debug for SimpleBandit
Source§impl Default for SimpleBandit
impl Default for SimpleBandit
Source§impl Environment for SimpleBandit
impl Environment for SimpleBandit
Source§type State = SimpleBanditState
type State = SimpleBanditState
Snapshot type for this env. For fully deterministic envs without
internal RNG, this is the complete env state and
restore_state
reproduces every subsequent step exactly. For envs that consume an
internal RNG (e.g. ball serve direction, food placement), the snapshot
captures the simulation step but not the RNG; see the env-level
documentation for which fields are preserved. Read moreSource§fn get_observation(&self) -> Vec<f32>
fn get_observation(&self) -> Vec<f32>
Get the current observation
Source§fn step(&mut self, action: i64) -> StepResult
fn step(&mut self, action: i64) -> StepResult
Step the environment with an action
Source§fn observation_space(&self) -> SpaceInfo
fn observation_space(&self) -> SpaceInfo
Get the observation space dimensions
Source§fn action_space(&self) -> SpaceInfo
fn action_space(&self) -> SpaceInfo
Get the action space dimensions
Source§fn clone_state(&self) -> SimpleBanditState
fn clone_state(&self) -> SimpleBanditState
Snapshot the current env state for later restoration. Read more
Source§fn restore_state(&mut self, state: &SimpleBanditState)
fn restore_state(&mut self, state: &SimpleBanditState)
Restore the env to a previously-snapshotted state. Read more
Auto Trait Implementations§
impl Freeze for SimpleBandit
impl RefUnwindSafe for SimpleBandit
impl Send for SimpleBandit
impl Sync for SimpleBandit
impl Unpin for SimpleBandit
impl UnsafeUnpin for SimpleBandit
impl UnwindSafe for SimpleBandit
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> 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