Verified Commit 0d092a36 authored by Stéphane Adjemian's avatar Stéphane Adjemian
Browse files

Acknowledge option trust_region_initial_step_bound_factor in matlab based trust_region routine.

parent e72dde69
......@@ -119,7 +119,7 @@ License: GPL-3+
Files: matlab/trust_region.m
Copyright: 2008-2012 VZLU Prague, a.s.
2014-2019 Dynare Team
2014-2021 Dynare Team
License: GPL-3+
Files: matlab/one_sided_hp_filter.m
......
......@@ -232,9 +232,10 @@ elseif options.solve_algo==1
tolf, tolx, ...
maxit, options.debug, arguments{:});
elseif options.solve_algo==9
[x, errorflag] = trust_region(f, x, 1:nn, 1:nn, jacobian_flag, options.gstep, ...
tolf, tolx, ...
maxit, options.debug, arguments{:});
[x, errorflag] = trust_region(f,x, 1:nn, 1:nn, jacobian_flag, options.gstep, ...
tolf, tolx, maxit, ...
options.trust_region_initial_step_bound_factor, ...
options.debug, arguments{:});
elseif ismember(options.solve_algo, [2, 12, 4])
if ismember(options.solve_algo, [2, 12])
solver = @solve1;
......@@ -312,8 +313,9 @@ elseif ismember(options.solve_algo, [2, 12, 4])
end
[x, errorflag] = solver(f, x, j1(j), j2(j), jacobian_flag, ...
options.gstep, ...
tolf, options.solve_tolx, ...
maxit, options.debug, arguments{:});
tolf, options.solve_tolx, maxit, ...
options.trust_region_initial_step_bound_factor, ...
options.debug, arguments{:});
fre = true;
if errorflag
return
......@@ -323,8 +325,9 @@ elseif ismember(options.solve_algo, [2, 12, 4])
if max(abs(fvec))>tolf
disp('Call solver on the full nonlinear problem.')
[x, errorflag] = solver(f, x, 1:nn, 1:nn, jacobian_flag, ...
options.gstep, tolf, options.solve_tolx, ...
maxit, options.debug, arguments{:});
options.gstep, tolf, options.solve_tolx, maxit, ...
options.trust_region_initial_step_bound_factor, ...
options.debug, arguments{:});
end
elseif options.solve_algo==3
if jacobian_flag
......
......@@ -32,9 +32,10 @@ info.status = 1;
for it = options.periods:-1:1
yf = endogenousvariables(:,it+1); % Values at next period, also used as guess value for current period
yf1 = yf(iyf);
% TODO Call dynare_solve instead.
[tmp, check] = solve1(dynamicmodel, [yf; yf1], 1:M.endo_nbr, 1:M.endo_nbr, ...
1, options.gstep, options.dynatol.f, ...
options.dynatol.x, options.simul.maxit, ...
options.dynatol.x, options.simul.maxit, [], ...
options.debug, exogenousvariables, M.params, steadystate, ...
it+M.maximum_lag);
if check
......
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
%
% INPUTS
......@@ -13,6 +13,7 @@ function [x,check] = solve1(func,x,j1,j2,jacobian_flag,gstep,tolf,tolx,maxit,deb
% tolf tolerance for residuals
% tolx tolerance for solution variation
% maxit maximum number of iterations
% fake unused argument (compatibity with trust_region).
% debug debug flag
% 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
% none
% Copyright (C) 2001-2017 Dynare Team
% Copyright © 2001-2021 Dynare Team
%
% This file is part of Dynare.
%
......
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
% 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
% tolx tolerance for solution variation
% maxiter maximum number of iterations
% factor real scalar, determines the initial step bound
% debug debug flag
% varargin: list of arguments following bad_cond_flag
%
......@@ -101,7 +102,7 @@ while (niter < maxiter && ~info)
if (niter == 1)
xn = norm (dg .* x(j2));
% FIXME: something better?
delta = max (xn, 1);
delta = max (xn, 1)*factor;
end
% Get trust-region model (dogleg) minimizer.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment