clear;
clc;
lb = [1;0.625;25;25];
ub = [1.375;1;150;240];
A=[-1 0 0.0193 0;
0 -1 0.00954 0;
0 0 0 1;
-1 0 0 0;
0 -1 0 0];
b=[0;0;240;-1.1;-0.6];
function [c,ceq] = mycon(x)
c=-pi*x(3)*x(3)-4/3*pi*x(3)*x(3)*x(3)+1296000;
ceq = [];
end
function [ f7 ] = mypeaks( x )
f7=0.6224*x(1)*x(3)*x(4)+1.7781*x(2)*x(3)^2+3.1661*x(1)^2*x(4)+19.84*x(1)^2*x(3);
end
for i=1:50
x0 = [1;0;0;0]+1.*rand(4,1); % randomly determine the initial point
% x0 = [0.5 -1.5];
% sqp
sqp_opts = optimset('Algorithm','sqp','Display','iter-detailed' );
[x,fval,exitflag,output]=fmincon(@mypeaks,x0,A,b,[],[],lb,ub,@mycon,sqp_opts);
% %% ga
% ga_opts = gaoptimset('Display','off','PopulationSize',100);
% [x,fval,exitflag,output]=ga(@mypeaks,4,A,b,[],[],lb,ub,@mycon,ga_opts);
% %% Record data
recordY(i) = fval;
recordNfe(i) = output.funcCount;
end
最优解答案应该在8960,但是我的sqp算法算出来50个都是8949,没有变化很不对啊,请问哪里出了问题呢?