diff --git a/src/DynamicModel.cc b/src/DynamicModel.cc index bb25c2d26bff51fae1787ae528ede5661dc3d973..b88d7d25c814095794a6a87bf496c76149b13dd8 100644 --- a/src/DynamicModel.cc +++ b/src/DynamicModel.cc @@ -5264,39 +5264,6 @@ DynamicModel::substituteLeadLagInternal(aux_var_t type, bool deterministic_model aux_equation = substeq; } - // Substitute in diff_aux_equations - // Without this loop, the auxiliary equations in equations - // will diverge from those in diff_aux_equations - for (auto & diff_aux_equation : diff_aux_equations) - { - expr_t subst; - switch (type) - { - case avEndoLead: - subst = diff_aux_equation->substituteEndoLeadGreaterThanTwo(subst_table, - neweqs, deterministic_model); - break; - case avEndoLag: - subst = diff_aux_equation->substituteEndoLagGreaterThanTwo(subst_table, neweqs); - break; - case avExoLead: - subst = diff_aux_equation->substituteExoLead(subst_table, neweqs, deterministic_model); - break; - case avExoLag: - subst = diff_aux_equation->substituteExoLag(subst_table, neweqs); - break; - case avDiffForward: - subst = diff_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); - diff_aux_equation = substeq; - } - // Add new equations for (auto & neweq : neweqs) addEquation(neweq, -1); @@ -5425,7 +5392,7 @@ DynamicModel::substituteUnaryOps(StaticModel &static_model, vector<int> &eqnumbe for (auto & neweq : neweqs) addEquation(neweq, -1); - copy(neweqs.begin(), neweqs.end(), back_inserter(diff_aux_equations)); + copy(neweqs.begin(), neweqs.end(), back_inserter(aux_equations)); if (subst_table.size() > 0) cout << "Substitution of Unary Ops: added " << neweqs.size() << " auxiliary variables and equations." << endl; @@ -5465,18 +5432,12 @@ DynamicModel::substituteDiff(StaticModel &static_model, ExprNode::subst_table_t for (auto & neweq : neweqs) addEquation(neweq, -1); - copy(neweqs.begin(), neweqs.end(), back_inserter(diff_aux_equations)); + copy(neweqs.begin(), neweqs.end(), back_inserter(aux_equations)); if (diff_subst_table.size() > 0) cout << "Substitution of Diff operator: added " << neweqs.size() << " auxiliary variables and equations." << endl; } -void -DynamicModel::combineDiffAuxEquations() -{ - copy(diff_aux_equations.begin(), diff_aux_equations.end(), back_inserter(aux_equations)); -} - void DynamicModel::substituteExpectation(bool partial_information_model) { diff --git a/src/DynamicModel.hh b/src/DynamicModel.hh index 79c726ce2d3cf3816c6acbdd79e35c54ce2a4dbd..ee96cf9d85869f953a42bf57e9bb8494380e5192 100644 --- a/src/DynamicModel.hh +++ b/src/DynamicModel.hh @@ -438,9 +438,6 @@ public: 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); - //! Adds contents of diff_aux_equations to the back of aux_equations - void combineDiffAuxEquations(); - //! Fill var_expectation_functions_to_write void fillVarExpectationFunctionsToWrite(); diff --git a/src/ModFile.cc b/src/ModFile.cc index ff08c4dce772be38c93ffbfe446a9830bf9351a1..18e657b3c7b565b362b824d3c3949f02760a99ec 100644 --- a/src/ModFile.cc +++ b/src/ModFile.cc @@ -512,8 +512,6 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const dynamic_model.substituteEndoLagGreaterThanTwo(true); } - dynamic_model.combineDiffAuxEquations(); - for (auto & statement : statements) { auto *vms = dynamic_cast<VarModelStatement *>(statement); diff --git a/src/ModelTree.hh b/src/ModelTree.hh index 46cad5f2118f0e35a58a6338ba6728d4b21f50dd..682fe0e1ef51a42c066fc1c83a12b32abaa44dbb 100644 --- a/src/ModelTree.hh +++ b/src/ModelTree.hh @@ -60,12 +60,6 @@ protected: //! Only stores generated auxiliary equations, in an order meaningful for evaluation deque<BinaryOpNode *> aux_equations; - //! Temporarily stores aux equations for diff operator - //! This is a hack to make diff aux vars work: they must be substituted before we consider VARs - //! But leads lags can't be substituted until after we consider VARs - //! The diff_aux_vars may depend on aux_vars created for leads lags, as in - //! diff(x(-1)) => x(-1) - x(-2) => x(-1) - aux_var(-1); aux_var = x(-1); - deque<BinaryOpNode *> diff_aux_equations; //! Stores equation tags vector<pair<int, pair<string, string>>> equation_tags;