function [Tnew,Bnew,flg] = ExtendedSimplexTableau(B,r,s,T) % % This function updates an ExtendedSimplexTableau % % Written by Ming Gu for Math 170 % March 2007 % % On input: % B: current basis index % T: current ExtendedTableau % r: B(r)-th column is to LEAVE the index. % s: s-th column is to JOIN the index. % % On output: % % flg: flg == 0 indicates SUCCESS in updating, % flg == 1 indicates FAILURE in updating, % Bnew: New basis index % Tnew: New Tableau % % % initialize flg. % flg = 0; % % find dimensions of T. % [mt,nt] = size(T); % % Set up Bnew % B = B(:); Bnew = [B(1:r-1);s;B(r+1:mt-1)]; % % Setup Tnew % Tnew = zeros(mt,nt); if (T(r,s) == 0) % % This is indication of degeneracy. Quit. % flg = 1; return; end % % This is the normal case. Proceed. % Tnew(1:mt-1,Bnew) = eye(mt-1); Tnew(1:mt-1,B(r)) =-T(1:mt-1,s)/T(r,s); Tnew(r,B(r)) = 1/T(r,s); Bbar = setdiff((1:nt)',[B;s]); Temp = T(r,Bbar)/T(r,s); Tnew(1:mt-1,Bbar) = T(1:mt-1,Bbar) - T(1:mt-1,s)*Temp; Tnew(r,Bbar) = Temp; theta0 = T(mt,s)/T(r,s); n = nt - mt; Tnew(mt,1:n) = T(mt,1:n) - theta0*T(r,1:n); Tnew(mt,n+1:end) = T(mt,n+1:end) + theta0*T(r,n+1:end);