用MATLAB编写程序求解以下问题,并给出代码已知w=[0,1,1,1,1,1,1,1],h=[0,1.083,0.875,0.875,0.83,1.25,0.875,1.125],d=[520,370,551,5300,1000,2400,1300],tmin=[0,1.5,3.1,4.3,19,22.5,29,33],tmax=[0,2.5,4.5,6,23,25,30,34],V=[17,14,17,14,12,16,15],β=[72,40,75,42,38,60,50],vmin=[8.67,9.8,7.6,8.1,7.3,6.9, 6.5],vmax=[18,19.2,18.7,25.2,23.4,23.7,22],A=480,B=720,C=2.7,D=125000.设七个未知量分别为x1,x2,x3,x4,x5,x6,x7.未知量需要满足vmin(i)≤x(i)≤vmax(i).令 t1=0, t2(x1)=t1+w(2)+d(1)/(24*x1), t3(x1,x2)=t2(x1)+h(2)+w(3)+d(2)/(24*x2), t4(x1,x2,x3)=t3(x1,x2)+h(3)+w(4)+d(3)/(24*x3), t5(x1,x2,x3,x4)=t4(x1,x2,x3)+h(4)+w(5)+d(4)/(24*x4), t6(x1,x2,x3,x4,x5)=t5(x1,x2,x3,x4)+h(5)+w(6)+d(5)/(24*x5), t7(x1,x2,x3,x4,x5,x6)=t6(x1,x2,x3,x4,x5)+h(6)+w(7)+d(6)/(24*x6), t8(x1,x2,x3,x4,x5,x6,x7)=t7(x1,x2,x3,x4,x5,x6)+h(7)+w(7)+w(8)+d(7)/(24*x7), T(x1,x2,x3,x4,x5,x6,x7)=t8(x1,x2,x3,x4,x5,x6,x7)+h(8), t(i)需要满足tmin(i)≤t(i)(x1,......,xi)≤tmax(i),函数T(x1,x2,x3,x4,x5,x6,x7)≤40 第一个函数为f1(x1,x2,x3,x4,x5,x6,x7)=A*∑((β(i)*d(i)*x(i))/(24*V(i)^3)+(D/720)*∑(d(i)/x(i))+B*T(x1,x2,x3,x4,x5,x6,x7)*C,求出它的最大值f1max和最小值f1min,命令新函数f11(x1,x2,x3,x4,x5,x6,x7)=(f1(x1,x2,x3,x4,x5,x6,x7)-f1min)/(f1max-f1min),求f11的最小值。
时间: 2023-08-13 14:06:28 浏览: 59
以下是MATLAB代码实现:
```matlab
% 定义目标函数
f = @(x) -f1(x);
% 定义约束条件
Aeq = []; beq = [];
lb = vmin; ub = vmax;
tmin = [0,1.5,3.1,4.3,19,22.5,29,33];
tmax = [0,2.5,4.5,6,23,25,30,34];
nonlcon = @(x) tcon(x, tmin, tmax);
% 设置初始点
x0 = (vmin + vmax) / 2;
% 求解最优解
[xopt, fopt] = fmincon(f, x0, [], [], Aeq, beq, lb, ub, nonlcon);
% 计算f1max和f1min
f1max = -f1(vmin);
f1min = -f1(vmax);
% 定义新的目标函数f11
f11 = @(x) (f1(x)-f1min)/(f1max-f1min);
% 求解f11的最小值
f11opt = f11(xopt);
```
其中,我们使用fmincon函数求解最优解,tcon函数用于定义t的约束条件,代码如下:
```matlab
function [c, ceq] = tcon(x, tmin, tmax)
% 定义t的约束条件
t = zeros(8, 1);
t(1) = 0;
t(2) = t(1) + 1*w(2) + d(1)/(24*x(1));
t(3) = t(2) + h(2) + w(3) + d(2)/(24*x(2));
t(4) = t(3) + h(3) + w(4) + d(3)/(24*x(3));
t(5) = t(4) + h(4) + w(5) + d(4)/(24*x(4));
t(6) = t(5) + h(5) + w(6) + d(5)/(24*x(5));
t(7) = t(6) + h(6) + w(7) + d(6)/(24*x(6));
t(8) = t(7) + h(7) + w(7) + w(8) + d(7)/(24*x(7));
c = [tmin-t(1:7); t(1:7)-tmax];
ceq = [];
end
```
阅读全文