Date post: | 17-Dec-2015 |
Category: |
Documents |
Upload: | jeremy-simpson |
View: | 216 times |
Download: | 0 times |
Management Science 461
Lecture 2b – Shortest Paths
September 16, 2008
2
Graph Theory
Branch of mathematics “Graph” has a very specific definition:
Collection of objectsCollection of relationships between objects
Both collections can have associated data (costs, weights)
3
Physical Abstraction
Euler and the Königsberg Bridges - 1736
4
Shortest Path Problems
Find the shortest (distance, time, cost) path between two nodes (e.g. 15)
1
2
34
58
2
5
4
3
5
9
Node = Vertex
Arc = Edge = Link
Route = Path
Tour = Circuit = Cycle
5
Algebraic formulation
otherwise0
selected is to node connecting edge theif1 jixij
1
2
34
58
2
5
4
3
5
9452543
344224
23321312
954
433
5528
minimize
xxx
xxx
xxxx
6
Flow and Integrality Constraints
subject to x12 + x13 = 1 (node 1)x12 + x32 + x42 = x23 + x24 + x25 (node 2)x13 + x23 + x43 = x32 + x34 (node 3)x34 + x24 = x43 + x42 + x45 (node 4)x25 + x45 = 1 (node 5)xij = 0 or 1 for all i, j
1
2
34
5
7
Rearranging, we get…
subject to - x12 - x13 = -1 (node 1)x12 + x32 + x42 - x23 - x24 - x25 = 0 (node 2)x13 + x23 + x43 - x32 - x34 = 0 (node 3)x34 + x24 - x43 - x42 - x45 = 0 (node 4)x25 + x45 = 1 (node 5)xij = 0 or 1 for all i, j
1
2
34
5
Flow in = flow out flow in – flow out = 0
Do these -1, 0, 1 values look familiar?
8
Shortest Path Problems
Solve using Excel’s Solver
However, a network with several hundred nodes would be out of reach, even for Premium Solver
e.g. Edmonton
Efficient algorithms need to be used – like Dijkstra’s algorithm
9
Dijkstra’s algorithm
“Label-setting” algorithmAt each node, keep track of minimum
distance from origin to the node, and how we got there
Very fast – polynomial time algorithmTime to solve increases polynomially with
problem size (not exponential)
10
Dijkstra’s Algorithm
8
2
5
4
3
5
9
1
2
34
5
11
Step 0 – Place Labels
8
2
5
4
3
5
9
1
2
34
5Dist: 0Pred: 1
Dist: Pred: 2
Dist: Pred: 5
Dist: Pred: 4
Dist: Pred: 3
12
Step 1 – Choose Minimum Label
8
2
5
4
3
5
9
1
2
34
5Dist: 0Pred: 1
Dist: Pred: 2
Dist: Pred: 5
Dist: Pred: 4
Dist: Pred: 3
13
Step 2 – Update Adjacent Labels
8
2
5
4
3
5
9
1
2
34
5Dist: 0Pred: 1
Dist: 8Pred: 1
Dist: Pred: 5
Dist: Pred: 4
Dist: 2Pred: 1
14
Step 2b – Mark Node As Optimal
8
2
5
4
3
5
9
1
2
34
5Dist: 0Pred: 1
Dist: 8Pred: 1
Dist: Pred: 5
Dist: Pred: 4
Dist: 2Pred: 1
15
Step 3 – Choose Next Min Dist
8
2
5
4
3
5
9
1
2
34
5Dist: 0Pred: 1
Dist: 8Pred: 1
Dist: Pred: 5
Dist: Pred: 4
Dist: 2Pred: 1
16
Step 4 – Update Adjacent Labels
8
2
5
4
3
5
9
1
2
34
5Dist: 0Pred: 1
Dist: 7Pred: 3
Dist: Pred: 5
Dist: 6Pred: 3
Dist: 2Pred: 1
17
Step 4b – Mark Node As Optimal
8
2
5
4
3
5
9
1
2
34
5Dist: 0Pred: 1
Dist: 7Pred: 3
Dist: Pred: 5
Dist: 6Pred: 3
Dist: 2Pred: 1
18
Step 5 – Choose Next Min Dist
8
2
5
4
3
5
9
1
2
34
5Dist: 0Pred: 1
Dist: 7Pred: 3
Dist: Pred: 5
Dist: 6Pred: 3
Dist: 2Pred: 1
19
Step 6 – Update Adjacent Labels
8
2
5
4
3
5
9
1
2
34
5Dist: 0Pred: 1
Dist: 7Pred: 3
Dist: 15Pred: 4
Dist: 6Pred: 3
Dist: 2Pred: 1
20
Step 6b – Mark Node As Optimal
8
2
5
4
3
5
9
1
2
34
5Dist: 0Pred: 1
Dist: 7Pred: 3
Dist: 15Pred: 5
Dist: 6Pred: 3
Dist: 2Pred: 1
21
Step 7 – Choose Next Min Dist
8
2
5
4
3
5
9
1
2
34
5Dist: 0Pred: 1
Dist: 7Pred: 3
Dist: 15Pred: 5
Dist: 6Pred: 3
Dist: 2Pred: 1
22
Step 8 – Update Adjacent Labels
8
2
5
4
3
5
9
1
2
34
5Dist: 0Pred: 1
Dist: 7Pred: 3
Dist: 12Pred: 2
Dist: 6Pred: 3
Dist: 2Pred: 1
23
Step 8b – Mark Node As Optimal
8
2
5
4
3
5
9
1
2
34
5Dist: 0Pred: 1
Dist: 7Pred: 3
Dist: 12Pred: 2
Dist: 6Pred: 3
Dist: 2Pred: 1
24
Step 9 – Choose Next Min Dist
8
2
5
4
3
5
9
1
2
34
5Dist: 0Pred: 1
Dist: 7Pred: 3
Dist: 12Pred: 2
Dist: 6Pred: 3
Dist: 2Pred: 1
25
Step 10 – Update Adjacent Labels
8
2
5
4
3
5
9
1
2
34
5Dist: 0Pred: 1
Dist: 7Pred: 3
Dist: 12Pred: 2
Dist: 6Pred: 3
Dist: 2Pred: 1
26
Step 10b – Mark Node As Optimal
8
2
5
4
3
5
9
1
2
34
5Dist: 0Pred: 1
Dist: 7Pred: 3
Dist: 12Pred: 2
Dist: 6Pred: 3
Dist: 2Pred: 1
27
Final Solution – Min Dist Tree
8
2
5
4
3
5
9
1
2
34
5Dist: 0Pred: 1
Dist: 7Pred: 3
Dist: 12Pred: 2
Dist: 6Pred: 3
Dist: 2Pred: 1