Commit f06da421 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Store deterministic shocks information in M_.

Previously, deterministic shock information was not store in M_, but rather
processed on the fly to create oo_.exo_simul and oo_.exo_det_simul. This had
several bad consequences, like for example #35.

Closes #271
parent 0908b0a5
...@@ -36,13 +36,13 @@ void ...@@ -36,13 +36,13 @@ void
AbstractShocksStatement::writeDetShocks(ostream &output) const AbstractShocksStatement::writeDetShocks(ostream &output) const
{ {
int exo_det_length = 0; int exo_det_length = 0;
int counter = 1;
for (det_shocks_t::const_iterator it = det_shocks.begin(); for (det_shocks_t::const_iterator it = det_shocks.begin();
it != det_shocks.end(); it++) it != det_shocks.end(); it++)
{ {
int id = symbol_table.getTypeSpecificID(it->first) + 1; int id = symbol_table.getTypeSpecificID(it->first) + 1;
bool exo_det = (symbol_table.getType(it->first) == eExogenousDet); bool exo_det = (symbol_table.getType(it->first) == eExogenousDet);
int set_shocks_index = ((int) mshocks) + 2 * ((int) exo_det);
for (size_t i = 0; i < it->second.size(); i++) for (size_t i = 0; i < it->second.size(); i++)
{ {
...@@ -50,20 +50,19 @@ AbstractShocksStatement::writeDetShocks(ostream &output) const ...@@ -50,20 +50,19 @@ AbstractShocksStatement::writeDetShocks(ostream &output) const
const int &period2 = it->second[i].period2; const int &period2 = it->second[i].period2;
const expr_t value = it->second[i].value; const expr_t value = it->second[i].value;
if (period1 == period2) output << "M_.det_shocks(" << counter << ").exo_det=" << (int) exo_det
{ << ";" << endl
output << "set_shocks(" << set_shocks_index << "," << period1 << "M_.det_shocks(" << counter << ").exo_id=" << id
<< ", " << id << ", "; << ";" << endl
value->writeOutput(output); << "M_.det_shocks(" << counter << ").multiplicative=" << (int) mshocks
output << ");" << endl; << ";" << endl
} << "M_.det_shocks(" << counter << ").periods=" << period1
else << ":" << period2 << ";" << endl
{ << "M_.det_shocks(" << counter << ").value=(";
output << "set_shocks(" << set_shocks_index << "," << period1
<< ":" << period2 << ", " << id << ", ";
value->writeOutput(output); value->writeOutput(output);
output << ");" << endl; output << ");" << endl;
}
counter++;
if (exo_det && (period2 > exo_det_length)) if (exo_det && (period2 > exo_det_length))
exo_det_length = period2; exo_det_length = period2;
...@@ -93,9 +92,6 @@ ShocksStatement::writeOutput(ostream &output, const string &basename) const ...@@ -93,9 +92,6 @@ ShocksStatement::writeOutput(ostream &output, const string &basename) const
<< "% SHOCKS instructions" << endl << "% SHOCKS instructions" << endl
<< "%" << endl; << "%" << endl;
// Write instruction that initializes a shock
output << "make_ex_;" << endl;
writeDetShocks(output); writeDetShocks(output);
writeVarAndStdShocks(output); writeVarAndStdShocks(output);
writeCovarAndCorrShocks(output); writeCovarAndCorrShocks(output);
...@@ -313,9 +309,6 @@ MShocksStatement::writeOutput(ostream &output, const string &basename) const ...@@ -313,9 +309,6 @@ MShocksStatement::writeOutput(ostream &output, const string &basename) const
<< "% MSHOCKS instructions" << endl << "% MSHOCKS instructions" << endl
<< "%" << endl; << "%" << endl;
// Write instruction that initializes a shock
output << "make_ex_;" << endl;
writeDetShocks(output); writeDetShocks(output);
} }
......
Supports Markdown
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