Increasing generality Decreasing efficiency Generality of Languages Linear Programs Reduction Algorithm Simplex Algorithm, Interior Point Algorithms Min Cost Flow Algorithm Klein s algorithm Reduction Max (s,t)-flow Algorithm Edmonds-Karp Reduction Maximum Cardinality Matching Algorithm Hopcroft-Karp 1
Min Cost Flow Problem Given flow network with costs G =(V,E,c,b,k), find flow f minimizing cost(f). 2
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) 3
Min Cost Flow Problem Find (x 1, x 2,, x 64 ) 2 R 64 minimizing k 1 x 1 + k 2 x 2 + + k 64 x 64 so that x 1 3, x 2-1,.. x 1 = - x 19, x 2 = - x 27,. x 9 + x 17 + x 34 = 17, x 12 + x 11 + x 19 = 0,. 4
Linear Programs Find x 2 R n minimizing or maximizing a linear form hx,ci = i c i x i (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. 5
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! 6
Diet Problem Serving Size Energy (kcal) Protein (g) Calcium (mg) 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 Price per serving (cents) Necessary daily intake: Energy 2000 kcal, Protein 55 g, Calcium 800 mg Compose a diet minimizing price and fulfilling necessary daily intake. 7
Diet Problem Serving Size Energy (kcal) Protein (g) Calcium (mg) Oatmeal x 1 28 g 110 4 2 3 Chicken x 2 100 g 205 32 12 24 Eggs x 3 2 large 160 13 54 13 Whole Milk x 4 237 cc 160 8 285 9 Cherry Pie x 5 170 g 420 4 22 20 Pork with Beans x 6 260 g 260 14 80 19 Price per serving (cents) Necessary daily intake: Energy 2000 kcal, Protein 55 g, Calcium 800 mg Compose a diet minimizing price and fulfilling necessary daily intake. 8
Linear Program for Diet Problem Find (x 1, x 2, x 3, x 4, x 5, x 6 ) 2 (R + ) n minimizing 3x 1 + 24x 2 + 13x 3 + 9x 4 + 20x 5 + 19x 6 so that 110x 1 + 205x 2 + 160 x 3 + 160 x 4 + 420 x 5 + 260 x 6 2000 4 x 1 + 32 x 2 + 13 x 3 + 8 x 4 + 4 x 5 + 14 x 6 55 2 x 1 + 12 x 2 + 54 x 3 + 285 x 4 + 22 x 5 + 80 x 6 800 9
Linear Programs, Geometric View x y = 0 10
x y 0 11
x + 2y 1 Æ x + 3 y -1 Æ x y 0 Æ 2 x - y 3 x + 2y = 1 x + 3y = -1 x y = 0 2x y = 3 12
x + 2y 1 Æ x + 3 y -1 Æ x y 0 Æ 2 x - y 3 13
The set of feasible solutions F is a convex Polyhedron. F 14
Minimize x-2y over F x-2y = 0 F x-2y = 1 15
Minimize x-2y over F x-2y = -2/3 F 16
Linear Programs, Geometric view The set of feasible solutions of a linear program is a polyhedron in R n. 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). 17
18
Linear Programs in Standard Form The objective must be to maximize a linear function. All variables are restricted to nonnegative values. All constraints have the form d 1 x 1 + d 2 x 2 + + d n x n e 19
Linear Programs in Standard Form Find (x 1, x 2, x 3,, x n ) 2 (R + ) n maximizing c 1 x 1 + c 2 x 2 + + c n x n so that a 11 x 1 + a 12 x 2 + + a 1n x n b 1 a 21 x 1 + a 22 x 2 + + a 2n x n b 2 a m1 x 1 + a m2 x 2 + + a mn x n b m Exceptions: If no fesible solution exist, report Infeasible. If arbitrarily good feasible solutions exist, report Unbounded. 20
Linear Program in Standard Form Matrix Notation Given A 2 R m n, b 2 R m, c 2 R n, find x 2 (R + ) n maximizing hc,xi so that Ax b. 21
Reduction from LP in general form to LP in standard form Suppose we want to minimize (not maximize) c 1 x 1 + c 2 x 2 + c n x n Maximize - c 1 x 1 - c 2 x 2 - - c n x n 22
Reduction from LP in general form to LP in standard form Suppose we have a constraint d 1 x 1 + d 2 x 2 + + d n x n e Replace with - d 1 x 1 - d 2 x 2 - - d n x n - e 23
Reduction from LP in general form to LP in standard form Suppose we have a constraint d 1 x 1 + d 2 x 2 + + d n x n = e Replace with d 1 x 1 + d 2 x 2 + + d n x n e - d 1 x 1 - d 2 x 2 - - d n x n - e 24
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. 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 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. 26
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 -. 27
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. 28