From 6d67c4b9b86bb114616d4f05c132f96987a76005 Mon Sep 17 00:00:00 2001 From: Ferhat Mihoubi Date: Wed, 6 Jun 2012 16:36:56 +0200 Subject: [PATCH] Add options static to model_info command and fixes the ticket #134 --- StaticModel.cc | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/StaticModel.cc b/StaticModel.cc index 2c495c2b..9b8319ca 100644 --- a/StaticModel.cc +++ b/StaticModel.cc @@ -1511,6 +1511,58 @@ StaticModel::writeOutput(ostream &output, bool block) const output << getBlockEquationID(b, i)+1 << "; "; output << "];" << endl; } + for (int b = 0; b < (int) nb_blocks; b++) + { + BlockSimulationType simulation_type = getBlockSimulationType(b); + unsigned int block_size = getBlockSize(b); + unsigned int block_mfs = getBlockMfs(b); + unsigned int block_recursive = block_size - block_mfs; + ostringstream tmp_s, tmp_s_eq; + tmp_s.str(""); + tmp_s_eq.str(""); + for (int i = 0; i < block_size; i++) + { + tmp_s << " " << getBlockVariableID(b, i)+1; + tmp_s_eq << " " << getBlockEquationID(b, i)+1; + } + output << "block_structure_stat.block(" << b+1 << ").Simulation_Type = " << simulation_type << ";\n"; + output << "block_structure_stat.block(" << b+1 << ").endo_nbr = " << block_size << ";\n"; + output << "block_structure_stat.block(" << b+1 << ").mfs = " << getBlockMfs(block) << ";\n"; + output << "block_structure_stat.block(" << b+1 << ").equation = [" << tmp_s_eq.str() << "];\n"; + output << "block_structure_stat.block(" << b+1 << ").variable = [" << tmp_s.str() << "];\n"; + } + output << "M_.block_structure_stat.block = block_structure_stat.block;\n"; + string cst_s; + int nb_endo = symbol_table.endo_nbr(); + output << "M_.block_structure_stat.variable_reordered = ["; + for (int i = 0; i < nb_endo; i++) + output << " " << variable_reordered[i]+1; + output << "];\n"; + output << "M_.block_structure_stat.equation_reordered = ["; + for (int i = 0; i < nb_endo; i++) + output << " " << equation_reordered[i]+1; + output << "];\n"; + + map, int> row_incidence; + for (first_derivatives_t::const_iterator it = first_derivatives.begin(); + it != first_derivatives.end(); it++) + { + int deriv_id = it->first.second; + if (getTypeByDerivID(deriv_id) == eEndogenous) + { + int eq = it->first.first; + int symb = getSymbIDByDerivID(deriv_id); + int var = symbol_table.getTypeSpecificID(symb); + //int lag = getLagByDerivID(deriv_id); + row_incidence[make_pair(eq, var)] = 1; + } + } + output << "M_.block_structure_stat.incidence.sparse_IM = ["; + for (map, int>::const_iterator it = row_incidence.begin(); it != row_incidence.end(); it++) + { + output << it->first.first+1 << " " << it->first.second+1 << ";\n"; + } + output << "];\n"; } SymbolType