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.issue#70
parent
fbeae9619a
commit
c6cb9aa1b8
|
@ -4286,12 +4286,11 @@ DynamicModel::computingPass(bool jacobianExo, bool hessian, bool thirdDerivative
|
|||
}
|
||||
}
|
||||
else
|
||||
if (!no_tmp_terms)
|
||||
{
|
||||
computeTemporaryTerms(!use_dll);
|
||||
if (bytecode)
|
||||
computeTemporaryTermsMapping();
|
||||
}
|
||||
{
|
||||
computeTemporaryTerms(!use_dll, no_tmp_terms);
|
||||
if (bytecode && !no_tmp_terms)
|
||||
computeTemporaryTermsMapping();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -1106,7 +1106,7 @@ ModelTree::computeThirdDerivatives(const set<int> &vars)
|
|||
}
|
||||
|
||||
void
|
||||
ModelTree::computeTemporaryTerms(bool is_matlab)
|
||||
ModelTree::computeTemporaryTerms(bool is_matlab, bool no_tmp_terms)
|
||||
{
|
||||
map<expr_t, pair<int, NodeTreeReference>> reference_count;
|
||||
temporary_terms.clear();
|
||||
|
@ -1129,6 +1129,11 @@ ModelTree::computeTemporaryTerms(bool is_matlab)
|
|||
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;
|
||||
temp_terms_map[NodeTreeReference::residuals] = temporary_terms_res;
|
||||
temp_terms_map[NodeTreeReference::firstDeriv] = temporary_terms_g1;
|
||||
|
|
|
@ -186,7 +186,7 @@ protected:
|
|||
//! 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;
|
||||
//! 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
|
||||
void computeParamsDerivativesTemporaryTerms();
|
||||
//! Writes temporary terms
|
||||
|
|
|
@ -1139,12 +1139,9 @@ StaticModel::computingPass(const eval_context_t &eval_context, bool no_tmp_terms
|
|||
}
|
||||
else
|
||||
{
|
||||
if (!no_tmp_terms)
|
||||
{
|
||||
computeTemporaryTerms(true);
|
||||
if (bytecode)
|
||||
computeTemporaryTermsMapping(temporary_terms, map_idx);
|
||||
}
|
||||
computeTemporaryTerms(true, no_tmp_terms);
|
||||
if (bytecode && !no_tmp_terms)
|
||||
computeTemporaryTermsMapping(temporary_terms, map_idx);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue