Commit c5c61f99 authored by Houtan Bastani's avatar Houtan Bastani

fix bug with max_lag reported for PAC equation

parent 0dffee46
......@@ -3759,15 +3759,35 @@ DynamicModel::walkPacParameters()
}
}
int
DynamicModel::getPacMaxLag(const string &pac_model_name) const
{
for (auto & equation : equations)
if (equation->containsPacExpectation(pac_model_name))
{
set<pair<int, int>> endogs;
equation->get_arg1()->collectDynamicVariables(SymbolType::endogenous, endogs);
if (endogs.size() != 1)
{
cerr << "The LHS of the PAC equation may only be comprised of one endogenous variable"
<< endl;
exit(EXIT_FAILURE);
}
return equation->PacMaxLag((*(endogs.begin())).first);
}
return 0;
}
void
DynamicModel::fillPacExpectationVarInfo(string &pac_model_name,
vector<int> &lhs,
int max_lag,
int pac_max_lag,
vector<bool> &nonstationary,
int growth_symb_id)
{
for (size_t i = 0; i < equations.size(); i++)
equations[i]->fillPacExpectationVarInfo(pac_model_name, lhs, max_lag, nonstationary, growth_symb_id, i);
equations[i]->fillPacExpectationVarInfo(pac_model_name, lhs, max_lag, pac_max_lag, nonstationary, growth_symb_id, i);
}
void
......
......@@ -326,6 +326,7 @@ public:
void fillPacExpectationVarInfo(string &pac_model_name,
vector<int> &lhs,
int max_lag,
int pac_max_lag,
vector<bool> &nonstationary,
int growth_symb_id);
......@@ -434,6 +435,9 @@ public:
//! Substitute VarExpectation operators
void substituteVarExpectation(const map<string, expr_t> &subst_table);
//! Return max lag of pac equation
int getPacMaxLag(const string &pac_model_name) const;
//! Table to undiff LHS variables for pac vector z
void getUndiffLHSForPac(vector<int> &lhs, vector<expr_t> &lhs_expr_t, vector<bool> &diff, vector<int> &orig_diff_var,
vector<int> &eqnumber, map<string, int> &undiff, ExprNode::subst_table_t &diff_subst_table);
......
This diff is collapsed.
This diff is collapsed.
......@@ -437,7 +437,8 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const
}
pms->fillUndiffedLHS(lhs);
dynamic_model.walkPacParameters();
dynamic_model.fillPacExpectationVarInfo(pac_model_name, lhs, max_lag, nonstationary, growth_symb_id);
int pac_max_lag = original_model.getPacMaxLag(pac_model_name);
dynamic_model.fillPacExpectationVarInfo(pac_model_name, lhs, max_lag, pac_max_lag, nonstationary, growth_symb_id);
dynamic_model.substitutePacExpectation();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment