Commit 31a13db6 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Remove duplicate information in M_.blocksMFS

parent bf19ab80
...@@ -2,7 +2,7 @@ function [r, g1] = block_bytecode_mfs_steadystate(y, b, y_all, exo, params, M) ...@@ -2,7 +2,7 @@ function [r, g1] = block_bytecode_mfs_steadystate(y, b, y_all, exo, params, M)
% Wrapper around the *_static.m file, for use with dynare_solve, % Wrapper around the *_static.m file, for use with dynare_solve,
% when block_mfs option is given to steady. % when block_mfs option is given to steady.
% Copyright (C) 2009-2011 Dynare Team % Copyright (C) 2009-2012 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -19,6 +19,6 @@ function [r, g1] = block_bytecode_mfs_steadystate(y, b, y_all, exo, params, M) ...@@ -19,6 +19,6 @@ function [r, g1] = block_bytecode_mfs_steadystate(y, b, y_all, exo, params, M)
% You should have received a copy of the GNU General Public License % You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>. % along with Dynare. If not, see <http://www.gnu.org/licenses/>.
indx = M.blocksMFS{b}; indx = M.block_structure_stat.block(b).variable;
y_all(indx) = y; y_all(indx) = y;
[chk, r, g1] = bytecode( y_all, exo, params, y_all, 1, y_all, 'evaluate', 'static', ['block = ' int2str(b) ]); [chk, r, g1] = bytecode( y_all, exo, params, y_all, 1, y_all, 'evaluate', 'static', ['block = ' int2str(b) ]);
...@@ -2,7 +2,7 @@ function [r, g1] = block_mfs_steadystate(y, b, y_all, exo, params, M) ...@@ -2,7 +2,7 @@ function [r, g1] = block_mfs_steadystate(y, b, y_all, exo, params, M)
% Wrapper around the *_static.m file, for use with dynare_solve, % Wrapper around the *_static.m file, for use with dynare_solve,
% when block_mfs option is given to steady. % when block_mfs option is given to steady.
% Copyright (C) 2009-2011 Dynare Team % Copyright (C) 2009-2012 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -19,7 +19,7 @@ function [r, g1] = block_mfs_steadystate(y, b, y_all, exo, params, M) ...@@ -19,7 +19,7 @@ function [r, g1] = block_mfs_steadystate(y, b, y_all, exo, params, M)
% You should have received a copy of the GNU General Public License % You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>. % along with Dynare. If not, see <http://www.gnu.org/licenses/>.
y_all(M.blocksMFS{b}) = y; y_all(M.block_structure_stat.block(b).variable) = y;
eval(['[r,g1] = ' M.fname '_static(b, y_all, exo, params);']); eval(['[r,g1] = ' M.fname '_static(b, y_all, exo, params);']);
g1 = full(g1); g1 = full(g1);
\ No newline at end of file
...@@ -19,13 +19,13 @@ function [x,info] = dynare_solve_block_or_bytecode(y, exo, params, options, M) ...@@ -19,13 +19,13 @@ function [x,info] = dynare_solve_block_or_bytecode(y, exo, params, options, M)
info = 0; info = 0;
x = y; x = y;
if options.block && ~options.bytecode if options.block && ~options.bytecode
for b = 1:size(M.blocksMFS,1) for b = 1:length(M.block_structure_stat.block)
n = size(M.blocksMFS{b}, 1);
ss = x; ss = x;
if n ~= 0 if M.block_structure_stat.block(b).Simulation_Type ~= 1 && ...
M.block_structure_stat.block(b).Simulation_Type ~= 2
if options.solve_algo <= 4 if options.solve_algo <= 4
[y, check] = dynare_solve('block_mfs_steadystate', ... [y, check] = dynare_solve('block_mfs_steadystate', ...
ss(M.blocksMFS{b}), ... ss(M.block_structure_stat.block(b).variable), ...
options.jacobian_flag, b, ss, exo, params, M); options.jacobian_flag, b, ss, exo, params, M);
if check ~= 0 if check ~= 0
% error(['STEADY: convergence % error(['STEADY: convergence
...@@ -33,10 +33,11 @@ if options.block && ~options.bytecode ...@@ -33,10 +33,11 @@ if options.block && ~options.bytecode
info = 1; info = 1;
return return
end end
ss(M.blocksMFS{b}) = y; ss(M.block_structure_stat.block(b).variable) = y;
else else
n = length(M.block_structure_stat.block(b).variable);
[ss, check] = solve_one_boundary([M.fname '_static_' int2str(b)], ss, exo, ... [ss, check] = solve_one_boundary([M.fname '_static_' int2str(b)], ss, exo, ...
params, [], M.blocksMFS{b}, n, 1, 0, b, 0, options.maxit_, ... params, [], M.block_structure_stat.block(b).variable, n, 1, 0, b, 0, options.maxit_, ...
options.solve_tolf, ... options.solve_tolf, ...
options.slowc, 0, options.solve_algo, 1, 0, 0,M,options); options.slowc, 0, options.solve_algo, 1, 0, 0,M,options);
if check if check
...@@ -57,11 +58,11 @@ elseif options.bytecode ...@@ -57,11 +58,11 @@ elseif options.bytecode
return return
end end
elseif options.block elseif options.block
for b = 1:size(M.blocksMFS,1) for b = 1:length(M.block_structure_stat.block)
n = size(M.blocksMFS{b}, 1); if M.block_structure_stat.block(b).Simulation_Type ~= 1 && ...
if n ~= 0 M.block_structure_stat.block(b).Simulation_Type ~= 2
[y, check] = dynare_solve('block_bytecode_mfs_steadystate', ... [y, check] = dynare_solve('block_bytecode_mfs_steadystate', ...
x(M.blocksMFS{b}), ... x(M.block_structure_stat.block(b).variable), ...
options.jacobian_flag, b, x, exo, params, M); options.jacobian_flag, b, x, exo, params, M);
if check if check
% error(['STEADY: convergence % error(['STEADY: convergence
...@@ -69,7 +70,7 @@ elseif options.bytecode ...@@ -69,7 +70,7 @@ elseif options.bytecode
info = 1; info = 1;
return return
end end
x(M.blocksMFS{b}) = y; x(M.block_structure_stat.block(b).variable) = y;
else else
[chk, nulldev, nulldev1, x] = bytecode( x, exo, params, ... [chk, nulldev, nulldev1, x] = bytecode( x, exo, params, ...
x, 1, x, 'evaluate', 'static', ['block = ' int2str(b)]); x, 1, x, 'evaluate', 'static', ['block = ' int2str(b)]);
...@@ -89,4 +90,4 @@ elseif options.bytecode ...@@ -89,4 +90,4 @@ elseif options.bytecode
return return
end end
end end
end end
\ No newline at end of file
...@@ -46,12 +46,12 @@ function [residuals,check1,jacob] = evaluate_static_model(ys,exo_ss,params,M,opt ...@@ -46,12 +46,12 @@ function [residuals,check1,jacob] = evaluate_static_model(ys,exo_ss,params,M,opt
fh_static = str2func([M.fname '_static']); fh_static = str2func([M.fname '_static']);
if options.block if options.block
residuals = zeros(M.endo_nbr,1); residuals = zeros(M.endo_nbr,1);
mfs = M.blocksMFS; for b = 1:length(M.block_structure_stat.block)
for b = 1:size(mfs,1) mfsb = M.block_structure_stat.block(b).variable;
mfsb = mfs{b};
% blocks that can be directly evaluated (mfsb is empty) % blocks that can be directly evaluated (mfsb is empty)
% have zero residuals by construction % have zero residuals by construction
if ~isempty(mfsb) if M.block_structure_stat.block(b).Simulation_Type ~= 1 && ...
M.block_structure_stat.block(b).Simulation_Type ~= 2
residuals(mfsb) = feval(fh_static,b,ys,exo_ss,params); residuals(mfsb) = feval(fh_static,b,ys,exo_ss,params);
else else
%need to evaluate the recursive blocks to compute the %need to evaluate the recursive blocks to compute the
......
...@@ -81,10 +81,10 @@ end ...@@ -81,10 +81,10 @@ end
% %
% singular Jacobian of static model % singular Jacobian of static model
% %
if ~isfield(M,'blocksMFS') if ~isfield(M,'block_structure_stat')
nb = 1; nb = 1;
else else
nb = length(M.blocksMFS); nb = length(M.block_structure_stat.block);
end end
exo = [oo.exo_steady_state; oo.exo_det_steady_state]; exo = [oo.exo_steady_state; oo.exo_det_steady_state];
......
...@@ -59,7 +59,7 @@ end ...@@ -59,7 +59,7 @@ end
% Compute the residuals % Compute the residuals
if options_.block && ~options_.bytecode if options_.block && ~options_.bytecode
z = zeros(M_.endo_nbr,1); z = zeros(M_.endo_nbr,1);
for i = 1:length(M_.blocksMFS) for i = 1:length(M_.block_structure_stat.block)
[r, g, yy, var_indx] = feval([M_.fname '_static'],... [r, g, yy, var_indx] = feval([M_.fname '_static'],...
i,... i,...
oo_.steady_state,... oo_.steady_state,...
......
...@@ -2547,7 +2547,7 @@ Interpreter::compute_blocks(string file_name, string bin_basename, bool steady_s ...@@ -2547,7 +2547,7 @@ Interpreter::compute_blocks(string file_name, string bin_basename, bool steady_s
if (block >= (int) code.get_block_number()) if (block >= (int) code.get_block_number())
{ {
ostringstream tmp; ostringstream tmp;
tmp << " in compute_blocks, input argument block = " << block+1 << " is greater than the number of blocks in the model (" << code.get_block_number() << " see M_.blocksMFS)\n"; tmp << " in compute_blocks, input argument block = " << block+1 << " is greater than the number of blocks in the model (" << code.get_block_number() << " see M_.block_structure_stat.block)\n";
throw FatalExceptionHandling(tmp.str()); throw FatalExceptionHandling(tmp.str());
} }
//The big loop on intructions //The big loop on intructions
......
...@@ -1487,21 +1487,6 @@ StaticModel::writeOutput(ostream &output, bool block) const ...@@ -1487,21 +1487,6 @@ StaticModel::writeOutput(ostream &output, bool block) const
return; return;
unsigned int nb_blocks = getNbBlocks(); unsigned int nb_blocks = getNbBlocks();
output << "M_.blocksMFS = cell(" << nb_blocks << ", 1);" << endl;
for (int b = 0; b < (int) nb_blocks; b++)
{
output << "M_.blocksMFS{" << b+1 << "} = [ ";
unsigned int block_size = getBlockSize(b);
unsigned int block_mfs = getBlockMfs(b);
unsigned int block_recursive = block_size - block_mfs;
BlockSimulationType simulation_type = getBlockSimulationType(b);
if (simulation_type != EVALUATE_BACKWARD && simulation_type != EVALUATE_FORWARD)
for (int i = block_recursive; i < (int) block_size; i++)
output << getBlockVariableID(b, i)+1 << "; ";
output << "];" << endl;
}
for (int b = 0; b < (int) nb_blocks; b++) for (int b = 0; b < (int) nb_blocks; b++)
{ {
BlockSimulationType simulation_type = getBlockSimulationType(b); BlockSimulationType simulation_type = getBlockSimulationType(b);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment