Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

1 Minimum Cost Flows

2 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 ij = amount shipped on arc (i,j) Minimize  (i,j)  A c ij x ij  j x ij -  k x ki = b i for all i  N. and 0  x ij  u ij for all (i,j)  A.

3 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 2 b(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

4 4 Find the Maximum Flow from s to t s 1 2 t 10, 8 8,7 1,1 10,6 6,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.

5 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?

6 6 A Network Representation Plants Warehouses 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 1 2 3 4 5 6 7

7 7 The Caterer Problem Demand for d i 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 567 2’ 3’ 4’ 5’6’7’ clean dirty 0 demand arcs a c b 1’

8 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 567 0 a clean napkins

9 9 Demand Arcs You must use d i napkins on day i 1 2 3 4 5670 lower bound on flows a dirty napkins 1’ d1d1 2’ d2d2 3’ d3d3 4’ 5’6’ d4d4 d5d5 d6d6 7’ d7d7

10 10 The rest of the arcs You may launder napkins in 2 days at b cents each 1 2 3 4 567 0 a 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.

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

12 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 6 1 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.

13 13 Overview of the solution procedure Reduced costs u recall replacing c ij –  i +  j for the shortest path problem. The same transformation is very useful for min cost flow algorithms. Optimality conditions u Most iterative optimization algorithms stop when “optimality conditions are satisfied”. We describe optimality conditions for the min cost flow problem.

14 14 Reduced Costs $3 12 3 $1 -$5 $3 –  1 +  2 12 3 $1 –  2 +  3 -$5 –  3 +  1 Let  i denote the node potential (or dual price) for node i. 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.

15 15 More on Using Reduced Costs Claim: For any feasible solution x, cx - c  x =  b. Thus a feasible flow x that minimizes cx will also minimize c  x. Proof:

16 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 c  ij > 0, then x ij = 0 3.If c  ij < 0, then x ij = u ij $3 12 -$5 34 If x,  satisfy (1) – (3), we say that x is an optimal flow, and  is an optimal set of node potentials.

17 17 Calculating A Spanning Tree Flow 1 36 4 5 27 1 3 -6 -4 1 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.

18 18 What would happen if the flows in non- tree arcs were not 0? 1 36 4 5 27 1 3 -6 -4 1 2 3 Suppose that non- tree arcs had a non- zero flow. How would this change the computations? 2 1 3

19 19 What would happen if the flows in non- tree arcs were not 0? 1 36 4 5 27 1 3 -6 -4 1 2 3 Adjust the supplies/demands. They will be interpreted as excesses and deficits. 2 1 3 0 4 2 6 The compute flows as in the previous method; e.g., what is the flow in (4,3)?

20 20 What would happen if the flow were negative? 1 36 4 5 27 1 3 -6 -4 1 2 3 If the direction of (4,3) were reversed, the flow in (3,4) would be negative. -2 3 64 43 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.

21 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, x ij = 0. For each (i,j)  U, x ij = u ij. 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.

22 22 Another way of calculating flows in arcs 1 36 4 5 27 1 3 -6 -4 1 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 x ij = 0.

23 23 Another way of calculating flows in arcs 1 36 4 5 27 1 3 -6 -4 1 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  j  S b(j).

24 24 Another way of calculating flows in arcs, general case 1 36 4 5 27 1 3 -6 -4 1 2 3 Deleting an arc (i,j) of T splits the nodes into two subsets, S and N-S. 2 1 3  j  S 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 x ij = 0 or u ij

25 25 Calculating Simplex Multipliers for a Spanning Tree 1 36 4 5 27 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 c ij -  i +  j = 0. 0 See the animation.

26 26 An alternative approach for calculating simplex multipliers 1 36 4 5 27 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 -c jk. 0 What is the simplex multiplier for node 6?

27 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 c  ij > 0, then x ij = 0 b. if c  ij < 0, then x ij = u ij 1 36 4 5 27 0 0 0 0 0 0 -4 What is the flow on arc (5,6) if arc (5,6) satisfies the optimality conditions?

28 28 Violating Arcs (T, L, U) : a spanning tree structure. x: basic feasible flow p : simplex multipliers. c  ij reduced costs A non-tree arc is a violating arc and eligible for entering the basis if i.c  ij < 0 and x ij = 0 or ii.c  ij > 0 and x ij = u ij.

29 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, T 1 and T 2 with the root node in T 1. Let d = |c  ij |. If i Î T 1, then add |c  ij | to each node v Î T 2. If i  T 2, then subtract d from each node in T 2.

30 30 The Steps for the network simplex 1. Select the entering arc. Key data structure: maintain the simplex multipliers O(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 T 2 obtained upon deleting the exiting arc from the current spanning tree. Update all multipliers in T 2. 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| + |T 2 |, and the major concern is the "proportion" or the "constant term."

31 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?

32 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.


Download ppt "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."

Similar presentations


Ads by Google