preprocessor: clean up xref JSON printing
parent
0bfc70676f
commit
dad94a7d58
|
@ -5536,84 +5536,43 @@ DynamicModel::writeJsonOutput(ostream &output) const
|
||||||
writeJsonXrefs(output);
|
writeJsonXrefs(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
DynamicModel::writeJsonXrefsHelper(ostream &output, const map<pair<int, int>, set<int> > &xrefs) const
|
||||||
|
{
|
||||||
|
for (map<pair<int, int>, set<int> >::const_iterator it = xrefs.begin();
|
||||||
|
it != xrefs.end(); it++)
|
||||||
|
{
|
||||||
|
if (it != xrefs.begin())
|
||||||
|
output << ", ";
|
||||||
|
output << "{\"name\": \"" << symbol_table.getName(it->first.first) << "\""
|
||||||
|
<< ", \"shift\": " << it->first.second
|
||||||
|
<< ", \"equations\": [";
|
||||||
|
for (set<int>::const_iterator it1 = it->second.begin();
|
||||||
|
it1 != it->second.end(); it1++)
|
||||||
|
{
|
||||||
|
if (it1 != it->second.begin())
|
||||||
|
output << ", ";
|
||||||
|
output << *it1 + 1;
|
||||||
|
}
|
||||||
|
output << "]}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicModel::writeJsonXrefs(ostream &output) const
|
DynamicModel::writeJsonXrefs(ostream &output) const
|
||||||
{
|
{
|
||||||
output << "\"xrefs\": {"
|
output << "\"xrefs\": {"
|
||||||
<< "\"parameters\": [";
|
<< "\"parameters\": [";
|
||||||
for (map<pair<int, int>, set<int> >::const_iterator it = xref_param.begin();
|
writeJsonXrefsHelper(output, xref_param);
|
||||||
it != xref_param.end(); it++)
|
|
||||||
{
|
|
||||||
if (it != xref_param.begin())
|
|
||||||
output << ", ";
|
|
||||||
output << "{\"parameter\": \"" << symbol_table.getName(it->first.first) << "\""
|
|
||||||
<< ", \"equations\": [";
|
|
||||||
for (set<int>::const_iterator it1 = it->second.begin();
|
|
||||||
it1 != it->second.end(); it1++)
|
|
||||||
{
|
|
||||||
if (it1 != it->second.begin())
|
|
||||||
output << ", ";
|
|
||||||
output << *it1 + 1;
|
|
||||||
}
|
|
||||||
output << "]}";
|
|
||||||
}
|
|
||||||
output << "]"
|
output << "]"
|
||||||
<< ", \"endogenous\": [";
|
<< ", \"endogenous\": [";
|
||||||
for (map<pair<int, int>, set<int> >::const_iterator it = xref_endo.begin();
|
writeJsonXrefsHelper(output, xref_endo);
|
||||||
it != xref_endo.end(); it++)
|
|
||||||
{
|
|
||||||
if (it != xref_endo.begin())
|
|
||||||
output << ", ";
|
|
||||||
output << "{\"endogenous\": \"" << symbol_table.getName(it->first.first) << "\""
|
|
||||||
<< ", \"shift\": " << it->first.second
|
|
||||||
<< ", \"equations\": [";
|
|
||||||
for (set<int>::const_iterator it1 = it->second.begin();
|
|
||||||
it1 != it->second.end(); it1++)
|
|
||||||
{
|
|
||||||
if (it1 != it->second.begin())
|
|
||||||
output << ", ";
|
|
||||||
output << *it1 + 1;
|
|
||||||
}
|
|
||||||
output << "]}";
|
|
||||||
}
|
|
||||||
output << "]"
|
output << "]"
|
||||||
<< ", \"exogenous\": [";
|
<< ", \"exogenous\": [";
|
||||||
for (map<pair<int, int>, set<int> >::const_iterator it = xref_exo.begin();
|
writeJsonXrefsHelper(output, xref_exo);
|
||||||
it != xref_exo.end(); it++)
|
|
||||||
{
|
|
||||||
if (it != xref_exo.begin())
|
|
||||||
output << ", ";
|
|
||||||
output << "{\"exogenous\": \"" << symbol_table.getName(it->first.first) << "\""
|
|
||||||
<< ", \"shift\": " << it->first.second
|
|
||||||
<< ", \"equations\": [";
|
|
||||||
for (set<int>::const_iterator it1 = it->second.begin();
|
|
||||||
it1 != it->second.end(); it1++)
|
|
||||||
{
|
|
||||||
if (it1 != it->second.begin())
|
|
||||||
output << ", ";
|
|
||||||
output << *it1 + 1;
|
|
||||||
}
|
|
||||||
output << "]}";
|
|
||||||
}
|
|
||||||
output << "]"
|
output << "]"
|
||||||
<< ", \"exogenous_deterministic\": [";
|
<< ", \"exogenous_deterministic\": [";
|
||||||
for (map<pair<int, int>, set<int> >::const_iterator it = xref_exo_det.begin();
|
writeJsonXrefsHelper(output, xref_exo_det);
|
||||||
it != xref_exo_det.end(); it++)
|
|
||||||
{
|
|
||||||
if (it != xref_exo_det.begin())
|
|
||||||
output << ", ";
|
|
||||||
output << "{\"exogenous_det\": \"" << symbol_table.getName(it->first.first) << "\""
|
|
||||||
<< ", \"shift\": " << it->first.second
|
|
||||||
<< ", \"equations\": [";
|
|
||||||
for (set<int>::const_iterator it1 = it->second.begin();
|
|
||||||
it1 != it->second.end(); it1++)
|
|
||||||
{
|
|
||||||
if (it1 != it->second.begin())
|
|
||||||
output << ", ";
|
|
||||||
output << *it1 + 1;
|
|
||||||
}
|
|
||||||
output << "]}";
|
|
||||||
}
|
|
||||||
output << "]}" << endl;
|
output << "]}" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -264,6 +264,7 @@ public:
|
||||||
|
|
||||||
//! Write cross reference output if the xref maps have been filed
|
//! Write cross reference output if the xref maps have been filed
|
||||||
void writeJsonXrefs(ostream &output) const;
|
void writeJsonXrefs(ostream &output) const;
|
||||||
|
void writeJsonXrefsHelper(ostream &output, const map<pair<int, int>, set<int> > &xrefs) const;
|
||||||
|
|
||||||
//! Return true if the hessian is equal to zero
|
//! Return true if the hessian is equal to zero
|
||||||
inline bool checkHessianZero() const;
|
inline bool checkHessianZero() const;
|
||||||
|
|
Loading…
Reference in New Issue