-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRevisedSimplexTableau.m
55 lines (53 loc) · 992 Bytes
/
RevisedSimplexTableau.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
function [Tnew,Bnew,flg] = RevisedSimplexTableau(B,r,s,t,zmin,T)
%
% This function updates a RevisedSimplexTableau
%
%
% On input:
% B: current basis index
% T: current RevisedTableau
% r: B(r)-th column is to LEAVE the index.
% t: Pivot column
% s: s-th column is to JOIN the index.
% zmin: s-th component in c-A'*y
%
% 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) == 0)
%
% This is indication of degeneracy. Quit.
%
flg = 1;
return;
end
%
% This is the normal case. Proceed.
%
Temp = T(r,:)/t(r);
Tnew(1:mt-1,:) = T(1:mt-1,:) - t*Temp;
Tnew(r,:) = Temp;
theta0 = zmin/t(r);
Tnew(mt,:) = T(mt,:) + theta0*T(r,:);
return