pub struct Actor<A, E, P, R>where
    A: Agent<E, R> + SyncModel,
    E: Env,
    P: StepProcessorBase<E>,
    R: ReplayBufferBase<PushedItem = P::Output>,{ /* private fields */ }
Expand description

Runs interaction between an Agent and an Env, then generates transitions.

flowchart TB E["Agent
(in AsyncTrainer)"]-->|SyncModel::ModelInfo|A subgraph D[Actor] A[Agent]-->|Env::Act|B[Env] B-->|Env::Obs|A B-->|Step<E: Env>|C[StepProcessorBase] end C-->|ReplayBufferBase::PushedItem|F[ReplayBufferProxy]

This diagram shows interaction of Agent, Env and StepProcessorBase, as shown in border_core::Trainer. However, this diagram also shows that The Agent in the Actor periodically synchronizes with the Agent in AsyncTrainer via SyncModel::ModelInfo, and the transitions generated by StepProcessorBase are sent to the ReplayBufferProxy.

See also the diagram in AsyncTrainer.

Implementations§

source§

impl<A, E, P, R> Actor<A, E, P, R>where A: Agent<E, R> + SyncModel, E: Env, P: StepProcessorBase<E>, R: ReplayBufferBase<PushedItem = P::Output>,

source

pub fn build( id: usize, agent_config: A::Config, env_config: E::Config, step_proc_config: P::Config, replay_buffer_config: ReplayBufferProxyConfig, stop: Arc<Mutex<bool>>, env_seed: i64, stats: Arc<Mutex<Option<ActorStat>>> ) -> Self

source

pub fn run( &mut self, sender: Sender<PushedItemMessage<R::PushedItem>>, model_info: Arc<Mutex<(usize, A::ModelInfo)>>, guard: Arc<Mutex<bool>>, guard_init_model: Arc<Mutex<bool>> )

Runs sampling loop until self.stop becomes true.

When finishes, this method sets ActorStat.

Auto Trait Implementations§

§

impl<A, E, P, R> RefUnwindSafe for Actor<A, E, P, R>where A: RefUnwindSafe, E: RefUnwindSafe, P: RefUnwindSafe, R: RefUnwindSafe, <A as Policy<E>>::Config: RefUnwindSafe, <E as Env>::Config: RefUnwindSafe, <P as StepProcessorBase<E>>::Config: RefUnwindSafe,

§

impl<A, E, P, R> Send for Actor<A, E, P, R>where A: Send, E: Send, P: Send, R: Send, <A as Policy<E>>::Config: Send, <E as Env>::Config: Send, <P as StepProcessorBase<E>>::Config: Send,

§

impl<A, E, P, R> Sync for Actor<A, E, P, R>where A: Sync, E: Sync, P: Sync, R: Sync, <A as Policy<E>>::Config: Sync, <E as Env>::Config: Sync, <P as StepProcessorBase<E>>::Config: Sync,

§

impl<A, E, P, R> Unpin for Actor<A, E, P, R>where A: Unpin, E: Unpin, P: Unpin, R: Unpin, <A as Policy<E>>::Config: Unpin, <E as Env>::Config: Unpin, <P as StepProcessorBase<E>>::Config: Unpin,

§

impl<A, E, P, R> UnwindSafe for Actor<A, E, P, R>where A: UnwindSafe, E: UnwindSafe, P: UnwindSafe, R: UnwindSafe, <A as Policy<E>>::Config: UnwindSafe, <E as Env>::Config: UnwindSafe, <P as StepProcessorBase<E>>::Config: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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, U> Into<U> for Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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

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

§

fn vzip(self) -> V