[求助]查看我的优化程序那里出错了?
约束条件文件function [c,ceq]=mycon(x)
n=1
for n=1:4;
c(1)=6*5660*x(3)/(0.09*n*x(1)^2)-500*10^6;
if x(3)>(x(4)-0.045)*(2*x(1)/x(2)-1)
q=1.5*5660*(x(2)-x(1))*((x(4)-x(3)-0.045)/(x(2)-x(1)))^2/(0.09*n*(x(1)*(x(4)-0.045)-x(2)*0.045);
else
q=6*5660*(x(4)-0.045)/(0.09*n*x(2)^2);
c(2)=q-500*10^6;
end ;
k=6*2.1*10^11*0.92*n*0.09*x(2)^3/(12*x(4)^3*(1+((x(4)-0.045)/x(4))^3)*(1-2*(x(3)/(x(4)-0.045))^1.5)+(x(3)/X(4))^3*(x(2)/x(1)));
c(3)=fabs((k-73.5)/73.5-0.005;
ceq=0;
A=[-1 0 0 0
0 1 0 0
1 -1 0 0
0 0 -1 0
0 0 0 1];
b=[0.0083;0.02;-0.001;0;0.6];
end;
目标函数文件
function f=myfun(x)
f=2*7.8*10^3*9.8*0.09*n*(x(1)*x(3)+(x(4)-x(3)-0.045)*(x(1)+x(2))/2+x(2)*0.045)
命令窗口的命令
b=[0.0083;0.02;-0.001;0;0.6];
A=[-1 0 0 0
0 1 0 0
1 -1 0 0
0 0 -1 0
0 0 0 1];
x0=[0.01;0.025;0.04;0.6];
lb=zeros(4,1);
[x,fval,exitflag,output,lambda]=fmincon(@opt0202514_o,x0,A,b,[],[],[],[],@opt_0202514_c)
[此贴子已经被作者于2006-4-17 22:07:37编辑过]