Skip to main content

Sampler

Trait Sampler 

Source
pub trait Sampler {
    type Tensor: R2lTensor;

    // Required methods
    fn collect_rollouts<A: Actor<Tensor = Self::Tensor> + Clone>(
        &mut self,
        actor: A,
    ) -> Result<(), Error>;
    fn trajectory_views(
        &mut self,
    ) -> impl AsRef<[TrajectoryView<'_, Self::Tensor>]>;

    // Provided method
    fn reset_all_envs(&mut self) -> Result<(), Error> { ... }
}
Expand description

Rollout collector used by an on-policy training loop.

Required Associated Types§

Source

type Tensor: R2lTensor

Tensor type stored in collected trajectories.

Required Methods§

Source

fn collect_rollouts<A: Actor<Tensor = Self::Tensor> + Clone>( &mut self, actor: A, ) -> Result<(), Error>

Collects rollout data using the provided actor.

§Errors

Returns an error if an environment operation fails during collection.

Source

fn trajectory_views(&mut self) -> impl AsRef<[TrajectoryView<'_, Self::Tensor>]>

Creates a view for the agents.

Provided Methods§

Source

fn reset_all_envs(&mut self) -> Result<(), Error>

Resets all environments managed by the sampler.

§Errors

Returns an error if an environment cannot be reset.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§