cs 473 algorithms
play

CS 473: Algorithms Chandra Chekuri Ruta Mehta University of - PowerPoint PPT Presentation

CS 473: Algorithms Chandra Chekuri Ruta Mehta University of Illinois, Urbana-Champaign Fall 2016 Chandra & Ruta (UIUC) CS473 1 Fall 2016 1 / 43 CS 473: Algorithms, Fall 2016 Introduction to Linear Programming Lecture 18 October 26,


  1. CS 473: Algorithms Chandra Chekuri Ruta Mehta University of Illinois, Urbana-Champaign Fall 2016 Chandra & Ruta (UIUC) CS473 1 Fall 2016 1 / 43

  2. CS 473: Algorithms, Fall 2016 Introduction to Linear Programming Lecture 18 October 26, 2016 Chandra & Ruta (UIUC) CS473 2 Fall 2016 2 / 43

  3. Part I Introduction to Linear Programming Chandra & Ruta (UIUC) CS473 3 Fall 2016 3 / 43

  4. A Factory Example Problem Suppose a factory produces two products 1 and 2 using resources A , B , C . Making a unit of 1 requires a unit each of A and C . 1 A unit of 2 requires one unit of B and C . 2 We have 200 units of A , 300 units of B , and 400 units of C . 3 Product 1 can be sold for $1 and product 2 for $6 . 4 How many units of product 1 and product 2 should the factory manufacture to maximize profit? Chandra & Ruta (UIUC) CS473 4 Fall 2016 4 / 43

  5. A Factory Example Problem Suppose a factory produces two products 1 and 2 using resources A , B , C . Making a unit of 1 requires a unit each of A and C . 1 A unit of 2 requires one unit of B and C . 2 We have 200 units of A , 300 units of B , and 400 units of C . 3 Product 1 can be sold for $1 and product 2 for $6 . 4 How many units of product 1 and product 2 should the factory manufacture to maximize profit? Solution: Chandra & Ruta (UIUC) CS473 4 Fall 2016 4 / 43

  6. A Factory Example Problem Suppose a factory produces two products 1 and 2 using resources A , B , C . Making a unit of 1 requires a unit each of A and C . 1 A unit of 2 requires one unit of B and C . 2 We have 200 units of A , 300 units of B , and 400 units of C . 3 Product 1 can be sold for $1 and product 2 for $6 . 4 How many units of product 1 and product 2 should the factory manufacture to maximize profit? Solution: Formulate as a linear program. Chandra & Ruta (UIUC) CS473 4 Fall 2016 4 / 43

  7. A Factory Example Problem Suppose a factory produces two products 1 and 2 , using resources A , B , C . Making a unit of 1 : Req. one 1 unit of A , C . Making unit of 2 : Req. one 2 unit of B , C . Have A : 200, B : 300 , and 3 C : 400. Price of 1 : $1 , and 2 : $6 . 4 How many units of 1 and 2 to manufacture to max profit? Chandra & Ruta (UIUC) CS473 5 Fall 2016 5 / 43

  8. A Factory Example Problem Suppose a factory produces two products 1 and 2 , using resources A , B , C . max x 1 + 6x 2 Making a unit of 1 : Req. one s.t. x 1 ≤ 200 (A) 1 unit of A , C . x 2 ≤ 300 (B) Making unit of 2 : Req. one 2 x 1 + x 2 ≤ 400 (C) unit of B , C . x 1 ≥ 0 Have A : 200, B : 300 , and 3 x 2 ≥ 0 C : 400. Price of 1 : $1 , and 2 : $6 . 4 How many units of 1 and 2 to manufacture to max profit? Chandra & Ruta (UIUC) CS473 5 Fall 2016 5 / 43

  9. Linear Programming Formulation Let us produce x 1 units of product 1 and x 2 units of product 2. Our profit can be computed by solving maximize x 1 + 6x 2 subject to x 1 ≤ 200 x 2 ≤ 300 x 1 + x 2 ≤ 400 x 1 , x 2 ≥ 0 Chandra & Ruta (UIUC) CS473 6 Fall 2016 6 / 43

  10. Linear Programming Formulation Let us produce x 1 units of product 1 and x 2 units of product 2. Our profit can be computed by solving maximize x 1 + 6x 2 subject to x 1 ≤ 200 x 2 ≤ 300 x 1 + x 2 ≤ 400 x 1 , x 2 ≥ 0 What is the solution? Chandra & Ruta (UIUC) CS473 6 Fall 2016 6 / 43

  11. Maximum Flow in Network 9 3 6 10 15 10 4 15 5 8 10 s 2 5 t 15 10 4 15 6 30 1 4 Chandra & Ruta (UIUC) CS473 7 Fall 2016 7 / 43

  12. Maximum Flow in Network Need to compute values 9 3 6 f s1 , f s2 , . . . f 25 , . . . f 5t , f 6t such that 10 15 10 4 15 5 8 10 s 2 5 t 15 10 4 15 6 30 1 4 Chandra & Ruta (UIUC) CS473 7 Fall 2016 7 / 43

  13. Maximum Flow in Network Need to compute values 9 3 6 f s1 , f s2 , . . . f 25 , . . . f 5t , f 6t such that 10 15 10 4 15 f s1 ≤ 15 f s2 ≤ 5 f s3 ≤ 10 5 8 10 f 14 ≤ 30 f 21 ≤ 4 f 25 ≤ 8 s 2 5 t f 32 ≤ 4 f 35 ≤ 15 f 36 ≤ 9 15 10 4 15 6 f 42 ≤ 6 f 4t ≤ 10 f 54 ≤ 15 30 f 5t ≤ 10 f 65 ≤ 15 f 6t ≤ 10 1 4 Chandra & Ruta (UIUC) CS473 7 Fall 2016 7 / 43

  14. Maximum Flow in Network Need to compute values 9 3 6 f s1 , f s2 , . . . f 25 , . . . f 5t , f 6t such that 10 15 10 4 15 f s1 ≤ 15 f s2 ≤ 5 f s3 ≤ 10 5 8 10 f 14 ≤ 30 f 21 ≤ 4 f 25 ≤ 8 s 2 5 t f 32 ≤ 4 f 35 ≤ 15 f 36 ≤ 9 15 10 4 15 6 f 42 ≤ 6 f 4t ≤ 10 f 54 ≤ 15 30 f 5t ≤ 10 f 65 ≤ 15 f 6t ≤ 10 1 4 and f s1 + f 21 = f 14 f s2 + f 32 = f 21 + f 25 f s3 = f 32 + f 35 + f 36 f 14 + f 54 = f 42 + f 4t f 25 + f 35 + f 65 = f 54 + f 5t f 36 = f 65 + f 6t Chandra & Ruta (UIUC) CS473 7 Fall 2016 7 / 43

  15. Maximum Flow in Network Need to compute values 9 3 6 f s1 , f s2 , . . . f 25 , . . . f 5t , f 6t such that 10 15 10 4 15 f s1 ≤ 15 f s2 ≤ 5 f s3 ≤ 10 5 8 10 f 14 ≤ 30 f 21 ≤ 4 f 25 ≤ 8 s 2 5 t f 32 ≤ 4 f 35 ≤ 15 f 36 ≤ 9 15 10 4 15 6 f 42 ≤ 6 f 4t ≤ 10 f 54 ≤ 15 30 f 5t ≤ 10 f 65 ≤ 15 f 6t ≤ 10 1 4 and f s1 + f 21 = f 14 f s2 + f 32 = f 21 + f 25 f s3 = f 32 + f 35 + f 36 f 14 + f 54 = f 42 + f 4t f 25 + f 35 + f 65 = f 54 + f 5t f 36 = f 65 + f 6t f s1 ≥ 0 f s2 ≥ 0 f s3 ≥ 0 · · · f 4t ≥ 0 f 5t ≥ 0 f 6t ≥ 0 Chandra & Ruta (UIUC) CS473 7 Fall 2016 7 / 43

  16. Maximum Flow in Network Need to compute values 9 3 6 f s1 , f s2 , . . . f 25 , . . . f 5t , f 6t such that 10 15 10 4 15 f s1 ≤ 15 f s2 ≤ 5 f s3 ≤ 10 5 8 10 f 14 ≤ 30 f 21 ≤ 4 f 25 ≤ 8 s 2 5 t f 32 ≤ 4 f 35 ≤ 15 f 36 ≤ 9 15 10 4 15 6 f 42 ≤ 6 f 4t ≤ 10 f 54 ≤ 15 30 f 5t ≤ 10 f 65 ≤ 15 f 6t ≤ 10 1 4 and f s1 + f 21 = f 14 f s2 + f 32 = f 21 + f 25 f s3 = f 32 + f 35 + f 36 f 14 + f 54 = f 42 + f 4t f 25 + f 35 + f 65 = f 54 + f 5t f 36 = f 65 + f 6t f s1 ≥ 0 f s2 ≥ 0 f s3 ≥ 0 · · · f 4t ≥ 0 f 5t ≥ 0 f 6t ≥ 0 and f s1 + f s2 + f s3 is maximized. Chandra & Ruta (UIUC) CS473 7 Fall 2016 7 / 43

  17. Maximum Flow as a Linear Program For a general flow network G = (V , E) with capacities c e on edge e ∈ E , we have variables f e indicating flow on edge e � Maximize f e e out of s subject to f e ≤ c e for each e ∈ E � � f e − f e = 0 ∀ v ∈ V \ { s , t } e out of v e into v f e ≥ 0 for each e ∈ E . Chandra & Ruta (UIUC) CS473 8 Fall 2016 8 / 43

  18. Maximum Flow as a Linear Program For a general flow network G = (V , E) with capacities c e on edge e ∈ E , we have variables f e indicating flow on edge e � Maximize f e e out of s subject to f e ≤ c e for each e ∈ E � � f e − f e = 0 ∀ v ∈ V \ { s , t } e out of v e into v f e ≥ 0 for each e ∈ E . Number of variables: m , one for each edge. Number of constraints: m + n − 2 + m . Chandra & Ruta (UIUC) CS473 8 Fall 2016 8 / 43

  19. Minimum Cost Flow with Lower Bounds ... as a Linear Program For a general flow network G = (V , E) with capacities c e , lower bounds ℓ e , and costs w e , we have variables f e indicating flow on edge e . Suppose we want a min-cost flow of value at least v . � Minimize w e f e e ∈ E � subject to f e ≥ v e out of s f e ≤ c e f e ≥ ℓ e for each e ∈ E � � f e − f e = 0 for each v ∈ V − { s , t } e out of v e into v f e ≥ 0 for each e ∈ E . Chandra & Ruta (UIUC) CS473 9 Fall 2016 9 / 43

  20. Minimum Cost Flow with Lower Bounds ... as a Linear Program For a general flow network G = (V , E) with capacities c e , lower bounds ℓ e , and costs w e , we have variables f e indicating flow on edge e . Suppose we want a min-cost flow of value at least v . � Minimize w e f e e ∈ E � subject to f e ≥ v e out of s f e ≤ c e f e ≥ ℓ e for each e ∈ E � � f e − f e = 0 for each v ∈ V − { s , t } e out of v e into v f e ≥ 0 for each e ∈ E . Number of variables: m , one for each edge Number of constraints: 1 + m + m + n − 2 + m = 3m + n − 1 . Chandra & Ruta (UIUC) CS473 9 Fall 2016 9 / 43

  21. Linear Programs Problem Find a vector x ∈ R d that � d maximize/minimize j=1 c j x j � d subject to j=1 a ij x j ≤ b i for i = 1 . . . p � d j=1 a ij x j = b i for i = p + 1 . . . q � d j=1 a ij x j ≥ b i for i = q + 1 . . . n Chandra & Ruta (UIUC) CS473 10 Fall 2016 10 / 43

  22. Linear Programs Problem Find a vector x ∈ R d that � d maximize/minimize j=1 c j x j � d subject to j=1 a ij x j ≤ b i for i = 1 . . . p � d j=1 a ij x j = b i for i = p + 1 . . . q � d j=1 a ij x j ≥ b i for i = q + 1 . . . n Input is matrix A = (a ij ) ∈ R n × d , column vector b = (b i ) ∈ R n , and row vector c = (c j ) ∈ R d Chandra & Ruta (UIUC) CS473 10 Fall 2016 10 / 43

  23. Canonical Form of Linear Programs Canonical Form A linear program is in canonical form if it has the following structure � d maximize j=1 c j x j � d subject to j=1 a ij x j ≤ b i for i = 1 . . . n Chandra & Ruta (UIUC) CS473 11 Fall 2016 11 / 43

  24. Canonical Form of Linear Programs Canonical Form A linear program is in canonical form if it has the following structure � d maximize j=1 c j x j � d subject to j=1 a ij x j ≤ b i for i = 1 . . . n Conversion to Canonical Form Replace � j a ij x j = b i by � j a ij x j ≤ b i and − � j a ij x j ≤ − b i 1 Replace � j a ij x j ≥ b i by − � j a ij x j ≤ − b i 2 Chandra & Ruta (UIUC) CS473 11 Fall 2016 11 / 43

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend