You are on page 1of 15

Informatics and Mathematical Modelling / Operations Research

The Min Cost Flow Problem


Jesper Larsen & Jens Clausen
jla,jc@imm.dtu.dk

Informatics and Mathematical Modelling Technical University of Denmark

Jesper Larsen & Jens Clausen

Informatics and Mathematical Modelling / Operations Research

Min Cost Flow - Terminology


We consider a digraph G = (V (G), E (G)) in which each edge e has a capacity ue R+ and a unit transportation cost ce R. Each vertex v furthermore has a demand bv R. If bv 0 then v is called a sink, and if bv < 0 then v is called a source. We assume that b(V ) = vV bv = 0.

Jesper Larsen & Jens Clausen

Informatics and Mathematical Modelling / Operations Research

Min Cost Flow - Example


Cost Capacity

2 Capacity 5 10

3 Demand 5 8

1 1 15 1 15

15

5 Capacity 10 15

4 Demand 10 15

Jesper Larsen & Jens Clausen

Informatics and Mathematical Modelling / Operations Research

Min Cost Flow - Denition


The Min Cost Flow problem consists in supplying the sinks from the sources by a ow in the cheapest possible way: min
eE ce xe

fx (v ) = bv vV 0 xvw uvw (u, w) E where fx (v ) =


(w,v )E

xwv

(w,v )E

xvw .

Jesper Larsen & Jens Clausen

Informatics and Mathematical Modelling / Operations Research

Special cases
Numerous ow problems can be stated as a Min Cost Flow problem: 1. The Transportation Problem 2. The Shortest Path Problem 3. The Max Flow Problem

Jesper Larsen & Jens Clausen

Informatics and Mathematical Modelling / Operations Research

Min Cost Flow - Dual LP


The dual variables corresponding to the ow balance equations are denoted yv , v V , and those corresponding to the capacity constraints are denoted zvw , (v, w) E . The dual problem is now: max bv yv (v,w)E uvw zvw yv + yw zvw cvw (v, w) E cvw yv + yw zvw (v, w) E (v, w) E zvw 0
v V
6

Jesper Larsen & Jens Clausen

Informatics and Mathematical Modelling / Operations Research

c vw = cvw + yv yw is called the reduced cost for the edge (v, w), and hence cvw yv + yw zvw is equivalent to c vw zvw When is the set of feasible solutions x, y and z optimal?

Jesper Larsen & Jens Clausen

Informatics and Mathematical Modelling / Operations Research

Optimality Conditions I
If ue = + (i.e. no capacity constraints for e) e 0 just has to then ze must be 0 and hence c hold (primal optimality condition for the LP). If ue = + then ze 0 and ze c e must hold. z has negative coefcient in the objective function hence the best choice for z is as e }. Therefore, small as possible: ze = max{0, c the optimal value of ze is uniquely determined from the other variables, and ze is unnecessary in the dual problem.

Jesper Larsen & Jens Clausen

Informatics and Mathematical Modelling / Operations Research

Optimality Conditions I - Comp. Slackness


The complementary slackness conditions (each primal variable times the corresponding dual slack must equal 0, and each dual variable times the corresponding primal slack must equal 0 in optimum) now give: xvw > 0 c vw = zvw = max(0, c vw ) i.e. (xe > 0 c e 0) ( ce > 0 xe = 0) and ze > 0 x e = ue i.e. (c e > 0 xe = ue ) ( ce < 0 xe = ue )
Jesper Larsen & Jens Clausen 9

Informatics and Mathematical Modelling / Operations Research

Optimality Conditions II
Summing up: A primal feasible ow satisfying demands in sinks from sources respecting the capacity constraints is optimal if and only if we can nd a dual solution ye , e E such that for all e E it holds that: c e < 0 xe = ue (= ) c e > 0 xe = 0 All pairs (x, y ) of optimal solutions satisfy these conditions and so what?

Jesper Larsen & Jens Clausen

10

Informatics and Mathematical Modelling / Operations Research

Optimality Conditions III


For a legal ow x in G, the residual graph is (like for Max Flow) a graph, in which the paths indicate how ow excess can be moved in G given that the ow x already is present. The only difference is that each edge has a cost assigned.

Jesper Larsen & Jens Clausen

11

Informatics and Mathematical Modelling / Operations Research

Optimality Conditions - Residual Graph


The residual graph Gx for G wrt. x is dened by V (Gx ) = V (G) E (Gx ) = Ex = {(v, w) : (v, w) E xvw < uvw } {(v, w) : (w, v ) E xwv > 0}

Jesper Larsen & Jens Clausen

12

Informatics and Mathematical Modelling / Operations Research

The unit cost cvw for an edge with xvw < uvw is cvw , while cvw for an edge with xwv > 0 is cvw . Note that a dicircuit with negative cost in Gx corresponds to a negative cost circuit in G, if cost are added for forward edges and subtracted for backward edges. Note that if a set of potentials yv , v V are given, and the cost of a circuit wrt. the reduced costs for the edges ( cvw = cvw + yv yw ) are calculated, the cost remains the same as the original costs the potentials are telescoped to 0.
Jesper Larsen & Jens Clausen 13

Informatics and Mathematical Modelling / Operations Research

Min Cost Flow - Negative cost circuits


A primal feasible ow satisfying sink demands from sources and respecting the capacity constraints is optimal if and only if an x-augmenting circuit with negative c-cost (or negative c -cost there is no difference) does not exist. The is the idea behind the identication of optimal solutions in the network simplex algorithm.

Jesper Larsen & Jens Clausen

14

Informatics and Mathematical Modelling / Operations Research

Min Cost Flow - Network Simplex Algorithm


capacity=7 b 2 1,3,0 2,4,2 2 a demand=2 4,5,5 q capacity=1 a 4 1 4,3,0 1,6,1 4 1 q 1 b

p demand=6 (G,c,u,x)

(G x, c)

Jesper Larsen & Jens Clausen

15

You might also like