28
1 Generality of Languages Maximum Cardinality Matching Max (s,t)-Flow Min Cost Flow Hopcroft-Karp Linear Programs Reduction Reduction Reduction Edmonds-Karp Klein’s algorithm Simplex Algorithm, Interior Point Algorithms Algorithm Algorithm Algorithm Increasing generality Decreasing efficiency Algorithm

1 Generality of Languages Maximum Cardinality Matching Max (s,t)-Flow Min Cost Flow Hopcroft-Karp Linear Programs Reduction Edmonds-Karp Klein’s algorithm

  • View
    219

  • Download
    0

Embed Size (px)

Citation preview

1

Generality of Languages

MaximumCardinalityMatching

Max (s,t)-Flow

Min Cost Flow

Hopcroft-Karp

Linear Programs

Reduction

Reduction

Reduction

Edmonds-Karp

Klein’salgorithm

Simplex Algorithm,Interior Point Algorithms

Algorithm

Algorithm

Algorithm

Incr

easi

ng g

ener

ality

Dec

reas

ing

effic

ienc

yAlgorithm

2

Min Cost Flow Problem

• Given flow network with costs G =(V,E,c,b,k), find flow f minimizing cost(f).

3

Min Cost Flow Problem

• Given G=(V,E,c,b,k), find f: V £ V ! R minimizing (u,v) 2 V £ V k(u,v) f(u,v) so that

8 (u,v): f(u,v) · c(u,v). 8 (u,v): f(u,v) = – f(v,u).

8 u 2 V: v 2 V f(u,v) = b(u)

4

Min Cost Flow Problem

Find (x1, x2,…, x64) 2 R64 minimizing k1x1 + k2x2 + + k64 x64

so that x1· 3, x2 · -1, ….. x1 = - x19, x2 = - x27, ….

x9 + x17 + x34

= 17,

x12

+ x11

+ x19

= 0, ….

5

Linear Programs

Find x 2 Rn minimizing or maximizing a linear form hx,ci = i ci xi (the objective function) so that a given set of linear equations and inequalities are satisfied.

A feasible solution to the program is a

point x satisfying the equations and inequalities.

6

Linear Programs

• Linear Programs generalize the min cost flow problem.

• Linear Programs generalize systems of linear equations.

• To solve general linear programs we seem to need a common generalization of Klein’s algorithm and Gaussian elimination!

7

Diet ProblemServing Size

Energy (kcal)

Protein (g)

Calcium (mg)

Price per serving (cents)

Oatmeal 28 g 110 4 2 3

Chicken 100 g 205 32 12 24

Eggs 2 large 160 13 54 13

Whole Milk 237 cc 160 8 285 9

Cherry Pie 170 g 420 4 22 20

Pork with Beans 260 g 260 14 80 19

Necessary daily intake: Energy 2000 kcal, Protein 55 g, Calcium 800 mg

Compose a diet minimizing price and fulfilling necessary daily intake.

8

Diet ProblemServing Size

Energy (kcal)

Protein (g)

Calcium (mg)

Price per serving (cents)

Oatmeal x1 28 g 110 4 2 3

Chicken x2 100 g 205 32 12 24

Eggs x3 2 large 160 13 54 13

Whole Milk x4 237 cc 160 8 285 9

Cherry Pie x5 170 g 420 4 22 20

Pork with Beans x6 260 g 260 14 80 19

Necessary daily intake: Energy 2000 kcal, Protein 55 g, Calcium 800 mg

Compose a diet minimizing price and fulfilling necessary daily intake.

9

Linear Program for Diet Problem

Find (x1, x2, x3, x4, x5, x6) 2 (R+)n minimizing

3x1 + 24x2 + 13x3 + 9x4 + 20x5 + 19x6

so that

110x1 + 205x2 + 160 x3 + 160 x4 + 420 x5 + 260 x6 ¸ 2000

4 x1 + 32 x2 + 13 x3 + 8 x4 + 4 x5 + 14 x6 ¸ 55

2 x1 + 12 x2 + 54 x3 + 285 x4 + 22 x5 + 80 x6 ¸ 800

10

Linear Programs, Geometric View

x – y = 0

11

x – y ¸ 0

12

x – y = 0

x + 3y = -1

x + 2y = 1

2x – y = 3

x + 2y · 1 Æx + 3 y ¸ -1 Æx – y ¸ 0 Æ2 x - y · 3

13

x + 2y · 1 Æx + 3 y ¸ -1 Æx – y ¸ 0 Æ2 x - y · 3

14

The set of feasible solutions F is a convex Polyhedron.

F

15

F

Minimize x-2y over F

x-2y = 1

x-2y = 0

16

F

Minimize x-2y over F

x-2y = -2/3

17

Linear Programs, Geometric view

• The set of feasible solutions of a linear program is a polyhedron in Rn.

• The minimal (maximal) value of the linear objective function is attained in a corner of the polyhedron.

• Simplex algorithm: Do a local search, walking from corner to corner of the polyhedron improving the objective function until no improvement is possible.

• Exceptions: The set of feasible solutions may be unbounded or empty (the linear program is then said to be infeasible).

18

19

Linear Programs in Standard Form

• The objective must be to maximize a linear function.

• All variables are restricted to non-negative values.

• All constraints have the form

d1 x1 + d2 x2 + + dn xn · e

20

Linear Programs in Standard Form

Find (x1, x2, x3, …, xn) 2 (R+)n maximizing

c1 x1+ c2 x2 + + cn xn

so that

a11 x1 + a12 x2 + + a1n xn · b1

a21 x1 + a22 x2 + + a2n xn · b2

am1 x1 + am2 x2 + + amn xn · bm

Exceptions: If no fesible solution exist, report “Infeasible”. If arbitrarily good feasible solutions exist, report “Unbounded”.

21

Linear Program in Standard FormMatrix Notation

Given A 2 Rm £ n, b 2 Rm, c 2 Rn,

find x 2 (R+)n maximizing hc,xi so that Ax · b.

22

Reduction from LP in general form to LP in standard form

Suppose we want to minimize (not maximize)

c1 x1 + c2 x2 + cn xn

Maximize

- c1 x1 - c2 x2 - - cn xn

23

Reduction from LP in general form to LP in standard form

Suppose we have a constraint

d1 x1 + d2 x2 + + dn xn ¸ e

Replace with

- d1 x1 - d2 x2 - - dn xn · - e

24

Reduction from LP in general form to LP in standard form

Suppose we have a constraint

d1 x1 + d2 x2 + + dn xn = e

Replace with

d1 x1 + d2 x2 + + dn xn · e

- d1 x1 - d2 x2 - - dn xn · - e

25

Reduction from LP in general form to LP in standard form

• Suppose y is a variable for which we do not want the constraint y ¸ 0.

• Suppose we do want a constraint such as y ¸ -17

• Introduce new variable y’ = y+17 and replace y with y’-17 everywhere in the program.

26

Reduction from LP in general form to LP in standard form

• Suppose y is a variable for which we do not want the constraint y ¸ 0 and no other constraint y ¸ –c.

• Introduce two new variables y+, y- with constraints y+ ¸ 0, y- ¸ 0.

• Replace y with y+ - y- everywhere in the program.

• Do this for every unconstrained variable in the program.

27

Reduction from LP in general form to LP in standard form

• The old program P and the new program P’ are related as follows:

• A feasible solution to P can be converted to a feasible solution to P’ with same value by setting y+ = max(y,0), y- = – min(y,0).

• A feasible solution to P’ can be converted to a feasible solution to P with same value by setting y = y+ - y-.

28

Reduction from LP in general form to LP in standard form

• Conclusion: Linear Programs in general form can be converted to linear programs in standard form by doubling the number of constraints and doubling number of variables.

• From a practical point of view, the factor 2£2= 4 blowup in size is undesirable. Exercise: One extra constraint and one extra variable suffices.