1 CS612 Algorithms for Electronic Design Automation CS 612 – Lecture 8 Lecture 8 Network Flow Based Modeling Mustafa Ozdal Computer Engineering Department,

Slides:



Advertisements
Similar presentations
Maximum flow Main goals of the lecture:
Advertisements

Lecture 7. Network Flows We consider a network with directed edges. Every edge has a capacity. If there is an edge from i to j, there is an edge from.
Orthogonal Drawing Kees Visser. Overview  Introduction  Orthogonal representation  Flow network  Bend optimal drawing.
C&O 355 Mathematical Programming Fall 2010 Lecture 22 N. Harvey TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A A.
Introduction to Algorithms
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
1 Maximum flow sender receiver Capacity constraint Lecture 6: Jan 25.
MAX FLOW APPLICATIONS CS302, Spring 2013 David Kauchak.
Introduction To Algorithms CS 445 Discussion Session 8 Instructor: Dr Alon Efrat TA : Pooja Vaswani 04/04/2005.
The Maximum Network Flow Problem. CSE Network Flows.
Lectures on Network Flows
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2001 Lecture 4 Tuesday, 2/19/02 Graph Algorithms: Part 2 Network.
Approximation Algorithms
Yangjun Chen 1 Network Flow What is a network? Flow network and flows Ford-Fulkerson method - Residual networks - Augmenting paths - Cuts of flow networks.
Computer Algorithms Integer Programming ECE 665 Professor Maciej Ciesielski By DFG.
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.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2004 Lecture 5 Wednesday, 10/6/04 Graph Algorithms: Part 2.
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
1 The Min Cost Flow Problem. 2 The Min Cost Flow problem We want to talk about multi-source, multi-sink flows than just “flows from s to t”. We want to.
Escape Routing For Dense Pin Clusters In Integrated Circuits Mustafa Ozdal, Design Automation Conference, 2007 Mustafa Ozdal, IEEE Trans. on CAD, 2009.
Introduction to Operations Research
CS774. Markov Random Field : Theory and Application Lecture 13 Kyomin Jung KAIST Oct
Lecture 22 More NPC problems
Lecture 5: Network Flow Algorithms Single-Source Shortest-Path (SSSP) (Dijkstra's Algorithm) Max Flow - Min Cut (Ford-Fulkerson) Job Sequencing.
CSE 421 Algorithms Richard Anderson Lecture 24 Network Flow Applications.
Theory of Computing Lecture 13 MAS 714 Hartmut Klauck.
1 CS612 Algorithms for Electronic Design Automation CS 612 – Lecture 8 Lecture 8 Network Flow Based Modeling Mustafa Ozdal Computer Engineering Department,
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] =
Yangjun Chen 1 Network Flow What is a network? Flow network and flows Ford-Fulkerson method - Residual networks - Augmenting paths - Cuts of flow networks.
Announcements Network Flow today, depending on how far we get, we will do String Matching on Wednesday Then Review for Final next Monday This week’s lab.
Network Flow. Network flow formulation A network G = (V, E). Capacity c(u, v)  0 for edge (u, v). Assume c(u, v) = 0 if (u, v)  E. Source s and sink.
CS 473Lecture ?1 CS473-Algorithms I Lecture ? Network Flows Finding Max Flow.
Minimizing Stall Time in Single Disk Susanne Albers, Naveen Garg, Stefano Leonardi, Carsten Witt Presented by Ruibin Xu.
1 1 © 2003 Thomson  /South-Western Slide Slides Prepared by JOHN S. LOUCKS St. Edward’s University.
MAX FLOW APPLICATIONS CS302, Spring 2012 David Kauchak.
CSE 589 Part VI. Reading Skiena, Sections 5.5 and 6.8 CLR, chapter 37.
Max Flow – Min Cut Problem. Directed Graph Applications Shortest Path Problem (Shortest path from one point to another) Max Flow problems (Maximum material.
CS 473Lecture ?1 CS473-Algorithms I Lecture ? Network Flows Flow Networks & Flows.
Maximum Flow Chapter 26. Flow Concepts Source vertex s – where material is produced Sink vertex t – where material is consumed For all other vertices.
CS223 Advanced Data Structures and Algorithms 1 Maximum Flow Neil Tang 3/30/2010.
Implicit Hitting Set Problems Richard M. Karp Erick Moreno Centeno DIMACS 20 th Anniversary.
Homework - hints Problem 1. Node weights  Edge weights
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
1 Approximation algorithms Algorithms and Networks 2015/2016 Hans L. Bodlaender Johan M. M. van Rooij TexPoint fonts used in EMF. Read the TexPoint manual.
CSEP 521 Applied Algorithms Richard Anderson Lecture 8 Network Flow.
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
Theory of Computing Lecture 12 MAS 714 Hartmut Klauck.
C&O 355 Lecture 19 N. Harvey TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A A A A A A A A A.
TU/e Algorithms (2IL15) – Lecture 12 1 Linear Programming.
Iterative Improvement for Domain-Specific Problems Lecturer: Jing Liu Homepage:
A directed graph G consists of a set V of vertices and a set E of arcs where each arc in E is associated with an ordered pair of vertices from V. V={0,
TU/e Algorithms (2IL15) – Lecture 12 1 Linear Programming.
The Maximum Network Flow Problem
TU/e Algorithms (2IL15) – Lecture 8 1 MAXIMUM FLOW (part II)
St. Edward’s University
Maximum Flow Chapter 26.
Algorithms and Networks
Lectures on Network Flows
Richard Anderson Lecture 23 Network Flow
Lecture 22 Network Flow, Part 2
Instructor: Shengyu Zhang
Analysis of Algorithms
Richard Anderson Lecture 21 Network Flow
Lecture 5 Tuesday, 3/2/10 Graph Algorithms: Part 2
Flow Networks General Characteristics Applications
Flow Networks and Bipartite Matching
Algorithms (2IL15) – Lecture 7
EE5900 Advanced Embedded System For Smart Infrastructure
Maximum Flow Neil Tang 4/8/2008
Lecture 22 Network Flow, Part 2
Presentation transcript:

1 CS612 Algorithms for Electronic Design Automation CS 612 – Lecture 8 Lecture 8 Network Flow Based Modeling Mustafa Ozdal Computer Engineering Department, Bilkent University Mustafa Ozdal

2 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Flow Network Definition  Given a directed graph G = (V, E):  Each edge (u, v) has capacity c(u,v) ≥ 0  Each edge (u, v) has flow f(u, v) ≥ 0  A special source vertex s  A special sink vertex t st 6/9 4/7 4/5 2/5 1/2 3/5 5/5 2/4 1/5 7/9 2/6 Flow f and capacity c values for each edge shown as f/c

3 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Flow Constraints  Capacity constraints: 0 ≤ f(u, v) ≤ c(u, v) for each edge (u, v)  Flow conservation: For all u ∈ V − {s, t}, we must have: Total incoming flow to u = Total outgoing flow from u st 6/9 4/7 4/5 2/5 1/2 3/5 5/5 2/4 1/5 7/9 2/6 Flow f and capacity c values for each edge shown as f/c

4 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Network Flow  The total flow through the network is defined as: the net flow out of source vertex s or equivalently: the net flow to the sink vertex t st 6/9 4/7 4/5 2/5 1/2 3/5 5/5 2/4 1/5 7/9 2/6 Total flow = 10

5 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Max Flow Problem  Given a flow network, determine the flow values through each edge such that:  The capacity constraints are satisfied  The flow conservation constraints are satisfied  The total flow value is maximized  Integrality theorem: If all edge capacities are integers, then it is guaranteed that there exists an optimal solution with integer flow values.

6 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Max Flow Problem  Max flow problem is polynomial-time solvable.  In practice, we can model it as a linear programming (LP) problem, and make use of efficient linear solvers.  If all edge capacities are integers, it is guaranteed that the corresponding LP model is unimodular Linear solver will return a solution with integer values  In practice, can handle reasonably large problems.

7 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Bipartite Matching Problem Many practical problems can be modeled as max flow problems. Exercise: There are n students who want to do internship, and there are m companies. Each student marks 3 companies as his/her preference. Your task is to assign the students to companies such that: Each student is assigned to 1 company, and vice versa. A student is not assigned to a company (s)he doesn’t prefer. The number of students assigned is maximized. Use network flow to model your algorithm.

8 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Solution An edge from source s to each student vertex u. An edge from company vertex v to sink t. Create edge (u, v) iff student u prefers company v. All edge capacities are 1. s t a vertex u for each student a vertex v for each company

9 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Solution Compute the max flow from source s to sink t. Total flow = # of assignments If edge (u,v) has non-zero flow, assign student u to company v. s t a vertex u for each student a vertex v for each company

10 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Optimality Proof 1. Any student assignment with size |A| can be mapped to a flow solution with size |A|. 2. Any flow solution with size |F| can be mapped to a student assignment with size |F|. 3. The max-flow algorithm returns the solution with max total flow |F max |. This solution can be mapped to a student assignment with the same size due to (2). 4. If there was a better student assignment with size |A max |, where |A max | > |F max |, we would be able to map it to a flow solution with size |A max | due to (1). But, this would be a contradiction because |F max | is the maximum flow achievable. Hence, the assignment obtained by mapping the max-flow solution must be optimal.

11 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Exercise There are n students and m courses. Each student indicates preference for 8 courses. You are supposed to assign courses to all students such that:  A student is not assigned more than 5 courses.  A course does not contain more than 20 students.  A student is not assigned a course that (s)he doesn’t prefer.  The number of courses assigned to all students is maximized. Use network flow to model your algorithm.

12 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Solution An edge from source s to each student vertex u with capacity 5. An edge from course vertex v to sink t with capacity 20. Create edge (u, v) with capacity 1 iff student u prefers course v. s t a vertex u for each student a vertex v for each course

13 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Solution Compute the max flow from source s to sink t. Total flow = # of assignments If edge (u,v) has non-zero flow, assign student u to course v. s t a vertex u for each student a vertex v for each course

14 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Proof: (1) Assignment → Flow (1) Show that any assignment can be mapped to a valid flow with the same size Given an assignment of size |S|:

15 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Proof: (1) Assignment → Flow Create a network as suggested in the solution. For flow to be valid, we need to satisfy 2 conditions: 1) flow conservation, 2) capacity constraints s t

16 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Proof: (1) Assignment → Flow Flow conservation: 1) Set the flow value from any student node i to the course node j to be 1. 2) Set the flow value from s to any student node i to be the # of courses i is assigned to. 3) Set the flow value from any course node j to t to be the # of students j is assigned to. s t

17 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Proof: (1) Assignment → Flow Capacity constraints: 1. Flow through and capacity of any (student → course) edge is 1 2. Student i can be assigned to at most 5 courses, and capacity(s → i) = 5 3. Course j can be assigned to at most 20 students, and capacity(j → t) = 20 s t

18 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Proof: (1) Assignment → Flow Solution size: The size of the flow going out of source s is the sum of flow values (s → i), which is equal to the # of student-to-course assignments. s t

19 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Proof: (2) Flow → Assignment (1) Show that any flow solution can be mapped to a valid assignment with the same size Given a flow solution of size |F|: s t

20 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Proof: (2) Flow → Assignment Create an assignment solution as described in the solution. For a solution to be valid: 1. A student is not assigned to a non-preferred course (trivial to prove) 2. A student is not assigned to more than 5 courses 3. A course is not assigned to more than 20 students s t

21 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Proof: (2) Flow → Assignment Student i is not assigned to more than 5 courses: Incoming flow cannot be more than 5 (capacity constraint) Outgoing flow cannot be more than 5 (flow conservation) Course j is not assigned to more than 20 students (similar to above) s t

22 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Extension for Vertex Capacities The original flow network model can be extended to define vertex capacities. Original vertex v v1v1 v2v2 Replace v with v 1 and v 2 v cap Vertex capacity v cap for vertex v can be handled by splitting v into v 1 and v 2, and setting the edge capacity between them as v cap.

23 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Min-Cost Max-Flow  Define a real-valued weight w for each edge e in the flow network.  Objective: Compute the maximum flow in the network that minimizes the total weight W, where: Most max-flow algorithms can be extended easily to handle the weight minimization objective.

24 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Exercise: Escape Routing Problem n pins inside a chip. Each pin needs to be routed to a boundary point. A routing grid is defined. Each grid edge has a predefined routing cost. Pins need to be routed to the boundary of the chip.

25 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Exercise: Escape Routing Problem Primary objective: Route as many pins as possible to the boundary. Secondary objective: Minimize the total edge cost. Describe a network flow model to solve this problem.

26 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Solution: Network Flow Model for Escape Routing s t Create a vertex for each grid point with capacity 1. Create an edge between each neighbor grid point with the corresponding cost. Create an edge from source s to each internal pin with zero cost. Create an edge from each boundary pin to sink t with zero cost. Solve min-cost max-flow.

27 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Solution: Network Flow Model for Escape Routing s t For any grid-edge with non- zero flow: create a routing edge. All pins p with non-zero flow entering from s are routed to the boundary.

28 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Proof: (1) Routing → Flow  Given a routing solution, create a flow network as described in the solution.  Set the flow values as follows:  Set the flow of each routed grid edge to be 1  Set the flow of each (s, p) edge to 1 if a route starts from pin p  Set the flow of each (b, t) edge to 1 if a route ends at boundary point b  Need to show that:  Capacity constraints are satisfied  Flow conservation constraints are satisfied  Size of flow is equal to the number of routed nets  Total cost of flow is equal to the total routing cost (1) Show that any routing solution can be mapped to a valid flow with the same size and same cost

29 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Proof: (1) Routing → Flow  Capacity constraints are satisfied:  No edge has more than 1 unit flow by definition  All edges have capacity of 1  Flow conservation constraints are satisfied:  For any vertex corresponding to a routed pin p: One unit flow enters p from s and exits through a routing edge  For any vertex corresponding to a routed boundary point b: One unit flow enters b through a routing edge and exits to t  For any other vertex v that has a route passing through it: One unit flow enters v through a routing edge and exits it through another routing edge.

30 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Proof: (1) Routing → Flow  Size of flow = # of routed nets:  By definition, an edge (s, p) has unit flow iff a route begins at p  Hence the flow size is equal to # of routed nets  Total flow cost= total routing cost:  The cost of any edge (s, p) or (b, t) is zero  Total flow cost is the sum of edge-weight * flow  By definition, a unit flow passes through a grid edge iff there is a route passing through that edge.  Hence, total flow cost = total routing cost

31 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Proof: (2) Flow → Routing (2) Show that any flow solution can be mapped to a valid routing solution with the same size and the same cost  Given a flow solution, construct routes as described in the solution.  Need to show that:  A route must start at a pin p and end at a boundary point b without splitting or merging  No two routes can share a vertex or edge  The flow size is equal to the # of routed nets  The total routing cost is equal to the total flow cost

32 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Proof: (2) Flow → Routing  A route must start at a pin p and end at a boundary point b without splitting  From capacity constraints, an edge/vtx can have at most one unit of flow  Since all capacities are integers, all flow values must be integer.  So, flow through each edge/vtx is either 0 or 1.  Source s is connected to vertices corresponding to pins  Sink t is connected to vertices corresponding to boundary points.  From flow conservation, if a unit flow enters a vertex, it must exit the vertex through another edge (except for s and t).  Hence, each route must start from p and end at t without splitting.

33 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Proof: (2) Flow → Routing  No two routes can share a vertex or edge  From capacity constraints, an edge/vtx can have at most one unit of flow  Flow size = # of routed nets  Already showed that a unit flow starting at source s corresponds to routing of one net from pin p to boundary b.  So, flow size is equal to the number of routed nets.  The total routing cost is equal to the total flow cost  The cost of any edge (s, p) or (b, t) is zero  Total flow cost is the sum of edge-weight * flow  By definition, a unit flow passes through a grid edge iff there is a route passing through that edge.  Hence, total flow cost = total routing cost  Proof is complete.

34 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Multi-Commodity Flow Define different types of flows, and enforce the conservation constraints for each flow separately. Source: Wikipedia Optional:

35 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Multi-Commodity Flow Max multi-commodity flow problem: Min-cost multi-commodity flow problem minimize maximize Both problems are NP-complete for integer flows.

36 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Exercise: Single Layer Routing There are n 2-pin nets that need to be routed on a grid. Objective: Route as many nets as possible and minimize the total wirelength. Use multi-commodity network flow to model this problem.

37 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Solution: Single Layer Routing s t f1f1 f1f1 f2f2 f2f2 f3f3 f3f3 Grid network similar to escape routing. Create an edge from source s to each pin i that allows only flow commodity f i. Create an edge from each pin i to sink t that allows only flow commodity f i. Solve the min-cost multi-commodity flow.

38 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Simultaneous Pin Assignment and Routing Pin assignment problem:  Consider a macro block B with a fixed outline  We have the netlist available for B  We need to assign the pin locations at the block boundaries before placement Routing between two macro blocks B 1 and B 2  Each pin {a 1, b 1, c 1, …} of B 1 needs to be connected to the corresponding pins {a 2, b 2, c 2, …} of B 2.

39 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Pin Assignment Followed By Routing Xiang, H. et. al., “Min-Cost Flow-Based Algorithm for Simultaneous Pin Assignment and Routing”, IEEE Transactions on Computer-Aided Design, Vol. 22, No. 7, July 2003 Step 1: Perform pin assignment in such a way that the pins to be connected are as close as possible. Step 2: Perform routing between the pins. Problem: Net d cannot be routed.

40 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Simultaneous Pin Assignment and Routing Xiang, H. et. al., “Min-Cost Flow-Based Algorithm for Simultaneous Pin Assignment and Routing”, IEEE Transactions on Computer-Aided Design, Vol. 22, No. 7, July 2003 Simultaneous pin assignment and routing assigns all pins and routes all connections.

41 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Simultaneous Pin Assignment and Routing: Greedy Xiang, H. et. al., “Min-Cost Flow-Based Algorithm for Simultaneous Pin Assignment and Routing”, IEEE Transactions on Computer-Aided Design, Vol. 22, No. 7, July 2003 Perform pin assignment and routing one net at a time in a greedy way.

42 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Simultaneous Pin Assignment and Routing: Optimal Xiang, H. et. al., “Min-Cost Flow-Based Algorithm for Simultaneous Pin Assignment and Routing”, IEEE Transactions on Computer-Aided Design, Vol. 22, No. 7, July 2003 Optimal solution routes all connections with min cost. Is there a polynomial time optimal algorithm for this problem?

43 CS 612 – Lecture 8 Mustafa Ozdal Computer Engineering Department, Bilkent University Solution: Simultaneous Pin Assignment and Routing s' t Grid network similar to escape routing. Remove edges overlapping blockages. Create an edge from source s to vertex s’ with capacity equal to the number of pins. Create an edge from s’ to each boundary point in the first block, with capacity equal to 1. Create an edge from each boundary point in the second block to sink t, with capacity equal to1. Solve the min-cost max flow. s