Fmincon too many input arguements

I used the fmincon, but always wrong
xi=1;
CAQL=1.33;CLTPD=1;b1=3*CAQL+abs(xi); b2=3*CLTPD+abs(xi);
alpha=0.01;beta=0.01;
fun=@(n) 0;
x0=[10,1];
nonlcon=@CAQL_CLTPD;
a=fmincon(fun,x0,[],[],[],[],[],[],nonlcon);
function:
function [c,ceq] = CAQL_CLTPD
y=@(x,t) normpdf(t+xi*sqrt(x(1)))+normpdf(t-xi*sqrt(x(1)));
g1=@(x,t) chi2cdf(((x(1)-1)*((b1*sqrt(x(1))-t).^2)./(9*x(1)*x(2)^2)),x(1)-1).*y(x,t);
g2=@(x,t) chi2cdf(((x(1)-1)*((b2*sqrt(x(1))-t).^2)./(9*x(1)*x(2)^2)),x(1)-1).*y(x,t);
c{1} = @(x) -(integral(@(t) g1(x,t),0,3*b1*sqrt(x(1)))-(1-alpha)); % CAQL
c{2} = @(x) (integral(@(t) g2(x,t),0,3*b2*sqrt(x(1)))-beta); % CLTPD
ceq = [];
the error message:
Error using CAQL_CLTPD
Too many input arguments.
Error in fmincon (line 639)
[ctmp,ceqtmp] = feval(confcn{3},X,varargin{:});
Error in Untitled (line 11)
a=fmincon(fun,x0,[],[],[],[],[],[],nonlcon);
Caused by:
Failure in initial nonlinear constraint function evaluation. FMINCON cannot continue.

 Accepted Answer

Walter Roberson
Walter Roberson on 31 Oct 2019
Your nonlinear constraint function must accept the x values that are input, and the returns must be numeric or empty.
You do not have the nonlinear constraint function return a function handle or cell array of function handles.

2 Comments

Sorry, I don't get what you mean.
It means I should return a value from nonlinear constraint function?
But I don't know how to do it, should I need to add or delect something?
function [c,ceq] = CAQL_CLTPD(x)
y=@(x,t) normpdf(t+xi*sqrt(x(1)))+normpdf(t-xi*sqrt(x(1)));
g1=@(x,t) chi2cdf(((x(1)-1)*((b1*sqrt(x(1))-t).^2)./(9*x(1)*x(2)^2)),x(1)-1).*y(x,t);
g2=@(x,t) chi2cdf(((x(1)-1)*((b2*sqrt(x(1))-t).^2)./(9*x(1)*x(2)^2)),x(1)-1).*y(x,t);
cf{1} = @(x) -(integral(@(t) g1(x,t),0,3*b1*sqrt(x(1)))-(1-alpha)); % CAQL
cf{2} = @(x) (integral(@(t) g2(x,t),0,3*b2*sqrt(x(1)))-beta); % CLTPD
c(1) = cf{1}(x);
c(2) = cf{2}(x);
ceq = [];

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!