flatland.envs.rail_env_shortest_paths module#
- flatland.envs.rail_env_shortest_paths.get_k_shortest_paths(env: RailEnv, source_position: Tuple[int, int], source_direction: int, target_position=typing.Tuple[int, int], k: int = 1, debug=False, target_direction: int = None, rail: GridTransitionMap = None, cutoff: int = None) List[Tuple[Waypoint]][source]#
Computes the k shortest paths using modified Dijkstra following pseudo-code https://en.wikipedia.org/wiki/K_shortest_path_routing In contrast to the pseudo-code in wikipedia, we do not a allow for loopy paths.
Parameters#
env : RailEnv source_position: Tuple[int,int] source_direction: int target_position: Tuple[int,int] k : int
max number of shortest paths
- debug: bool
print debug statements
target_direction: Optional[Tuple[int,int]] cutoff : Optional[int]
do not consider paths longer than cutoff
Returns#
- List[Tuple[WalkingElement]]
We use tuples since we need the path elements to be hashable. We use a list of paths in order to keep the order of length.
- flatland.envs.rail_env_shortest_paths.visualize_distance_map(distance_map: DistanceMap, agent_handle: int = 0)[source]#