Skip to main content

AsyncPolicy

Struct AsyncPolicy 

Source
pub struct AsyncPolicy<B: Backend, P: Policy<B>> { /* private fields */ }
Expand description

An asynchronous policy using an inference server with autobatching.

Implementations§

Source§

impl<B, P> AsyncPolicy<B, P>

Source

pub fn new(autobatch_size: usize, inner_policy: P) -> Self

Create the policy.

§Arguments
  • autobatch_size - Number of observations to accumulate before running a pass of inference.
  • inner_policy - The policy used to take actions.
Source

pub fn increment_agents(&self, num: usize)

Increment the number of agents using the inference server.

Source

pub fn decrement_agents(&self, num: usize)

Decrement the number of agents using the inference server.

Trait Implementations§

Source§

impl<B: Clone + Backend, P: Clone + Policy<B>> Clone for AsyncPolicy<B, P>

Source§

fn clone(&self) -> AsyncPolicy<B, P>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<B, P> Policy<B> for AsyncPolicy<B, P>
where B: Backend, P: Policy<B> + Send + 'static,

Source§

type ActionContext = <P as Policy<B>>::ActionContext

Additional context on the policy’s decision.
Source§

type PolicyState = <P as Policy<B>>::PolicyState

The current parameterization of the policy.
Source§

type Observation = <P as Policy<B>>::Observation

The observation given as input to the policy.
Source§

type ActionDistribution = <P as Policy<B>>::ActionDistribution

The action distribution parameters defining how the action will be sampled.
Source§

type Action = <P as Policy<B>>::Action

The action.
Source§

fn forward(&mut self, states: Self::Observation) -> Self::ActionDistribution

Produces the action distribution from a batch of observations.
Source§

fn action( &mut self, states: Self::Observation, deterministic: bool, ) -> (Self::Action, Vec<Self::ActionContext>)

Gives the action from a batch of observations.
Source§

fn update(&mut self, update: Self::PolicyState)

Update the policy’s parameters.
Source§

fn state(&self) -> Self::PolicyState

Returns the current parameterization.
Source§

fn load_record( self, _record: <Self::PolicyState as PolicyState<B>>::Record, ) -> Self

Loads the policy parameters from a record.

Auto Trait Implementations§

§

impl<B, P> Freeze for AsyncPolicy<B, P>

§

impl<B, P> RefUnwindSafe for AsyncPolicy<B, P>

§

impl<B, P> Send for AsyncPolicy<B, P>
where <P as Policy<B>>::PolicyState: Send, <P as Policy<B>>::Observation: Send, <P as Policy<B>>::ActionDistribution: Send, <P as Policy<B>>::Action: Send, <P as Policy<B>>::ActionContext: Send,

§

impl<B, P> Sync for AsyncPolicy<B, P>
where <P as Policy<B>>::PolicyState: Send, <P as Policy<B>>::Observation: Send, <P as Policy<B>>::ActionDistribution: Send, <P as Policy<B>>::Action: Send, <P as Policy<B>>::ActionContext: Send,

§

impl<B, P> Unpin for AsyncPolicy<B, P>

§

impl<B, P> UnsafeUnpin for AsyncPolicy<B, P>

§

impl<B, P> UnwindSafe for AsyncPolicy<B, P>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.