* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Network Simplex Method I
Survey
Document related concepts
Transcript
OR 215 Network Flows Spring 1999 M. Hartmann NETWORK SIMPLEX METHOD I Basic (Spanning Tree) Solutions Optimality Conditions Simplex Multipliers The Network Simplex Pivot Maintaining the Tree Structure THE NETWORK SIMPLEX ALGORITHM 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 (lower bound arcs) for each (i,j) U, xij = uij (upper bound arcs) The arc flows in T are selected so that each node satisfies its supply/demand constraint. (This selection may violate upper and lower bound constraints.) minimize cijxij subject to j xij - k xki 0 xij uij = bi for all i N for all (i,j) A A basis structure is said to be feasible if the arc flows in T are selected to satisfy supply/demand constraints and they also satisfy the upper and lower bound constraints. BASIC SOLUTIONS If x is a feasible flow, an arc (i,j) is a free arc if 0 < xij < uij and a restricted arc if xij = 0 or xij = uij. Theorem: If a minimum cost flow problem has an optimal solution, then it has an optimal solution represented by a basis structure (T,L,U). Proof: Let x be an optimal solution for which the set F(x) of free arcs is minimal. If F(x) contains an undirected cycle C, then let W be a directed cycle in G(x) corresponding to C which contains the reversal of an arc in C. Then W must be a zero-cost cycle (why?) and augmenting along W gives another optimal solution, which contradicts the minimality of F(x). Since F(x) contains no cycles, it is a forest, and T can be any spanning tree containing F(x). HOW TO CALCULATE FLOWS For each non-tree arc (i,j) either xij = 0 and (i,j) L or else xij = uij and (i,j) U . e(1) = 1 e(2) = -6 e(3) = 1 e(4) = 2 4 1 2 3 7 6 5 e(7) = 3 e(6) = -4 e(5) = 3 Method 1: Calculate flows iteratively starting at leaves and working upwards. Method 2: Calculating flows directly (conceptually useful but not necessarily practical.) To calculate the flow in arc (i,j), first let S be the part of T \ {(i,j)} containing i. Then let the flow in arc (i,j) be the net supply in S. Example: What is the flow in arc (3,2)? OPTIMALITY CONDITIONS II Recall: The reduced cost of arc (i,j) is c ij = cij - i + j. Theorem: The solution represented by a basis structure (T,L,U) is an optimal solution if it is feasible and for some choice of node potentials , the reduced costs satisfy: c ij = 0 for (i,j) T, c ij 0 for (i,j) L, c ij 0 for (i,j) U. Proof: This implies that c ij 0 for all (i,j) in G(x). Here is the vector of simplex multipliers associated with the equality constraints of the minimum cost flow problem: minimize cijxij subject to j xij - k xki 0 xij uij = bi for all i N for all (i,j) A SIMPLEX MULTIPLIERS We choose multipliers so that c ij = 0 for each (i,j) in T. Recall: There is a redundant constraint so one of the simplex multipliers can be chosen arbitrarily (say 1 = 0). 1 -6 5 2 3 3 -2 4 -4 7 6 1 5 An iterative approach: Set 1 = 0, choose 2 so that c12 = 0, choose 3 so that c 32 = 0, etc. Rule: Always select an arc (i,j) for which either i or j is known. Setting c ij = 0 will fix the other value of . An alternate approach: Let (i) denote the cost of disposing one unit of flow at node i (sending it to the root node.) (i) is the cost of the path from i to the root. (i) = cij + (j) for each arc (i,j) in the tree. Then let j = (j) so that cij i + j = 0 for (i,j) in the tree. 1 -6 5 2 3 3 -2 4 -4 6 1 5 7 THE NETWORK SIMPLEX PIVOT Suppose that T is a rooted spanning tree and let x be the basic (feasible) solution associated with T. Let be the vector of simplex multipliers and let c ij = cij i + j. A non-tree arc is a violating arc for entering if i. c ij < 0 and xij = 0 or ii. c ij > 0 and xij = uij. 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 “directed” circuit C. i. Orient C in the appropriate direction. [ If xij = 0, then orient C in the direction of (i,j). Otherwise orient C in the direction of (j,i).] xij = 0 i j ii. Let = min { min { ukl-xkl : (k,l) is forward on C }, min { xkl : (k,l) is backward on C } } Send units of flow in cycle C. Pivot out an arc (p,q) whose flow increases to upq or decreases to 0, obtaining a new tree T'; iii. T \ (p,q) partitions into two subtrees, T1 and T2 with the root node in T1. Let = | c ij |. [Update so that c ij = 0 for (i,j) T.] If i T1, then add to each node v T2. If i T2, then subtract from each node in T2. MAINTAINING THE TREE STRUCTURE Comment: The data structures that you will see are not the only ones that are appropriate. They are data structures that have worked well in practice. 1. Hang the tree from a root node. 2. For each node, store pred(i), the parent of i in the tree. 3. For each node i store the depth(i), the number of arcs on the path from i to the root. 4. For each node i, store a pointer to the next node on the depth first search ordering of T. This data structure is called the thread. 1 2 3 7 6 4 5 Note: These three data structures used in conjunction are excellent for finding sub-trees and for locating circuits. Note: Updating these data structures requires a lot of bookkeeping, but it's fast. node i pred(i) depth(i) thread(i) 1 2 3 4 5 6 7 FINDING THE CYCLE Suppose that arc (k,l) enters the basis. procedure IDENTIFY CYCLE; begin set i := k and j := l; while i j do begin if depth(i) > depth(j) then i := pred(i) else if depth(j) > depth(i) then j := pred(j) else i := pred(i) and j := pred(j); end; set w := i; end This subroutine locates the least common ancestor w of k and l. We could simulataneously locate the arc that drops out as well as the change in the flows. UPDATING THE MULTIPLIERS Suppose that (i,j) is pivoted in and (p,q) is pivoted out. (Assume for now that xij = 0 before the pivot.) Let T1 be the subtree of T \ (p,q) containing the root node 1 and T2 = [T \ (p,q)] \ T1 be the other subtree. procedure UPDATE POTENTIALS; begin if i T2 then = -| c ij | else if j T2 then = | c ij |; for each i T2, add to i; end Note: Use the thread and depth indices to identify T2. 1 2 7 T2 3 4 6 5 EXAMPLE OF A MIN-COST FLOW PROBLEM b(1) = 2 1 1 4, $1 b(4) = -4 2, $4 4 4, $2 3, $5 2 3, $4 3 1 4, $2 1, $4 5 5, $5 b(2) = 5 b(5) = -3 The minimum cost flow problem b(1) = 2 1 1 0 1 4 1 2 2 b(2) = 5 b(4) = -4 3 3 1 3 0 0 5 b(5) = -3 The initial spanning tree solution (1) = 0 1 1 (4) = -4 $4 4 $2 $5 2 3 1 (3) = -2 5 $5 (2) = 3 The initial simplex multipliers (5) = -3 (1) = 0 (4) = -4 1 1 4 $2 -$2 3 1 Reduced costs for the initial spanning tree (3) = -2 $4 2 5 (2) = 3 (5) = -3 1 1 4 0, 4 2 1, 4 2, 3 The fundamental cycle 3 1 5 1 1 1 2 4 3 0 2 3 1 0 0 The second spanning tree solution. 5 3 (1) = 0 1 1 3 (4) = -4 $4 4 $2 $1 3 1 2 (3) = -2 5 $5 (2) = 1 The second simplex multipliers (5) = -4 (1) = 0 (4) = -4 1 1 4 $2 $2 3 1 Reduced costs for the second spanning tree (3) = -2 $4 2 5 (2) = 1 (5) = -4 1, 2 1 1 4 3, 4 3, 3 The fundamental cycle 3 1 2 5 2 1 1 2 4 2 0 2 2 3 1 0 5 3 (1) = 0 1 1 $1 2 (2) = 1 0 The third spanning tree solution. (4) = -6 4 $4 $2 3 1 $5 The third simplex multipliers (3) = -2 5 (5) = -4 SOME REMAINING ISSUES 1. How can we avoid cycling in the simplex method? 2. What is the worst case performance of the simplex method? 3. What are some good heuristics to speed up performance in practice? 4. Is there a good way of doing sensitivity analysis?