CSE 421 Algorithms Richard Anderson Lecture 24 Network Flow Applications.

Slides:



Advertisements
Similar presentations
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
Advertisements

1 Maximum flow sender receiver Capacity constraint Lecture 6: Jan 25.
R. Johnsonbaugh Discrete Mathematics 5 th edition, 2001 Chapter 8 Network models.
Parallel Scheduling of Complex DAGs under Uncertainty Grzegorz Malewicz.
Five Problems CSE 421 Richard Anderson Winter 2009, Lecture 3.
CSE 421 Algorithms Richard Anderson Lecture 23 Network Flow Applications.
Foreground/Background Image Segmentation. What is our goal? To label each pixel in an image as belonging to either the foreground of the scene or the.
Piyush Kumar (Lecture 6: MaxFlow MinCut Applications)
HW2 Solutions. Problem 1 Construct a bipartite graph where, every family represents a vertex in one partition, and table represents a vertex in another.
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
7.7 Extensions to Max Flow. 2 Circulation with Demands Circulation with demands. n Directed graph G = (V, E). n Edge capacities c(e), e  E. n Node supply.
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.
Maximum Flow Applications
Applications of Network Flow Problem. 7.5 Bipartite Matching.
1 Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
CSEP 521 Applied Algorithms
15.082J and 6.855J and ESD.78J November 2, 2010 Network Flow Duality and Applications of Network Flows.
Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 26.
CS774. Markov Random Field : Theory and Application Lecture 13 Kyomin Jung KAIST Oct
10/11/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne Adam Smith Algorithm Design and Analysis L ECTURE 22 Network.
CSE 421 Algorithms Richard Anderson Lecture 24 Network Flow Applications.
Applications of the Max-Flow Min-Cut Theorem. S-T Cuts SF D H C A NY S = {SF, D, H}, T={C,A,NY} [S,T] = {(D,A),(D,C),(H,A)}, Cap [S,T] =
CSE 421 Algorithms Richard Anderson Lecture 26 Network Flow Applications.
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 Problem (Thanks to Jim Orlin & MIT OCW)
Maximum Flow Chapter 26. Flow Concepts Source vertex s – where material is produced Sink vertex t – where material is consumed For all other vertices.
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.
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
CSEP 521 Applied Algorithms Richard Anderson Lecture 8 Network Flow.
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
Prof. Swarat Chaudhuri COMP 382: Reasoning about Algorithms Fall 2015.
1 Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
CSE 421 Algorithms Richard Anderson Lecture 24 Network Flow Applications.
CSE 421 Algorithms Richard Anderson Lecture 21 Shortest Paths and Network Flow.
TU/e Algorithms (2IL15) – Lecture 8 1 MAXIMUM FLOW (part II)
Algorithms Classroom Activities Richard Anderson University of Washington July 3, 20081IUCEE: Algorithm Activities.
CS4234 Optimiz(s)ation Algorithms
Graph Theory and Algorithm 02
Richard Anderson Lecture 25 Min Cut Applications and NP-Completeness
Richard Anderson Lecture 23 Network Flow
Maximum Flow 9/13/2018 6:12 PM Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015.
Lecture 22 Network Flow, Part 2
3.3 Applications of Maximum Flow and Minimum Cut
Richard Anderson Lecture 23 Network Flow Applications
Richard Anderson Lecture 27 Network Flow Applications
Richard Anderson Lecture 24 Network Flow Applications
Richard Anderson Lecture 25 Open Pit Mining
CSE 421 Richard Anderson Autumn 2016, Lecture 3
Richard Anderson Lecture 23 Network Flow
Richard Anderson Lecture 23 Network Flow
R. Johnsonbaugh Discrete Mathematics 5th edition, 2001
Richard Anderson Lecture 21 Network Flow
Richard Anderson Lecture 25 Network Flow Applications
CSE 421 Richard Anderson Autumn 2015, Lecture 3
Piyush Kumar (Lecture 6: MaxFlow MinCut Applications)
Algorithms (2IL15) – Lecture 7
Lecture 21 Network Flow, Part 1
Richard Anderson Lecture 22 Network Flow
Lecture 21 Network Flow, Part 1
CSE 421, University of Washington, Autumn 2006
Richard Anderson Lecture 23 Network Flow Applications
Lecture 22 Network Flow, Part 2
Richard Anderson Lecture 24 Network Flow Applications
Richard Anderson Lecture 26 Open Pit Mining
Richard Anderson Lecture 22 Network Flow
Vertex Covers and Matchings
CSE 421 Richard Anderson Autumn 2019, Lecture 3
Presentation transcript:

CSE 421 Algorithms Richard Anderson Lecture 24 Network Flow Applications

Today’s topics Problem Reductions –Undirected Flow to Flow –Bipartite Matching –Disjoint Path Problem Circulations Lowerbound constraints on flows Survey design

Problem Reduction Reduce Problem A to Problem B –Convert an instance of Problem A to an instance Problem B –Use a solution of Problem B to get a solution to Problem A Practical –Use a program for Problem B to solve Problem A Theoretical –Show that Problem B is at least as hard as Problem A

Problem Reduction Examples Reduce the problem of finding the Maximum of a set of integers to finding the Minimum of a set of integers Find the maximum of: 8, -3, 2, 12, 1, -6 Construct an equivalent minimization problem

Undirected Network Flow Undirected graph with edge capacities Flow may go either direction along the edges (subject to the capacity constraints) u st v Construct an equivalent flow problem

Bipartite Matching A graph G=(V,E) is bipartite if the vertices can be partitioned into disjoints sets X,Y A matching M is a subset of the edges that does not share any vertices Find a matching as large as possible

Application A collection of teachers A collection of courses And a graph showing which teachers can teach which courses RA PB CC DG AK

Converting Matching to Network Flow ts

Finding edge disjoint paths s t Construct a maximum cardinality set of edge disjoint paths

Theorem The maximum number of edge disjoint paths equals the minimum number of edges whose removal separates s from t

Directed graph with capacities, c(e) on the edges, and demands d(v) on vertices Find a flow function that satisfies the capacity constraints and the vertex demands –0 <= f(e) <= c(e) –f in (v) – f out (v) = d(v) Circulation facts: –Feasibility problem –d(v) 0: sink –Must have  v d(v)=0 to be feasible Circulation Problem u st v

Find a circulation in the following graph a be c f dg h

Reducing the circulation problem to Network flow u ab v

Formal reduction Add source node s, and sink node t For each node v, with d(v) < 0, add an edge from s to v with capacity -d(v) For each node v, with d(v) > 0, add an edge from v to t with capacity d(v) Find a maximum s-t flow. If this flow has size  v cap(s,v) then the flow gives a circulation satisifying the demands

Circulations with lowerbounds on flows on edges Each edge has a lowerbound l(e). –The flow f must satisfy l(e) <= f(e) <= c(e) ax yb ,4 1,2 0,2 1,4

Removing lowerbounds on edges Lowerbounds can be shifted to the demands yb -43 2,5 yb -21 3

Formal reduction L in (v): sum of lowerbounds on incoming edges L out (v): sum of lowerbounds on outgoing edges Create new demands d’ and capacities c’ on vertices and edges –d’(v) = d(v) + l out (v) – l in (v) –c’(e) = c(e) – l(e)

Application Customized surveys –Ask customers about products Only ask customers about products they use Limited number of questions you can ask each customer Need to ask a certain number of customers about each product Information available about which products each customer has used

Details Customer C 1,..., C n Products P 1,..., P m S i is the set of products used by C i Customer C i can be asked between c i and c’ i questions Questions about product P j must be asked on between p j and p’ j surveys

Circulation construction

Today’s topics Open Pit Mining Problem Task Selection Problem Reduction to Min Cut problem S, T is a cut if S, T is a partition of the vertices with s in S and t in T The capacity of an S, T cut is the sum of the capacities of all edges going from S to T

Open Pit Mining Each unit of earth has a profit (possibly negative) Getting to the ore below the surface requires removing the dirt above Test drilling gives reasonable estimates of costs Plan an optimal mining operation

Mine Graph

Determine an optimal mine

Generalization Precedence graph G=(V,E) Each v in V has a profit p(v) A set F if feasible if when w in F, and (v,w) in E, then v in F. Find a feasible set to maximize the profit

Min cut algorithm for profit maximization Construct a flow graph where the minimum cut identifies a feasible set that maximizes profit

Precedence graph construction Precedence graph G=(V,E) Each edge in E has infinite capacity Add vertices s, t Each vertex in V is attached to s and t with finite capacity edges

Show a finite value cut with at least two vertices on each side of the cut s t Infinite Finite

The sink side of a finite cut is a feasible set No edges permitted from S to T If a vertex is in T, all of its ancestors are in T

Setting the costs If p(v) > 0, –cap(v,t) = p(v) –cap(s,v) = 0 If p(v) < 0 –cap(s,v) = -p(v) –cap(v,t) = 0 If p(v) = 0 –cap(s,v) = 0 –cap(v,t) = 0 s t

Enumerate all finite s,t cuts and show their capacities s t

Minimum cut gives optimal solution Why? s t

Computing the Profit Cost(W) =  {w in W; p(w) < 0} -p(w) Benefit(W) =  {w in W; p(w) > 0} p(w) Profit(W) = Benefit(W) – Cost(W) Maximum cost and benefit –C = Cost(V) –B = Benefit(V)

Express Cap(S,T) in terms of B, C, Cost(T), Benefit(T), and Profit(T)

Summary Construct flow graph –Infinite capacity for precedence edges –Capacities to source/sink based on cost/benefit Finite cut gives a feasible set of tasks Minimizing the cut corresponds to maximizing the profit Find minimum cut with a network flow algorithm

Today’s topics More network flow reductions –Airplane scheduling –Image segmentation –Baseball elimination

Airplane Scheduling Given an airline schedule, and starting locations for the planes, is it possible to use a fixed set of planes to satisfy the schedule. Schedule –[segments] Departure, arrival pairs (cities and times) Approach –Construct a circulation problem where paths of flow give segments flown by each plane

Example Seattle->San Francisco, 9:00 – 11:00 Seattle->Denver, 8:00 – 11:00 San Francisco -> Los Angeles, 13:00 – 14:00 Salt Lake City -> Los Angeles, 15:00-17:00 San Diego -> Seattle, 17:30-> 20:00 Los Angeles -> Seattle, 18:00->20:00 Flight times: –Denver->Salt Lake City, 2 hours –Los Angeles->San Diego, 1 hour Can this schedule be full filled with two planes, starting from Seattle?

Compatible segments Segments S 1 and S 2 are compatible if the same plane can be used on S 1 and S 2 –End of S 1 equals start of S 2, and enough time for turn around between arrival and departure times –End of S 1 is different from S 2, but there is enough time to fly between cities

Each segment, S i, is represented as a pair of vertices (d i, a i, for departure and arrival), with an edge between them. Add an edge between a i and d j if S i is compatible with S j. Graph representation didi aiai aiai djdj

Setting up a flow problem didi aiai aiai djdj PiPi P’ i 1,1 0,1 1

Result The planes can satisfy the schedule iff there is a feasible circulation

Image Segmentation Separate foreground from background

Image analysis a i : value of assigning pixel i to the foreground b i : value of assigning pixel i to the background p ij : penalty for assigning i to the foreground, j to the background or vice versa A: foreground, B: background Q(A,B) =  {i in A} a i +  {j in B} b j -  {(i,j) in E, i in A, j in B} p ij

Pixel graph to flow graph s t

Mincut Construction uv s t bvbv avav p uv p vu

Baseball elimination Can the Dinosaurs win the league? Remaining games: –AB, AC, AD, AD, AD, BC, BC, BC, BD, CD WL Ants42 Bees42 Cockroaches33 Dinosaurs15 A team wins the league if it has strictly more wins than any other team at the end of the season A team ties for first place if no team has more wins, and there is some other team with the same number of wins

Baseball elimination Can the Fruit Flies win the league? Remaining games: –AC, AD, AD, AD, AF, BC, BC, BC, BC, BC, BD, BE, BE, BE, BE, BF, CE, CE, CE, CF, CF, DE, DF, EF, EF WL Ants1712 Bees167 Cockroaches167 Dinosaurs1413 Earthworms1410 Fruit Flies1215

Assume Fruit Flies win remaining games Fruit Flies are tied for first place if no team wins more than 19 games Allowable wins –Ants (2) –Bees (3) –Cockroaches (3) –Dinosaurs (5) –Earthworms (5) 18 games to play –AC, AD, AD, AD, BC, BC, BC, BC, BC, BD, BE, BE, BE, BE, CE, CE, CE, DE WL Ants1713 Bees168 Cockroaches169 Dinosaurs14 Earthworms1412 Fruit Flies1915

Remaining games AC, AD, AD, AD, BC, BC, BC, BC, BC, BD, BE, BE, BE, BE, CE, CE, CE, DE s ACADBCBDBE CE ABCD E T DE

Network flow applications summary Bipartite Matching Disjoint Paths Airline Scheduling Survey Design Baseball Elimination Project Selection Image Segmentation