Fix check for unused endos in the presence of PAC model-consistent expectations

Since commit 64f55e4a5e, in the presence of PAC
model-consistent expectations, some endogenous variables are added to the
symbol table at the beginning of ModFile::transformPass(), while their defining
equations are added at a later point.

But commit 7c3f981eac has introduced a check that
verifies that all endogenous are used in equations. That check happens after
the above mentioned endogenous are created, but after their defining equations
are added. Hence it fails.

The fix consists in creating those endogenous after the check. Incidently, they
are no longer part of the saved original model, but this is a good thing.
issue#70
Sébastien Villemot 2019-09-25 12:00:40 +02:00
parent d3db73b7e4
commit f66e6a7f35
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
1 changed files with 14 additions and 11 deletions

View File

@ -397,21 +397,11 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const
DataTree:AddDiff()
*/
dynamic_model.simplifyEquations();
for (auto & statement : statements)
{
auto pms = dynamic_cast<PacModelStatement *>(statement.get());
if (pms != nullptr)
{
if (pms->growth != nullptr)
pac_growth.push_back(pms->growth);
if (pms->aux_model_name == "")
dynamic_model.declarePacModelConsistentExpectationEndogs(pms->name);
}
}
dynamic_model.substituteAdl();
dynamic_model.setLeadsLagsOrig();
original_model = dynamic_model;
// Check that all declared endogenous are used in equations
set<int> unusedEndogs = dynamic_model.findUnusedEndogenous();
bool unusedEndogsIsErr = !nostrict && !mod_file_struct.bvar_present && unusedEndogs.size();
for (int unusedEndog : unusedEndogs)
@ -427,6 +417,19 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const
if (unusedEndogsIsErr)
exit(EXIT_FAILURE);
// Declare endogenous used for PAC model-consistent expectations
for (auto & statement : statements)
{
auto pms = dynamic_cast<PacModelStatement *>(statement.get());
if (pms != nullptr)
{
if (pms->growth != nullptr)
pac_growth.push_back(pms->growth);
if (pms->aux_model_name == "")
dynamic_model.declarePacModelConsistentExpectationEndogs(pms->name);
}
}
// Get all equation tags associated with VARs and Trend Component Models
set<string> eqtags;
for (auto const & it : trend_component_model_table.getEqTags())