From 3422bfcf933beaa50ce95a6c77a2e86bcafc788f Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Thu, 2 Apr 2015 17:42:01 +0200 Subject: [PATCH] take care of extra exos in estimated_params --- preprocessor/ComputingTasks.cc | 26 ++++++++++++++++++++++++++ preprocessor/ComputingTasks.hh | 1 + 2 files changed, 27 insertions(+) diff --git a/preprocessor/ComputingTasks.cc b/preprocessor/ComputingTasks.cc index 7882a61f4..b060df704 100644 --- a/preprocessor/ComputingTasks.cc +++ b/preprocessor/ComputingTasks.cc @@ -874,6 +874,32 @@ EstimatedParamsStatement::checkPass(ModFileStructure &mod_file_struct, WarningCo mod_file_struct.estimated_parameters.insert(symbol_table.getID(it->name)); } +Statement * +EstimatedParamsStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) +{ + vector new_estim_params_list; + SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); + try + { + for (vector::const_iterator it = estim_params_list.begin(); + it != estim_params_list.end(); it++) + if (!it->name2.empty()) + { + new_symbol_table->getID(it->name); + new_symbol_table->getID(it->name2); + } + else + new_symbol_table->getID(it->name); + } + catch (SymbolTable::UnknownSymbolNameException &e) + { + cerr << "ERROR: A variable in the estimated_params 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 EstimatedParamsStatement(estim_params_list, *new_symbol_table); +} + void EstimatedParamsStatement::writeOutput(ostream &output, const string &basename) const { diff --git a/preprocessor/ComputingTasks.hh b/preprocessor/ComputingTasks.hh index a3dc37caa..690315c7e 100644 --- a/preprocessor/ComputingTasks.hh +++ b/preprocessor/ComputingTasks.hh @@ -318,6 +318,7 @@ public: const SymbolTable &symbol_table_arg); virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings); virtual void writeOutput(ostream &output, const string &basename) const; + virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class EstimatedParamsInitStatement : public Statement