preprocessor: fix bug in conditional_forecast_paths where the shocked endogenous variable id was provided as symb_id instead of type specific symb_id. #1276

time-shift
Houtan Bastani 2016-09-06 14:43:06 +02:00
parent e31f0a8d0f
commit 833f8c7845
3 changed files with 9 additions and 5 deletions

View File

@ -2098,7 +2098,7 @@ ParsingDriver::plot_conditional_forecast(string *periods)
void
ParsingDriver::conditional_forecast_paths()
{
mod_file->addStatement(new ConditionalForecastPathsStatement(det_shocks));
mod_file->addStatement(new ConditionalForecastPathsStatement(det_shocks, mod_file->symbol_table));
det_shocks.clear();
}

View File

@ -352,8 +352,10 @@ MShocksStatement::writeOutput(ostream &output, const string &basename, bool mini
writeDetShocks(output);
}
ConditionalForecastPathsStatement::ConditionalForecastPathsStatement(const AbstractShocksStatement::det_shocks_t &paths_arg) :
ConditionalForecastPathsStatement::ConditionalForecastPathsStatement(const AbstractShocksStatement::det_shocks_t &paths_arg,
const SymbolTable &symbol_table_arg) :
paths(paths_arg),
symbol_table(symbol_table_arg),
path_length(-1)
{
}
@ -393,11 +395,11 @@ ConditionalForecastPathsStatement::writeOutput(ostream &output, const string &ba
{
if (it == paths.begin())
{
output << "constrained_vars_ = " << it->first +1 << ";" << endl;
output << "constrained_vars_ = " << symbol_table.getTypeSpecificID(it->first) + 1 << ";" << endl;
}
else
{
output << "constrained_vars_ = [constrained_vars_; " << it->first +1 << "];" << endl;
output << "constrained_vars_ = [constrained_vars_; " << symbol_table.getTypeSpecificID(it->first) + 1 << "];" << endl;
}

View File

@ -94,9 +94,11 @@ class ConditionalForecastPathsStatement : public Statement
{
private:
const AbstractShocksStatement::det_shocks_t paths;
const SymbolTable &symbol_table;
int path_length;
public:
ConditionalForecastPathsStatement(const AbstractShocksStatement::det_shocks_t &paths_arg);
ConditionalForecastPathsStatement(const AbstractShocksStatement::det_shocks_t &paths_arg,
const SymbolTable &symbol_table_arg);
virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const;
};