Add several types of auxiliary variables to M_.mapping

In practice, only those auxiliary variables which do not have an orig_symb_id
will be listed (in addition to unary ops, due to an implementation bug).
pac-components
Sébastien Villemot 2021-11-23 12:35:43 +01:00
parent 2282d4773c
commit a210a8fd59
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
3 changed files with 7 additions and 11 deletions

View File

@ -4546,19 +4546,17 @@ DynamicModel::ParamUsedWithLeadLag() const
}
void
DynamicModel::createVariableMapping(int orig_eq_nbr)
DynamicModel::createVariableMapping()
{
for (int ii = 0; ii < orig_eq_nbr; ii++)
for (size_t ii = 0; ii < equations.size(); ii++)
{
set<int> eqvars;
equations[ii]->collectVariables(SymbolType::endogenous, eqvars);
equations[ii]->collectVariables(SymbolType::exogenous, eqvars);
for (auto eqvar : eqvars)
{
eqvar = symbol_table.getUltimateOrigSymbID(eqvar);
if (eqvar >= 0 && !symbol_table.isAuxiliaryVariable(eqvar))
variableMapping[eqvar].emplace(ii);
}
if (int orig_symb_id = symbol_table.getUltimateOrigSymbID(eqvar);
orig_symb_id >= 0)
variableMapping[orig_symb_id].emplace(ii);
}
}

View File

@ -396,7 +396,7 @@ public:
void writeDynamicJacobianNonZeroElts(const string &basename) const;
//! Creates mapping for variables and equations they are present in
void createVariableMapping(int orig_eq_nbr);
void createVariableMapping();
//! Expands equation tags with default equation names (available "name" tag or LHS variable or equation ID)
void expandEqTags();

View File

@ -559,9 +559,7 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, bool
}
// And finally perform the substitutions
dynamic_model.substituteVarExpectation(var_expectation_subst_table);
dynamic_model.createVariableMapping(mod_file_struct.orig_eq_nbr +
(mod_file_struct.ramsey_model_present ?
mod_file_struct.ramsey_eq_nbr : 0));
dynamic_model.createVariableMapping();
/* Create auxiliary vars for leads and lags greater than 2, on both endos and
exos. The transformation is not exactly the same on stochastic and