dynare/matlab/dynare_solve_block_or_bytec...

92 lines
3.6 KiB
Matlab
Raw Normal View History

2011-11-25 12:57:42 +01:00
function [x,info] = dynare_solve_block_or_bytecode(y, exo, params, options, M)
2012-06-08 18:22:34 +02:00
% Copyright (C) 2010-2012 Dynare Team
%
% 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);
ss = x;
if n ~= 0
2011-11-25 12:57:42 +01:00
if options.solve_algo <= 4
[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);
if check ~= 0
% error(['STEADY: convergence
% problems in block ' int2str(b)])
info = 1;
return
end
2011-11-25 12:57:42 +01:00
ss(M.blocksMFS{b}) = y;
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_, ...
options.solve_tolf, ...
options.slowc, 0, options.solve_algo, 1, 0, 0,M,options);
if check
info = 1;
return
end
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);
end
2011-11-25 12:57:42 +01:00
elseif options.bytecode
if options.solve_algo > 4
[check, x] = bytecode('static', x, exo, params);
% mexErrCheck('bytecode', check);
if check
info = 1;
return
end
2011-11-25 12:57:42 +01:00
elseif options.block
for b = 1:size(M.blocksMFS,1)
n = size(M.blocksMFS{b}, 1);
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);
if check
% error(['STEADY: convergence
% problems in block ' int2str(b)])
info = 1;
return
end
2011-11-25 12:57:42 +01:00
x(M.blocksMFS{b}) = y;
else
[chk, nulldev, nulldev1, x] = bytecode( x, exo, params, ...
x, 1, x, 'evaluate', 'static', ['block = ' int2str(b)]);
if chk
info = 1;
return
end
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);
if check
% error('STEADY: convergence problems')
info = 1;
return
end
end
end