2011-11-25 12:57:42 +01:00
|
|
|
function [x,info] = dynare_solve_block_or_bytecode(y, exo, params, options, M)
|
2011-02-04 17:27:33 +01:00
|
|
|
% Copyright (C) 2010-2011 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
|
|
|
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
info = 0;
|
|
|
|
x = y;
|
2011-11-25 12:57:42 +01:00
|
|
|
if options.block && ~options.bytecode
|
|
|
|
for b = 1:size(M.blocksMFS,1)
|
|
|
|
n = size(M.blocksMFS{b}, 1);
|
2010-10-27 18:35:42 +02:00
|
|
|
ss = x;
|
|
|
|
if n ~= 0
|
2011-11-25 12:57:42 +01:00
|
|
|
if options.solve_algo <= 4
|
2010-10-27 18:35:42 +02:00
|
|
|
[y, check] = dynare_solve('block_mfs_steadystate', ...
|
2011-11-25 12:57:42 +01:00
|
|
|
ss(M.blocksMFS{b}), ...
|
|
|
|
options.jacobian_flag, b, ss, exo, params, M);
|
2010-10-27 18:35:42 +02:00
|
|
|
if check ~= 0
|
|
|
|
error(['STEADY: convergence problems in block ' int2str(b)])
|
|
|
|
end
|
2011-11-25 12:57:42 +01:00
|
|
|
ss(M.blocksMFS{b}) = y;
|
2010-10-27 18:35:42 +02:00
|
|
|
else
|
2011-11-25 12:57:42 +01:00
|
|
|
[ss, check] = solve_one_boundary([M.fname '_static_' int2str(b)], ss, exo, ...
|
|
|
|
params, [], M.blocksMFS{b}, n, 1, 0, b, 0, options.maxit_, ...
|
2011-11-28 14:18:02 +01:00
|
|
|
options.solve_tolf, options.slowc, 0, options.solve_algo, 1, 0, 0,M,options);
|
2011-02-04 17:17:48 +01:00
|
|
|
|
2010-10-27 18:35:42 +02:00
|
|
|
end
|
|
|
|
end
|
2011-11-25 12:57:42 +01:00
|
|
|
[r, g1, x] = feval([M.fname '_static'], b, ss, ...
|
2011-02-04 17:17:48 +01:00
|
|
|
exo, params);
|
2010-10-27 18:35:42 +02:00
|
|
|
end
|
2011-11-25 12:57:42 +01:00
|
|
|
elseif options.bytecode
|
|
|
|
if options.solve_algo > 4
|
2010-11-20 15:33:56 +01:00
|
|
|
[check, x] = bytecode('static', x, exo, params);
|
2010-10-27 18:35:42 +02:00
|
|
|
mexErrCheck('bytecode', check);
|
|
|
|
info = check;
|
2011-11-25 12:57:42 +01:00
|
|
|
elseif options.block
|
|
|
|
for b = 1:size(M.blocksMFS,1)
|
|
|
|
n = size(M.blocksMFS{b}, 1);
|
2010-10-27 18:35:42 +02:00
|
|
|
if n ~= 0
|
|
|
|
[y, check] = dynare_solve('block_bytecode_mfs_steadystate', ...
|
2011-11-25 12:57:42 +01:00
|
|
|
x(M.blocksMFS{b}), ...
|
|
|
|
options.jacobian_flag, b, x, exo, params, M);
|
2010-10-27 18:35:42 +02:00
|
|
|
if check ~= 0
|
|
|
|
error(['STEADY: convergence problems in block ' int2str(b)])
|
|
|
|
end
|
2011-11-25 12:57:42 +01:00
|
|
|
x(M.blocksMFS{b}) = y;
|
2010-10-27 18:35:42 +02:00
|
|
|
else
|
2011-03-14 17:46:00 +01:00
|
|
|
[chk, nulldev, nulldev1, x] = bytecode( x, exo, params, x, 1, x, 'evaluate', 'static', ['block = ' int2str(b)]);
|
2010-10-27 18:35:42 +02:00
|
|
|
end;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
[x, check] = dynare_solve('bytecode_steadystate', ...
|
2011-02-04 17:17:48 +01:00
|
|
|
y, ...
|
2011-11-25 12:57:42 +01:00
|
|
|
options.jacobian_flag, exo, params);
|
2010-10-27 18:35:42 +02:00
|
|
|
if check ~= 0
|
|
|
|
error('STEADY: convergence problems')
|
|
|
|
end
|
|
|
|
end
|
2010-10-27 15:34:48 +02:00
|
|
|
end
|