diff --git a/src/DynamicModel.cc b/src/DynamicModel.cc index 95cfaa94..a3b18744 100644 --- a/src/DynamicModel.cc +++ b/src/DynamicModel.cc @@ -5191,7 +5191,7 @@ DynamicModel::substituteAdl() void DynamicModel::substituteDiff(StaticModel &static_model, ExprNode::subst_table_t &diff_subst_table) { - // Find diff Nodes + // Find unary ops in diff Nodes diff_table_t diff_table; for (map::iterator it = local_variables_table.begin(); it != local_variables_table.end(); it++) @@ -5229,7 +5229,7 @@ void DynamicModel::substituteDiffUnaryOps(StaticModel &static_model) { // Find diff Nodes - set nodes; + diff_table_t nodes; for (map::iterator it = local_variables_table.begin(); it != local_variables_table.end(); it++) it->second->findDiffUnaryOpNodes(static_model, nodes); @@ -5237,6 +5237,17 @@ DynamicModel::substituteDiffUnaryOps(StaticModel &static_model) for (int i = 0; i < (int) equations.size(); i++) equations[i]->findDiffUnaryOpNodes(static_model, nodes); + if (nodes.empty()) + return; + + // Find matching unary ops that may be outside of diffs (i.e., those with different lags) + for (map::iterator it = local_variables_table.begin(); + it != local_variables_table.end(); it++) + it->second->findUnaryOpNodesForAuxVarCreation(static_model, nodes); + + for (int i = 0; i < (int) equations.size(); i++) + equations[i]->findUnaryOpNodesForAuxVarCreation(static_model, nodes); + // Substitute in model local variables ExprNode::subst_table_t subst_table; vector neweqs; diff --git a/src/ExprNode.cc b/src/ExprNode.cc index 528ea617..86194634 100644 --- a/src/ExprNode.cc +++ b/src/ExprNode.cc @@ -539,7 +539,12 @@ NumConstNode::findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table) } void -NumConstNode::findDiffUnaryOpNodes(DataTree &static_datatree, set &unary_op_nodes_in_diff) const +NumConstNode::findDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const +{ +} + +void +NumConstNode::findUnaryOpNodesForAuxVarCreation(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const { } @@ -550,7 +555,7 @@ NumConstNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table } expr_t -NumConstNode::substituteDiffUnaryOpNodes(DataTree &static_datatree, set &nodes, subst_table_t &subst_table, vector &neweqs) const +NumConstNode::substituteDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &nodes, subst_table_t &subst_table, vector &neweqs) const { return const_cast(this); } @@ -1425,7 +1430,12 @@ VariableNode::findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table) } void -VariableNode::findDiffUnaryOpNodes(DataTree &static_datatree, set &unary_op_nodes_in_diff) const +VariableNode::findDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const +{ +} + +void +VariableNode::findUnaryOpNodesForAuxVarCreation(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const { } @@ -1437,7 +1447,7 @@ VariableNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table } expr_t -VariableNode::substituteDiffUnaryOpNodes(DataTree &static_datatree, set &nodes, subst_table_t &subst_table, vector &neweqs) const +VariableNode::substituteDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &nodes, subst_table_t &subst_table, vector &neweqs) const { return const_cast(this); } @@ -3036,7 +3046,7 @@ UnaryOpNode::isDiffPresent() const } void -UnaryOpNode::findDiffUnaryOpNodes(DataTree &static_datatree, set &unary_op_nodes_in_diff) const +UnaryOpNode::findDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const { if (op_code != oDiff) { @@ -3055,9 +3065,6 @@ UnaryOpNode::findDiffUnaryOpNodes(DataTree &static_datatree, set exit(EXIT_FAILURE); } - if (unary_op_nodes_in_diff.find(sarg) != unary_op_nodes_in_diff.end()) - return; - if (sarg->get_op_code() == oDiff) { arg->findDiffUnaryOpNodes(static_datatree, unary_op_nodes_in_diff); @@ -3071,7 +3078,39 @@ UnaryOpNode::findDiffUnaryOpNodes(DataTree &static_datatree, set exit(EXIT_FAILURE); } - unary_op_nodes_in_diff.insert(sarg); + int arg_max_lag = -arg->maxLag(); + diff_table_t::iterator it = unary_op_nodes_in_diff.find(sarg); + if (it != unary_op_nodes_in_diff.end()) + { + for (map::const_iterator it1 = it->second.begin(); + it1 != it->second.end(); it1++) + if (arg == it1->second) + return; + it->second[arg_max_lag] = dynamic_cast(arg); + } + else + unary_op_nodes_in_diff[sarg][arg_max_lag] = dynamic_cast(arg); +} + +void +UnaryOpNode::findUnaryOpNodesForAuxVarCreation(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const +{ + UnaryOpNode *sthis = dynamic_cast(this->toStatic(static_datatree)); + diff_table_t::iterator it = unary_op_nodes_in_diff.find(sthis); + if (it == unary_op_nodes_in_diff.end()) + { + arg->findUnaryOpNodesForAuxVarCreation(static_datatree, unary_op_nodes_in_diff); + return; + } + else + { + int this_max_lag = -this->maxLag(); + for (map::const_iterator it1 = it->second.begin(); + it1 != it->second.end(); it1++) + if (this == it1->second) + return; + it->second[this_max_lag] = const_cast(this); + } } bool @@ -3289,40 +3328,42 @@ UnaryOpNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, } expr_t -UnaryOpNode::substituteDiffUnaryOpNodes(DataTree &static_datatree, set &nodes, subst_table_t &subst_table, vector &neweqs) const +UnaryOpNode::substituteDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &nodes, subst_table_t &subst_table, vector &neweqs) const { - UnaryOpNode *sarg, *argtouse; - if (op_code == oDiff) - { - sarg = dynamic_cast(arg->toStatic(static_datatree)); - argtouse = dynamic_cast(arg); - } - else - { - sarg = dynamic_cast(this->toStatic(static_datatree)); - argtouse = const_cast(this); - } - - if (sarg == NULL || nodes.find(sarg) == nodes.end()) + UnaryOpNode *sthis = dynamic_cast(this->toStatic(static_datatree)); + diff_table_t::iterator it = nodes.find(sthis); + if (it == nodes.end()) { expr_t argsubst = arg->substituteDiffUnaryOpNodes(static_datatree, nodes, subst_table, neweqs); return buildSimilarUnaryOpNode(argsubst, datatree); } - subst_table_t::const_iterator sit = subst_table.find(argtouse); + subst_table_t::const_iterator sit = subst_table.find(this); if (sit != subst_table.end()) return const_cast(sit->second); - VariableNode *vn = dynamic_cast(dynamic_cast(argtouse)->get_arg()); - int lag = vn->get_lag(); - int symb_id = datatree.symbol_table.addUnaryOpInsideDiffAuxiliaryVar(argtouse->idx, argtouse, - vn->get_symb_id(), lag); - VariableNode *aux_var = datatree.AddVariable(symb_id, 0); - neweqs.push_back(dynamic_cast(datatree.AddEqual(aux_var, argtouse))); - subst_table[argtouse] = dynamic_cast(aux_var); - if (op_code == oDiff) - return buildSimilarUnaryOpNode(aux_var, datatree); - return const_cast(aux_var); + VariableNode *aux_var = NULL; + for (map::reverse_iterator rit = it->second.rbegin(); + rit != it->second.rend(); rit++) + { + if (rit == it->second.rbegin()) + { + VariableNode *vn = dynamic_cast(const_cast(this)->get_arg()); + int symb_id = datatree.symbol_table.addUnaryOpInsideDiffAuxiliaryVar(this->idx, const_cast(this), + vn->get_symb_id(), vn->get_lag()); + aux_var = datatree.AddVariable(symb_id, 0); + neweqs.push_back(dynamic_cast(datatree.AddEqual(aux_var, const_cast(this)))); + subst_table[rit->second] = dynamic_cast(aux_var); + } + else + { + VariableNode *vn = dynamic_cast(dynamic_cast(rit->second)->get_arg()); + subst_table[rit->second] = dynamic_cast(aux_var->decreaseLeadsLags(-vn->get_lag())); + } + } + + sit = subst_table.find(this); + return const_cast(sit->second); } expr_t @@ -4994,12 +5035,19 @@ BinaryOpNode::substituteAdl() const } void -BinaryOpNode::findDiffUnaryOpNodes(DataTree &static_datatree, set &unary_op_nodes_in_diff) const +BinaryOpNode::findDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const { arg1->findDiffUnaryOpNodes(static_datatree, unary_op_nodes_in_diff); arg2->findDiffUnaryOpNodes(static_datatree, unary_op_nodes_in_diff); } +void +BinaryOpNode::findUnaryOpNodesForAuxVarCreation(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const +{ + arg1->findUnaryOpNodesForAuxVarCreation(static_datatree, unary_op_nodes_in_diff); + arg2->findUnaryOpNodesForAuxVarCreation(static_datatree, unary_op_nodes_in_diff); +} + void BinaryOpNode::findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table) const { @@ -5017,7 +5065,7 @@ BinaryOpNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table } expr_t -BinaryOpNode::substituteDiffUnaryOpNodes(DataTree &static_datatree, set &nodes, subst_table_t &subst_table, vector &neweqs) const +BinaryOpNode::substituteDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &nodes, subst_table_t &subst_table, vector &neweqs) const { expr_t arg1subst = arg1->substituteDiffUnaryOpNodes(static_datatree, nodes, subst_table, neweqs); expr_t arg2subst = arg2->substituteDiffUnaryOpNodes(static_datatree, nodes, subst_table, neweqs); @@ -5910,13 +5958,21 @@ TrinaryOpNode::findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table } void -TrinaryOpNode::findDiffUnaryOpNodes(DataTree &static_datatree, set &unary_op_nodes_in_diff) const +TrinaryOpNode::findDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const { arg1->findDiffUnaryOpNodes(static_datatree, unary_op_nodes_in_diff); arg2->findDiffUnaryOpNodes(static_datatree, unary_op_nodes_in_diff); arg3->findDiffUnaryOpNodes(static_datatree, unary_op_nodes_in_diff); } +void +TrinaryOpNode::findUnaryOpNodesForAuxVarCreation(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const +{ + arg1->findUnaryOpNodesForAuxVarCreation(static_datatree, unary_op_nodes_in_diff); + arg2->findUnaryOpNodesForAuxVarCreation(static_datatree, unary_op_nodes_in_diff); + arg3->findUnaryOpNodesForAuxVarCreation(static_datatree, unary_op_nodes_in_diff); +} + expr_t TrinaryOpNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table, vector &neweqs) const @@ -5928,7 +5984,7 @@ TrinaryOpNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_tabl } expr_t -TrinaryOpNode::substituteDiffUnaryOpNodes(DataTree &static_datatree, set &nodes, subst_table_t &subst_table, vector &neweqs) const +TrinaryOpNode::substituteDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &nodes, subst_table_t &subst_table, vector &neweqs) const { expr_t arg1subst = arg1->substituteDiffUnaryOpNodes(static_datatree, nodes, subst_table, neweqs); expr_t arg2subst = arg2->substituteDiffUnaryOpNodes(static_datatree, nodes, subst_table, neweqs); @@ -6350,12 +6406,19 @@ AbstractExternalFunctionNode::findDiffNodes(DataTree &static_datatree, diff_tabl } void -AbstractExternalFunctionNode::findDiffUnaryOpNodes(DataTree &static_datatree, set &unary_op_nodes_in_diff) const +AbstractExternalFunctionNode::findDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const { for (vector::const_iterator it = arguments.begin(); it != arguments.end(); it++) (*it)->findDiffUnaryOpNodes(static_datatree, unary_op_nodes_in_diff); } +void +AbstractExternalFunctionNode::findUnaryOpNodesForAuxVarCreation(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const +{ + for (vector::const_iterator it = arguments.begin(); it != arguments.end(); it++) + (*it)->findUnaryOpNodesForAuxVarCreation(static_datatree, unary_op_nodes_in_diff); +} + expr_t AbstractExternalFunctionNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table, vector &neweqs) const @@ -6367,7 +6430,7 @@ AbstractExternalFunctionNode::substituteDiff(DataTree &static_datatree, diff_tab } expr_t -AbstractExternalFunctionNode::substituteDiffUnaryOpNodes(DataTree &static_datatree, set &nodes, subst_table_t &subst_table, vector &neweqs) const +AbstractExternalFunctionNode::substituteDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &nodes, subst_table_t &subst_table, vector &neweqs) const { vector arguments_subst; for (vector::const_iterator it = arguments.begin(); it != arguments.end(); it++) @@ -7929,7 +7992,12 @@ VarExpectationNode::findDiffNodes(DataTree &static_datatree, diff_table_t &diff_ } void -VarExpectationNode::findDiffUnaryOpNodes(DataTree &static_datatree, set &unary_op_nodes_in_diff) const +VarExpectationNode::findDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const +{ +} + +void +VarExpectationNode::findUnaryOpNodesForAuxVarCreation(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const { } @@ -7941,7 +8009,7 @@ VarExpectationNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff } expr_t -VarExpectationNode::substituteDiffUnaryOpNodes(DataTree &static_datatree, set &nodes, subst_table_t &subst_table, vector &neweqs) const +VarExpectationNode::substituteDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &nodes, subst_table_t &subst_table, vector &neweqs) const { return const_cast(this); } @@ -8374,7 +8442,12 @@ PacExpectationNode::findDiffNodes(DataTree &static_datatree, diff_table_t &diff_ } void -PacExpectationNode::findDiffUnaryOpNodes(DataTree &static_datatree, set &unary_op_nodes_in_diff) const +PacExpectationNode::findDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const +{ +} + +void +PacExpectationNode::findUnaryOpNodesForAuxVarCreation(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const { } @@ -8386,7 +8459,7 @@ PacExpectationNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff } expr_t -PacExpectationNode::substituteDiffUnaryOpNodes(DataTree &static_datatree, set &nodes, subst_table_t &subst_table, vector &neweqs) const +PacExpectationNode::substituteDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &nodes, subst_table_t &subst_table, vector &neweqs) const { return const_cast(this); } diff --git a/src/ExprNode.hh b/src/ExprNode.hh index f28a6b1f..5a70b86b 100644 --- a/src/ExprNode.hh +++ b/src/ExprNode.hh @@ -492,9 +492,10 @@ class ExprNode //! Substitute diff operator virtual void findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table) const = 0; - virtual void findDiffUnaryOpNodes(DataTree &static_datatree, set &unary_op_nodes_in_diff) const = 0; + virtual void findDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const = 0; + virtual void findUnaryOpNodesForAuxVarCreation(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const = 0; virtual expr_t substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table, vector &neweqs) const = 0; - virtual expr_t substituteDiffUnaryOpNodes(DataTree &static_datatree, set &nodes, subst_table_t &subst_table, vector &neweqs) const = 0; + virtual expr_t substituteDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &nodes, subst_table_t &subst_table, vector &neweqs) const = 0; //! Substitute pac_expectation operator virtual expr_t substitutePacExpectation(map &subst_table) = 0; @@ -586,9 +587,10 @@ public: virtual expr_t substituteExpectation(subst_table_t &subst_table, vector &neweqs, bool partial_information_model) const; virtual expr_t substituteAdl() const; virtual void findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table) const; - virtual void findDiffUnaryOpNodes(DataTree &static_datatree, set &unary_op_nodes_in_diff) const; + virtual void findDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const; + virtual void findUnaryOpNodesForAuxVarCreation(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const; virtual expr_t substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table, vector &neweqs) const; - virtual expr_t substituteDiffUnaryOpNodes(DataTree &static_datatree, set &nodes, subst_table_t &subst_table, vector &neweqs) const; + virtual expr_t substituteDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &nodes, subst_table_t &subst_table, vector &neweqs) const; virtual expr_t substitutePacExpectation(map &subst_table); virtual expr_t decreaseLeadsLagsPredeterminedVariables() const; virtual expr_t differentiateForwardVars(const vector &subset, subst_table_t &subst_table, vector &neweqs) const; @@ -676,9 +678,10 @@ public: virtual expr_t substituteExpectation(subst_table_t &subst_table, vector &neweqs, bool partial_information_model) const; virtual expr_t substituteAdl() const; virtual void findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table) const; - virtual void findDiffUnaryOpNodes(DataTree &static_datatree, set &unary_op_nodes_in_diff) const; + virtual void findDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const; + virtual void findUnaryOpNodesForAuxVarCreation(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const; virtual expr_t substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table, vector &neweqs) const; - virtual expr_t substituteDiffUnaryOpNodes(DataTree &static_datatree, set &nodes, subst_table_t &subst_table, vector &neweqs) const; + virtual expr_t substituteDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &nodes, subst_table_t &subst_table, vector &neweqs) const; virtual expr_t substitutePacExpectation(map &subst_table); virtual expr_t decreaseLeadsLagsPredeterminedVariables() const; virtual expr_t differentiateForwardVars(const vector &subset, subst_table_t &subst_table, vector &neweqs) const; @@ -789,10 +792,11 @@ public: virtual expr_t substituteAdl() const; virtual void findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table) const; bool createAuxVarForUnaryOpNodeInDiffOp() const; - virtual void findDiffUnaryOpNodes(DataTree &static_datatree, set &unary_op_nodes_in_diff) const; + virtual void findDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const; + virtual void findUnaryOpNodesForAuxVarCreation(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const; void getDiffArgUnaryOperatorIfAny(string &op_handle) const; virtual expr_t substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table, vector &neweqs) const; - virtual expr_t substituteDiffUnaryOpNodes(DataTree &static_datatree, set &nodes, subst_table_t &subst_table, vector &neweqs) const; + virtual expr_t substituteDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &nodes, subst_table_t &subst_table, vector &neweqs) const; virtual expr_t substitutePacExpectation(map &subst_table); virtual expr_t decreaseLeadsLagsPredeterminedVariables() const; virtual expr_t differentiateForwardVars(const vector &subset, subst_table_t &subst_table, vector &neweqs) const; @@ -919,9 +923,10 @@ public: virtual expr_t substituteExpectation(subst_table_t &subst_table, vector &neweqs, bool partial_information_model) const; virtual expr_t substituteAdl() const; virtual void findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table) const; - virtual void findDiffUnaryOpNodes(DataTree &static_datatree, set &unary_op_nodes_in_diff) const; + virtual void findDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const; + virtual void findUnaryOpNodesForAuxVarCreation(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const; virtual expr_t substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table, vector &neweqs) const; - virtual expr_t substituteDiffUnaryOpNodes(DataTree &static_datatree, set &nodes, subst_table_t &subst_table, vector &neweqs) const; + virtual expr_t substituteDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &nodes, subst_table_t &subst_table, vector &neweqs) const; virtual expr_t substitutePacExpectation(map &subst_table); virtual expr_t decreaseLeadsLagsPredeterminedVariables() const; virtual expr_t differentiateForwardVars(const vector &subset, subst_table_t &subst_table, vector &neweqs) const; @@ -1024,9 +1029,10 @@ public: virtual expr_t substituteExpectation(subst_table_t &subst_table, vector &neweqs, bool partial_information_model) const; virtual expr_t substituteAdl() const; virtual void findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table) const; - virtual void findDiffUnaryOpNodes(DataTree &static_datatree, set &unary_op_nodes_in_diff) const; + virtual void findDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const; + virtual void findUnaryOpNodesForAuxVarCreation(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const; virtual expr_t substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table, vector &neweqs) const; - virtual expr_t substituteDiffUnaryOpNodes(DataTree &static_datatree, set &nodes, subst_table_t &subst_table, vector &neweqs) const; + virtual expr_t substituteDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &nodes, subst_table_t &subst_table, vector &neweqs) const; virtual expr_t substitutePacExpectation(map &subst_table); virtual expr_t decreaseLeadsLagsPredeterminedVariables() const; virtual expr_t differentiateForwardVars(const vector &subset, subst_table_t &subst_table, vector &neweqs) const; @@ -1129,9 +1135,10 @@ public: virtual expr_t substituteExpectation(subst_table_t &subst_table, vector &neweqs, bool partial_information_model) const; virtual expr_t substituteAdl() const; virtual void findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table) const; - virtual void findDiffUnaryOpNodes(DataTree &static_datatree, set &unary_op_nodes_in_diff) const; + virtual void findDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const; + virtual void findUnaryOpNodesForAuxVarCreation(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const; virtual expr_t substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table, vector &neweqs) const; - virtual expr_t substituteDiffUnaryOpNodes(DataTree &static_datatree, set &nodes, subst_table_t &subst_table, vector &neweqs) const; + virtual expr_t substituteDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &nodes, subst_table_t &subst_table, vector &neweqs) const; virtual expr_t substitutePacExpectation(map &subst_table); virtual expr_t buildSimilarExternalFunctionNode(vector &alt_args, DataTree &alt_datatree) const = 0; virtual expr_t decreaseLeadsLagsPredeterminedVariables() const; @@ -1324,9 +1331,10 @@ public: virtual expr_t substituteExpectation(subst_table_t &subst_table, vector &neweqs, bool partial_information_model) const; virtual expr_t substituteAdl() const; virtual void findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table) const; - virtual void findDiffUnaryOpNodes(DataTree &static_datatree, set &unary_op_nodes_in_diff) const; + virtual void findDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const; + virtual void findUnaryOpNodesForAuxVarCreation(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const; virtual expr_t substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table, vector &neweqs) const; - virtual expr_t substituteDiffUnaryOpNodes(DataTree &static_datatree, set &nodes, subst_table_t &subst_table, vector &neweqs) const; + virtual expr_t substituteDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &nodes, subst_table_t &subst_table, vector &neweqs) const; virtual expr_t substitutePacExpectation(map &subst_table); virtual pair normalizeEquation(int symb_id_endo, vector > > &List_of_Op_RHS) const; virtual void compile(ostream &CompileCode, unsigned int &instruction_number, @@ -1409,9 +1417,10 @@ public: virtual expr_t substituteExpectation(subst_table_t &subst_table, vector &neweqs, bool partial_information_model) const; virtual expr_t substituteAdl() const; virtual void findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table) const; - virtual void findDiffUnaryOpNodes(DataTree &static_datatree, set &unary_op_nodes_in_diff) const; + virtual void findDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const; + virtual void findUnaryOpNodesForAuxVarCreation(DataTree &static_datatree, diff_table_t &unary_op_nodes_in_diff) const; virtual expr_t substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table, vector &neweqs) const; - virtual expr_t substituteDiffUnaryOpNodes(DataTree &static_datatree, set &nodes, subst_table_t &subst_table, vector &neweqs) const; + virtual expr_t substituteDiffUnaryOpNodes(DataTree &static_datatree, diff_table_t &nodes, subst_table_t &subst_table, vector &neweqs) const; virtual expr_t substitutePacExpectation(map &subst_table); virtual pair normalizeEquation(int symb_id_endo, vector > > &List_of_Op_RHS) const; virtual void compile(ostream &CompileCode, unsigned int &instruction_number,