disp('initial data') initial data A=[3 2 1 1 0 0 A = 3 2 1 1 0 0 1 1 2 0 1 0 2 1 1 0 0 1 1 1 2 0 1 0 2 1 1 0 0 1] [m,n]=size(A) m = 3 n = 6 b=[36; 32; 22] b = 36 32 22 c=[10 7 6 0 0 0 ]' c =. 10 7 6 0 0 0 pause disp('optimal basis - nonbasic variables') optimal basis - nonbasic variables B=[2 5 3] B = 2 5 3 N=[1 4 6] N = 1 4 6 [x isort]=sort([B N]); pause disp('optimal basis matrix') optimal basis matrix A_B=A(:,B) A_B = 2 0 1 1 1 2 1 0 1 pause disp('inverse of optimal basis matrix') inverse of optimal basis matrix A_Bi=inv(A_B) A_Bi = 1 0 -1 1 1 -3 -1 0 2 pause disp('optimal primal solution x') optimal primal solution x x_B=A_Bi*b x_B = 14 2 8 x_N=zeros(n-m,1);x=[x_B;x_N]; x=x(isort) % sorted true x x = 0 14 8 0 2 0 pause disp('c_B and dual vrbles y') c_B and dual vrbles y c_B=c(B) c_B = 7 0 6 y=(c_B'*A_Bi)' y = 1 0 5 pause disp('verify dual feasibility and complementary slackness') verify dual feasibility and complementary slackness [A'*y-c x] ans = 3 0 0 14 0 8 1 0 0 2 5 0 pause disp('reduced costs') reduced costs c'-y'*A ans = -3 0 0 -1 0 -5 pause disp('row 1 of current tableau for ratio test for basic c_2 change') row 1 of current tableau for ratio test for basic c_2 change Abar=A_Bi*A; Abar(1,N) ans = 1 1 -1 pause disp('row 2 of current tableau for ratio test for basic c_5 change') row 2 of current tableau for ratio test for basic c_5 change Abar=A_Bi*A; Abar(2,N) ans = -2 1 -3 pause disp('row 3 of current tableau for ratio test for basic c_3 change') row 3 of current tableau for ratio test for basic c_3 change Abar=A_Bi*A; Abar(3,N) ans = 1 -1 2 pause echo off