Fix check for unused endos in the presence of PAC model-consistent expectations
Since commitissue#7064f55e4a5e
, 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 commit7c3f981eac
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.
parent
d3db73b7e4
commit
f66e6a7f35
|
@ -397,21 +397,11 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const
|
||||||
DataTree:AddDiff()
|
DataTree:AddDiff()
|
||||||
*/
|
*/
|
||||||
dynamic_model.simplifyEquations();
|
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.substituteAdl();
|
||||||
dynamic_model.setLeadsLagsOrig();
|
dynamic_model.setLeadsLagsOrig();
|
||||||
original_model = dynamic_model;
|
original_model = dynamic_model;
|
||||||
|
|
||||||
|
// Check that all declared endogenous are used in equations
|
||||||
set<int> unusedEndogs = dynamic_model.findUnusedEndogenous();
|
set<int> unusedEndogs = dynamic_model.findUnusedEndogenous();
|
||||||
bool unusedEndogsIsErr = !nostrict && !mod_file_struct.bvar_present && unusedEndogs.size();
|
bool unusedEndogsIsErr = !nostrict && !mod_file_struct.bvar_present && unusedEndogs.size();
|
||||||
for (int unusedEndog : unusedEndogs)
|
for (int unusedEndog : unusedEndogs)
|
||||||
|
@ -427,6 +417,19 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const
|
||||||
if (unusedEndogsIsErr)
|
if (unusedEndogsIsErr)
|
||||||
exit(EXIT_FAILURE);
|
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
|
// Get all equation tags associated with VARs and Trend Component Models
|
||||||
set<string> eqtags;
|
set<string> eqtags;
|
||||||
for (auto const & it : trend_component_model_table.getEqTags())
|
for (auto const & it : trend_component_model_table.getEqTags())
|
||||||
|
|
Loading…
Reference in New Issue