🐛 Incorrect stochastic transformation with endo lead ⩾ 2 or exo lead ⩾ 1 in external functions

If an endogenous with a lead ⩾ 2 or an exogenous with a lead ⩾ 1 appeared in
the argument(s) of a call to an external function, the auxiliary variable
transformation was incorrect (the variable was replaced inside the function
call, while it is the whole function call that has to be replaced).

This could lead to incorrect results in stochastic contexts, when the external
function is nonlinear.
master
Sébastien Villemot 2023-03-23 17:58:20 +01:00
parent 3b20f835db
commit 712b11a045
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
1 changed files with 12 additions and 2 deletions

View File

@ -6928,7 +6928,12 @@ AbstractExternalFunctionNode::decreaseLeadsLagsPredeterminedVariables() const
expr_t
AbstractExternalFunctionNode::substituteEndoLeadGreaterThanTwo(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool deterministic_model) const
{
return recurseTransform(&ExprNode::substituteEndoLeadGreaterThanTwo, subst_table, neweqs, deterministic_model);
if (maxEndoLead() < 2)
return const_cast<AbstractExternalFunctionNode *>(this);
else if (deterministic_model)
return recurseTransform(&ExprNode::substituteEndoLeadGreaterThanTwo, subst_table, neweqs, deterministic_model);
else
return createEndoLeadAuxiliaryVarForMyself(subst_table, neweqs);
}
expr_t
@ -6940,7 +6945,12 @@ AbstractExternalFunctionNode::substituteEndoLagGreaterThanTwo(subst_table_t &sub
expr_t
AbstractExternalFunctionNode::substituteExoLead(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool deterministic_model) const
{
return recurseTransform(&ExprNode::substituteExoLead, subst_table, neweqs, deterministic_model);
if (maxExoLead() == 0)
return const_cast<AbstractExternalFunctionNode *>(this);
else if (deterministic_model)
return recurseTransform(&ExprNode::substituteExoLead, subst_table, neweqs, deterministic_model);
else
return createExoLeadAuxiliaryVarForMyself(subst_table, neweqs);
}
expr_t