Skip to main content

SimpleBandit

Struct SimpleBandit 

Source
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

Source

pub fn new() -> Self

Create a new simple bandit environment

Trait Implementations§

Source§

impl Debug for SimpleBandit

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for SimpleBandit

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Environment for SimpleBandit

Source§

type Action = i64

Action type accepted by Environment::step. Read more
Source§

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 more
Source§

fn reset(&mut self)

Reset the environment and return initial observation
Source§

fn get_observation(&self) -> Vec<f32>

Get the current observation
Source§

fn step(&mut self, action: i64) -> StepResult

Step the environment with an action
Source§

fn observation_space(&self) -> SpaceInfo

Get the observation space dimensions
Source§

fn action_space(&self) -> SpaceInfo

Get the action space dimensions
Source§

fn render(&self) -> Vec<u8>

Render the current environment state
Source§

fn close(&mut self)

Close the environment
Source§

fn clone_state(&self) -> SimpleBanditState

Snapshot the current env state for later restoration. Read more
Source§

fn restore_state(&mut self, state: &SimpleBanditState)

Restore the env to a previously-snapshotted state. 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more