In the driver file, provide mapping between model local variables and indices in the temporary terms vector
The structures are M_.model_local_variables_{dynamic,static}_tt_idxs. Ref. dynare#1722issue#70
parent
90b9b6a1e4
commit
b402e35683
|
@ -2575,6 +2575,14 @@ DynamicModel::writeDriverOutput(ostream &output, const string &basename, bool bl
|
||||||
for (size_t i = 0; i < temporary_terms_derivatives.size(); i++)
|
for (size_t i = 0; i < temporary_terms_derivatives.size(); i++)
|
||||||
output << temporary_terms_derivatives[i].size() + (i == 0 ? temporary_terms_mlv.size() : 0) << "; ";
|
output << temporary_terms_derivatives[i].size() + (i == 0 ? temporary_terms_mlv.size() : 0) << "; ";
|
||||||
output << "];" << endl;
|
output << "];" << endl;
|
||||||
|
|
||||||
|
/* Write mapping between model local variables and indices in the temporary
|
||||||
|
terms vector (dynare#1722) */
|
||||||
|
output << modstruct << "model_local_variables_dynamic_tt_idxs = {" << endl;
|
||||||
|
for (auto [mlv, value] : temporary_terms_mlv)
|
||||||
|
output << " '" << symbol_table.getName(mlv->symb_id) << "', "
|
||||||
|
<< temporary_terms_idxs.at(mlv)+1 << ';' << endl;
|
||||||
|
output << "};" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write equation tags
|
// Write equation tags
|
||||||
|
|
|
@ -70,7 +70,7 @@ ModelTree::copyHelper(const ModelTree &m)
|
||||||
|
|
||||||
// Temporary terms
|
// Temporary terms
|
||||||
for (const auto &it : m.temporary_terms_mlv)
|
for (const auto &it : m.temporary_terms_mlv)
|
||||||
temporary_terms_mlv[f(it.first)] = f(it.second);
|
temporary_terms_mlv[dynamic_cast<VariableNode *>(f(it.first))] = f(it.second);
|
||||||
for (const auto &it : m.temporary_terms_derivatives)
|
for (const auto &it : m.temporary_terms_derivatives)
|
||||||
temporary_terms_derivatives.push_back(convert_temporary_terms_t(it));
|
temporary_terms_derivatives.push_back(convert_temporary_terms_t(it));
|
||||||
for (const auto &it : m.temporary_terms_idxs)
|
for (const auto &it : m.temporary_terms_idxs)
|
||||||
|
|
|
@ -123,7 +123,7 @@ protected:
|
||||||
|
|
||||||
//! Used model local variables, that will be treated as temporary terms
|
//! Used model local variables, that will be treated as temporary terms
|
||||||
/*! See the comments in ModelTree::computeTemporaryTerms() */
|
/*! See the comments in ModelTree::computeTemporaryTerms() */
|
||||||
map<expr_t, expr_t, ExprNodeLess> temporary_terms_mlv;
|
map<VariableNode *, expr_t, ExprNodeLess> temporary_terms_mlv;
|
||||||
|
|
||||||
//! Temporary terms for residuals and derivatives
|
//! Temporary terms for residuals and derivatives
|
||||||
/*! Index 0 is temp. terms of residuals, index 1 for first derivatives, ... */
|
/*! Index 0 is temp. terms of residuals, index 1 for first derivatives, ... */
|
||||||
|
|
|
@ -1728,6 +1728,14 @@ StaticModel::writeDriverOutput(ostream &output, bool block) const
|
||||||
output << temporary_terms_derivative.size() << "; ";
|
output << temporary_terms_derivative.size() << "; ";
|
||||||
output << "];" << endl;
|
output << "];" << endl;
|
||||||
|
|
||||||
|
/* Write mapping between model local variables and indices in the temporary
|
||||||
|
terms vector (dynare#1722) */
|
||||||
|
output << "M_.model_local_variables_static_tt_idxs = {" << endl;
|
||||||
|
for (auto [mlv, value] : temporary_terms_mlv)
|
||||||
|
output << " '" << symbol_table.getName(mlv->symb_id) << "', "
|
||||||
|
<< temporary_terms_idxs.at(mlv)+1 << ';' << endl;
|
||||||
|
output << "};" << endl;
|
||||||
|
|
||||||
if (!block)
|
if (!block)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue