fmincon check Hessian (in DerivativeCheck)

9 ビュー (過去 30 日間)
Zohar
Zohar 2014 年 7 月 6 日
編集済み: Matt J 2014 年 7 月 8 日
When I set opts.DerivativeCheck='on' in fmincon, it checks only the gradient. How do I tell it to check the Hessian as well?
EDIT: My options
opts = optimset();
opts.MaxIter = 1e4;
opts.MaxFunEvals = 1e6;
opts.TolFun = 1e-4;
opts.Algorithm = 'interior-point'; % 'trust-region-reflective'
opts.GradObj = 'on';
opts.GradConstr = 'on';
opts.DerivativeCheck = 'on';
opts.Diagnostics = 'on';
opts.Display = 'iter';
%opts.Display = 'none';
opts.FinDiffType = 'central';
if 1
opts.HessMult = fH;
opts.Hessian = 'user-supplied';
%opts.Hessian = 'fin-diff-grads';
opts.SubproblemAlgorithm = 'cg';
else
opts.Hessian = 'lbfgs';
end

採用された回答

Matt J
Matt J 2014 年 7 月 6 日
編集済み: Matt J 2014 年 7 月 8 日
I don't think you can, but an indirect way would be to run like below with MaxIter=1 and have fmincon return the Hessian with the 'Hessian' option turned both on and off. Then you can check the Hessian error manually.
I agree it is counter-intuitive, but I think it might be deliberate that the DerivativeCheck does not test the Hessian. Often, minimization algorithms will work with fairly crude approximations to the Hessian, so maybe it is expected that your user-supplied Hessian will not always be exact. Or, maybe it is with large dimensional problems in mind, where finite difference derived Hessians are too expensive to compute, even for testing purposes, but you still might want to use DerivativeCheck to verify the gradient.
Q=[2 1;1,2];
Q=Q+Q.';
opts=optimoptions(@fmincon,'DerivativeCheck','on',...
'GradObj','on','Hessian','off','MaxIter',1);
[x,fval,exitflag,output,lambda,grad,H_off]=...
fmincon(@(x)objfun(x,Q),[1,2],[],[],[],[],[-1,-1],[1,1],[],opts)
opts=optimoptions(@fmincon,'DerivativeCheck','on',...
'GradObj','on','Hessian','on','MaxIter',1);
[x,fval,exitflag,output,lambda,grad,H_on]=...
fmincon(@(x)objfun(x,Q),[1,2],[],[],[],[],[-1,-1],[1,1],[],opts)
HessianError=H_on-H_off
keyboard
function [f,g,H]=objfun(x,Q)
x=x(:);
f=x.'*Q*x/2;
g=Q*x;
H=eye(2);
  1 件のコメント
Zohar
Zohar 2014 年 7 月 6 日
Nice idea!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by