MATLAB求解关于带有不等式约束的非线性方程组问题

从师姐那弄来的题,计算体积的最优值,目标函数为
y=0.25*pi*(x(1)*power(x(2),2)*power(x(3),2)-power(x(5),2)+(x(1)*power(x(2),2)*power(x(3),2))/25-power(x(6),2)-0.8*x(1)*power(5*x(2)*x(3)-10*x(3),2)+2.048*x(1)*power(x(6),2)-0.05*x(1)*power(5*x(2)*x(3)-10*x(1)-1.6*x(6),2)+x(4)*power(x(5),2)+x(4)*power(x(6),2));
然后有16个约束条件,分别为
c(1)=17-x(2);
c(2)=0.9-x(1)/(x(2)*x(3));
c(3)=x(1)/(x(2)*x(3))-1.4;
c(4)=2-x(3);
c(5)=x(2)*x(3)-300;
c(6)=100-x(5);
c(7)=x(5)-150;
c(8)=130-x(6);
c(9)=x(6)-200;
c(10)=x(1)+0.5*x(6)+40-x(4);
c(11)=21676/(x(2)*x(3)*sqrt(x(1)))-550;
c(12)=6.6992/(x(1)*x(3))-400;
c(13)=6.2020/(x(1)*x(3))-400;
c(14)=117.04*power(x(4),3)/(x(2)*x(3)*power(x(5),4))-0.003*x(4);
c(15)=sqrt(power(2.85*power(10,6)*x(4)/(x(2)*x(3)),2)+2.4*power(10,12))/power(x(5),3)-5.5;
c(16)=sqrt(power(2.85*power(10,6)*x(4)/(x(2)*x(3)),2)+6*power(10,13))/power(x(6),3)-5.5;
初始值
x0=[230;21;8;420;120;160]
然后我用了fmincon函数来求最优解最后得出的结果居然是个负数,不知道是哪里错了,希望大家能够帮忙算算看是不是也是这样,如果不是的话请指点一下,谢谢啦~

我的程序:

function y=myobj(x)
y=0.25*pi*(x(1)*power(x(2),2)*power(x(3),2)-power(x(5),2)+(x(1)*power(x(2),2)*power(x(3),2))/25-power(x(6),2)-0.8*x(1)*power(5*x(2)*x(3)-10*x(3),2)+2.048*x(1)*power(x(6),2)-0.05*x(1)*power(5*x(2)*x(3)-10*x(1)-1.6*x(6),2)+x(4)*power(x(5),2)+x(4)*power(x(6),2));

function[c,ceq]=mycon(x)
c(1)=17-x(2);
c(2)=0.9-x(1)/(x(2)*x(3));
c(3)=x(1)/(x(2)*x(3))-1.4;
c(4)=2-x(3);
c(5)=x(2)*x(3)-300;
c(6)=100-x(5);
c(7)=x(5)-150;
c(8)=130-x(6);
c(9)=x(6)-200;
c(10)=x(1)+0.5*x(6)+40-x(4);
c(11)=21676/(x(2)*x(3)*sqrt(x(1)))-550;
c(12)=6.6992/(x(1)*x(3))-400;
c(13)=6.2020/(x(1)*x(3))-400;
c(14)=117.04*power(x(4),3)/(x(2)*x(3)*power(x(5),4))-0.003*x(4);
c(15)=sqrt(power(2.85*power(10,6)*x(4)/(x(2)*x(3)),2)+2.4*power(10,12))/power(x(5),3)-5.5;
c(16)=sqrt(power(2.85*power(10,6)*x(4)/(x(2)*x(3)),2)+6*power(10,13))/power(x(6),3)-5.5;

ceq=[];

A=[];
b=[];
Aeq=[];
beq=[];
lb=[0;0;0;0;0;0];
ub=[inf;inf;inf;inf;inf;inf];
x0=[230;21;8;420;120;160];
options=optimset('LargeScale','off','display','iter');
[x,fval,exitflag]=fmincon(@myobj,x0,A,b,Aeq,beq,lb,ub,@mycon,options)
请指点一下拜托了~~我的分数快没了所以就只能这点了不好意思啦

你的非线性函数里面有大量线性的句子。这是错误的原因,修改到A,b,lb,ub里面去。

从目标函数来看,最好用遗传算法ga来求

c(1)=17-x(2)
c(4)=2-x(3);
c(6)=100-x(5);
c(7)=x(5)-150;
c(8)=130-x(6);
c(9)=x(6)-200;
c(10)=x(1)+0.5*x(6)+40-x(4);
以上7项,前6项放在lb、ub中,最后1项放到A、b中

作如下变动:
A=[1,0 0 -1 0 .5];
b=-40;
lb=[-2^10,17,2,-2^10,100,130];
ub=[inf,inf,inf,inf,150,200];
Aeq=[];
beq=[];
x0=[230;21;8;420;120;160];

解得:
x =
420.0000
150.0000
2.0000
525.0000
100.0000
130.0000

fval =
-6.6415e+08
exitflag =
4
exitflag=4查的:4 Computed search direction too small.不是很满意。

是不是你的目标函数或约束条件有问题,我求的的数值也不好,负数!
温馨提示:答案为网友推荐,仅供参考