From 54ef4e28386972ac715a424b7f2d2d66f2afe3f6 Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Wed, 20 Jul 2016 17:09:46 -0400 Subject: [PATCH] preprocessor: always write M_.state_var #637 --- preprocessor/DynamicModel.cc | 39 ++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/preprocessor/DynamicModel.cc b/preprocessor/DynamicModel.cc index 6d68eb425..71247755f 100644 --- a/preprocessor/DynamicModel.cc +++ b/preprocessor/DynamicModel.cc @@ -2603,23 +2603,24 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de (julia ? "false" : "0")) << ";" << endl; + vector state_var; + for (int endoID = 0; endoID < symbol_table.endo_nbr(); endoID++) + // Loop on periods + for (int lag = -max_endo_lag; lag < 0; lag++) + try + { + getDerivID(symbol_table.getID(eEndogenous, variable_reordered[endoID]), lag); + if (lag < 0 && find(state_var.begin(), state_var.end(), variable_reordered[endoID]+1) == state_var.end()) + state_var.push_back(variable_reordered[endoID]+1); + } + catch (UnknownDerivIDException &e) + { + } + //In case of sparse model, writes the block_decomposition structure of the model if (block_decomposition) { - vector state_var, state_equ; - for (int endoID = 0; endoID < symbol_table.endo_nbr(); endoID++) - // Loop on periods - for (int lag = -max_endo_lag; lag < 0; lag++) - try - { - getDerivID(symbol_table.getID(eEndogenous, variable_reordered[endoID]), lag); - if (lag < 0 && find(state_var.begin(), state_var.end(), variable_reordered[endoID]+1) == state_var.end()) - state_var.push_back(variable_reordered[endoID]+1); - } - catch (UnknownDerivIDException &e) - { - } - + vector state_equ; int count_lead_lag_incidence = 0; int max_lead, max_lag, max_lag_endo, max_lead_endo, max_lag_exo, max_lead_exo, max_lag_exo_det, max_lead_exo_det; unsigned int nb_blocks = getNbBlocks(); @@ -3039,13 +3040,13 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de KF_index_file.write(reinterpret_cast(&(*it)), sizeof(index_KF)); KF_index_file.close(); } - output << modstruct << "state_var = ["; - - for (vector::const_iterator it=state_var.begin(); it != state_var.end(); it++) - output << *it << " "; - output << "];" << endl; } + output << modstruct << "state_var = ["; + for (vector::const_iterator it=state_var.begin(); it != state_var.end(); it++) + output << *it << " "; + output << "];" << endl; + // Writing initialization for some other variables if (!julia) output << modstruct << "exo_names_orig_ord = [1:" << symbol_table.exo_nbr() << "];" << endl;