注册地址 登录
数学建模社区-数学中国 返回首页

luke77777的个人空间 http://www.madio.net/?1417799 [收藏] [复制] [分享] [RSS]

日志

好东西,美赛共分享

已有 353 次阅读2015-2-3 21:19 | 灵敏度

实验二、线性规划的灵敏度分析

 

(一)  实验目的

    1. 线性规划求解的单纯形法的灵敏度分析的编程实现

2.掌握使用matlabLingoExcel的规划求解功能求解,并利用“敏感性报告”进行分析。

(二)实验内容

课本例1 解的灵敏度分析

1):调用单纯形程序:

function [x,z,flg,sgma]=simplexfun(A,A1,b,c,m,n,n1,cb,xx)

% A,b are the matric in A*x=b

% c is the matrix in max z=c*x

% A1 is the matric in simplex table

% m is the numbers of row in A and n is the con number in A

% n1 is the nubers of artificial variables,and artificial variables are default as the last % n1 variables in x.

% cb is the worth coefficient matrix for basic variables

% xx is the index matrix for basic variables

% B1 is the invers matrix for the basic matrix in simplex table.The initial

% matrix is default as the last m con in the matrix A.

 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 (masg>0)&&(ll<20)

    ll=ll+1;

    thita=1000+zeros(m,1);

    for i=1:m

        if A1(i,k)>0

            thita(i)=A1(i,k)\b(i);

        end

    end

    [r8,c8]=find(thita>999);

if sum(c8)<m

    [mith,rr]=min(thita);

    r=rr(1);

    aa=A1(r,k);

    for i=1:m

        if i==r

             b(r)=b(r)/aa;

             for j=1:n

                 A1(r,j)=A1(r,j)/aa  ;                                    

             end

        end

    end

        for i=1:m

        if i~=r 

               cc=A1(i,k)

               b(i)=b(i)-b(r)*cc;             

              for j=1:n               

                 A1(i,j)=A1(i,j)-A1(r,j)*cc;                             

             end           

         end       

    end

    cb(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);

else

    flg=3;

    masg=-1;

    x='unbound solution';

    z='inf';

end

end

 

 

if flg~=3

   if n1==0

       sgma1=c-(cb*B1)*A

       [rc,ccc]=find(sgma1<-0.0000000001);

      if sum(rc)==n-m

         flg=1;

      else

         flg=2;

      end

         x=zeros(n,1);

      for i=1:m

         x(xx(i))=b(i);        

      end   

        z=c*x;

   else

         x=zeros(n,1);

      for i=1:m

         x(xx(i))=b(i);

      end

      xa=x((n-n1+1):n,:);

      ra=find(xa);

      if sum(ra)==0

          sgma1=c-(cb*B1)*A;

         [rc,ccc]=find(sgma1<-0.00000001);

         if sum(rc)==n-m

             flg=1;

         else

             flg=2;

         end

           z=c*x;  

      else

           flg=4;

           x='nothing';

           z='nothing';

      end

   end      

end

sgma=sgma1;

ll;

A=[1,2,1,0,0;4 0 0 1 0;0 4 0 0 1];

A1=A;

b=[8;16;12];

c=[2 3 0 0 0];

m=3;

n=5

cb=[0 0 0];

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);

for i=1:m

    if B1(i,r)>0

        aa(i)=-b(i)/B1(i,r);

    end

    if B1(i,r)<0

        bb(i)=-b(i)/B1(i,r);

    end

end

a1=max(aa);

b1=min(bb);

 

 

 

 

实验小结:通过matlab程序的编写,掌握了单纯形法灵敏度分析的编程实现。

 


路过

雷人

握手

鲜花

鸡蛋

全部作者的其他最新日志

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 注册地址

qq
收缩
  • 电话咨询

  • 04714969085

关于我们| 联系我们| 诚征英才| 对外合作| 产品服务| QQ

手机版|Archiver| |繁體中文 手机客户端  

蒙公网安备 15010502000194号

Powered by Discuz! X2.5   © 2001-2013 数学建模网-数学中国 ( 蒙ICP备14002410号-3 蒙BBS备-0002号 )     论坛法律顾问:王兆丰

GMT+8, 2025-9-28 20:06 , Processed in 0.309640 second(s), 27 queries .

回顶部