diff --git a/matlab/block_bytecode_mfs_steadystate.m b/matlab/block_bytecode_mfs_steadystate.m index e0a718db94c6d6c89b986e79e808c26a3e8ae86f..a34b15c197196a4d31dd342812c36d76856b14e8 100644 --- a/matlab/block_bytecode_mfs_steadystate.m +++ b/matlab/block_bytecode_mfs_steadystate.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, % 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. % @@ -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 % 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; [chk, r, g1] = bytecode( y_all, exo, params, y_all, 1, y_all, 'evaluate', 'static', ['block = ' int2str(b) ]); diff --git a/matlab/block_mfs_steadystate.m b/matlab/block_mfs_steadystate.m index 78a87b442a4bf19333613963bd979b22ed2878c6..8cbce053a187802d79450b3b3edf1d829505a8e1 100644 --- a/matlab/block_mfs_steadystate.m +++ b/matlab/block_mfs_steadystate.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, % 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. % @@ -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 % 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);']); -g1 = full(g1); \ No newline at end of file +g1 = full(g1); diff --git a/matlab/dynare_solve_block_or_bytecode.m b/matlab/dynare_solve_block_or_bytecode.m index 0dd8074f6d5bc0e152fe8a87cdde255c32305fa4..301d3aa26615a8e8dbb9617a19eefd38199d7ea8 100644 --- a/matlab/dynare_solve_block_or_bytecode.m +++ b/matlab/dynare_solve_block_or_bytecode.m @@ -19,13 +19,13 @@ function [x,info] = dynare_solve_block_or_bytecode(y, exo, params, options, M) info = 0; x = y; if options.block && ~options.bytecode - for b = 1:size(M.blocksMFS,1) - n = size(M.blocksMFS{b}, 1); + for b = 1:length(M.block_structure_stat.block) 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 [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); if check ~= 0 % error(['STEADY: convergence @@ -33,10 +33,11 @@ if options.block && ~options.bytecode info = 1; return end - ss(M.blocksMFS{b}) = y; + ss(M.block_structure_stat.block(b).variable) = y; else + n = length(M.block_structure_stat.block(b).variable); [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.slowc, 0, options.solve_algo, 1, 0, 0,M,options); if check @@ -57,11 +58,11 @@ elseif options.bytecode return end elseif options.block - for b = 1:size(M.blocksMFS,1) - n = size(M.blocksMFS{b}, 1); - if n ~= 0 + for b = 1:length(M.block_structure_stat.block) + if M.block_structure_stat.block(b).Simulation_Type ~= 1 && ... + M.block_structure_stat.block(b).Simulation_Type ~= 2 [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); if check % error(['STEADY: convergence @@ -69,7 +70,7 @@ elseif options.bytecode info = 1; return end - x(M.blocksMFS{b}) = y; + x(M.block_structure_stat.block(b).variable) = y; else [chk, nulldev, nulldev1, x] = bytecode( x, exo, params, ... x, 1, x, 'evaluate', 'static', ['block = ' int2str(b)]); @@ -89,4 +90,4 @@ elseif options.bytecode return end end -end \ No newline at end of file +end diff --git a/matlab/evaluate_static_model.m b/matlab/evaluate_static_model.m index e9c8ba3f1c275cfbdf499e62516e2b7551b7e57d..a65e093e7ac9d32307c3a992c2b1b1daea915dc2 100644 --- a/matlab/evaluate_static_model.m +++ b/matlab/evaluate_static_model.m @@ -46,12 +46,12 @@ function [residuals,check1,jacob] = evaluate_static_model(ys,exo_ss,params,M,opt fh_static = str2func([M.fname '_static']); if options.block residuals = zeros(M.endo_nbr,1); - mfs = M.blocksMFS; - for b = 1:size(mfs,1) - mfsb = mfs{b}; + for b = 1:length(M.block_structure_stat.block) + mfsb = M.block_structure_stat.block(b).variable; % blocks that can be directly evaluated (mfsb is empty) % 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); else %need to evaluate the recursive blocks to compute the diff --git a/matlab/model_diagnostics.m b/matlab/model_diagnostics.m index 3118bb2defd21ba17b461dd49eeb680db8c5af57..cd004fdbf28ff00d2fe5406a1c9b9d64f5a56c31 100644 --- a/matlab/model_diagnostics.m +++ b/matlab/model_diagnostics.m @@ -81,10 +81,10 @@ end % % singular Jacobian of static model % -if ~isfield(M,'blocksMFS') +if ~isfield(M,'block_structure_stat') nb = 1; else - nb = length(M.blocksMFS); + nb = length(M.block_structure_stat.block); end exo = [oo.exo_steady_state; oo.exo_det_steady_state]; diff --git a/matlab/resid.m b/matlab/resid.m index d7fb56cf37f926232d57397388879cfc935fb054..b8082b8e0cb933d52f1223f337bbdea32d54179d 100644 --- a/matlab/resid.m +++ b/matlab/resid.m @@ -59,7 +59,7 @@ end % Compute the residuals if options_.block && ~options_.bytecode 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'],... i,... oo_.steady_state,... diff --git a/mex/sources/bytecode/Interpreter.cc b/mex/sources/bytecode/Interpreter.cc index a50a0eff9f75d0bac8610775a44bb9f576461d3d..1587e2d456e325c023bf8e3de7d8dfe34fd7fcdf 100644 --- a/mex/sources/bytecode/Interpreter.cc +++ b/mex/sources/bytecode/Interpreter.cc @@ -2547,7 +2547,7 @@ Interpreter::compute_blocks(string file_name, string bin_basename, bool steady_s if (block >= (int) code.get_block_number()) { 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()); } //The big loop on intructions diff --git a/preprocessor/StaticModel.cc b/preprocessor/StaticModel.cc index 43bd8128ca86da25e9c0332ae6156e1bc0cd9f6f..66a4366c8e4f7696dcf71b7f2e5636fd2a6c9194 100644 --- a/preprocessor/StaticModel.cc +++ b/preprocessor/StaticModel.cc @@ -1487,21 +1487,6 @@ StaticModel::writeOutput(ostream &output, bool block) const return; 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++) { BlockSimulationType simulation_type = getBlockSimulationType(b);