2011-11-25 12:57:42 +01:00
|
|
|
function [x,info] = dynare_solve_block_or_bytecode(y, exo, params, options, M)
|
2022-02-17 17:00:53 +01:00
|
|
|
% Copyright (C) 2010-2022 Dynare Team
|
2010-10-27 18:35:42 +02:00
|
|
|
%
|
|
|
|
% This file is part of Dynare.
|
|
|
|
%
|
|
|
|
% Dynare is free software: you can redistribute it and/or modify
|
|
|
|
% it under the terms of the GNU General Public License as published by
|
|
|
|
% the Free Software Foundation, either version 3 of the License, or
|
|
|
|
% (at your option) any later version.
|
|
|
|
%
|
|
|
|
% Dynare is distributed in the hope that it will be useful,
|
|
|
|
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
% GNU General Public License for more details.
|
|
|
|
%
|
|
|
|
% You should have received a copy of the GNU General Public License
|
2021-06-09 17:33:48 +02:00
|
|
|
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
2010-10-27 18:35:42 +02:00
|
|
|
|
|
|
|
info = 0;
|
|
|
|
x = y;
|
2011-11-25 12:57:42 +01:00
|
|
|
if options.block && ~options.bytecode
|
2020-05-25 18:36:55 +02:00
|
|
|
T = NaN(M.block_structure_stat.tmp_nbr, 1);
|
2012-11-16 17:39:03 +01:00
|
|
|
for b = 1:length(M.block_structure_stat.block)
|
2010-10-27 18:35:42 +02:00
|
|
|
ss = x;
|
2012-11-16 17:39:03 +01:00
|
|
|
if M.block_structure_stat.block(b).Simulation_Type ~= 1 && ...
|
2017-05-16 15:10:20 +02:00
|
|
|
M.block_structure_stat.block(b).Simulation_Type ~= 2
|
2020-05-25 17:22:17 +02:00
|
|
|
if options.solve_algo <= 4 || options.solve_algo >= 9
|
2010-10-27 18:35:42 +02:00
|
|
|
[y, check] = dynare_solve('block_mfs_steadystate', ...
|
2012-11-16 17:39:03 +01:00
|
|
|
ss(M.block_structure_stat.block(b).variable), ...
|
2020-05-25 18:36:55 +02:00
|
|
|
options, b, ss, exo, params, T, M);
|
2010-10-27 18:35:42 +02:00
|
|
|
if check ~= 0
|
2012-04-23 14:27:18 +02:00
|
|
|
% error(['STEADY: convergence
|
|
|
|
% problems in block ' int2str(b)])
|
|
|
|
info = 1;
|
|
|
|
return
|
2010-10-27 18:35:42 +02:00
|
|
|
end
|
2012-11-16 17:39:03 +01:00
|
|
|
ss(M.block_structure_stat.block(b).variable) = y;
|
2010-10-27 18:35:42 +02:00
|
|
|
else
|
2012-11-16 17:39:03 +01:00
|
|
|
n = length(M.block_structure_stat.block(b).variable);
|
2020-06-19 18:34:48 +02:00
|
|
|
[ss, T, ~, check] = solve_one_boundary([M.fname '.static' ], ss, exo, ...
|
2020-06-02 17:45:28 +02:00
|
|
|
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, []);
|
2012-04-23 14:27:18 +02:00
|
|
|
if check
|
|
|
|
info = 1;
|
|
|
|
return
|
|
|
|
end
|
2010-10-27 18:35:42 +02:00
|
|
|
end
|
|
|
|
end
|
2020-06-19 18:34:48 +02:00
|
|
|
% 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);
|
2010-10-27 18:35:42 +02:00
|
|
|
end
|
2011-11-25 12:57:42 +01:00
|
|
|
elseif options.bytecode
|
2022-02-17 17:00:53 +01:00
|
|
|
if options.solve_algo >= 5 && options.solve_algo <= 8
|
2020-01-10 17:55:57 +01:00
|
|
|
try
|
|
|
|
x = bytecode('static', x, exo, params);
|
|
|
|
catch ME
|
|
|
|
disp(ME.message);
|
2012-04-23 14:27:18 +02:00
|
|
|
info = 1;
|
|
|
|
return
|
|
|
|
end
|
2011-11-25 12:57:42 +01:00
|
|
|
elseif options.block
|
2022-02-17 17:00:53 +01:00
|
|
|
T = NaN(M.block_structure_stat.tmp_nbr, 1);
|
2012-11-16 17:39:03 +01:00
|
|
|
for b = 1:length(M.block_structure_stat.block)
|
|
|
|
if M.block_structure_stat.block(b).Simulation_Type ~= 1 && ...
|
2017-05-16 15:10:20 +02:00
|
|
|
M.block_structure_stat.block(b).Simulation_Type ~= 2
|
2010-10-27 18:35:42 +02:00
|
|
|
[y, check] = dynare_solve('block_bytecode_mfs_steadystate', ...
|
2015-05-25 10:06:13 +02:00
|
|
|
x(M.block_structure_stat ...
|
|
|
|
.block(b).variable), ...
|
2022-02-17 17:00:53 +01:00
|
|
|
options, b, x, exo, params, T, M);
|
2012-04-23 14:27:18 +02:00
|
|
|
if check
|
2015-05-25 10:06:13 +02:00
|
|
|
% error(['STEADY: convergence problems in block '
|
|
|
|
% int2str(b)])
|
2012-04-23 14:27:18 +02:00
|
|
|
info = 1;
|
|
|
|
return
|
2010-10-27 18:35:42 +02:00
|
|
|
end
|
2012-11-16 17:39:03 +01:00
|
|
|
x(M.block_structure_stat.block(b).variable) = y;
|
2022-02-17 17:00:53 +01:00
|
|
|
end
|
|
|
|
% Compute endogenous if the block is of type evaluate forward/backward
|
|
|
|
% Also update the temporary terms vector (needed for the dynare_solve case)
|
|
|
|
try
|
|
|
|
[~, ~, x, T] = bytecode(x, exo, params, x, 1, x, T, 'evaluate', 'static', ...
|
|
|
|
['block = ' int2str(b)]);
|
|
|
|
catch ME
|
|
|
|
disp(ME.message);
|
|
|
|
info = 1;
|
|
|
|
return
|
2017-05-16 12:42:01 +02:00
|
|
|
end
|
2010-10-27 18:35:42 +02:00
|
|
|
end
|
|
|
|
else
|
2015-05-25 10:06:13 +02:00
|
|
|
[x, check] = dynare_solve('bytecode_steadystate', y, ...
|
|
|
|
options, exo, params);
|
2012-04-23 14:27:18 +02:00
|
|
|
if check
|
|
|
|
% error('STEADY: convergence problems')
|
|
|
|
info = 1;
|
|
|
|
return
|
2010-10-27 18:35:42 +02:00
|
|
|
end
|
|
|
|
end
|
2012-11-16 17:39:03 +01:00
|
|
|
end
|