2IMA20 Algorithms for Geographic Data Spring 2016 Lecture 11: - - PowerPoint PPT Presentation

2ima20 algorithms for geographic data
SMART_READER_LITE
LIVE PREVIEW

2IMA20 Algorithms for Geographic Data Spring 2016 Lecture 11: - - PowerPoint PPT Presentation

2IMA20 Algorithms for Geographic Data Spring 2016 Lecture 11: Route Planning Vehicle navigation systems Main tasks: positioning : locating the vehicle using GPS and/or dead reckoning with distance and heading sensors routing :


slide-1
SLIDE 1

2IMA20 Algorithms for Geographic Data

Spring 2016 Lecture 11: Route Planning

slide-2
SLIDE 2

Vehicle 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

slide-3
SLIDE 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

slide-4
SLIDE 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

slide-5
SLIDE 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

slide-6
SLIDE 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?

slide-7
SLIDE 7

Routing – Basic examples

 Based on Dijkstra’s shortest path algorithm  Many improvements to deal with huge networks  Improvements use preprocessing

slide-8
SLIDE 8

Routing – Basic examples

 Based on Dijkstra’s shortest path algorithm  Many improvements to deal with huge networks  Improvements use preprocessing

slide-9
SLIDE 9

Routing – Basic examples

Bidirectional search (from Bayreuth and from Erlangen)

 Based on Dijkstra’s shortest path algorithm  Many improvements to deal with huge networks  Improvements use preprocessing

slide-10
SLIDE 10

Routing – Basic examples

Bidirectional search (from Bayreuth and from Erlangen)

 Based on Dijkstra’s shortest path algorithm  Many improvements to deal with huge networks  Improvements use preprocessing

slide-11
SLIDE 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

slide-12
SLIDE 12

Recap: Dijkstra’s algorithm

 Dijkstra’s algorithm takes O(m + n log n) time for a graph

with n nodes and m edges

10 6 9 1 3 2 5 4 9 7 2 2 6

slide-13
SLIDE 13

Recap: Dijkstra’s algorithm

 Dijkstra’s algorithm takes O(m + n log n) time for a graph

with n nodes and m edges

10 6 9 1 3 2 5 4 9 7 2 2 6

∞ ∞ ∞ ∞ ∞

slide-14
SLIDE 14

Recap: Dijkstra’s algorithm

 Dijkstra’s algorithm takes O(m + n log n) time for a graph

with n nodes and m edges

10 6 9 1 3 2 5 4 9 7 2 2 6

∞ ∞ ∞ ∞ ∞

slide-15
SLIDE 15

Recap: Dijkstra’s algorithm

 Dijkstra’s algorithm takes O(m + n log n) time for a graph

with n nodes and m edges

10 6 9 1 3 2 5 4 9 7 2 2 6

∞ ∞ ∞

5 10

slide-16
SLIDE 16

Recap: Dijkstra’s algorithm

 Dijkstra’s algorithm takes O(m + n log n) time for a graph

with n nodes and m edges

10 6 9 1 3 2 5 4 9 7 2 2 6

∞ ∞ ∞

5 10

slide-17
SLIDE 17

Recap: Dijkstra’s algorithm

 Dijkstra’s algorithm takes O(m + n log n) time for a graph

with n nodes and m edges

10 6 9 1 3 2 5 4 9 7 2 2 6

∞ ∞ ∞

5 10

slide-18
SLIDE 18

Recap: Dijkstra’s algorithm

 Dijkstra’s algorithm takes O(m + n log n) time for a graph

with n nodes and m edges

10 6 9 1 3 2 5 4 9 7 2 2 6 5 8 14 7 14

slide-19
SLIDE 19

Recap: Dijkstra’s algorithm

 Dijkstra’s algorithm takes O(m + n log n) time for a graph

with n nodes and m edges

10 6 9 1 3 2 5 4 9 7 2 2 6 5 8 14 7 14

slide-20
SLIDE 20

Recap: Dijkstra’s algorithm

 Dijkstra’s algorithm takes O(m + n log n) time for a graph

with n nodes and m edges

10 6 9 1 3 2 5 4 9 7 2 2 6 5 8 14 7 14

slide-21
SLIDE 21

Recap: Dijkstra’s algorithm

 Dijkstra’s algorithm takes O(m + n log n) time for a graph

with n nodes and m edges

10 6 9 1 3 2 5 4 9 7 2 2 6 5 8 13 7 13

slide-22
SLIDE 22

Recap: Dijkstra’s algorithm

 Dijkstra’s algorithm takes O(m + n log n) time for a graph

with n nodes and m edges

10 6 9 1 3 2 5 4 9 7 2 2 6 5 8 13 7 13

slide-23
SLIDE 23

Recap: Dijkstra’s algorithm

 Dijkstra’s algorithm takes O(m + n log n) time for a graph

with n nodes and m edges

10 6 9 1 3 2 5 4 9 7 2 2 6 5 8 13 7 13

slide-24
SLIDE 24

Recap: Dijkstra’s algorithm

 Dijkstra’s algorithm takes O(m + n log n) time for a graph

with n nodes and m edges

10 6 9 1 3 2 5 4 9 7 2 2 6 5 8 9 7 13

slide-25
SLIDE 25

Recap: Dijkstra’s algorithm

 Dijkstra’s algorithm takes O(m + n log n) time for a graph

with n nodes and m edges

10 6 9 1 3 2 5 4 9 7 2 2 6 5 8 9 7 13

slide-26
SLIDE 26

Recap: Dijkstra’s algorithm

 Dijkstra’s algorithm takes O(m + n log n) time for a graph

with n nodes and m edges

10 6 9 1 3 2 5 4 9 7 2 2 6 5 8 9 7 13

slide-27
SLIDE 27

Recap: Dijkstra’s algorithm

 Dijkstra’s algorithm takes O(m + n log n) time for a graph

with n nodes and m edges

10 6 9 1 3 2 5 4 9 7 2 2 6 5 8 9 7 13

slide-28
SLIDE 28

Recap: Dijkstra’s algorithm

 Dijkstra’s algorithm takes O(m + n log n) time for a graph

with n nodes and m edges

10 6 9 1 3 2 5 4 9 7 2 2 6 5 8 9 7 13

slide-29
SLIDE 29

Recap: Dijkstra’s algorithm

 Dijkstra’s algorithm takes O(m + n log n) time for a graph

with n nodes and m edges

10 6 9 1 3 2 5 4 9 7 2 2 6 5 8 9 7 13

slide-30
SLIDE 30

Recap: Dijkstra’s algorithm

 Dijkstra’s algorithm takes O(m + n log n) time for a graph

with n nodes and m edges

10 6 9 1 3 2 5 4 9 7 2 2 6 5 8 9 7 13

slide-31
SLIDE 31

Recap: Dijkstra’s algorithm

 Dijkstra’s algorithm takes O(m + n log n) time for a graph

with n nodes and m edges

10 6 9 1 3 2 5 4 9 7 2 2 6 5 8 9 7 13 shortest path tree

slide-32
SLIDE 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

slide-33
SLIDE 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 admissable and monotone ... later slide  Best results when h[u] = dist(u, t) for all u  then A* settles only the nodes on a shortest path

slide-34
SLIDE 34

A* Example

2 2 1 1 2 10 10 1

slide-35
SLIDE 35

A* Example

2 2 1 1 2 10 10 1 h=0 h=1 h=3 h=5 h=7 h=7 h=6

slide-36
SLIDE 36

A* Example

2 2 1 1 2 10 10 1 h=0 h=1 h=3 h=5 h=7 h=7 h=6 0 +5

slide-37
SLIDE 37

A* Example

2 2 1 1 2 10 10 1 h=0 h=1 h=3 h=5 h=7 h=7 h=6 2 +3 1 +6

slide-38
SLIDE 38

A* Example

2 2 1 1 2 10 10 1 h=0 h=1 h=3 h=5 h=7 h=7 h=6 2 1 +6

slide-39
SLIDE 39

A* Example

2 2 1 1 2 10 10 1 h=0 h=1 h=3 h=5 h=7 h=7 h=6 2 1 +6 4 +1

slide-40
SLIDE 40

A* Example

2 2 1 1 2 10 10 1 h=0 h=1 h=3 h=5 h=7 h=7 h=6 2 1 +6 4

slide-41
SLIDE 41

A* Example

2 2 1 1 2 10 10 1 h=0 h=1 h=3 h=5 h=10 h=10 h=9 2 1 +6 4 6 +0

slide-42
SLIDE 42

A* Example

2 2 1 1 2 10 10 1 h=0 h=1 h=3 h=5 h=7 h=7 h=6 2 1 +6 4 6

slide-43
SLIDE 43

A* algorithm — Conditions on h

 The heuristic h must be admissable

 For each node u it must hold: h(u) ≤ dist(u, t)  Informally: the heuristic must never overestimate

 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

 How do we compute h?

slide-44
SLIDE 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

slide-45
SLIDE 45

 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?

A* with 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)

slide-46
SLIDE 46

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' ?

Landmark selection

slide-47
SLIDE 47

Arc flags — Basic idea 1/2

 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

slide-48
SLIDE 48

Arc flags — Basic idea 1/2

 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

H

source

(outside H)

target

(inside H)

slide-49
SLIDE 49

Arc flags

 How to perform queries?  How to precompute efficiently?  Properties of good partition?  Space usage?

H

source

(outside H)

target

(inside H)

slide-50
SLIDE 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

slide-51
SLIDE 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

slide-52
SLIDE 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:  Run a bi-directional Dijkstra, with the following constraints  at distance ≥ ryellow from source and target, consider only roads

  • f type ≥ yellow

 at distance ≥ rorange from source and target, consider only roads

  • f 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 algo's were known

ryellow, rorange

slide-53
SLIDE 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

slide-54
SLIDE 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

slide-55
SLIDE 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

slide-56
SLIDE 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 u 3 4 7

slide-57
SLIDE 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?

v w u 3 4 x y 2 3 2 7 P

slide-58
SLIDE 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

 

s t

slide-59
SLIDE 59

Query - Graphs

 Graph G = (V, E)  All nodes, original edges and shortcuts  Upward graph G↑  Downward graph G↓

2 2 2 3 3 5 8 1

Node

  • rder
slide-60
SLIDE 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

slide-61
SLIDE 61

2

Query - Example

2 2 2 3 3 5 8 s t ∞ ∞ ∞ ∞ ∞ ∞ ∞ ∞ ∞ ∞ 1 1 6 Shortest Path with distance 2 + 6 = 8

Upward graph G↑ Downward graph G↓

slide-62
SLIDE 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

slide-63
SLIDE 63

Highways and other major roads; every shortest path in the

  • riginal road network
  • f at least 60 km will

use a highway or

  • ther major road

60 km

slide-64
SLIDE 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

slide-65
SLIDE 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

slide-66
SLIDE 66
slide-67
SLIDE 67

V : nodes of the input graph T : transit nodes chosen

transit nodes transit nodes nodes of V i access nodes of i

transit node table access node table/list

slide-68
SLIDE 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

slide-69
SLIDE 69

Transit-Node Routing

 Need (for preprocessing):

 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)

  • r not ( use table look-up)

 a way to retrieve the shortest path itself

slide-70
SLIDE 70

Choosing transit nodes

 Use grid-based

partition and use intersections of the network and the grid

slide-71
SLIDE 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

  • n some shortest

path from a node in C to Vouter

C inner

  • uter
slide-72
SLIDE 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

slide-73
SLIDE 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)

slide-74
SLIDE 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 v shortest path tree from u

slide-75
SLIDE 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

slide-76
SLIDE 76

Summary

 Vehicle 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 Acknowledgement: based on slides by M.van Kreveld and H. Bast CH example: P.Denissen, R.Jacobs, J.Snoeren