Skip to main content

OnPolicyAlgorithmHooks

Trait OnPolicyAlgorithmHooks 

Source
pub trait OnPolicyAlgorithmHooks {
    type A: Agent;
    type S: Sampler;

    // Required methods
    fn init_hook(
        &mut self,
        runtime: &mut OnPolicyRuntime<Self::A, Self::S>,
    ) -> HookResult;
    fn post_rollout_hook(
        &mut self,
        runtime: &mut OnPolicyRuntime<Self::A, Self::S>,
    ) -> HookResult;
    fn post_training_hook(
        &mut self,
        runtime: &mut OnPolicyRuntime<Self::A, Self::S>,
    ) -> HookResult;
    fn finish_training_hook(
        &mut self,
        runtime: &mut OnPolicyRuntime<Self::A, Self::S>,
    ) -> Result<(), Error>;
}
Expand description

Lifecycle hooks that control an OnPolicyAlgorithm training loop.

Required Associated Types§

Source

type A: Agent

Agent type controlled by the training loop.

Source

type S: Sampler

Sampler type controlled by the training loop.

Required Methods§

Source

fn init_hook( &mut self, runtime: &mut OnPolicyRuntime<Self::A, Self::S>, ) -> HookResult

Called once before rollout/training starts.

Source

fn post_rollout_hook( &mut self, runtime: &mut OnPolicyRuntime<Self::A, Self::S>, ) -> HookResult

Called after rollouts are collected and before agent learning.

Source

fn post_training_hook( &mut self, runtime: &mut OnPolicyRuntime<Self::A, Self::S>, ) -> HookResult

Called after the agent has learned from the latest rollouts.

Source

fn finish_training_hook( &mut self, runtime: &mut OnPolicyRuntime<Self::A, Self::S>, ) -> Result<(), Error>

Called once when the loop exits.

§Errors

Returns an error if end-of-training finalization fails.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§