Skip to main content

Agent

Trait Agent 

Source
pub trait Agent {
    type Tensor: R2lTensor;
    type Actor: Actor<Tensor = Self::Tensor> + Clone;

    // Required methods
    fn actor(&self) -> Self::Actor;
    fn learn<B: TrajectoryBatch<Self::Tensor>>(
        &mut self,
        buffers: &[B],
    ) -> Result<(), Error>;
    fn set_learning_rate(&mut self, learning_rate: f64);
}
Expand description

Trainable on-policy component that owns an actor and learns from rollouts.

Required Associated Types§

Source

type Tensor: R2lTensor

Tensor type shared with the sampler and rollout buffers.

Source

type Actor: Actor<Tensor = Self::Tensor> + Clone

Actor type used by samplers to collect new rollouts.

Required Methods§

Source

fn actor(&self) -> Self::Actor

Returns an actor snapshot for rollout collection.

Source

fn learn<B: TrajectoryBatch<Self::Tensor>>( &mut self, buffers: &[B], ) -> Result<(), Error>

Learns from a batch of trajectory containers.

§Errors

Returns an error if the agent update fails.

Source

fn set_learning_rate(&mut self, learning_rate: f64)

Sets the learning rate used by future updates.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§