preprocessor: write certain variables from M_ to JSON output
parent
8b63e53d68
commit
c59b6ab035
|
@ -5544,6 +5544,76 @@ DynamicModel::writeJsonOriginalModelOutput(ostream &output) const
|
||||||
writeJsonModelEquations(output, false);
|
writeJsonModelEquations(output, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
DynamicModel::writeJsonDynamicModelInfo(ostream &output) const
|
||||||
|
{
|
||||||
|
output << "\"model_info\": {"
|
||||||
|
<< "\"lead_lag_incidence\": [";
|
||||||
|
// Loop on endogenous variables
|
||||||
|
int nstatic = 0,
|
||||||
|
nfwrd = 0,
|
||||||
|
npred = 0,
|
||||||
|
nboth = 0;
|
||||||
|
for (int endoID = 0; endoID < symbol_table.endo_nbr(); endoID++)
|
||||||
|
{
|
||||||
|
if (endoID != 0)
|
||||||
|
output << ",";
|
||||||
|
output << "[";
|
||||||
|
int sstatic = 1,
|
||||||
|
sfwrd = 0,
|
||||||
|
spred = 0,
|
||||||
|
sboth = 0;
|
||||||
|
// Loop on periods
|
||||||
|
for (int lag = -max_endo_lag; lag <= max_endo_lead; lag++)
|
||||||
|
{
|
||||||
|
// Print variableID if exists with current period, otherwise print 0
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (lag != -max_endo_lag)
|
||||||
|
output << ",";
|
||||||
|
int varID = getDerivID(symbol_table.getID(eEndogenous, endoID), lag);
|
||||||
|
output << " " << getDynJacobianCol(varID) + 1;
|
||||||
|
if (lag == -1)
|
||||||
|
{
|
||||||
|
sstatic = 0;
|
||||||
|
spred = 1;
|
||||||
|
}
|
||||||
|
else if (lag == 1)
|
||||||
|
{
|
||||||
|
if (spred == 1)
|
||||||
|
{
|
||||||
|
sboth = 1;
|
||||||
|
spred = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sstatic = 0;
|
||||||
|
sfwrd = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (UnknownDerivIDException &e)
|
||||||
|
{
|
||||||
|
output << " 0";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nstatic += sstatic;
|
||||||
|
nfwrd += sfwrd;
|
||||||
|
npred += spred;
|
||||||
|
nboth += sboth;
|
||||||
|
output << "]";
|
||||||
|
}
|
||||||
|
output << "], "
|
||||||
|
<< "\"nstatic\": " << nstatic << ", "
|
||||||
|
<< "\"nfwrd\": " << nfwrd << ", "
|
||||||
|
<< "\"npred\": " << npred << ", "
|
||||||
|
<< "\"nboth\": " << nboth << ", "
|
||||||
|
<< "\"nsfwrd\": " << nfwrd+nboth << ", "
|
||||||
|
<< "\"nspred\": " << npred+nboth << ", "
|
||||||
|
<< "\"ndynamic\": " << npred+nboth+nfwrd << endl;
|
||||||
|
output << "}";
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) const
|
DynamicModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -242,6 +242,9 @@ public:
|
||||||
//! Write JSON Output representation of original dynamic model
|
//! Write JSON Output representation of original dynamic model
|
||||||
void writeJsonOriginalModelOutput(ostream &output) const;
|
void writeJsonOriginalModelOutput(ostream &output) const;
|
||||||
|
|
||||||
|
//! Write JSON Output representation of model info (useful stuff from M_)
|
||||||
|
void writeJsonDynamicModelInfo(ostream &output) const;
|
||||||
|
|
||||||
//! Write JSON Output representation of dynamic model after computing pass
|
//! Write JSON Output representation of dynamic model after computing pass
|
||||||
void writeJsonComputingPassOutput(ostream &output, bool writeDetails) const;
|
void writeJsonComputingPassOutput(ostream &output, bool writeDetails) const;
|
||||||
|
|
||||||
|
|
12
ModFile.cc
12
ModFile.cc
|
@ -1270,7 +1270,7 @@ ModFile::writeJsonOutput(const string &basename, JsonOutputPointType json, JsonF
|
||||||
if (json == parsing || json == checkpass)
|
if (json == parsing || json == checkpass)
|
||||||
symbol_table.freeze();
|
symbol_table.freeze();
|
||||||
|
|
||||||
writeJsonOutputParsingCheck(basename, json_output_mode, json == transformpass);
|
writeJsonOutputParsingCheck(basename, json_output_mode, json == transformpass, json == computingpass);
|
||||||
|
|
||||||
if (json == parsing || json == checkpass)
|
if (json == parsing || json == checkpass)
|
||||||
symbol_table.unfreeze();
|
symbol_table.unfreeze();
|
||||||
|
@ -1302,7 +1302,7 @@ ModFile::writeJsonOutput(const string &basename, JsonOutputPointType json, JsonF
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ModFile::writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType json_output_mode, bool transformpass) const
|
ModFile::writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType json_output_mode, bool transformpass, bool computingpass) const
|
||||||
{
|
{
|
||||||
ostringstream output;
|
ostringstream output;
|
||||||
output << "{" << endl;
|
output << "{" << endl;
|
||||||
|
@ -1323,6 +1323,12 @@ ModFile::writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType
|
||||||
}
|
}
|
||||||
output << "]" << endl;
|
output << "]" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (computingpass)
|
||||||
|
{
|
||||||
|
output << ",";
|
||||||
|
dynamic_model.writeJsonDynamicModelInfo(output);
|
||||||
|
}
|
||||||
output << "}" << endl;
|
output << "}" << endl;
|
||||||
|
|
||||||
ostringstream original_model_output;
|
ostringstream original_model_output;
|
||||||
|
@ -1338,7 +1344,7 @@ ModFile::writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType
|
||||||
{
|
{
|
||||||
cout << output.str();
|
cout << output.str();
|
||||||
if (!original_model_output.str().empty())
|
if (!original_model_output.str().empty())
|
||||||
cout << original_model_output.str();
|
cout << "," << original_model_output.str();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -118,7 +118,7 @@ private:
|
||||||
//! Warnings Encountered
|
//! Warnings Encountered
|
||||||
WarningConsolidation &warnings;
|
WarningConsolidation &warnings;
|
||||||
//! Functions used in writing of JSON outut. See writeJsonOutput
|
//! Functions used in writing of JSON outut. See writeJsonOutput
|
||||||
void writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType json_output_mode, bool transformpass) const;
|
void writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType json_output_mode, bool transformpass, bool computingpass) const;
|
||||||
void writeJsonComputingPassOutput(const string &basename, JsonFileOutputType json_output_mode, bool jsonprintderivdetail) const;
|
void writeJsonComputingPassOutput(const string &basename, JsonFileOutputType json_output_mode, bool jsonprintderivdetail) const;
|
||||||
void writeJsonFileHelper(string &fname, ostringstream &output) const;
|
void writeJsonFileHelper(string &fname, ostringstream &output) const;
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in New Issue