function [x,v] = solution(t,itb) % % returns the solution corresponding to the current tableau % % on entry: % t linear programming problem in standard format; % otb indices to variables outside the basis. % % on return: % x solution vector; % v value of the objective function % n = size(t,2)-1; % number of variables x = zeros(1,n); % result is row vector m = length(itb); % number of elements in basis r = size(t,1); % number of rows in tableau for j=1:m % assign solutions c = itb(j); % index to column in tableau for i=2:r % look for one in rows if (t(i,c) == 1) x(1,c) = t(i,n+1); break; end; end; end; v = -t(1,n+1); % upper right corner has objective value