所报的错为:
错误使用 ATCDemo>ATCconstraints0
输入参数太多。
出错 fmincon (line 622)
[ctmp,ceqtmp] = feval(confcn{3},X,varargin{:});
出错 ATCDemo>ATC_P1 (line 58)
[xopt,fopt] = fmincon(@ATC_F1,x0,[],[],[],[],lb,ub,@ATCconstraints0,optimset('display','off'),v,w,z);
出错 ATCDemo>ATCinnerloop (line 49)
P1_output = ATC_P1(v(1),w(1),z0);
出错 ATCDemo (line 21)
[c,x,f] = ATCinnerloop(v,w,z0);
原因:
Failure in initial nonlinear constraint function evaluation. FMINCON cannot continue.
程序如下:
function [c,x,f] = ATCinnerloop(v,w,z0)
P1_output = ATC_P1(v(1),w(1),z0);
c1 = P1_output.c;
z = P1_output.x;
% f = P1_output.f;
f = P1_output.F;
function P1_output = ATC_P1(v,w,z)
x0 = [0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0];
lb = [0 0 0 0 0 0 0 0];
ub = [10 10 10 10 10 10 10 10];
[xopt,fopt] = fmincon(@ATC_F1,x0,[],[],[],[],lb,ub,@ATCconstraints0,optimset('display','off'),v,w,z);
disp(['x*=[' num2str(xopt(1)) ', ' num2str(xopt(2)) ',' num2str(xopt(3)) ',' num2str(xopt(4)) ', ' num2str(xopt(5)) ', ' num2str(xopt(6)) ', ' num2str(xopt(7)) ', ' num2str(xopt(8)) '], f(x*)=' num2str(fopt)])
c1 = [xopt(3)-z xopt(6)-z xopt(11)-z];
P1_output.F = fopt;
P1_output.c = c1;
function obj = ATC_F1(x,v,w,z)
a = [1 1];
c = x(8)-z;
f = a(1)*x(1)^2+a(2)*x(2)^2;
phi_1 = v*c + (w*c)^2;
obj = f + phi_1;
function [g,h] = ATCconstraints0(x)
g = [x(3)^(-2)+x(4)^2-x(5)^2
x(5)^2+x(6)^(-2)-x(7)^2];
h = [x(1)^2-x(3)^2-x(4)^(-2)-x(5)^2
x(2)^2-x(5)^2-x(6)^2-x(7)^2];
错误使用 ATCDemo>ATCconstraints0
输入参数太多。
出错 fmincon (line 622)
[ctmp,ceqtmp] = feval(confcn{3},X,varargin{:});
出错 ATCDemo>ATC_P1 (line 58)
[xopt,fopt] = fmincon(@ATC_F1,x0,[],[],[],[],lb,ub,@ATCconstraints0,optimset('display','off'),v,w,z);
出错 ATCDemo>ATCinnerloop (line 49)
P1_output = ATC_P1(v(1),w(1),z0);
出错 ATCDemo (line 21)
[c,x,f] = ATCinnerloop(v,w,z0);
原因:
Failure in initial nonlinear constraint function evaluation. FMINCON cannot continue.
程序如下:
function [c,x,f] = ATCinnerloop(v,w,z0)
P1_output = ATC_P1(v(1),w(1),z0);
c1 = P1_output.c;
z = P1_output.x;
% f = P1_output.f;
f = P1_output.F;
function P1_output = ATC_P1(v,w,z)
x0 = [0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0];
lb = [0 0 0 0 0 0 0 0];
ub = [10 10 10 10 10 10 10 10];
[xopt,fopt] = fmincon(@ATC_F1,x0,[],[],[],[],lb,ub,@ATCconstraints0,optimset('display','off'),v,w,z);
disp(['x*=[' num2str(xopt(1)) ', ' num2str(xopt(2)) ',' num2str(xopt(3)) ',' num2str(xopt(4)) ', ' num2str(xopt(5)) ', ' num2str(xopt(6)) ', ' num2str(xopt(7)) ', ' num2str(xopt(8)) '], f(x*)=' num2str(fopt)])
c1 = [xopt(3)-z xopt(6)-z xopt(11)-z];
P1_output.F = fopt;
P1_output.c = c1;
function obj = ATC_F1(x,v,w,z)
a = [1 1];
c = x(8)-z;
f = a(1)*x(1)^2+a(2)*x(2)^2;
phi_1 = v*c + (w*c)^2;
obj = f + phi_1;
function [g,h] = ATCconstraints0(x)
g = [x(3)^(-2)+x(4)^2-x(5)^2
x(5)^2+x(6)^(-2)-x(7)^2];
h = [x(1)^2-x(3)^2-x(4)^(-2)-x(5)^2
x(2)^2-x(5)^2-x(6)^2-x(7)^2];