Fix crash in simulation of “Solve forward/backward complete” blocks with stack_solve_algo=4 (without bytecode)
parent
188df7711d
commit
fa7b331cf4
|
@ -1,17 +1,19 @@
|
|||
function r = lnsrch1_wrapper_one_boundary(ya, ll_index, fname, blk, y, x, params, steady_state, T, it_)
|
||||
function r = lnsrch1_wrapper_one_boundary(ya, y_index, fname, blk, y, x, params, steady_state, T, it_, M_)
|
||||
% wrapper for solve_one_boundary m-file when it is used with a dynamic
|
||||
% model
|
||||
%
|
||||
% INPUTS
|
||||
% ya [vector] The endogenous of the current block
|
||||
% ll_index [vector] M_.lead_lag_incidence(M_.maximum_endo_lag+1, :)
|
||||
% y_index [vector of int] The index of the endogenous variables of the block
|
||||
% fname [string] name of the static/dynamic file
|
||||
% blk [int] block number
|
||||
% y [vector] Dynamic endogenous variables of the model
|
||||
% y [vector] All endogenous variables of the model
|
||||
% x [matrix] All the exogenous variables of the model
|
||||
% params [vector] All the parameters of the model
|
||||
% steady_state [vector] steady state of the model
|
||||
% T [vector] Temporary terms
|
||||
% M_ Model description structure
|
||||
%
|
||||
% OUTPUTS
|
||||
% r [vector] The residuals of the current block
|
||||
%
|
||||
|
@ -22,7 +24,7 @@ function r = lnsrch1_wrapper_one_boundary(ya, ll_index, fname, blk, y, x, params
|
|||
% none.
|
||||
%
|
||||
|
||||
% Copyright (C) 2009-2020 Dynare Team
|
||||
% Copyright (C) 2009-2022 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -39,5 +41,5 @@ function r = lnsrch1_wrapper_one_boundary(ya, ll_index, fname, blk, y, x, params
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licen
|
||||
|
||||
y2(nonzeros(ll_index)) = ya(find(ll_index));
|
||||
[r, ~, ~, g1]=feval(fname, blk, y, x, params, steady_state, T, it_, false);
|
||||
y(y_index, it_) = ya;
|
||||
r = feval(fname, blk, dynvars_from_endo_simul(y, it_, M_), x, params, steady_state, T, it_, false);
|
||||
|
|
|
@ -53,7 +53,7 @@ function [y, T, oo_, info] = solve_one_boundary(fname, y, x, params, steady_stat
|
|||
% none.
|
||||
%
|
||||
|
||||
% Copyright (C) 1996-2020 Dynare Team
|
||||
% Copyright (C) 1996-2022 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -191,24 +191,19 @@ for it_=start:incr:finish
|
|||
ya_save=ya;
|
||||
g1a=g1;
|
||||
if is_dynamic && stack_solve_algo==4
|
||||
lambda=1;
|
||||
stpmx = 100 ;
|
||||
if is_dynamic
|
||||
stpmax = stpmx*max([sqrt(ya'*ya);size(y_index_eq,2)]);
|
||||
else
|
||||
stpmax = stpmx*max([sqrt(ya'*ya);size(y_index_eq,2)]);
|
||||
end
|
||||
stpmax = stpmx*max([sqrt(ya'*ya);size(y_index_eq,2)]);
|
||||
nn=1:size(y_index_eq,2);
|
||||
g = (r'*g1)';
|
||||
f = 0.5*r'*r;
|
||||
p = -g1\r ;
|
||||
[ya,f,r,check]=lnsrch1(ya,f,g,p,stpmax, ...
|
||||
'lnsrch1_wrapper_one_boundary',nn, ...
|
||||
y_index_eq, options.solve_tolx, M.lead_lag_incidence(M.maximum_endo_lag+1, :), fname, Block_Num, dynvars_from_endo_simul(y, it_, M), x, params, steady_state, T(:, it_), it_);
|
||||
nn, options.solve_tolx, y_index_eq, fname, Block_Num, y, x, params, steady_state, T(:, it_), it_, M);
|
||||
dx = ya - y(y_index_eq, it_);
|
||||
y(y_index_eq, it_) = ya;
|
||||
%% Recompute temporary terms, since they are not given as output of lnsrch1
|
||||
[~, ~, T(:, it_)] = feval(fname, Block_Num, dynvars_from_endo_simul(y, it_, M), x, params, steady_state, T(:, it_), it_, false);
|
||||
dx = ya' - y(index_eq, it_);
|
||||
y(index_eq, it_) = ya;
|
||||
elseif (is_dynamic && (stack_solve_algo==1 || stack_solve_algo==0)) || (~is_dynamic && options.solve_algo==6)
|
||||
if verbose && ~is_dynamic
|
||||
disp('steady: Sparse LU ')
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
var y y_s R pie dq pie_s de A y_obs pie_obs R_obs vv ww pure_forward;
|
||||
varexo e_R e_q e_ys e_pies e_A e_pure_forward;
|
||||
varexo e_R e_q e_ys e_pies e_A e_pure_forward e_vv e_ww;
|
||||
|
||||
parameters psi1 psi2 psi3 rho_R tau alpha rr k rho_q rho_A rho_ys rho_pies;
|
||||
|
||||
|
@ -40,19 +40,10 @@ A = rho_A*A(-1)+e_A;
|
|||
y_obs = y-y(-1)+A;
|
||||
pie_obs = 4*pie;
|
||||
R_obs = 4*R;
|
||||
vv = 0.2*ww+0.5*vv(-1)+1;
|
||||
ww = 0.1*vv+0.5*ww(-1)+2;
|
||||
/* A lt=
|
||||
0.5*vv-0.2*ww = 1
|
||||
-0.1*vv+0.5*ww = 2
|
||||
[ 0.5 -0.2][vv] [1]
|
||||
=
|
||||
[-0.1 0.5][ww] [2]
|
||||
det = 0.25-0.02 = 0.23
|
||||
[vv] [0.5 0.2] [1] [0.9] [3.91304]
|
||||
= 1/0.23* = 1/0.23* =
|
||||
[ww] [0.1 0.5] [2] [1.1] [4.7826]
|
||||
*/
|
||||
|
||||
// Solve backward complete block (nonlinear)
|
||||
vv = 0.2*ww+0.5*vv(-1)+e_vv;
|
||||
ww = min(0.1*vv+0.5*ww(-1), 200)+e_ww;
|
||||
|
||||
/* Test a purely forward variable (thus within a block of type “evaluate
|
||||
backward”). See #1727. */
|
||||
|
@ -83,6 +74,14 @@ values 0.5;
|
|||
var e_pure_forward;
|
||||
periods 19;
|
||||
values 1;
|
||||
|
||||
var e_vv;
|
||||
periods 9;
|
||||
values 0.2;
|
||||
|
||||
var e_ww;
|
||||
periods 12;
|
||||
values -0.4;
|
||||
end;
|
||||
|
||||
simul(periods=20, markowitz=0, stack_solve_algo = @{stack_solve_algo});
|
||||
|
|
Loading…
Reference in New Issue