diff --git a/matlab/optimization/dynare_minimize_objective.m b/matlab/optimization/dynare_minimize_objective.m index e611bed46d67935b37019e185de9ff52d9d6c930..0f82b81c02eed3d28914f949c7206bd13cb5fba2 100644 --- a/matlab/optimization/dynare_minimize_objective.m +++ b/matlab/optimization/dynare_minimize_objective.m @@ -289,6 +289,8 @@ switch minimizer_algorithm end nit=options_.newrat.maxiter; epsilon = options_.gradient_epsilon; + gstep_crit = NaN; + gstep_crit_rel = NaN; robust = false; Verbose = options_.newrat.verbosity; Save_files = options_.newrat.Save_files; @@ -311,6 +313,10 @@ switch minimizer_algorithm robust = options_list{i,2}; case 'TolFun' crit = options_list{i,2}; + case 'TolGstep' + gstep_crit = options_list{i,2}; + case 'TolGstepRel' + gstep_crit_rel = options_list{i,2}; case 'verbosity' Verbose = options_list{i,2}; case 'SaveFiles' @@ -324,8 +330,12 @@ switch minimizer_algorithm Save_files = 0; Verbose = 0; end + if isnan(gstep_crit) + gstep_crit = crit; + end hess_info.gstep=options_.gstep; - hess_info.htol = 1.e-4; + hess_info.htol = gstep_crit; + hess_info.htol_rel = gstep_crit_rel; hess_info.h1=epsilon*ones(n_params,1); hess_info.robust=robust; % here we force 7th input argument (flagg) to be 0, since outer product diff --git a/matlab/optimization/mr_hessian.m b/matlab/optimization/mr_hessian.m index c17b161b6716dbfe462626211fa4b94e43fe54ef..b763b70c8720ed837d080f788be65f486893a911 100644 --- a/matlab/optimization/mr_hessian.m +++ b/matlab/optimization/mr_hessian.m @@ -83,6 +83,11 @@ hess_info.h1 = min(hess_info.h1,0.9.*hmax); if htol0<hess_info.htol hess_info.htol=htol0; end +if not(isnan(hess_info.htol_rel)) + htol1=hess_info.htol; + hess_info.htol=abs(hess_info.htol_rel*f0); +end + xh1=x; f1=zeros(size(f0,1),n); f_1=f1; @@ -298,4 +303,6 @@ else hh1 = []; end -htol1=hhtol; +if isnan(hess_info.htol_rel) + htol1=hhtol; +end diff --git a/matlab/optimization/newrat.m b/matlab/optimization/newrat.m index 68a98987926826b8bbdc5c3b03333ca31ca5e5ea..2106ae0e494f303ec42dd9586dd53d774eae7c76 100644 --- a/matlab/optimization/newrat.m +++ b/matlab/optimization/newrat.m @@ -69,7 +69,7 @@ icount=0; nx=length(x); xparam1=x; %ftol0=1.e-6; -htol_base = max(1.e-7, ftol0); +htol_base = max(1.e-7, hess_info.htol); flagit=0; % mode of computation of hessian in each iteration; hard-coded outer-product of gradients as it performed best in tests ftol=ftol0; gtol=1.e-3; @@ -232,7 +232,7 @@ while norm(gg)>gtol && check==0 && jit<nit if flagit==2 hh=hh0; elseif flagg>0 - [dum, gg, htol0, igg, hhg, h1, hess_info]=mr_hessian(xparam1,func0,penalty,flagg,ftol0,hess_info,bounds,prior_std,Save_files,varargin{:}); + [dum, gg, htol0, igg, hhg, h1, hess_info]=mr_hessian(xparam1,func0,penalty,flagg,htol_base,hess_info,bounds,prior_std,Save_files,varargin{:}); if flagg==2 hh = reshape(dum,nx,nx); ee=eig(hh);