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
issue#70
Sébastien Villemot 2014-04-08 17:43:58 +02:00
parent 0908b0a50a
commit f06da421cd
1 changed files with 14 additions and 21 deletions

View File

@ -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
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 value->writeOutput(output);
<< ":" << period2 << ", " << id << ", "; output << ");" << endl;
value->writeOutput(output);
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
<< "% 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
<< "% MSHOCKS instructions" << endl << "% MSHOCKS instructions" << endl
<< "%" << endl; << "%" << endl;
// Write instruction that initializes a shock
output << "make_ex_;" << endl;
writeDetShocks(output); writeDetShocks(output);
} }