matlab线性优化已经编了一个,可是答案有点特殊得让人觉得不对求解最大值Z=y1×5.2×105+(2.5+x1+x2-y1) ×4.3×105+y2×4.7 × 105+(8.2—x1+x3-y2) ×3.9×105+[0.25×y1+0.2×(2.5+x1+x2-y1)+0.23×y2+0.185×(8.2-x1+x2-y2)-2]×106-
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/24 21:07:11
matlab线性优化已经编了一个,可是答案有点特殊得让人觉得不对求解最大值Z=y1×5.2×105+(2.5+x1+x2-y1) ×4.3×105+y2×4.7 × 105+(8.2—x1+x3-y2) ×3.9×105+[0.25×y1+0.2×(2.5+x1+x2-y1)+0.23×y2+0.185×(8.2-x1+x2-y2)-2]×106-
matlab线性优化
已经编了一个,可是答案有点特殊得让人觉得不对
求解最大值Z=y1×5.2×105+(2.5+x1+x2-y1) ×4.3×105+y2×4.7 × 105+(8.2—x1+x3-y2) ×3.9×105+[0.25×y1+0.2×(2.5+x1+x2-y1)+0.23×y2+0.185×(8.2-x1+x2-y2)-2]×106-x1×2.0×105-x3×8.5×105-x2×10×105
约束条件:3.5-x2-x3≥0
8.2-x1+x3≥0
0≤y1≤2.5+x1+x2
0≤y2≤8.2-x1+x3
7.5y1+6.1 ×(2.5+x1+x2-y1)+9.0y2+7.35×(8.2-x1+x3-y2) ≤96.5
1.4y1+1.65y2≤7.5
0.25y1+0.2×(2.5+x1+x2-y1)+0.23y2+0.185×(8.2-x1+x3-y2) ≥2
x1≥0,x2≥0,x3≥0
matlab线性优化已经编了一个,可是答案有点特殊得让人觉得不对求解最大值Z=y1×5.2×105+(2.5+x1+x2-y1) ×4.3×105+y2×4.7 × 105+(8.2—x1+x3-y2) ×3.9×105+[0.25×y1+0.2×(2.5+x1+x2-y1)+0.23×y2+0.185×(8.2-x1+x2-y2)-2]×106-
clc;clear;
fmax=[-166.41 -557.69 -483 99.8 88.77];
fmin=-fmax;
A=[0 1 1 0 0;1 0 -1 0 0;-1 -1 0 1 0;1 0 -1 0 1;6.1-7.35 6.1 7.35 7.5-6.1 9.0-7.35;0 0 0 1.4 1.65;-0.2+0.185 -0.2 -0.185 -0.25+0.2 -0.23+0.185]
B=[3.5;8.2;2.5;8.2;96.5-75.52;7.5;-2+2.017]
LB=[0 0 0 0 0]%下限
[X,FVAL,EXITFLAG]=linprog(fmin,A,B,[],[],LB,[])
%关键是化简容易出错,化简过程如下:
%{
syms x1 x2 x3 y1 y2
f1=y1*5.2*105+(2.5+x1+x2-y1)*4.3*105+y2*4.7*105+(8.2-x1+x3-y2)*3.9*105+(0.25*y1+0.2*(2.5+x1+x2-y1)+0.23*y2+0.185*(8.2-x1+x2-y2)-2)*106-x1*2.0*105-x3*8.5*105-x2*10*105
f1 =
499/5*y1+1122113/250-16641/100*x1-55769/100*x2+8877/100*y2-483*x3
f2=vpa(f1,8)
f2 =
99.800000*y1+4488.4520-166.41000*x1-557.69000*x2+88.770000*y2-483.*x3
%}
%{
3.5-x2-x3≥0
8.2-x1+x3≥0
0≤y1≤2.5+x1+x2
0≤y2≤8.2-x1+x3
7.5y1+6.1 ×(2.5+x1+x2-y1)+9.0y2+7.35×(8.2-x1+x3-y2) ≤96.5
syms x1 x2 x3 y1 y2
ff=7.5*y1+6.1 *(2.5+x1+x2-y1)+9.0*y2+7.35*(8.2-x1+x3-y2)
ff =
7/5*y1+1888/25-5/4*x1+61/10*x2+33/20*y2+147/20*x3
vpa(ff,5)
ans =
1.4000*y1+75.520-1.2500*x1+6.1000*x2+1.6500*y2+7.3500*x3
1.4y1+1.65y2≤7.5
0.25y1+0.2×(2.5+x1+x2-y1)+0.23y2+0.185×(8.2-x1+x3-y2) ≥2
syms x1 x2 x3 y1 y2
ff=0.25*y1+0.2*(2.5+x1+x2-y1)+0.23*y2+0.185*(8.2-x1+x3-y2)
ff =
1/20*y1+2017/1000+3/200*x1+1/5*x2+9/200*y2+37/200*x3
vpa(ff,5)
ans =
.50000e-1*y1+2.0170+.15000e-1*x1+.20000*x2+.45000e-1*y2+.18500*x3
%}
运行结果:
A =
0 1.0000 1.0000 0 0
1.0000 0 -1.0000 0 0
-1.0000 -1.0000 0 1.0000 0
1.0000 0 -1.0000 0 1.0000
-1.2500 6.1000 7.3500 1.4000 1.6500
0 0 0 1.4000 1.6500
-0.0150 -0.2000 -0.1850 -0.0500 -0.0450
B =
3.5000
8.2000
2.5000
8.2000
20.9800
7.5000
0.0170
LB =
0 0 0 0 0
Optimization terminated.
X =
0.0000
0.0000
0.0000
2.5000
2.4242
FVAL =
-464.7000
EXITFLAG =
1