Struct Actor

Source
pub struct Actor<A, E, P, R>
where A: Agent<E, R> + Configurable + SyncModel + 'static, E: Env, P: StepProcessor<E>, R: ExperienceBufferBase<Item = P::Output> + ReplayBufferBase,
{ /* private fields */ }
Expand description

Generate transitions by running Agent in Env.

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[StepProcessor] end C-->|ReplayBufferBase::PushedItem|F[ReplayBufferProxy]

In Actor, an Agent runs on an Env and generates Step objects. These objects are processed with StepProcessor and sent to ReplayBufferProxy. The Agent in the Actor periodically synchronizes with the Agent in AsyncTrainer via SyncModel::ModelInfo.

See also the diagram in AsyncTrainer.

Implementations§

Source§

impl<A, E, P, R> Actor<A, E, P, R>
where A: Agent<E, R> + Configurable + SyncModel + 'static, E: Env, P: StepProcessor<E>, R: ExperienceBufferBase<Item = P::Output> + ReplayBufferBase,

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::Item>>, 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> Freeze for Actor<A, E, P, R>
where <A as Configurable>::Config: Freeze, <E as Env>::Config: Freeze, <P as StepProcessor<E>>::Config: Freeze,

§

impl<A, E, P, R> RefUnwindSafe for Actor<A, E, P, R>

§

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

§

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

§

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

§

impl<A, E, P, R> UnwindSafe for Actor<A, E, P, R>

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, 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, 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