该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
function [xstar,fxstar,AO,IB,iter]=Dsimplex(A,b,c)
[m,n]=size(A);E=eye(m);IB=zeros(1,m);k=0;
for i=1:m
for j=1:n
if A(:,j)==E(:,i)
IB(i)=j;SA(i)=j;
elseif A(:,j)==(-E(:,i))
SA(i)=j;
end
end
end
AO=[b,A];N=1:n;IB;N(IB)=[];IN=N;x(IB)=AO(:,1)';
x(IN)=zeros(1,length(IN));cB=c(IB);
sigma=c'-cB'*AO(:,2:n+1);
t=find(AO(:,1)<0);
flag=0;
while (t~=0)&(flag==0)
[~,jj]=min(AO(:,1));
tt=find(AO(jj,2:n+1)<0);kk=length(tt);
if kk==0
disp
xstar=[]; fxstar=[]; AO=[]; IB=[]; iter=k;
flag=1;
else
theta=zeros(1,kk);
for i=1:kk
theta(i)=sigma(tt(i))/AO(jj,tt(i)+1);
end
for i=1:m
if i~=jj
AO(i,:)=AO(i,:)-(AO(jj,:)/AO(jj,Temp+1))*AO(i,Temp+1);
else
AO(jj,:)=AO(jj,:)/AO(jj,Temp+1);
end
end
TT=IB(jj); IB(jj)=Temp;IN(Temp)=TT; x(IB)=AO(:,1)';
N=1:n;N(IB)=[];IN=N;x(IN)=zeros(1,length(IN));cB=c(IB);
t=find(AO(:,1)<0); sigma=c'-cB*AO(:,2:n+1);
end
k=k+1;
end
if flag==1
xstar=[];fxstar=[];iter=k;
disp
else
B=A(:,IB);
xstar=x;fxstar=x(IB)*c(IB);iter=k;
endclc,clear
A=[-1 -2 -1 1 0;-2 1 -3 0 1];
b=[-3 -4]';
c=[-2 -3 -4 0 0]';
[xstar,fxstar,AO,IB,iter]=Dsimplex(A,b,c);
未定义函数或变量 'Temp'。
出错 Dsimplex (line 31)
AO(i,:)=AO(i,:)-(AO(jj,:)/AO(jj,Temp+1))*AO(i,Temp+1);
出错 Untitled222 (line 5)
[xstar,fxstar,AO,IB,iter]=Dsimplex(A,b,c);
>>
拜托大佬帮忙指点一下~可以有偿~~~