0% found this document useful (0 votes)
49 views31 pages

3E4 Lecture 5

The document discusses network flow problems that can be represented graphically. It describes three types of nodes in a network - supply, demand, and transshipment nodes. The document uses an example problem of distributing cars from import locations to various cities to illustrate defining decision variables, the objective function, and constraints for a transshipment problem modeled as a network flow problem. It also briefly describes the shortest path problem as a special case of a transshipment problem.

Uploaded by

Ke12Zed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views31 pages

3E4 Lecture 5

The document discusses network flow problems that can be represented graphically. It describes three types of nodes in a network - supply, demand, and transshipment nodes. The document uses an example problem of distributing cars from import locations to various cities to illustrate defining decision variables, the objective function, and constraints for a transshipment problem modeled as a network flow problem. It also briefly describes the shortest path problem as a special case of a transshipment problem.

Uploaded by

Ke12Zed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

3E4: Modelling Choice

Lecture 5

Network Flows Problems

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

Solutions to Lecture 1-3 Homework


• now available from
http://www.eng.cam.ac.uk/~dr241/3E4 2

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

Defining the Decision Variables


For each arc in a network flow model
we define a decision variable as:

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)

Note: The number of arcs determine the number of variables


in a network flow problem!

10

5
Defining the Objective Function
Minimize total shipping costs.

MIN: 30X12 + 40X14 + 50X23 + 35X35


+40X53 + 30X54 + 35X56 + 25X65
+ 50X74 + 45X75 + 50X76

11

Constraints for Network Flow Problems:


The Balance-of-Flow Rules

For Minimum Cost Network Apply This Balance-of-Flow


Flow Problems Where: Rule At Each Node:

Total Supply > Total Demand Inflow-Outflow >= Supply or Demand

Total Supply < Total Demand Inflow-Outflow <=Supply or Demand

Total Supply = Total Demand Inflow-Outflow = Supply or Demand

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!)

• This is equivalent to:


+X12 + X14 <= 200 13

Defining the Constraints


• Flow constraints
–X12 – X14 >= –200 } node 1
+X12 – X23 >= +100 } node 2
+X23 + X53 – X35 >= +60 } node 3
+ X14 + X54 + X74 >= +80 } node 4
+ X35 + X65 + X75 – X53 – X54 – X56 >= +170 } node 5
+ X56 + X76 – X65 >= +70 } node 6
–X74 – X75 – X76 >= –300 } node 7
• Nonnegativity conditions
Xij >= 0 for all (i,j)

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

The Shortest Path Problem


• Many decision problems boil down to
determining the shortest (or least costly) route
or path through a network.
– Ex. Emergency Vehicle Routing
• This is a special case of a transshipment
problem where:
– there is a supply node with a supply of –1
– there is a demand node with a demand of +1
– all other nodes have supply/demand of +0
16

8
The American Car Association

The ACA provides a service to its clients:


you provide your origin and destination
cities, then it determines the quickest way
(shortest path) for you to drive there.

17

The American Car Association


+0 3.3 hrs
L'burg 5 pts +1
9
Va Bch
5.0 hrs 11
9 pts 2.0 hrs
4 pts
4.7 hrs 2.7 hrs
+0 9 pts 4 pts
+0 1.1 hrs
K'ville 3 pts
5 2.0 hrs G'boro Raleigh
3.0 hrs
9 pts 4 pts 8
10 +0
1.7 hrs
5 pts
A'ville 1.5 hrs
6 +0 3 pts 2.3 hrs
+0 3 pts
Chatt. 2.8 hrs
3 7 pts
2.0 hrs Charl.
8 pts 7
1.7 hrs
+0
3.0 hrs
4 pts 4 pts
1.5 hrs
G'ville 2 pts
4
Atlanta +0
B'ham 2.5 hrs
2 3 pts
1 2.5 hrs
3 pts +0 18
-1

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

Transportation & Assignment Problems


• Some network flow problems don’t have trans-
shipment nodes; only supply and demand nodes.
• Groves assignment problem:
Processing
Groves Distances (in miles) Plants
Supply Capacity
Mt. Dora 21 Ocala
275,000 200,000
1 50 4
40

35
Eustis 30 Orlando
400,000 600,000
2 5
22

55
Clermont 20 Leesburg
300,000 225,000
3 25 6

• These problems are implemented more effectively using


the LP technique described in Lectures 2-3 20

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

An algorithm for the


Minimal spanning tree problem
1. Select any node and call this the current
subnetwork.
2. Add to the current subnetwork the cheapest arc,
and the corresponding node, that connect any
node within the network to any node not in the
current subnetwork. Call this the current
subnetwork.
3. If all nodes are in the subnetwork STOP, this is
the optimal solution. Otherwise return to step 2.
26

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

An algorithm for the


Minimal spanning tree problem
2. The cheapest arc is (5,6). The new subnetwork is
{1,5,6}.
3. Three nodes remain unconnected. Go to step 2.
4
2
£85 £75
£100
5
1
£85
£50
3 £90
6
28

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

An algorithm for the


Minimal spanning tree problem
2. The cheapest arc is (2,3). The new subnetwork is
{1,2,3,5,6}.
3. One node remains unconnected. Go to step 2.
4
2
£85 £75
£100
£40 5
1

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

An algorithm for the


Minimal spanning tree problem
The optimal solution:
4
2
£75
£40 5
1 £80

£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

The Northwest Petroleum Company


Pumping Pumping
Station 1 Station 3

3 4
2

6
6 2

1 Oil Field Refinery 6

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

1 Oil Field Refinery 6

4 2

4
3 5
5

Pumping Pumping
Station 2 Station 4
35

Formulation of the Max Flow Problem


MAX: X61
Subject to: +X61 - X12 - X13 = 0
+X12 - X24 - X25 = 0
+X13 - X34 - X35 = 0
+X24 + X34 - X46 = 0
+X25 + X35 - X56 = 0
+X46 + X56 - X61 = 0

with the following bounds on the decision variables:


0 <= X12 <= 6 0 <= X25 <= 2 0 <= X46 <= 6
0 <= X13 <= 4 0 <= X34 <= 2 0 <= X56 <= 4
0 <= X24 <= 3 0 <= X35 <= 5 0 <= X61 <= inf

36

18
Optimal Solution
Pumping Pumping
Station 1 Station 3
3
3 4
2
5
5 6
6 2 2

1 Oil Field Refinery 6

4 2
2
4 4
4
3 5
5
2
Pumping Pumping
Station 2 Station 4
37

Max Flow general formulation


Network G=(N,A)
N=set of nodes, A=set of (directed) arcs
s: source node, t: sink node, cij: capacity of arc (i,j)
f: value of an s-t flow
max f
s.t. f − ∑x
j :( s , j )∈ A
sj =0

−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

• We would expect that the value of an s-t flow


cannot exceed the capacity of an s-t cut

39

Max Flow – Min Cut Theorem


• The value f of any s-t flow is no greater than
the capacity C(V,W) of any s-t cut.
Furthermore, the value of the maximal flow
equals the capacity of the minimum cut, and
a flow f and a cut (V,W) are jointly optimal
if and only if
xij = 0 ∀(i, j ) ∈ A : i ∈ W , j ∈ V
xij = cij ∀(i, j ) ∈ A : i ∈ V , j ∈ W
40

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

Augmenting path (cont.)


• Remark: Given a feasible s-t flow x, we can increase
the flow from s to t (maintaining flow conservation)
by increasing the flow on every forward arc of P, and
decreasing it along every backward arc.
• The maximum amount of flow augmentation along P
is given by
⎧⎪cij − xij along a forward arc
δ = min ⎨
( i , j )∈P ⎪ x along a backward arc
⎩ ji
• Theorem: Given a feasible s-t flow x, with value f,
over the network G=(N,A), if there exists in G an
augmenting path from s to t, then the corresponding
flow value f is not maximal. 42

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

Finding an augmenting path


The labeling algorithm
• The process of labeling outward from a given node i is
called scanning i.
• The labeling algorithm amounts to look for an
augmenting path by scanning the nodes of the
network, starting from node s.
• In particular, a list containing all labeled but
unscanned nodes is kept.
• The list is initialized by adding s to it.
• At each iteration an element i is selected from the list
and scanned, and all nodes labeled from i are added to
the list. 44

22
Finding an augmenting path
The labeling algorithm

• The process terminates in one of two ways:


– Either t gets labeled, in which case we can
reconstruct an augmenting path backwards from t
using P(i)’s, and increase the current flow along the
augmenting path of F(t);
– Or the list is empty, then the flow is maximal (to be
proved later).

45

Solving the Max Flow Problem


The Ford-Fulkerson algorithm
• Set x:=0; (Initialize the flow)
• Find, if any, an augmenting path P and increase
the flow of
⎪⎧cij − xij along a forward arc
δ = min ⎨
( i , j )∈P ⎪ x along a backward arc
⎩ ji
• If there does not exist any augmenting path, then
terminate, the current flow is maximal.

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

The Ford-Fulkerson algorithm


Termination and optimality
• When the capacities are integers or rational numbers, the Ford-
Fulkerson labeling algorithm terminates after finitely many
iterations.
• Theorem: When the Ford-Fulkerson labeling algorithm terminates,
it does so at optimal flow.
• Proof: At termination of the algorithm, some nodes are labeled and
some are not (at least the sink node). Call the set of labeled nodes V
and the set of unlabeled nodes W. (V,W) is an s-t cut for the network
G. All arcs (i,j), with i∈V and j∈W, must be saturated, otherwise j
would have been labeled when i was scanned. Similarly, all arcs
(j,i), with i∈V and j∈W, must be empty, otherwise j would have
been labeled when i was scanned. Therefore, (V,W) is a min-cut,
and the flow is optimal due to the max flow-min cut theorem. 48

24
The Northwest Petroleum Company
Pumping Pumping
Station 1 Station 3

3 4
2

6
6 2

1 Oil Field Refinery 6

4 2

4
3 5
5

Pumping Pumping
Station 2 Station 4
49

The Northwest Petroleum Company


• L:={1}; Extract 1; L:=∅; [0,3]
2 4
• Scan 1: [0,6] [0,2] [0,6]
– P(2)=1,F(2)=6,
– 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(4)=2,F(4)=min{6,3}=3,
– P(5)=2,F(5)=min{6,2}=2;
– L:={3,4,5};
• Extract 4; L:={3,5};
• Scan 4:
– P(6)=4,F(6)=min{3,6}=3;
• 6 is labeled, increase of F(6)=3 the flow along the
augmenting path 6←P(6)=4 ← P(4) = 2 ← P(2)=1.
50

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

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)=4;
– L:={2,3}; 1 6
• Extract 2; L:={3}; Scan 2: No label. [0,2]
[0,4]
• Extract 3; L:= ∅; [2,4]
3 [0,5] 5
• Scan 3:
– P(4)=3,F(4)=min{4,2}=2; P(5)=3,F(5)=min{4,5}=5;
– L:={4,5}
• Extract 5; L:={4}
• Scan 5:
– P(6)=5,F(6)=min{5,4−2}=2;
• 6 is labeled, increase of F(6)=2 the flow along the augmenting
path 6←P(6)=5 ← P(5) = 3 ← P(3)=1.
52

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

The Northwest Petroleum Company


• L:={1}; Extract 1; L:=∅; [3,3]
2 4
• Scan 1: [5,6] [2,2] [5,6]
– P(2)=1,F(2)=1, P(3)=1,F(3)=2;
– L:={2,3}; 1 6
• Extract 3; L:= {2}; [2,2]
[4,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.
54

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

The Northwest Petroleum Company


V={1,2} [3,3] W={3,4,5,6}
2 4

[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

Lecture 5 3E4 Homework


2 The Equipment Replacement Problem
The problem of determining when to replace
equipment is a common business problem. It can
also be modeled as a shortest path problem.
2.a Model the following Compu-Train replacement
problem as a pair of shortest path problems,
comparing the two solutions.

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

Lecture 5 3E4 Homework


3.a
Given the network in the next slide, determine the
maximum flow that is possible to send from s to t
using the Ford-Fulkerson algorithm. Arc capacities are
showed in the picture along each arc.
3.b
Check the optimality of the solution using the max flow
– min cut theorem.
3.c
Solve the problem using Excel.

60

30
Lecture 5 3E4 Homework 3

7
2 3
3
2

s 5 2 t

2
1
1 4
2

61

31

You might also like