Download presentation
Presentation is loading. Please wait.
1
2IMG15 Algorithms for Geographic Data
Fall Lecture 11: Route Planning
2
Navigation systems Main tasks:
positioning: locating the vehicle using GPS and/or dead reckoning with distance and heading sensors routing: determining a good route from a source to a destination guidance: providing visual and audio feedback on the route
3
Positioning GPS: works well, except in “urban canyons”
Urban canyons can give gross errors in position due to reflections from buildings Urban canyons can give loss of signal Especially problematic when driving out of parking garages
4
Positioning Dead reckoning: determine position from last known position using distance and heading sensors (relative position) Use map matching: the shape of the route taken and where it matches on the map, to correct dead reckoning
5
Guiding Top view, perspective view, overview
Schematic information on exit lanes Spoken directions largely an Human-Computer-Interaction issue Algorithms for automated map construction
6
Routing Routing = “shortest” path computation
Dijkstra’s algorithm solves the problem, so we can all go home now (after O(m + n log n) time for routing)? Can we do better?
7
Routing – Basic examples
Based on Dijkstra’s shortest path algorithm Many improvements to deal with huge networks Improvements use preprocessing
8
Routing – Basic examples
Based on Dijkstra’s shortest path algorithm Many improvements to deal with huge networks Improvements use preprocessing
9
Routing – Basic examples
Based on Dijkstra’s shortest path algorithm Many improvements to deal with huge networks Improvements use preprocessing Bidirectional search (from Bayreuth and from Erlangen)
10
Routing – Basic examples
Based on Dijkstra’s shortest path algorithm Many improvements to deal with huge networks Improvements use preprocessing Bidirectional search (from Bayreuth and from Erlangen)
11
Routing – Overview of techniques
Goal-directed A*, ALT: A* with landmarks and triangle inequality Arc Flags Separator-based Hierarchical Highway hierarchies Contraction hierarchies Bounded hop Transit node routing For public transit networks: time-expanded vs time-dependent
12
Recap: Dijkstra’s algorithm
Dijkstra’s algorithm takes O(m + n log n) time for a graph with n nodes and m edges 1 2 10 6 9 4 2 3 7 9 6 5 2
13
Recap: Dijkstra’s algorithm
Dijkstra’s algorithm takes O(m + n log n) time for a graph with n nodes and m edges 1 2 10 6 9 4 2 3 7 9 6 5 2
14
Recap: Dijkstra’s algorithm
Dijkstra’s algorithm takes O(m + n log n) time for a graph with n nodes and m edges 1 2 10 6 9 4 2 3 7 9 6 5 2
15
Recap: Dijkstra’s algorithm
Dijkstra’s algorithm takes O(m + n log n) time for a graph with n nodes and m edges 1 10 2 10 6 9 4 2 3 7 9 6 5 5 2
16
Recap: Dijkstra’s algorithm
Dijkstra’s algorithm takes O(m + n log n) time for a graph with n nodes and m edges 1 10 2 10 6 9 4 2 3 7 9 6 5 5 2
17
Recap: Dijkstra’s algorithm
Dijkstra’s algorithm takes O(m + n log n) time for a graph with n nodes and m edges 1 10 2 10 6 9 4 2 3 7 9 6 5 5 2
18
Recap: Dijkstra’s algorithm
Dijkstra’s algorithm takes O(m + n log n) time for a graph with n nodes and m edges 1 14 8 2 10 6 9 4 14 2 3 7 9 6 5 5 7 2
19
Recap: Dijkstra’s algorithm
Dijkstra’s algorithm takes O(m + n log n) time for a graph with n nodes and m edges 1 14 8 2 10 6 9 4 14 2 3 7 9 6 5 5 7 2
20
Recap: Dijkstra’s algorithm
Dijkstra’s algorithm takes O(m + n log n) time for a graph with n nodes and m edges 1 14 8 2 10 6 9 4 14 2 3 7 9 6 5 5 7 2
21
Recap: Dijkstra’s algorithm
Dijkstra’s algorithm takes O(m + n log n) time for a graph with n nodes and m edges 1 13 8 2 10 6 9 4 13 2 3 7 9 6 5 5 7 2
22
Recap: Dijkstra’s algorithm
Dijkstra’s algorithm takes O(m + n log n) time for a graph with n nodes and m edges 1 13 8 2 10 6 9 4 13 2 3 7 9 6 5 5 7 2
23
Recap: Dijkstra’s algorithm
Dijkstra’s algorithm takes O(m + n log n) time for a graph with n nodes and m edges 1 13 8 2 10 6 9 4 13 2 3 7 9 6 5 5 7 2
24
Recap: Dijkstra’s algorithm
Dijkstra’s algorithm takes O(m + n log n) time for a graph with n nodes and m edges 1 9 8 2 10 6 9 4 13 2 3 7 9 6 5 5 7 2
25
Recap: Dijkstra’s algorithm
Dijkstra’s algorithm takes O(m + n log n) time for a graph with n nodes and m edges 1 9 8 2 10 6 9 4 13 2 3 7 9 6 5 5 7 2
26
Recap: Dijkstra’s algorithm
Dijkstra’s algorithm takes O(m + n log n) time for a graph with n nodes and m edges 1 9 8 2 10 6 9 4 13 2 3 7 9 6 5 5 7 2
27
Recap: Dijkstra’s algorithm
Dijkstra’s algorithm takes O(m + n log n) time for a graph with n nodes and m edges 1 9 8 2 10 6 9 4 13 2 3 7 9 6 5 5 7 2
28
Recap: Dijkstra’s algorithm
Dijkstra’s algorithm takes O(m + n log n) time for a graph with n nodes and m edges 1 9 8 2 10 6 9 4 13 2 3 7 9 6 5 5 7 2
29
Recap: Dijkstra’s algorithm
Dijkstra’s algorithm takes O(m + n log n) time for a graph with n nodes and m edges 1 9 8 2 10 6 9 4 13 2 3 7 9 6 5 5 7 2
30
Recap: Dijkstra’s algorithm
Dijkstra’s algorithm takes O(m + n log n) time for a graph with n nodes and m edges 1 9 8 2 10 6 9 4 13 2 3 7 9 6 5 5 7 2
31
Recap: Dijkstra’s algorithm
Dijkstra’s algorithm takes O(m + n log n) time for a graph with n nodes and m edges shortest path tree 1 9 8 2 10 6 9 4 13 2 3 7 9 6 5 5 7 2
32
Recap: Dijkstra’s algorithm
Dijkstra’s algorithm takes O(m + n log n) time for a graph with n nodes and m edges Every node is handled only once Its outgoing edges are considered only then Considering an edge may lower the cost of its destination node In theory: nodes are stored by distance in a Fibonacci heap (it allows for a very efficient decrease-value operation) In practice: use binary heap or generalization e.g. 4-heap: O((m+n) log n) time Road networks have m = O(n), so it takes O(n log n) time
33
A* algorithm A* is a simple variant of Dijkstra's algorithm
Additionally: for each node u, a value h[u] that estimates dist(u, t), where t is the target h is often called the heuristic function of A* Difference to Dijkstra: value of a node u in the priority queue is not dist[u] but dist[u] + h[u] therefore, if h[u] = 0 for all u, then A* = Dijkstra Works if h is monotone ... later slide Best results when h[u] = dist(u, t) for all u then A* settles only the nodes on a shortest path
34
A* Example 2 2 2 10 1 10 1 1
35
A* Example h=1 h=3 2 2 h=0 2 h=5 h=7 10 h=6 1 10 1 1 h=7
36
A* Example h=1 h=3 2 2 h=0 2 h=5 h=7 10 0 +5 h=6 1 10 1 1 h=7
37
A* Example h=1 h=3 2 2 +3 2 h=0 2 h=5 h=7 10 h=6 1 10 1 1 +6 1 h=7
38
A* Example h=1 h=3 2 2 2 h=0 2 h=5 h=7 10 h=6 1 10 1 1 +6 1 h=7
39
A* Example h=1 h=3 2 4 +1 2 2 h=0 2 h=5 h=7 10 h=6 1 10 1 1 +6 1 h=7
40
A* Example h=1 h=3 2 4 2 2 h=0 2 h=5 h=7 10 h=6 1 10 1 1 +6 1 h=7
41
A* Example h=1 h=3 2 4 2 2 h=0 2 h=5 h=7 6 +0 10 h=6 1 10 1 1 +6 1 h=7
42
A* Example h=1 h=3 2 4 2 2 h=0 2 h=5 h=7 6 10 h=6 1 10 1 1 +6 1 h=7
43
A* algorithm — Conditions on h
The heuristic h must be monotone For each arc (u,v) it must hold: h(u) ≤ cost(u,v) + h(v) Informally: heuristic must obey the triangle inequality This also implies that h is admissible For each node u it must hold: h(u) ≤ dist(u, t) Informally: the heuristic must never overestimate How do we compute h?
44
A* algorithm — Two heuristics
Straight-line distance (also: as-the-crow-flies distance) Take h(u) = eucl(u, t) / vmax eucl(u,t) is the Euclidean distance from u to t vmax is the maximum speed Admissible and monotone because of triangle inequality Landmark heuristic Informally: for every node u, precompute distances to a set of pre-selected nodes, called landmarks How to obtain a heuristic function from that ... next slides
45
A* with landmarks Consider an arbitrary node ℓ and call it a landmark
Our SP distance function dist satisfies the triangle inequality: dist(u, v) ≤ dist(u, w) + dist(w, v) for all nodes u, v, w Then, in particular, for all landmarks ℓ and all nodes u, v Hence, for a landmark ℓ, a target node t, and any node u h(u) := max( dist(u,ℓ)–dist(t,ℓ) , dist(ℓ,t)–dist(ℓ,u) ) ≤ dist(u,t) For undirected graphs, dist(x,y) = dist(y,x) for all x,y and thus: h(u) := |dist(ℓ,u)–dist(ℓ,t)| ≤ dist(u,t) When is this a good bound? How many landmarks? Precomputation? How to select landmarks? dist(u,ℓ) ≤ dist(u,v)+dist(v,ℓ) dist(u,ℓ)–dist(v,ℓ) ≤ dist(u,v) dist(ℓ,v) ≤ dist(ℓ,u)+dist(u,v) dist(ℓ,v)–dist(ℓ,u) ≤ dist(u,v)
46
Landmark selection Two heuristics Random selection
Not bad, but suboptimal distribution Greedy farthest node selection Start with a random node, then iteratively add more In each iteration, pick the node u which maximizes minℓϵ L' dist(ℓ, u), where L' = nodes already selected intuitively: u is "farthest" from all nodes in L‘ How to compute u with minℓϵ L' dist(ℓ, u) for given L' ?
47
Arc flags — Basic idea 1/2 A B C D E F G H Precomputation
Divide the map into "compact" regions of about equal size For each arc, compute "direction signs" for each region We call these direction signs arc flags A B C D E F G H
48
Arc flags — Basic idea 2/2 H At query time
Determine the region containing the target node In Dijkstra's algorithm, outside of that region, consider only arcs with direction signs towards that region source (outside H) H target (inside H)
49
Arc flags H How to perform queries? How to precompute efficiently?
Properties of good partition? Space usage? source (outside H) H target (inside H)
50
Routing – Overview of techniques
Goal-directed A*, ALT: A* with landmarks and triangle inequality Arc Flags Separator-based Hierarchical Highway hierarchies Contraction hierarchies Bounded hop Transit node routing For public transit networks: time-expanded vs time-dependent
51
Hierarchical Approaches – Intuition
Basic intuition "Far away" from the source and target, consider only "important" roads ... the further away, the more important Let's look at the shortest path of some random queries on Google Maps, typically: close to source and target: mainly white (residential) roads a bit further away: mainly yellow (national) roads even further away: mainly orange (motorway) roads But not always true
52
Hierarchical Approaches – Heuristic
This intuition leads to the following heuristic Indeed consider the types / colors from the road, with an order between them, e.g. white < yellow < orange Have a radius for each color > white: ryellow , rorange Run a bi-directional Dijkstra, with the following constraints at distance ≥ ryellow from source and target, consider only roads of type ≥ yellow at distance ≥ rorange from source and target, consider only roads of type ≥ orange Note: this does not necessarily find the shortest path Still, heuristics of this kind were employed in navigation devices for a long time ... since no better algorithms were known
53
Highway Hierarchies Compute a level for each arc
Along with a radius for each level: r1, r2, r3, ... Similarly as for the heuristic, run bi-directional Dijkstra constraint now: at distance ≥ ri from the source and target, consider only arcs of level ≥ I Note: the basic idea is simple, but the (implementation) details are quite intricate, in particular hard to get the implementation error-free in practice
54
Contraction Hierarchies (CHs)
Compute a level for each node At query time again do a bidirectional Dijkstra in the Dijkstra from the source consider only arcs u,v where level(v) > level(u) ... so called upwards graph in the Dijkstra from the target, consider only arcs v,u with level(v) > level(u) ... so called downwards graph Intuitively, this is like a "continuous" version of highway hierarchies ... and significantly easier to implement
55
CHs – Precomputation Basic building block of CH precomputation: contracting a node Idea: take out a node, and add all necessary arcs such that all SP distances in the remaining graphs are preserved Formally, a node v is contracted as follows Let {u1,...,ul} be the incoming arcs, i.e. (ui, v) ϵ E Let {w1,...,wk} be the outgoing arcs, i.e. (v, wj) ϵ E For each pair {ui, wj}, if (ui, v, wj) is the only shortest path from ui to wj, add the shortcut arc (ui, wj) Then remove v and its adjacent arcs from the graph
56
Node Contraction Add a shortcut that replaces the original path
Remove the original nodes and edges All nodes except u will have a higher order than u (we contract them in node order) v w 7 u Node Contraction: delete a node u and add a shortcut to preserve shortest path distances between the remaining nodes. Shortcuts bypass node u and represent whole paths. 3 4
57
Witness witness: path shorter than potential shortcut
don‘t need to add shortcut if there is a witness any order works what is a good order for contracting? P x y 3 2 2 v w 7 u Path P witnesses that a path <v, u, w> is not the shortest path or not the only shortest path and allows to omit a shortcut. 3 4
58
Query - Idea Perform query on graph with shortcuts added
Points sorted by order of contraction Only relax edges to higher nodes Forward search from s Backward search from t We would like to find a path between a source node s and a target node t. We essentially run a modified version of Dijkstra in which we only relax edges leading to nodes higher than the current node. (2 small examples) Perform a forward search starting from s. Perform a backward search starting from t in which we follow the edges in reverse direction. Finally we combine the two results. t s
59
Query - Graphs Node order Graph G = (V, E)
All nodes, original edges and shortcuts Upward graph G↑ Downward graph G↓ 8 5 3 2 2 Node order 3 1 For the query algorithm we consider the graph containing all nodes and edges from the initial graph, and all added shortcut edges. For this graph we define two search graphs. The first graph is the upward graph, which contains all nodes in V and only the edges in E that go from a lower node to a higher node. (Illustrated in red) Next to that we have the downward graph, which also contains all nodes in V, however now only edges that go from a higher to a lower node. (Illustrated in cyan) 2
60
Query - Algorithm Run Dijkstra in G↑ from s
Shortest paths from s to any other node Run Dijkstra in G↓ from t Backwards Shortest paths from any node to t Combine paths from both searches The algorithm now works as follows: First we run dijkstra from s forwards in the upward graph. We now get the shortest paths in the upward graph from s to any other node. Then we run dijkstra from t backwards in the downward graph. This means we follow all the edges in the reverse direction. We now get the shortest paths in the downward graph from any node to t.
61
Query - Example Upward graph G↑ Downward graph G↓ ∞ 2 6 ∞ 8 ∞ ∞ 5 ∞ ∞
1 3 2 2 3 1 t ∞ 2 ∞ s Animation: Pick s and t First do upward graph: - initialization - relax outgoing edges of s - done Next downward graph: - init - relax incoming edges of t - relax incoming edges of next node One node is visited by both searches. Combine the paths, the length of the path is the sum of the distances found by both searches. ∞ ∞ Shortest Path with distance = 8
62
Routing – Overview of techniques
Goal-directed A*, ALT: A* with landmarks and triangle inequality Arc Flags Separator-based Hierarchical Highway hierarchies Contraction hierarchies Bounded hop Transit node routing For public transit networks: time-expanded vs time-dependent
63
Highways and other major roads; every shortest path in the original road network of at least 60 km will use a highway or other major road 60 km
64
Transit-Node Routing This relatively small set of nodes is called the set of transit nodes Furthermore, for every node, there are (typically) only few nodes that are the first transit nodes encountered when going far enough (access nodes) For the USA, the road network has 24 million nodes and 58 million edges Transit-node routing uses 10,000 transit nodes and for each node there are ~10 access nodes
65
Transit-Node Routing Store all distances between two transit nodes in a table For every node, store the distance to its ~10 access nodes in a table Use table look-up to determine shortest paths, if the distance between source and target is large enough for the source and target, get the access nodes and distances for every pair [access node of source, access node of target], determine a candidate path length by 3 table look-ups If the distance is small, just run Dijkstra bidirectional
67
V : nodes of the input graph T : transit nodes chosen access node
table/list nodes of V transit nodes i access nodes of i transit node table transit nodes
68
Transit-Node Routing Trade-off: many transit nodes: fast query time, large storage requirements, high preprocessing time few transit nodes: slower query time, smaller storage requirements, lower preprocessing time Reported (road network USA): query time: 5 – 63 s storage: 21 – 244 bytes/node preprocessing: 59 – 1200 minutes
69
Transit-Node Routing Need (for preprocessing): Need (at query time):
a way to choose transit-nodes a way to determine access nodes a way to compute the transit node table and access node table Need (at query time): a way to decide if a query is local ( use Dijkstra) or not ( use table look-up) a way to retrieve the shortest path itself
70
Choosing transit nodes
Use grid-based partition and use intersections of the network and the grid
71
Choosing transit nodes
Use grid-based partition and use intersections of the network and the grid Select nodes from Vinner based on whether they lie on some shortest path from a node in C to Vouter outer inner C
72
Choosing transit nodes
Consider every center square C Use 5 x 5 squares to define Vinner Use 9 x 9 squares to define Vouter Consider all paths from some node in C to some node in Vouter All nodes of Vinner on such a path will go in the set of transit nodes (eventually united over all C) Run Dijkstra from every node in C until all nodes in Vouter are settled
73
Choosing transit nodes
Given s and t, if they are more than 4 grid cells apart (horizontally or vertically), their shortest path must contain a transit node This provides an easy test for locality of any query (later, during query time)
74
Computing access nodes
For each transit node u, run Dijkstra until all shortest paths from u pass another transit node Every node v in the shortest path tree from u before another transit node is reached gets u as one of its access nodes u shortest path tree from u v
75
Computing the tables The access node table is automatically computed when the access nodes are determined Distances between “near” transit nodes are also computed transit node graph Dijkstra on the transit node graph gives the transit node table
76
Summary Navigation systems rely on positioning, routing, and guidance
Route planning relies on Dijkstra’s algorithm and techniques to speed up queries, like preprocessing using the transit nodes idea
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.