>> %%%%%%%%%%%%%%%%%  Solutions to CS525 May 18, 2000 Final %%%%%%%%%%%%%% 

>> %%%%%%%%%%%%%%%%%%%%%%%%%%  Problem 1  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>>Q=[1 1;1 1];p=[1 -1]';b=[-2 -1]';A=[1 1;-2 1];M=[Q -A';A zeros(2,2)];q=[p;-b];
>> H=lemketbl(M,q);H=addcol(H,ones(4,1),'z0',5);
              z1         z2         z3         z4         z0         1   
       ------------------------------------------------------------------
 w1 = |     1.0000     1.0000    -1.0000     2.0000     1.0000     1.0000 
 w2 = |     1.0000     1.0000    -1.0000    -1.0000     1.0000    -1.0000 
 w3 = |     1.0000     1.0000     0.0000     0.0000     1.0000     2.0000 
 w4 = |    -2.0000     1.0000     0.0000     0.0000     1.0000     1.0000 
>> H=ljx(H,2,5);
              z1         z2         z3         z4         w2         1   
       ------------------------------------------------------------------
 w1 = |     0.0000     0.0000     0.0000     3.0000     1.0000     2.0000 
 z0 = |    -1.0000    -1.0000     1.0000     1.0000     1.0000     1.0000 
 w3 = |     0.0000     0.0000     1.0000     1.0000     1.0000     3.0000 
 w4 = |    -3.0000     0.0000     1.0000     1.0000     1.0000     2.0000 
>> H=ljx(H,2,2);
              z1         z0         z3         z4         w2         1   
       ------------------------------------------------------------------
 w1 = |     0.0000    -0.0000     0.0000     3.0000     1.0000     2.0000 
 z2 = |    -1.0000    -1.0000     1.0000     1.0000     1.0000     1.0000 
 w3 = |     0.0000    -0.0000     1.0000     1.0000     1.0000     3.0000 
 w4 = |    -3.0000    -0.0000     1.0000     1.0000     1.0000     2.0000 
>> %Complementary tableau x1=z1=0;x2=z2=1;u1=z3=0;u2=z4=0. Minimum=-0.5

>> %%%%%%%%%%%%%%%%%%%%%%%%%%  Problem 2  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>> A=[1 1 1;1 -2 1;-1 -1 1;-1 2 1];b=[1 6 -1 -6]';c=[0 0 1]';H=totbl(A,b,c);
              x1         x2         x3         1   
       --------------------------------------------
 x4 = |     1.0000     1.0000     1.0000    -1.0000 
 x5 = |     1.0000    -2.0000     1.0000    -6.0000 
 x6 = |    -1.0000    -1.0000     1.0000     1.0000 
 x7 = |    -1.0000     2.0000     1.0000     6.0000 
       --------------------------------------------
 z  = |     0.0000     0.0000     1.0000     0.0000 
>> %Dual feasible so use dual simplex.
>>  H=ljx(H,2,1);
              x5         x2         x3         1   
       --------------------------------------------
 x4 = |     1.0000     3.0000     0.0000     5.0000 
 x1 = |     1.0000     2.0000    -1.0000     6.0000 
 x6 = |    -1.0000    -3.0000     2.0000    -5.0000 
 x7 = |    -1.0000     0.0000     2.0000     0.0000 
       --------------------------------------------
 z  = |     0.0000     0.0000     1.0000     0.0000 
>>  H=ljx(H,3,3);
              x5         x2         x6         1   
       --------------------------------------------
 x4 = |     1.0000     3.0000     0.0000     5.0000 
 x1 = |     0.5000     0.5000    -0.5000     3.5000 
 x3 = |     0.5000     1.5000     0.5000     2.5000 
 x7 = |     0.0000     3.0000     1.0000     5.0000 
       --------------------------------------------
 z  = |     0.5000     1.5000     0.5000     2.5000 
>> %Optimal tableau. Solution x1=3.5;x2=0. Minimum=2.5.

>> %%%%%%%%%%%%%%%%%%%%%%%%%%  Problem 3  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>> A=[1 -1;-2 1];b=[-2 -4]';p=[1 0]';q=[-1 -1]';H=totbl(A,b,p);
>> H=addrow(H,[q' 0],'z0',3); 
              x1         x2         1   
       ---------------------------------
 x3 = |     1.0000    -1.0000     2.0000 
 x4 = |    -2.0000     1.0000     4.0000 
 z0 = |    -1.0000    -1.0000     0.0000 
       ---------------------------------
 z  = |     1.0000     0.0000     0.0000 
>> %1-t>=0 & -t>=0 imply optimal tableau for -infinity<t=<0.
>> H=ljx(H,1,2);
              x1         x3         1   
       ---------------------------------
 x2 = |     1.0000    -1.0000     2.0000 
 x4 = |    -1.0000    -1.0000     6.0000 
 z0 = |    -2.0000     1.0000    -2.0000 
       ---------------------------------
 z  = |     1.0000    -0.0000     0.0000 
>> %1-2t>=0 & t>=0 imply optimal tableau for 0=<t=<0.5
>> H=ljx(H,2,1);
              x4         x3         1   
       ---------------------------------
 x2 = |    -1.0000    -2.0000     8.0000 
 x1 = |    -1.0000    -1.0000     6.0000 
 z0 = |     2.0000     3.0000   -14.0000 
       ---------------------------------
 z  = |    -1.0000    -1.0000     6.0000 
>> %-1+2t>=0 & -1+3t>=0 imply optimal tableau for 0.5=<t<+infinity.
>> %Summary
>> %-infinity<t=<0, z(t)=0 at x1=x2=0
>> %0=<t=<0.5, z(t)=-2t at x1=0, x2=2
>> %0.5=<t<+infinity, z(t)=6-14t at x1=6, x2=8

>> %%%%%%%%%%%%%%%%%%%%%%%%%%  Problem 4  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>> % NO. Because Q is psd and equality of primal-dual objectives gives:
>> % p'x-b'u =< x'Qx+p'x-b'u = 0. So:  p'x-b'u =< 0.
>> % p'x=b'u if and only if x'Qx=0, which is equivalent to Qx=0 but need
>> % NOT imply that x=0.
>> save exam1
>> diary off
