preprocessor: take care of extra exos in observation_trends

issue#70
Houtan Bastani 2015-04-03 16:20:11 +02:00
parent fd5b9279da
commit e7218bd26a
2 changed files with 24 additions and 0 deletions

View File

@ -1181,6 +1181,29 @@ ObservationTrendsStatement::ObservationTrendsStatement(const trend_elements_t &t
{
}
Statement *
ObservationTrendsStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table)
{
SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable();
map<string, expr_t> new_trend_elements;
try
{
for (map<string, expr_t>::const_iterator it = trend_elements.begin();
it != trend_elements.end(); it++)
{
new_symbol_table->getID(it->first);
new_trend_elements[it->first] = it->second->cloneDynamicReindex(dynamic_datatree, orig_symbol_table);
}
}
catch (...)
{
cerr << "ERROR: A variable in the observation_trends statement was not found in the symbol table" << endl
<< " This likely means that you have declared a varexo that is not used in the model" << endl;
exit(EXIT_FAILURE);
}
return new ObservationTrendsStatement(new_trend_elements, *new_symbol_table);
}
void
ObservationTrendsStatement::writeOutput(ostream &output, const string &basename) const
{

View File

@ -222,6 +222,7 @@ public:
ObservationTrendsStatement(const trend_elements_t &trend_elements_arg,
const SymbolTable &symbol_table_arg);
virtual void writeOutput(ostream &output, const string &basename) const;
virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table);
};
class OsrParamsStatement : public Statement