|
我改了以前约束里存在的问题,运行还是有问题!
以下是我做的3个M文件
myfun2.m
function f=myfun2(x)
f=0.785398*(4.75*x(1)*x(2)^2*x(3)^2+85*x(1)*x(2)*x(3)^2-85*x(1)*x(3)^2+0.92*x(1)*x(6)^2-x(1)*x(5)^2+0.8*x(1)*x(2)*x(3)*x(6)-1.6*x(1)*x(3)*x(6)+x(4)*x(5)^2+x(4)*x(6)^2+28*x(5)^2+32*x(6)^2);
mycon2.m
function [c,ceq]=mycon2(x)
c(1)=0.9-x(1)/(x(2)*x(3));
c(2)=x(1)/(x(2)*x(3))-1.4;
c(3)=x(2)*x(3)-300;
c(4)=1486250/(x(2)*x(3)*sqrt(x(1)))-550;
c(5)=(9064860*2.65*2.22)/(x(1)*x(2)*x(3)^2)-400;
c(6)=(((9064860*2.65*2.22)/(x(1)*x(2)*x(3)^2)-400)*1.59*1.81)/(2.65*2.22)-400;
c(7)=(117.04*x(4)^4)/(x(2)*x(3)*x(5)^4)-0.003*x(4);
c(8)=sqrt(((2.85*10^6*x(4))/(x(2)*x(3)))^2+2.4*10^12)/x(5)^3-5.5;
c(9)=sqrt(((2.85*10^6*x(4))/(x(2)*x(3)))^2+6*10^13)/x(6)^3-5.5;
ceq=[];
myans2.m
A=[0 -1 0 0 0 0
0 0 -1 0 0 0
0 0 0 0 -1 0
0 0 0 0 1 0
0 0 0 0 0 -1
0 0 0 0 0 1
1 0 0 -1 0 0.5];
b=[-17;-2;-100;150;-130;200;40];
x0=[230;21;8;420;120;160];
options=optimset('LargeScale','off','maxfunevals',1e+20,'MaxIter',1000)
[x,fval]=fmincon(@myfun2,x0,A,b,[],[],[],[],@mycon2,options)
这是一个关于传动齿轮设计的优化问题运行后出现以下问题:
>>
>> myanswer2
Maximum number of function evaluations exceeded;
increase OPTIONS.MaxFunEvals
x =
124.4702
53.0046
3.1608
147.8510
150.8096
129.1904
fval =
2.3756e+007
我加上了options=optimset('LargeScale','off','maxfuneval',1e+20,'MaxIter',20);运行后:
>> myanswer2
Maximum number of function evaluations exceeded;
increase OPTIONS.MaxIter
x =
180.2363
53.8921
3.7217
205.2165
141.5584
129.9901
fval =
4.4890e+007
增大MAXiter 也不行!!怎么办,哪里有问题??
很明显,这是错的,请问老师哪里有问题???
|
|