% Has been modified for the transport problem. % % This is for the simplex method. You provide a matrix A and a vector % that corresponds to the basic variables. % The program returns the new matrix A and the new basic variables % % This file was written by Mary Pugh, mpugh@math.toronto.edu, in % March 2002. Please do not use this without her consent and % without attributing her. % % [A,bv] = pivot_transport(A,bv,M,N) % function [A,bv] = pivot_transport(A,bv,M,N) a = input('what is the incoming variable? ','s'); n = length(a); b = a(2:n); % find the index of the incoming variable for i=1:M for j=1:N a = int2str(i*10+j); if a == b j_in = (i-1)*N + j; I = i; J = j; end end end a = input('what is the outgoing variable? ','s'); n = length(a); b = a(2:n); n = length(bv); % find the index of the outgoing variable for i=1:n if int2str(bv(i)) == b i_out = i; end end [m,n] = size(A); if A(i_out,j_in) == 0 disp('you cannot pivot with your choice of incoming and outgoing variables'); end for i=1:i_out-1 A(i,:) = A(i,:) - A(i_out,:)*A(i,j_in)/A(i_out,j_in); end for i=i_out+1:m A(i,:) = A(i,:) - A(i_out,:)*A(i,j_in)/A(i_out,j_in); end A(i_out,:) = A(i_out,:)/A(i_out,j_in); % change the label corresponding to the i-out row to the j-in variable... bv(i_out) = I*10 + J; LP_disp_transport;