%MATLAB code to pivot on a dictionary
%Usage:
%Set up:
%Specify...
%   an mxn matrix, A, of constraint coeffs.
%   an mx1 matrix, b, of RHS values (assumed >=0)
%   a 1xn matrix, c, of objective fn coeffs.
%   and an initial value z (the objective value), usually zero.
%   There are three MATLAB functions to be used with these definitions
%   dict() prints the current A, b, c, z in dictionary format
%   ratios(j) determines all upper bounds for entering variable xj.
%   lppivot(i,j) modifies A, b, c, z by pivoting on eqn i, variable j
%   Define A, b, c, z in the space indicated, then run this script. The
%   three functions dict, ratios, and lppivot can then be used.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Contents of ratios.m
 
function ratios(enter)
%ratios(j) determines all upper bounds for entering variable xj.
global A m bas b myeps 
 
for i=1:m
    if A(i,enter) > myeps
        fprintf('Row %d (x%d basic): Upper bound = %.2f\n',i,bas(1,i),b(i,1)/A(i,enter))
    else
        fprintf('Row %d (x%d basic): No upper bound\n',i,bas(1,i))
    end
end
end
