% LP is min y st y >= x1 + x2 - t, y >= -x1-x2 + t, 3x1+5x2 >= -1 + 5t, x1,x2,y >= 0 p = [0 0 1]'; b = [0 0 -1]'; h = [-1 1 5]'; A = [-1 -1 1; 1 1 1; 3 5 0]; T = totbl(A,b,p); x1 x2 x3 1 -------------------------------------------- x4 = | -1.0000 -1.0000 1.0000 -0.0000 x5 = | 1.0000 1.0000 1.0000 -0.0000 x6 = | 3.0000 5.0000 0.0000 1.0000 -------------------------------------------- z = | 0.0000 0.0000 1.0000 0.0000 T = relabel(T,'x3','y'); x1 x2 y 1 -------------------------------------------- x4 = | -1.0000 -1.0000 1.0000 -0.0000 x5 = | 1.0000 1.0000 1.0000 -0.0000 x6 = | 3.0000 5.0000 0.0000 1.0000 -------------------------------------------- z = | 0.0000 0.0000 1.0000 0.0000 T = addcol(T,[-h; 0],'t',5); x1 x2 y 1 t ------------------------------------------------------- x4 = | -1.0000 -1.0000 1.0000 -0.0000 1.0000 x5 = | 1.0000 1.0000 1.0000 -0.0000 -1.0000 x6 = | 3.0000 5.0000 0.0000 1.0000 -5.0000 ------------------------------------------------------- z = | 0.0000 0.0000 1.0000 0.0000 0.0000 % optimal for t=0; z(t) = 0; % if t > 0 T = ljx(T,2,1); x5 x2 y 1 t ------------------------------------------------------- x4 = | -1.0000 0.0000 2.0000 0.0000 0.0000 x1 = | 1.0000 -1.0000 -1.0000 -0.0000 1.0000 x6 = | 3.0000 2.0000 -3.0000 1.0000 -2.0000 ------------------------------------------------------- z = | 0.0000 0.0000 1.0000 0.0000 0.0000 % optimal for 0 <= t <= 0.5, z(t) = 0 T = ljx(T,3,2); x5 x6 y 1 t ------------------------------------------------------- x4 = | -1.0000 0.0000 2.0000 0.0000 0.0000 x1 = | 2.5000 -0.5000 -2.5000 0.5000 0.0000 x2 = | -1.5000 0.5000 1.5000 -0.5000 1.0000 ------------------------------------------------------- z = | 0.0000 0.0000 1.0000 0.0000 0.0000 % optimal for t >= 0.5 z(t) = 0 % for T decreasing T = totbl(A,b,p); x1 x2 x3 1 -------------------------------------------- x4 = | -1.0000 -1.0000 1.0000 -0.0000 x5 = | 1.0000 1.0000 1.0000 -0.0000 x6 = | 3.0000 5.0000 0.0000 1.0000 -------------------------------------------- z = | 0.0000 0.0000 1.0000 0.0000 T = relabel(T,'x3','y'); x1 x2 y 1 -------------------------------------------- x4 = | -1.0000 -1.0000 1.0000 -0.0000 x5 = | 1.0000 1.0000 1.0000 -0.0000 x6 = | 3.0000 5.0000 0.0000 1.0000 -------------------------------------------- z = | 0.0000 0.0000 1.0000 0.0000 T = addcol(T,[-h; 0],'t',5); x1 x2 y 1 t ------------------------------------------------------- x4 = | -1.0000 -1.0000 1.0000 -0.0000 1.0000 x5 = | 1.0000 1.0000 1.0000 -0.0000 -1.0000 x6 = | 3.0000 5.0000 0.0000 1.0000 -5.0000 ------------------------------------------------------- z = | 0.0000 0.0000 1.0000 0.0000 0.0000 T = ljx(T,1,3); x1 x2 x4 1 t ------------------------------------------------------- y = | 1.0000 1.0000 1.0000 0.0000 -1.0000 x5 = | 2.0000 2.0000 1.0000 -0.0000 -2.0000 x6 = | 3.0000 5.0000 0.0000 1.0000 -5.0000 ------------------------------------------------------- z = | 1.0000 1.0000 1.0000 0.0000 -1.0000 % optimal for t <= 0, zt) = -t. % z(t) is piecewise linear convex function of t % Q2 % Problem is recast as QP by making y >= each linear term in max in objective Q = [2 0; 0 0]; p = [-3 1]'; A = [-2 1; 1 1]; b = [-10; 2]; % Q is psd so KKT are n & s % M = [Q -A'; A zeros(2,2)]; q = [p; -b]; T = lemketbl(M,q); M = [Q -A'; A zeros(2,2)]; q = [p; -b]; T = lemketbl(M,q); z1 z2 z3 z4 1 ------------------------------------------------------- w1 = | 2.0000 0.0000 2.0000 -1.0000 -3.0000 w2 = | 0.0000 0.0000 -1.0000 -1.0000 1.0000 w3 = | -2.0000 1.0000 0.0000 0.0000 10.0000 w4 = | 1.0000 1.0000 0.0000 0.0000 -2.0000 T = addcol(T,ones(4,1),'z0',5); z1 z2 z3 z4 z0 1 ------------------------------------------------------------------ w1 = | 2.0000 0.0000 2.0000 -1.0000 1.0000 -3.0000 w2 = | 0.0000 0.0000 -1.0000 -1.0000 1.0000 1.0000 w3 = | -2.0000 1.0000 0.0000 0.0000 1.0000 10.0000 w4 = | 1.0000 1.0000 0.0000 0.0000 1.0000 -2.0000 T = ljx(T,1,5); z1 z2 z3 z4 w1 1 ------------------------------------------------------------------ z0 = | -2.0000 -0.0000 -2.0000 1.0000 1.0000 3.0000 w2 = | -2.0000 0.0000 -3.0000 0.0000 1.0000 4.0000 w3 = | -4.0000 1.0000 -2.0000 1.0000 1.0000 13.0000 w4 = | -1.0000 1.0000 -2.0000 1.0000 1.0000 1.0000 T = ljx(T,4,1); w4 z2 z3 z4 w1 1 ------------------------------------------------------------------ z0 = | 2.0000 -2.0000 2.0000 -1.0000 -1.0000 1.0000 w2 = | 2.0000 -2.0000 1.0000 -2.0000 -1.0000 2.0000 w3 = | 4.0000 -3.0000 6.0000 -3.0000 -3.0000 9.0000 z1 = | -1.0000 1.0000 -2.0000 1.0000 1.0000 1.0000 T = ljx(T,1,4); w4 z2 z3 z0 w1 1 ------------------------------------------------------------------ z4 = | 2.0000 -2.0000 2.0000 -1.0000 -1.0000 1.0000 w2 = | -2.0000 2.0000 -3.0000 2.0000 1.0000 0.0000 w3 = | -2.0000 3.0000 0.0000 3.0000 0.0000 6.0000 z1 = | 1.0000 -1.0000 0.0000 -1.0000 0.0000 2.0000 % solution is x1 = z1 = 2; y = z2 = 0; obj = -2 % solution is unique, just consider cases 0< x1 <=2, and 2< x1 <=5 % Q3 A = [1 3; -1 0; 1 1]; b = [-1 -2 1]'; p = [1 2]'; T = totbl(A,b,p); x1 x2 1 --------------------------------- x3 = | 1.0000 3.0000 1.0000 x4 = | -1.0000 0.0000 2.0000 x5 = | 1.0000 1.0000 -1.0000 --------------------------------- z = | 1.0000 2.0000 0.0000 T = dualbl(T); u4 = u5 = w = x1 x2 1 --------------------------------- -u1 x3 = | 1.0000 3.0000 1.0000 -u2 x4 = | -1.0000 0.0000 2.0000 -u3 x5 = | 1.0000 1.0000 -1.0000 --------------------------------- 1 z = | 1.0000 2.0000 0.0000 % SHOULD WRITE THIS DOWN STRAIGHT OFF T = ljx(T,3,1); u3 = u5 = w = x5 x2 1 --------------------------------- -u1 x3 = | 1.0000 2.0000 2.0000 -u2 x4 = | -1.0000 1.0000 1.0000 -u4 x1 = | 1.0000 -1.0000 1.0000 --------------------------------- 1 z = | 1.0000 1.0000 1.0000 % dual solution is (0,0,1) % dual is max -u1 -2u2 + u3 st u1 -u2 +u3 <= 1, 3u1 + c3 <=2, u1,u2,u3 >= 0 p = [1 0.5]'; T = totbl(A,b,p); x1 x2 1 --------------------------------- x3 = | 1.0000 3.0000 1.0000 x4 = | -1.0000 0.0000 2.0000 x5 = | 1.0000 1.0000 -1.0000 --------------------------------- z = | 1.0000 0.5000 0.0000 T = ljx(T,3,2); x1 x5 1 --------------------------------- x3 = | -2.0000 3.0000 4.0000 x4 = | -1.0000 0.0000 2.0000 x2 = | -1.0000 1.0000 1.0000 --------------------------------- z = | 1.5000 0.5000 0.5000 4. a) 0 < y'(Bx) = x'(B'y) = 0 contradiction b) max e'w st w = Bx, w >= 0. If (I) has no soln, then above LP is solvable with optimal value 0. c) Dual is min 0' y st y >= e, -B'y = 0 d) By strong duality, dual has soln with opt value 0. ie y >= e, -B'y = 0 has soln, which is then a soln of II.