facilities planning objectives and agenda: 1. examples of shortest path problem 2. finding shortest...

19
Facilities Planning ectives and Agenda: . Examples of Shortest Path Problem . Finding shortest paths: Dijkstra’s method . Other applications of Shortest path problem

Post on 21-Dec-2015

230 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Facilities Planning Objectives and Agenda: 1. Examples of Shortest Path Problem 2. Finding shortest paths: Dijkstra’s method 3. Other applications of Shortest

Facilities Planning

Objectives and Agenda:

1. Examples of Shortest Path Problem

2. Finding shortest paths: Dijkstra’s method

3. Other applications of Shortest path problem

Page 2: Facilities Planning Objectives and Agenda: 1. Examples of Shortest Path Problem 2. Finding shortest paths: Dijkstra’s method 3. Other applications of Shortest

Example (Shortest Path Problem)

What is the shortest route from Point A to Point B ?

What if some roads are specified as 1-way only ?

AB••AB••

Page 3: Facilities Planning Objectives and Agenda: 1. Examples of Shortest Path Problem 2. Finding shortest paths: Dijkstra’s method 3. Other applications of Shortest

A Graph-model of the Shortest Route problem

4

7

2

2

4

4

3

3 3

ust

kt

ch

pe

hh

tko

6

1

tkw

4

7

2

2

4

4

3

3 3

ust

kt

ch

pe

hh

tko

6

1

tkw

Given a directed, weighted graph, G(V, E), start node s, end node v,Find the minimum total weight path from s to v

Legend:Edge direct roadweight road lengthnodes road intersections

ust = HKUSTtko = Tseung Kwan Okt = Kowloon Tongch = Choi Hungtkw = To Kwa Wanpe = Prince Edwardhh = Hung Hom

Page 4: Facilities Planning Objectives and Agenda: 1. Examples of Shortest Path Problem 2. Finding shortest paths: Dijkstra’s method 3. Other applications of Shortest

Finding shortest paths: Dijkstra’s method

Strategy:Find shortest path to one node;[all other nodes remain]Find shortest path to one of the remaining nodes;Repeat … until done

Key concept: Relaxation

How?Upper bound on distance from s to u: d[u]If Node k has the MIN upper bound

d[k] is the shortest distance from s to kSelect node k to update upper bounds on remaining nodes

Page 5: Facilities Planning Objectives and Agenda: 1. Examples of Shortest Path Problem 2. Finding shortest paths: Dijkstra’s method 3. Other applications of Shortest

Relaxation..

4x y10 18

4x y10 14

Relax( x, y)

4x y10 12

4x y10 12

Relax( x, y)

cyan edge => current immediate predecessor of y is x

Two cases of relaxation

Page 6: Facilities Planning Objectives and Agenda: 1. Examples of Shortest Path Problem 2. Finding shortest paths: Dijkstra’s method 3. Other applications of Shortest

Dijkstra’s method..

d[vi] = for each vertex; d[s] = 0;

Make two lists: S = { }; Q = V

Find the node, u, in Q with minimum d[u]

Remove u from Q, and add u to S

For each edge (u, v),Relax (u, v); update IP(v)

Q = { }no yes

DONE

Page 7: Facilities Planning Objectives and Agenda: 1. Examples of Shortest Path Problem 2. Finding shortest paths: Dijkstra’s method 3. Other applications of Shortest

Dijkstra’s method, Example

0

4

7

2

2

4

4

3

3 3

ust

kt

ch

pe

hh

tko

6

1

tkw

0

4

7

2

2

4

4

3

3 3

ust

kt

ch

pe

hh

tko

6

1

tkw

Find shortest path from ust to hh

Page 8: Facilities Planning Objectives and Agenda: 1. Examples of Shortest Path Problem 2. Finding shortest paths: Dijkstra’s method 3. Other applications of Shortest

Dijkstra’s method, Example..

0

4

7

2

2

4

4

3

3 3

ust

kt

ch

pe

hh

tko

6

1

tkw

0

4

7

2

2

4

4

3

3 3

ust

kt

ch

pe

hh

tko

6

1

tkw

0

4

7

2

2

4

4

3

3 3

ust

kt

ch

pe

hh

tko

6

1

tkw

6

7

0

4

7

2

2

4

4

3

3 3

ust

kt

ch

pe

hh

tko

6

1

tkw

6

7

S = set of nodes for which we know the shortest distance from s

Q = remaining nodes in the graph

d[ust] = d*[ust] = 0relax ust

Page 9: Facilities Planning Objectives and Agenda: 1. Examples of Shortest Path Problem 2. Finding shortest paths: Dijkstra’s method 3. Other applications of Shortest

Dijkstra’s method, Example...

0

4

7

2

2

4

4

3

3 3

ust

kt

ch

pe

hh

tko

6

1

tkw

6

7

0

4

7

2

2

4

4

3

3 3

ust

kt

ch

pe

hh

tko

6

1

tkw

6

7

mark IP’s of tko, ch MIN d[u] in Q is tkod*[tko] = 6relax tko

0

4

7

2

2

4

4

3

3 3

ust

kt

ch

pe

hh

tko

6

1

tkw

610

7

0

4

7

2

2

4

4

3

3 3

ust

kt

ch

pe

hh

tko

6

1

tkw

610

7

Page 10: Facilities Planning Objectives and Agenda: 1. Examples of Shortest Path Problem 2. Finding shortest paths: Dijkstra’s method 3. Other applications of Shortest

Dijkstra’s method, Example….

0

4

7

2

2

4

4

3

3 3

ust

kt

ch

pe

hh

tko

6

1

tkw

610

7

0

4

7

2

2

4

4

3

3 3

ust

kt

ch

pe

hh

tko

6

1

tkw

610

7

MIN d[u] in Q is chd*[ch] = 7relax ch

0

4

7

2

2

4

4

3

3 3

ust

kt

ch

pe

hh

tko

6

1

tkw

69

10

11

7

0

4

7

2

2

4

4

3

3 3

ust

kt

ch

pe

hh

tko

6

1

tkw

69

10

11

7NOTE: what happens to IP of kt?

Page 11: Facilities Planning Objectives and Agenda: 1. Examples of Shortest Path Problem 2. Finding shortest paths: Dijkstra’s method 3. Other applications of Shortest

Dijkstra’s method, Example…..

0

4

7

2

2

4

4

3

3 3

ust

kt

ch

pe

hh

tko

6

1

tkw

69 13

10

11

7

0

4

7

2

2

4

4

3

3 3

ust

kt

ch

pe

hh

tko

6

1

tkw

69 13

10

11

7

0

4

7

2

2

4

4

3

3 3

ust

kt

ch

pe

hh

tko

6

1

tkw

69

10

11

7

0

4

7

2

2

4

4

3

3 3

ust

kt

ch

pe

hh

tko

6

1

tkw

69

10

11

7

MIN d[u] in Q is ktd*[kt] = 9relax kt

Page 12: Facilities Planning Objectives and Agenda: 1. Examples of Shortest Path Problem 2. Finding shortest paths: Dijkstra’s method 3. Other applications of Shortest

Dijkstra’s method, Example…...

0

4

7

2

2

4

4

3

3 3

ust

kt

ch

pe

hh

tko

6

1

tkw

69 13

10

11

7

0

4

7

2

2

4

4

3

3 3

ust

kt

ch

pe

hh

tko

6

1

tkw

69 13

10

11

7

0

4

7

2

2

4

4

3

3 3

ust

kt

ch

pe

hh

tko

6

1

tkw

69 13

10

11

7

0

4

7

2

2

4

4

3

3 3

ust

kt

ch

pe

hh

tko

6

1

tkw

69 13

10

11

7

MIN d[u] in Q is ped*[pe] = 10relax pe

NOTE: what happens to IP of hh?

Page 13: Facilities Planning Objectives and Agenda: 1. Examples of Shortest Path Problem 2. Finding shortest paths: Dijkstra’s method 3. Other applications of Shortest

Dijkstra’s method, Example…....

0

4

7

2

2

4

4

3

3 3

ust

kt

ch

pe

hh

tko

6

1

tkw

69 13

10

11

7

0

4

7

2

2

4

4

3

3 3

ust

kt

ch

pe

hh

tko

6

1

tkw

69 13

10

11

7

0

4

7

2

2

4

4

3

3 3

ust

kt

ch

pe

hh

tko

6

1

tkw

69 12

10

11

7

0

4

7

2

2

4

4

3

3 3

ust

kt

ch

pe

hh

tko

6

1

tkw

69 12

10

11

7

MIN d[u] in Q is tkwd*[tkw] = 11relax tkw

Page 14: Facilities Planning Objectives and Agenda: 1. Examples of Shortest Path Problem 2. Finding shortest paths: Dijkstra’s method 3. Other applications of Shortest

Dijkstra’s method, Example……..

0

4

7

2

2

4

4

3

3 3

ust

kt

ch

pe

hh

tko

6

1

tkw

69 12

10

11

7

0

4

7

2

2

4

4

3

3 3

ust

kt

ch

pe

hh

tko

6

1

tkw

69 12

10

11

7

0

4

7

2

2

4

4

3

3 3

ust

kt

ch

pe

hh

tko

6

1

tkw

69 12

10

11

7

0

4

7

2

2

4

4

3

3 3

ust

kt

ch

pe

hh

tko

6

1

tkw

69 12

10

11

7

Shortest path: reverse(hh tkw ch ust)

MIN d[u] in Q is hhd*[hh] = 12relax hhDONE!

Page 15: Facilities Planning Objectives and Agenda: 1. Examples of Shortest Path Problem 2. Finding shortest paths: Dijkstra’s method 3. Other applications of Shortest

Dijkstra’s method, Proof

PROPERTIES OF RELAXATION

(i) d[u] is non-increasing: relaxation cannot increase d[u]

(ii) d[u] cannot go below the shortest distance from s to u.

connected graph there is a shortest distance from s to u = d*[u]

d[u] ≥ d*[u]

(i) and (ii) => Once we have found the shortest path to node u,d[u] will never change.

Page 16: Facilities Planning Objectives and Agenda: 1. Examples of Shortest Path Problem 2. Finding shortest paths: Dijkstra’s method 3. Other applications of Shortest

Dijkstra’s method, Proof..

What are such nodes ?

(2) Next candidate: select min d[u] node from nodes in set Q

(1) The elements of set S

why?

S S

s

v

s

v

y. . .

. . .

p

m

. . .

(a) (b)

S S

s

v

s

v

y. . .

. . .

p

m

. . .

S S

s

v

s

v

y. . .

. . .

p

m

. . .

(a) (b)

Q Q

Let: d[v] be minimum among all nodes in QThere are two possibilities for the shortest path from s to v

so … ?

Page 17: Facilities Planning Objectives and Agenda: 1. Examples of Shortest Path Problem 2. Finding shortest paths: Dijkstra’s method 3. Other applications of Shortest

Dijkstra’s method, concluding remarks

What if the graph is undirected ?

Replace each undirected edge with two directed edges4x y 4x y

4

What if the some edge weights are negative?

Page 18: Facilities Planning Objectives and Agenda: 1. Examples of Shortest Path Problem 2. Finding shortest paths: Dijkstra’s method 3. Other applications of Shortest

Shortest path, Applications

- Telephone routes- Which communication links to activate when a user makes a phone call, e.g. from HK to New York, USA.

- Road systems designProblem: how to determine the no. of lanes in each road?Given: expected traffic between each pair of locationsMethod: Estimate total traffic on each road link assuming

each passenger will use shortest path

- Many other applications, including: - Finance (arbitrage), - Assembly line inspection systems design, …

Page 19: Facilities Planning Objectives and Agenda: 1. Examples of Shortest Path Problem 2. Finding shortest paths: Dijkstra’s method 3. Other applications of Shortest

Prof Edsger Dijkstra [1930-2002]

next topic: transportation flow planning – max flow