Implement cloneDynamic() for {First,Second}DerivExternalFunction.

Since the method was not implement, the method of the parent class was used.
This was leading to wrong results in the context of Ramsey Policy (basically
derivative operators on external functions were dropped from FOCs).
time-shift
Sébastien Villemot 2014-03-11 17:33:46 +01:00
parent 1f6fd55594
commit f55fda0938
2 changed files with 24 additions and 0 deletions

View File

@ -5140,6 +5140,17 @@ FirstDerivExternalFunctionNode::compileExternalFunctionOutput(ostream &CompileCo
}
}
expr_t
FirstDerivExternalFunctionNode::cloneDynamic(DataTree &dynamic_datatree) const
{
vector<expr_t> dynamic_arguments;
for (vector<expr_t>::const_iterator it = arguments.begin();
it != arguments.end(); it++)
dynamic_arguments.push_back((*it)->cloneDynamic(dynamic_datatree));
return dynamic_datatree.AddFirstDerivExternalFunctionNode(symb_id, dynamic_arguments,
inputIndex);
}
SecondDerivExternalFunctionNode::SecondDerivExternalFunctionNode(DataTree &datatree_arg,
int top_level_symb_id_arg,
const vector<expr_t> &arguments_arg,
@ -5336,3 +5347,14 @@ SecondDerivExternalFunctionNode::writeExternalFunctionOutput(ostream &output, Ex
output << ");" << endl;
}
}
expr_t
SecondDerivExternalFunctionNode::cloneDynamic(DataTree &dynamic_datatree) const
{
vector<expr_t> dynamic_arguments;
for (vector<expr_t>::const_iterator it = arguments.begin();
it != arguments.end(); it++)
dynamic_arguments.push_back((*it)->cloneDynamic(dynamic_datatree));
return dynamic_datatree.AddSecondDerivExternalFunctionNode(symb_id, dynamic_arguments,
inputIndex1, inputIndex2);
}

View File

@ -874,6 +874,7 @@ public:
bool lhs_rhs, const temporary_terms_t &temporary_terms,
const map_idx_t &map_idx, bool dynamic, bool steady_dynamic,
deriv_node_temp_terms_t &tef_terms) const;
virtual expr_t cloneDynamic(DataTree &dynamic_datatree) const;
};
class SecondDerivExternalFunctionNode : public ExternalFunctionNode
@ -899,6 +900,7 @@ public:
virtual void writeExternalFunctionOutput(ostream &output, ExprNodeOutputType output_type,
const temporary_terms_t &temporary_terms,
deriv_node_temp_terms_t &tef_terms) const;
virtual expr_t cloneDynamic(DataTree &dynamic_datatree) const;
};
#endif