Merge branch 'master' into ecb-master

issue#70
Stéphane Adjemian (Charybdis) 2017-06-29 13:33:29 +02:00
commit 9b4cb8b8ca
8 changed files with 311 additions and 171 deletions

View File

@ -510,7 +510,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &dynamic_basename) const
} }
else else
{ {
cerr << "Type missmatch for equation " << equation_ID+1 << "\n"; cerr << "Type mismatch for equation " << equation_ID+1 << "\n";
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
output << ";\n"; output << ";\n";
@ -5647,6 +5647,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
{ {
@ -5691,13 +5761,17 @@ DynamicModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) c
expr_t d1 = it->second; expr_t d1 = it->second;
if (writeDetails) if (writeDetails)
jacobian_output << "{\"eq\": " << eq + 1 jacobian_output << "{\"eq\": " << eq + 1;
<< ", \"var\": \"" << symbol_table.getName(getSymbIDByDerivID(var)) << "\""
<< ", \"lag\": " << getLagByDerivID(var);
else else
jacobian_output << "{\"row\": " << eq + 1; jacobian_output << "{\"row\": " << eq + 1;
jacobian_output << ", \"col\": " << col + 1
<< ", \"val\": \""; jacobian_output << ", \"col\": " << col + 1;
if (writeDetails)
jacobian_output << ", \"var\": \"" << symbol_table.getName(getSymbIDByDerivID(var)) << "\""
<< ", \"shift\": " << getLagByDerivID(var);
jacobian_output << ", \"val\": \"";
d1->writeJsonOutput(jacobian_output, temp_term_union, tef_terms); d1->writeJsonOutput(jacobian_output, temp_term_union, tef_terms);
jacobian_output << "\"}" << endl; jacobian_output << "\"}" << endl;
} }
@ -5728,19 +5802,22 @@ DynamicModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) c
int col_nb_sym = id2 * dynJacobianColsNbr + id1; int col_nb_sym = id2 * dynJacobianColsNbr + id1;
if (writeDetails) if (writeDetails)
hessian_output << "{\"eq\": " << eq + 1 hessian_output << "{\"eq\": " << eq + 1;
<< ", \"var1\": \"" << symbol_table.getName(getSymbIDByDerivID(var1)) << "\""
<< ", \"lag1\": " << getLagByDerivID(var1)
<< ", \"var2\": \"" << symbol_table.getName(getSymbIDByDerivID(var2)) << "\""
<< ", \"lag2\": " << getLagByDerivID(var2);
else else
hessian_output << "{\"row\": " << eq + 1; hessian_output << "{\"row\": " << eq + 1;
hessian_output << ", \"col\": [" << col_nb + 1; hessian_output << ", \"col\": [" << col_nb + 1;
if (id1 != id2) if (id1 != id2)
hessian_output << ", " << col_nb_sym + 1; hessian_output << ", " << col_nb_sym + 1;
hessian_output << "]" hessian_output << "]";
<< ", \"val\": \"";
if (writeDetails)
hessian_output << ", \"var1\": \"" << symbol_table.getName(getSymbIDByDerivID(var1)) << "\""
<< ", \"shift1\": " << getLagByDerivID(var1)
<< ", \"var2\": \"" << symbol_table.getName(getSymbIDByDerivID(var2)) << "\""
<< ", \"shift2\": " << getLagByDerivID(var2);
hessian_output << ", \"val\": \"";
d2->writeJsonOutput(hessian_output, temp_term_union, tef_terms); d2->writeJsonOutput(hessian_output, temp_term_union, tef_terms);
hessian_output << "\"}" << endl; hessian_output << "\"}" << endl;
} }
@ -5768,13 +5845,7 @@ DynamicModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) c
expr_t d3 = it->second; expr_t d3 = it->second;
if (writeDetails) if (writeDetails)
third_derivatives_output << "{\"eq\": " << eq + 1 third_derivatives_output << "{\"eq\": " << eq + 1;
<< ", \"var1\": \"" << symbol_table.getName(getSymbIDByDerivID(var1)) << "\""
<< ", \"lag1\": " << getLagByDerivID(var1)
<< ", \"var2\": \"" << symbol_table.getName(getSymbIDByDerivID(var2)) << "\""
<< ", \"lag2\": " << getLagByDerivID(var2)
<< ", \"var3\": \"" << symbol_table.getName(getSymbIDByDerivID(var3)) << "\""
<< ", \"lag3\": " << getLagByDerivID(var3);
else else
third_derivatives_output << "{\"row\": " << eq + 1; third_derivatives_output << "{\"row\": " << eq + 1;
@ -5796,17 +5867,26 @@ DynamicModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) c
third_derivatives_output << ", "; third_derivatives_output << ", ";
third_derivatives_output << *it2 + 1; third_derivatives_output << *it2 + 1;
} }
third_derivatives_output << "]" third_derivatives_output << "]";
<< ", \"val\": \"";
if (writeDetails)
third_derivatives_output << ", \"var1\": \"" << symbol_table.getName(getSymbIDByDerivID(var1)) << "\""
<< ", \"shift1\": " << getLagByDerivID(var1)
<< ", \"var2\": \"" << symbol_table.getName(getSymbIDByDerivID(var2)) << "\""
<< ", \"shift2\": " << getLagByDerivID(var2)
<< ", \"var3\": \"" << symbol_table.getName(getSymbIDByDerivID(var3)) << "\""
<< ", \"shift3\": " << getLagByDerivID(var3);
third_derivatives_output << ", \"val\": \"";
d3->writeJsonOutput(third_derivatives_output, temp_term_union, tef_terms); d3->writeJsonOutput(third_derivatives_output, temp_term_union, tef_terms);
third_derivatives_output << "\"}" << endl; third_derivatives_output << "\"}" << endl;
} }
third_derivatives_output << "]}"; third_derivatives_output << "]}";
if (writeDetails) if (writeDetails)
output << "\"dynamic_model_derivative_details\": {"; output << "\"dynamic_model\": {";
else else
output << "\"dynamic_model_derivatives\": {"; output << "\"dynamic_model_simple\": {";
output << model_local_vars_output.str() output << model_local_vars_output.str()
<< ", " << model_output.str() << ", " << model_output.str()
<< ", " << jacobian_output.str() << ", " << jacobian_output.str()
@ -5856,12 +5936,16 @@ DynamicModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails)
int param_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param)) + 1; int param_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param)) + 1;
if (writeDetails) if (writeDetails)
jacobian_output << "{\"eq\": " << eq + 1 jacobian_output << "{\"eq\": " << eq + 1;
<< ", \"param\": \"" << symbol_table.getName(getSymbIDByDerivID(param)) << "\"";
else else
jacobian_output << "{\"row\": " << eq + 1; jacobian_output << "{\"row\": " << eq + 1;
jacobian_output << ", \"param_col\": " << param_col + 1
<< ", \"val\": \""; jacobian_output << ", \"param_col\": " << param_col + 1;
if (writeDetails)
jacobian_output << ", \"param\": \"" << symbol_table.getName(getSymbIDByDerivID(param)) << "\"";
jacobian_output << ", \"val\": \"";
d1->writeJsonOutput(jacobian_output, params_derivs_temporary_terms, tef_terms); d1->writeJsonOutput(jacobian_output, params_derivs_temporary_terms, tef_terms);
jacobian_output << "\"}" << endl; jacobian_output << "\"}" << endl;
} }
@ -5886,15 +5970,19 @@ DynamicModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails)
int param_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param)) + 1; int param_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param)) + 1;
if (writeDetails) if (writeDetails)
hessian_output << "{\"eq\": " << eq + 1 hessian_output << "{\"eq\": " << eq + 1;
<< ", \"var\": \"" << symbol_table.getName(getSymbIDByDerivID(var)) << "\""
<< ", \"lag\": " << getLagByDerivID(var)
<< ", \"param\": \"" << symbol_table.getName(getSymbIDByDerivID(param)) << "\"";
else else
hessian_output << "{\"row\": " << eq + 1; hessian_output << "{\"row\": " << eq + 1;
hessian_output << ", \"var_col\": " << var_col + 1 hessian_output << ", \"var_col\": " << var_col + 1
<< ", \"param_col\": " << param_col + 1 << ", \"param_col\": " << param_col + 1;
<< ", \"val\": \"";
if (writeDetails)
hessian_output << ", \"var\": \"" << symbol_table.getName(getSymbIDByDerivID(var)) << "\""
<< ", \"lag\": " << getLagByDerivID(var)
<< ", \"param\": \"" << symbol_table.getName(getSymbIDByDerivID(param)) << "\"";
hessian_output << ", \"val\": \"";
d2->writeJsonOutput(hessian_output, params_derivs_temporary_terms, tef_terms); d2->writeJsonOutput(hessian_output, params_derivs_temporary_terms, tef_terms);
hessian_output << "\"}" << endl; hessian_output << "\"}" << endl;
} }
@ -5920,14 +6008,17 @@ DynamicModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails)
int param2_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param2)) + 1; int param2_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param2)) + 1;
if (writeDetails) if (writeDetails)
hessian1_output << "{\"eq\": " << eq + 1 hessian1_output << "{\"eq\": " << eq + 1;
<< ", \"param1\": \"" << symbol_table.getName(getSymbIDByDerivID(param1)) << "\""
<< ", \"param2\": \"" << symbol_table.getName(getSymbIDByDerivID(param2)) << "\"";
else else
hessian1_output << "{\"row\": " << eq + 1; hessian1_output << "{\"row\": " << eq + 1;
hessian1_output << ", \"param1_col\": " << param1_col + 1 hessian1_output << ", \"param1_col\": " << param1_col + 1
<< ", \"param2_col\": " << param2_col + 1 << ", \"param2_col\": " << param2_col + 1;
<< ", \"val\": \"";
if (writeDetails)
hessian1_output << ", \"param1\": \"" << symbol_table.getName(getSymbIDByDerivID(param1)) << "\""
<< ", \"param2\": \"" << symbol_table.getName(getSymbIDByDerivID(param2)) << "\"";
hessian1_output << ", \"val\": \"";
d2->writeJsonOutput(hessian1_output, params_derivs_temporary_terms, tef_terms); d2->writeJsonOutput(hessian1_output, params_derivs_temporary_terms, tef_terms);
hessian1_output << "\"}" << endl; hessian1_output << "\"}" << endl;
} }
@ -5955,17 +6046,21 @@ DynamicModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails)
int param2_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param2)) + 1; int param2_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param2)) + 1;
if (writeDetails) if (writeDetails)
third_derivs_output << "{\"eq\": " << eq + 1 third_derivs_output << "{\"eq\": " << eq + 1;
<< ", \"var\": \"" << symbol_table.getName(var) << "\"" else
third_derivs_output << "{\"row\": " << eq + 1;
third_derivs_output << ", \"var_col\": " << var_col + 1
<< ", \"param1_col\": " << param1_col + 1
<< ", \"param2_col\": " << param2_col + 1;
if (writeDetails)
third_derivs_output << ", \"var\": \"" << symbol_table.getName(var) << "\""
<< ", \"lag\": " << getLagByDerivID(var) << ", \"lag\": " << getLagByDerivID(var)
<< ", \"param1\": \"" << symbol_table.getName(getSymbIDByDerivID(param1)) << "\"" << ", \"param1\": \"" << symbol_table.getName(getSymbIDByDerivID(param1)) << "\""
<< ", \"param2\": \"" << symbol_table.getName(getSymbIDByDerivID(param2)) << "\""; << ", \"param2\": \"" << symbol_table.getName(getSymbIDByDerivID(param2)) << "\"";
else
third_derivs_output << "{\"row\": " << eq + 1; third_derivs_output << ", \"val\": \"";
third_derivs_output << ", \"var_col\": " << var_col + 1
<< ", \"param1_col\": " << param1_col + 1
<< ", \"param2_col\": " << param2_col + 1
<< ", \"val\": \"";
d2->writeJsonOutput(third_derivs_output, params_derivs_temporary_terms, tef_terms); d2->writeJsonOutput(third_derivs_output, params_derivs_temporary_terms, tef_terms);
third_derivs_output << "\"}" << endl; third_derivs_output << "\"}" << endl;
} }
@ -5994,27 +6089,31 @@ DynamicModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails)
int param_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param)) + 1; int param_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param)) + 1;
if (writeDetails) if (writeDetails)
third_derivs1_output << "{\"eq\": " << eq + 1 third_derivs1_output << "{\"eq\": " << eq + 1;
<< ", \"var1\": \"" << symbol_table.getName(getSymbIDByDerivID(var1)) << "\"" else
third_derivs1_output << "{\"row\": " << eq + 1;
third_derivs1_output << ", \"var1_col\": " << var1_col + 1
<< ", \"var2_col\": " << var2_col + 1
<< ", \"param_col\": " << param_col + 1;
if (writeDetails)
third_derivs1_output << ", \"var1\": \"" << symbol_table.getName(getSymbIDByDerivID(var1)) << "\""
<< ", \"lag1\": " << getLagByDerivID(var1) << ", \"lag1\": " << getLagByDerivID(var1)
<< ", \"var2\": \"" << symbol_table.getName(getSymbIDByDerivID(var2)) << "\"" << ", \"var2\": \"" << symbol_table.getName(getSymbIDByDerivID(var2)) << "\""
<< ", \"lag2\": " << getLagByDerivID(var2) << ", \"lag2\": " << getLagByDerivID(var2)
<< ", \"param\": \"" << symbol_table.getName(getSymbIDByDerivID(param)) << "\""; << ", \"param\": \"" << symbol_table.getName(getSymbIDByDerivID(param)) << "\"";
else
third_derivs1_output << "{\"row\": " << eq + 1; third_derivs1_output << ", \"val\": \"";
third_derivs1_output << ", \"var1_col\": " << var1_col + 1
<< ", \"var2_col\": " << var2_col + 1
<< ", \"param_col\": " << param_col + 1
<< ", \"val\": \"";
d2->writeJsonOutput(third_derivs1_output, params_derivs_temporary_terms, tef_terms); d2->writeJsonOutput(third_derivs1_output, params_derivs_temporary_terms, tef_terms);
third_derivs1_output << "\"}" << endl; third_derivs1_output << "\"}" << endl;
} }
third_derivs1_output << "]}" << endl; third_derivs1_output << "]}" << endl;
if (writeDetails) if (writeDetails)
output << "\"dynamic_model_params_derivative_details\": {"; output << "\"dynamic_model_params_derivative\": {";
else else
output << "\"dynamic_model_params_derivatives\": {"; output << "\"dynamic_model_params_derivatives_simple\": {";
output << model_local_vars_output.str() output << model_local_vars_output.str()
<< ", " << model_output.str() << ", " << model_output.str()
<< ", " << jacobian_output.str() << ", " << jacobian_output.str()

View File

@ -247,6 +247,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;

View File

@ -45,7 +45,7 @@ void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool
#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__) #if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
, bool cygwin, bool msvc, bool mingw , bool cygwin, bool msvc, bool mingw
#endif #endif
, JsonOutputPointType json, JsonFileOutputType json_output_mode, bool onlyjson, bool jsonprintderivdetail , JsonOutputPointType json, JsonFileOutputType json_output_mode, bool onlyjson, bool jsonderivsimple
); );
void main1(char *modfile, string &basename, bool debug, bool save_macro, string &save_macro_file, void main1(char *modfile, string &basename, bool debug, bool save_macro, string &save_macro_file,
@ -62,7 +62,7 @@ usage()
#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__) #if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
<< " [cygwin] [msvc] [mingw]" << " [cygwin] [msvc] [mingw]"
#endif #endif
<< "[json=parse|check|transform|compute] [jsonstdout] [onlyjson] [jsonprintderivdetail]" << "[json=parse|check|transform|compute] [jsonstdout] [onlyjson] [jsonderivsimple]"
<< endl; << endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -118,7 +118,7 @@ main(int argc, char **argv)
JsonOutputPointType json = nojson; JsonOutputPointType json = nojson;
JsonFileOutputType json_output_mode = file; JsonFileOutputType json_output_mode = file;
bool onlyjson = false; bool onlyjson = false;
bool jsonprintderivdetail = false; bool jsonderivsimple = false;
LanguageOutputType language = matlab; LanguageOutputType language = matlab;
// Parse options // Parse options
@ -251,7 +251,7 @@ main(int argc, char **argv)
{ {
if (strlen(argv[arg]) <= 7 || argv[arg][6] != '=') if (strlen(argv[arg]) <= 7 || argv[arg][6] != '=')
{ {
cerr << "Incorrect syntax for ouput option" << endl; cerr << "Incorrect syntax for output option" << endl;
usage(); usage();
} }
if (strlen(argv[arg]) == 14 && !strncmp(argv[arg] + 7, "dynamic", 7)) if (strlen(argv[arg]) == 14 && !strncmp(argv[arg] + 7, "dynamic", 7))
@ -264,7 +264,7 @@ main(int argc, char **argv)
output_mode = third; output_mode = third;
else else
{ {
cerr << "Incorrect syntax for ouput option" << endl; cerr << "Incorrect syntax for output option" << endl;
usage(); usage();
} }
} }
@ -301,8 +301,8 @@ main(int argc, char **argv)
json_output_mode = standardout; json_output_mode = standardout;
else if (!strcmp(argv[arg], "onlyjson")) else if (!strcmp(argv[arg], "onlyjson"))
onlyjson = true; onlyjson = true;
else if (!strcmp(argv[arg], "jsonprintderivdetail")) else if (!strcmp(argv[arg], "jsonderivsimple"))
jsonprintderivdetail = true; jsonderivsimple = true;
else if (strlen(argv[arg]) >= 4 && !strncmp(argv[arg], "json", 4)) else if (strlen(argv[arg]) >= 4 && !strncmp(argv[arg], "json", 4))
{ {
if (strlen(argv[arg]) <= 5 || argv[arg][4] != '=') if (strlen(argv[arg]) <= 5 || argv[arg][4] != '=')
@ -370,7 +370,7 @@ main(int argc, char **argv)
#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__) #if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
, cygwin, msvc, mingw , cygwin, msvc, mingw
#endif #endif
, json, json_output_mode, onlyjson, jsonprintderivdetail , json, json_output_mode, onlyjson, jsonderivsimple
); );
return EXIT_SUCCESS; return EXIT_SUCCESS;

View File

@ -34,7 +34,7 @@ main2(stringstream &in, string &basename, bool debug, bool clear_all, bool clear
#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__) #if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
, bool cygwin, bool msvc, bool mingw , bool cygwin, bool msvc, bool mingw
#endif #endif
, JsonOutputPointType json, JsonFileOutputType json_output_mode, bool onlyjson, bool jsonprintderivdetail , JsonOutputPointType json, JsonFileOutputType json_output_mode, bool onlyjson, bool jsonderivsimple
) )
{ {
ParsingDriver p(warnings, nostrict); ParsingDriver p(warnings, nostrict);
@ -60,7 +60,7 @@ main2(stringstream &in, string &basename, bool debug, bool clear_all, bool clear
// Do computations // Do computations
mod_file->computingPass(no_tmp_terms, output_mode, params_derivs_order); mod_file->computingPass(no_tmp_terms, output_mode, params_derivs_order);
if (json == computingpass) if (json == computingpass)
mod_file->writeJsonOutput(basename, json, json_output_mode, onlyjson, jsonprintderivdetail); mod_file->writeJsonOutput(basename, json, json_output_mode, onlyjson, jsonderivsimple);
// Write outputs // Write outputs
if (output_mode != none) if (output_mode != none)

View File

@ -86,7 +86,7 @@ html-local:
endif endif
clean-local: clean-local:
rm -rf ../matlab/preprocessor* rm -rf ../matlab/preprocessor* ../julia/preprocessor*
rm -rf doc/html/ rm -rf doc/html/
EXTRA_DIST = $(BUILT_SOURCES) Doxyfile EXTRA_DIST = $(BUILT_SOURCES) Doxyfile

View File

@ -232,7 +232,7 @@ ModFile::checkPass(bool nostrict)
if (mod_file_struct.dsge_prior_weight_initialized && mod_file_struct.dsge_prior_weight_in_estimated_params) if (mod_file_struct.dsge_prior_weight_initialized && mod_file_struct.dsge_prior_weight_in_estimated_params)
{ {
cerr << "ERROR: dsge_prior_weight cannot be both initalized and estimated." << endl; cerr << "ERROR: dsge_prior_weight cannot be both initialized and estimated." << endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
@ -1290,7 +1290,7 @@ ModFile::writeExternalFilesJulia(const string &basename, FileOutputType output)
} }
void void
ModFile::writeJsonOutput(const string &basename, JsonOutputPointType json, JsonFileOutputType json_output_mode, bool onlyjson, bool jsonprintderivdetail) ModFile::writeJsonOutput(const string &basename, JsonOutputPointType json, JsonFileOutputType json_output_mode, bool onlyjson, bool jsonderivsimple)
{ {
if (json == nojson) if (json == nojson)
return; return;
@ -1298,13 +1298,21 @@ 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); if (json_output_mode == standardout)
cout << "//-- BEGIN JSON --// " << endl
<< "{" << endl;
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();
if (json == computingpass) if (json == computingpass)
writeJsonComputingPassOutput(basename, json_output_mode, jsonprintderivdetail); writeJsonComputingPassOutput(basename, json_output_mode, jsonderivsimple);
if (json_output_mode == standardout)
cout << "}" << endl
<< "//-- END JSON --// " << endl;
switch (json) switch (json)
{ {
@ -1330,7 +1338,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;
@ -1351,11 +1359,17 @@ 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;
original_model_output << ""; original_model_output << "";
if (transformpass) if (transformpass || computingpass)
{ {
original_model_output << "{"; original_model_output << "{";
original_model.writeJsonOriginalModelOutput(original_model_output); original_model.writeJsonOriginalModelOutput(original_model_output);
@ -1364,9 +1378,13 @@ ModFile::writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType
if (json_output_mode == standardout) if (json_output_mode == standardout)
{ {
if (transformpass || computingpass)
cout << "\"transformed_model\": ";
else
cout << "\"model\": ";
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\": " << original_model_output.str();
} }
else else
{ {
@ -1418,83 +1436,77 @@ ModFile::writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType
} }
void void
ModFile::writeJsonComputingPassOutput(const string &basename, JsonFileOutputType json_output_mode, bool jsonprintderivdetail) const ModFile::writeJsonComputingPassOutput(const string &basename, JsonFileOutputType json_output_mode, bool jsonderivsimple) const
{ {
ostringstream static_output, static_detail_output; ostringstream static_output, static_simple_output;
static_output << "{"; static_output << "{";
static_model.writeJsonComputingPassOutput(static_output, false); static_model.writeJsonComputingPassOutput(static_output, true);
static_output << "}" << endl; static_output << "}" << endl;
ostringstream dynamic_output, dynamic_detail_output; ostringstream dynamic_output, dynamic_simple_output;
dynamic_output << "{"; dynamic_output << "{";
dynamic_model.writeJsonComputingPassOutput(dynamic_output, false); dynamic_model.writeJsonComputingPassOutput(dynamic_output, true);
dynamic_output << "}" << endl; dynamic_output << "}" << endl;
ostringstream original_model_output; ostringstream tmp_out, static_paramsd_output, static_paramsd_simple_output;
original_model_output << "{";
original_model.writeJsonOriginalModelOutput(original_model_output);
original_model_output << "}" << endl;
ostringstream tmp_out, static_paramsd_output, static_paramsd_detail_output;
tmp_out << ""; tmp_out << "";
static_paramsd_output << ""; static_paramsd_output << "";
static_paramsd_detail_output << ""; static_paramsd_simple_output << "";
static_model.writeJsonParamsDerivativesFile(tmp_out, false); static_model.writeJsonParamsDerivativesFile(tmp_out, true);
if (!tmp_out.str().empty()) if (!tmp_out.str().empty())
static_paramsd_output << "{" << tmp_out.str() << "}" << endl; static_paramsd_output << "{" << tmp_out.str() << "}" << endl;
ostringstream tmp1_out, dynamic_paramsd_output, dynamic_paramsd_detail_output; ostringstream tmp1_out, dynamic_paramsd_output, dynamic_paramsd_simple_output;
tmp1_out << ""; tmp1_out << "";
dynamic_paramsd_output << ""; dynamic_paramsd_output << "";
dynamic_paramsd_detail_output << ""; dynamic_paramsd_simple_output << "";
dynamic_model.writeJsonParamsDerivativesFile(tmp1_out, false); dynamic_model.writeJsonParamsDerivativesFile(tmp1_out, true);
if (!tmp1_out.str().empty()) if (!tmp1_out.str().empty())
dynamic_paramsd_output << "{" << tmp1_out.str() << "}" << endl; dynamic_paramsd_output << "{" << tmp1_out.str() << "}" << endl;
if (jsonprintderivdetail) if (jsonderivsimple)
{ {
static_detail_output << "{"; static_simple_output << "{";
static_model.writeJsonComputingPassOutput(static_detail_output, true); static_model.writeJsonComputingPassOutput(static_simple_output, false);
static_detail_output << "}"; static_simple_output << "}";
dynamic_detail_output << "{"; dynamic_simple_output << "{";
dynamic_model.writeJsonComputingPassOutput(dynamic_detail_output, true); dynamic_model.writeJsonComputingPassOutput(dynamic_simple_output, false);
dynamic_detail_output << "}"; dynamic_simple_output << "}";
ostringstream tmpd_out, tmpd1_out; ostringstream tmpd_out, tmpd1_out;
tmpd_out << ""; tmpd_out << "";
tmpd1_out << ""; tmpd1_out << "";
static_model.writeJsonParamsDerivativesFile(tmpd_out, true); static_model.writeJsonParamsDerivativesFile(tmpd_out, true);
if (!tmpd_out.str().empty()) if (!tmpd_out.str().empty())
static_paramsd_detail_output << "{" << tmpd_out.str() << "}" << endl; static_paramsd_simple_output << "{" << tmpd_out.str() << "}" << endl;
dynamic_model.writeJsonParamsDerivativesFile(tmpd1_out, true); dynamic_model.writeJsonParamsDerivativesFile(tmpd1_out, true);
if (!tmpd1_out.str().empty()) if (!tmpd1_out.str().empty())
dynamic_paramsd_detail_output << "{" << tmpd1_out.str() << "}" << endl; dynamic_paramsd_simple_output << "{" << tmpd1_out.str() << "}" << endl;
} }
if (json_output_mode == standardout) if (json_output_mode == standardout)
{ {
cout << original_model_output.str() << endl cout << ", \"static_model\": " << static_output.str() << endl
<< static_output.str() << endl << ", \"dynamic_model\": " << dynamic_output.str() << endl;
<< dynamic_output.str() << endl;
if (!static_paramsd_output.str().empty()) if (!static_paramsd_output.str().empty())
cout << static_paramsd_output.str() << endl; cout << ", \"static_params_deriv\": " << static_paramsd_output.str() << endl;
if (!dynamic_paramsd_output.str().empty()) if (!dynamic_paramsd_output.str().empty())
cout << dynamic_paramsd_output.str() << endl; cout << ", \"dynamic_params_deriv\":" << dynamic_paramsd_output.str() << endl;
if (jsonprintderivdetail) if (jsonderivsimple)
{ {
cout << static_detail_output.str() << endl cout << ", \"static_model_simple\": " << static_simple_output.str() << endl
<< dynamic_detail_output.str() << endl; << ", \"dynamic_model_simple\": " << dynamic_simple_output.str() << endl;
if (!static_paramsd_detail_output.str().empty()) if (!static_paramsd_simple_output.str().empty())
cout << static_paramsd_detail_output.str() << endl; cout << "," << static_paramsd_simple_output.str() << endl;
if (!dynamic_paramsd_detail_output.str().empty()) if (!dynamic_paramsd_simple_output.str().empty())
cout << dynamic_paramsd_detail_output.str() << endl; cout << "," << dynamic_paramsd_simple_output.str() << endl;
} }
} }
else else
@ -1506,40 +1518,38 @@ ModFile::writeJsonComputingPassOutput(const string &basename, JsonFileOutputType
} }
string fname_original, fname_static, fname_dynamic; string fname_original, fname_static, fname_dynamic;
fname_original = basename + "_original.json";
fname_static = basename + "_static.json"; fname_static = basename + "_static.json";
fname_dynamic = basename + "_dynamic.json"; fname_dynamic = basename + "_dynamic.json";
writeJsonFileHelper(fname_original, original_model_output);
writeJsonFileHelper(fname_static, static_output); writeJsonFileHelper(fname_static, static_output);
writeJsonFileHelper(fname_dynamic, dynamic_output); writeJsonFileHelper(fname_dynamic, dynamic_output);
if (jsonprintderivdetail) if (jsonderivsimple)
{ {
string fname_static_details, fname_dynamic_details; string fname_static_simple, fname_dynamic_simple;
fname_static_details = basename + "_static_details.json"; fname_static_simple = basename + "_static_simple.json";
fname_dynamic_details = basename + "_dynamic_details.json"; fname_dynamic_simple = basename + "_dynamic_simple.json";
writeJsonFileHelper(fname_static_details, static_detail_output); writeJsonFileHelper(fname_static_simple, static_simple_output);
writeJsonFileHelper(fname_dynamic_details, dynamic_detail_output); writeJsonFileHelper(fname_dynamic_simple, dynamic_simple_output);
} }
if (!static_paramsd_output.str().empty()) if (!static_paramsd_output.str().empty())
{ {
string fname_static_params, fname_static_params_details; string fname_static_params, fname_static_params_simple;
fname_static_params = basename + "_static_params_derivs.json"; fname_static_params = basename + "_static_params_derivs.json";
fname_static_params_details = basename + "_static_params_derivs_details.json"; fname_static_params_simple = basename + "_static_params_derivs_simple.json";
writeJsonFileHelper(fname_static_params, static_paramsd_output); writeJsonFileHelper(fname_static_params, static_paramsd_output);
writeJsonFileHelper(fname_static_params_details, static_paramsd_detail_output); writeJsonFileHelper(fname_static_params_simple, static_paramsd_simple_output);
} }
if (!dynamic_paramsd_output.str().empty()) if (!dynamic_paramsd_output.str().empty())
{ {
string fname_dynamic_params, fname_dynamic_params_details; string fname_dynamic_params, fname_dynamic_params_simple;
fname_dynamic_params = basename + "_params_derivs.json"; fname_dynamic_params = basename + "_params_derivs.json";
fname_dynamic_params_details = basename + "_params_derivs_details.json"; fname_dynamic_params_simple = basename + "_params_derivs_simple.json";
writeJsonFileHelper(fname_dynamic_params, dynamic_paramsd_output); writeJsonFileHelper(fname_dynamic_params, dynamic_paramsd_output);
writeJsonFileHelper(fname_dynamic_params_details, dynamic_paramsd_detail_output); writeJsonFileHelper(fname_dynamic_params_simple, dynamic_paramsd_simple_output);
} }
} }
} }

View File

@ -118,8 +118,8 @@ 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 jsonderivsimple) const;
void writeJsonFileHelper(string &fname, ostringstream &output) const; void writeJsonFileHelper(string &fname, ostringstream &output) const;
public: public:
//! Add a statement //! Add a statement
@ -174,7 +174,7 @@ public:
//! Initially created to enable Julia to work with .mod files //! Initially created to enable Julia to work with .mod files
//! Potentially outputs ModFile after the various parts of processing (parsing, checkPass, transformPass, computingPass) //! Potentially outputs ModFile after the various parts of processing (parsing, checkPass, transformPass, computingPass)
//! Allows user of other host language platforms (python, fortran, etc) to provide support for dynare .mod files //! Allows user of other host language platforms (python, fortran, etc) to provide support for dynare .mod files
void writeJsonOutput(const string &basename, JsonOutputPointType json, JsonFileOutputType json_output_mode, bool onlyjson, bool jsonprintderivdetail = false); void writeJsonOutput(const string &basename, JsonOutputPointType json, JsonFileOutputType json_output_mode, bool onlyjson, bool jsonderivsimple = false);
}; };
#endif // ! MOD_FILE_HH #endif // ! MOD_FILE_HH

View File

@ -341,7 +341,7 @@ StaticModel::writeModelEquationsOrdered_M(const string &static_basename) const
} }
else else
{ {
cerr << "Type missmatch for equation " << equation_ID+1 << "\n"; cerr << "Type mismatch for equation " << equation_ID+1 << "\n";
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
output << ";\n"; output << ";\n";
@ -2467,12 +2467,16 @@ StaticModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) co
expr_t d1 = it->second; expr_t d1 = it->second;
if (writeDetails) if (writeDetails)
jacobian_output << "{\"eq\": " << eq + 1 jacobian_output << "{\"eq\": " << eq + 1;
<< ", \"var\": \"" << symbol_table.getName(symb_id) << "\"";
else else
jacobian_output << "{\"row\": " << eq + 1; jacobian_output << "{\"row\": " << eq + 1;
jacobian_output << ", \"col\": " << col + 1
<< ", \"val\": \""; jacobian_output << ", \"col\": " << col + 1;
if (writeDetails)
jacobian_output << ", \"var\": \"" << symbol_table.getName(symb_id) << "\"";
jacobian_output << ", \"val\": \"";
d1->writeJsonOutput(jacobian_output, temp_term_union, tef_terms); d1->writeJsonOutput(jacobian_output, temp_term_union, tef_terms);
jacobian_output << "\"}" << endl; jacobian_output << "\"}" << endl;
} }
@ -2506,13 +2510,16 @@ StaticModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) co
int col_sym = tsid2*symbol_table.endo_nbr()+tsid1; int col_sym = tsid2*symbol_table.endo_nbr()+tsid1;
if (writeDetails) if (writeDetails)
hessian_output << "{\"eq\": " << eq + 1 hessian_output << "{\"eq\": " << eq + 1;
<< ", \"var1\": \"" << symbol_table.getName(symb_id1) << "\""
<< ", \"var2\": \"" << symbol_table.getName(symb_id2) << "\"";
else else
hessian_output << "{\"row\": " << eq + 1; hessian_output << "{\"row\": " << eq + 1;
hessian_output << ", \"col\": [" << col + 1; hessian_output << ", \"col\": [" << col + 1;
if (writeDetails)
hessian_output << ", \"var1\": \"" << symbol_table.getName(symb_id1) << "\""
<< ", \"var2\": \"" << symbol_table.getName(symb_id2) << "\"";
if (symb_id1 != symb_id2) if (symb_id1 != symb_id2)
hessian_output << ", " << col_sym + 1; hessian_output << ", " << col_sym + 1;
hessian_output << "]" hessian_output << "]"
@ -2544,10 +2551,7 @@ StaticModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) co
expr_t d3 = it->second; expr_t d3 = it->second;
if (writeDetails) if (writeDetails)
third_derivatives_output << "{\"eq\": " << eq + 1 third_derivatives_output << "{\"eq\": " << eq + 1;
<< ", \"var1\": \"" << symbol_table.getName(getSymbIDByDerivID(var1)) << "\""
<< ", \"var2\": \"" << symbol_table.getName(getSymbIDByDerivID(var2)) << "\""
<< ", \"var3\": \"" << symbol_table.getName(getSymbIDByDerivID(var3)) << "\"";
else else
third_derivatives_output << "{\"row\": " << eq + 1; third_derivatives_output << "{\"row\": " << eq + 1;
@ -2569,17 +2573,23 @@ StaticModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) co
third_derivatives_output << ", "; third_derivatives_output << ", ";
third_derivatives_output << *it2 + 1; third_derivatives_output << *it2 + 1;
} }
third_derivatives_output << "]" third_derivatives_output << "]";
<< ", \"val\": \"";
if (writeDetails)
third_derivatives_output << ", \"var1\": \"" << symbol_table.getName(getSymbIDByDerivID(var1)) << "\""
<< ", \"var2\": \"" << symbol_table.getName(getSymbIDByDerivID(var2)) << "\""
<< ", \"var3\": \"" << symbol_table.getName(getSymbIDByDerivID(var3)) << "\"";
third_derivatives_output << ", \"val\": \"";
d3->writeJsonOutput(third_derivatives_output, temp_term_union, tef_terms); d3->writeJsonOutput(third_derivatives_output, temp_term_union, tef_terms);
third_derivatives_output << "\"}" << endl; third_derivatives_output << "\"}" << endl;
} }
third_derivatives_output << "]}"; third_derivatives_output << "]}";
if (writeDetails) if (writeDetails)
output << "\"static_model_derivative_details\": {"; output << "\"static_model\": {";
else else
output << "\"static_model_derivatives\": {"; output << "\"static_model_simple\": {";
output << model_local_vars_output.str() output << model_local_vars_output.str()
<< ", " << model_output.str() << ", " << model_output.str()
<< ", " << jacobian_output.str() << ", " << jacobian_output.str()
@ -2629,12 +2639,16 @@ StaticModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails)
int param_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param)) + 1; int param_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param)) + 1;
if (writeDetails) if (writeDetails)
jacobian_output << "{\"eq\": " << eq + 1 jacobian_output << "{\"eq\": " << eq + 1;
<< ", \"param\": \"" << symbol_table.getName(getSymbIDByDerivID(param)) << "\"";
else else
jacobian_output << "{\"row\": " << eq + 1; jacobian_output << "{\"row\": " << eq + 1;
jacobian_output << ", \"param_col\": " << param_col
<< ", \"val\": \""; if (writeDetails)
jacobian_output << ", \"param_col\": " << param_col;
jacobian_output << ", \"param\": \"" << symbol_table.getName(getSymbIDByDerivID(param)) << "\"";
jacobian_output << ", \"val\": \"";
d1->writeJsonOutput(jacobian_output, params_derivs_temporary_terms, tef_terms); d1->writeJsonOutput(jacobian_output, params_derivs_temporary_terms, tef_terms);
jacobian_output << "\"}" << endl; jacobian_output << "\"}" << endl;
} }
@ -2659,11 +2673,14 @@ StaticModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails)
int param_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param)) + 1; int param_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param)) + 1;
if (writeDetails) if (writeDetails)
hessian_output << "{\"eq\": " << eq + 1 hessian_output << "{\"eq\": " << eq + 1;
<< ", \"var\": \"" << symbol_table.getName(getSymbIDByDerivID(var)) << "\""
<< ", \"param\": \"" << symbol_table.getName(getSymbIDByDerivID(param)) << "\"";
else else
hessian_output << "{\"row\": " << eq + 1; hessian_output << "{\"row\": " << eq + 1;
if (writeDetails)
hessian_output << ", \"var\": \"" << symbol_table.getName(getSymbIDByDerivID(var)) << "\""
<< ", \"param\": \"" << symbol_table.getName(getSymbIDByDerivID(param)) << "\"";
hessian_output << ", \"var_col\": " << var_col hessian_output << ", \"var_col\": " << var_col
<< ", \"param_col\": " << param_col << ", \"param_col\": " << param_col
<< ", \"val\": \""; << ", \"val\": \"";
@ -2692,14 +2709,18 @@ StaticModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails)
int param2_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param2)) + 1; int param2_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param2)) + 1;
if (writeDetails) if (writeDetails)
hessian1_output << "{\"eq\": " << eq + 1 hessian1_output << "{\"eq\": " << eq + 1;
<< ", \"param1\": \"" << symbol_table.getName(getSymbIDByDerivID(param1)) << "\""
<< ", \"param2\": \"" << symbol_table.getName(getSymbIDByDerivID(param2)) << "\"";
else else
hessian1_output << "{\"row\": " << eq + 1; hessian1_output << "{\"row\": " << eq + 1;
hessian1_output << ", \"param1_col\": " << param1_col hessian1_output << ", \"param1_col\": " << param1_col
<< ", \"param2_col\": " << param2_col << ", \"param2_col\": " << param2_col;
<< ", \"val\": \"";
if (writeDetails)
hessian1_output << ", \"param1\": \"" << symbol_table.getName(getSymbIDByDerivID(param1)) << "\""
<< ", \"param2\": \"" << symbol_table.getName(getSymbIDByDerivID(param2)) << "\"";
hessian1_output << ", \"val\": \"";
d2->writeJsonOutput(hessian1_output, params_derivs_temporary_terms, tef_terms); d2->writeJsonOutput(hessian1_output, params_derivs_temporary_terms, tef_terms);
hessian1_output << "\"}" << endl; hessian1_output << "\"}" << endl;
} }
@ -2727,16 +2748,19 @@ StaticModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails)
int param2_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param2)) + 1; int param2_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param2)) + 1;
if (writeDetails) if (writeDetails)
third_derivs_output << "{\"eq\": " << eq + 1 third_derivs_output << "{\"eq\": " << eq + 1;
<< ", \"var\": \"" << symbol_table.getName(var) << "\""
<< ", \"param1\": \"" << symbol_table.getName(getSymbIDByDerivID(param1)) << "\""
<< ", \"param2\": \"" << symbol_table.getName(getSymbIDByDerivID(param2)) << "\"";
else else
third_derivs_output << "{\"row\": " << eq + 1; third_derivs_output << "{\"row\": " << eq + 1;
third_derivs_output << ", \"var_col\": " << var_col third_derivs_output << ", \"var_col\": " << var_col
<< ", \"param1_col\": " << param1_col << ", \"param1_col\": " << param1_col
<< ", \"param2_col\": " << param2_col << ", \"param2_col\": " << param2_col;
<< ", \"val\": \"";
if (writeDetails)
third_derivs_output << ", \"var\": \"" << symbol_table.getName(var) << "\""
<< ", \"param1\": \"" << symbol_table.getName(getSymbIDByDerivID(param1)) << "\""
<< ", \"param2\": \"" << symbol_table.getName(getSymbIDByDerivID(param2)) << "\"";
third_derivs_output << ", \"val\": \"";
d2->writeJsonOutput(third_derivs_output, params_derivs_temporary_terms, tef_terms); d2->writeJsonOutput(third_derivs_output, params_derivs_temporary_terms, tef_terms);
third_derivs_output << "\"}" << endl; third_derivs_output << "\"}" << endl;
} }
@ -2765,25 +2789,29 @@ StaticModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails)
int param_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param)) + 1; int param_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param)) + 1;
if (writeDetails) if (writeDetails)
third_derivs1_output << "{\"eq\": " << eq + 1 third_derivs1_output << "{\"eq\": " << eq + 1;
<< ", \"var1\": \"" << symbol_table.getName(getSymbIDByDerivID(var1)) << "\""
<< ", \"var2\": \"" << symbol_table.getName(getSymbIDByDerivID(var2)) << "\""
<< ", \"param1\": \"" << symbol_table.getName(getSymbIDByDerivID(param)) << "\"";
else else
third_derivs1_output << "{\"row\": " << eq + 1; third_derivs1_output << "{\"row\": " << eq + 1;
third_derivs1_output << ", \"var1_col\": " << var1_col third_derivs1_output << ", \"var1_col\": " << var1_col
<< ", \"var2_col\": " << var2_col << ", \"var2_col\": " << var2_col
<< ", \"param_col\": " << param_col << ", \"param_col\": " << param_col;
<< ", \"val\": \"";
if (writeDetails)
third_derivs1_output << ", \"var1\": \"" << symbol_table.getName(getSymbIDByDerivID(var1)) << "\""
<< ", \"var2\": \"" << symbol_table.getName(getSymbIDByDerivID(var2)) << "\""
<< ", \"param1\": \"" << symbol_table.getName(getSymbIDByDerivID(param)) << "\"";
third_derivs1_output << ", \"val\": \"";
d2->writeJsonOutput(third_derivs1_output, params_derivs_temporary_terms, tef_terms); d2->writeJsonOutput(third_derivs1_output, params_derivs_temporary_terms, tef_terms);
third_derivs1_output << "\"}" << endl; third_derivs1_output << "\"}" << endl;
} }
third_derivs1_output << "]}" << endl; third_derivs1_output << "]}" << endl;
if (writeDetails) if (writeDetails)
output << "\"static_model_params_derivative_details\": {"; output << "\"static_model_params_derivative\": {";
else else
output << "\"static_model_params_derivatives\": {"; output << "\"static_model_params_derivatives_simple\": {";
output << model_local_vars_output.str() output << model_local_vars_output.str()
<< ", " << model_output.str() << ", " << model_output.str()
<< ", " << jacobian_output.str() << ", " << jacobian_output.str()