求(560*16*x4+16*x3+4*x2)*(167+2*x1)*(850+x6)*(2000+5*x6)/(6400*(950+x6-x5)*(2000+3*x6))的最大值,我是新手,以下是自己的做法:
fmax=-inf;
ff(5000000)=0;
cnt=0;
for x1=0:100
temp1=167+2*x1;
for x2=0:100-x1
x1_2=x1+x2;
for x3=0:100-x1_2
x1_3=x1_2+x3;
for x4=0:100-x1_3
x1_4=x1_3+x4;
temp4=560+16*x4+16*x3+4*x2;
for x5=0:100-x1_4;
x6=100-(x1_4+x5);
if x6>=0 || x6<=100
temp6=950+x6-x5;
cnt=cnt+1;
f=temp4*temp1*(850+x6)*(2000+5*x6)/(6400*temp6*(2000+3*x6));
ff(cnt)=f;
if fmax<f
famx=f;
[x1,x2,x3,x4,x5,fmax]
end
end
end
end
end
end
end
fmax
一直在循环算,时间似乎要算比较久,我也不知道对不对,请问有效率更高的方法吗?还是这种做法是错的?
fmax=-inf;
ff(5000000)=0;
cnt=0;
for x1=0:100
temp1=167+2*x1;
for x2=0:100-x1
x1_2=x1+x2;
for x3=0:100-x1_2
x1_3=x1_2+x3;
for x4=0:100-x1_3
x1_4=x1_3+x4;
temp4=560+16*x4+16*x3+4*x2;
for x5=0:100-x1_4;
x6=100-(x1_4+x5);
if x6>=0 || x6<=100
temp6=950+x6-x5;
cnt=cnt+1;
f=temp4*temp1*(850+x6)*(2000+5*x6)/(6400*temp6*(2000+3*x6));
ff(cnt)=f;
if fmax<f
famx=f;
[x1,x2,x3,x4,x5,fmax]
end
end
end
end
end
end
end
fmax
一直在循环算,时间似乎要算比较久,我也不知道对不对,请问有效率更高的方法吗?还是这种做法是错的?