Add a warning when some exogenous are not used in the model
parent
ed2f6d62c1
commit
839ae22b1f
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue