1 Linear Programming & Flows Instructor: yedeshi

Slides:



Advertisements
Similar presentations
COMP 482: Design and Analysis of Algorithms
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.
The simplex algorithm The simplex algorithm is the classical method for solving linear programs. Its running time is not polynomial in the worst case.
C&O 355 Lecture 23 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.
Transportation Problem (TP) and Assignment Problem (AP)
Introduction to Algorithms
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
1 Maximum flow sender receiver Capacity constraint Lecture 6: Jan 25.
1 Introduction to Linear Programming. 2 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. X1X2X3X4X1X2X3X4.
MS&E 211 Minimum Cost Flow LP Ashish Goel. Minimum Cost Flow (MCF) Need to ship some good from “supply” nodes to “demand” nodes over a network – Example:
Basic Feasible Solutions: Recap MS&E 211. WILL FOLLOW A CELEBRATED INTELLECTUAL TEACHING TRADITION.
Piyush Kumar (Lecture 6: MaxFlow MinCut Applications)
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 Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
1 COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf.
CS38 Introduction to Algorithms Lecture 15 May 20, CS38 Lecture 15.
Advanced Algorithms Piyush Kumar (Lecture 2: Max Flows) Welcome to COT5405 Slides based on Kevin Wayne’s slides.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2006 Lecture 9 Wednesday, 11/15/06 Linear Programming.
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.
Chapter 10: Iterative Improvement
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.
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.
15.082J, 6.855J, and ESD.78J September 21, 2010 Eulerian Walks Flow Decomposition and Transformations.
1 Linear Programming & Flows Instructor: YE, Deshi
Computational Geometry Piyush Kumar (Lecture 5: Linear Programming) Welcome to CIS5930.
Linear Programming Piyush Kumar. Graphing 2-Dimensional LPs Example 1: x y Feasible Region x  0y  0 x + 2 y  2 y  4 x  3 Subject.
Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.
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.
Linear Programming Data Structures and Algorithms A.G. Malamos References: Algorithms, 2006, S. Dasgupta, C. H. Papadimitriou, and U. V. Vazirani Introduction.
Theory of Computing Lecture 13 MAS 714 Hartmut Klauck.
1 COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf.
Flows in Planar Graphs Hadi Mahzarnia. Outline O Introduction O Planar single commodity flow O Multicommodity flows for C 1 O Feasibility O Algorithm.
Max Flow – Min Cut Problem. Directed Graph Applications Shortest Path Problem (Shortest path from one point to another) Max Flow problems (Maximum material.
1 Network Models Transportation Problem (TP) Distributing any commodity from any group of supply centers, called sources, to any group of receiving.
Maximum Flow Problem (Thanks to Jim Orlin & MIT OCW)
Chapter 7 April 28 Network Flow.
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 Introduction to Linear Programming. 2 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. X1X2X3X4X1X2X3X4.
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.
CSEP 521 Applied Algorithms Richard Anderson Lecture 8 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.
Iterative Improvement for Domain-Specific Problems Lecturer: Jing Liu Homepage:
Linear Programming Piyush Kumar Welcome to CIS5930.
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
Algorithm Design and Analysis
Richard Anderson Lecture 23 Network Flow
Algorithms and Networks
COMP 382: Reasoning about Algorithms
3.3 Applications of Maximum Flow and Minimum Cut
Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Network Flow and Connectivity in Wireless Sensor Networks
Introduction to Maximum Flows
CISC5835, Algorithms for Big Data
Max Flow Min Cut, Bipartite Matching Yin Tat Lee
Piyush Kumar (Lecture 6: MaxFlow MinCut Applications)
Algorithms (2IL15) – Lecture 7
Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
EE5900 Advanced Embedded System For Smart Infrastructure
Flow Feasibility Problems
Algorithms and Networks
Presentation transcript:

1 Linear Programming & Flows Instructor: yedeshi

2 Linear Programming What is it? Quintessential tool for optimal allocation of scarce resources, among a number of competing activities. (e.g., see ORF 307) Powerful and general problem-solving method. shortest path, max flow, min cost flow, generalized flow, multicommodity flow, MST, matching, 2-person zero sum games Why significant? Fast commercial solvers: CPLEX, OSL, Lindo. Powerful modeling languages: AMPL, GAMS. Ranked among most important scientific advances of 20th century. Also a general tool for attacking NP-hard optimization problems. Dominates world of industry. ex: Delta claims saving $100 million per year using LP

3 Example

4 Geometry Observation. Regardless of objective function (convex) coefficients, an optimal solution occurs at an extreme point.

5 Standard and slack forms Standard form In standard form, we are given n real numbers c 1, c 2,..., c n ; m real numbers b 1, b 2,..., b m ; and mn real numbers a ij for i = 1, 2,..., m and j = 1, 2,..., n. We wish to find n real numbers x 1, x 2,..., x n that

6 Standard and slack forms Standard form In standard form, we are given n real numbers c 1, c 2,..., c n ; m real numbers b 1, b 2,..., b m ; and mn real numbers a ij for i = 1, 2,..., m and j = 1, 2,..., n. We wish to find n real numbers x 1, x 2,..., x n that

7 slack form In standard form, Slack variable s, such that

8 The simplex algorithm Simplex algorithm. (George Dantzig, 1947) Developed shortly after World War II in response to logistical problems. Used for 1948 Berlin airlift. Generic algorithm. Start at some extreme point. Pivot from one extreme point to a neighboring one. Repeat until optimal. How to implement? Linear algebra. never decrease objective func

9 Illustration of Simplex Step1: Convert the LP problem to a system of linear equations (slack form). Step 2: Set up the initial tableau. Step 3: Find the PIVOT Step 4: Form RATIOS (quotients) for each row: divide the right-most number by the number in the pivot column of that row. Step 5: The PIVOT ROW is the row with the smallest NON-NEGATIVE ratio (quotient). Step 6: If all indicators (in the bottom row) are non- negative, STOP. Step 7: Otherwise, goes to Step 3.

10 Step 1 Original problem:Slack form:

11 Step SIMPLEX TABLEAU. Compare RED symbols with Z = x 1 + 2x 2 - x 3.

12 Step 3: Pivot Pivot column Indicator row

13 Step 3: Pivot ratios Pivot column Indicator row Ratios: 14÷1 =14 28÷2 =14 30÷5 =6 Pivot

14 Step 4: entering variable r1:r1: r2:r2: r3:r3: r4:r4: / / R3=(r 3 /5)

15 Step 4: leaving variable r1:r1: r2:r2: R3:R3: r4:r4: / / R 1 =r 1 - R 3 R 2 =r 2 -2R 3 R 4 =r 4 +2R 3 8/ /58 16/ /516 2/ /56 -1/503002/512 R1:R1: R2:R2: R3:R3: R4:R4:

16 Step 3 again 8/ /58 16/ /516 2/ /56 -1/503002/512 R1:R1: R2:R2: R3:R3: R4:R4: Pivot column Indicator row

17 Step 3 again 8/ /58 16/ /516 2/ /56 -1/503002/512 R1:R1: R2:R2: R3:R3: R4:R4: Pivot column Indicator row Ratios: 8÷(8/5) =5 16÷(16/5) =5 6÷ (2/5) =15 Tie: choose arbitrary

18 Step 3 again 8/ /58 16/ /516 2/ /56 -1/503002/512 R1:R1: R2:R2: R3:R3: R4:R4: 8/ / /160 -1/85 2/ /56 -1/503002/512 R1:R1: R2:R2: R3:R3: R4:R4: R 2 =(R 2 /(16/5))

19 Step 3 again 8/ / /160 -1/85 2/ /56 -1/503002/512 R1:R1: R2:R2: R3:R3: R4:R4: 00 -1/ /160 -1/ /80-1/81/ /1601/163/813 R1:R1: R2:R2: R3:R3: R4:R4: R 1 =R 1 – (8/5)R 2 R 3 =R 3 -(2/5)R 2 R 4 =R 4 +(1/2)R 2

20 STOP 00 -1/ /160 -1/ /80-1/81/ /1601/163/813 R1:R1: R2:R2: R3:R3: R4:R4: x1x1 x2x2 x3x3 s1s1 s2s2 s3s3 x 3 =s 2 =s 3 =0 x 1 =5, x 2 =4, s 1 =0 z =13 Finally, the optimal solution of LP is

21 History of LP Production, planning. (Kantorovich, USSR) Propaganda to make paper more palatable to communist censors. Kantorovich awarded 1975 Nobel prize in Economics for contributions to the theory of optimum allocation of resources. Staple in MBA curriculum. Used by most large companies and other profit maximizers.

22 History Production, planning. (Kantorovich) Simplex algorithm. (Dantzig) Applications in many fields. Military logistics. Operations research. Control theory. Filter design. Structural optimization.

23 History Production, planning. (Kantorovich) Simplex algorithm. (Dantzig) Applications in many fields Ellipsoid algorithm. (Khachian) Geometric divide-and-conquer. Solvable in polynomial time: O(n 4 L) bit operations. – n = # variables – L = # bits in input Theoretical tour de force, not remotely practical.

24 History Production, planning. (Kantorovich) Simplex algorithm. (Dantzig) Applications in many fields Ellipsoid algorithm. (Khachian) Projective scaling algorithm. (Karmarkar) O(n 3.5 L). Efficient implementations possible.

25 History Production, planning. (Kantorovich) Simplex algorithm. (Dantzig) Applications in many fields Ellipsoid algorithm. (Khachian) Projective scaling algorithm. (Karmarkar) Interior point methods. O(n 3 L) and practical. Extends to even more general problems.

26 Perspective LP is near the deep waters of NP- completeness. Solvable in polynomial time. Known for less than 28 years. Integer linear programming. LP with integrality requirement. NP-hard.

27 Formulating problems as linear programs Maximum flow: we are given a directed graph G = (V, E) in which each edge (u, v) ∈ E has a nonnegative capacity c(u, v) ≥ 0, and two distinguished vertices, a sink s and a source t. The goal is to find s-t flow of maximum value.

28 China Rail Network

29 Maximum Flow and Minimum Cut Max flow and min cut. Two very rich algorithmic problems. Cornerstone problems in combinatorial optimization. Beautiful mathematical duality.

30 Flow network. n Abstraction for material flowing through the edges. n G = (V, E) = directed graph, no parallel edges. n Two distinguished nodes: s = source, t = sink. n c(e) = capacity of edge e. Minimum Cut Problem s t capacity source sink

31 Def. An s-t cut is a partition (A, B) of V with s  A and t  B. Def. The capacity of a cut (A, B) is: Cuts s t Capacity = = 30 A

32 s t A Cuts Def. An s-t cut is a partition (A, B) of V with s  A and t  B. Def. The capacity of a cut (A, B) is: Capacity = = 62

33 Min s-t cut problem. Find an s-t cut of minimum capacity. Minimum Cut Problem s t A Capacity = = 28

34 Def. An s-t flow is a function that satisfies: n For each e  E: (capacity) n For each v  V – {s, t}: (conservation) Def. The value of a flow f is: Flows Value = 4 0 capacity flow s t

35 Def. An s-t flow is a function that satisfies: n For each e  E: (capacity) n For each v  V – {s, t}: (conservation) Def. The value of a flow f is: Flows capacity flow s t Value = 24 4

36 Max flow problem. Find s-t flow of maximum value. Maximum Flow Problem capacity flow s t Value = 28

37 Flow value lemma. Let f be any flow, and let (A, B) be any s-t cut. Then, the net flow sent across the cut is equal to the amount leaving s. Flows and Cuts s t Value = 24 4 A

38 Flow value lemma. Let f be any flow, and let (A, B) be any s-t cut. Then, the net flow sent across the cut is equal to the amount leaving s. Flows and Cuts s t Value = = A

39 Flow value lemma. Let f be any flow, and let (A, B) be any s-t cut. Then, the net flow sent across the cut is equal to the amount leaving s. Flows and Cuts s t Value = = 24 4 A

40 Flows and Cuts Flow value lemma. Let f be any flow, and let (A, B) be any s-t cut. Then Pf. by flow conservation, all terms except v = s are 0

41 Flows and Cuts Weak duality. Let f be any flow, and let (A, B) be any s-t cut. Then the value of the flow is at most the capacity of the cut. Cut capacity = 30  Flow value  30 s t Capacity = 30 A

42 Weak duality. Let f be any flow. Then, for any s-t cut (A, B) we have v(f)  cap(A, B). Pf. ▪ Flows and Cuts s t A B

43 Certificate of Optimality Corollary. Let f be any flow, and let (A, B) be any cut. If v(f) = cap(A, B), then f is a max flow and (A, B) is a min cut. Value of flow = 28 Cut capacity = 28  Flow value  s t A

Bipartite Matching

45 Matching. n Input: undirected graph G = (V, E). n M  E is a matching if each node appears in at most one edge in M. n Max matching: find a max cardinality matching. Matching

46 Bipartite Matching Bipartite matching. n Input: undirected, bipartite graph G = (L  R, E). n M  E is a matching if each node appears in at most one edge in M. n Max matching: find a max cardinality matching ' 3' 5' 2 4 2' 4' matching 1-2', 3-1', 4-5' RL

47 Bipartite Matching Bipartite matching. n Input: undirected, bipartite graph G = (L  R, E). n M  E is a matching if each node appears in at most edge in M. n Max matching: find a max cardinality matching ' 3' 5' 2 4 2' 4' RL max matching 1-1', 2-2', 3-3' 4-4'

48 Max flow formulation. n Create digraph G' = (L  R  {s, t}, E' ). n Direct all edges from L to R, and assign infinite (or unit) capacity. n Add source s, and unit capacity edges from s to each node in L. n Add sink t, and unit capacity edges from each node in R to t. Bipartite Matching s ' 3' 5' t 2 4 2' 4' 1 1  RL G'

49 Theorem. Max cardinality matching in G = value of max flow in G'. Pf.  n Given max matching M of cardinality k. n Consider flow f that sends 1 unit along each of k paths. n f is a flow, and has cardinality k. ▪ Bipartite Matching: Proof of Correctness s ' 3' 5' t 2 4 2' 4' 11  ' 3' 5' 2 4 2' 4' G' G

50 Theorem. Max cardinality matching in G = value of max flow in G'. Pf.  n Let f be a max flow in G' of value k. n Integrality theorem  k is integral and can assume f is 0-1. n Consider M = set of edges from L to R with f(e) = 1. – each node in L and R participates in at most one edge in M – |M| = k: consider cut (L  s, R  t) ▪ Bipartite Matching: Proof of Correctness ' 3' 5' 2 4 2' 4' G s ' 3' 5' t 2 4 2' 4' 11  G'

Disjoint Paths

52 Disjoint path problem. Given a digraph G = (V, E) and two nodes s and t, find the max number of edge-disjoint s-t paths. Def. Two paths are edge-disjoint if they have no edge in common. Ex: communication networks. s Edge Disjoint Paths t

53 Disjoint path problem. Given a digraph G = (V, E) and two nodes s and t, find the max number of edge-disjoint s-t paths. Def. Two paths are edge-disjoint if they have no edge in common. Ex: communication networks. s Edge Disjoint Paths t

54 Max flow formulation: assign unit capacity to every edge. Theorem. Max number edge-disjoint s-t paths equals max flow value. Pf.  n Suppose there are k edge-disjoint paths P 1,..., P k. n Set f(e) = 1 if e participates in some path P i ; else set f(e) = 0. n Since paths are edge-disjoint, f is a flow of value k. ▪ Edge Disjoint Paths st

55 Max flow formulation: assign unit capacity to every edge. Theorem. Max number edge-disjoint s-t paths equals max flow value. Pf.  n Suppose max flow value is k. n Integrality theorem  there exists 0-1 flow f of value k. n Consider edge (s, u) with f(s, u) = 1. – by conservation, there exists an edge (u, v) with f(u, v) = 1 – continue until reach t, always choosing a new edge n Produces k (not necessarily simple) edge-disjoint paths. ▪ Edge Disjoint Paths st can eliminate cycles to get simple paths if desired

56 Network connectivity. Given a digraph G = (V, E) and two nodes s and t, find min number of edges whose removal disconnects t from s. Def. A set of edges F  E disconnects t from s if all s-t paths uses at least on edge in F. Network Connectivity s t

57 Edge Disjoint Paths and Network Connectivity Theorem. [Menger 1927] The max number of edge-disjoint s-t paths is equal to the min number of edges whose removal disconnects t from s. Pf.  n Suppose the removal of F  E disconnects t from s, and |F| = k. n All s-t paths use at least one edge of F. Hence, the number of edge- disjoint paths is at most k. ▪ s t s t

58 Disjoint Paths and Network Connectivity Theorem. [Menger 1927] The max number of edge-disjoint s-t paths is equal to the min number of edges whose removal disconnects t from s. Pf.  n Suppose max number of edge-disjoint paths is k. n Then max flow value is k. n Max-flow min-cut  cut (A, B) of capacity k. n Let F be set of edges going from A to B. n |F| = k and disconnects t from s. ▪ s t s t A

Extensions to Max Flow

60 Circulation with Demands Circulation with demands. n Directed graph G = (V, E). n Edge capacities c(e), e  E. n Node supply and demands d(v), v  V. Def. A circulation is a function that satisfies: n For each e  E:0  f(e)  c(e) (capacity) n For each v  V: (conservation) Circulation problem: given (V, E, c, d), does there exist a circulation? demand if d(v) > 0; supply if d(v) < 0; transshipment if d(v) = 0

61 Necessary condition: sum of supplies = sum of demands. Pf. Sum conservation constraints for every demand node v flow Circulation with Demands capacity demand supply

62 Circulation with Demands Max flow formulation. G: supply demand

63 Circulation with Demands Max flow formulation. n Add new source s and sink t. n For each v with d(v) < 0, add edge (s, v) with capacity -d(v). n For each v with d(v) > 0, add edge (v, t) with capacity d(v). n Claim: G has circulation iff G' has max flow of value D. G': supply s t saturates all edges leaving s and entering t demand

64 Circulation with Demands Integrality theorem. If all capacities and demands are integers, and there exists a circulation, then there exists one that is integer-valued. Pf. Follows from max flow formulation and integrality theorem for max flow. Characterization. Given (V, E, c, d), there does not exists a circulation iff there exists a node partition (A, B) such that  v  B d v > cap(A, B) Pf idea. Look at min cut in G'. demand by nodes in B exceeds supply of nodes in B plus max capacity of edges going from A to B

Project Selection

66 Project Selection Projects with prerequisites. n Set P of possible projects. Project v has associated revenue p v. – some projects generate money: create interactive e-commerce interface, redesign web page – others cost money: upgrade computers, get site license n Set of prerequisites E. If (v, w)  E, can't do project v and unless also do project w. n A subset of projects A  P is feasible if the prerequisite of every project in A also belongs to A. Project selection. Choose a feasible subset of projects to maximize revenue. can be positive or negative

67 Project Selection: Prerequisite Graph Prerequisite graph. n Include an edge from v to w if can't do v without also doing w. n {v, w, x} is feasible subset of projects. n {v, x} is infeasible subset of projects. v w x v w x feasibleinfeasible

68 Min cut formulation. n Assign capacity  to all prerequisite edge. n Add edge (s, v) with capacity -p v if p v > 0. n Add edge (v, t) with capacity -p v if p v < 0. n For notational convenience, define p s = p t = 0. st -p w u v w x yz Project Selection: Min Cut Formulation  pvpv -p x      pypy pupu -p z 

69 Claim. (A, B) is min cut iff A  { s } is optimal set of projects. n Infinite capacity edges ensure A  { s } is feasible. n Max revenue because: s t -p w u v w x yz Project Selection: Min Cut Formulation pvpv -p x pypy pupu    A