用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)/(24x1), t3(x1,x2)=t2(x1)+h(2)+w(3)+d(2)/(24x2), t4(x1,x2,x3)=t3(x1,x2)+h(3)+w(4)+d(3)/(24x3), t5(x1,x2,x3,x4)=t4(x1,x2,x3)+h(4)+w(5)+d(4)/(24x4), t6(x1,x2,x3,x4,x5)=t5(x1,x2,x3,x4)+h(5)+w(6)+d(5)/(24x5), t7(x1,x2,x3,x4,x5,x6)=t6(x1,x2,x3,x4,x5)+h(6)+w(7)+d(6)/(24x6), t8(x1,x2,x3,x4,x5,x6,x7)=t7(x1,x2,x3,x4,x5,x6)+h(7)+w(7)+w(8)+d(7)/(24x7), 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))/(24V(i)^3)+(D/720)∑(d(i)/x(i))+BT(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-15 14:08:41 浏览: 177
huiseyuce.zip_MATLAB财务数据_gm (1_1)_huiseyuce_数据预测代码_灰色模型
以下是MATLAB代码实现:
```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];
beta = [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;
% 定义目标函数
f1 = @(x1,x2,x3,x4,x5,x6,x7) A*sum((beta.*d.*x)./(24*V.^3)+(D/720)*sum(d./x))+B*T(x1,x2,x3,x4,x5,x6,x7)*C;
% 定义约束条件
vmin_constr = @(x) vmin - x;
vmax_constr = @(x) x - vmax;
t_constr = @(x) T(x(1),x(2),x(3),x(4),x(5),x(6),x(7)) - [0,tmax(2:end)];
T_constr = @(x) 40 - T(x(1),x(2),x(3),x(4),x(5),x(6),x(7));
% 求解最小值
options = optimoptions('fmincon','Display','iter','Algorithm','sqp');
x0 = [10,10,10,10,10,10,10];
[x,fval] = fmincon(@(x) f11(x,f1),x0,[],[],[],[],vmin,vmax,@(x) [vmin_constr(x),vmax_constr(x),t_constr(x),T_constr(x)],options);
% 定义f11函数
function y = f11(x,f)
f_max = f(18,19.2,18.7,25.2,23.4,23.7,22);
f_min = f(8.67,9.8,7.6,8.1,7.3,6.9,6.5);
y = (f(x(1),x(2),x(3),x(4),x(5),x(6),x(7))-f_min)/(f_max-f_min);
end
% 定义T函数
function y = T(x1,x2,x3,x4,x5,x6,x7)
t1 = 0;
t2 = t1+w(2)+d(1)/(24*x1);
t3 = t2+h(2)+w(3)+d(2)/(24*x2);
t4 = t3+h(3)+w(4)+d(3)/(24*x3);
t5 = t4+h(4)+w(5)+d(4)/(24*x4);
t6 = t5+h(5)+w(6)+d(5)/(24*x5);
t7 = t6+h(6)+w(7)+d(6)/(24*x6);
t8 = t7+h(7)+w(7)+w(8)+d(7)/(24*x7);
y = t8+h(8);
end
```
其中,`fmincon` 函数用于求解带约束条件的非线性优化问题,`f11` 函数用于对目标函数进行归一化,`T` 函数用于计算时间。需要注意的是,在定义约束条件时,需要将不等式转化为 $Ax \leq b$ 的形式,其中 $A$ 为系数矩阵,$b$ 为常数向量。
阅读全文