minimum cost flows. 2 the minimum cost flow problem u ij = capacity of arc (i,j). c ij = unit cost...

32
1 Minimum Cost Flows

Upload: brittany-patrick

Post on 31-Dec-2015

229 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x

1

Minimum Cost Flows

Page 2: Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x

2

The Minimum Cost Flow Problem

uij = capacity of arc (i,j).

cij = unit cost of shipping flow from node i to node j on (i,j).

xij = amount shipped on arc (i,j)

Minimize (i,j)A cijxij

j xij - k xki = bi for all i N.

and 0 xij uij for all (i,j) A.

Page 3: Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x

3

Find the shortest path from node 1 to node 6

1

2

3

4

5

6

2

4

2 1

3

4

2

3

2b(1) = 1 b(6) = -1

The optimal flow is to send one unit of flow along 1-2-5-6.

This transformation works so long as there are no negative cost cycles in G. (What if there are negative cost cycles?)

0 0

0 0

Page 4: Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x

4

Find the Maximum Flow from s to t

s

1

2

t

10, 8 8,7

1,1

10,66, 5

b(i) = 0 for all i;

add arc (t,s) with a cost of -1 and large capacity.

The cost of every other arc is 0.

13

The optimal solution in the corresponding minimum cost flow problem will send as much flow in (t,s) as possible.

Page 5: Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x

5

Transshipment Problems

Plants with given production capabilities for a product.

One can ship directly from the plants to retailers, or from plants to warehouses, and then from warehouses to retailers.

There is a given demand for each retailer.

Costs of shipment are given.

What is the minimum cost method for satisfying demands?

Page 6: Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x

6

A Network Representation

PlantsWarehouses

Retailers

1

2

3

4

5

6

7

190

310

100

400

180

Demands

1

2

3

4

5

6

7

400

1

2

3

4

5

6

7

400

1

2

3

4

5

6

7

Page 7: Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x

7

The Caterer Problem

Demand for di napkins on day i for i = 1 to 7 (so, j [1..7]).

Cost of new napkins: a cents each,

2-day laundry: b cents per napkin

1-day laundry: c cents per napkin.

Minimize the cost of meeting demand.

1 2 3 4 5 6 7

2’ 3’ 4’ 5’ 6’ 7’

clean

dirty

0

demand arcs

a

cb

1’

Page 8: Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x

8

Purchase arcs

In any period of the seven periods, one can purchase

napkins, at a cost of a cents per napkin.

1 2 3 4 5 6 7

0a

clean napkins

Page 9: Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x

9

Demand Arcs

You must use di napkins on day i

1 2 3 4 5 6 7

0

lower bound on flows

a

dirty napkins

1’

d1

2’

d2

3’

d3

4’ 5’ 6’

d4 d5 d6

7’

d7

Page 10: Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x

10

The rest of the arcs

You may launder napkins in 2 days at b cents each

1 2 3 4 5 6 7

0a

1’ 2’ 3’ 4’ 5’ 6’ 7’

b

You may launder napkins in 1 day at c cents each

c

You may store clean napkins for free

You may store dirty napkins for free Application to airplane maintenance.

Page 11: Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x

11

Some Assumptions

1. All data is integral. (Needed for some proofs,

and some running time analysis).

2. The network is directed.

3. i=1 to n b(i) = 0.

(Otherwise, there cannot be a feasible solution)

4. There is a feasible solution (see next slide)

Page 12: Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x

12

Artificial Solutions

Add an arc to d from each supply node, each with a large cost M, and a large capacity.

1

2

3

4

5

61

3 -4

3

-52

To create a feasible solution, add a dummy node d.

Add an arc from d to each demand node, each with a large cost M, and large capacity. d

In an optimal solution, arcs with large cost will have a flow of 0.

Page 13: Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x

13

Overview of the solution procedure

Reduced costs recall replacing cij – i + j for the shortest path

problem. The same transformation is very useful for min cost flow algorithms.

Optimality conditions Most iterative optimization algorithms stop when

“optimality conditions are satisfied”. We describe optimality conditions for the min cost flow problem.

Page 14: Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x

14

Reduced Costs

$31 2

3

$1-$5

$3 – 1 + 21 2

3

$1 – 2 + 3-$5 – 3 + 1

Let i denote the node potential (or dual price) for node i.

ij ij i jc c

For unit of flow out of node i, subtract i from the cost

For unit of flow into node j, add j to the cost.

Page 15: Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x

15

More on Using Reduced Costs

Claim: For any feasible solution x, cx - cx = b. Thus a feasible flow x that minimizes cx will also minimize cx.

( , )( )i j iji j A

cx c x x

Proof:

( )i ij jii j jx x

i iib b

Page 16: Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x

16

Optimality Conditions

Let x be a flow and let be a vector of node potentials.

The pair (x, ) is optimal if it satisfies the following:

1. x is a feasible flow

2. If cij > 0, then xij = 0

3. If cij < 0, then xij = uij

$31 2

-$53 4

If x, satisfy (1) – (3), we say that x is an optimal

flow, and is an optimal set of node potentials.

Page 17: Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x

17

Calculating A Spanning Tree Flow

1

3 6

4 5

2 7

1

3-6

-41

2 3

A tree with supplies and demands. (Assume that all other arcs have a flow of 0)

What is the flow in arc (4,3)?

See the animation.

Page 18: Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x

18

What would happen if the flows in non-tree arcs were not 0?

1

3 6

4 5

2 7

1

3-6

-4

1

23

Suppose that non-tree arcs had a non-zero flow. How would this change the computations?

2

1

3

Page 19: Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x

19

What would happen if the flows in non-tree arcs were not 0?

1

3 6

4 5

2 7

1

3-6

-4

1

23

Adjust the supplies/demands.

They will be interpreted as excesses and deficits.

2

1

3

04

2

6

The compute flows as in the previous method; e.g., what is the flow in (4,3)?

Page 20: Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x

20

What would happen if the flow were negative?

1

3 6

4 5

2 7

1

3

-6

-41

2 3

If the direction of (4,3) were reversed, the flow in (3,4) would be negative.

-2 3

6 4

4 3 A spanning tree flow is guaranteed to satisfy the supply/demand constraints. It may violate an upper or lower bound.

A spanning tree flow is called feasible if it satisfies its upper and lower bound. Otherwise, it is infeasible.

Page 21: Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x

21

Basic Flows

A basis structure consists of a spanning tree T, a set L of arcs, and a set U of arcs, such that T L U = A.

For each (i,j) L, xij = 0.

For each (i,j) U, xij = uij.

The arc flows in T are selected so that each node satisfies its supply/demand constraint.

The basis structure is feasible if the arc flows also satisfy the upper and lower bounds.

It is possible for a basis structure to be infeasible. In fact, this is normally the case in the dual simplex algorithm.

Page 22: Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x

22

Another way of calculating flows in arcs

1

3 6

4 5

2 7

1

3-6

-41

2 3

The total supply in subset S = (3,4,5) of nodes is 6. How can one satisfy the supply/demand constraints for S?

Case 1. If (i,j) is not in the tree, then xij = 0.

Page 23: Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x

23

Another way of calculating flows in arcs

1

3 6

4 5

2 7

1

3

-6

-41

2 3

Deleting an arc (i,j) of T splits the nodes into two subsets, S and N-S.

To compute the flow

in (i,j), compute jS

b(j).

Page 24: Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x

24

Another way of calculating flows in arcs, general case

1

3 6

4 5

2 7

1

3-6

-41

2 3

Deleting an arc (i,j) of T splits the nodes into two subsets, S and N-S.

2

1

3

jS b(j) - f(S, N-S).

To compute the flow in (i,j), compute

Let f(S, N-S) denote the flow across the cutset (S, N-S) from the non-tree arcs.

Case 2. If (i,j) is not in the tree, then xij = 0 or uij

Page 25: Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x

25

Calculating Simplex Multipliers for a Spanning Tree

1

3 6

4 5

2 7

5 -6

-2

-4

1

3

What is the node potential for node 2?

To calculate node potentials,

1. Let i = 0;

2. Choose other multipliers so that for each arc (i,j) in the tree cij - i + j = 0.

0

See the animation.

Page 26: Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x

26

An alternative approach for calculating simplex multipliers

1

3 6

4 5

2 7

5 -6

-2

-4

1

3

What is the simplex multiplier for node 4?

Let i be the cost of the path from node i to node 1 (the root node) in T. If (j,k) is backward, then use cost -cjk.

0

What is the simplex multiplier for node 6?

Page 27: Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x

27

Optimality Conditions (again)

Optimality Conditions for Spanning Tree Solutions: The following are conditions under which x is an optimal solution for the minimum cost flow problem and is optimal for the dual problem:

1. The basic flow x is feasible

2. is the vector of simplex multipliers.

3. For each non-tree arc (i,j)

a. if cij > 0, then xij = 0

b. if cij < 0, then xij = uij

1

3 6

4 5

2 7

0

0 0

00

0

-4What is the flow on arc (5,6) if arc (5,6) satisfies the optimality conditions?

Page 28: Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x

28

Violating Arcs

(T, L, U) : a spanning tree structure.

x: basic feasible flow

p : simplex multipliers.

cij reduced costs

A non-tree arc is a violating arc and eligible for entering the basis if

i. cij < 0 and xij = 0 or

ii. cij > 0 and xij = uij.

Page 29: Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x

29

The Network Simplex Pivot

1. Choose a violating non-tree arc. If no such arc exists, then the solution x is optimal.

2. Add (i,j) to T creating a unique cycle C. Send a maximum flow around C while maintaining feasibility. Suppose the exiting arc is (p,q).

3. Update the multipliers so that the reduced costs of all tree arcs are 0 after the pivot.

T-(p,q) partitions into two subtrees, T1 and T2 with the root node in T1. Let d = |c

ij|. If i Î T1, then add |c

ij| to each node v Î T2. If i T2, then subtract d from each node in T2.

Page 30: Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x

30

The Steps for the network simplex

1. Select the entering arc. Key data structure: maintain the simplex multipliersO(1) step to determine if (i,j) is violating.

2. Determine the basic cycle C. Determine the flow around the basic cycle. Send the flow.

3. Determine the subtree T2 obtained upon deleting the exiting arc from the current spanning tree. Update all multipliers in T2.

Fact: Lots of computational work was done in trying to figure out how to do steps 2 and 3 efficiently. For many choices of data structures, the running time to be proportional to |C| + |T2|, and the major concern is the "proportion" or the "constant term."

Page 31: Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x

31

Some Remaining Issues

How can we avoid cycling in the simplex method? (Or what do we do if the amount of flow sent around a cycle is 0).

What is the worst case performance of the simplex method?

What are some good heuristics to speed up performance in practice?

Page 32: Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x

32

Summary

1. Network simplex is extremely fast in practice.

2. Relying on network data structures, rather than matrix algebra, causes the speedups. It leads to simple rules for selecting the entering and exiting variables.

3. Running time per pivot :

(i) arcs scanned to identify an entering arc

(ii) arcs scanned of the basic cycle

(iii) nodes of the subtree

4. A good pivot rule can dramatically reduce running time in practice.