Upload
others
View
4
Download
1
Embed Size (px)
Citation preview
Minimum Cost Network Flow Problems
(MCNFP)
MCNFP:The most fundamental of all network flow problems.
Determine a least cost shipment of a commodity through a network in order to satisfy demands at certain nodes from available supplies at other nodes while respecting capacity constraints.
Examples: • distribution of a product from manufacturing plants to warehouses• flow of materials through the various stations in a production line• routing of calls through the telephone system
ns.restrictiocapacity obeying demands tosuppliers fromshipment cost least A :Find
E,j)(i,arceachforccostanducapacity
N,inodeeachforbsupplynetE),(N,GgraphdirectedA:Given
ijij
i
1
2
3
4
6, ∞ 13,40
5,102,50
-204,30
i jcij, uij
15
5
0bi bj
nodeenttransshipmaisi0,b
node)(sourcenodesupplyaisi0,b
node)(sinknodedemandaisi0,bif
N,inodeaFor
i
i
i
(3,4)}(2,4),(2,3),(1,3),{(1,2),E
{1,2,3,4}N
0b
Ni
i
Balanced Network
Transportation, assignment, shortest path and max flow problems are special cases of minimum cost network flow problem.
Ej)(i,ux0
Nibxx
s.t.
xcmin
:Model
E j)(i,each for j)(i,arconflowthex
:VariablesDecision
ijij
i
Ei)(j,:j
ji
Ej)(i,:j
ij
Ej)(i,
ijij
ij
MCNFP (Model):
Note: Typically, the shipped commodities are integer by nature, products, people etc. so we should require integrality of the decision variables and work with an IP. However, even if you remove the integrality requirements and solve it as an LP, each bfs will be an integer vector. This is a strong property of the constraint matrix and is called totally unimodularity.
Ej)(i,integer x
Ej)(i,ux0
Nibxx
s.t.
xcmin
ij
ijij
i
Ei)(j,:j
ji
Ej)(i,:j
ij
Ej)(i,
ijij
MCNFP Model: LP or IP?(Totally Unimodularity):
Formulation as an MCNFP
• Step 1: Form the network G=(N,E)
• Step 2: Provide b,c and u parameter values based on the problem requirements
• Step 3: Observe that sending flows in this network with minimum cost will solve the problem at hand
Example: The Assignment Problem (Recall from Set 2):
• There are n people and njobs to carry out.
• Each person is assigned to carry out exactly one job.
• If person i is assigned to job j, then the cost is cij .
Find an assignment of n
people to n jobs with
minimum total cost.
P1
P2
Pn
J1
J2
Jn
Example: The Assignment Problem (Recall from Set 2):
P1
P2
Pn
J1
J2
Jn
njni
jixij
,,2,1 ; ,,2,1
otherwise ,0
job toassigned is person ,1
Such variables are called
BINARY VARIABLES and offer
great flexibility in modeling.
They are ideal for YES/NO
decisions.
So how is the problem
formulated?
Example: The Assignment Problem (Recall from Set 2):
The problem is formulated as follows:
job) oneexactly toassigned is i(person n 1,...,i , 1x
s.t.
n
1j
ij
This is still an example of an IP problem since xij can only
take one of the two integer values 0 and 1.
xcmin ij
n
1i
n
1j
ij
n ... 1,j ...n; 1,i {0,1}, x
person) oneexactly toassigned is j (jobn 1,...,j , 1x
ij
n
1i
ij
Example: The Assignment Problem (Formulation as an MCNFP)
Step 2: Provide b,c and u parameter
values based on the problem requirements
}J,...,J,{J i1,b
}P,...,P,{P i1,b
n21i
n21i
}}J,...,J,{J j and }P,...,P,{Pi:j){(i,E
}J,...,J,J,P,...,P,{P N
n21n21
n21n21
Jn
P1
P2
Pn
J1
J2
Step 1: Form the network G=(N,E)
Step 3: Observe that sending flows in this network with minimum cost will solve the
assignment problem
j job toiperson ofcost assignmentgiven c
E, j)(i,
ij
1u
E, j)(i,
ij
Example: The Assignment Problem (Formulation as an MCNFP)
Step 2: Provide b,c and u parameter
values based on the problem requirements
}J,...,J,{J i1,b
}P,...,P,{P i1,b
n21i
n21i
}}J,...,J,{J j and }P,...,P,{Pi:j){(i,E
}J,...,J,J,P,...,P,{P N
n21n21
n21n21
Step 1: Form the network G=(N,E)
Step 3: Observe that sending flows in this network with minimum cost will solve the
assignment problem
j job toiperson ofcost assignmentgiven c
E, j)(i,
ij
1u
E, j)(i,
ij
Ej)(i,ux0
Nibxx
s.t.
xcmin
ijij
i
Ei)(j,:j
ji
Ej)(i,:j
ij
Aj)(i,
ijij
Example: Single pair shortest path problem
ttosfrom cost) totalminimum with arcs of sequence (apath shortest the :Find
E,j)(i,forccostsshipment unit
t,andsnodesdistinct two
E),(N,Ggraphdirecteda :Given
ij
Example: Find the shortest path from node 1 to node 6:
Observe: The optimal flow is to send one unit of flow along 1-2-5-6
How to formulate the single pair shortest path problem as MCNFP?
Recall: Formulation as an MCNFP
• Step 1: Form the network G=(N,E)
• Step 2: Provide b,c and u parameter values based on the problem requirements
• Step 3: Observe that sending flows in this network with minimum cost will solve the problem at hand
Example: Find the shortest path from node 1 to node 6:
Step 1: Form the network G=(N,E)
Step 3: Observe that sending flows in this network with minimum cost will
solve the single source shortest path problem
Step 2: Provide b,c and u parameter values based on the problem requirements
5} ..., {2, ifor ,0b
1,b
1,b
i
6
1
1u
cost shipment given c
E, j)(i,
ij
ij
t}{s,\N ifor ,0b1,b1,b :GeneralIn its
Example: Maximum Flow
.capacitiesexceedingwithoutttosfromsentbecanthatflowmaxThe:Find
E,j)(i,forucapcitiesarc
t,andsnodesdistinct two
E),(N,GgraphdirectedA:Given
ij
t tos from flow maximumv
E.j)(i,arconflow ofamountx
:VariablesDecision
ij
Ej)(i,ux0
t}{s,\N i allfor xx
x
x s.t.
max v
:Model
ijij
Ei)(j,:j
ji
Ej)(i,:j
ij
Et)(j,:j
jt
Ej)(s,:j
sj
v
v
3
S
2
4
3
6
5
7
t
3
5
2
1
8
4
3
7
22
10
Max flow as MCNF:
3
S=1
2
4
3
6
5
7
t=8
3
5
2
1
8
4
3
7
2
2
10
possible as large asit make try to weand vknownot do We
min max toconvert toNeed
Max flow as MCNF:
3
S=1
2
4
3
6
5
7
t=8
3
5
2
1
8
4
3
7
2
2
10
possibleasstotfromflowmuchassendwecost,minimizeTo
0costandcapacitiesowntheirhavearcsother
1.costandcapacitywiths)(t,arcadd
Niallfor 0b i
MCNFP in Matrix form:
Let c be the cost vectoru be the capacity vectorb be the demand vector
and x be the flow vector
A is the constraint matrix (corresponding to flow balance)
Then the MCNFP in matrix form is
ux
bAxts
xcT
0
..
min
Node-Arc Incidence Matrices:
Matrix A is called the node-arc incidence matrix.
Each row corresponds to a node and each column corresponds to an arc.
The only nonzero entries in each column are+1 in the row of the node the arc leaves (tail)
and -1 in the row of the node the arc enters (head)
i j
+1 -1
Ex: 2
4
1 3
1110104
1001003
0111012
0000111
)3,4()2,4()4,2()3,2()4,1()2,1(
A
(4,3)}(4,2),(2,4),(2,3),(1,4),{(1,2),E
i j
+1 -1
Ex:
110001
011100
100110
001011
A
1
43
2
i j
+1 -1
Upper Bounded Simplex:
Regular simplex:Look for a maximal set of linearly independent colums of A
(m since rank(A)=m). The variables corresponding to these colums are basic variables. The other variables are nonbasic and are set to zero.
Upper bounded simplex:Set n-m nonbasic variables to zero or to their upper bounds and solve for the remaining basic variables (solution will be unique).
ux0
bAxs.t.
xcmin T
A is an mxn matrix rank(A)=m.m basic, n-m nonbasic variables
Network Simplex:In simplex, we look for bases, maximal collections of linearly independent columns of matrix A.
Recall that columns of a node-arc incidence matrix correspond to arcs.
What collection of arcs correspond to linearly independent collections of colums?
Consider a cycle (not necessarily directed):
1
2
3
4
5
6
Network Simplex:In simplex, we look for bases, maximal collections of linearly independent columns of matrix A.
Recall that columns of a node-arc incidence matrix correspond to arcs.
What collection of arcs correspond to linearly independent collections of colums?
Consider a cycle (not necessarily directed):
1
2
3
4
5
6
Network Simplex:Colums corresponding to this cycle are
0
0
1
0
1
0
0
0
0
1
1
0
0
0
1
0
0
1
0
0
0
1
0
1
6
5
4
3
3
1
)3,1( )4,1( )3,2( )4,2(
1a 2a 3a 4a
dependentlinearlyarecolumstheseSo
0
0
0
0
0
0
1.a1.a1.a1.a
thatNotice
4321
1
2
3
4
5
6
Choose a cycle direction, forward arcs have +1 coefficient, backward arcs have -1
Columns for arcs of a cycle are linearly dependent.
Thus, a basis cannot correspond to a cycle and cannot contain a cycle.
Definitions: A graph is a tree if it is connected (there exists a path between every pair of nodes) and has no cycles.
A tree is a spanning tree of graph G=(N,E) if it touches every node of a graph G.
Every spanning tree of a graph on n nodes has |N|-1 edges.
Graph G
21
3 45
1 2
45
1 2
3 45
tree but not spanning for G
spanning tree of G
To form a spanning tree of a given graph:Start adding arcs arbitrarily as long as they don’t create cycles. When |N|-1 arcs are added, the resulting graph is a spanning tree of G.
To form a spanning tree of a given graph:Start adding arcs arbitrarily as long as they don’t create cycles. When |N|-1 arcs are added, the resulting graph is a spanning tree of G.
1 2
3 45
21
3 45
To form a spanning tree of a given graph:Start adding arcs arbitrarily as long as they don’t create cycles. When |N|-1 arcs are added, the resulting graph is a spanning tree of G.
1 2
3 45
Observation: Every pair of nodes in a tree is connected by a unique path (otherwise we have cycles)
Observation: Adding an arc to a spanning tree creates a unique cycle.
1 2
3 45
21
3 45
To form a spanning tree of a given graph:Start adding arcs arbitrarily as long as they don’t create cycles. When |N|-1 arcs are added, the resulting graph is a spanning tree of G.
1 2
3 45
Observation: Every pair of nodes in a tree is connected by a unique path (otherwise we have cycles)
Observation: Adding an arc to a spanning tree creates a unique cycle.
1 2
3 45
21
3 45
Theorem: A collection of columns in the node-arc incidence matrix of a MCNFP forms a basis if and only if corresponding arcs form a spanning tree of the associated directed graph.
tree.spanninga toscorrespondcolumsindepentlinearly1NofsetAny
vector)0rowsofsum(since1Nrank(A)Then
NEassumearcs,Enodes,Nb,Ax
E)(N,G
Basic Feasible Solutions:In basic solutions for network flow problems, nonbasic arcs have flow equal to 0 or equal to capacity uij .
Basic arcs have the unique flow achieving flow balance for the nonbasic values specified
The flow is basic feasible if all basic flows are within bounds.Example:
1 2
3 4
10
50
40 0
20
-10 30 -30
30 i j
biuij
bj
Basic Feasible Solutions:
Need 3 basic arcs and 2 nonbasic arcs.
For instance, let (1,4) be nonbasic at lower bound and (2,4) be nonbasic at upper bound. Basic arcs (1,2), (1,3) and (3,4) form spanning tree. So {(1,2),(1,3),(3,4)} is a basis.
With x14 = 0 and x24 = 0, the unique choice of basic values that meets the demand requirements at all nodes is x12 = 20, x13 = 20, x34 = 10
1 2
3 4
10,20
50, 20
40 0
20, 20
-1030, 10
-30
30,0 i juij, xij
401 2
3 4
10
50 20
-10 30 -30
30
0
This basic solution is not basic feasible
since flow x12 exceeds capacity u12.
Basic Feasible Solutions:
Now let (3,4) be nonbasic at lower bound and (1,2) be nonbasic at upper bound.
1 2
3 4
10,10
50, 10
40 0
20, 10
-10 30, 0 -30
30,20
{(1,3), (1,4), (2,4)} is a basis.
2424
1414
1313
20100
30200
50100
ux
ux
ux
So this corresponds to a basic feasible solution.
1 2
3 4
10
50 20
-10 30 -30
30
40 0
Network Simplex Iteration:
Choose a nonbasic arc. Either increase its value from lower bound or decrease it from upper bound.
Recall that basic arcs forms a spanning tree. Thus introducing any nonbasic arc creates a unique cycle.
How to find the network simplex direction?1) If xij = 0, only possible change is to increase flow.So the arc should be a forward arc (consistent with the direction of the cycle).
i j
Network Simplex Iteration:
i j
2) If xij = uij , only possible change is to decrease flow.So the arc should be a reverse arc (opposite to cycle direction).
Routing the same amount of flow on a cycle direction does not affect flow conservation
Increase forward arcs and decrease backward arcs by the same amount (This will be the ratio test!).
Network Simplex Iteration:
Ex:
1
2
3
4
6, ∞, 20 13,40,10
5,10,102,50,0
0
20 -20
0
4,30,10
i jcij, uij, xij
Basic arcs are (1,2), (2,4) and (2,3).Nonbasic arcs are (1,3) and (3,4).
If nonbasic arc (1,3) is introduced, as x13 = 0, its flow should be increased and it should be a forward arc.
Cost of current flow=340=6*20+4*10+13*10+5*10+2*0
Network Simplex Iteration:
1
2
3
Cycle direction is 1-3-2-1
Since improving, enter arc (1,3) to basis
negative) iscost in change (sincedirection improving
086)4(2
costs) arc rdsum(backwa- costs) arc dsum(forwarcostinchangeunit
1
2
3
4
6, ∞, 20 13,40,10
5,10,102,50,0
0
20 -20
0
4,30,10
Since a cycle is created, one of the arcs in the cycle should leave the basis (we must do a RATIO TEST)
Network Simplex Iteration:
1
2
3
arcs) backwardover decrease allowable maximum
arcs, forwardover increase allowable (maximum
min
λchange allowable maximum
TestRatio
Cycle direction is 1-3-2-1
1
2
3
4
6, ∞, 20 13,40,10
5,10,102,50,0
0
20 -20
0
10}10,50min{}}10,20min{),050min{min(
}{xmin},x{uminminλ ijB),(
ijijF),(
jiji
4,30,10
Arc (2,3) leaves!
Increase forward arcs, decrease backward arcs by 10
Network Simplex Iteration
New BFS (new tree):
1 -20
0
2
3
4
6, ∞, 10 13,40,10
5,10,102,50,10
0
20 4,30,0
If nonbasic arc (3,4) is introduced, as x34 = u34 , its flow should be decreased and it should be a reverse arc.
New cost =260=340-8x10
Is this bfs optimal?
Check each nonbasic arc
Network Simplex Iteration:
1
2
3
!improvingNot
01225136costinchange
Cycle direction is 1-2-4-3-1
How about arc (2,3). It must be a forward arc.
4
1
2
3
!OPTIMALSTOP
1
2
3
4
6, ∞, 20 13,40,10
5,10,102,50,0
0
20 -20
0
4,30,10
!improvingNot
08246costinchange
Finding a Starting Bfs (2 Phase method):Start with an artificial model where a bfs can be constructed easily.
Then apply network simplex to drive the artificial arcs out of the basis.
Add an artificial node, node 0, and artificial arcs as followsIf bi > 0 then add (i,0) with flow bi
If bi < 0 then add (0,i) with flow -bi
If bi = 0 then add (i,0) or (0,i) with flow 0
cij = 0 for all (i,j) ∈ Acij = 1 for all artificial arcs
uij = as given for original arcs
uij = ∞ for artificial arcs
xij =0 for original arcs
Finding a Starting Bfs (2 Phase method):Add an artificial node, node 0, and artificial arcs as follows
If bi > 0 then add (i,0) with flow bi
If bi < 0 then add (0,i) with flow -bi
If bi = 0 then add (i,0) or (0,i) with flow 0 cij = 0 for all (i,j) ∈ Ecij = 1 for all artificial arcsuij = as given for original arcs
uij = ∞ for artificial arcs
1
2
3
4
6, ∞ 13,40
5,102,50
-154,30
i jcij, uij
20
-5
0
Phase 1:
2
0
-15
Immediate bfs:
1
1
3
4
0,∞ 0,40
0,100,50
20 0,30
0
1,∞1,∞
1,∞1,∞
0
2
3
4
2010 x
020 x
503 x 1504 x
1
2
3
4
6, ∞
5,102,50
4,3020
-5
0
-15
13,40
If bi > 0 then add (i,0) with flow bi
If bi < 0 then add (0,i) with flow -bi
If bi = 0 then add (i,0) or (0,i) with flow 0
cij = 0 for all (i,j) ∈ E
cij = 1 for all artificial arcs
uij = as given for original arcs
uij = ∞ for artificial arcs
i jcij, uij
Phase 1:
2
0
-15
Immediate bfs:
1
1
3
4
0,∞ 0,40
0,100,50
20 0,30
0
1,∞1,∞
1,∞1,∞
0
2
3
4
2010 x
020 x
503 x 1504 x
1
2
3
4
6, ∞
5,102,50
4,3020
5
0
-15
13,40
i jcij, uij
Apply network simplex.Consider nonbasic arc (2,4). x24 =0 so it should be a forward arc.
So Improving and should enterRatio test
00)min(40,15,
}x,x),xmin{(uλ 20042424
So arc (2,0) should leave
02)11(0
)(costin change 042024
ccc
0
1
2
3
4
20
5 15
Consider nonbasic arc (1,3). It should be forward Change in cost=0-1-1=-2Improving.λ=5.Arc (0,3) leaves
0
Note: Once an artificial arc leaves, you can forget about it.It will not be beneficial to enter it.
0
1
2
3
4
15
5
15
0
0
1
2
3
4
20
5 15
Consider nonbasic arc (1,3). It should be forward Change in cost=0-1-1=-2Improving.λ=5.Arc (0,3) leaves
0
Note: Once an artificial arc leaves, you can forget about it.It will not be beneficial to enter it.
Arc (3,4). Forward Change in cost=0-1-1=-2
Arc (3,4) remains nonbasic (enters and leaves immediately)
0
1
2
3
4
15
5
15
0
015),15,15)}-(500),-min{(10
}x,x),x(u),xmin{(uλ 100413133434
0
1
2
3
415
5
5
Arc (1,2). ForwardChange in cost=0+0-1-1=-2λ=5.(0,4) or (1,0) becomes nonbasicSay, (0,4) leaves
0
10
0
1
2
3
415
5
5
Arc (1,2). ForwardChange in cost=0+0-1-1=-2λ=5.(0,4) or (1,0) becomes nonbasicSay, (0,4) leaves
0
0
1
2
3
4
0
15
5
0
One artificial arc left with zero flow Eliminate it as well as artificial node 0!
10
5
0
1
2
3
415
5
5
Arc (1,2). ForwardChange in cost=0+0-1-1=-2λ=5.(0,4) or (1,0) becomes nonbasicSay, (0,4) leaves
0
1
2
3
415
5
0
One artificial arc left with zero flow Eliminate it as well as artificial node 0!
10
5
1
2
3
4
6, ∞, 5 13,40,5
5,10,102,50,15
0
20 -154,30,0
i jcij, uij, xij
Phase 2:
-5
Is it optimal?
Consider nonbasic arc (2,3). It should be forward.Change in cost=4-2+6=8>0 not improving!
Consider nonbasic arc (3,4). It should be backward.Change in cost=-5-2+6+13=12>0 not improving!
Current solution is optimal!
Network Simplex Algorithm:Step 1: Choose a starting bfs x (Use 2-phase if necessary)
Step 2: If there is no nonbasic arc which improves the flow, STOP! x is optimal Else find a nonbasic arc which creates an improving cycle direction and compute λ. (RATIO TEST)
The chosen network simplex direction may have a step size λ=0 (degenerate basic step). But we change basis.
Step 3: Update x (increase flow on forward arcs by λ, decrease flow on reverse arcs by λ)
Step 4: One of the arcs which become binding (at upper or lower bound) leaves. (This might be the arc which has just entered)Go to step 2.