3E4 Lecture 5
3E4 Lecture 5
Lecture 5
Announcements
Coursework
• To be handed in:
– on Mon 28 Feb, 4pm, Lecture Room 1, Eng. Dept.
• Filling in the coversheet:
– MODULE: 3E4 MODELLING CHOICE
– MODULE LEADER: GG278
– TITLE OF COURSEWORK: Production planning and
optimal decisions: The SteelPro case
• Cover sheet also available online
1
3E4 : Lecture Outline
Lecture 1. Management Science & Optimisation
Modelling: Linear Programming
Lecture 2. LP: Spreadsheets and the Simplex Method
Lecture 3. LP: Sensitivity & shadow prices
Reduced cost & shadow price formulae
Lecture 4. Integer LP: branch & bound
Lecture 5. Network flows problems
Lecture 6. Multiobjective LP
Lecture 7 – 8. Introduction to nonlinear programming
Introduction
• A number of business problems can be
represented graphically as networks.
• Several types of network flow problems:
– Transshipment Problems
– Shortest Path Problems
– Transportation/Assignment Problems
– Minimal Spanning Tree Problems
– Maximal Flow Problems
– Generalized Network Flow Problems
2
Characteristics of
Network Flow Problems
• Network flow problems can be represented as “graphs”, i.e. a
collection of nodes connected by arcs.
• There are three types of nodes:
– “Supply” or “Source” (less flow goes in than comes out)
– “Demand” or “Sink” (more flow goes in than comes out)
– “Transshipment” (inflow = outflow)
• We’ll use
– Net inflow (=inflow – outflow) to model the amount of flow
passing through a node, hence we’ll use negative numbers to
represent supplies and positive numbers to represent demand.
Characteristics of
Network Flow Problems
• Arcs can be directed or undirected
• Arcs can have a limited capacity
• A “cost” (or a “cost” function) can be
associated to each arc
• A directed graph whose nodes and/or arcs
have associated numerical values (costs,
capacities, supplies, demands) is named
“directed network”.
6
3
Important properties of Network
LPs
• The relatively simple structure of Network
LPs means there is very efficient (fast)
software specialised for these problems.
• If a Network LP with INTEGER data has
any solutions then
– it has at least one solution with all integer flows
– the Simplex method will find an integral
solution!
7
A Transshipment Problem:
The Bavarian Motor Company
A luxury car importer, BMC, ships
vehicles from Hamburg, Germany to
Jacksonville (FLA) and Newark (NJ)
in the USA, and then must distribute
them as cheaply as possible to 5 other
cities.
4
A Transshipment Problem:
The Bavarian Motor Company
+100
Boston $30
$50 2 Newark -200
1
Columbus
+60
3 $40
$40
$35 $30 Richmond
+80
Atlanta 4
+170 5
$25
$45 $50
$35
+70 Mobile
6 J'ville -300
$50 7
Xij = the amount being shipped (or flowing) from node i to node j
For example,
X12 = the number of cars shipped from node 1 (Newark) to node 2 (Boston)
X56 = the number of cars shipped from node 5 (Atlanta) to node 6 (Mobile)
10
5
Defining the Objective Function
Minimize total shipping costs.
11
12
6
Defining the Constraints
• In the BMC problem:
Total Supply = 500 cars
Total Demand = 480 cars
• So for each node we need a constraint of the
form:
Inflow - Outflow >= Supply or Demand
• Constraint for node 1:
–X12 – X14 >= – 200 (there is no inflow for node 1!)
14
7
Optimal Solution to the BMC Problem
+100
Boston $30
$50 2 Newark -200
120 1
20
Columbus 80
+60
3 $40
$40
40 Richmond
+80
Atlanta 4
+170 5
$45
210
70
+70 Mobile
6 J'ville -300
$50 7
15
8
The American Car Association
17
9
Solving the Problem
• There are two possible objectives for this
problem
– Finding the quickest route (minimizing travel
time)
– Finding the most scenic route (maximizing the
scenic rating points)
• Model & solve (using Excel) either of these
shortest path problems for homework.
19
35
Eustis 30 Orlando
400,000 600,000
2 5
22
55
Clermont 20 Leesburg
300,000 225,000
3 25 6
10
Minimal spanning tree problems
• For a network with n nodes, a spanning tree
is a set of n−1 arcs that connects all the
nodes and contain no loops.
• A minimum spanning tree problem involves
determining the spanning tree with minimal
total length (or cost) of the selected arcs.
21
Spanning tree
4
2
5
1
3
6
22
11
Spanning tree
4
2
5
1
3
6
23
Spanning tree
4
2
5
1
3
6
24
12
Minimal spanning tree problems
• Suppose you are requested to design a computer LAN,
where all computers are connected together, not
necessarily directly one to each other. The network in the
picture represents all the possible links that can be
activated, and the £ amount on each link represents the cost
of making the connection:
£150 4
2
£85 £75
£100
£40 5
1 £80
£85
£50
£90
3
6 25
£65
13
An algorithm for the
Minimal spanning tree problem
1. Select 1 as a starting subnetwork.
2. The cheapest arc is (1,5). The new subnetwork is
{1,5}.
3. Four nodes remain unconnected. Go to step 2.
4
2
£85
£100
5
1 £80
£85
£90
3
6 27
14
An algorithm for the
Minimal spanning tree problem
2. The cheapest arc is (3,6). The new subnetwork is
{1,3,5,6}.
3. Two nodes remain unconnected. Go to step 2.
4
2
£85 £75
£100
5
1
£85
3
6 29
£65
3
6 30
15
An algorithm for the
Minimal spanning tree problem
2. The cheapest arc is (4,5). The new subnetwork is
{1,2,3,4,5,6}.
3. No nodes remain unconnected. STOP.
£150 4
2
£85 £75
5
1
3
6 31
£50
3
6
£65
32
16
The Maximal Flow Problem
• In some network problems, the objective is to
determine the maximum amount of flow that
can occur through a network.
• The arcs in these problems have upper and
lower flow limits.
• Examples
– How much water can flow through a network of
pipes?
– How many cars can travel through a network of
streets?
33
3 4
2
6
6 2
4 2
4
3 5
5
Pumping Pumping
Station 2 Station 4
34
17
The Northwest Petroleum Company
Pumping Pumping
Station 1 Station 3
3 4
2
6
6 2
4 2
4
3 5
5
Pumping Pumping
Station 2 Station 4
35
36
18
Optimal Solution
Pumping Pumping
Station 1 Station 3
3
3 4
2
5
5 6
6 2 2
4 2
2
4 4
4
3 5
5
2
Pumping Pumping
Station 2 Station 4
37
−f + ∑x
j:( j ,t )∈ A
jt =0
∑x ij − ∑x ji =0 ∀i ∈ N − {s, t }
j:( i , j )∈ A j:( j ,i )∈ A
0 ≤ xij ≤ cij ∀ (i , j ) ∈ A 38
19
Notation
• An s-t cut is a partition (V,W) of the nodes of N
into sets V and W such that
s∈V, t∈W, V∪W=N, V∩W=∅
• The capacity of an s-t cut is
C (V , W ) = ∑c
( i , j )∈ A
ij
i∈V , j∈W
39
20
Augmenting path
• Given a feasible s-t flow x over the network
G=(N,A), an augmenting path P is a path from
s to t in the undirected graph resulting from G
by ignoring arc directions with the following
properties:
– For every arc (i,j)∈A that is traversed by P in the
forward direction (forward arc), we have xij<cij.
That is forward arcs of P are unsaturated.
– For every arc (j,i)∈A that is traversed by P in the
backward direction (forward arc), we have xji>0.
41
21
Finding an augmenting path
The labeling algorithm
• To each node i is assigned a two part label
λ(i)=(P(i),F(i)), where P(i) denotes the node
from where i was labeled and F(i) the amount
of extra flow that can be brought from s to i.
• There are two cases:
– If node j is unlabeled and succeeds i, then we may
label j if xij<cij, in which case we set
• P(j):=i and F(j):=min{F(i),cij − xij}
– If node j is unlabeled and precedes i, then we may
label j if xij>0, in which case we set
• P(j):= − i and F(j):=min{F(i),xij}
43
22
Finding an augmenting path
The labeling algorithm
45
46
23
Solving the Max Flow Problem
The Ford-Fulkerson algorithm
• Set x:=0; (Initialize the flow)
• Repeat
– Set all labels to zero;
– Set LIST:={s};
– While (LIST≠∅) and (t is unlabeled) do
• Let i be any node in LIST,
• Remove i from LIST and Scan i.
• If t is labeled then increase the flow along the augmenting
path of F(t)
Endwhile
Until t is unlabeled 47
24
The Northwest Petroleum Company
Pumping Pumping
Station 1 Station 3
3 4
2
6
6 2
4 2
4
3 5
5
Pumping Pumping
Station 2 Station 4
49
25
The Northwest Petroleum Company
• L:={1}; Extract 1; L:=∅; [3,3]
2 4
• Scan 1: [3,6] [0,2] [3,6]
– P(2)=1,F(2)=3,
– P(3)=1,F(3)=4; 1 6
– L:={2,3}; [0,2]
[0,4]
• Extract 2; L:={3}; [0,4]
3 [0,5] 5
• Scan 2:
– P(5)=2,F(5)=min{3,2}=2;
– L:={3,5};
• Extract 5; L:={3};
• Scan 5:
– P(6)=5,F(6)=min{2,6}=2;
• 6 is labeled, increase of F(6)=2 the flow along the
augmenting path 6←P(6)=5 ← P(5) = 2 ← P(2)=1.
51
26
The Northwest Petroleum Company
• L:={1}; Extract 1; L:=∅; [3,3]
2 4
• Scan 1: [5,6] [2,2] [3,6]
– P(2)=1,F(2)=1, P(3)=1,F(3)=2;
– L:={2,3}; 1 6
• Extract 3; L:= {2}; [0,2]
[2,4]
• Scan 3: [4,4]
3 [2,5] 5
– P(4)=3,F(4)=2;
– P(5)=3,F(5)=min{2,3}=2;
– L:={2,4,5}
• Extract 4; L:={2,5}
• Scan 4:
– P(6)=4,F(6)=min{2,6−3}=2;
• 6 is labeled, increase of F(6)=2 the flow along the augmenting
path 6←P(6)=4 ← P(4) = 3 ← P(3)=1.
53
27
The Northwest Petroleum Company
[3,3]
2 4
• L:={1}; Extract 1; L:=∅; [5,6] [2,2] [5,6]
• Scan 1:
1 6
– P(2)=1,F(2)=1;
[4,4] [2,2]
– L:={2}; [4,4]
3 [2,5] 5
• Extract 2; L:= ∅;
• Scan 2: No label.
• List empty!!!
55
[5,6] [5,6]
[2,2]
1 6
[2,2]
[4,4]
[4,4]
3 5
[2,5]
C*(V,W)=c13+c24+c25=9
f*=x12+x13=9
56
28
Lecture 5 3E4 Homework
1.a. Model the ACA’s shortest path problem to find the
quickest route (minimizing travel time).
1.b Model the ACA’s shortest path problem to find the
the most scenic route (maximizing the scenic
rating points)
1.c Solve (using Excel) either of these shortest path
problems.
57
58
29
The Compu-Train Company
• Compu-Train provides hands-on software training.
• Computers must be replaced at least every two years.
• Two lease contracts are being considered:
– Each required $62,000 initially
– Contract 1:
• Prices increase 6% per year
• 60% trade-in for 1 year old equipment
• 15% trade-in for 2 year old equipment
– Contract 2:
• Prices increase 2% per year
• 30% trade-in for 1 year old equipment
• 10% trade-in for 2 year old equipment
• Want to determine which contract would allow to minimize the
remaining leasing cost over the next five years and when, under
the selected contract, the equipment should be replaced. 59
60
30
Lecture 5 3E4 Homework 3
7
2 3
3
2
s 5 2 t
2
1
1 4
2
61
31