From 858a1b9b2a277765a116b9127cd6a3db08a11a61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org> Date: Mon, 24 Feb 2014 17:27:19 +0100 Subject: [PATCH] Add a warning if some endogenous is not present in steady_state_model block. Closes #556 --- preprocessor/SteadyStateModel.cc | 9 +++++++++ preprocessor/SymbolTable.cc | 22 +++++++++++++++++++++- preprocessor/SymbolTable.hh | 6 +++++- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/preprocessor/SteadyStateModel.cc b/preprocessor/SteadyStateModel.cc index fa39c8e50..9f1665275 100644 --- a/preprocessor/SteadyStateModel.cc +++ b/preprocessor/SteadyStateModel.cc @@ -93,6 +93,15 @@ SteadyStateModel::checkPass(bool ramsey_policy, WarningConsolidation &warnings) copy(symb_ids.begin(), symb_ids.end(), back_inserter(so_far_defined)); } + + set<int> orig_endogs = symbol_table.getOrigEndogenous(); + for (set<int>::const_iterator it = orig_endogs.begin(); + it != orig_endogs.end(); ++it) + { + if (find(so_far_defined.begin(), so_far_defined.end(), *it) + == so_far_defined.end()) + warnings << "WARNING: in the 'steady_state_model' block, variable '" << symbol_table.getName(*it) << "' is not assigned a value" << endl; + } } void diff --git a/preprocessor/SymbolTable.cc b/preprocessor/SymbolTable.cc index 21b406b80..97b984304 100644 --- a/preprocessor/SymbolTable.cc +++ b/preprocessor/SymbolTable.cc @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 Dynare Team + * Copyright (C) 2003-2014 Dynare Team * * This file is part of Dynare. * @@ -591,3 +591,23 @@ SymbolTable::getEndogenous() const endogs.insert(it->second); return endogs; } + +bool +SymbolTable::isAuxiliaryVariable(int symb_id) const +{ + for (int i = 0; i < aux_vars.size(); i++) + if (aux_vars[i].get_symb_id() == symb_id) + return true; + return false; +} + +set<int> +SymbolTable::getOrigEndogenous() const +{ + set <int> origendogs; + for (symbol_table_type::const_iterator it = symbol_table.begin(); + it != symbol_table.end(); it++) + if (getType(it->second) == eEndogenous && !isAuxiliaryVariable(it->second)) + origendogs.insert(it->second); + return origendogs; +} diff --git a/preprocessor/SymbolTable.hh b/preprocessor/SymbolTable.hh index c87160145..8e0903e5c 100644 --- a/preprocessor/SymbolTable.hh +++ b/preprocessor/SymbolTable.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 Dynare Team + * Copyright (C) 2003-2014 Dynare Team * * This file is part of Dynare. * @@ -297,6 +297,10 @@ public: set <int> getExogenous() const; //! Get list of endogenous variables set <int> getEndogenous() const; + //! Is a given symbol an auxiliary variable + bool isAuxiliaryVariable(int symb_id) const; + //! Get list of endogenous variables without aux vars + set <int> getOrigEndogenous() const; }; inline bool -- GitLab