facilities planning objectives and agenda: 1. examples of shortest path problem 2. finding shortest...
Post on 21-Dec-2015
228 views
TRANSCRIPT
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
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••
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
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
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
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
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
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
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
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?
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
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?
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
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!
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.
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 … ?
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?
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, …
Prof Edsger Dijkstra [1930-2002]
next topic: transportation flow planning – max flow