Commit c6cb9aa1 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Fix bug in option notmpterms with model local variables

Since model local variables are now treated as temporary terms, they must be
marked as such even when option notmpterms is present.
parent fbeae961
Pipeline #58 passed with stage
in 1 minute and 17 seconds
...@@ -4286,12 +4286,11 @@ DynamicModel::computingPass(bool jacobianExo, bool hessian, bool thirdDerivative ...@@ -4286,12 +4286,11 @@ DynamicModel::computingPass(bool jacobianExo, bool hessian, bool thirdDerivative
} }
} }
else else
if (!no_tmp_terms) {
{ computeTemporaryTerms(!use_dll, no_tmp_terms);
computeTemporaryTerms(!use_dll); if (bytecode && !no_tmp_terms)
if (bytecode) computeTemporaryTermsMapping();
computeTemporaryTermsMapping(); }
}
} }
void void
......
...@@ -1106,7 +1106,7 @@ ModelTree::computeThirdDerivatives(const set<int> &vars) ...@@ -1106,7 +1106,7 @@ ModelTree::computeThirdDerivatives(const set<int> &vars)
} }
void void
ModelTree::computeTemporaryTerms(bool is_matlab) ModelTree::computeTemporaryTerms(bool is_matlab, bool no_tmp_terms)
{ {
map<expr_t, pair<int, NodeTreeReference>> reference_count; map<expr_t, pair<int, NodeTreeReference>> reference_count;
temporary_terms.clear(); temporary_terms.clear();
...@@ -1129,6 +1129,11 @@ ModelTree::computeTemporaryTerms(bool is_matlab) ...@@ -1129,6 +1129,11 @@ ModelTree::computeTemporaryTerms(bool is_matlab)
reference_count[v] = { ExprNode::min_cost(is_matlab)+1, NodeTreeReference::residuals }; reference_count[v] = { ExprNode::min_cost(is_matlab)+1, NodeTreeReference::residuals };
} }
/* When option notmpterms is set, we only need to process model local
variables (and turn them into temporary terms); no need to go further */
if (no_tmp_terms)
return;
map<NodeTreeReference, temporary_terms_t> temp_terms_map; map<NodeTreeReference, temporary_terms_t> temp_terms_map;
temp_terms_map[NodeTreeReference::residuals] = temporary_terms_res; temp_terms_map[NodeTreeReference::residuals] = temporary_terms_res;
temp_terms_map[NodeTreeReference::firstDeriv] = temporary_terms_g1; temp_terms_map[NodeTreeReference::firstDeriv] = temporary_terms_g1;
......
...@@ -186,7 +186,7 @@ protected: ...@@ -186,7 +186,7 @@ protected:
//! Write derivative of an equation w.r. to a variable //! Write derivative of an equation w.r. to a variable
void writeDerivative(ostream &output, int eq, int symb_id, int lag, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms) const; void writeDerivative(ostream &output, int eq, int symb_id, int lag, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms) const;
//! Computes temporary terms (for all equations and derivatives) //! Computes temporary terms (for all equations and derivatives)
void computeTemporaryTerms(bool is_matlab); void computeTemporaryTerms(bool is_matlab, bool no_tmp_terms);
//! Computes temporary terms for the file containing parameters derivatives //! Computes temporary terms for the file containing parameters derivatives
void computeParamsDerivativesTemporaryTerms(); void computeParamsDerivativesTemporaryTerms();
//! Writes temporary terms //! Writes temporary terms
......
...@@ -1139,12 +1139,9 @@ StaticModel::computingPass(const eval_context_t &eval_context, bool no_tmp_terms ...@@ -1139,12 +1139,9 @@ StaticModel::computingPass(const eval_context_t &eval_context, bool no_tmp_terms
} }
else else
{ {
if (!no_tmp_terms) computeTemporaryTerms(true, no_tmp_terms);
{ if (bytecode && !no_tmp_terms)
computeTemporaryTerms(true); computeTemporaryTermsMapping(temporary_terms, map_idx);
if (bytecode)
computeTemporaryTermsMapping(temporary_terms, map_idx);
}
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment