From e56f994d28100f10d92e4b3c668e9dc56e8c31cb Mon Sep 17 00:00:00 2001 From: Houtan Bastani <houtan@dynare.org> Date: Fri, 1 Mar 2019 11:20:26 +0100 Subject: [PATCH] pac_model: write growth argument as string --- src/ComputingTasks.cc | 21 +++++++++++++++++---- src/ComputingTasks.hh | 2 +- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/ComputingTasks.cc b/src/ComputingTasks.cc index 2f3976e0..c4852874 100644 --- a/src/ComputingTasks.cc +++ b/src/ComputingTasks.cc @@ -268,6 +268,7 @@ PacModelStatement::PacModelStatement(string name_arg, aux_model_name{move(aux_model_name_arg)}, discount{move(discount_arg)}, growth{growth_arg}, + original_growth{growth_arg}, steady_state_growth_rate_number{steady_state_growth_rate_number_arg}, steady_state_growth_rate_symb_id{steady_state_growth_rate_symb_id_arg}, symbol_table{symbol_table_arg} @@ -369,7 +370,10 @@ PacModelStatement::writeOutput(ostream &output, const string &basename, bool min int aux_symb_id = symbol_table.searchAuxiliaryVars(growth_symb_id, growth_lag); output << "M_.pac." << name << ".growth_index = " << symbol_table.getTypeSpecificID(aux_symb_id) + 1 << ";" << endl << "M_.pac." << name << ".growth_lag = 0;" << endl - << "M_.pac." << name << ".growth_type = '" << growth_type << "';" << endl; + << "M_.pac." << name << ".growth_type = '" << growth_type << "';" << endl + << "M_.pac." << name << ".growth_str = '"; + original_growth->writeJsonOutput(output, {}, {}, true); + output << "';" << endl; } catch (...) { @@ -380,14 +384,20 @@ PacModelStatement::writeOutput(ostream &output, const string &basename, bool min int aux_symb_id = symbol_table.searchAuxiliaryVars(growth_symb_id, tmp_growth_lag); output << "M_.pac." << name << ".growth_index = " << symbol_table.getTypeSpecificID(aux_symb_id) + 1 << ";" << endl << "M_.pac." << name << ".growth_lag = -1;" << endl - << "M_.pac." << name << ".growth_type = '" << growth_type << "';" << endl; + << "M_.pac." << name << ".growth_type = '" << growth_type << "';" << endl + << "M_.pac." << name << ".growth_str = '"; + original_growth->writeJsonOutput(output, {}, {}, true); + output << "';" << endl; } catch (...) { // case when there is no aux var for the variable output << "M_.pac." << name << ".growth_index = " << symbol_table.getTypeSpecificID(growth_symb_id) + 1 << ";" << endl << "M_.pac." << name << ".growth_lag = " << growth_lag << ";" << endl - << "M_.pac." << name << ".growth_type = '" << growth_type << "';" << endl; + << "M_.pac." << name << ".growth_type = '" << growth_type << "';" << endl + << "M_.pac." << name << ".growth_str = '"; + original_growth->writeJsonOutput(output, {}, {}, true); + output << "';" << endl; } } } @@ -422,7 +432,10 @@ PacModelStatement::writeJsonOutput(ostream &output) const output << "," << "\"growth_index\": " << symbol_table.getTypeSpecificID(growth_symb_id) + 1 << "," << "\"growth_lag\": " << growth_lag << "," - << "\"growth_type\": " << "\"" << growth_type << "\"" << endl; + << "\"growth_type\": \"" << growth_type << "\"," << endl + << "\"growth_str\": \""; + original_growth->writeJsonOutput(output, {}, {}, true); + output << "\"" << endl; } output << "}"; } diff --git a/src/ComputingTasks.hh b/src/ComputingTasks.hh index 36764150..1098fdf8 100644 --- a/src/ComputingTasks.hh +++ b/src/ComputingTasks.hh @@ -138,7 +138,7 @@ class PacModelStatement : public Statement { public: const string name, aux_model_name, discount; - expr_t growth; + expr_t growth, original_growth; private: const double steady_state_growth_rate_number; const int steady_state_growth_rate_symb_id; -- GitLab