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

Slides:



Advertisements
Similar presentations
COMP 482: Design and Analysis of Algorithms
Advertisements

Max Flow Problem Given network N=(V,A), two nodes s,t of V, and capacities on the arcs: uij is the capacity on arc (i,j). Find non-negative flow fij for.
15.082J & 6.855J & ESD.78J October 14, 2010 Maximum Flows 2.
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
1 Maximum flow sender receiver Capacity constraint Lecture 6: Jan 25.
Chapter 6 Maximum Flow Problems Flows and Cuts Augmenting Path Algorithm.
Network Optimization Models: Maximum Flow Problems
MAXIMUM FLOW Max-Flow Min-Cut Theorem (Ford Fukerson’s Algorithm)
Prof. Swarat Chaudhuri COMP 482: Design and Analysis of Algorithms Spring 2012 Lecture 19.
1 Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
1 Maximum Flow Networks Suppose G = (V, E) is a directed network. Each edge (i,j) in E has an associated ‘capacity’ u ij. Goal: Determine the maximum amount.
1 Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Chapter 7 Maximum Flows: Polynomial Algorithms
1 COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf.
Network Optimization Models: Maximum Flow Problems In this handout: The problem statement Solving by linear programming Augmenting path algorithm.
3 t s the black numbers next to an arc is its capacity.
The max flow problem
Yangjun Chen 1 Network Flow What is a network? Flow network and flows Ford-Fulkerson method - Residual networks - Augmenting paths - Cuts of flow networks.
Maximum Flows Lecture 4: Jan 19. Network transmission Given a directed graph G A source node s A sink node t Goal: To send as much information from s.
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
15.082J and 6.855J and ESD.78J November 2, 2010 Network Flow Duality and Applications of Network Flows.
CS774. Markov Random Field : Theory and Application Lecture 13 Kyomin Jung KAIST Oct
Yangjun Chen 1 Network Flow What is a network? Flow network and flows Ford-Fulkerson method - Residual networks - Augmenting paths - Cuts of flow networks.
1 COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf.
10. Lecture WS 2006/07Bioinformatics III1 V10: Network Flows V10 follows closely chapter 12.1 in on „Flows and Cuts in Networks and Chapter 12.2 on “Solving.
Max flows in O(nm) time, and sometimes less. by James B. Orlin MIT Sloan School.
Max Flow – Min Cut Problem. Directed Graph Applications Shortest Path Problem (Shortest path from one point to another) Max Flow problems (Maximum material.
Maximum Flow Chapter 26. Flow Concepts Source vertex s – where material is produced Sink vertex t – where material is consumed For all other vertices.
The Ford-Fulkerson Augmenting Path Algorithm for the Maximum Flow Problem Thanks to Jim Orlin & MIT OCW.
CS223 Advanced Data Structures and Algorithms 1 Maximum Flow Neil Tang 3/30/2010.
Chapter 7 April 28 Network Flow.
15.082J & 6.855J & ESD.78J October 7, 2010 Introduction to Maximum Flows.
15.082J and 6.855J March 4, 2003 Introduction to Maximum Flows.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 25.
15.082J and 6.855J and ESD.78J The Successive Shortest Path Algorithm and the Capacity Scaling Algorithm for the Minimum Cost Flow Problem.
and 6.855J March 6, 2003 Maximum Flows 2. 2 Network Reliability u Communication Network u What is the maximum number of arc disjoint paths from.
Chapter 7 May 3 Ford-Fulkerson algorithm Step-by-step walk through of an example Worst-case number of augmentations Edmunds-Karp modification Time complexity.
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
Exercise 6.1 Find the number of different shortest paths from point A to point B in a city with perfectly horizontal streets and vertical avenues as shown.
CSEP 521 Applied Algorithms Richard Anderson Lecture 8 Network Flow.
1 Network Flow CSC401 – Analysis of Algorithms Chapter 8 Network Flow Objectives: Flow networks –Flow –Cut Maximum flow –Augmenting path –Maximum flow.
Fall 2003Maximum Flow1 w s v u t z 3/33/3 1/91/9 1/11/1 3/33/3 4/74/7 4/64/6 3/53/5 1/11/1 3/53/5 2/22/2 
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
Theory of Computing Lecture 12 MAS 714 Hartmut Klauck.
1 Maximum Flows CONTENTS Introduction to Maximum Flows (Section 6.1) Introduction to Minimum Cuts (Section 6.1) Applications of Maximum Flows (Section.
Minimum Cost Flow Algorithms and Networks. Algorithms and Networks: Minimum Cost Flow2 This lecture The minimum cost flow problem: statement and applications.
TU/e Algorithms (2IL15) – Lecture 8 1 MAXIMUM FLOW (part II)
CS4234 Optimiz(s)ation Algorithms
Richard Anderson Lecture 23 Network Flow
Lecture 22 Network Flow, Part 2
Max Flow – Min Cut Problem
James B. Orlin Presented by Tal Kaminker
Instructor: Shengyu Zhang
Introduction to Maximum Flows
Richard Anderson Lecture 23 Network Flow
Richard Anderson Lecture 23 Network Flow
Richard Anderson Lecture 21 Network Flow
Max Flow Min Cut, Bipartite Matching Yin Tat Lee
Max Flow Problem Given network N=(V,A), two nodes s,t of V, and capacities on the arcs: uij is the capacity on arc (i,j). Find non-negative flow fij for.
Algorithms (2IL15) – Lecture 7
EE5900 Advanced Embedded System For Smart Infrastructure
and 6.855J March 6, 2003 Maximum Flows 2
Lecture 21 Network Flow, Part 1
The Ford-Fulkerson Algorithm
Introduction to Maximum Flows
Richard Anderson Lecture 22 Network Flow
Lecture 21 Network Flow, Part 1
Maximum Flow Neil Tang 4/8/2008
Lecture 22 Network Flow, Part 2
Introduction to Maximum Flows
Presentation transcript:

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

2 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 Maximizev Subject to  j x ij -  k x ki = 0 for each i  s,t  j x sj = v 0  x ij  u ij for all (i,j)  A.

3 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. s 1 2 t 10, 8 8,7 1,1 10,6 6,5 A max flow problem. Capacities and a non- optimum flow.

4 The feasibility problem: find a feasible flow retailers warehouses Is there a way of shipping from the warehouses to the retailers to satisfy demand?

5 Transformation to a max flow problem warehouses retailers There is a 1-1 correspondence with flows from s to t with 24 units (why 24?) and feasible flows for the transportation problem s t

6 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? personstasks

7 Transformation to a maximum flow problem Does the maximum flow from s to t have 4 units? personstasks s t

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

9 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  (P) = min{r ij : (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. r ij := r ij -  (P) and r ji := r ji +  (P) for (i,j)  P. s 1 2 t s 1 2 t

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);  :=  (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  of P is the smallest residual capacity on P, which is integral. After updating, we modify residual capacities by 0, or , 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 How do we know when a flow is optimal? s 1 2 t 10, 9 8,8 1,1 10,7 6,6 METHOD 1. There is no augmenting path in the residual network. s 1 2 t reachable from s in G(x) not reachable from s in G(x)

14 Method 2: Cut Duality Theory s 1 2 t 10, 9 8,8 1,1 10,7 6,6 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  T u ij

15 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 F x (S,T) =  i  S  j  T x ij -  i  S  j  T x ji s 1 2 t 10, 9 8,8 1,1 10,7 6,6 If S = {s}, then the flow across (S, T) is = 15.

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

17 More on Flows Across Cuts Claim: Let (S,T) be any s-t cut. Then F x (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 F x (S,T) = v.  j x ij -  k x ki = 0 for each i  S\s  j x sj = v ij i  S j  T x ij ij i  T j  S -x ij

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 x ij  u ij. If i  T, and j  S, then x ij  0. F x (S,T) =  i  S  j  T x ij -  i  S  j  T x ji Cap(S,T) =  i  S  j  T u ij -  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 = F x (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  x ij = u ij i  T and j  S  x ij = 0.

21 Final steps of the proof Thus i  S and j  T  x ij = u ij i  T and j  S  x ij = 0. x 12 = u 12 x 43 = 0 If follows that F x (S,T) =  i  S  j  T x ij -  i  S  j  T x ji =  i  S  j  T u ij -  i  S  j  T 0 = CAP(S,T) Set S Set T st There is no arc from S to T in G(x)

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 u ij =  or if capacities may be irrational.

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

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

25 After two augmentations s 1 2 t M

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

27 And so on

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

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)1234 Processing Time Release Time 2024 Due Date5479 Suppose there are 2 parallel machines No schedule is possible unless preemption is allowed

32 Application 6.4 Scheduling on Uniform Parallel Machines A feasible schedule with preemption allowed 43 Job(j)1234 Processing Time Release Time 2024 Due Date5479 Suppose there are 2 parallel machines

33 Transformation into a maximum flow problem s t red arcs: the amount of processing of job j during t time units is at most t. blue arcs: the amount of processing of job j over all time units is p j. green arcs: the amount of processing during t time units is at most Mt.

34 A maximum flow s t ,2 4,4 2,2 4,4 4, Flow decomposition can be used to transform flows into schedules There is a feasible schedule if there is a maximum flow that saturates each of the arcs out of s.