关于matlab多目标优化的一个问题,希望matlab高手能够帮忙!
function f=myfun(x);
rou=7900;
G=81000000000;
tao=810000000;
F1=16390;
F2=4000;
K1=80;
K2=50;
taoo=2000000000;
f=2000*pi*rou/G*(x(2)^4)*((x(3)+x(4)+x(5))^2)/(x(1)^3);
然后是非线性约束函数M文件:
function[c,ceq]=mycoun(x);
c=[8*x(2)*F1/(pi*(x(1)^3))*((4*x(2)-x(1))/(4*x(2)-4*x(1))+0.615*x(1)/x(2))-tao;
8*F1*(x(2)^3)*(x(3)+x(4)+x(5))/(G*(x(1)^3))-x(3)*x(6)-x(4)*x(7)-x(5)*x(8)+(x(3)+x(4)+x(5))*x(1);
4-x(2)/x(1);
x(2)/x(1)-16;
1.3-(taoo*pi*(x(1)^3)+0.75*8*F2*x(2)*((4*x(2)-x(1))/(4*x(2)-4*x(1))+0.615*x(1)/x(2)))/(8*F1*x(2)*((4*x(2)-x(1))/(4*x(2)-4*x(1))+0.615*x(1)/x(2)));
(x(3)*x(6)+x(4)*x(7)+x(5)*x(8))/x(2)-5.3;
atan(x(6)/(pi*x(2)))-9;
atan(x(7)/(pi*x(2)))-9;
atan(x(8)/(pi*x(2)))-9];
ceq=[G*(x(1)^4)/(8*(x(2)^3)*(x(3)+x(4)+x(5)))-K2;
G*(x(1)^4)/(8*(x(2)^3)*x(5))-K1];
最后实在command window里面输入
》》x0=[13;130;2;3;2;1;1;1];
》》lb=[12;120;1;3;1;1;1;1];
》》ub=[20;180;3;5;3;50;50;50];
》》options=optimset('LargeScale','off');
》》[x,fval]=fmincon('myfun',x0,[],[],[],[],lb,ub,'mycoun',options)
运行结果:
Warning: Options LargeScale = 'off' and Algorithm = 'trust-region-reflective' conflict.
Ignoring Algorithm and running active-set method. To run trust-region-reflective, set
LargeScale = 'on'. To run active-set without this warning, use Algorithm = 'active-set'.
> In fmincon at 395
??? Error using ==> fmincon at 600
FMINCON cannot continue because user supplied nonlinear constraint function
failed with the following error:
Undefined function or variable 'F1'.
目标函数公式和约束编辑的应该都没问题,我主要是语法上面 有什么错误,还有那个F1是个常数,明明定义了怎么还报错?谢谢 展开
然后是非线性约束函数M文件:此文件中用到的常数要在此函数中定义:如下
function[c,ceq]=mycoun(x)
F1=16390;
G=81000000000;
tao=810000000;
F2=4000;K1=80;K2=50;
taoo=2000000000;
c=[8*x(2)*F1/(pi*(x(1)^3))*((4*x(2)-x(1))/(4*x(2)-4*x(1))+0.615*x(1)/x(2))-tao;
8*F1*(x(2)^3)*(x(3)+x(4)+x(5))/(G*(x(1)^3))-x(3)*x(6)-x(4)*x(7)-x(5)*x(8)+(x(3)+x(4)+x(5))*x(1);
4-x(2)/x(1);
x(2)/x(1)-16;
1.3-(taoo*pi*(x(1)^3)+0.75*8*F2*x(2)*((4*x(2)-x(1))/(4*x(2)-4*x(1))+0.615*x(1)/x(2)))/(8*F1*x(2)*((4*x(2)-x(1))/(4*x(2)-4*x(1))+0.615*x(1)/x(2)));
(x(3)*x(6)+x(4)*x(7)+x(5)*x(8))/x(2)-5.3;
atan(x(6)/(pi*x(2)))-9;
atan(x(7)/(pi*x(2)))-9;
atan(x(8)/(pi*x(2)))-9];
ceq=[G*(x(1)^4)/(8*(x(2)^3)*(x(3)+x(4)+x(5)))-K2;
G*(x(1)^4)/(8*(x(2)^3)*x(5))-K1];
把常数项移到约束函数里面了,可还是不行,请问你能给我运行出来吗?谢谢