Skip to content

simulo.Trainer

The training-orchestration contract — run, evaluate, and persist a training job.

A trainer owns the RL loop: it drives an environment, updates the policy, and reads/writes checkpoints. Structural mirror of simulo.core.trainer.Trainer.

Trainer.train(max_iterations: int) -> Dict[str, Any]

Run the training loop for up to max_iterations and return summary metrics.

The returned mapping includes at least the final iteration count and reward statistics (implementation-defined keys).

Trainer.evaluate(checkpoint: Optional[str] = ..., num_episodes: int = ...) -> Dict[str, Any]

Roll out the current (or checkpoint-loaded) policy without learning.

Returns evaluation metrics such as mean episode return over num_episodes episodes.

Trainer.save(path: str) -> None

Write the trainer’s full state (policy + optimizer) to path.

Trainer.load(path: str) -> None

Restore trainer state previously written by save().


Declared as:

@runtime_checkable
class TrainerProtocol(Protocol)