Chapter 7 - Formulating Network Problems
Chapter 7 - Formulating Network Problems
1
Outline
• Summary
2
Network Flow Models
c: arc cost
u: arc capacity –3
9 6
3 2
2
c12, u12 3
7 10
3 8 -1
+1 4
1
100,10
2
50,3
4 –7 1 5
8 5
6 7
7
+10 4
5 3 5 4
5
3
Minimum Cost Flow Problem
4
Minimum Cost Flow Problem:
LP Formulation
5
Minimum Cost Flow Problem:
LP Formulation Example
Min 𝑍 = 3𝑥12 + 4𝑥13 + 1𝑥14 + 5𝑥23 + 6𝑥25 + 1𝑥34 + 2𝑥35 + 2𝑥46 + 4𝑥56
6
Minimum Cost Flow Problem
LP Formulation Example
Min 𝑍 = 3𝑥12 + 4𝑥13 + 1𝑥14 + 5𝑥23 + 6𝑥25 + 1𝑥34 + 2𝑥35 + 2𝑥46 + 4𝑥56
7
Minimum Cost Flow Problem:
Application Examples
9
Shortest Path Problem
9 6 2
3 2
7 10
3 8 -1 f1 = +1, f8 = –1, and
+1 4
1 5 fi = 0 for all other nodes
8 5
6 7
4
7 All arc capacities uij = 1
3 5 4
5
10
Shortest Path Problem Example:
LP Formulation
Both directions
Min 𝑍 = 3𝑥12 + 3𝑥21 + 4𝑥13 + 4𝑥31 + 5𝑥23 + 5𝑥32 + ⋯ + 5𝑥78 + 5𝑥87
Objective Value = 13
0 6
𝑥𝑖𝑗 0
1 2
1 0
1 8 -1
+1 4
1 0
0 0
0 0
7
0
3 5 0 9 6
0 2
3 2
7 10
3 8 -1
+1 4
1 5
8 5
6 7
7
𝑐𝑖𝑗 4
3 5 4
5
12
Shortest Path Problem Special Restricted Case
Case 1: Unavailable Arcs
50 6
2 50
3 7 50 c26=50
3 8 -1
+1 1 5
4 c46=50
8 c86=50
7 5
6
7
4
3 5 4 Undirected arcs
5 14
Shortest Path Problem Special Restricted Case
Case 3: Compulsory Arcs
• Finding the shortest path which does go through an arc, e.g. arc
(4,7) or (7,4)
→ Does Not Work: Assign a zero cost to the compulsory arc (e.g. arc
(4,7))
9 6
2 2
3 10
7 3 8 -1
+1 4
1 5
8 5
6 0
7
4
3 5 4
5 Cost of 1-2-4-7-8 = 15
Cost of 1-2-4-8 = 13 (Optimal)
15
Shortest Path Problem Special Restricted Case
Case 3: Compulsory Arcs (Cont.)
• Finding the shortest path which does go through an arc, e.g. arc (4,7)
→ Solution:
(1) Find the shortest path between nodes 1-4 and 7-8: Cost = 22
(2) Find the shortest path between nodes 1-7 and 4-8: Cost = 23
(3) Take the smaller one, i.e. 1-2-4-7-8
9 6
2 2
3 10
7
3 8 -1
+1 4
1 5
8 5
6 7
7
4
3 5 4
5 16
Shortest Path Problem: Dijkstra’s Algorithm
• This algorithm finds the shortest path from source nodes to all other
nodes in the network.
where i is the node immediately preceding j on the shortest path and d(j)
indicates the length of the current shortest path from s to j.
17
Labels
2
(3) (2)
18
Shortest Path Problem: Dijkstra’s Algorithm
• Step 1: Label node s with the permanent label [0,–]. Label every
node i connected to node s with a temporary label [c(s,i),s]. Assign
the label [∞, –] to all other nodes.
• Step 2: Select the node with the smallest temporary label, say node
i, and make it permanent.
19
Shortest Path Problem – Dijkstra’s Algorithm
Example 1: Travelling in a City
• Each node represents a road junction. Each road section has a different
length, as shown in the network diagram.
• Goal: To find the shortest path from node s to every other node.
6
A
3
C
4 2
s 1 E
3 2
B D
3
20
Shortest Path Problem – Dijkstra’s Algorithm
Example 1: Travelling in a City
• Step 1: Label node s with the permanent label [0,–]. Label every node i
connected to node s with a temporary label [c(s,i),s]. Assign the label
[∞, –] to all other nodes.
Initialization 6 [6,s]
[4,s]
A
3
C
4 2
[0,–]* s 1 E [∞, –]
3 2
B D
Permanent label with * 3
[3,s] [∞, –]
• Step 2: Select the node with the smallest temporary label, say node i,
and make it permanent.
6 [4,s] [6,s]
3
Iteration 1 A C
4 2
[0,–]* s 1 E [∞, –]
3 2
B D
3 The node connected
[3,s]* [6, B] to Node B and with
temporary label
3+3=6 23
Shortest Path Problem – Dijkstra’s Algorithm
Example 1: Travelling in a City
• Step 2: Select the node with the smallest temporary label, say node i,
and make it permanent.
6 [4,s]* [6,s]
Iteration 2 3
A C
4 2
[0,–]* s 1 E [∞, –]
3 2
B D
3
[3,s]* [6, B]
24
Shortest Path Problem – Dijkstra’s Algorithm
Example 1: Travelling in a City
• Step 3: For all node j connected to i by arcs that do not have permanent
labels, compare the current temporary distance label d(j) with d(i)+c(i,j).
If d(i)+c(i,j)<d(j), give a temporary label to node j with [d(i)+c(i,j),i].
• Step 4: Go to Step 2.
4+3=7>6
Keep the old label
Iteration 2
6 [4,s]* [6,s]
A
3
C
4 2
[0,–]* s 1 E [∞, –]
3 2
B D
3
[3,s]* [5, A] [6, B]
4+1=5<6 25
Shortest Path Problem – Dijkstra’s Algorithm
Example 1: Travelling in a City
• Step 2: Select the node with the smallest temporary label, say node i,
and make it permanent.
6 [4,s]* [6,s]
Iteration 3
A
3
C
4 2
[0,–]* s 1 E [∞, –]
3 2
B D
3 Permanent label with *
[3,s]* [5, A]*
The smallest
temporary label
26
Shortest Path Problem – Dijkstra’s Algorithm
Example 1: Travelling in a City
• Step 3: For all node j connected to i by arcs that do not have permanent
labels, compare the current temporary distance label d(j) with d(i)+c(i,j).
If d(i)+c(i,j)<d(j), give a temporary label to node j with [d(i)+c(i,j),i].
• Step 4: Go to Step 2.
6 [4,s]* [6,s]
Iteration 3 3
A C
4 2
[0,–]* s 1 E [7, D]
3 2
B D 5+2=7
3
[3,s]* [5, A]*
27
Shortest Path Problem – Dijkstra’s Algorithm
Example 1: Travelling in a City
• Step 2: Select the node with the smallest temporary label, say node i,
and make it permanent.
The smallest
temporary label
6 [4,s]* [6,s]*
Iteration 4 3
A C
4 2
[0,–]* s 1 E [7, D]
3 2
B D
3
[3,s]* [5, A]*
28
Shortest Path Problem – Dijkstra’s Algorithm
Example 1: Travelling in a City
• Step 3: For all node j connected to i by arcs that do not have permanent
labels, compare the current temporary distance label d(j) with d(i)+c(i,j).
If d(i)+c(i,j)<d(j), give a temporary label to node j with [d(i)+c(i,j),i].
• Step 4: Go to Step 2.
6 [4,s]* [6,s]*
Iteration 4 A
3
C
4 2
[0,–]* s 1 E [7, D]
3 2
B D 6+2=8>7
3 Keep old label
[3,s]* [5, A]*
29
Shortest Path Problem – Dijkstra’s Algorithm
Example 1: Travelling in a City
• Step 2: Select the node with the smallest temporary label, say node i,
and make it permanent.
• Step 3: Check the label for all node j connected to i by arcs that do
not have permanent labels.
• Step 4: If all nodes have permanent labels, STOP. Otherwise, Go to
Step 2.
6 [4,s]* [6,s]*
Iteration 5 A
3
C
4 2
[0,–]* s 1 E [7, D]*
3 2
B D
3
[3,s]* [5, A]* 30
Shortest Path Problem – Dijkstra’s Algorithm
Example 1: Travelling in a City
• Optimal Solution:
6 [4,s]* [6,s]*
A
3
C
4 2
[0,–]* s 1 E [7, D]*
3 2
B D
3
[3,s]* [5,A]*
Skim tree for node s
31
Iteration s → A B C D E Table format
4 3 6 ∞ ∞
Initial
s s s - -
4 3 6 6 ∞
1 B
s s s B -
4 3 6 5 ∞
2 A
s s s A -
4 3 6 5 7 Distance label
3 D
s s s A D
4 3 6 5 7
4 C
s s s A D Predecessor (preceding
node) label
4 3 6 5 7
5 E
s s s A D
6
The node made permanent Red text cell s : label being checked
in current iteration 3
Yellow cell s : permanent label
Each iteration has two steps:
• Make the node with the smallest temporary label permanent
• Update temporary labels of nodes connected to the (new) permanent node 32
Shortest Path Problem – Dijkstra’s Algorithm
Example 2: Travelling in a City with One-Way Roads
• Consider a city with the following road network.
• Each node represents a road junction. Each road section has a
different length, as shown in the network diagram.
• Goal: To find the shortest path from node s to every other node.
A 15
C
100 20 55
10
30 60
s B D
33
Shortest Path Problem – Dijkstra’s Algorithm
Example 2: Travelling in a City with One-Way Roads
• Step 1: Label node s with the permanent label [0,–]. Label every
node i connected to node s with a temporary label [c(s,i),s]. Assign
the label [∞, –] to all other nodes.
[100, s]
Initialization
A 15 [∞, -]
C
100 20 55
10
30 60
[0, -]* s B D [∞, -]
[30, s]
34
Shortest Path Problem – Dijkstra’s Algorithm
Example 2: Travelling in a City with One-Way Roads
• Step 2: Select the node with the smallest temporary label, say node i,
and make it permanent.
• Step 3: For all node j connected to i by arcs that do not have
permanent labels, compare the current temporary distance label d(j)
with d(i)+c(i,j). If d(i)+c(i,j)<d(j), give a temporary label to node j with
[d(i)+c(i,j),i].
• Step 4: Go to Step 2. Cannot go to Node A
[100, s] from Node B
Iteration 1 A 15 [40, B]
C
100 20 55
10
30 60
[0, -]* s B D [90, B]
[30, s]* 35
Shortest Path Problem – Dijkstra’s Algorithm
Example 2: Travelling in a City with One-Way Roads
• Step 2: Select the node with the smallest temporary label, say node i,
and make it permanent.
• Step 3: For all node j connected to i by arcs that do not have permanent
labels, compare the current temporary distance label d(j) with d(i)+c(i,j).
If d(i)+c(i,j)<d(j), give a temporary label to node j with [d(i)+c(i,j),i].
• Step 4: Go to Step 2.
40 + 15 = 55 < 100
Iteration 2
[100, s] [55, C]
A 15
C [40, B]*
100 20 55
10
30 60
s B D
[0, -]* [30, s]* [90, B]
36
Shortest Path Problem – Dijkstra’s Algorithm
Example 2: Travelling in a City with One-Way Roads
• Step 2: Select the node with the smallest temporary label, say node i,
and make it permanent.
• Step 3: For all node j connected to i by arcs that do not have permanent
labels, compare the current temporary distance label d(j) with d(i)+c(i,j).
If d(i)+c(i,j)<d(j), give a temporary label to node j with [d(i)+c(i,j),i].
• Step 4: Go to Step 2. Node B is the only node connected from
Node A, but it already has a permanent
[55, C]* label → No change needed
A 15 [40, B] *
Iteration 3 C
100 20 55
10
30 60
[0, -]* s B D [90, B]
[30, s]* 37
Shortest Path Problem – Dijkstra’s Algorithm
Example 2: Travelling in a City with One-Way Roads
• Step 2: Select the node with the smallest temporary label, say node i,
and make it permanent.
• Step 3: For all node j connected to i by arcs that do not have permanent
labels, compare the current temporary distance label d(j) with d(i)+c(i,j).
If d(i)+c(i,j)<d(j), give a temporary label to node j with [d(i)+c(i,j),i].
• Step 4: If all nodes have permanent labels, STOP.
Only one temporary label left,
[55, C]* which is changed to permanent.
A 15 [40, B] *
Iteration 4 C
100 20 55
10
30 60
[0, -]* s B D [90, B]*
[30, s]* 38
Shortest Path Problem – Dijkstra’s Algorithm
Example 2: Travelling in a City with One-Way Roads
• What is the shortest path from Node s to Node A?
– Node A → Node C → Node B → Node s
– Shortest path: s-B-C-A, Distance 55.
[55, C]*
1 A 15 [40, B] *
C
100 20 55
10
30 60
1 s B D [90, B]*
[0, -]* [30, s]*
39
Shortest Path Problem – Dijkstra’s Algorithm
Example 2: Travelling in a City with One-Way Roads
• What is the shortest path from Node s to Node A?
Min 𝑍 = 100𝑥𝑠𝐴 + 30𝑥𝑠𝐵 + 20𝑥𝐴𝐵 + 10𝑥𝐵𝐶 + 60𝑥𝐵𝐷 + 15𝑥𝐶𝐴 + 55𝑥𝐶𝐷
40
Shortest Path Problem – Dijkstra’s Algorithm
Example 2: Travelling in a City with One-Way Roads
1 A 15
C
Each column has one “1” and one “-1” 55
100 20
10
Optimal: z = 55, xsB = 1, xBC = 1, xCA = 1 30 60
1 s B D
41
Shortest Path Problem – Dijkstra’s Algorithm
Summary
42
Formulating and Solving Network Flow
Problems
43
Maximal Flow Problem
• In the maximal flow problem, each link has a maximum flow capacity
which limits the flow through the arc.
1 12 3
16 20
• There is no cost associated with the flow.
s 10 4 9 7 t
• For any directed graph D = (V, A)
13 14 4
– Source (node): vs 2 4
– Sink (node): vt V: Set of vertices (nodes)
– Intermediate points (nodes): vi A: Set of arcs
– Link capacity: u(vi, vj) 0 (or uij) for each link (vi, vj)A
• Network D = (V, A, U)
44
Maximal Flow Problem
q i=s
fij − f ji = 0 i s, t
( vi ,v j )A ( v j ,vi )A −q i = t
where q is the volume of the feasible flow
• A feasible flow always exists, e.g., q = 0
45
Maximal Flow Problem: LP Formulation
Maximal Flow
max q
f
Flow
s.t. Conservation
q i=s
fij − f ji = 0 i s, t
( vi ,v j )A ( v j ,vi )A −q i=t
0 fij uij , ( vi , v j ) A
Capacity
Limitation
46
Maximal Flow Problem: LP Formulation: Example
12
16 1 3 20
s 10 4 9 7 t
13 4
2 4
14
Capacity
47
Maximal Flow Problem: LP Formulation
1 12 3
16 20
+𝑞 −𝑞
s 10 4 9 7 t
Max 𝑞
13 4
s.t. (Flow conservation) 2 4
14
𝑓𝑠1 + 𝑓𝑠2 = 𝑞 (Node s - Source)
𝑓12 + 𝑓13 − 𝑓𝑠1 − 𝑓21 = 0 (Node 1 - Intermediate)
𝑓21 + 𝑓24 − 𝑓𝑠2 − 𝑓12 − 𝑓32 = 0 (Node 2 - Intermediate)
𝑓32 + 𝑓3𝑡 − 𝑓13 − 𝑓43 = 0 (Node 3 - Intermediate)
𝑓43 + 𝑓4𝑡 − 𝑓24 = 0 (Node 4 - Intermediate)
−𝑓3𝑡 − 𝑓4𝑡 = −𝑞 (Node t – Sink/Destination)
49
Maximal Flow Problem:
Application Example
• Internet bandwidth
50
Formulating and Solving Network Flow
Problems
51
Minimum Spanning Tree Problem
(undirected graph)
2 4 2
1 3 5 1 3
Network Tree
2 4 2 4 2 4
1 3 5 1 3 5 1 3 5
Spanning Tree 52
Minimum Spanning Tree Problem
(undirected graph)
53
Minimum Spanning Tree Problem: Applications
Hub-and-Spoke
54
Summary
55