diff --git a/ComputingTasks.cc b/ComputingTasks.cc index 32d3690b..2b4063af 100644 --- a/ComputingTasks.cc +++ b/ComputingTasks.cc @@ -169,63 +169,6 @@ StochSimulStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsoli } -Statement * -StochSimulStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - vector errors; - SymbolList new_symbol_list, new_options_symbol_list; - OptionsList new_options_list = options_list; - SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); - vector symbols = symbol_list.get_symbols(); - - for (vector::const_iterator it = symbols.begin(); it != symbols.end(); it++) - try - { - new_symbol_table->getID(*it); - new_symbol_list.addSymbol(*it); - } - catch (SymbolTable::UnknownSymbolIDException &e) - { - errors.push_back(orig_symbol_table.getName(e.id)); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - - OptionsList::symbol_list_options_t::const_iterator it = options_list.symbol_list_options.find("irf_shocks"); - if (it != options_list.symbol_list_options.end()) - { - symbols = it->second.get_symbols(); - for (vector::const_iterator it1 = symbols.begin(); it1 != symbols.end(); it1++) - try - { - new_symbol_table->getID(*it1); - new_options_symbol_list.addSymbol(*it1); - } - catch (SymbolTable::UnknownSymbolIDException &e) - { - errors.push_back(orig_symbol_table.getName(e.id)); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - new_options_list.symbol_list_options["irf_shocks"] = new_options_symbol_list; - } - - if (!errors.empty()) - { - cerr << endl - << "ERROR: The following vars were used in the stoch_simul statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl; - for (vector::const_iterator it = errors.begin(); it != errors.end(); it++) - cerr << *it << endl; - exit(EXIT_FAILURE); - } - return new StochSimulStatement(new_symbol_list, new_options_list); -} - void StochSimulStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const { @@ -248,37 +191,6 @@ ForecastStatement::ForecastStatement(const SymbolList &symbol_list_arg, { } -Statement * -ForecastStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - vector errors; - SymbolList new_symbol_list; - SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); - vector symbols = symbol_list.get_symbols(); - for (vector::const_iterator it = symbols.begin(); it != symbols.end(); it++) - try - { - new_symbol_table->getID(*it); - new_symbol_list.addSymbol(*it); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - - if (!errors.empty()) - { - cerr << endl - << "ERROR: The following vars were used in the forecast statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl; - for (vector::const_iterator it = errors.begin(); it != errors.end(); it++) - cerr << *it << endl; - exit(EXIT_FAILURE); - } - - return new ForecastStatement(new_symbol_list, options_list); -} - void ForecastStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const { @@ -326,63 +238,6 @@ RamseyModelStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsol mod_file_struct.k_order_solver = true; } -Statement * -RamseyModelStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - vector errors; - SymbolList new_symbol_list, new_options_symbol_list; - OptionsList new_options_list = options_list; - SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); - vector symbols = symbol_list.get_symbols(); - - for (vector::const_iterator it = symbols.begin(); it != symbols.end(); it++) - try - { - new_symbol_table->getID(*it); - new_symbol_list.addSymbol(*it); - } - catch (SymbolTable::UnknownSymbolIDException &e) - { - errors.push_back(orig_symbol_table.getName(e.id)); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - - OptionsList::symbol_list_options_t::const_iterator it = options_list.symbol_list_options.find("instruments"); - if (it != options_list.symbol_list_options.end()) - { - symbols = it->second.get_symbols(); - for (vector::const_iterator it1 = symbols.begin(); it1 != symbols.end(); it1++) - try - { - new_symbol_table->getID(*it1); - new_options_symbol_list.addSymbol(*it1); - } - catch (SymbolTable::UnknownSymbolIDException &e) - { - errors.push_back(orig_symbol_table.getName(e.id)); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - new_options_list.symbol_list_options["instruments"] = new_options_symbol_list; - } - - if (!errors.empty()) - { - cerr << endl - << "ERROR: The following vars were used in the ramsey_model statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl; - for (vector::const_iterator it = errors.begin(); it != errors.end(); it++) - cerr << *it << endl; - exit(EXIT_FAILURE); - } - return new RamseyModelStatement(new_symbol_list, options_list); -} - void RamseyModelStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const { @@ -547,63 +402,6 @@ RamseyPolicyStatement::checkPass(ModFileStructure &mod_file_struct, WarningConso mod_file_struct.k_order_solver = true; } -Statement * -RamseyPolicyStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - vector errors; - SymbolList new_symbol_list, new_options_symbol_list; - OptionsList new_options_list = options_list; - SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); - vector symbols = symbol_list.get_symbols(); - - for (vector::const_iterator it = symbols.begin(); it != symbols.end(); it++) - try - { - new_symbol_table->getID(*it); - new_symbol_list.addSymbol(*it); - } - catch (SymbolTable::UnknownSymbolIDException &e) - { - errors.push_back(orig_symbol_table.getName(e.id)); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - - OptionsList::symbol_list_options_t::const_iterator it = options_list.symbol_list_options.find("instruments"); - if (it != options_list.symbol_list_options.end()) - { - symbols = it->second.get_symbols(); - for (vector::const_iterator it1 = symbols.begin(); it1 != symbols.end(); it1++) - try - { - new_symbol_table->getID(*it1); - new_options_symbol_list.addSymbol(*it1); - } - catch (SymbolTable::UnknownSymbolIDException &e) - { - errors.push_back(orig_symbol_table.getName(e.id)); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - new_options_list.symbol_list_options["instruments"] = new_options_symbol_list; - } - - if (!errors.empty()) - { - cerr << endl - << "ERROR: The following vars were used in the ramsey_policy statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl; - for (vector::const_iterator it = errors.begin(); it != errors.end(); it++) - cerr << *it << endl; - exit(EXIT_FAILURE); - } - return new RamseyPolicyStatement(new_symbol_list, options_list); -} - void RamseyPolicyStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const { @@ -664,63 +462,6 @@ DiscretionaryPolicyStatement::checkPass(ModFileStructure &mod_file_struct, Warni mod_file_struct.k_order_solver = true; } -Statement * -DiscretionaryPolicyStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - vector errors; - SymbolList new_symbol_list, new_options_symbol_list; - OptionsList new_options_list = options_list; - SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); - vector symbols = symbol_list.get_symbols(); - - for (vector::const_iterator it = symbols.begin(); it != symbols.end(); it++) - try - { - new_symbol_table->getID(*it); - new_symbol_list.addSymbol(*it); - } - catch (SymbolTable::UnknownSymbolIDException &e) - { - errors.push_back(orig_symbol_table.getName(e.id)); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - - OptionsList::symbol_list_options_t::const_iterator it = options_list.symbol_list_options.find("instruments"); - if (it != options_list.symbol_list_options.end()) - { - symbols = it->second.get_symbols(); - for (vector::const_iterator it1 = symbols.begin(); it1 != symbols.end(); it1++) - try - { - new_symbol_table->getID(*it1); - new_options_symbol_list.addSymbol(*it1); - } - catch (SymbolTable::UnknownSymbolIDException &e) - { - errors.push_back(orig_symbol_table.getName(e.id)); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - new_options_list.symbol_list_options["instruments"] = new_options_symbol_list; - } - - if (!errors.empty()) - { - cerr << endl - << "ERROR: The following vars were used in the discretionary_policy statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl; - for (vector::const_iterator it = errors.begin(); it != errors.end(); it++) - cerr << *it << endl; - exit(EXIT_FAILURE); - } - return new DiscretionaryPolicyStatement(new_symbol_list, options_list); -} - void DiscretionaryPolicyStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const { @@ -827,63 +568,6 @@ EstimationStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsoli } } -Statement * -EstimationStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - vector errors; - SymbolList new_symbol_list, new_options_symbol_list; - OptionsList new_options_list = options_list; - SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); - vector symbols = symbol_list.get_symbols(); - - for (vector::const_iterator it = symbols.begin(); it != symbols.end(); it++) - try - { - new_symbol_table->getID(*it); - new_symbol_list.addSymbol(*it); - } - catch (SymbolTable::UnknownSymbolIDException &e) - { - errors.push_back(orig_symbol_table.getName(e.id)); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - - OptionsList::symbol_list_options_t::const_iterator it = options_list.symbol_list_options.find("irf_shocks"); - if (it != options_list.symbol_list_options.end()) - { - symbols = it->second.get_symbols(); - for (vector::const_iterator it1 = symbols.begin(); it1 != symbols.end(); it1++) - try - { - new_symbol_table->getID(*it1); - new_options_symbol_list.addSymbol(*it1); - } - catch (SymbolTable::UnknownSymbolIDException &e) - { - errors.push_back(orig_symbol_table.getName(e.id)); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - new_options_list.symbol_list_options["irf_shocks"] = new_options_symbol_list; - } - - if (!errors.empty()) - { - cerr << endl - << "ERROR: The following vars were used in the estimation statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl; - for (vector::const_iterator it = errors.begin(); it != errors.end(); it++) - cerr << *it << endl; - exit(EXIT_FAILURE); - } - return new EstimationStatement(new_symbol_list, new_options_list); -} - void EstimationStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const { @@ -919,61 +603,6 @@ DynareSensitivityStatement::checkPass(ModFileStructure &mod_file_struct, Warning mod_file_struct.identification_present = true; } -Statement * -DynareSensitivityStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - vector errors; - SymbolList new_options_symbol_list; - OptionsList new_options_list = options_list; - SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); - string opts_to_check[] = {"namendo", "namlagendo", "namexo", "var_rmse"}; - vector opts (opts_to_check, opts_to_check + sizeof(opts_to_check)/sizeof(string)); - for (vector::const_iterator it=opts.begin(); it != opts.end(); it++) - try - { - OptionsList::symbol_list_options_t::const_iterator it1 = - options_list.symbol_list_options.find(*it); - if (it1 != options_list.symbol_list_options.end()) - { - vector symbols = it1->second.get_symbols(); - for (vector::const_iterator it2 = symbols.begin(); it2 != symbols.end(); it2++) - try - { - new_symbol_table->getID(*it2); - new_options_symbol_list.addSymbol(*it2); - } - catch (SymbolTable::UnknownSymbolIDException &e) - { - errors.push_back(orig_symbol_table.getName(e.id)); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - new_options_list.symbol_list_options[*it] = new_options_symbol_list; - } - } - catch (SymbolTable::UnknownSymbolIDException &e) - { - errors.push_back(orig_symbol_table.getName(e.id)); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - - if (!errors.empty()) - { - cerr << endl - << "ERROR: The following vars were used in the dynare_sensitivity statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl; - for (vector::const_iterator it = errors.begin(); it != errors.end(); it++) - cerr << *it << endl; - exit(EXIT_FAILURE); - } - return new DynareSensitivityStatement(new_options_list); -} - void DynareSensitivityStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const { @@ -1001,36 +630,6 @@ RplotStatement::RplotStatement(const SymbolList &symbol_list_arg) : { } -Statement * -RplotStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - vector errors; - SymbolList new_symbol_list; - SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); - vector symbols = symbol_list.get_symbols(); - for (vector::const_iterator it = symbols.begin(); it != symbols.end(); it++) - try - { - new_symbol_table->getID(*it); - new_symbol_list.addSymbol(*it); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - - if (!errors.empty()) - { - cerr << endl - << "ERROR: The following vars were used in the rplot statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl; - for (vector::const_iterator it = errors.begin(); it != errors.end(); it++) - cerr << *it << endl; - exit(EXIT_FAILURE); - } - return new RplotStatement(new_symbol_list); -} - void RplotStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const { @@ -1147,42 +746,6 @@ 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 errors; - vector new_estim_params_list; - SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); - - for (vector::const_iterator it = estim_params_list.begin(); - it != estim_params_list.end(); it++) - try - { - 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) - { - errors.push_back(e.name); - } - - if (!errors.empty()) - { - cerr << endl - << "ERROR: The following vars were used in the estimated_params statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl; - for (vector::const_iterator it = errors.begin(); it != errors.end(); it++) - cerr << *it << endl; - exit(EXIT_FAILURE); - } - return new EstimatedParamsStatement(estim_params_list, *new_symbol_table); -} - void EstimatedParamsStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const { @@ -1258,41 +821,6 @@ EstimatedParamsInitStatement::checkPass(ModFileStructure &mod_file_struct, Warni mod_file_struct.estim_params_use_calib = true; } -Statement * -EstimatedParamsInitStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - vector errors; - vector new_estim_params_list; - SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); - for (vector::const_iterator it = estim_params_list.begin(); - it != estim_params_list.end(); it++) - try - { - 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) - { - errors.push_back(e.name); - } - - if (!errors.empty()) - { - cerr << endl - << "ERROR: The following vars were used in the estimated_params_init statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl; - for (vector::const_iterator it = errors.begin(); it != errors.end(); it++) - cerr << *it << endl; - exit(EXIT_FAILURE); - } - return new EstimatedParamsInitStatement(estim_params_list, *new_symbol_table, use_calibration); -} - void EstimatedParamsInitStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const { @@ -1359,41 +887,6 @@ EstimatedParamsBoundsStatement::EstimatedParamsBoundsStatement(const vector errors; - vector new_estim_params_list; - SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); - for (vector::const_iterator it = estim_params_list.begin(); - it != estim_params_list.end(); it++) - try - { - 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) - { - errors.push_back(e.name); - } - - if (!errors.empty()) - { - cerr << endl - << "ERROR: The following vars were used in the estimated_params_bounds statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl; - for (vector::const_iterator it = errors.begin(); it != errors.end(); it++) - cerr << *it << endl; - exit(EXIT_FAILURE); - } - return new EstimatedParamsBoundsStatement(estim_params_list, *new_symbol_table); -} - void EstimatedParamsBoundsStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const { @@ -1482,39 +975,6 @@ ObservationTrendsStatement::ObservationTrendsStatement(const trend_elements_t &t { } -Statement * -ObservationTrendsStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - vector errors; - map new_trend_elements; - for (map::const_iterator it = trend_elements.begin(); - it != trend_elements.end(); it++) - try - { - symbol_table.getID(it->first); - new_trend_elements[it->first] = it->second->cloneDynamicReindex(dynamic_datatree, orig_symbol_table); - } - catch (SymbolTable::UnknownSymbolIDException &e) - { - errors.push_back(orig_symbol_table.getName(e.id)); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - - if (!errors.empty()) - { - cerr << endl - << "ERROR: The following vars were used in the observation_trends statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl; - for (vector::const_iterator it = errors.begin(); it != errors.end(); it++) - cerr << *it << endl; - exit(EXIT_FAILURE); - } - return new ObservationTrendsStatement(new_trend_elements, symbol_table); -} - void ObservationTrendsStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const { @@ -1548,36 +1008,6 @@ OsrParamsStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolid mod_file_struct.osr_params_present = true; } -Statement * -OsrParamsStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - vector errors; - SymbolList new_symbol_list; - SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); - vector symbols = symbol_list.get_symbols(); - for (vector::const_iterator it = symbols.begin(); it != symbols.end(); it++) - try - { - new_symbol_table->getID(*it); - new_symbol_list.addSymbol(*it); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - - if (!errors.empty()) - { - cerr << endl - << "ERROR: The following vars were used in the osr_params statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl; - for (vector::const_iterator it = errors.begin(); it != errors.end(); it++) - cerr << *it << endl; - exit(EXIT_FAILURE); - } - return new OsrParamsStatement(new_symbol_list); -} - void OsrParamsStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const { @@ -1613,36 +1043,6 @@ OsrStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation mod_file_struct.k_order_solver = true; } -Statement * -OsrStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - vector errors; - SymbolList new_symbol_list; - SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); - vector symbols = symbol_list.get_symbols(); - for (vector::const_iterator it = symbols.begin(); it != symbols.end(); it++) - try - { - new_symbol_table->getID(*it); - new_symbol_list.addSymbol(*it); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - - if (!errors.empty()) - { - cerr << endl - << "ERROR: The following vars were used in the osr statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl; - for (vector::const_iterator it = errors.begin(); it != errors.end(); it++) - cerr << *it << endl; - exit(EXIT_FAILURE); - } - return new OsrStatement(new_symbol_list, options_list); -} - void OsrStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const { @@ -1673,59 +1073,6 @@ OptimWeightsStatement::checkPass(ModFileStructure &mod_file_struct, WarningConso mod_file_struct.optim_weights_present = true; } -Statement * -OptimWeightsStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - vector errors; - var_weights_t new_var_weights; - covar_weights_t new_covar_weights; - - for (var_weights_t::const_iterator it = var_weights.begin(); - it != var_weights.end(); it++) - try - { - symbol_table.getID(it->first); - new_var_weights[it->first] = it->second->cloneDynamicReindex(dynamic_datatree, orig_symbol_table); - } - catch (SymbolTable::UnknownSymbolIDException &e) - { - errors.push_back(orig_symbol_table.getName(e.id)); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - - for (covar_weights_t::const_iterator it = covar_weights.begin(); - it != covar_weights.end(); it++) - try - { - symbol_table.getID(it->first.first); - symbol_table.getID(it->first.second); - new_covar_weights[make_pair(it->first.first, it->first.second)] = - it->second->cloneDynamicReindex(dynamic_datatree, orig_symbol_table); - } - catch (SymbolTable::UnknownSymbolIDException &e) - { - errors.push_back(orig_symbol_table.getName(e.id)); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - - if (!errors.empty()) - { - cerr << endl - << "ERROR: The following vars were used in the optim_weights statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl; - for (vector::const_iterator it = errors.begin(); it != errors.end(); it++) - cerr << *it << endl; - exit(EXIT_FAILURE); - } - return new OptimWeightsStatement(new_var_weights, new_covar_weights, symbol_table); -} - void OptimWeightsStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const { @@ -1769,36 +1116,6 @@ DynaSaveStatement::DynaSaveStatement(const SymbolList &symbol_list_arg, { } -Statement * -DynaSaveStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - vector errors; - SymbolList new_symbol_list; - SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); - vector symbols = symbol_list.get_symbols(); - for (vector::const_iterator it = symbols.begin(); it != symbols.end(); it++) - try - { - new_symbol_table->getID(*it); - new_symbol_list.addSymbol(*it); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - - if (!errors.empty()) - { - cerr << endl - << "ERROR: The following vars were used in the dynasave statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl; - for (vector::const_iterator it = errors.begin(); it != errors.end(); it++) - cerr << *it << endl; - exit(EXIT_FAILURE); - } - return new DynaSaveStatement(new_symbol_list, filename); -} - void DynaSaveStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const { @@ -1814,36 +1131,6 @@ DynaTypeStatement::DynaTypeStatement(const SymbolList &symbol_list_arg, { } -Statement * -DynaTypeStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - vector errors; - SymbolList new_symbol_list; - SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); - vector symbols = symbol_list.get_symbols(); - for (vector::const_iterator it = symbols.begin(); it != symbols.end(); it++) - try - { - new_symbol_table->getID(*it); - new_symbol_list.addSymbol(*it); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - - if (!errors.empty()) - { - cerr << endl - << "ERROR: The following vars were used in the dynatype statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl; - for (vector::const_iterator it = errors.begin(); it != errors.end(); it++) - cerr << *it << endl; - exit(EXIT_FAILURE); - } - return new DynaTypeStatement(new_symbol_list, filename); -} - void DynaTypeStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const { @@ -1893,34 +1180,6 @@ PlannerObjectiveStatement::checkPass(ModFileStructure &mod_file_struct, WarningC mod_file_struct.planner_objective_present = true; } -Statement * -PlannerObjectiveStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - string error; - try - { - model_tree->reindex(orig_symbol_table); - } - catch (SymbolTable::UnknownSymbolIDException &e) - { - error = orig_symbol_table.getName(e.id); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - error = e.name; - } - - if (!error.empty()) - { - cerr << endl - << "ERROR: The following vars were used in the planner_objective statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl - << error << endl; - exit(EXIT_FAILURE); - } - return new PlannerObjectiveStatement(model_tree); -} - StaticModel * PlannerObjectiveStatement::getPlannerObjective() const { @@ -2136,36 +1395,6 @@ MSSBVARIrfStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsoli } } -Statement * -MSSBVARIrfStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - vector errors; - SymbolList new_symbol_list; - SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); - vector symbols = symbol_list.get_symbols(); - for (vector::const_iterator it = symbols.begin(); it != symbols.end(); it++) - try - { - new_symbol_table->getID(*it); - new_symbol_list.addSymbol(*it); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - - if (!errors.empty()) - { - cerr << endl - << "ERROR: The following vars were used in the ms_sbvar_irf statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl; - for (vector::const_iterator it = errors.begin(); it != errors.end(); it++) - cerr << *it << endl; - exit(EXIT_FAILURE); - } - return new MSSBVARIrfStatement(new_symbol_list, options_list); -} - void MSSBVARIrfStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const { @@ -2324,36 +1553,6 @@ ShockDecompositionStatement::ShockDecompositionStatement(const SymbolList &symbo { } -Statement * -ShockDecompositionStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - vector errors; - SymbolList new_symbol_list; - SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); - vector symbols = symbol_list.get_symbols(); - for (vector::const_iterator it = symbols.begin(); it != symbols.end(); it++) - try - { - new_symbol_table->getID(*it); - new_symbol_list.addSymbol(*it); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - - if (!errors.empty()) - { - cerr << endl - << "ERROR: The following vars were used in the shock_decomposition statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl; - for (vector::const_iterator it = errors.begin(); it != errors.end(); it++) - cerr << *it << endl; - exit(EXIT_FAILURE); - } - return new ShockDecompositionStatement(new_symbol_list, options_list); -} - void ShockDecompositionStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const { @@ -2367,47 +1566,6 @@ ConditionalForecastStatement::ConditionalForecastStatement(const OptionsList &op { } -Statement * -ConditionalForecastStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - vector errors; - OptionsList new_options_list = options_list; - OptionsList::symbol_list_options_t::const_iterator it = - options_list.symbol_list_options.find("controlled_varexo"); - if (it != options_list.symbol_list_options.end()) - { - SymbolList new_options_symbol_list; - SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); - vector symbols = it->second.get_symbols(); - for (vector::const_iterator it1 = symbols.begin(); it1 != symbols.end(); it1++) - try - { - new_symbol_table->getID(*it1); - new_options_symbol_list.addSymbol(*it1); - } - catch (SymbolTable::UnknownSymbolIDException &e) - { - errors.push_back(orig_symbol_table.getName(e.id)); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - new_options_list.symbol_list_options["controlled_varexo"] = new_options_symbol_list; - } - - if (!errors.empty()) - { - cerr << endl - << "ERROR: The following vars were used in the conditional_forecast statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl; - for (vector::const_iterator it = errors.begin(); it != errors.end(); it++) - cerr << *it << endl; - exit(EXIT_FAILURE); - } - return new ConditionalForecastStatement(new_options_list); -} - void ConditionalForecastStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const { @@ -2421,36 +1579,6 @@ PlotConditionalForecastStatement::PlotConditionalForecastStatement(int periods_a { } -Statement * -PlotConditionalForecastStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - vector errors; - SymbolList new_symbol_list; - SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); - vector symbols = symbol_list.get_symbols(); - for (vector::const_iterator it = symbols.begin(); it != symbols.end(); it++) - try - { - new_symbol_table->getID(*it); - new_symbol_list.addSymbol(*it); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - - if (!errors.empty()) - { - cerr << endl - << "ERROR: The following vars were used in the plot_conditional_forecast statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl; - for (vector::const_iterator it = errors.begin(); it != errors.end(); it++) - cerr << *it << endl; - exit(EXIT_FAILURE); - } - return new PlotConditionalForecastStatement(periods, new_symbol_list); -} - void PlotConditionalForecastStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const { @@ -3365,25 +2493,6 @@ PriorStatement::PriorStatement(const string &name_arg, { } -Statement * -PriorStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - try - { - SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); - new_symbol_table->getID(name); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - cerr << endl - << "ERROR: The following vars were used in the prior statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl - << e.name << endl; - exit(EXIT_FAILURE); - } - return new PriorStatement(name, subsample_name, prior_shape, variance, options_list); -} - void PriorStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const { @@ -3421,25 +2530,6 @@ StdPriorStatement::StdPriorStatement(const string &name_arg, { } -Statement * -StdPriorStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); - try - { - new_symbol_table->getID(name); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - cerr << endl - << "ERROR: The following vars were used in the std_prior statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl - << e.name << endl; - exit(EXIT_FAILURE); - } - return new StdPriorStatement(name, subsample_name, prior_shape, variance, options_list, *new_symbol_table); -} - void StdPriorStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const { @@ -3503,40 +2593,6 @@ CorrPriorStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolid } } -Statement * -CorrPriorStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - vector errors; - SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); - try - { - new_symbol_table->getID(name); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - try - { - new_symbol_table->getID(name1); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - - if (!errors.empty()) - { - cerr << endl - << "ERROR: The following vars were used in the std_prior statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl; - for (vector::const_iterator it = errors.begin(); it != errors.end(); it++) - cerr << *it << endl; - exit(EXIT_FAILURE); - } - return new CorrPriorStatement(name, name1, subsample_name, prior_shape, variance, options_list, *new_symbol_table); -} - void CorrPriorStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const { @@ -3616,48 +2672,6 @@ PriorEqualStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsoli } } -Statement * -PriorEqualStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - vector errors; - SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); - string names_to_check[] = {to_name1, to_name2, from_name1, from_name2}; - vector opts (names_to_check, names_to_check + sizeof(names_to_check)/sizeof(string)); - for (vector::const_iterator it=opts.begin(); it != opts.end(); it++) - try - { - if (!it->empty()) - new_symbol_table->getID(*it); - } - catch (SymbolTable::UnknownSymbolIDException &e) - { - errors.push_back(orig_symbol_table.getName(e.id)); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - - if (!errors.empty()) - { - cerr << endl - << "ERROR: The following vars were used in the prior equal statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl; - for (vector::const_iterator it = errors.begin(); it != errors.end(); it++) - cerr << *it << endl; - exit(EXIT_FAILURE); - } - return new PriorEqualStatement(to_declaration_type, - to_name1, - to_name2, - to_subsample_name, - from_declaration_type, - from_name1, - from_name2, - from_subsample_name, - *new_symbol_table); -} - void PriorEqualStatement::get_base_name(const SymbolType symb_type, string &lhs_field) const { @@ -3813,25 +2827,6 @@ OptionsStatement::OptionsStatement(const string &name_arg, { } -Statement * -OptionsStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - try - { - SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); - new_symbol_table->getID(name); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - cerr << endl - << "ERROR: The following vars were used in the options statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl - << e.name << endl; - exit(EXIT_FAILURE); - } - return new OptionsStatement(name, subsample_name, options_list); -} - void OptionsStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const { @@ -3860,25 +2855,6 @@ StdOptionsStatement::StdOptionsStatement(const string &name_arg, { } -Statement * -StdOptionsStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); - try - { - new_symbol_table->getID(name); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - cerr << endl - << "ERROR: The following vars were used in the std_options statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl - << e.name << endl; - exit(EXIT_FAILURE); - } - return new StdOptionsStatement(name, subsample_name, options_list, *new_symbol_table); -} - void StdOptionsStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const { @@ -3934,42 +2910,6 @@ CorrOptionsStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsol } } -Statement * -CorrOptionsStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - vector errors; - SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); - try - { - new_symbol_table->getID(name); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - - try - { - new_symbol_table->getID(name1); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - - if (!errors.empty()) - { - cerr << endl - << "ERROR: The following vars were used in the corr_options statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl; - for (vector::const_iterator it = errors.begin(); it != errors.end(); it++) - cerr << *it << endl; - exit(EXIT_FAILURE); - } - - return new CorrOptionsStatement(name, name1, subsample_name, options_list, *new_symbol_table); -} - void CorrOptionsStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const { @@ -4044,49 +2984,6 @@ OptionsEqualStatement::checkPass(ModFileStructure &mod_file_struct, WarningConso } } -Statement * -OptionsEqualStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - vector errors; - SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); - string names_to_check[] = {to_name1, to_name2, from_name1, from_name2}; - vector opts (names_to_check, names_to_check + sizeof(names_to_check)/sizeof(string)); - for (vector::const_iterator it=opts.begin(); it != opts.end(); it++) - try - { - if (!it->empty()) - new_symbol_table->getID(*it); - } - catch (SymbolTable::UnknownSymbolIDException &e) - { - errors.push_back(orig_symbol_table.getName(e.id)); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - - if (!errors.empty()) - { - cerr << endl - << "ERROR: The following vars were used in the options equal statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl; - for (vector::const_iterator it = errors.begin(); it != errors.end(); it++) - cerr << *it << endl; - exit(EXIT_FAILURE); - } - - return new OptionsEqualStatement(to_declaration_type, - to_name1, - to_name2, - to_subsample_name, - from_declaration_type, - from_name1, - from_name2, - from_subsample_name, - *new_symbol_table); -} - void OptionsEqualStatement::get_base_name(const SymbolType symb_type, string &lhs_field) const { @@ -4170,36 +3067,6 @@ CalibSmootherStatement::checkPass(ModFileStructure &mod_file_struct, WarningCons mod_file_struct.calib_smoother_present = true; } -Statement * -CalibSmootherStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - vector errors; - SymbolList new_symbol_list; - SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); - vector symbols = symbol_list.get_symbols(); - for (vector::const_iterator it = symbols.begin(); it != symbols.end(); it++) - try - { - new_symbol_table->getID(*it); - new_symbol_list.addSymbol(*it); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - - if (!errors.empty()) - { - cerr << endl - << "ERROR: The following vars were used in the calib_smoother statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl; - for (vector::const_iterator it = errors.begin(); it != errors.end(); it++) - cerr << *it << endl; - exit(EXIT_FAILURE); - } - return new CalibSmootherStatement(new_symbol_list, options_list); -} - void CalibSmootherStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const { @@ -4262,61 +3129,6 @@ Smoother2histvalStatement::Smoother2histvalStatement(const OptionsList &options_ { } -Statement * -Smoother2histvalStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - vector errors; - SymbolList new_options_symbol_list; - OptionsList new_options_list = options_list; - SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); - string opts_to_check[] = {"invars", "outvars"}; - vector opts (opts_to_check, opts_to_check + sizeof(opts_to_check)/sizeof(string)); - for (vector::const_iterator it=opts.begin(); it != opts.end(); it++) - try - { - OptionsList::symbol_list_options_t::const_iterator it1 = - options_list.symbol_list_options.find(*it); - if (it1 != options_list.symbol_list_options.end()) - { - vector symbols = it1->second.get_symbols(); - for (vector::const_iterator it2 = symbols.begin(); it2 != symbols.end(); it2++) - try - { - new_symbol_table->getID(*it2); - new_options_symbol_list.addSymbol(*it2); - } - catch (SymbolTable::UnknownSymbolIDException &e) - { - errors.push_back(orig_symbol_table.getName(e.id)); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - new_options_list.symbol_list_options[*it] = new_options_symbol_list; - } - } - catch (SymbolTable::UnknownSymbolIDException &e) - { - errors.push_back(orig_symbol_table.getName(e.id)); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - - if (!errors.empty()) - { - cerr << endl - << "ERROR: The following vars were used in the smoother2histval statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl; - for (vector::const_iterator it = errors.begin(); it != errors.end(); it++) - cerr << *it << endl; - exit(EXIT_FAILURE); - } - return new Smoother2histvalStatement(new_options_list); -} - void Smoother2histvalStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const { diff --git a/ComputingTasks.hh b/ComputingTasks.hh index b9b65d46..7e6d863b 100644 --- a/ComputingTasks.hh +++ b/ComputingTasks.hh @@ -97,7 +97,6 @@ public: const OptionsList &options_list_arg); virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class ForecastStatement : public Statement @@ -109,7 +108,6 @@ public: ForecastStatement(const SymbolList &symbol_list_arg, const OptionsList &options_list_arg); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class RamseyModelStatement : public Statement @@ -122,7 +120,6 @@ public: const OptionsList &options_list_arg); virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class RamseyConstraintsStatement : public Statement @@ -153,7 +150,6 @@ public: const OptionsList &options_list_arg); virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class DiscretionaryPolicyStatement : public Statement @@ -166,7 +162,6 @@ public: const OptionsList &options_list_arg); virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class RplotStatement : public Statement @@ -176,7 +171,6 @@ private: public: RplotStatement(const SymbolList &symbol_list_arg); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class UnitRootVarsStatement : public Statement @@ -215,7 +209,6 @@ public: const OptionsList &options_list_arg); virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class DynareSensitivityStatement : public Statement @@ -226,7 +219,6 @@ public: DynareSensitivityStatement(const OptionsList &options_list_arg); virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class ObservationTrendsStatement : public Statement @@ -240,7 +232,6 @@ public: ObservationTrendsStatement(const trend_elements_t &trend_elements_arg, const SymbolTable &symbol_table_arg); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class OsrParamsStatement : public Statement @@ -251,7 +242,6 @@ public: OsrParamsStatement(const SymbolList &symbol_list_arg); virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class OsrStatement : public Statement @@ -264,7 +254,6 @@ public: const OptionsList &options_list_arg); virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class DynaTypeStatement : public Statement @@ -276,7 +265,6 @@ public: DynaTypeStatement(const SymbolList &symbol_list_arg, const string &filename_arg); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class DynaSaveStatement : public Statement @@ -288,7 +276,6 @@ public: DynaSaveStatement(const SymbolList &symbol_list_arg, const string &filename_arg); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class ModelComparisonStatement : public Statement @@ -341,7 +328,6 @@ public: 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; - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class EstimatedParamsInitStatement : public Statement @@ -356,7 +342,6 @@ public: const bool use_calibration_arg); virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class EstimatedParamsBoundsStatement : public Statement @@ -368,7 +353,6 @@ public: EstimatedParamsBoundsStatement(const vector &estim_params_list_arg, const SymbolTable &symbol_table_arg); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class OptimWeightsStatement : public Statement @@ -386,7 +370,6 @@ public: 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; - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; /*! \todo Make model_tree a member instead of a pointer */ @@ -408,7 +391,6 @@ public: virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; //! Return the Planner Objective StaticModel *getPlannerObjective() const; - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class BVARDensityStatement : public Statement @@ -493,7 +475,6 @@ public: const OptionsList &options_list_arg); virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class MSSBVARForecastStatement : public Statement @@ -562,7 +543,6 @@ public: ShockDecompositionStatement(const SymbolList &symbol_list_arg, const OptionsList &options_list_arg); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class ConditionalForecastStatement : public Statement @@ -572,7 +552,6 @@ private: public: ConditionalForecastStatement(const OptionsList &options_list_arg); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class PlotConditionalForecastStatement : public Statement @@ -584,7 +563,6 @@ private: public: PlotConditionalForecastStatement(int periods_arg, const SymbolList &symbol_list_arg); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class CalibSmootherStatement : public Statement @@ -597,7 +575,6 @@ public: const OptionsList &options_list_arg); virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class ExtendedPathStatement : public Statement @@ -775,7 +752,6 @@ public: const OptionsList &options_list_arg); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; virtual void writeCOutput(ostream &output, const string &basename); - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class StdPriorStatement : public BasicPriorStatement @@ -791,7 +767,6 @@ public: const SymbolTable &symbol_table_arg); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; virtual void writeCOutput(ostream &output, const string &basename); - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class CorrPriorStatement : public BasicPriorStatement @@ -810,7 +785,6 @@ public: virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; virtual void writeCOutput(ostream &output, const string &basename); - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class PriorEqualStatement : public Statement @@ -838,7 +812,6 @@ public: void get_base_name(const SymbolType symb_type, string &lhs_field) const; virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class BasicOptionsStatement : public Statement @@ -869,7 +842,6 @@ public: OptionsStatement(const string &name_arg, const string &subsample_name_arg, const OptionsList &options_list_arg); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; virtual void writeCOutput(ostream &output, const string &basename); - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class StdOptionsStatement : public BasicOptionsStatement @@ -883,7 +855,6 @@ public: const SymbolTable &symbol_table_arg); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; virtual void writeCOutput(ostream &output, const string &basename); - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class CorrOptionsStatement : public BasicOptionsStatement @@ -899,7 +870,6 @@ public: virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; virtual void writeCOutput(ostream &output, const string &basename); - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class OptionsEqualStatement : public Statement @@ -927,7 +897,6 @@ public: void get_base_name(const SymbolType symb_type, string &lhs_field) const; virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class ModelDiagnosticsStatement : public Statement @@ -944,7 +913,6 @@ private: public: Smoother2histvalStatement(const OptionsList &options_list_arg); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; #endif diff --git a/DataTree.cc b/DataTree.cc index acbae348..3f90a44f 100644 --- a/DataTree.cc +++ b/DataTree.cc @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2015 Dynare Team + * Copyright (C) 2003-2014 Dynare Team * * This file is part of Dynare. * @@ -50,31 +50,6 @@ DataTree::~DataTree() delete *it; } -void -DataTree::reindex(SymbolTable &orig_symbol_table) -{ - variable_node_map.clear(); - unary_op_node_map.clear(); - binary_op_node_map.clear(); - trinary_op_node_map.clear(); - external_function_node_map.clear(); - first_deriv_external_function_node_map.clear(); - second_deriv_external_function_node_map.clear(); - - reindexLocalVars(orig_symbol_table); -} - -void -DataTree::reindexLocalVars(SymbolTable &orig_symbol_table) -{ - map orig_local_variables_table = local_variables_table; - local_variables_table.clear(); - for (map::const_iterator it = orig_local_variables_table.begin(); - it != orig_local_variables_table.end(); it++) - AddLocalVariable(symbol_table.getID(orig_symbol_table.getName(it->first)), - it->second->cloneDynamicReindex(*this, orig_symbol_table)); -} - expr_t DataTree::AddNonNegativeConstant(const string &value) { diff --git a/DataTree.hh b/DataTree.hh index b7cd2565..d7c53645 100644 --- a/DataTree.hh +++ b/DataTree.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2015 Dynare Team + * Copyright (C) 2003-2014 Dynare Team * * This file is part of Dynare. * @@ -233,13 +233,10 @@ public: //! Returns the minimum lag (as a negative number) of the given symbol in the whole data tree (and not only in the equations !!) /*! Returns 0 if the symbol is not used */ int minLagForSymbol(int symb_id) const; - inline SymbolTable *getSymbolTable() const { return &symbol_table; }; //! Write the Header for getPowerDeriv when use_dll is used void writePowerDerivCHeader(ostream &output) const; //! Write getPowerDeriv void writePowerDeriv(ostream &output, bool use_dll) const; - void reindex(SymbolTable &orig_symbol_table); - void reindexLocalVars(SymbolTable &orig_symbol_table); //! Thrown when trying to access an unknown variable by deriv_id class UnknownDerivIDException { diff --git a/DynamicModel.cc b/DynamicModel.cc index a43a599b..339cbe97 100644 --- a/DynamicModel.cc +++ b/DynamicModel.cc @@ -4202,23 +4202,6 @@ DynamicModel::addStaticOnlyEquation(expr_t eq, int lineno) static_only_equations_lineno.push_back(lineno); } -void -DynamicModel::reindex(SymbolTable &orig_symbol_table) -{ - ModelTree::reindex(orig_symbol_table); - reindexStaticOnlyEquations(orig_symbol_table); -} - -void -DynamicModel::reindexStaticOnlyEquations(SymbolTable &orig_symbol_table) -{ - vectoreqbak = static_only_equations; - static_only_equations.clear(); - for (size_t i = 0; i < eqbak.size(); i++) - addStaticOnlyEquation(eqbak[i]->cloneDynamicReindex(*this, orig_symbol_table), - static_only_equations_lineno[i]); -} - size_t DynamicModel::staticOnlyEquationsNbr() const { diff --git a/DynamicModel.hh b/DynamicModel.hh index 7adda7fd..d96a7d50 100644 --- a/DynamicModel.hh +++ b/DynamicModel.hh @@ -244,15 +244,9 @@ public: //! Adds an equation marked as [static] void addStaticOnlyEquation(expr_t eq, int lineno); - //! reindex Dynamic Model after removal of extra exogenous - void reindex(SymbolTable &orig_symbol_table); - - //! reindex equations marked as [static] - void reindexStaticOnlyEquations(SymbolTable &orig_symbol_table); - //! Returns number of static only equations size_t staticOnlyEquationsNbr() const; - + //! Returns number of dynamic only equations size_t dynamicOnlyEquationsNbr() const; diff --git a/ExprNode.cc b/ExprNode.cc index c1619806..b9c44055 100644 --- a/ExprNode.cc +++ b/ExprNode.cc @@ -360,12 +360,6 @@ NumConstNode::cloneDynamic(DataTree &dynamic_datatree) const return dynamic_datatree.AddNonNegativeConstant(datatree.num_constants.get(id)); } -expr_t -NumConstNode::cloneDynamicReindex(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) const -{ - return dynamic_datatree.AddNonNegativeConstant(datatree.num_constants.get(id)); -} - int NumConstNode::maxEndoLead() const { @@ -1006,12 +1000,6 @@ VariableNode::cloneDynamic(DataTree &dynamic_datatree) const return dynamic_datatree.AddVariable(symb_id, lag); } -expr_t -VariableNode::cloneDynamicReindex(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) const -{ - return dynamic_datatree.AddVariable(dynamic_datatree.symbol_table.getID(orig_symbol_table.getName(symb_id)), lag); -} - int VariableNode::maxEndoLead() const { @@ -2264,13 +2252,6 @@ UnaryOpNode::cloneDynamic(DataTree &dynamic_datatree) const return buildSimilarUnaryOpNode(substarg, dynamic_datatree); } -expr_t -UnaryOpNode::cloneDynamicReindex(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) const -{ - expr_t substarg = arg->cloneDynamicReindex(dynamic_datatree, orig_symbol_table); - return buildSimilarUnaryOpNode(substarg, dynamic_datatree); -} - int UnaryOpNode::maxEndoLead() const { @@ -3496,14 +3477,6 @@ BinaryOpNode::cloneDynamic(DataTree &dynamic_datatree) const return buildSimilarBinaryOpNode(substarg1, substarg2, dynamic_datatree); } -expr_t -BinaryOpNode::cloneDynamicReindex(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) const -{ - expr_t substarg1 = arg1->cloneDynamicReindex(dynamic_datatree, orig_symbol_table); - expr_t substarg2 = arg2->cloneDynamicReindex(dynamic_datatree, orig_symbol_table); - return buildSimilarBinaryOpNode(substarg1, substarg2, dynamic_datatree); -} - int BinaryOpNode::maxEndoLead() const { @@ -4180,15 +4153,6 @@ TrinaryOpNode::cloneDynamic(DataTree &dynamic_datatree) const return buildSimilarTrinaryOpNode(substarg1, substarg2, substarg3, dynamic_datatree); } -expr_t -TrinaryOpNode::cloneDynamicReindex(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) const -{ - expr_t substarg1 = arg1->cloneDynamicReindex(dynamic_datatree, orig_symbol_table); - expr_t substarg2 = arg2->cloneDynamicReindex(dynamic_datatree, orig_symbol_table); - expr_t substarg3 = arg3->cloneDynamicReindex(dynamic_datatree, orig_symbol_table); - return buildSimilarTrinaryOpNode(substarg1, substarg2, substarg3, dynamic_datatree); -} - int TrinaryOpNode::maxEndoLead() const { @@ -4961,17 +4925,6 @@ ExternalFunctionNode::cloneDynamic(DataTree &dynamic_datatree) const return dynamic_datatree.AddExternalFunction(symb_id, dynamic_arguments); } -expr_t -ExternalFunctionNode::cloneDynamicReindex(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) const -{ - vector dynamic_arguments; - for (vector::const_iterator it = arguments.begin(); - it != arguments.end(); it++) - dynamic_arguments.push_back((*it)->cloneDynamicReindex(dynamic_datatree, orig_symbol_table)); - return dynamic_datatree.AddExternalFunction(dynamic_datatree.symbol_table.getID(orig_symbol_table.getName(symb_id)), - dynamic_arguments); -} - expr_t ExternalFunctionNode::buildSimilarExternalFunctionNode(vector &alt_args, DataTree &alt_datatree) const { @@ -5267,18 +5220,6 @@ FirstDerivExternalFunctionNode::cloneDynamic(DataTree &dynamic_datatree) const inputIndex); } -expr_t -FirstDerivExternalFunctionNode::cloneDynamicReindex(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) const -{ - vector dynamic_arguments; - for (vector::const_iterator it = arguments.begin(); - it != arguments.end(); it++) - dynamic_arguments.push_back((*it)->cloneDynamicReindex(dynamic_datatree, orig_symbol_table)); - return dynamic_datatree.AddFirstDerivExternalFunction(dynamic_datatree.symbol_table.getID(orig_symbol_table.getName(symb_id)), - dynamic_arguments, - inputIndex); -} - expr_t FirstDerivExternalFunctionNode::buildSimilarExternalFunctionNode(vector &alt_args, DataTree &alt_datatree) const { @@ -5514,18 +5455,6 @@ SecondDerivExternalFunctionNode::cloneDynamic(DataTree &dynamic_datatree) const inputIndex1, inputIndex2); } -expr_t -SecondDerivExternalFunctionNode::cloneDynamicReindex(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) const -{ - vector dynamic_arguments; - for (vector::const_iterator it = arguments.begin(); - it != arguments.end(); it++) - dynamic_arguments.push_back((*it)->cloneDynamicReindex(dynamic_datatree, orig_symbol_table)); - return dynamic_datatree.AddSecondDerivExternalFunction(dynamic_datatree.symbol_table.getID(orig_symbol_table.getName(symb_id)), - dynamic_arguments, - inputIndex1, inputIndex2); -} - expr_t SecondDerivExternalFunctionNode::buildSimilarExternalFunctionNode(vector &alt_args, DataTree &alt_datatree) const { diff --git a/ExprNode.hh b/ExprNode.hh index bef4a415..0500ff6d 100644 --- a/ExprNode.hh +++ b/ExprNode.hh @@ -410,9 +410,6 @@ public: //! Add ExprNodes to the provided datatree virtual expr_t cloneDynamic(DataTree &dynamic_datatree) const = 0; - //! Add ExprNodes to the provided datatree, changing the symbol id from those provided in orig_symbol_table - virtual expr_t cloneDynamicReindex(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) const = 0; - //! Move a trend variable with lag/lead to time t by dividing/multiplying by its growth factor virtual expr_t removeTrendLeadLag(map trend_symbols_map) const = 0; @@ -474,7 +471,6 @@ public: virtual expr_t replaceTrendVar() const; virtual expr_t detrend(int symb_id, bool log_trend, expr_t trend) const; virtual expr_t cloneDynamic(DataTree &dynamic_datatree) const; - virtual expr_t cloneDynamicReindex(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) const; virtual expr_t removeTrendLeadLag(map trend_symbols_map) const; virtual bool isInStaticForm() const; }; @@ -538,7 +534,6 @@ public: virtual expr_t replaceTrendVar() const; virtual expr_t detrend(int symb_id, bool log_trend, expr_t trend) const; virtual expr_t cloneDynamic(DataTree &dynamic_datatree) const; - virtual expr_t cloneDynamicReindex(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) const; virtual expr_t removeTrendLeadLag(map trend_symbols_map) const; virtual bool isInStaticForm() const; }; @@ -617,7 +612,6 @@ public: virtual expr_t replaceTrendVar() const; virtual expr_t detrend(int symb_id, bool log_trend, expr_t trend) const; virtual expr_t cloneDynamic(DataTree &dynamic_datatree) const; - virtual expr_t cloneDynamicReindex(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) const; virtual expr_t removeTrendLeadLag(map trend_symbols_map) const; virtual bool isInStaticForm() const; }; @@ -709,7 +703,6 @@ public: virtual expr_t replaceTrendVar() const; virtual expr_t detrend(int symb_id, bool log_trend, expr_t trend) const; virtual expr_t cloneDynamic(DataTree &dynamic_datatree) const; - virtual expr_t cloneDynamicReindex(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) const; virtual expr_t removeTrendLeadLag(map trend_symbols_map) const; //! Function to write out the oPowerNode in expr_t terms as opposed to writing out the function itself expr_t unpackPowerDeriv() const; @@ -781,7 +774,6 @@ public: virtual expr_t replaceTrendVar() const; virtual expr_t detrend(int symb_id, bool log_trend, expr_t trend) const; virtual expr_t cloneDynamic(DataTree &dynamic_datatree) const; - virtual expr_t cloneDynamicReindex(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) const; virtual expr_t removeTrendLeadLag(map trend_symbols_map) const; virtual bool isInStaticForm() const; }; @@ -858,7 +850,6 @@ public: virtual expr_t replaceTrendVar() const; virtual expr_t detrend(int symb_id, bool log_trend, expr_t trend) const; virtual expr_t cloneDynamic(DataTree &dynamic_datatree) const = 0; - virtual expr_t cloneDynamicReindex(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) const = 0; virtual expr_t removeTrendLeadLag(map trend_symbols_map) const; virtual bool isInStaticForm() const; }; @@ -889,7 +880,6 @@ public: virtual expr_t toStatic(DataTree &static_datatree) const; virtual expr_t buildSimilarExternalFunctionNode(vector &alt_args, DataTree &alt_datatree) const; virtual expr_t cloneDynamic(DataTree &dynamic_datatree) const; - virtual expr_t cloneDynamicReindex(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) const; }; class FirstDerivExternalFunctionNode : public AbstractExternalFunctionNode @@ -924,7 +914,6 @@ public: virtual expr_t toStatic(DataTree &static_datatree) const; virtual expr_t buildSimilarExternalFunctionNode(vector &alt_args, DataTree &alt_datatree) const; virtual expr_t cloneDynamic(DataTree &dynamic_datatree) const; - virtual expr_t cloneDynamicReindex(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) const; }; class SecondDerivExternalFunctionNode : public AbstractExternalFunctionNode @@ -961,7 +950,6 @@ public: virtual expr_t toStatic(DataTree &static_datatree) const; virtual expr_t buildSimilarExternalFunctionNode(vector &alt_args, DataTree &alt_datatree) const; virtual expr_t cloneDynamic(DataTree &dynamic_datatree) const; - virtual expr_t cloneDynamicReindex(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) const; }; #endif diff --git a/ExternalFunctionsTable.cc b/ExternalFunctionsTable.cc index 2fa1523d..8554d830 100644 --- a/ExternalFunctionsTable.cc +++ b/ExternalFunctionsTable.cc @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2015 Dynare Team + * Copyright (C) 2010-2011 Dynare Team * * This file is part of Dynare. * @@ -24,6 +24,7 @@ #include #include "ExternalFunctionsTable.hh" +#include "SymbolTable.hh" ExternalFunctionsTable::ExternalFunctionsTable() { @@ -114,44 +115,3 @@ ExternalFunctionsTable::addExternalFunction(int symb_id, const external_function externalFunctionTable[symb_id] = external_function_options_chng; } - -void -ExternalFunctionsTable::reindex(SymbolTable &new_symbol_table, SymbolTable &orig_symbol_table) -{ - external_function_table_type orig_externalFunctionTable = externalFunctionTable; - externalFunctionTable.clear(); - for (external_function_table_type::const_iterator it = orig_externalFunctionTable.begin(); - it != orig_externalFunctionTable.end(); it++) - try - { - external_function_options new_external_function_options; - if (it->second.firstDerivSymbID == eExtFunNotSet || - it->second.firstDerivSymbID == eExtFunSetButNoNameProvided) - new_external_function_options.firstDerivSymbID = it->second.firstDerivSymbID; - else - new_external_function_options.firstDerivSymbID = - new_symbol_table.getID(orig_symbol_table.getName(it->second.firstDerivSymbID)); - - if (it->second.secondDerivSymbID == eExtFunNotSet || - it->second.secondDerivSymbID == eExtFunSetButNoNameProvided) - new_external_function_options.secondDerivSymbID = it->second.secondDerivSymbID; - else - new_external_function_options.secondDerivSymbID = - new_symbol_table.getID(orig_symbol_table.getName(it->second.secondDerivSymbID)); - new_external_function_options.nargs = it->second.nargs; - bool new_track_nargs = true; - if (it->second.nargs == eExtFunNotSet) - { - new_track_nargs = false; - new_external_function_options.nargs = eExtFunSetDefaultNargs; - } - addExternalFunction(new_symbol_table.getID(orig_symbol_table.getName(it->first)), - new_external_function_options, - new_track_nargs); - } - catch (...) - { - cerr << "Error: problem encountered when reindexing external functions table." << endl; - exit(EXIT_FAILURE); - } -} diff --git a/ExternalFunctionsTable.hh b/ExternalFunctionsTable.hh index b5218bea..aa4b02cd 100644 --- a/ExternalFunctionsTable.hh +++ b/ExternalFunctionsTable.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2015 Dynare Team + * Copyright (C) 2010-2011 Dynare Team * * This file is part of Dynare. * @@ -27,8 +27,6 @@ using namespace std; #include #include -#include "SymbolTable.hh" - enum ExternalFunctionSetOrNot { eExtFunSetButNoNameProvided = -2, //! Signifies that the derivative is obtained from the top-level function @@ -78,8 +76,6 @@ public: inline int getSecondDerivSymbID(int symb_id) const throw (UnknownExternalFunctionSymbolIDException); //! Returns the total number of unique external functions declared or used in the .mod file inline int get_total_number_of_unique_model_block_external_functions() const; - //! Reindex external function table (after removal of extra exo) - void reindex(SymbolTable &new_symbol_table, SymbolTable &orig_symbol_table); }; inline bool diff --git a/ModFile.cc b/ModFile.cc index 862fd4ca..285532a5 100644 --- a/ModFile.cc +++ b/ModFile.cc @@ -300,28 +300,13 @@ ModFile::checkPass() if (++it != unusedExo.end()) warnings << ", "; } - warnings << ") are declared but not used in the model. We have removed them and will attempt to continue..." << endl; + warnings << ") are declared but not used in the model. This may lead to crashes or unexpected behaviour." << endl; } } void ModFile::transformPass(bool nostrict) { - // Remove unused exogenous from symbol table and update dynamic_model - set unusedExo = dynamic_model.findUnusedExogenous(); - if (unusedExo.size() > 0) - { - SymbolTable orig_symbol_table = symbol_table; - symbol_table.rmExo(unusedExo); - dynamic_model.reindex(orig_symbol_table); - external_functions_table.reindex(symbol_table, orig_symbol_table); - - vector orig_statements = statements; - statements.clear(); - for (vector::iterator it = orig_statements.begin(); it != orig_statements.end(); it++) - addStatement((*it)->cloneAndReindexSymbIds(dynamic_model, orig_symbol_table)); - } - // Save the original model (must be done before any model transformations by preprocessor) dynamic_model.cloneDynamic(original_model); diff --git a/ModelTree.cc b/ModelTree.cc index 9d187b05..688d4f29 100644 --- a/ModelTree.cc +++ b/ModelTree.cc @@ -1413,64 +1413,6 @@ ModelTree::addAuxEquation(expr_t eq) aux_equations.push_back(beq); } -void -ModelTree::reindex(SymbolTable &orig_symbol_table) -{ - DataTree::reindex(orig_symbol_table); - reindexEquations(orig_symbol_table); - reindexTrendSymbolsMap(orig_symbol_table); - reindexNonstationarySymbolsMap(orig_symbol_table); -} - -void -ModelTree::reindexEquations(SymbolTable &orig_symbol_table) -{ - vectoreqbak = equations; - equations.clear(); - for (size_t i = 0; i < eqbak.size(); i++) - addEquation(eqbak[i]->cloneDynamicReindex(*this, orig_symbol_table), equations_lineno[i]); -} - -void -ModelTree::reindexTrendSymbolsMap(SymbolTable &orig_symbol_table) -{ - map orig_trend_symbols_map = trend_symbols_map; - trend_symbols_map.clear(); - for (map::const_iterator it = orig_trend_symbols_map.begin(); - it != orig_trend_symbols_map.end(); it++) - try - { - vector symb_id (1, symbol_table.getID(orig_symbol_table.getName(it->first))); - addTrendVariables(symb_id, it->second->cloneDynamicReindex(*this, orig_symbol_table)); - } - catch(...) - { - cerr << "Error: unused exo in trend symbols." << endl; - exit(EXIT_FAILURE); - } -} - -void -ModelTree::reindexNonstationarySymbolsMap(SymbolTable &orig_symbol_table) -{ - nonstationary_symbols_map_t orig_nonstationary_symbols_map = nonstationary_symbols_map; - nonstationary_symbols_map.clear(); - for (nonstationary_symbols_map_t::const_iterator it = orig_nonstationary_symbols_map.begin(); - it != orig_nonstationary_symbols_map.end(); it++) - try - { - vector symb_id (1, symbol_table.getID(orig_symbol_table.getName(it->first))); - addNonstationaryVariables(symb_id, - it->second.first, - it->second.second->cloneDynamicReindex(*this, orig_symbol_table)); - } - catch(...) - { - cerr << "Error: unused exo in nonstationary symbols." << endl; - exit(EXIT_FAILURE); - } -} - void ModelTree::addTrendVariables(vector trend_vars, expr_t growth_factor) throw (TrendException) { diff --git a/ModelTree.hh b/ModelTree.hh index b86376b2..4d161daf 100644 --- a/ModelTree.hh +++ b/ModelTree.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2015 Dynare Team + * Copyright (C) 2003-2014 Dynare Team * * This file is part of Dynare. * @@ -303,13 +303,6 @@ public: void addEquation(expr_t eq, int lineno, vector > &eq_tags); //! Declare a node as an auxiliary equation of the model, adding it at the end of the list of auxiliary equations void addAuxEquation(expr_t eq); - void reindex(SymbolTable &orig_symbol_table); - //! reindex equations after change in symbol_table - void reindexEquations(SymbolTable &orig_symbol_table); - //! reindex trend_symbol_map after change in symbol_table - void reindexTrendSymbolsMap(SymbolTable &orig_symbol_table); - //! reindex nonstationary_symbol_map after change in symbol_table - void reindexNonstationarySymbolsMap(SymbolTable &orig_symbol_table); //! Returns the number of equations in the model int equation_number() const; //! Adds a trend variable with its growth factor diff --git a/NumericalInitialization.cc b/NumericalInitialization.cc index a86cedfc..85055905 100644 --- a/NumericalInitialization.cc +++ b/NumericalInitialization.cc @@ -74,32 +74,6 @@ InitParamStatement::fillEvalContext(eval_context_t &eval_context) const } } -Statement * -InitParamStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - string error; - try - { - return new InitParamStatement(symbol_table.getID(orig_symbol_table.getName(symb_id)), - param_value->cloneDynamicReindex(dynamic_datatree, orig_symbol_table), - symbol_table); - } - catch (SymbolTable::UnknownSymbolIDException &e) - { - error = orig_symbol_table.getName(e.id); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - error = e.name; - } - - cerr << endl - << "ERROR: The following vars were used in the init param statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl - << error << endl; - exit(EXIT_FAILURE); -} - InitOrEndValStatement::InitOrEndValStatement(const init_values_t &init_values_arg, const SymbolTable &symbol_table_arg, const bool &all_values_required_arg) : @@ -235,35 +209,6 @@ InitValStatement::writeOutputPostInit(ostream &output) const <<"end;" << endl; } -Statement * -InitValStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - vector errors; - init_values_t new_init_values; - for (init_values_t::const_iterator it=init_values.begin(); - it != init_values.end(); it++) - try - { - new_init_values.push_back(make_pair(symbol_table.getID(orig_symbol_table.getName(it->first)), - it->second->cloneDynamicReindex(dynamic_datatree, orig_symbol_table))); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - - if (!errors.empty()) - { - cerr << endl - << "ERROR: The following vars were used in the initval statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl; - for (vector::const_iterator it = errors.begin(); it != errors.end(); it++) - cerr << *it << endl; - exit(EXIT_FAILURE); - } - return new InitValStatement(new_init_values, symbol_table, all_values_required); -} - EndValStatement::EndValStatement(const init_values_t &init_values_arg, const SymbolTable &symbol_table_arg, const bool &all_values_required_arg) : @@ -310,36 +255,6 @@ EndValStatement::writeOutput(ostream &output, const string &basename, bool minim writeInitValues(output); } -Statement * -EndValStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - vector errors; - init_values_t new_init_values; - - for (init_values_t::const_iterator it=init_values.begin(); - it != init_values.end(); it++) - try - { - new_init_values.push_back(make_pair(symbol_table.getID(orig_symbol_table.getName(it->first)), - it->second->cloneDynamicReindex(dynamic_datatree, orig_symbol_table))); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - - if (!errors.empty()) - { - cerr << endl - << "ERROR: The following vars were used in the endval statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl; - for (vector::const_iterator it = errors.begin(); it != errors.end(); it++) - cerr << *it << endl; - exit(EXIT_FAILURE); - } - return new EndValStatement(new_init_values, symbol_table, all_values_required); -} - HistValStatement::HistValStatement(const hist_values_t &hist_values_arg, const SymbolTable &symbol_table_arg) : hist_values(hist_values_arg), @@ -406,36 +321,6 @@ HistValStatement::writeOutput(ostream &output, const string &basename, bool mini } } -Statement * -HistValStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - vector errors; - hist_values_t new_hist_values; - for (hist_values_t::const_iterator it=hist_values.begin(); - it != hist_values.end(); it++) - try - { - new_hist_values[make_pair(symbol_table.getID(orig_symbol_table.getName(it->first.first)), - it->first.second)] = - it->second->cloneDynamicReindex(dynamic_datatree, orig_symbol_table); - } - catch (SymbolTable::UnknownSymbolNameException &e) - { - errors.push_back(e.name); - } - - if (!errors.empty()) - { - cerr << endl - << "ERROR: The following vars were used in the histval statement(s) but were not declared." << endl - << " This likely means that you declared them as varexo and that they're not in the model" << endl; - for (vector::const_iterator it = errors.begin(); it != errors.end(); it++) - cerr << *it << endl; - exit(EXIT_FAILURE); - } - return new HistValStatement(new_hist_values, symbol_table); -} - InitvalFileStatement::InitvalFileStatement(const string &filename_arg) : filename(filename_arg) { @@ -509,10 +394,9 @@ SaveParamsAndSteadyStateStatement::writeOutput(ostream &output, const string &ba output << "save_params_and_steady_state('" << filename << "');" << endl; } -LoadParamsAndSteadyStateStatement::LoadParamsAndSteadyStateStatement(const string &filename_arg, +LoadParamsAndSteadyStateStatement::LoadParamsAndSteadyStateStatement(const string &filename, const SymbolTable &symbol_table_arg, WarningConsolidation &warnings) : - filename(filename_arg), symbol_table(symbol_table_arg) { cout << "Reading " << filename << "." << endl; diff --git a/NumericalInitialization.hh b/NumericalInitialization.hh index a8573f2e..142838f7 100644 --- a/NumericalInitialization.hh +++ b/NumericalInitialization.hh @@ -44,7 +44,6 @@ public: virtual void writeCOutput(ostream &output, const string &basename); //! Fill eval context with parameter value void fillEvalContext(eval_context_t &eval_context) const; - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class InitOrEndValStatement : public Statement @@ -81,7 +80,6 @@ public: virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; //! Writes initializations for oo_.exo_simul and oo_.exo_det_simul void writeOutputPostInit(ostream &output) const; - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class EndValStatement : public InitOrEndValStatement @@ -93,7 +91,6 @@ public: //! Workaround for trac ticket #35 virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class HistValStatement : public Statement @@ -114,7 +111,6 @@ public: //! Workaround for trac ticket #157 virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class InitvalFileStatement : public Statement @@ -162,7 +158,6 @@ public: class LoadParamsAndSteadyStateStatement : public Statement { private: - const string filename; const SymbolTable &symbol_table; //! Content of the file /*! Maps symbol ID to numeric value (stored as string) */ diff --git a/Shocks.cc b/Shocks.cc index 81a9cdde..b2ebd79e 100644 --- a/Shocks.cc +++ b/Shocks.cc @@ -67,31 +67,6 @@ AbstractShocksStatement::writeDetShocks(ostream &output) const output << "M_.exo_det_length = " << exo_det_length << ";\n"; } -AbstractShocksStatement::det_shocks_t -AbstractShocksStatement::reindexDetShocksSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - det_shocks_t new_det_shocks; - SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); - for (det_shocks_t::const_iterator it=det_shocks.begin(); it!=det_shocks.end(); it++) - try - { - vector det_shock_vec; - for (size_t i = 0; i < it->second.size(); i++) - { - DetShockElement dse; - dse.period1 = it->second[i].period1; - dse.period2 = it->second[i].period2; - dse.value = it->second[i].value->cloneDynamicReindex(dynamic_datatree, orig_symbol_table); - det_shock_vec.push_back(dse); - } - new_det_shocks[new_symbol_table->getID(orig_symbol_table.getName(it->first))] = det_shock_vec; - } - catch (...) - { - } - return new_det_shocks; -} - ShocksStatement::ShocksStatement(bool overwrite_arg, const det_shocks_t &det_shocks_arg, const var_and_std_shocks_t &var_shocks_arg, @@ -357,69 +332,6 @@ ShocksStatement::has_calibrated_measurement_errors() const return false; } -Statement * -ShocksStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - var_and_std_shocks_t new_var_shocks, new_std_shocks; - covar_and_corr_shocks_t new_covar_shocks, new_corr_shocks; - SymbolTable *new_symbol_table = dynamic_datatree.getSymbolTable(); - - for (var_and_std_shocks_t::const_iterator it = var_shocks.begin(); - it != var_shocks.end(); it++) - try - { - new_var_shocks[new_symbol_table->getID(orig_symbol_table.getName(it->first))] = - it->second->cloneDynamicReindex(dynamic_datatree, orig_symbol_table); - } - catch (...) - { - } - - for (var_and_std_shocks_t::const_iterator it = std_shocks.begin(); - it != std_shocks.end(); it++) - try - { - new_std_shocks[new_symbol_table->getID(orig_symbol_table.getName(it->first))] = - it->second->cloneDynamicReindex(dynamic_datatree, orig_symbol_table); - } - catch (...) - { - } - - for (covar_and_corr_shocks_t::const_iterator it = covar_shocks.begin(); - it != covar_shocks.end(); it++) - try - { - new_covar_shocks[make_pair(new_symbol_table->getID(orig_symbol_table.getName(it->first.first)), - new_symbol_table->getID(orig_symbol_table.getName(it->first.second)))] = - it->second->cloneDynamicReindex(dynamic_datatree, orig_symbol_table); - } - catch (...) - { - } - - for (covar_and_corr_shocks_t::const_iterator it = corr_shocks.begin(); - it != corr_shocks.end(); it++) - try - { - new_corr_shocks[make_pair(new_symbol_table->getID(orig_symbol_table.getName(it->first.first)), - new_symbol_table->getID(orig_symbol_table.getName(it->first.second)))] = - it->second->cloneDynamicReindex(dynamic_datatree, orig_symbol_table); - } - catch (...) - { - } - - return new ShocksStatement(overwrite, - reindexDetShocksSymbIds(dynamic_datatree, orig_symbol_table), - new_var_shocks, - new_std_shocks, - new_covar_shocks, - new_corr_shocks, - *(dynamic_datatree.getSymbolTable())); -} - - MShocksStatement::MShocksStatement(bool overwrite_arg, const det_shocks_t &det_shocks_arg, const SymbolTable &symbol_table_arg) : @@ -440,14 +352,6 @@ MShocksStatement::writeOutput(ostream &output, const string &basename, bool mini writeDetShocks(output); } -Statement * -MShocksStatement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - return new MShocksStatement(overwrite, - reindexDetShocksSymbIds(dynamic_datatree, orig_symbol_table), - *(dynamic_datatree.getSymbolTable())); -} - ConditionalForecastPathsStatement::ConditionalForecastPathsStatement(const AbstractShocksStatement::det_shocks_t &paths_arg) : paths(paths_arg), path_length(-1) diff --git a/Shocks.hh b/Shocks.hh index dc11dbc3..155ef967 100644 --- a/Shocks.hh +++ b/Shocks.hh @@ -50,7 +50,7 @@ protected: const det_shocks_t det_shocks; const SymbolTable &symbol_table; void writeDetShocks(ostream &output) const; - det_shocks_t reindexDetShocksSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); + AbstractShocksStatement(bool mshocks_arg, bool overwrite_arg, const det_shocks_t &det_shocks_arg, const SymbolTable &symbol_table_arg); @@ -79,7 +79,6 @@ public: const SymbolTable &symbol_table_arg); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings); - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class MShocksStatement : public AbstractShocksStatement @@ -89,7 +88,6 @@ public: const det_shocks_t &det_shocks_arg, const SymbolTable &symbol_table_arg); virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const; - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class ConditionalForecastPathsStatement : public Statement diff --git a/Statement.cc b/Statement.cc index a061a6b6..5da10f1f 100644 --- a/Statement.cc +++ b/Statement.cc @@ -74,12 +74,6 @@ Statement::computingPass() { } -Statement * -Statement::cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table) -{ - return this; -} - NativeStatement::NativeStatement(const string &native_statement_arg) : native_statement(native_statement_arg) { diff --git a/Statement.hh b/Statement.hh index 4c53f9fc..6fe1e7aa 100644 --- a/Statement.hh +++ b/Statement.hh @@ -27,8 +27,6 @@ #include "SymbolList.hh" #include "WarningConsolidation.hh" -#include "SymbolTable.hh" -#include "DataTree.hh" class ModFileStructure { @@ -140,11 +138,6 @@ public: */ virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const = 0; virtual void writeCOutput(ostream &output, const string &basename); - //! clone a statement while updating all symbol ids that are contained within it. - /* Symbol id's are updated from the symbol table contained in dynamic_datatree - The original symbol table is contained in orig_symbol_table - */ - virtual Statement *cloneAndReindexSymbIds(DataTree &dynamic_datatree, SymbolTable &orig_symbol_table); }; class NativeStatement : public Statement diff --git a/SymbolTable.cc b/SymbolTable.cc index dc45f5d1..2c1a699c 100644 --- a/SymbolTable.cc +++ b/SymbolTable.cc @@ -21,7 +21,6 @@ #include #include #include -#include #include "SymbolTable.hh" @@ -483,52 +482,6 @@ SymbolTable::addLeadAuxiliaryVarInternal(bool endo, int index) throw (FrozenExce return symb_id; } -void -SymbolTable::rmExo(set &unused) throw (FrozenException) -{ - if (frozen) - throw FrozenException(); - - list idxs; - for (set::const_iterator it = unused.begin(); it != unused.end(); it++) - idxs.push_back(getID(getName(*it))); - - idxs.sort(); - idxs.reverse(); - vector orig_name_table = name_table; - for (list::const_iterator it = idxs.begin(); it != idxs.end(); it++) - { - type_table.erase(type_table.begin() + *it); - name_table.erase(name_table.begin() + *it); - tex_name_table.erase(tex_name_table.begin() + *it); - long_name_table.erase(long_name_table.begin() + *it); - } - - symbol_table.clear(); - size = 0; - for (vector::const_iterator it=name_table.begin(); - it != name_table.end(); it++) - symbol_table[*it] = size++; - assert((size_t)size == symbol_table.size()); - - set orig_predetermined_variables = predetermined_variables; - predetermined_variables.clear(); - for (set::const_iterator it=orig_predetermined_variables.begin(); - it != orig_predetermined_variables.end(); it++) - if (orig_name_table[*it] != getName(*it)) - markPredetermined(getID(orig_name_table[*it])); - else - markPredetermined(*it); - - vector orig_varobs = varobs; - varobs.clear(); - for (vector::const_iterator it=orig_varobs.begin(); it != orig_varobs.end(); it++) - if (orig_name_table[*it] != getName(*it)) - addObservedVariable(getID(orig_name_table[*it])); - else - addObservedVariable(*it); -} - int SymbolTable::addLagAuxiliaryVarInternal(bool endo, int orig_symb_id, int orig_lead_lag) throw (FrozenException) { diff --git a/SymbolTable.hh b/SymbolTable.hh index d6d29362..4be960a1 100644 --- a/SymbolTable.hh +++ b/SymbolTable.hh @@ -310,8 +310,6 @@ public: bool isAuxiliaryVariable(int symb_id) const; //! Get list of endogenous variables without aux vars set getOrigEndogenous() const; - //! Remove exogenous variables contained in the set - void rmExo(set &unused) throw (FrozenException); }; inline bool