Strange error in fmincon with nonlinear constraints

조회 수: 2 (최근 30일)
Manthos Vogiatzoglou
Manthos Vogiatzoglou 2011년 2월 7일
Hello all
my optimization problem is as follows:
function fval = myfunc(theta,data,spec) % the objective function defined in an M file. theta is the parameters vector
My function has only nonlinear constraints so I create another function:
function [c, ceq]=myconstr(theta)
In a third function named fitmyfunc I have the optimization routine:
options = optimset('Algorithm','interior-point','Display','iter','MaxFunEvals',9000,'MaxIter',1000,'TolCon',10^-12,'TolFun',10^-4,'TolX',10^-5,'FinDiffType','central');
[params, LogL,exitflag]= fmincon(@myfunc,theta0,[],[],[],[],[],[],@myconstr,options,data,spec);
I get the following error message:
??? Error using ==> myconstr Too many input arguments.
Error in ==> fmincon at 597 [ctmp,ceqtmp] = confcn{3}(X,varargin{:});
Error in ==> fitmyfunc at 67 [params, fval,exitflag,output,lambda,grad,hessian]= fmincon(@myfunc,theta0,[],[],[],[],[],[],@myconstr,options,data,spec);
Caused by: Failure in initial user-supplied nonlinear constraint function evaluation. FMINCON cannot continue.
It is obvious that my constraints function does not have too many input arguments. There is only one input argument, theta, which is the parameters vector. I use MATLABR2008b. Does anybody has any idea on what causes my problem? Thanks in advance!

답변 (2개)

Manthos Vogiatzoglou
Manthos Vogiatzoglou 2011년 2월 7일
The input arguments in myfunc and myconstr should(?) be identical. I changed myconstr to [c, ceq] = myconstr(theta, data, spec) and the problem seems to solved

Fara
Fara 2011년 2월 8일
Hi Manthos,
That may not be the issue. I used non-linear constraints for my codes too and I only passed input parameters (i.e., theta in your case).
I don't have much Matlab experiences. The way I pass parameters to fmincon is abit different from yours. Here is my line for your reference.
[paramr, fval, exitflag, Output] = fmincon(@(paramr) reg_mrsG_lik(regdata(nc), wOutput, paramr), param0, A, b, Aeq, beq, lB, uB,@reg_con, options);
my function is reg_mrsG_lik;
input parameters: regdata(nc), wOutput, paramr;
starting values: param0
Regards, Fara

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by