flatland.core.distance_map module#
- class flatland.core.distance_map.AgentSourceTargetDistanceMap(agents: List[EnvAgent], waypoint_init: Callable[[UnderlyingConfigurationType], UnderlyingWaypointType])[source]#
Bases:
ConfigurationDistanceMap[UnderlyingTransitionMapType,UnderlyingDistanceMapType,UnderlyingConfigurationType,UnderlyingWaypointType]Adds agent-handle (target_nr) aware querying on top of ConfigurationDistanceMap. get_agent_distance returns the minimum distance from a source configuration to any of a given agent’s target configurations; concrete subclasses provide the underlying per-agent storage via _set_agent_distance.
- get_shortest_paths(max_depth: int | None = None, agent_handle: int | None = None) Dict[int, List[UnderlyingWaypointType] | None][source]#
Computes the shortest path for each agent to its target and the action to be taken to do so. The paths are derived from a DistanceMap.
If there is no path (rail disconnected), the path is given as None. The agent state (moving or not) and its speed are not taken into account
- example:
agent_fixed_travel_paths = get_shortest_paths(env.distance_map, None, agent.handle) path = agent_fixed_travel_paths[agent.handle]
Parameters#
self : reference to the distance_map max_depth : max path length, if the shortest path is longer, it will be cut agent_handle : if set, the shortest path for agent.handle will be returned, otherwise for all agents
Returns#
Dict[int, Optional[List[UnderlyingWaypointType]]]