bloqade.lanes.arch.path.PathFinder
classPathFinder¶source
bloqade.lanes.arch.path.PathFinder
class PathFinder(spec: ArchSpec)Parameters
| Name | Type | Description |
|---|---|---|
spec | ArchSpec |
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
spec | ArchSpec | required | |
metrics | MoveMetricCalculator | field(init=False) | |
site_graph | nx.PyDiGraph | field(init=False, default_factory=(nx.PyDiGraph)) | Graph representing all sites and edges as lanes. |
physical_addresses | list[LocationAddress] | field(init=False, default_factory=list) | Map from graph node index to (zone_id, word_id, site_id) tuple. |
physical_address_map | dict[LocationAddress, int] | field(init=False, default_factory=dict) | Map from (zone_id, word_id, site_id) tuple to graph node index. |
end_points_cache | dict[LaneAddress, tuple[LocationAddress, LocationAddress]] | field(init=False, default_factory=dict) |
methodextract_lanes_from_path¶source
bloqade.lanes.arch.path.PathFinder.extract_lanes_from_path
def extract_lanes_from_path(path: list[int]) -> tuple[LaneAddress, ...]Given a path as node indices, extract the lane addresses.
Parameters
| Name | Type | Description |
|---|---|---|
path | list[int] |
Returns
tuple[LaneAddress, ...]
methodextract_locations_from_path¶source
bloqade.lanes.arch.path.PathFinder.extract_locations_from_path
Signature
def extract_locations_from_path(path: list[int]) -> tuple[LocationAddress, ...]Given a path as node indices, extract the location addresses.
Parameters
| Name | Type | Description |
|---|---|---|
path | list[int] |
Returns
tuple[LocationAddress, ...]
methodget_lane¶source
bloqade.lanes.arch.path.PathFinder.get_lane
Signature
def get_lane(start: LocationAddress, end: LocationAddress) -> LaneAddress | NoneGet the LaneAddress connecting two LocationAddress sites.
Parameters
| Name | Type | Description |
|---|---|---|
start | LocationAddress | |
end | LocationAddress |
Returns
LaneAddress | None
methodget_endpoints¶source
bloqade.lanes.arch.path.PathFinder.get_endpoints
def get_endpoints(lane: LaneAddress)Get the start and end LocationAddress for a given LaneAddress.
Parameters
| Name | Type | Description |
|---|---|---|
lane | LaneAddress |
methodfind_path¶source
bloqade.lanes.arch.path.PathFinder.find_path
Signature
def find_path(start: LocationAddress, end: LocationAddress, occupied: frozenset[LocationAddress] = frozenset(), path_heuristic: Callable[[tuple[LaneAddress, ...], tuple[LocationAddress, ...]], float] = lambda _, __: 0.0, edge_weight: Callable[[LaneAddress], float] | None = None) -> tuple[tuple[LaneAddress, ...], tuple[LocationAddress, ...]] | NoneFind a weighted shortest path from start to end.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
start | LocationAddress | required | The starting location. |
end | LocationAddress | required | The ending location. |
occupied | frozenset[LocationAddress] | frozenset() | Locations to exclude when searching for a path. If this excludes `start` or `end`, no path is returned. |
path_heuristic | Callable[[tuple[LaneAddress, ...], tuple[LocationAddress, ...]], float] | lambda _, __: 0.0 | A tie-breaker over candidate shortest paths, evaluated on the candidate location sequence. |
edge_weight | Callable[[LaneAddress], float] | None | None | Optional edge weight function used for shortest-path costs. Defaults to `Metrics.get_lane_duration_us` when not provided. |
Returns
(tuple[tuple[LaneAddress, ...], tuple[LocationAddress, ...]] | None, tuple[tuple[LaneAddress, ...], tuple[LocationAddress, ...]] | None)A tuple containing: - The selected path as `LaneAddress` values. - The same path as `LocationAddress` values (including start and end). Returns `None` when no valid path exists.