• Keine Ergebnisse gefunden

TRANSIT Ultrafast Shortest-Path Queries with Linear-Time Preprocessing

N/A
N/A
Protected

Academic year: 2021

Aktie "TRANSIT Ultrafast Shortest-Path Queries with Linear-Time Preprocessing"

Copied!
67
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

TRANSIT

Ultrafast Shortest-Path Queries with Linear-Time Preprocessing

Ferienakademie im Sarntal — Course 2 Distance Problems: Theory and Praxis

Andreas Heider

Fakult¨at f¨ur Informatik TU M¨unchen

26. September 2010

(2)

Outline

1 Introduction

2 Transit Node Routing The key observation Formalization

Computing the Set of Transit Nodes Computing the Distance Tables Shortest-distance queries

Shortest-path queries (with edges) Local queries

Multi-Level Grid

3 Conclusions

(3)

Introduction

Overview

Goal

• Faster Shortest-Path Queries

• Application: Navigation Systems

Example

• US Road Network: 24 million nodes, 58 million edges

• Traditional Dijkstra too slow: worst case O (m + nlogn)

• Query time:

• Dijkstra: seconds

• Best other algorithms: milliseconds

• Do we really need even faster algorithms?

• Yes: Web services, Traffic simulation, etc.

(4)

Introduction

Overview

Goal

• Faster Shortest-Path Queries

• Application: Navigation Systems

Example

• US Road Network: 24 million nodes, 58 million edges

• Traditional Dijkstra too slow: worst case O (m + nlogn)

• Query time:

• Dijkstra: seconds

• Best other algorithms: milliseconds

• Do we really need even faster algorithms?

• Yes: Web services, Traffic simulation, etc.

(5)

Introduction

Overview

Goal

• Faster Shortest-Path Queries

• Application: Navigation Systems

Example

• US Road Network: 24 million nodes, 58 million edges

• Traditional Dijkstra too slow: worst case O (m + nlogn)

• Query time:

• Dijkstra: seconds

• Best other algorithms: milliseconds

• Do we really need even faster algorithms?

(6)

Introduction

Overview

Solution

• Split the work into a preprocessing step and fast queries

• Considerations: Query time, preprocessing time, space usage, etc.

Special properties of road networks

• Optimize for the special structure of the problem

• Nodes have a small degree (US road network: 2.4)

• There is a hierachy of more and more important roads

• The graph is relatively static

• Much more...

(7)

Introduction

Overview

Solution

• Split the work into a preprocessing step and fast queries

• Considerations: Query time, preprocessing time, space usage, etc.

Special properties of road networks

• Optimize for the special structure of the problem

• Nodes have a small degree (US road network: 2.4)

• There is a hierachy of more and more important roads

• The graph is relatively static

• Much more...

(8)

Transit Node Routing The key observation

The key observation

• When travelling far there are only a few points you will leave your neighborhood through

• Those will be called Transit Nodes

(9)

Transit Node Routing The key observation

Vierkirchen - Amsterdam

(10)

Transit Node Routing The key observation

Vierkirchen - Berlin

(11)

Transit Node Routing The key observation

Vierkirchen - Prague

(12)

Transit Node Routing The key observation

Vierkirchen - Amsterdam/Berlin

(13)

Transit Node Routing The key observation

Vierkirchen - Prague

(14)

Transit Node Routing The key observation

Altom¨ unster - Prague

(15)

Transit Node Routing The key observation

Haimhausen - Prague

(16)

Transit Node Routing The key observation

The key observation

• When travelling far there are only a few points you will leave your neighborhood through

• Those will be called Transit Nodes

Algorithm outline

• Precomputation step:

• For each neighborhood: find a set of Transit Nodes

• Calculate distance from each node to its neighborhoods Transit Nodes

• Run APSP (distances) between all Transit Nodes

• Shortest distance query: Find t1, t2 so that

dist(src , t1) + dist(t1, t2) + dist(t2, trg) is minimal

(17)

Transit Node Routing Formalization

Formalization

How to implement ‘far’

• Some metric is needed to determine wether a trip is far enough

• One possibility: Subdivide the map into a grid of cells

• A trip is long enough if the start and destination points are more than 4 cells apart

• To determine: best grid size

(18)

Transit Node Routing Formalization

Formalization

How to implement ‘far’

• Some metric is needed to determine wether a trip is far enough

• One possibility: Subdivide the map into a grid of cells

• A trip is long enough if the start and destination points are more than 4 cells apart

• To determine: best grid size

(19)

Transit Node Routing Formalization

Formalization

How to implement ‘far’

• Some metric is needed to determine wether a trip is far enough

• One possibility: Subdivide the map into a grid of cells

• A trip is long enough if the start and destination points are more than 4 cells apart

• To determine: best grid size

(20)

Transit Node Routing Computing the Set of Transit Nodes

Formalization

Definitions

• C: The cell for which we want to compute the Transit Nodes

• S

outer

: Square with C at it’s center, everything outside is ‘far away’

• S

inner

: Between C and S

outer

, all

Transit Nodes cross S

inner

(21)

Transit Node Routing Computing the Set of Transit Nodes

Formalization

Definitions

• C: The cell for which we want to compute the Transit Nodes

• S

outer

: Square with C at it’s center, everything outside is ‘far away’

• S

inner

: Between C and S

outer

, all

Transit Nodes cross S

inner

(22)

Transit Node Routing Computing the Set of Transit Nodes

Formalization

Definitions

• C: The cell for which we want to compute the Transit Nodes

• S

outer

: Square with C at it’s center, everything outside is ‘far away’

• S

inner

: Between C and S

outer

, all

Transit Nodes cross S

inner

(23)

Transit Node Routing Computing the Set of Transit Nodes

Formalization

Definitions

• E

C/inner/outer

: Edges that cross a square

• V

C/inner/outer

: For each edge in E: pick the node with the lower id

• All far trips starting inside C

always first pass a node in V

C

,

then V

inner

, then V

outer

(24)

Transit Node Routing Computing the Set of Transit Nodes

Formalization

Definitions

• E

C/inner/outer

: Edges that cross a square

• V

C/inner/outer

: For each edge in E: pick the node with the lower id

• All far trips starting inside C

always first pass a node in V

C

,

then V

inner

, then V

outer

(25)

Transit Node Routing Computing the Set of Transit Nodes

Formalization

Definitions

• E

C/inner/outer

: Edges that cross a square

• V

C/inner/outer

: For each edge in E: pick the node with the lower id

• All far trips starting inside C

always first pass a node in V

C

,

then V

inner

, then V

outer

(26)

Transit Node Routing Computing the Set of Transit Nodes

Naive approach

Computing the Transit Nodes

• For each cell: Compute all shortest paths between V

C

and V

outer

• Mark all nodes in V

inner

that lie on such a path, these are the Transit Nodes

• All paths starting inside V

C

and ending outside V

outer

will pass one of the Transit Nodes

• This requires a shortest paths

run with a radius of 5 cells

(27)

Transit Node Routing Computing the Set of Transit Nodes

Sweep-line algorithm

Sweep-line algorithm

• A line is moved across the whole grid

• All roads that cross the line get processed

• When the line reaches the other

end, the solution is available

(28)

Transit Node Routing Computing the Set of Transit Nodes

Sweep-line algorithm

Sweep-line algorithm

• A line is moved across the whole grid

• All roads that cross the line get processed

• When the line reaches the other

end, the solution is available

(29)

Transit Node Routing Computing the Set of Transit Nodes

Sweep-line algorithm

Sweep-line algorithm

• A line is moved across the whole grid

• All roads that cross the line get processed

• When the line reaches the other

end, the solution is available

(30)

Transit Node Routing Computing the Set of Transit Nodes

Sweep-line algorithm

Sweep-line algorithm

• A line is moved across the whole grid

• All roads that cross the line get processed

• When the line reaches the other

end, the solution is available

(31)

Transit Node Routing Computing the Set of Transit Nodes

Sweep-line algorithm

Sweep-line algorithm

• A line is moved across the whole grid

• All roads that cross the line get processed

• When the line reaches the other

end, the solution is available

(32)

Transit Node Routing Computing the Set of Transit Nodes

Sweep-line algorithm

Sweep-line algorithm

• A line is moved across the whole grid

• All roads that cross the line get processed

• When the line reaches the other

end, the solution is available

(33)

Transit Node Routing Computing the Set of Transit Nodes

Sweep-line algorithm

Sweep-line algorithm

• A line is moved across the whole grid

• All roads that cross the line get processed

• When the line reaches the other

end, the solution is available

(34)

Transit Node Routing Computing the Set of Transit Nodes

Sweep-line algorithm

Sweep-line algorithm

• A line is moved across the whole grid

• All roads that cross the line get processed

• When the line reaches the other

end, the solution is available

(35)

Transit Node Routing Computing the Set of Transit Nodes

Sweep-line algorithm

Sweep-line algorithm

• A line is moved across the whole grid

• All roads that cross the line get processed

• When the line reaches the other

end, the solution is available

(36)

Transit Node Routing Computing the Set of Transit Nodes

Sweep-line algorithm

Sweep-line algorithm

• A line is moved across the whole grid

• All roads that cross the line get processed

• When the line reaches the other

end, the solution is available

(37)

Transit Node Routing Computing the Set of Transit Nodes

Sweep-line algorithm

Sweep-line algorithm

• A line is moved across the whole grid

• All roads that cross the line get processed

• When the line reaches the other

end, the solution is available

(38)

Transit Node Routing Computing the Set of Transit Nodes

Sweep-line algorithm

Sweep-line algorithm

• A line is moved across the whole grid

• All roads that cross the line get processed

• When the line reaches the other

end, the solution is available

(39)

Transit Node Routing Computing the Set of Transit Nodes

Sweep-line algorithm

Sweep-line algorithm

• A line is moved across the whole grid

• All roads that cross the line get processed

• When the line reaches the other

end, the solution is available

(40)

Transit Node Routing Computing the Set of Transit Nodes

Sweep-line algorithm

Sweep-line algorithm

• A line is moved across the whole grid

• All roads that cross the line get processed

• When the line reaches the other

end, the solution is available

(41)

Transit Node Routing Computing the Set of Transit Nodes

Sweep-line algorithm

Sweep-line algorithm

• A line is moved across the whole grid

• All roads that cross the line get processed

• When the line reaches the other

end, the solution is available

(42)

Transit Node Routing Computing the Set of Transit Nodes

Sweep-line algorithm

Sweep-line algorithm

• A line is moved across the whole grid

• All roads that cross the line get processed

• When the line reaches the other

end, the solution is available

(43)

Transit Node Routing Computing the Set of Transit Nodes

Sweep-line algorithm

Sweep-line algorithm

• A line is moved across the whole grid

• All roads that cross the line get processed

• When the line reaches the other

end, the solution is available

(44)

Transit Node Routing Computing the Set of Transit Nodes

Sweep-line algorithm

Sweep-line algorithm

• A line is moved across the whole grid

• All roads that cross the line get processed

• When the line reaches the other

end, the solution is available

(45)

Transit Node Routing Computing the Set of Transit Nodes

Sweep-line algorithm

Sweep-line algorithm

• A line is moved across the whole grid

• All roads that cross the line get processed

• When the line reaches the other

end, the solution is available

(46)

Transit Node Routing Computing the Set of Transit Nodes

Sweep-line algorithm

Computing the Transit Nodes

• For all roads intersecting the sweep line:

• Choose one endpoint v

• C

left

, C

right

: Cells two grid units left/right

• Find all boundary nodes v

L

, v

R

on C

left

, C

right

• Run Dijkstra starting at v until we know the distance d (v , v

L/R

) for all boundary nodes

• To do this we mostly need to

look at nodes no more than 3

(47)

Transit Node Routing Computing the Set of Transit Nodes

Sweep-line algorithm

Computing the Transit Nodes

• We now know all d (v, v

L/R

)

• Look at all combinations of boundary nodes in (v

L

, v

R

) with a vertical distance of <= 4

• And determine v so that d (v

L

, v ) + d (v, v

R

) is minimal

• This v is a Transit Node for the cells containing v

L

and v

R

• After one horizontal and one

vertical sweep we computed

exactly the Transit Nodes as

defined before

(48)

Transit Node Routing Computing the Set of Transit Nodes

Sweep-line algorithm

Computing the Transit Nodes

• We now know all d (v, v

L/R

)

• Look at all combinations of boundary nodes in (v

L

, v

R

) with a vertical distance of <= 4

• And determine v so that d (v

L

, v ) + d (v, v

R

) is minimal

• This v is a Transit Node for the cells containing v

L

and v

R

• After one horizontal and one

vertical sweep we computed

exactly the Transit Nodes as

(49)

Transit Node Routing Computing the Distance Tables

Computing the Distance Tables

• For each node inside C : store the distance to all of C s Transit Nodes

• For each Transit Node: compute and the distance to all other Transit Nodes

• This is possible because only a few vertices are Transit Nodes

• Most cells only have about 10 Transit Nodes

• Transit Nodes are often shared between adjacent cells

• Ballpark figure: US road network using a 128x128 grid: 8000 Transit

Nodes

(50)

Transit Node Routing Computing the Distance Tables

Computing the Distance Tables

• For each node inside C : store the distance to all of C s Transit Nodes

• For each Transit Node: compute and the distance to all other Transit Nodes

• This is possible because only a few vertices are Transit Nodes

• Most cells only have about 10 Transit Nodes

• Transit Nodes are often shared between adjacent cells

• Ballpark figure: US road network using a 128x128 grid: 8000 Transit

Nodes

(51)

Transit Node Routing Shortest-distance queries

Shortest-distance queries

• Transit Nodes also work in reverse: Every ‘far’ trip entering a cell will do it through one of the Transit Nodes

• All ‘far’ trips can be split up into three parts:

src −transit

src

−transit

dest

−dest

• Try all possible combinations of transit nodes to find the

minimum of d (src, transit

src

) + d (transit

src

, transitdest) + d (transit

dest

, dest )

src tn

1

tn

0

tn

2

trg

tn

b

tn

a

(52)

Transit Node Routing Shortest-distance queries

Shortest-distance queries

• Transit Nodes also work in reverse: Every ‘far’ trip entering a cell will do it through one of the Transit Nodes

• All ‘far’ trips can be split up into three parts:

src −transit

src

−transit

dest

−dest

• Try all possible combinations of transit nodes to find the

minimum of d (src, transit

src

) + d (transit

src

, transitdest) + d (transit

dest

, dest )

src tn

1

tn

0

tn

2

trg

tn

b

tn

a

(53)

Transit Node Routing Shortest-distance queries

Shortest-distance queries

• Transit Nodes also work in reverse: Every ‘far’ trip entering a cell will do it through one of the Transit Nodes

• All ‘far’ trips can be split up into three parts:

src −transit

src

−transit

dest

−dest

• Try all possible combinations of transit nodes to find the

minimum of d (src, transit

src

) + d (transit

src

, transitdest) + d (transit

dest

, dest )

src tn

1

tn

0

tn

2

trg

tn

b

tn

a

(54)

Transit Node Routing Shortest-distance queries

Shortest-distance queries

• Transit Nodes also work in reverse: Every ‘far’ trip entering a cell will do it through one of the Transit Nodes

• All ‘far’ trips can be split up into three parts:

src −transit

src

−transit

dest

−dest

• Try all possible combinations of transit nodes to find the

minimum of d (src, transit

src

) + d (transit

src

, transitdest) + d (transit

dest

, dest )

src tn

1

tn

0

tn

2

trg

tn

b

tn

a

(55)

Transit Node Routing Shortest-distance queries

Shortest-distance queries

• Transit Nodes also work in reverse: Every ‘far’ trip entering a cell will do it through one of the Transit Nodes

• All ‘far’ trips can be split up into three parts:

src −transit

src

−transit

dest

−dest

• Try all possible combinations of transit nodes to find the

minimum of d (src, transit

src

) + d (transit

src

, transitdest) + d (transit

dest

, dest )

src tn

1

tn

0

tn

2

trg

tn

b

tn

a

(56)

Transit Node Routing Shortest-distance queries

Shortest-distance queries

• Transit Nodes also work in reverse: Every ‘far’ trip entering a cell will do it through one of the Transit Nodes

• All ‘far’ trips can be split up into three parts:

src −transit

src

−transit

dest

−dest

• Try all possible combinations of transit nodes to find the

minimum of d (src, transit

src

) + d (transit

src

, transitdest) + d (transit

dest

, dest )

src tn

1

tn

0

tn

2

trg

tn

b

tn

a

(57)

Transit Node Routing Shortest-path queries (with edges)

Shortest-path queries (with edges)

• Gradually find all nodes along the path

• Split it up into an already known part and the unknown rest

• Suppose we already know the path from src to a node u (initially src = u )

• To find the next step, find the neighbor v of u so that

d (u , dest) = d (u, v) + d (v, dest)

(58)

Transit Node Routing Shortest-path queries (with edges)

Shortest-path queries (with edges)

• Problem: When approaching dest the path is no longer long enough

• Two Solutions:

• Reverse the search: start from dest instead of src

• Only possible if the overall path is not too short

• Just use another algorithm to find the shortest path

• It’s possible to just fetch the next few steps instead of the whole path

• E.g. to just display the current region in navigation systems

(59)

Transit Node Routing Shortest-path queries (with edges)

Shortest-path queries (with edges)

• Problem: When approaching dest the path is no longer long enough

• Two Solutions:

• Reverse the search: start from dest instead of src

• Only possible if the overall path is not too short

• Just use another algorithm to find the shortest path

• It’s possible to just fetch the next few steps instead of the whole path

• E.g. to just display the current region in navigation systems

(60)

Transit Node Routing Shortest-path queries (with edges)

Shortest-path queries (with edges)

• Problem: When approaching dest the path is no longer long enough

• Two Solutions:

• Reverse the search: start from dest instead of src

• Only possible if the overall path is not too short

• Just use another algorithm to find the shortest path

• It’s possible to just fetch the next few steps instead of the whole path

• E.g. to just display the current region in navigation systems

(61)

Transit Node Routing Local queries

Local queries

• If src and dest are less than 4 cells apart the shortest distance wasn’t precomputed

• In such cases often the small roads are faster

• Use another shortest-path algorithm instead: Dijkstra, Highway Hierachies, etc.

• Most other algorithms are faster if the distance is very short

(62)

Transit Node Routing Multi-Level Grid

Multi-Level Grid

• Open Question: What grid size to choose?

Size |T | |T | × |T |/node % global queries preprocessing

64 × 64 2042 0.1 91.7% 498 min

128 × 128 7426 1.1 97.4% 525 min

256 × 256 24899 12.8 99.2% 638 min

512 × 512 89382 164.6 99.8% 859 min

1024 × 1024 351484 2545.5 99.9% 964 min

• Still the same goal: Not too many Transit Nodes, almost no local

queries

(63)

Transit Node Routing Multi-Level Grid

Multi-Level Grid

• Solution: Precompute multiple grids of different sizes

• Query: Use the coarsest grid for which the query is still non-local

• Few Transit nodes, faster query time

• Precomputation: Start with a coarse grid, do normal precomputation

• Add finer grids: Compute Transit Nodes like before, but only compute

distances beween Transit Nodes if they are in the local region of the

parent grid

(64)

Transit Node Routing Multi-Level Grid

Multi-Level Grid

• Solution: Precompute multiple grids of different sizes

• Query: Use the coarsest grid for which the query is still non-local

• Few Transit nodes, faster query time

• Precomputation: Start with a coarse grid, do normal precomputation

• Add finer grids: Compute Transit Nodes like before, but only compute

distances beween Transit Nodes if they are in the local region of the

parent grid

(65)

Conclusions

Conclusion

• Most work done in a preprocessing step

• Shortest-path queries reduced to a few table lookups

• Query time reduced from milliseconds to microseconds

• Exact responses, not an approximation

• Other stuff: Compress preprocessed data, ...

• Interesting Problems:

• Directed graphs

• Best algorithm for local queries

• Graph changes require full recomputation

(66)

Conclusions

Conclusion

• Most work done in a preprocessing step

• Shortest-path queries reduced to a few table lookups

• Query time reduced from milliseconds to microseconds

• Exact responses, not an approximation

• Other stuff: Compress preprocessed data, ...

• Interesting Problems:

• Directed graphs

• Best algorithm for local queries

• Graph changes require full recomputation

(67)

Conclusions

Thank you!

Referenzen

ÄHNLICHE DOKUMENTE

Er kommt in Ihrem Geburtsbild in folgenden Bereichen zum Ausdruck: Wir, Familie, Herkunft, Ursprung, Kindheit, Tradition, innere oder äußere Heimat, Heim, Haus,

My life in Lodz in those few postwar years centered on three locations: the apartment on 33 Gdanska Street, the Hebrew school on 18 Poludniowa Street, and the Hashomer Hatzair

Die B22 soll offenbar stärker ausgebaut werden als bisher geplant, zur bisher vorgesehenen OU Eckersdorf (Bt) kommen zwei neue Vorhaben dazu.. Der Ausbau der B85 soll vor allem im

Keine Rolle spielt die Anzahl der Zielsprachen: Sie können STAR MT sowohl für einsprachige als auch für mehrsprachige Projekte nutzen.. Unsere Empfehlung: Versuchen Sie es einfach

It decides which path in N 2 is preferred based on a number of rules that can differ from the cost function used in topological search (this is why all possible paths are retrieved

164.. Bei dem verhältnismäßig hohen Stand der schwedischen und finnischen Viehzucht, stellen Butter, Felle, Häute, Tierhaare u. einen weiteren wichtigen Einfuhrposten

Planetary and Stellar parameters from photodynamical analysis of the 3:2:1 resonance model on Kepler data and the three KOINet transit light curves.. Listed are the median values

Belarus / Telebrichi / 2009.. Seine Bilder sind vielmehr Versuchsanordnungen – über Kunst, Gesellschaft und Politik –, sie tragen den Charakter einer Suche