필터 지우기
필터 지우기

I get matlab error :Failure in initial user-supplied objective function evaluation. FMINCON cannot continue.

조회 수: 1 (최근 30일)
Dear all, I am new to optimization toolbox and 'fmincon' function throws error message :'Failure in initial user-supplied objective function evaluation. FMINCON cannot continue.' Please see the code below: Y is an array. F = @(x,xdata) x(1)*(exp(-x(2)*xdata))+x(3)*(exp(-x(4)*xdata)); pot_diff = abs(max(y) - min(y)); tau = 0.01*length(y); x0 = [0.02 20 0.04 10]; A = []; b = []; Aeq = []; beq = []; lb = []; ub = []; % lb = [0.1*pot_diff 0.3*tau 0.3*pot_diff 0.1*tau]; % ub = [0.6*pot_diff 0.8*tau 0.8*pot_diff 0.6*tau]; options = optimoptions(@fmincon,'Algorithm','interior-point','Display','off'); [x,fval,exitflag,output,lambda,grad,hessian] = fmincon(F,x0,A,b,Aeq,beq,lb,ub,@my_nlincon,options)
function [C,Ceq] = my_nlincon(x)
C(1) = x(3)-x(1); C(2) = x(2)-x(4); Ceq = []; return
The complete error message is : Error using @(x,xdata)x(1)*(exp(-x(2)*xdata))+x(3)*(exp(-x(4)*xdata)) Not enough input arguments. Error in fmincon (line 640) initVals.f = feval(funfcn{3},X,varargin{:}); Error in strt (line 113) [x,fval,exitflag,output,lambda,grad,hessian] = fmincon(F,x0,A,b,Aeq,beq,lb,ub,@my_nlincon,options) Caused by: Failure in initial user-supplied objective function evaluation. FMINCON cannot continue.
Please help me solve this error. I also have doubt on using fmincon for a equation having 4 parameters.

채택된 답변

Torsten
Torsten 2017년 7월 27일
1. Input vector for the objective function F is only x, not x and xdata.
2. I don't see that you define "xdata".
3. Since I suspect that "xdata" will be a vector, take care that F returns a scalar. As it stands, F returns a vector.
Best wishes
Torsten.
  댓글 수: 1
praveen
praveen 2017년 7월 28일
Thanks dude. The problem is solved . Actually 'xdata' is calculated prior to the creation of function handle and it is a scalar. :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by