From 833f8c784530daf6065992ee0787b5d2c92e77ee Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Tue, 6 Sep 2016 14:43:06 +0200 Subject: [PATCH] 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 --- preprocessor/ParsingDriver.cc | 2 +- preprocessor/Shocks.cc | 8 +++++--- preprocessor/Shocks.hh | 4 +++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/preprocessor/ParsingDriver.cc b/preprocessor/ParsingDriver.cc index 3ca5a401b..42ac5cdf2 100644 --- a/preprocessor/ParsingDriver.cc +++ b/preprocessor/ParsingDriver.cc @@ -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(); } diff --git a/preprocessor/Shocks.cc b/preprocessor/Shocks.cc index 37b64eea8..9cea0e2d8 100644 --- a/preprocessor/Shocks.cc +++ b/preprocessor/Shocks.cc @@ -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; } diff --git a/preprocessor/Shocks.hh b/preprocessor/Shocks.hh index b29477c4a..f89e1fba1 100644 --- a/preprocessor/Shocks.hh +++ b/preprocessor/Shocks.hh @@ -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; };