Add a warning when some exogenous are not used in the model

time-shift
Sébastien Villemot 2013-11-29 16:03:15 +01:00
parent ed2f6d62c1
commit 839ae22b1f
3 changed files with 30 additions and 0 deletions

View File

@ -3585,6 +3585,19 @@ DynamicModel::findUnusedEndogenous()
return unusedEndo;
}
set<int>
DynamicModel::findUnusedExogenous()
{
set<int> usedExo, unusedExo;
for (int i = 0; i < (int) equations.size(); i++)
equations[i]->collectVariables(eExogenous, usedExo);
set<int> allExo = symbol_table.getExogenous();
set_difference(allExo.begin(), allExo.end(),
usedExo.begin(), usedExo.end(),
inserter(unusedExo, unusedExo.begin()));
return unusedExo;
}
void
DynamicModel::computeDerivIDs()
{

View File

@ -224,6 +224,8 @@ public:
//! Find endogenous variables not used in model
set<int> findUnusedEndogenous();
//! Find exogenous variables not used in model
set<int> findUnusedExogenous();
//! Copies a dynamic model (only the equations)
/*! It assumes that the dynamic model given in argument has just been allocated */

View File

@ -286,6 +286,21 @@ ModFile::checkPass()
cerr << ") also appear in the expressions defining the variance/covariance matrix of shocks; this is not allowed." << endl;
exit(EXIT_FAILURE);
}
// Check if some exogenous is not used in the model block
set<int> unusedExo = dynamic_model.findUnusedExogenous();
if (unusedExo.size() > 1)
{
warnings << "WARNING: some exogenous (";
for (set<int>::const_iterator it = unusedExo.begin();
it != unusedExo.end(); )
{
warnings << symbol_table.getName(*it);
if (++it != unusedExo.end())
warnings << ", ";
}
warnings << ") are declared but not used in the model. This may lead to crashes or unexpected behaviour." << endl;
}
}
void