flatland.envs.schedule_generators module

Schedule generators (railway undertaking, “EVU”).

flatland.envs.schedule_generators.complex_schedule_generator(speed_ratio_map:Mapping[float, float]=None, seed:int=1) → Callable[[flatland.core.transition_map.GridTransitionMap, int, Union[Any, NoneType], Union[int, NoneType]], flatland.envs.schedule_utils.Schedule][source]

Generator used to generate the levels of Round 1 in the Flatland Challenge. It can only be used together with complex_rail_generator. It places agents at end and start points provided by the rail generator. It assigns speeds to the different agents according to the speed_ratio_map :param speed_ratio_map: Speed ratios of all agents. They are probabilities of all different speeds and have to

add up to 1.
Parameters:seed – Initiate random seed generator
Returns:
flatland.envs.schedule_generators.random_schedule_generator(speed_ratio_map:Union[Mapping[float, float], NoneType]=None, seed:int=1) → Callable[[flatland.core.transition_map.GridTransitionMap, int, Union[Any, NoneType], Union[int, NoneType]], flatland.envs.schedule_utils.Schedule][source]

Given a rail GridTransitionMap, return a random placement of agents (initial position, direction and target).

Parameters:
speed_ratio_map : Optional[Mapping[float, float]]

A map of speeds mapping to their ratio of appearance. The ratios must sum up to 1.

Returns:
Tuple[List[Tuple[int,int]], List[Tuple[int,int]], List[Tuple[int,int]], List[float]]

initial positions, directions, targets speeds

flatland.envs.schedule_generators.schedule_from_file(filename, load_from_package=None) → Callable[[flatland.core.transition_map.GridTransitionMap, int, Union[Any, NoneType], Union[int, NoneType]], flatland.envs.schedule_utils.Schedule][source]

Utility to load pickle file

Parameters:
input_file : Pickle file generated by env.save() or editor
Returns:
Tuple[List[Tuple[int,int]], List[Tuple[int,int]], List[Tuple[int,int]], List[float]]

initial positions, directions, targets speeds

flatland.envs.schedule_generators.sparse_schedule_generator(speed_ratio_map:Mapping[float, float]=None, seed:int=1) → Callable[[flatland.core.transition_map.GridTransitionMap, int, Union[Any, NoneType], Union[int, NoneType]], flatland.envs.schedule_utils.Schedule][source]

This is the schedule generator which is used for Round 2 of the Flatland challenge. It produces schedules to railway networks provided by sparse_rail_generator. :param speed_ratio_map: Speed ratios of all agents. They are probabilities of all different speeds and have to

add up to 1.
Parameters:seed – Initiate random seed generator
flatland.envs.schedule_generators.speed_initialization_helper(nb_agents:int, speed_ratio_map:Mapping[float, float]=None, seed:int=None, np_random:numpy.random.mtrand.RandomState=None) → List[float][source]
Parameters:
nb_agents : int

The number of agents to generate a speed for

speed_ratio_map : Mapping[float,float]

A map of speeds mappint to their ratio of appearance. The ratios must sum up to 1.

Returns:
List[float]

A list of size nb_agents of speeds with the corresponding probabilistic ratios.