使用matlab进行灵敏性分析(附源代码)

举报
yk 坤帝 发表于 2021/07/15 02:20:54 2021/07/15
【摘要】 个人公众号 yk 坤帝 后台回复 灵敏性分析源代码 获取整理资源 调用单纯形程序: function [x,z,flg,sgma]=simplexfun(A,A1,b,c,m,n,n1,cb,xx) % A,b are the matric in Ax=b % c is the matrix in max z=cx % A1 is the matric in simp...

个人公众号 yk 坤帝
后台回复 灵敏性分析源代码 获取整理资源

调用单纯形程序:
function [x,z,flg,sgma]=simplexfun(A,A1,b,c,m,n,n1,cb,xx)
% A,b are the matric in Ax=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-(cbB1)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 ir b®=b®/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®*cc;
for j=1:n
A1(i,j)=A1(i,j)-A1(r,j)cc;
end
end
end
cb®=c(k);
xx®=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 求之。

在这里插入图片描述

个人公众号 yk 坤帝
后台回复 灵敏性分析源代码 获取整理资源

文章来源: blog.csdn.net,作者:yk 坤帝,版权归原作者所有,如需转载,请联系作者。

原文链接:blog.csdn.net/qq_45803923/article/details/117091363

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。