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 #271issue#70
parent
0908b0a50a
commit
f06da421cd
35
Shocks.cc
35
Shocks.cc
|
@ -36,13 +36,13 @@ void
|
|||
AbstractShocksStatement::writeDetShocks(ostream &output) const
|
||||
{
|
||||
int exo_det_length = 0;
|
||||
int counter = 1;
|
||||
|
||||
for (det_shocks_t::const_iterator it = det_shocks.begin();
|
||||
it != det_shocks.end(); it++)
|
||||
{
|
||||
int id = symbol_table.getTypeSpecificID(it->first) + 1;
|
||||
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++)
|
||||
{
|
||||
|
@ -50,20 +50,19 @@ AbstractShocksStatement::writeDetShocks(ostream &output) const
|
|||
const int &period2 = it->second[i].period2;
|
||||
const expr_t value = it->second[i].value;
|
||||
|
||||
if (period1 == period2)
|
||||
{
|
||||
output << "set_shocks(" << set_shocks_index << "," << period1
|
||||
<< ", " << id << ", ";
|
||||
value->writeOutput(output);
|
||||
output << ");" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
output << "set_shocks(" << set_shocks_index << "," << period1
|
||||
<< ":" << period2 << ", " << id << ", ";
|
||||
value->writeOutput(output);
|
||||
output << ");" << endl;
|
||||
}
|
||||
output << "M_.det_shocks(" << counter << ").exo_det=" << (int) exo_det
|
||||
<< ";" << endl
|
||||
<< "M_.det_shocks(" << counter << ").exo_id=" << id
|
||||
<< ";" << endl
|
||||
<< "M_.det_shocks(" << counter << ").multiplicative=" << (int) mshocks
|
||||
<< ";" << endl
|
||||
<< "M_.det_shocks(" << counter << ").periods=" << period1
|
||||
<< ":" << period2 << ";" << endl
|
||||
<< "M_.det_shocks(" << counter << ").value=(";
|
||||
value->writeOutput(output);
|
||||
output << ");" << endl;
|
||||
|
||||
counter++;
|
||||
|
||||
if (exo_det && (period2 > exo_det_length))
|
||||
exo_det_length = period2;
|
||||
|
@ -93,9 +92,6 @@ ShocksStatement::writeOutput(ostream &output, const string &basename) const
|
|||
<< "% SHOCKS instructions" << endl
|
||||
<< "%" << endl;
|
||||
|
||||
// Write instruction that initializes a shock
|
||||
output << "make_ex_;" << endl;
|
||||
|
||||
writeDetShocks(output);
|
||||
writeVarAndStdShocks(output);
|
||||
writeCovarAndCorrShocks(output);
|
||||
|
@ -313,9 +309,6 @@ MShocksStatement::writeOutput(ostream &output, const string &basename) const
|
|||
<< "% MSHOCKS instructions" << endl
|
||||
<< "%" << endl;
|
||||
|
||||
// Write instruction that initializes a shock
|
||||
output << "make_ex_;" << endl;
|
||||
|
||||
writeDetShocks(output);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue