>> % I-1 >> A = [1 2 3 4; -1 0 2 0; 3 4 4 8]; >> b = [1; 2; 0]; >> H = totbl(A,b); x1 x2 x3 x4 1 ------------------------------------------------------- y1 = | 1.0000 2.0000 3.0000 4.0000 -1.0000 y2 = | -1.0000 0.0000 2.0000 0.0000 -2.0000 y3 = | 3.0000 4.0000 4.0000 8.0000 -0.0000 >> H = ljx(H,1,1); y1 x2 x3 x4 1 ------------------------------------------------------- x1 = | 1.0000 -2.0000 -3.0000 -4.0000 1.0000 y2 = | -1.0000 2.0000 5.0000 4.0000 -3.0000 y3 = | 3.0000 -2.0000 -5.0000 -4.0000 3.0000 >> H = ljx(H,2,2); y1 y2 x3 x4 1 ------------------------------------------------------- x1 = | 0.0000 -1.0000 2.0000 0.0000 -2.0000 x2 = | 0.5000 0.5000 -2.5000 -2.0000 1.5000 y3 = | 2.0000 -1.0000 0.0000 0.0000 0.0000 >> % Solutions are: x1 = -2 + x3, x2 = 1.5 - 2.5x3 -2x4, x3, x4 arbitrary >> >> %I-2 >> A = [2 -2 -1; 1 1 -3; -1 0 4]; >> b = [3; 0; 2]; >> % make 3rd row >= >> A(3,:) = -A(3,:); b(3) = -b(3); >> p = [-1 2 -1]'; >> H = totbl(A,b,p); x1 x2 x3 1 -------------------------------------------- x4 = | 2.0000 -2.0000 -1.0000 -3.0000 x5 = | 1.0000 1.0000 -3.0000 -0.0000 x6 = | 1.0000 -0.0000 -4.0000 2.0000 -------------------------------------------- z = | -1.0000 2.0000 -1.0000 0.0000 >> H = addcol(H,[1 0 0 0]','x0',4); x1 x2 x3 x0 1 ------------------------------------------------------- x4 = | 2.0000 -2.0000 -1.0000 1.0000 -3.0000 x5 = | 1.0000 1.0000 -3.0000 0.0000 -0.0000 x6 = | 1.0000 -0.0000 -4.0000 0.0000 2.0000 ------------------------------------------------------- z = | -1.0000 2.0000 -1.0000 0.0000 0.0000 >> H = addrow(H,[0 0 0 1 0],'z0',5); x1 x2 x3 x0 1 ------------------------------------------------------- x4 = | 2.0000 -2.0000 -1.0000 1.0000 -3.0000 x5 = | 1.0000 1.0000 -3.0000 0.0000 -0.0000 x6 = | 1.0000 -0.0000 -4.0000 0.0000 2.0000 ------------------------------------------------------- z = | -1.0000 2.0000 -1.0000 0.0000 0.0000 z0 = | 0.0000 0.0000 0.0000 1.0000 0.0000 >> H = ljx(H,1,4); x1 x2 x3 x4 1 ------------------------------------------------------- x0 = | -2.0000 2.0000 1.0000 1.0000 3.0000 x5 = | 1.0000 1.0000 -3.0000 0.0000 -0.0000 x6 = | 1.0000 -0.0000 -4.0000 0.0000 2.0000 ------------------------------------------------------- z = | -1.0000 2.0000 -1.0000 0.0000 0.0000 z0 = | -2.0000 2.0000 1.0000 1.0000 3.0000 >> H = ljx(H,1,1); x0 x2 x3 x4 1 ------------------------------------------------------- x1 = | -0.5000 1.0000 0.5000 0.5000 1.5000 x5 = | -0.5000 2.0000 -2.5000 0.5000 1.5000 x6 = | -0.5000 1.0000 -3.5000 0.5000 3.5000 ------------------------------------------------------- z = | 0.5000 1.0000 -1.5000 -0.5000 -1.5000 z0 = | 1.0000 0.0000 0.0000 0.0000 0.0000 >> >> % optimal for Phase I, delete z0 row and x0 col. >> % resulting tableau is unbounded in Phase II >> % x1 = 1.5 + x4, x2 = 0, x3 = 0; objective = -1.5 - 0.5 x4 >> % let x4 go to plus infinity >> % II-1 >> A = [1 -4.5 12; 0 0 1; 1 -4.5 9]; >> b = [2; 3; -11.5]; >> p = [0 1 3]; alpha = -0.5; %note converted from max to min >> H = totbl(A,b,p,alpha); x1 x2 x3 1 -------------------------------------------- x4 = | 1.0000 -4.5000 12.0000 -2.0000 x5 = | 0.0000 0.0000 1.0000 -3.0000 x6 = | 1.0000 -4.5000 9.0000 11.5000 -------------------------------------------- z = | 0.0000 1.0000 3.0000 -0.5000 >> % equality x5 >> H = ljx(H,2,3); x1 x2 x5 1 -------------------------------------------- x4 = | 1.0000 -4.5000 12.0000 34.0000 x3 = | -0.0000 -0.0000 1.0000 3.0000 x6 = | 1.0000 -4.5000 9.0000 38.5000 -------------------------------------------- z = | 0.0000 1.0000 3.0000 8.5000 >> % could delete x5 col, but will just leave it for part (b) >> % free variable x1 >> H = ljx(H,1,1); x4 x2 x5 1 -------------------------------------------- x1 = | 1.0000 4.5000 -12.0000 -34.0000 x3 = | -0.0000 -0.0000 1.0000 3.0000 x6 = | 1.0000 0.0000 -3.0000 4.5000 -------------------------------------------- z = | 0.0000 1.0000 3.0000 8.5000 >> H = permrows(H,[2 3 4 1]); x4 x2 x5 1 -------------------------------------------- x3 = | -0.0000 -0.0000 1.0000 3.0000 x6 = | 1.0000 0.0000 -3.0000 4.5000 -------------------------------------------- z = | 0.0000 1.0000 3.0000 8.5000 x1 = | 1.0000 4.5000 -12.0000 -34.0000 >> % optimal, x1 = -34, x2 = 0; x3 = 3; objective = -8.5 >> >> % (b) remains optimal, since x5 is now a "normal slack" >> % but even so the tableau remains optimal >> >> % II-2 >> A = [-1 -1 3; -4 1 2]; >> b = [-1; 0]; >> p = [7 1 2]'; >> H = totbl(A,b,p); x1 x2 x3 1 -------------------------------------------- x4 = | -1.0000 -1.0000 3.0000 1.0000 x5 = | -4.0000 1.0000 2.0000 -0.0000 -------------------------------------------- z = | 7.0000 1.0000 2.0000 0.0000 >> H = dualbl(H); u3 = u4 = u5 = w = x1 x2 x3 1 -------------------------------------------- -u1 x4 = | -1.0000 -1.0000 3.0000 1.0000 -u2 x5 = | -4.0000 1.0000 2.0000 -0.0000 -------------------------------------------- -1 z = | 7.0000 1.0000 2.0000 0.0000 >> % Optimal tableau; dual solution w=0; u1 = u2 = 0, u3 = 7, u4 = 1, u5 = 2 >> >> % do dual simplex pivot on u2 row >> H = ljx(H,2,2); u3 = u2 = u5 = w = x1 x5 x3 1 -------------------------------------------- -u1 x4 = | -5.0000 -1.0000 5.0000 1.0000 -u4 x2 = | 4.0000 1.0000 -2.0000 0.0000 -------------------------------------------- -1 z = | 11.0000 1.0000 0.0000 0.0000 >> % w=0; u1 = u4 = 0; u2 = 1; u3 = 11; u5 = 0 is another dual solution