Network Models: Based On: "Operations Research: Applications and Algorithms" by Wayne L. Winston
Network Models: Based On: "Operations Research: Applications and Algorithms" by Wayne L. Winston
2 3 3
Shortest Path Problems
Assume that each arc in the network has a
length associated with it.
The problem of finding the shortest path from
node 1 to any other node in the network is
called a shortest path problem.
4
Assuming that all arc lengths are non-negative,
Dijkstra’s algorithm, can be used to find the
shortest path from a node.
Finding the shortest path between node i and
node j in a network may be viewed as a
transshipment problem.
The transshipment problem can then easily be
solved by using LINGO.
5
Shortest Path Problem
Consider the following flow network:
d26
2 6
d12 d36
d23
d13
1 3 d56
d35
d34
d14 d45
4 5
The objective is to find the shortest path from node 1 to node
n. The distance from node i to j, dij does not have to equal the
distance from node j to i, dji.
6
Shortest Path Problem
Dijkstra’s labeling algorithm: 9
2 6
3 6
2
7
1 3 3
3
1
4 3
Summary: Nodes are
4 5
permanently labeled or
temporarily labeled. All nodes that can be immediately reached from
permanently labeled nodes are temporarily labeled. The label is the minimum
of the sum of the distance from node 1 to the permanent node plus the distance
to the temporary node. Start with node 1 as the only permanently labeled
node. Find the temporarily labeled node with minimum distance. Make this
node permanent. Repeat this process until all nodes are permanently labeled.
7
Shortest Path Problem
Dijkstra’s labeling algorithm:
2 9 6
(3,1) ()
3 6
2
1 7 3
[0] (7,1)
3
1 3
4 4 3 5
(4,1) ()
[ ] – permanent label
(d,f) – temporary label; d – distance, f - from node
9
Shortest Path Problem
Dijkstra’s labeling algorithm:
2 9 6
[3,1] (12,2)
3 6
2
1 7 3
[0] (5,2)
3
1 3
4 4 3 5
[4,1] (7,4)
10
Shortest Path Problem
Dijkstra’s labeling algorithm:
2 9 6
[3,1] (11,3)
3 6
2
1 7 3
[0] [5,2]
3
1 3
4 4 3 5
[4,1] (7,4)
11
Shortest Path Problem
Dijkstra’s labeling algorithm:
2 9 6
[3,1] (10,5)
3 6
2
1 7 3
[0] [5,2]
3
1 3
4 4 3 5
[4,1] [7,4]
12
Shortest Path Problem
Dijkstra’s labeling algorithm:
2 9 6
[3,1] [10,5]
3 6
2
1 7 3
[0] [5,2]
3
1 3
4 4 3 5
[4,1] [7,4]
d14
d13
d35
16
Example 1: Solution
This problem should be formulated as a
shortest path problem.
The network will have six nodes.
Node i is the beginning of year i and for i<j, an arc
(i,j) corresponds to purchasing a new car at the
beginning of year i and keeping it until the beginning
of year j.
The length of arc (i,j) (call it cij) is the total net
cost incurred from year i to j.
cij = maintenance cost incurred during years i,i+1,…,j-1
+ cost of purchasing a car at the beginning of year i
- trade-in value received at the beginning of year j
17
Ex. 1 – Solution continued
Applying this formula to the information the
problem yields
c12=2+12-7=7 c16=2+4+5+9+12+12-0=44
c13=2+4+12-6=12 c23=2+12-7=7
c14=2+4+5+12-2=21 c24=2+4+12-6=12
c15=2+4+5+9+12-1=31
c25=2+4+5+12-2=21
c26=2+4+5+9+12-1=31 c45=2+12-7=7
c34=2+12-7=7 c46=2+4+12-6=12
c35=2+4+12-6=12 c56=2+12-7=7
c36=2+4+5+12-2=21
18
Ex. 1 – Solution continued
From the figure below we can see that both
path 1-3-5-6 and 1-2-4-6 will give us the
shortest path with a value of 31.
44
31 31
21 21
12
12
1 7
2 7
3 7
4 7
5 7
6
12 12
21
19
Example-2
A company sells seven types of boxes, ranging in volume from
17 to 33 cubic feet. The demand and size of each box is given
below
Box type: 1 2 3 4 5 6 7
Size: 33 30 26 24 19 18 17
Demand: 400 300 500 700 200 400 200
21
Maximal Flow Problem
The maximal flow problem is concerned with
determining the maximal volume of flow from
one node (called the source) to another node
(called the sink).
In the maximal flow problem, each arc has a
maximum arc flow capacity which limits the
flow through the arc.
22
Example: Maximal Flow
Network Model
3
2 5
3
4 2 3 2
Source 3 4 Sink
4 3
1 4 7
3 1
3 5 1 5
3 6
6
23
Example: Maximal Flow
A capacitated transshipment model can be
developed for the maximal flow problem.
We will add an arc from node 7 back to node 1
to represent the total flow through the
network.
There is no capacity on the newly added 7-1
arc.
We want to maximize the flow over the 7-1
arc.
24
Example: Maximal Flow
Modified Network Model
3
2 5
3
4 2 3 2
Source 3 4 Sink
4 3
1 4 7
3 1
3 5 1 5
3 6
6
25
Maximal Flow Problem
LP Formulation
(as Capacitated Transshipment Problem)
There is a variable for every arc.
There is a constraint for every node; the flow out
must equal the flow in.
There is a constraint for every arc (except the added
sink-to-source arc); arc capacity cannot be
exceeded.
The objective is to maximize the flow over the added,
sink-to-source arc.
26
Maximal Flow Problem
LP Formulation
(as Capacitated Transshipment Problem)
27
Example: Maximal Flow
LP Formulation
18 variables (for 17 original arcs and 1 added arc)
24 constraints
7 node flow-conservation constraints
17 arc capacity constraints (for original arcs)
28
Example: Maximal Flow
LP Formulation
Objective Function
Max x71
Node Flow-Conservation Constraints
x71 - x12 - x13 - x14 = 0 (flow in & out of node 1)
x12 + x42 + x52 – x24 - x25 = 0 (node 2)
x13 + x43 – x34 – x36 = 0 (etc.)
x14 + x24 + x34 + x54 + x64 – x42 - x43 - x45 - x46 - x47 = 0
x25 + x45 – x52 – x54 - x57 = 0
x36 + x46 - x64 - x67 = 0
x47 + x57 + x67 - x71 = 0
29
Example: Maximal Flow
LP Formulation (continued)
Arc Capacity Constraints
x12 < 4 x13 < 3 x14 < 4
x42 < 3 x43 < 5 x45 < 3 x46 < 1 x47 < 3
2
2 5
3 1 2
Source Sink
4 3
1 4 7
1
3 1 5
10 3 6
4
31
Example 3: Maximum Flow
Sunco Oil wants to ship the maximum possible
amount of oil (per hour) via pipeline from node
so to node si.
Arc Capacity
a0(2)
(so,1) 2
(0)3 (so,2) 3
(1,2) 3
so (2)2
1 (2)3
2 (2)2
si (1,3) 4
(3,si) 1
33
Ex. 3 – Solution continued
Let x0 be the flow through the artificial arc, the
conservation of flow implies that x0 = total amount of oil
entering the sink.
Sunco’s goal is to maximize x0.
Max Z= X0
S.t. Xso,1<=2 (Arc Capacity constraints)
Xso,2<=3
X12<=3
X2,si<=2
X13<=4
X3,si<=1
X0=Xso,1+Xso,2 (Node so flow constraints)
Xso,1=X12+X13 (Node 1 flow constraints)
Xso,2+X12=X2,si (Node 2 flow constraints)
X13+X3,si (Node 3 flow constraints)
X3,si+X2,si=X0 (Node si flow constraints)
Xij>=0
35
Choose any set of nodes V’ that contains the
sink but does not contain the source. Then the
set of arcs (i,j) with i not in V’ and j a member
of V’ is a cut for the network.
The capacity of a cut is the sum of the
capacities of the arcs in the cut.
The flow from source to sink for any feasible
flow is less than or equal to the capacity of any
cut.
If the sink cannot be labeled, then
Capacity of CUT = current flow from source to sink
36
Minimum Cost Network Flow
Problems
The transportation, assignment,
transshipment, shortest path, maximum flow,
and CPM problems are all special cases of
minimum cost network flow problems (MCNFP).
Any MCNFP can be solved by a generalization
of the transportation simplex called the
network simplex.
MCNFP can be written as
min c X
allarcs
ij ij
37
Constraints stipulate that the net flow out of
node i must equal bi and are referred to as the
flow balance equation.
Consider the following transportation problem
Supply point 1 Demand point 1
1 3 1 2 4 (Node 1)
3 4 5 (Node 2)
6 (Node 3) 3 (Node 4)
2 4
Supply point 2 Demand point 2
38
MCNFP representation of the problem
min Z=X13+2X14+3X23+4X24
1 1 0 0 = 4 Node 1
0 0 1 1 = 5 Node 2
-1 0 -1 0 = -6 Node 3
0 -1 0 -1 = -3 Node 4
39
The flow balance equations in any MCNFP have
this important property:
40
Assignment Problems
Time (Hours)
Machine 1 14 5 8 7
Machine 2 2 12 6 5
Machine 3 7 8 3 9
Machine 4 2 4 6 10
The Model
min Z 14 X 11 5 X 12 8 X 13 7 X 14 2 X 21 12 X 22 6 X 23 5 X 24
7 X 31 8 X 32 3 X 33 9 X 34 2 X 41 X 42 6 X 43 10 X 44
s.t. X 11 X 12 X 13 X 14 1
X 21 X 22 X 23 X 24 1
X 31 X 32 X 33 X 34 1
X 41 X 42 X 43 X 44 1
X 11 X 21 X 31 X 41 1
X 12 X 22 X 32 X 42 1
X 13 X 23 X 33 X 43 1
X 14 X 24 X 34 X 44 1
Xij 0orXij 1
For the model on the previous page note that:
Personnel Assignment:
Time (hours)
Job 1 Job 2 Job 3 Job 4
Person 1 14 5 8 7
Person 2 2 12 6 5
Person 3 7 8 3 9
Person 4 2 4 6 10
47
Assignment Problem Formulation
Define Variables:
Let Xij = 1 if ith person is assigned to jth job
Xij = 0 if ith person is not assigned to jth job
Objective Function:
Min z = 14*X11 + 5*X12 + … + 10*X44
Personnel Constraints: Demand Constraints:
X11 + X12 + X13 + X14 = 1 X11 + X21 + X31 + X41 = 1
X21 + X22 + X23 + X24 = 1 X12 + X22 + X32 + X42 = 1
X31 + X32 + X33 + X34 = 1 X13 + X23 + X33 + X43 = 1
X41 + X42 + X43 + X44 = 1 X14 + X24 + X34 + X44 = 1
Binary Constraints:
Xij = 0 or Xij = 1 48
Assignment Problem Algorithm
Row Minimum
14 5 8 7 5
2 12 6 5 2
7 8 3 9 3
2 4 6 10 2
Subtract Row Minimum from Each Row:
9 0 3 2
0 10 4 3
4 5 0 6
0 2 4 8
Column Minimum 0 0 0 2
49
Assignment Problem Algorithm
Subtract Column Minimum from Each Column:
9 0 3 0
0 10 4 1
4 5 0 4
0 2 4 6
Subtract Minimum uncrossed value from uncrossed values
and add to twice-crossed values:
Solution:
10 0 3 0 0
0 9 3 0 0
5 5 0 4 0
0 1 3 5 0
Draw lines to cross out zeros and read solution from zeros
50
Example - 1
Five men are available for doing five different jobs. From past
records, the time (in hours) that each man takes to do each
job is known and given in the following table:
Jobs
I II III IV V
A 4 11 4 9 3
B 8 10 9 8 3
C 6 8 7 5 3
Men D 6 4 9 5 3
E 7 5 11 7 3
Find the assignment of men to jobs that will minimize the total
time taken
51
Example - 2
Xo-Air has six flights arriving at IGI airport between 9.00 and 9.30
am. The same six airplanes depart on different flights between 9.40
am and 12.20 am. The average numbers of people transferring
between incoming and leaving flights appear below:
I02 17 15 33 12 8 6
I03 9 12 18 16 30 13
I04 12 8 11 27 19 14
I05 0 7 10 21 10 32
I06 0 0 0 6 11 13
52
Example - 2..
Flight I05 arrives too late to connect with L01,
similarly I06 is too late for flights L01, L02 and L03.
53
Example - 3
54
Example – 3…
Painter Bid
House A B C D
1 2.5 1.3 3.6 1.8
2 2.9 1.4 5.0 2.2
3 2.2 1.6 3.2 2.4
4 3.1 1.8 4.0 2.5
55
Minimum Spanning Tree
Problems
Suppose that each arc (i,j) in a network has a
length associated with it and that arc (i,j)
represents a way of connecting node i to node
j.
In many applications it must be determined
that the set of arcs in a network that connects
all nodes such that the sum of the length of the
arcs is minimized. Clearly, such a group of arcs
contain no loop.
For a network with n nodes, a spanning tree
is a group of n-1 arcs that connects all nodes of
the network and contains no loops.
56
A spanning tree of minimum length in a
network is a minimum spanning tree (MST).
The MST Algorithm may be used to find a
minimum spanning tree.
Begin at any node i, and join node i to the node in
the network (call it node j) that is closest to node i.
The two nodes i and j now form a connected set of
nodes C={i,j}, and arc (i,j) will be in the minimum
spanning tree. The remaining nodes in the network
(call them Ć) are referred to as the unconnected set
of nodes.
57
Now choose a member of C’ (call it n) that is closest
to set C. Let m represent the node in C that is closest
to n. Then the arc(m,n) will be in the minimum
spanning tree. Now update C and C’. Since n is now
connected to {i,j}, C now equals {i,j,n} and we must
eliminate node n from C’.
Repeat this process until a minimum spanning tree is
found. Ties for closest node and arc to be included in
the minimum spanning tree may be broken
arbitrarily.
58
Example: MST Algorithm
The State University campus has five
computers. The distances between each pair os
computers are given.
What is the minimum length of cable required
to interconnect the computers?
Note that if two computers are not connected this is
because of underground rock formations.
1 1 2
2 2
6 5
2 4 3
4 4
3
5
59
Example: Solution
We want to find the minimum spanning tree.
Iteration 1: Following the MST algorithm discussed
before, arbitrarily choose node 1 to begin. The
closest node is node 2. Now C={1,2}, Ć={3,4,5},
and arc(1,2) will be in the minimum spanning tree.
1 1
2
2
2
6
5 4
2 3
4
4
5 3 60
Ex. – Solution continued
Iteration 2: Node 5 is closest to C. since node 5
is two blocks from node 1 and node 2, we may
include either arc(2,5) or arc(1,5) in the
minimum spanning tree. We arbitrarily choose
to include arc(2,5). Then C={1,2,5} and
Ć={3,4}. 1 1
2
2
2
6
5 4
2 3
4
4
5 3 61
Ex.– Solution continued
Iteration 3: Since node 3 is two blocks from
node 5, we may include arc(5,3) in the
minimum spanning tree. Now C={1,2,5,3} and
Ć={4}.
1 1
2
2
2
6
5 4
2 3
4
4
5 3
62
Ex. – Solution continued
Iteration 4: Node 5 is the closest node to node
4. Thus, we add arc(5,4) to the minimum
spanning tree.
The minimum spanning tree consists of
arcs(1,2), (2,5), (5,3), and (5,4). The length of
the minimum spanning tree is 1+2+2+4=9
blocks. 1 1
2
2
2
6
5 4
2 3
4
4
5 3 63
Another Example : Minimal Spanning Tree
9
2 6
3 6
2
7
1 3 3
3
1
4 3
4 5
64
Minimal Spanning Tree
9
2 6
3
7
1 3
4 3
4 5
65
Minimal Spanning Tree
Possible applications:
• Phone lines between cities.
• Rail lines between cities.
• Road networks.
• Air conditioning ducts. 9
• etc.. 2 6
3
7
1 3
4 3
4 5
66
Minimal Spanning Tree
Algorithm:
67
Minimal Spanning Tree
9
2 6
3 6
2
7
1 3 3
3
1
4 3
4 5
68
Minimal Spanning Tree
9
2 6
3 6
2
1 3 3
3
1
4 3
4 5
69
Minimal Spanning Tree
9
2 6
3 6
2
1 3 3
3
1
3
4 5
70
Minimal Spanning Tree
9
2 6
3 6
2
1 3 3
1
3
4 5
71
Minimal Spanning Tree
2 6
3
2
1 3 3
1
3
4 5
(1,1)
2 4
(1,10) (2,3) (1,7)
1 (1,2) (10,1) 6
(5,7)
(10,3) (2,2)
3 5
(12,3)
Z* = Min c xij
( i , j ) A ij
1 if i = s
s. t. j xij j x ji 1 if i = t
0 otherwise
( i , j )A tij xij T Complicating constraint
75
Traveling salesman problem:
The integer programming formulation
1, if the salesman goes from node i to j during leg k
xijk
0, otherwise
Subject to constraints
x
j, j1
1 j1 1
x
i, i 1
i1n 1
n 1
x
i k 1
ijk 1, j 2,3,..., n; i j
n
x
j k 1
ijk 1, i 1,2,3,..., n; i j
76
Traveling salesman problem:
The integer programming formulation
Subject to constraints
N
x
i 1
ij 1 (for j 1,2,...N)
N
x
j 1
ij 1 (for i 1,2,...N)
n 1
x
i k 1
ijk 1, j 2,3,..., n; i j
78
Traveling salesman problem:
The nearest neighbor procedure
1. Start with a node at the beginning of the tour (the depot
node).
2. Find the node closest to the last node added to the tour.
3. Go back to step-2 until all nodes have been added.
4. Connect the first and the last nodes to form a complete tour.
Advantage:
1. Simple and gives a ‘near optimal’ solution
Disadvantage:
1. May not give a optimal solution
79
Traveling salesman problem:
The nearest neighbor procedure
From To node (distance in kilometers)
Node
A B C D E F
Best tour
A B E D C F A
The length of the tour 30.9 km
81
Traveling salesman problem:
The nearest neighbor procedure
83
The Vehicle routing problem
Cluster first, route second approach
84