实验二、线性规划的灵敏度分析(一)实验目的1.线性规划求解的单纯形法的灵敏度分析的编程实现2.掌握使用matlab、Lingo、Excel的规划求解功能求解,并利用“敏感性报告”进行分析。(二)实验内容课本例1解的灵敏度分析(1):调用单纯形程序:function[x,z,flg,sgma]=simplexfun(A,A1,b,c,m,n,n1,cb,xx)%A,barethematricinA*x=b%cisthematrixinmaxz=c*x%A1isthematricinsimplextable%misthenumbersofrowinAandnistheconnumberinA%n1isthenubersofartificialvariables,andartificialvariablesaredefaultasthelast%n1variablesinx.%cbistheworthcoefficientmatrixforbasicvariables%xxistheindexmatrixforbasicvariables%B1istheinversmatrixforthebasicmatrixinsimplextable.Theinitial%matrixisdefaultasthelastmconinthematrixA.x=zeros(n,1);z=0;B1=A1(:,n-m+1:n);sgma1=c-(cb*B1)*A;[masg,kk]=max(sgma1);k=kk(1);flg=0;ll=0;while(masg0)&&(ll20)ll=ll+1;thita=1000+zeros(m,1);fori=1:mifA1(i,k)0thita(i)=A1(i,k)\b(i);endend[r8,c8]=find(thita999);ifsum(c8)m[mith,rr]=min(thita);r=rr(1);aa=A1(r,k);fori=1:mifi==rb(r)=b(r)/aa;forj=1:nA1(r,j)=A1(r,j)/aa;endendendfori=1:mifi~=rcc=A1(i,k)b(i)=b(i)-b(r)*cc;forj=1:nA1(i,j)=A1(i,j)-A1(r,j)*cc;endendendcb(r)=c(k);xx(r)=k;B1=A1(:,n-m+1:n);sgma1=c-(cb*B1)*A;[masg,kk]=max(sgma1);k=kk(1);thita=100+zeros(m,1);elseflg=3;masg=-1;x='unboundsolution';z='inf';endendifflg~=3ifn1==0sgma1=c-(cb*B1)*A[rc,ccc]=find(sgma1-0.0000000001);ifsum(rc)==n-mflg=1;elseflg=2;endx=zeros(n,1);fori=1:mx(xx(i))=b(i);endz=c*x;elsex=zeros(n,1);fori=1:mx(xx(i))=b(i);endxa=x((n-n1+1):n,:);ra=find(xa);ifsum(ra)==0sgma1=c-(cb*B1)*A;[rc,ccc]=find(sgma1-0.00000001);ifsum(rc)==n-mflg=1;elseflg=2;endz=c*x;elseflg=4;x='nothing';z='nothing';endendendsgma=sgma1;ll;A=[1,2,1,0,0;40010;04001];A1=A;b=[8;16;12];c=[23000];m=3;n=5cb=[000];xx=[3,4,5];然后调用单纯行解法simplexfun111;求出值,并返回B1,b,然后输入:r=1,2,3求之。function[a1,b1]=lingb(B1,b,r)m=length(b);aa=-10000*ones(m,1);bb=10000*ones(m,1);fori=1:mifB1(i,r)0aa(i)=-b(i)/B1(i,r);endifB1(i,r)0bb(i)=-b(i)/B1(i,r);endenda1=max(aa);b1=min(bb);实验小结:通过matlab程序的编写,掌握了单纯形法灵敏度分析的编程实现。