1 / 34

Maximum Flow Problem

Maximum Flow Problem. (Thanks to Jim Orlin & MIT OCW). The Max Flow Problem. G = (N,A) x ij = flow on arc (i,j) u ij = capacity of flow in arc (i,j) s = source node t = sink node. Maximize v Subject to S j x ij - S k x ki = 0 for each i  s,t

Télécharger la présentation

Maximum Flow Problem

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Maximum Flow Problem (Thanks to Jim Orlin & MIT OCW)

  2. The Max Flow Problem • G = (N,A) • xij = flow on arc (i,j) • uij = capacity of flow in arc (i,j) • s = source node • t = sink node Maximize v Subject to Sj xij - Sk xki= 0 for each i  s,t Sj xsj = v 0£ xij£ uij for all (i,j)ÎA.

  3. 1 8, 7 10 8 , 1, 1 s t 6, 5 10, 6 2 Maximum Flows • We refer to a flow x as maximum if it is feasible and maximizes v. Our objective in the max flow problem is to find a maximum flow. A max flow problem. Capacities and a non-optimum flow.

  4. warehouses warehouses retailers 6 1 6 5 6 2 7 7 4 3 8 6 5 4 9 5 4 5 The feasibility problem: find a feasible flow Is there a way of shipping from the warehouses to the retailers to satisfy demand?

  5. 6 6 5 6 6 5 7 7 s 4 4 t 5 6 6 5 4 5 5 4 Transformation to a max flow problem warehouses warehouses retailers 1 6 2 7 3 8 4 9 5 There is a 1-1 correspondence with flows from s to t with 24 units (why 24?) and feasible flows for the transportation problem.

  6. persons tasks 1 5 2 6 3 7 4 8 The feasibility problem: find a matching Is there a way of assigning persons to tasks so that each person is assigned a task, and each task has a person assigned to it?

  7. 1 1 1 1 1 1 1 s t 1 1 Transformation to a maximum flow problem persons tasks 5 2 6 3 7 4 8 Does the maximum flow from s to t have 4 units?

  8. 1 8, 7 10 8 , 1, 1 x s t i ij j u ij 6, 5 10, 6 2 u - x ij ij i j x 1 1 2 ij 8 7 1 s t 4 1 2 6 5 The Residual Network We let rij denote the residual capacity of arc (i,j) The Residual Network G(x)

  9. 1 1 2 8 7 1 s t 4 1 1 2 2 6 5 8 8 1 s t 4 2 6 6 A Useful Idea: Augmenting Paths • An augmenting path is a path from s to t in the residual network. • The residual capacity of the augmenting path P is d(P) = min{rij : (i,j)  P}. • To augment along P is to send d(P) units of flow along each arc of the path. We modify x and the residual capacities appropriately. • rij := rij - d(P) and rji := rji + d(P) for (i,j)  P.

  10. The Ford Fulkerson Maximum Flow Algorithm • Begin • x := 0; • create the residual network G(x); • while there is some directed path from s to t in G(x) do • begin • let P be a path from s to t in G(x); •  := d(P); • send  units of flow along P; • update the r's; • end • end {the flow x is now maximum}. Ford-Fulkerson Algorithm Animation

  11. Proof of Correctness of the Algorithm • Assume that all data are integral. • Lemma: At each iteration all residual capacities are integral. • Proof. It is true at the beginning. Assume it is true after the first k-1 augmentations, and consider augmentation k along path P. • The residual capacity D of P is the smallest residual capacity on P, which is integral. • After updating, we modify residual capacities by 0, or D, and thus residual capacities stay integral.

  12. Theorem. The Ford-Fulkerson Algorithm is finite • Proof. The capacity of each augmenting path is at least 1. • The augmentation reduces the residual capacity of some arc (s, j) and does not increase the residual capacity of (s, i) for any i. • So, the sum of the residual capacities of arcs out of s keeps decreasing, and is bounded below by 0. • Number of augmentations is O(nU), where U is the largest capacity in the network.

  13. 1 8, 8 10 9 , 1, 1 s t 6, 6 10, 7 2 reachable from s in G(x) 1 8 1 1 9 s t 3 6 7 not reachable from s in G(x) 2 How do we know when a flow is optimal? METHOD 1. There is no augmenting path in the residual network.

  14. 1 8, 8 10 9 , 1, 1 s t 6, 6 10, 7 2 Method 2: Cut Duality Theory An (s,t)-cut in a network G = (N,A) is a partition of N into two disjoint subsets S and T such that s  S and t  T, e.g., S = { s, 1 } and T = { 2, t }. The capacity of a cut (S,T) is CAP(S,T) = iSjTuij

  15. 1 8, 8 10 9 , 1, 1 s t 6, 6 10, 7 2 Weak Duality Theorem for the Max Flow Problem • Theorem.If x is any feasible flow and if (S,T) is an (s,t)-cut, then the flow v(x) from source to sink in x is at most CAP(S,T). • PROOF. We define the flow across the cut (S,T) to be • Fx(S,T) = iSjT xij - iSjT xji If S = {s}, then the flow across (S, T) is 9 + 6 = 15.

  16. 1 8, 8 10 9 , 1, 1 s t 6, 6 10, 7 2 1 8, 8 10 9 , 1, 1 s t 6, 6 10, 7 2 Flows Across Cuts If S = {s,1}, then the flow across (S, T) is 8+1+6 = 15. If S = {s,2}, then the flow across (S, T) is 9 + 7 - 1 = 15.

  17. i  S i  T j  T j  S i j i j xij -xij More on Flows Across Cuts • Claim:Let (S,T) be any s-t cut. Then Fx(S,T) = v = flow into t. • Proof. Add the conservation of flow constraints for each node i Î S - {s} to the constraint that the flow leaving s is v. The resulting equality is Fx(S,T) = v. Sj xij - Sk xki= 0 for each i  S\sSj xsj = v

  18. More on Flows Across Cuts • Claim: The flow across (S,T) is at most the capacity of a cut. • Proof. If i  S, and j  T, then xij  uij. If i  T, and j  S, then xij  0. Fx(S,T) = iSjT xij - iSjT xji Cap(S,T) = iSjT uij - iSjT 0

  19. Max Flow Min Cut Theorem • Theorem. (Optimality conditions for max flows). The following are equivalent. • 1. A flow x is maximum. • 2. There is no augmenting path in G(x). • 3. There is an s-t cutset (S, T) whose capacity is the flow value of x. • Corollary. (Max-flow Min-Cut). The maximum flow value is the minimum value of a cut. • Proof of Theorem. 1 Þ 2. (not 2 Þ not 1) • Suppose that there is an augmenting path in G(x). Then x is not maximum.

  20. Continuation of the proof. • 3 Þ 1. Let v = Fx(S, T) be the flow from s to t. By assumption, v = CAP(S, T). By weak duality, the maximum flow is at most CAP(S, T). Thus the flow is maximum. • 2 Þ 3. Suppose there is no augmenting path in G(x). • Claim: Let S be the set of nodes reachable from s in G(x). Let T = N\S. Then there is no arc in G(x) from S to T. • Thus i Î S and j Î T Þ xij = uij • i Î T and j Î S Þ xij = 0.

  21. 1 2 s t 3 4 Set S Set T Final steps of the proof • Thus i Î S and j Î T Þ xij = uij • i Î T and j Î S Þ xij = 0. There is no arc from S to T in G(x) x12 = u12 x43 = 0 If follows that Fx(S,T) = iSjT xij - iSjT xji = iSjT uij - iSjT 0 = CAP(S,T)

  22. Review • Corollary. If the capacities are finite integers, then the Ford-Fulkerson Augmenting Path Algorithm terminates in finite time with a maximum flow from s to t. • Corollary. If the capacities are finite rational numbers, then the Ford-Fulkerson Augmenting Path Algorithm terminates in finite time with a maximum flow from s to t. (why?) • Corollary. To obtain a minimum cut from a maximum flow x, let S denote all nodes reachable from s in G(x). • Remark. This does not establish finiteness if uij =  or if capacities may be irrational.

  23. 1 M M s t 1 M M 2 A simple and very bad example

  24. After 1 augmentation 1 M-1 M 1 s t 1 M-1 M 1 2

  25. After two augmentations 1 M-1 M-1 1 1 s t 1 M-1 M-1 1 1 2

  26. After 3 augmentations 1 M-2 M-1 2 1 s t 1 M-2 M-1 1 2 2

  27. And so on

  28. After 2M augmentations 1 M M s t 1 M M 2

  29. An even worse example • There are examples that takes an infinite number of augmentations on irrational data, and does not converge to the correct flow. • But we shall soon see how to solve max flows in a polynomial number of operations, even if data can be irrational.

  30. Summary and Extensions • 1. Augmenting path theorem • 2. Ford-Fulkerson Algorithm • 3. Duality Theory. • 4. Computational Speedups.

  31. Application 6.4 Scheduling on Uniform Parallel Machines Job(j) 1 2 3 4 Processing 1.5 3 4.5 5 Time Release 2 0 2 4 Time Due Date 5 4 7 9 Suppose there are 2 parallel machines 2 1 4 3 No schedule is possible unless preemption is allowed

  32. Application 6.4 Scheduling on Uniform Parallel Machines Job(j) 1 2 3 4 Processing 1.5 3 4.5 5 Time Release 2 0 2 4 Time Due Date 5 4 7 9 Suppose there are 2 parallel machines 2 1 4 3 4 3 A feasible schedule with preemption allowed

  33. 0-2 1 t s 2-4 4-5 5-7 7-9 Transformation into a maximum flow problem red arcs: the amount of processing of job j during t time units is at most t. green arcs: the amount of processing during t time units is at most Mt. 2 4 1.5 4 2 3 2 4.5 1 3 5 4 4 4 2 blue arcs: the amount of processing of job j over all time units is pj.

  34. 0-2 1 t s 2-4 4-5 5-7 7-9 A maximum flow There is a feasible schedule if there is a maximum flow that saturates each of the arcs out of s. 1 .5 4,2 1.5 2 1 4,4 2 3 2 4.5 2,2 .5 3 5 2 4,4 1 2 4 4,2 2 Flow decomposition can be used to transform flows into schedules

More Related