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

11 次查看(过去 30 天)
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

回答(1 个)

Walter Roberson
Walter Roberson 2016-11-15
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 个评论
Lu zhang
Lu zhang 2016-11-16
编辑:Lu zhang 2016-11-16
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 2016-11-16
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?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Solver-Based Nonlinear Optimization 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by