Acknowledge option trust_region_initial_step_bound_factor in matlab based trust_region routine.
parent
e72dde69d3
commit
0d092a36a0
|
@ -119,7 +119,7 @@ License: GPL-3+
|
||||||
|
|
||||||
Files: matlab/trust_region.m
|
Files: matlab/trust_region.m
|
||||||
Copyright: 2008-2012 VZLU Prague, a.s.
|
Copyright: 2008-2012 VZLU Prague, a.s.
|
||||||
2014-2019 Dynare Team
|
2014-2021 Dynare Team
|
||||||
License: GPL-3+
|
License: GPL-3+
|
||||||
|
|
||||||
Files: matlab/one_sided_hp_filter.m
|
Files: matlab/one_sided_hp_filter.m
|
||||||
|
|
|
@ -232,9 +232,10 @@ elseif options.solve_algo==1
|
||||||
tolf, tolx, ...
|
tolf, tolx, ...
|
||||||
maxit, options.debug, arguments{:});
|
maxit, options.debug, arguments{:});
|
||||||
elseif options.solve_algo==9
|
elseif options.solve_algo==9
|
||||||
[x, errorflag] = trust_region(f, x, 1:nn, 1:nn, jacobian_flag, options.gstep, ...
|
[x, errorflag] = trust_region(f,x, 1:nn, 1:nn, jacobian_flag, options.gstep, ...
|
||||||
tolf, tolx, ...
|
tolf, tolx, maxit, ...
|
||||||
maxit, options.debug, arguments{:});
|
options.trust_region_initial_step_bound_factor, ...
|
||||||
|
options.debug, arguments{:});
|
||||||
elseif ismember(options.solve_algo, [2, 12, 4])
|
elseif ismember(options.solve_algo, [2, 12, 4])
|
||||||
if ismember(options.solve_algo, [2, 12])
|
if ismember(options.solve_algo, [2, 12])
|
||||||
solver = @solve1;
|
solver = @solve1;
|
||||||
|
@ -312,8 +313,9 @@ elseif ismember(options.solve_algo, [2, 12, 4])
|
||||||
end
|
end
|
||||||
[x, errorflag] = solver(f, x, j1(j), j2(j), jacobian_flag, ...
|
[x, errorflag] = solver(f, x, j1(j), j2(j), jacobian_flag, ...
|
||||||
options.gstep, ...
|
options.gstep, ...
|
||||||
tolf, options.solve_tolx, ...
|
tolf, options.solve_tolx, maxit, ...
|
||||||
maxit, options.debug, arguments{:});
|
options.trust_region_initial_step_bound_factor, ...
|
||||||
|
options.debug, arguments{:});
|
||||||
fre = true;
|
fre = true;
|
||||||
if errorflag
|
if errorflag
|
||||||
return
|
return
|
||||||
|
@ -323,8 +325,9 @@ elseif ismember(options.solve_algo, [2, 12, 4])
|
||||||
if max(abs(fvec))>tolf
|
if max(abs(fvec))>tolf
|
||||||
disp('Call solver on the full nonlinear problem.')
|
disp('Call solver on the full nonlinear problem.')
|
||||||
[x, errorflag] = solver(f, x, 1:nn, 1:nn, jacobian_flag, ...
|
[x, errorflag] = solver(f, x, 1:nn, 1:nn, jacobian_flag, ...
|
||||||
options.gstep, tolf, options.solve_tolx, ...
|
options.gstep, tolf, options.solve_tolx, maxit, ...
|
||||||
maxit, options.debug, arguments{:});
|
options.trust_region_initial_step_bound_factor, ...
|
||||||
|
options.debug, arguments{:});
|
||||||
end
|
end
|
||||||
elseif options.solve_algo==3
|
elseif options.solve_algo==3
|
||||||
if jacobian_flag
|
if jacobian_flag
|
||||||
|
|
|
@ -32,9 +32,10 @@ info.status = 1;
|
||||||
for it = options.periods:-1:1
|
for it = options.periods:-1:1
|
||||||
yf = endogenousvariables(:,it+1); % Values at next period, also used as guess value for current period
|
yf = endogenousvariables(:,it+1); % Values at next period, also used as guess value for current period
|
||||||
yf1 = yf(iyf);
|
yf1 = yf(iyf);
|
||||||
|
% TODO Call dynare_solve instead.
|
||||||
[tmp, check] = solve1(dynamicmodel, [yf; yf1], 1:M.endo_nbr, 1:M.endo_nbr, ...
|
[tmp, check] = solve1(dynamicmodel, [yf; yf1], 1:M.endo_nbr, 1:M.endo_nbr, ...
|
||||||
1, options.gstep, options.dynatol.f, ...
|
1, options.gstep, options.dynatol.f, ...
|
||||||
options.dynatol.x, options.simul.maxit, ...
|
options.dynatol.x, options.simul.maxit, [], ...
|
||||||
options.debug, exogenousvariables, M.params, steadystate, ...
|
options.debug, exogenousvariables, M.params, steadystate, ...
|
||||||
it+M.maximum_lag);
|
it+M.maximum_lag);
|
||||||
if check
|
if check
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
function [x,check] = solve1(func,x,j1,j2,jacobian_flag,gstep,tolf,tolx,maxit,debug,varargin)
|
function [x,check] = solve1(func,x,j1,j2,jacobian_flag,gstep,tolf,tolx,maxit,fake,debug,varargin)
|
||||||
% Solves systems of non linear equations of several variables
|
% Solves systems of non linear equations of several variables
|
||||||
%
|
%
|
||||||
% INPUTS
|
% INPUTS
|
||||||
|
@ -13,6 +13,7 @@ function [x,check] = solve1(func,x,j1,j2,jacobian_flag,gstep,tolf,tolx,maxit,deb
|
||||||
% tolf tolerance for residuals
|
% tolf tolerance for residuals
|
||||||
% tolx tolerance for solution variation
|
% tolx tolerance for solution variation
|
||||||
% maxit maximum number of iterations
|
% maxit maximum number of iterations
|
||||||
|
% fake unused argument (compatibity with trust_region).
|
||||||
% debug debug flag
|
% debug debug flag
|
||||||
% varargin: list of extra arguments to the function
|
% varargin: list of extra arguments to the function
|
||||||
%
|
%
|
||||||
|
@ -23,7 +24,7 @@ function [x,check] = solve1(func,x,j1,j2,jacobian_flag,gstep,tolf,tolx,maxit,deb
|
||||||
% SPECIAL REQUIREMENTS
|
% SPECIAL REQUIREMENTS
|
||||||
% none
|
% none
|
||||||
|
|
||||||
% Copyright (C) 2001-2017 Dynare Team
|
% Copyright © 2001-2021 Dynare Team
|
||||||
%
|
%
|
||||||
% This file is part of Dynare.
|
% This file is part of Dynare.
|
||||||
%
|
%
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
function [x,check,info] = trust_region(fcn,x0,j1,j2,jacobian_flag,gstep,tolf,tolx,maxiter,debug,varargin)
|
function [x,check,info] = trust_region(fcn,x0,j1,j2,jacobian_flag,gstep,tolf,tolx,maxiter,factor,debug,varargin)
|
||||||
% Solves systems of non linear equations of several variables, using a
|
% Solves systems of non linear equations of several variables, using a
|
||||||
% trust-region method.
|
% trust-region method.
|
||||||
%
|
%
|
||||||
|
@ -14,6 +14,7 @@ function [x,check,info] = trust_region(fcn,x0,j1,j2,jacobian_flag,gstep,tolf,tol
|
||||||
% tolf tolerance for residuals
|
% tolf tolerance for residuals
|
||||||
% tolx tolerance for solution variation
|
% tolx tolerance for solution variation
|
||||||
% maxiter maximum number of iterations
|
% maxiter maximum number of iterations
|
||||||
|
% factor real scalar, determines the initial step bound
|
||||||
% debug debug flag
|
% debug debug flag
|
||||||
% varargin: list of arguments following bad_cond_flag
|
% varargin: list of arguments following bad_cond_flag
|
||||||
%
|
%
|
||||||
|
@ -101,7 +102,7 @@ while (niter < maxiter && ~info)
|
||||||
if (niter == 1)
|
if (niter == 1)
|
||||||
xn = norm (dg .* x(j2));
|
xn = norm (dg .* x(j2));
|
||||||
% FIXME: something better?
|
% FIXME: something better?
|
||||||
delta = max (xn, 1);
|
delta = max (xn, 1)*factor;
|
||||||
end
|
end
|
||||||
|
|
||||||
% Get trust-region model (dogleg) minimizer.
|
% Get trust-region model (dogleg) minimizer.
|
||||||
|
|
Loading…
Reference in New Issue