aequilibrae.paths.PathResults#

class aequilibrae.paths.PathResults[source]#

Path computation result holder

>>> from aequilibrae.paths.results import PathResults

>>> project = create_example(project_path)
>>> project.network.build_graphs()

# Mode c is car in this project
>>> car_graph = project.network.graphs['c']

# minimize distance
>>> car_graph.set_graph('distance')

# If you want to compute skims
# It does increase path computation time substantially
>>> car_graph.set_skimming(['distance', 'free_flow_time'])

>>> res = PathResults()
>>> res.prepare(car_graph)
>>> res.compute_path(1, 17)

# Update all the outputs mentioned above for destination 9. Same origin: 1
>>> res.update_trace(9)

# clears all computation results
>>> res.reset()
__init__() None[source]#

Methods

__init__()

compute_path(origin, destination[, ...])

Computes the path between two nodes in the network.

get_heuristics()

Return the availiable heuristics.

prepare(graph)

Prepares the object with dimensions corresponding to the graph object

reset()

Resets object to prepared and pre-computation state

set_heuristic(heuristic)

Set the heuristics to be used in A*.

update_trace(destination)

Updates the path's nodes, links, skims and mileposts

compute_path(origin: int, destination: int, early_exit: bool = False, a_star: bool = False, heuristic: str | None = None) None[source]#

Computes the path between two nodes in the network.

A* heuristics are currently only valid distance cost fields.

Arguments:

origin (int): Origin for the path

destination (int): Destination for the path

early_exit (bool): Stop constructing the shortest path tree once the destination is found. Doing so may cause subsequent calls to update_trace to recompute the tree. Default is False.

a_star (bool): Whether or not to use A* over Dijkstra’s algorithm. When True, early_exit is always True. Default is False.

heuristic (str): Heuristic to use if a_star is enabled. Default is None.

get_heuristics() List[str][source]#

Return the availiable heuristics.

prepare(graph: Graph) None[source]#

Prepares the object with dimensions corresponding to the graph object

Arguments:

graph (Graph): Needs to have been set with number of centroids and list of skims (if any)

reset() None[source]#

Resets object to prepared and pre-computation state

set_heuristic(heuristic: str) None[source]#

Set the heuristics to be used in A*. Must be one of get_heuristics().

Arguments:

heuristic (str): Heuristic to use in A*.

update_trace(destination: int) None[source]#

Updates the path’s nodes, links, skims and mileposts

If the previously computed path had early_exit enabled, update_trace will check if the destination has already been found, if not the shortest path tree will be recomputed with the early_exit argument passed on.

If the previously computed path had a_star enabled, update_trace always recompute the path.

Arguments:

destination (int): ID of the node we are computing the path too