flatland.envs.timetable_generators module#

Timetable generators: Railway Undertaking (RU) / Eisenbahnverkehrsunternehmen (EVU).

class flatland.envs.timetable_generators.FileTimetableGenerator(filename: Path, load_from_package: bool | None = None)[source]#

Bases: object

generate(*args, **kwargs) Timetable[source]#
static save(filename: Path, tt: Timetable)[source]#
static wrap(timetable_generator: timetable_generator, tt_pkl: Path) timetable_generator[source]#
flatland.envs.timetable_generators.len_handle_none(v)[source]#
flatland.envs.timetable_generators.timetable_from_file(filename: Path, load_from_package: bool | None = None) timetable_generator[source]#

Loads timetable from env pickle file.

Parameters#

filename : Pickle file generated by RailEnvPersister.save()

Returns#

Tuple[List[Tuple[int,int]], List[Tuple[int,int]], List[Tuple[int,int]], List[float]]

initial positions, directions, targets speeds

flatland.envs.timetable_generators.timetable_generator(agents: List[EnvAgent], distance_map: DistanceMap, agents_hints: dict, np_random: RandomState | None = None) Timetable[source]#

Calculates earliest departure and latest arrival times for the agents This is the new addition in Flatland 3 Also calculates the max episodes steps based on the density of the timetable

inputs:

agents - List of all the agents rail_env.agents distance_map - Distance map of positions to targets of each agent in each direction agent_hints - Uses the number of cities np_random - RNG state for seeding

returns:

Timetable with the latest_arrivals, earliest_departures and max_episdode_steps

flatland.envs.timetable_generators.ttgen_flatland2(agents: List[EnvAgent], distance_map: DistanceMap, agents_hints: dict, np_random: RandomState | None = None) Timetable[source]#