Week9
Week9
Deterministic Operations
Research
2023-2024 Spring
Week 9
Network Models
(1,2)-(2,3)-(4,3)
(1,2)-(2,3)-(3,4)
Shortest Path Problems
Example 1.
Dijkstra’s Algorithm
1 2 3 4 5 6
0* ∞ ∞ ∞ ∞ ∞
1 2 3 4 5 6
0* ∞ ∞ ∞ ∞ ∞
0* min{∞,0+4} min{∞,0+3} ∞ ∞ ∞
4 3*
Dijkstra’s Algorithm
1 2 3 4 5 6
0* ∞ ∞ ∞ ∞ ∞
0* 4 3* ∞ ∞ ∞
0* 4* 3* ∞ min{∞,3+3} ∞
6
Dijkstra’s Algorithm
1 2 3 4 5 6
0* ∞ ∞ ∞ ∞ ∞
0* 4 3* ∞ ∞ ∞
0* 4* 3* ∞ 6 ∞
0* 4* 3* min{∞,4+3} min{6,4+2} ∞
7 6*
Dijkstra’s Algorithm
1 2 3 4 5 6
0* ∞ ∞ ∞ ∞ ∞
0* 4 3* ∞ ∞ ∞
0* 4* 3* ∞ 6 ∞
0* 4* 3* 7 6* ∞
0* 4* 3* 7* 6* min{∞,6+2}
8
Dijkstra’s Algorithm
1 2 3 4 5 6
0* ∞ ∞ ∞ ∞ ∞
0* 4 3* ∞ ∞ ∞
0* 4* 3* ∞ 6 ∞
0* 4* 3* 7 6* ∞
0* 4* 3* 7* 6* 8
0* 4* 3* 7* 6* min{8,7+2}
8*
1 2 3 4 5 6
0* 4* 3* 7* 6* 8*
4 6 Label of 4: 7
Label of 5: 6
If 4 is used, I would reach 6 in (7+2=9).
5 6 If 5 is used, I would reach 6 in (6+2=8).
1 2 3 4 5 6
0* 4* 3* 7* 6* 8*
→5 →6
Which node precedes 5?
Label of 2: 4
2 5 Label of 3: 3
If 2 is used, I would reach 5 in (4+2=6).
If 3 is used, I would reach 5 in (3+3=6).
3 5
I reach 5 in 6 units, so either 2 or 3 is the preceding
node.
Dijkstra’s Algorithm
1 2 3 4 5 6
0* 4* 3* 7* 6* 8*
For; For;
→ 3→5 →6 → 2→5 →6
Which node precedes 3? Which node precedes 2?
Node 1. Node 1.
1→ 3→5 →6 1→ 2→5 →6
Example 2.
Example 2.
Dijkstra’s Algorithm
1 2 3 4 5 6
0* ∞ ∞ ∞ ∞ ∞
Example 2.
Dijkstra’s Algorithm
1 2 3 4 5 6
0* ∞ ∞ ∞ ∞ ∞
0* 7* 12 21 31 44
Example 2.
Dijkstra’s Algorithm
1 2 3 4 5 6
0* ∞ ∞ ∞ ∞ ∞
0* 7* 12 21 31 44
0* 7* min{12,7+7} min{21,7+12} min{31,7+21} min{44,7+31}
12* 19 28 38
Example 2.
Dijkstra’s Algorithm
1 2 3 4 5 6
0* ∞ ∞ ∞ ∞ ∞
0* 7* 12 21 31 44
0* 7* min{12,7+7} min{21,7+12} min{31,7+21} min{44,7+31}
12* 19 28 38
0* 7* 12* min{19, 12+7} min{28,12+12} min{38,12+21}
19* 24 33
Example 2.
Dijkstra’s Algorithm
1 2 3 4 5 6
0* ∞ ∞ ∞ ∞ ∞
0* 7* 12 21 31 44
0* 7* min{12,7+7} min{21,7+12} min{31,7+21} min{44,7+31}
12* 19 28 38
0* 7* 12* min{19, 12+7} min{28,12+12} min{38,12+21}
19* 24 33
0* 7* 12* 19* min{24,19+7} min{33,19+12}
24* 31
Example 2.
Dijkstra’s Algorithm
1 2 3 4 5 6
0* ∞ ∞ ∞ ∞ ∞
0* 7* 12 21 31 44
0* 7* min{12,7+7} min{21,7+12} min{31,7+21} min{44,7+31}
12* 19 28 38
0* 7* 12* min{19, 12+7} min{28,12+12} min{38,12+21}
19* 24 33
0* 7* 12* 19* min{24,19+7} min{33,19+12}
24* 31
0* 7* 12* 19* 24* min{31,24+7}
31*
26
Example
3
4 1
2 3 2
so 1 2 si
Capacity of
arc (i,j)
i j
27
Example
Maximize the amount sent from node so to node si.
3
4 1
2 3 2
so 1 2 si
Mathematical Model
28
3
4 1
2 3 2
so 1 2 si
3 a0
Mathematical Model
29
Optimal Solution:
3
4 (1) 1 (1)
30
Example
There are 5 men and 5 women at a Tango dance lesson. Not
everybody wants to dance with everybody, the table below
shows the pairs that both men and women agree on. We
want to maximize the number of pairs dancing. Draw a
network to represent this problem as a maximum-flow
problem.
Men/Women LA MS KH LE VP
KC √
BR √
TS √ √
MJ √ √ √
TC √ √ √
31
Men/Wom LA MS KH LE VP
en
KC √
BR √
TS √ √
MJ √ √ √
TC √ √ √
Network:
Optimal Solution:
Minimum-Cost Network Flow Problems (MCNF)
Notation:
𝑥𝑖𝑗 : number of units sent from node i to node j through arc
(i,j).
𝑐𝑖𝑗 : cost of transporting 1 unit from node i to node j through
arc (i,j).
𝑏𝑖 : net supply at node i.
𝑙𝑖𝑗 : lower bound on flow through arc (i,j) (if none, =0)
𝑢𝑖𝑗 : upper bound on flow through arc (i,j) (if none, =∞)
33
Minimum-Cost Network Flow Problems (MCNF)
Formulation:
(1)
(2)
34
Formulating a Transportation Problem as a MCNFP
Supply
1 2
4
3 4
5
Demand 6 3
35
Formulating a Max-Flow Problem as a MCNFP
max
36
Example
Minimum Spanning Tree (MST)
39
Use the following algorithm to find the optimal
spanning tree.
Prim’s Algorithm
1. Choose an initial node i, and join node j that is
closest to node i to the network with arc (i,j).
C: set of connected nodes, C={i,j}
C’: set of unconnected nodes
2. Choose a node (say k) in C’ that is closest to some
node (say m) in C. Add arc (k,m) to the network.
Update C and C’.
3. Repeat Step 2 until a minimum spanning tree is
found.
40
Example
The State University campus has 5 minicomputers. The
distance between each pair of computers is given in the
following figure. The computers must be interconnected by
underground cable. What is the minimum length of cable
required?
1
1 2
4 2 3
5 3
2
6
4
5
4
41
Start with node 1.
As an exercise, start with another node and develop the
MST.
(It should have the same total length with the tree found
above.)
43