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

调用单纯形程序:
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-(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

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

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-(cbB1)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 求之。

在这里插入图片描述

  • 2
    点赞
  • 85
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论
灵敏度分析matlab源代码如下: ```matlab 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 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 flg=1; break; end \[thita0,k0\]=min(thita); x0=A1(k0,:)'; xx(k0)=k; cb(k)=c(k); B1(k0,:)=x0'; sgma1=c-(cb*B1)*A; \[masg,kk\]=max(sgma1); k=kk(1); end if flg==0 x(xx)=B1*b; z=cb*x; end ``` 这段代码是一个用于灵敏度分析的单纯形法程序。它可以根据给定的线性规划问题的系数矩阵A、约束条件矩阵b、目标函数系数矩阵c等参数,通过单纯形法求解最优解,并计算出灵敏度分析的结果。 #### 引用[.reference_title] - *1* [使用matlab进行灵敏性分析源代码)](https://blog.csdn.net/qq_45803923/article/details/117091363)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [灵敏性分析源代码](https://blog.csdn.net/qq_45803923/article/details/122398988)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [matlab灵敏度分析绘图——道路最大通行能力](https://blog.csdn.net/qq_58539881/article/details/120859416)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

yk 坤帝

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值