Error: Failure in initial user-supplied objective function evaluation when using fminunc ?

6 views (last 30 days)
Hi, I plan to calculate a minimum distance estimator using fminunc function.
[b,fun,flag] = fminunc(@cov,b0);
However, during execution, Matlab send me an error message:
Error: Failure in initial user-supplied objective function evaluation
Following some suggestion from previous thread, I command
dbstop if caught error
And then run my code again. Matlab located the error at
Caught-error breakpoint was hit in optimget>optimgetfast at line 102. The error was:
Reference to non-existent field 'DiffMinChange'.
102 value = options.(name);
the cov function is defined as
%******************************
% Minimum Distance Procedure
%******************************
function f=cov(b):
fmm = fcn(b); %parameterized moment
peso= diag(diag(var));
f = (m-fmm)'*inv(peso)*(m-fmm); %m is vector of actual covariances - fmm is implied covariances
end

Answers (1)

Walter Roberson
Walter Roberson on 15 Nov 2016
It appears to me that your installation somehow combines multiple versions of the fmincon support routines, as if someone had copied some of them instead of doing a complete installation.
At the very least you should
rehash toolboxcache
and if the problem continues then you will need to check your MATLAB path and possibly reinstall the Optimization Toolbox
  2 Comments
Lu zhang
Lu zhang on 16 Nov 2016
Edited: Lu zhang on 16 Nov 2016
After I rehash the toolbox, the error message remains
Error using feval
Error: File: cov.m Line: 4 Column: 18
Unexpected MATLAB operator.
Error in fminunc (line 250)
f = feval(funfcn{3},x,varargin{:});
Caused by:
Failure in initial user-supplied objective function evaluation. FMINUNC cannot
continue.
and shift+F5 gives me
Reference to non-existent field 'DiffMinChange'.
Error in optimget>optimgetfast (line 102)
value = options.(name);
Error in optimget (line 25)
o = optimgetfast(options,name,default);
Error in fminunc (line 201)
options.DiffMinChange = optimget(options,'DiffMinChange',defaultopt,'fast');
How to restall the optimization toolbox?
Walter Roberson
Walter Roberson on 16 Nov 2016
I just noticed that you are using dbstop if caught error. The error you are detecting is not necessarily a problem, since it is caught and potentially dealt with smoothly. Sometimes Mathworks writes "try it and see" code instead of checking more directly for errors.
Where is your cov getting m from? Is your cov a nested function grabbing from a shared variable?

Sign in to comment.

Categories

Find more on Linear Programming and Mixed-Integer Linear Programming in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!