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

조회 수: 3 (최근 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