preprocessor: write JSON output for cross refs #1387
parent
bab5d9bea1
commit
6e9e2eac40
|
@ -5446,6 +5446,89 @@ void
|
||||||
DynamicModel::writeJsonOutput(ostream &output) const
|
DynamicModel::writeJsonOutput(ostream &output) const
|
||||||
{
|
{
|
||||||
writeJsonModelEquations(output, false);
|
writeJsonModelEquations(output, false);
|
||||||
|
output << ", ";
|
||||||
|
writeJsonXrefs(output);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
DynamicModel::writeJsonXrefs(ostream &output) const
|
||||||
|
{
|
||||||
|
output << "\"xrefs\": {"
|
||||||
|
<< "\"parameters\": [";
|
||||||
|
for (map<pair<int, int>, set<int> >::const_iterator it = xref_param.begin();
|
||||||
|
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 << "]"
|
||||||
|
<< ", \"endogenous\": [";
|
||||||
|
for (map<pair<int, int>, set<int> >::const_iterator it = xref_endo.begin();
|
||||||
|
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 << "]"
|
||||||
|
<< ", \"exogenous\": [";
|
||||||
|
for (map<pair<int, int>, set<int> >::const_iterator it = xref_exo.begin();
|
||||||
|
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 << "]"
|
||||||
|
<< ", \"exogenous_deterministic\": [";
|
||||||
|
for (map<pair<int, int>, set<int> >::const_iterator it = xref_exo_det.begin();
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -245,6 +245,9 @@ public:
|
||||||
//! Write JSON prams derivatives file
|
//! Write JSON prams derivatives file
|
||||||
void writeJsonParamsDerivativesFile(ostream &output, bool writeDetails) const;
|
void writeJsonParamsDerivativesFile(ostream &output, bool writeDetails) const;
|
||||||
|
|
||||||
|
//! Write cross reference output if the xref maps have been filed
|
||||||
|
void writeJsonXrefs(ostream &output) 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;
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ main2(stringstream &in, string &basename, bool debug, bool clear_all, bool clear
|
||||||
mod_file->writeJsonOutput(basename, json, json_output_mode, onlyjson);
|
mod_file->writeJsonOutput(basename, json, json_output_mode, onlyjson);
|
||||||
|
|
||||||
// Perform transformations on the model (creation of auxiliary vars and equations)
|
// Perform transformations on the model (creation of auxiliary vars and equations)
|
||||||
mod_file->transformPass(nostrict, compute_xrefs);
|
mod_file->transformPass(nostrict, compute_xrefs || json == transformpass);
|
||||||
if (json == transformpass)
|
if (json == transformpass)
|
||||||
mod_file->writeJsonOutput(basename, json, json_output_mode, onlyjson);
|
mod_file->writeJsonOutput(basename, json, json_output_mode, onlyjson);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue