aux_equations may diverge from those in the main model
aux_equations only contain the definition of auxiliary variables, and may diverge from those in the main model (equations), if other model transformations applied subsequently. This is not a problem, since aux_equations is only used for regenerating the values of auxiliaries given the others. For example, such a divergence appears when there is an expectation operator in a ramsey model, see tests/optimal_policy/nk_ramsey_expectation.mod */issue#70
parent
762f25abe9
commit
b9ee0bb204
|
@ -5229,39 +5229,6 @@ DynamicModel::substituteLeadLagInternal(AuxVarType type, bool deterministic_mode
|
|||
equation = substeq;
|
||||
}
|
||||
|
||||
// Substitute in aux_equations
|
||||
// Without this loop, the auxiliary equations in equations
|
||||
// will diverge from those in aux_equations
|
||||
for (auto & aux_equation : aux_equations)
|
||||
{
|
||||
expr_t subst;
|
||||
switch (type)
|
||||
{
|
||||
case AuxVarType::endoLead:
|
||||
subst = aux_equation->substituteEndoLeadGreaterThanTwo(subst_table,
|
||||
neweqs, deterministic_model);
|
||||
break;
|
||||
case AuxVarType::endoLag:
|
||||
subst = aux_equation->substituteEndoLagGreaterThanTwo(subst_table, neweqs);
|
||||
break;
|
||||
case AuxVarType::exoLead:
|
||||
subst = aux_equation->substituteExoLead(subst_table, neweqs, deterministic_model);
|
||||
break;
|
||||
case AuxVarType::exoLag:
|
||||
subst = aux_equation->substituteExoLag(subst_table, neweqs);
|
||||
break;
|
||||
case AuxVarType::diffForward:
|
||||
subst = aux_equation->differentiateForwardVars(subset, subst_table, neweqs);
|
||||
break;
|
||||
default:
|
||||
cerr << "DynamicModel::substituteLeadLagInternal: impossible case" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
auto *substeq = dynamic_cast<BinaryOpNode *>(subst);
|
||||
assert(substeq != nullptr);
|
||||
aux_equation = substeq;
|
||||
}
|
||||
|
||||
// Add new equations
|
||||
for (auto & neweq : neweqs)
|
||||
addEquation(neweq, -1);
|
||||
|
|
|
@ -59,6 +59,15 @@ protected:
|
|||
vector<int> equations_lineno;
|
||||
|
||||
//! Only stores generated auxiliary equations, in an order meaningful for evaluation
|
||||
/*! These equations only contain the definition of auxiliary variables, and
|
||||
may diverge from those in the main model (equations), if other model
|
||||
transformations applied subsequently. This is not a problem, since
|
||||
aux_equations is only used for regenerating the values of auxiliaries
|
||||
given the others.
|
||||
|
||||
For example, such a divergence appears when there is an expectation
|
||||
operator in a ramsey model, see
|
||||
tests/optimal_policy/nk_ramsey_expectation.mod */
|
||||
deque<BinaryOpNode *> aux_equations;
|
||||
|
||||
//! Stores equation tags
|
||||
|
|
Loading…
Reference in New Issue