flatland.trajectories.policy_runner module

flatland.trajectories.policy_runner module#

class flatland.trajectories.policy_runner.PolicyRunner[source]#

Bases: object

static create_from_policy(policy: Policy, data_dir: Path, env: RailEnv, snapshot_interval: int = 1, ep_id: str | None = None, callbacks: FlatlandCallbacks | None = None, tqdm_kwargs: dict | None = None, start_step: int = 0, end_step: int | None = None, fork_from_trajectory: Trajectory | None = None, no_save: bool = False) Trajectory[source]#

Creates trajectory by running submission (policy and obs builder).

Always backs up the actions and positions for steps executed in the tsvs. Can start from existing trajectory.

Parameters#

policyPolicy

the submission’s policy

data_dirPath

the path to write the trajectory to

env: RailEnv

directly inject env, skip env generation

snapshot_intervalint

interval to write pkl snapshots

ep_id: str

episode ID to store data under. If not provided, generate one.

callbacks: FlatlandCallbacks

callbacks to run during trajectory creation

tqdm_kwargs: dict

additional kwargs for tqdm

start_stepint

start evaluation from intermediate step incl. (requires snapshot to be present); take actions from start_step and first step executed is start_step + 1. Defaults to 0 with first elapsed step 1.

end_stepint

stop evaluation at intermediate step excl. Capped by env’s max_episode_steps

fork_from_trajectoryTrajectory

copy data from this trajectory up to start step and run policy from there on

Returns#

Trajectory