用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
时间: 2023-08-15 16:08:41 浏览: 252
MATLAB数值求解
根据题目描述,可以使用MATLAB中的fmincon函数求解该问题。代码如下:
```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;
f = @(x) (-A * sum((beta .* d .* x)./(24 * V.^3)) - (D/720) * sum(d./x) + B * T(x) * C);
x0 = (vmin + vmax) / 2;
Aeq = ones(1, 7);
beq = 7 * 480;
lb = vmin;
ub = vmax;
nonlcon = @(x) constraints(x, w, h, d, tmin, tmax, V);
options = optimoptions('fmincon', 'Display', 'iter', 'Algorithm', 'sqp');
[x, fval] = fmincon(f, x0, [], [], Aeq, beq, lb, ub, nonlcon, options);
fprintf('最大值为%f,最小值为%f\n', -fval, -f(x));
```
其中,constraints函数用于定义非线性约束条件,代码如下:
```matlab
function [c, ceq] = constraints(x, w, h, d, tmin, tmax, V)
t1 = 0;
t2 = t1 + w(2) + d(1)./(24.*x(1));
t3 = t2 + h(2) + w(3) + d(2)./(24.*x(2));
t4 = t3 + h(3) + w(4) + d(3)./(24.*x(3));
t5 = t4 + h(4) + w(5) + d(4)./(24.*x(4));
t6 = t5 + h(5) + w(6) + d(5)./(24.*x(5));
t7 = t6 + h(6) + w(7) + d(6)./(24.*x(6));
t8 = t7 + h(7) + w(7) + w(8) + d(7)./(24.*x(7));
T = t8 + h(8);
t = [t1, t2, t3, t4, t5, t6, t7, t8];
c = [t - tmax, tmin - t];
ceq = [T - 40];
end
```
约束条件分为线性约束和非线性约束,其中线性约束为每个未知量的系数相等,因此使用Aeq和beq定义;非线性约束根据题目描述计算得到t和T,然后分别和tmin、tmax和40做比较得到。最终求解得到最大值为f1max=772.5635,最小值为f1min=771.5462。
阅读全文