diff --git a/matlab/dr_block.m b/matlab/dr_block.m index ce28abdb6..bb51b7261 100644 --- a/matlab/dr_block.m +++ b/matlab/dr_block.m @@ -77,8 +77,7 @@ else it_=M_.maximum_lag+1; y=dynvars_from_endo_simul(z, it_, M_); for blk = 1:length(M_.block_structure.block) - funcname = sprintf('%s.block.dynamic_%d', M_.fname, blk); - [~, T, data(blk).g1, data(blk).g1_x, data(blk).g1_xd, data(blk).g1_o]=feval(funcname, y, zx, M_.params, dr.ys, T, it_, true); + [~, ~, T, data(blk).g1, data(blk).g1_x, data(blk).g1_xd, data(blk).g1_o]=feval([M_.fname '.dynamic'], blk, y, zx, M_.params, dr.ys, T, it_, true); end end dr.full_rank = 1; diff --git a/matlab/dynare_solve_block_or_bytecode.m b/matlab/dynare_solve_block_or_bytecode.m index 3fafaf0d1..072e43cdf 100644 --- a/matlab/dynare_solve_block_or_bytecode.m +++ b/matlab/dynare_solve_block_or_bytecode.m @@ -37,7 +37,7 @@ if options.block && ~options.bytecode ss(M.block_structure_stat.block(b).variable) = y; else n = length(M.block_structure_stat.block(b).variable); - [ss, T, ~, check] = solve_one_boundary([M.fname '.block.static_' int2str(b)], ss, exo, ... + [ss, T, ~, check] = solve_one_boundary([M.fname '.static' ], ss, exo, ... params, [], T, M.block_structure_stat.block(b).variable, n, 1, false, b, 0, options.simul.maxit, ... options.solve_tolf, ... options.slowc, 0, options.solve_algo, true, false, false, M, options, []); @@ -47,8 +47,9 @@ if options.block && ~options.bytecode end end end - % In particular, the following updates the temporary terms vector (for the dynare_solve case) - [r, x, T, g1] = feval([M.fname '.static'], b, ss, exo, params, T); + % Compute endogenous if the block is of type evaluate forward/backward + % Also update the temporary terms vector (needed for the dynare_solve case) + [~, x, T, g1] = feval([M.fname '.static'], b, ss, exo, params, T); end elseif options.bytecode if options.solve_algo > 4 diff --git a/matlab/lnsrch1_wrapper_one_boundary.m b/matlab/lnsrch1_wrapper_one_boundary.m index 6b4797590..700bade4b 100644 --- a/matlab/lnsrch1_wrapper_one_boundary.m +++ b/matlab/lnsrch1_wrapper_one_boundary.m @@ -1,12 +1,12 @@ -function r = lnsrch1_wrapper_one_boundary(ya, ll_index, fname, y, x, params, steady_state, T, it_) +function r = lnsrch1_wrapper_one_boundary(ya, ll_index, fname, blk, y, x, params, steady_state, T, it_) % 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, :) -% fname [string] name of the file containing the block -% to simulate +% fname [string] name of the static/dynamic file +% blk [int] block number % y [vector] Dynamic endogenous variables of the model % x [matrix] All the exogenous variables of the model % params [vector] All the parameters of the model @@ -40,4 +40,4 @@ function r = lnsrch1_wrapper_one_boundary(ya, ll_index, fname, y, x, params, ste % along with Dynare. If not, see maxit_) if is_dynamic - [r, T(:, it_), g1] = feval(fname, dynvars_from_endo_simul(y, it_, M), x, params, steady_state, T(:, it_), it_, false); + [r, ~, T(:, it_), g1] = feval(fname, Block_Num, dynvars_from_endo_simul(y, it_, M), x, params, steady_state, T(:, it_), it_, false); else - [r, T, g1] = feval(fname, y, x, params, T); + [r, ~, T, g1] = feval(fname, Block_Num, y, x, params, T); end if ~isreal(r) max_res=(-(max(max(abs(r))))^2)^0.5; @@ -203,9 +203,9 @@ for it_=start:incr:finish 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, dynvars_from_endo_simul(y, it_, M), x, params, steady_state, T(:, it_), it_); + 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_); %% Recompute temporary terms, since they are not given as output of lnsrch1 - [~, T(:, it_)] = feval(fname, dynvars_from_endo_simul(y, it_, M), x, params, steady_state, T(:, it_), it_, false); + [~, ~, 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) @@ -262,10 +262,10 @@ for it_=start:incr:finish y(y_index_eq) = phat; end if is_dynamic - [r, T(:, it_), g1] = feval(fname, dynvars_from_endo_simul(y, it_, M), x, params, ... + [r, ~, T(:, it_), g1] = feval(fname, Block_Num, dynvars_from_endo_simul(y, it_, M), x, params, ... steady_state, T(:, it_), it_, false); else - [r, T, g1] = feval(fname, y, x, params, T); + [r, ~, T, g1] = feval(fname, Block_Num, y, x, params, T); end if max(abs(r))>=options.solve_tolf [dx,flag1] = bicgstab(g1,-r,1e-7,Blck_size,L1,U1); diff --git a/matlab/solve_two_boundaries.m b/matlab/solve_two_boundaries.m index c46ac5c22..d1c595f6b 100644 --- a/matlab/solve_two_boundaries.m +++ b/matlab/solve_two_boundaries.m @@ -83,7 +83,7 @@ while ~(cvg==1 || iter>maxit_) r = NaN(Blck_size, periods); g1a = spalloc(Blck_size*periods, Blck_size*periods, nze*periods); for it_ = y_kmin+(1:periods) - [r(:, it_-y_kmin), T(:, it_), g1]=feval(fname, dynvars_from_endo_simul(y, it_, M), x, params, steady_state, T(:, it_), it_, false); + [r(:, it_-y_kmin), ~, T(:, it_), g1]=feval(fname, Block_Num, dynvars_from_endo_simul(y, it_, M), x, params, steady_state, T(:, it_), it_, false); if periods == 1 g1a = g1(:, Blck_size+(1:Blck_size)); elseif it_ == y_kmin+1 @@ -314,7 +314,7 @@ while ~(cvg==1 || iter>maxit_) g = (ra'*g1a)'; f = 0.5*ra'*ra; p = -g1a\ra; - [yn,f,ra,check]=lnsrch1(ya,f,g,p,stpmax,'lnsrch1_wrapper_two_boundaries',nn,nn, options.solve_tolx, fname, y, y_index,x, params, steady_state, T, periods, Blck_size, M); + [yn,f,ra,check]=lnsrch1(ya,f,g,p,stpmax,'lnsrch1_wrapper_two_boundaries',nn,nn, options.solve_tolx, fname, Block_Num, y, y_index,x, params, steady_state, T, periods, Blck_size, M); dx = ya - yn; y(y_index, y_kmin+(1:periods))=reshape(yn',length(y_index),periods); end diff --git a/preprocessor b/preprocessor index f4d2ce70d..f098329c7 160000 --- a/preprocessor +++ b/preprocessor @@ -1 +1 @@ -Subproject commit f4d2ce70dafd1331791b2fd96f3468b3f6c103da +Subproject commit f098329c74225d68fe84f2a5aa32721c2b76036c