diff --git a/ComputingTasks.cc b/ComputingTasks.cc index 4b7b7c7e93ddb8dec834f309d4d74c55b7877d13..9acdc06ae9069c8873749de7bd73dc2abffa7db2 100644 --- a/ComputingTasks.cc +++ b/ComputingTasks.cc @@ -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 { diff --git a/ComputingTasks.hh b/ComputingTasks.hh index 968fd5d9258a198c457c452c2912b473163a90e5..3a4df94be87357c90148cfeb32bbec7f1f3ba020 100644 --- a/ComputingTasks.hh +++ b/ComputingTasks.hh @@ -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