Verified Commit e56f994d authored by Houtan Bastani's avatar Houtan Bastani
Browse files

pac_model: write growth argument as string

parent 341b9c66
Pipeline #921 passed with stage
in 1 minute and 54 seconds
...@@ -268,6 +268,7 @@ PacModelStatement::PacModelStatement(string name_arg, ...@@ -268,6 +268,7 @@ PacModelStatement::PacModelStatement(string name_arg,
aux_model_name{move(aux_model_name_arg)}, aux_model_name{move(aux_model_name_arg)},
discount{move(discount_arg)}, discount{move(discount_arg)},
growth{growth_arg}, growth{growth_arg},
original_growth{growth_arg},
steady_state_growth_rate_number{steady_state_growth_rate_number_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}, steady_state_growth_rate_symb_id{steady_state_growth_rate_symb_id_arg},
symbol_table{symbol_table_arg} symbol_table{symbol_table_arg}
...@@ -369,7 +370,10 @@ PacModelStatement::writeOutput(ostream &output, const string &basename, bool min ...@@ -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); 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 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_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 (...) catch (...)
{ {
...@@ -380,14 +384,20 @@ PacModelStatement::writeOutput(ostream &output, const string &basename, bool min ...@@ -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); 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 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_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 (...) catch (...)
{ {
// case when there is no aux var for the variable // case when there is no aux var for the variable
output << "M_.pac." << name << ".growth_index = " << symbol_table.getTypeSpecificID(growth_symb_id) + 1 << ";" << endl 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_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 ...@@ -422,7 +432,10 @@ PacModelStatement::writeJsonOutput(ostream &output) const
output << "," output << ","
<< "\"growth_index\": " << symbol_table.getTypeSpecificID(growth_symb_id) + 1 << "," << "\"growth_index\": " << symbol_table.getTypeSpecificID(growth_symb_id) + 1 << ","
<< "\"growth_lag\": " << growth_lag << "," << "\"growth_lag\": " << growth_lag << ","
<< "\"growth_type\": " << "\"" << growth_type << "\"" << endl; << "\"growth_type\": \"" << growth_type << "\"," << endl
<< "\"growth_str\": \"";
original_growth->writeJsonOutput(output, {}, {}, true);
output << "\"" << endl;
} }
output << "}"; output << "}";
} }
......
...@@ -138,7 +138,7 @@ class PacModelStatement : public Statement ...@@ -138,7 +138,7 @@ class PacModelStatement : public Statement
{ {
public: public:
const string name, aux_model_name, discount; const string name, aux_model_name, discount;
expr_t growth; expr_t growth, original_growth;
private: private:
const double steady_state_growth_rate_number; const double steady_state_growth_rate_number;
const int steady_state_growth_rate_symb_id; const int steady_state_growth_rate_symb_id;
......
Markdown is supported
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