Failure in initial user-supplied objective function evaluation. FMINCON cannot continue.

8 views (last 30 days)
I 'll be working on the nonlinear program with fmincon as follows:
>> load('JIRIOT_base.mat')
>> options = optimoptions('fmincon',
'Display','iter','Algorithm','interior-point');
>> [x,fval,exitflag,output,lambda] =
fmincon(@(x)mindistance(x,xo),xo,A,b,Aeq,beq,lb,[],[],options)
Then, error messages occurred as follows:
error: barrier (line 22)
Caused by:
Failure in initial user-supplied objective function evaluation. FMINCON cannot continue.
error:fmincon (line 905)
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] = barrier(funfcn,X,A,B,Aeq,Beq, l,u,confcn,options.HessFcn, ...
my objective function code is as follows:
>>function y = mindistance(x,xo) % objective function
>>y = sum(abs(xo(1:14386,1)).*(x(1:14386,1)./xo(1:14386,1)).*(log(x(1:14386,1)./xo(1:14386,1))-1)+1);
I guess there are many zeros in 'JIRIOT_base.mat'file. I attached the matfile, so please tell me how to solve my program.

Accepted Answer

Roger Stafford
Roger Stafford on 20 Jan 2014
The purpose of the xo argument in fmincon(fun,xo,...) is that it, in Mathworks' words, "starts at xo and attempts to find a minimum x". In view of this it makes no sense to also include xo as an argument in the objective function, 'fun', itself as you have done here. It should be exclusively an estimate of where 'fmincon' should start in its iterations to a final minimum value and should not appear in the objection function.

More Answers (1)

Walter Roberson
Walter Roberson on 20 Jan 2014
At the MATLAB command prompt, command
dbstop if caught error
and run your program. It should stop in your mindistance function and tell you what error it encountered there.
If you have any 0's in your x0 then the division by 0 in the log() term is going to give NaN there, and log(NaN) would be NaN. That would be multiplied by something to the left, giving NaN at that position. Then, sum() of a term that includes NaN is going to give NaN, so if there is even one 0 in your x0, your entire right hand side is going to give NaN. One would presume that that is not what you would want, but we cannot guess what result you would like if there is a 0 in your x0.
Question: your code fragment
abs(xo(1:14386,1)).*(x(1:14386,1)./xo(1:14386,1))
the xo in numerator and denominator are going to cancel out except for their sign (because of the abs()) so would that not be
sign(x0(1:14386,1)) .* x(1:14386,1)
except that the sign() version is better behaved at 0 ?
  8 Comments
Walter Roberson
Walter Roberson on 20 Jan 2014
The difficulty is 0's in x0. What would you like to have happen with them?
If you would like to remove the 0 entries of x0 and the corresponding entries of x (to avoid length problems), then logically it becomes the same as using a shorter x0 and shorter x of the same length -- no point in varying values that are going to be ignored. So...
After the load,
x0 = nonzeros(x0);
and change your function to
y = sum(sign(xo) .* x .* (log(x ./ xo)-1)+1);

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!