Apply modernize-raw-string-literal from clang-tidy
Use ReplaceShorterLiterals option to enforce replacement of all strings. https://clang.llvm.org/extra/clang-tidy/checks/modernize-raw-string-literal.htmlissue#70
parent
6ba31087ab
commit
8a41a75c85
File diff suppressed because it is too large
Load Diff
|
@ -845,7 +845,7 @@ DataTree::writePowerDeriv(ostream &output) const
|
|||
string
|
||||
DataTree::packageDir(const string &package)
|
||||
{
|
||||
regex pat{"\\."};
|
||||
regex pat{R"(\.)"};
|
||||
string dirname = "+" + regex_replace(package, pat, "/+");
|
||||
boost::filesystem::create_directories(dirname);
|
||||
return dirname;
|
||||
|
|
|
@ -974,7 +974,7 @@ DynamicModel::writeModelEquationsCode(const string &basename, const map_idx_t &m
|
|||
code_file.open(main_name, ios::out | ios::binary | ios::ate);
|
||||
if (!code_file.is_open())
|
||||
{
|
||||
cerr << "Error : Can't open file \"" << main_name << "\" for writing" << endl;
|
||||
cerr << R"(Error : Can't open file ")" << main_name << R"(" for writing)" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -1244,7 +1244,7 @@ DynamicModel::writeModelEquationsCode_Block(const string &basename, const map_id
|
|||
code_file.open(main_name, ios::out | ios::binary | ios::ate);
|
||||
if (!code_file.is_open())
|
||||
{
|
||||
cerr << "Error : Can't open file \"" << main_name << "\" for writing" << endl;
|
||||
cerr << R"(Error : Can't open file ")" << main_name << R"(" for writing)" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
//Temporary variables declaration
|
||||
|
@ -1721,7 +1721,7 @@ DynamicModel::writeDynamicCFile(const string &basename, const int order) const
|
|||
if (external_functions_table.get_total_number_of_unique_model_block_external_functions())
|
||||
// External Matlab function, implies Dynamic function will call mex
|
||||
mDynamicModelFile << "#include <uchar.h>" << endl // For MATLAB ≤ R2011a
|
||||
<< "#include \"mex.h\"" << endl;
|
||||
<< R"(#include "mex.h")" << endl;
|
||||
|
||||
mDynamicModelFile << "#define max(a, b) (((a) > (b)) ? (a) : (b))" << endl
|
||||
<< "#define min(a, b) (((a) > (b)) ? (b) : (a))" << endl;
|
||||
|
@ -1758,7 +1758,7 @@ DynamicModel::writeDynamicCFile(const string &basename, const int order) const
|
|||
<< endl
|
||||
<< "#include <stdlib.h>" << endl
|
||||
<< "#include <uchar.h>" << endl // For MATLAB ≤ R2011a
|
||||
<< "#include \"mex.h\"" << endl
|
||||
<< R"(#include "mex.h")" << endl
|
||||
<< endl
|
||||
<< "const int ntt = " << ntt << ";" << endl
|
||||
<< "void dynamic_resid_tt(const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, double *T);" << endl
|
||||
|
@ -1773,7 +1773,7 @@ DynamicModel::writeDynamicCFile(const string &basename, const int order) const
|
|||
<< "{" << endl
|
||||
<< " /* Check that no derivatives of higher order than computed are being requested */" << endl
|
||||
<< " if (nlhs > " << order + 1 << ")" << endl
|
||||
<< " mexErrMsgTxt(\"Derivatives of higher order than computed have been requested\");" << endl
|
||||
<< R"( mexErrMsgTxt("Derivatives of higher order than computed have been requested");)" << endl
|
||||
<< " /* Create a pointer to the input matrix y. */" << endl
|
||||
<< " double *y = mxGetPr(prhs[0]);" << endl
|
||||
<< endl
|
||||
|
@ -1840,16 +1840,16 @@ string
|
|||
DynamicModel::reform(const string name1) const
|
||||
{
|
||||
string name = name1;
|
||||
int pos = name.find("\\", 0);
|
||||
int pos = name.find(R"(\)", 0);
|
||||
while (pos >= 0)
|
||||
{
|
||||
if (name.substr(pos + 1, 1) != "\\")
|
||||
if (name.substr(pos + 1, 1) != R"(\)")
|
||||
{
|
||||
name = name.insert(pos, "\\");
|
||||
name = name.insert(pos, R"(\)");
|
||||
pos++;
|
||||
}
|
||||
pos++;
|
||||
pos = name.find("\\", pos);
|
||||
pos = name.find(R"(\)", pos);
|
||||
}
|
||||
return (name);
|
||||
}
|
||||
|
@ -1910,7 +1910,7 @@ DynamicModel::Write_Inf_To_Bin_File_Block(const string &basename, const int &num
|
|||
SaveCode.open(filename, ios::out | ios::binary);
|
||||
if (!SaveCode.is_open())
|
||||
{
|
||||
cerr << "Error : Can't open file \"" << filename << "\" for writing" << endl;
|
||||
cerr << R"(Error : Can't open file ")" << filename << R"(" for writing)" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
u_count_int = 0;
|
||||
|
@ -3108,9 +3108,9 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
|
|||
output << modstruct << "equation_tags = [" << endl;
|
||||
for (const auto & equation_tag : equation_tags)
|
||||
output << " EquationTag("
|
||||
<< equation_tag.first + 1 << " , \""
|
||||
<< equation_tag.second.first << "\" , \""
|
||||
<< equation_tag.second.second << "\")" << endl;
|
||||
<< equation_tag.first + 1 << R"( , ")"
|
||||
<< equation_tag.second.first << R"(" , ")"
|
||||
<< equation_tag.second.second << R"("))" << endl;
|
||||
output << " ]" << endl;
|
||||
}
|
||||
else
|
||||
|
@ -6716,14 +6716,14 @@ void
|
|||
DynamicModel::writeJsonAST(ostream &output) const
|
||||
{
|
||||
vector<pair<string, string>> eqtags;
|
||||
output << "\"abstract_syntax_tree\":[" << endl;
|
||||
output << R"("abstract_syntax_tree":[)" << endl;
|
||||
for (int eq = 0; eq < (int) equations.size(); eq++)
|
||||
{
|
||||
if (eq != 0)
|
||||
output << ", ";
|
||||
|
||||
output << "{ \"number\":" << eq
|
||||
<< ", \"line\":" << equations_lineno[eq];
|
||||
output << R"({ "number":)" << eq
|
||||
<< R"(, "line":)" << equations_lineno[eq];
|
||||
|
||||
for (const auto & equation_tag : equation_tags)
|
||||
if (equation_tag.first == eq)
|
||||
|
@ -6731,19 +6731,19 @@ DynamicModel::writeJsonAST(ostream &output) const
|
|||
|
||||
if (!eqtags.empty())
|
||||
{
|
||||
output << ", \"tags\": {";
|
||||
output << R"(, "tags": {)";
|
||||
int i = 0;
|
||||
for (vector<pair<string, string>>::const_iterator it = eqtags.begin(); it != eqtags.end(); it++, i++)
|
||||
{
|
||||
if (i != 0)
|
||||
output << ", ";
|
||||
output << "\"" << it->first << "\": \"" << it->second << "\"";
|
||||
output << R"(")" << it->first << R"(": ")" << it->second << R"(")";
|
||||
}
|
||||
output << "}";
|
||||
eqtags.clear();
|
||||
}
|
||||
|
||||
output << ", \"AST\": ";
|
||||
output << R"(, "AST": )";
|
||||
equations[eq]->writeJsonAST(output);
|
||||
output << "}";
|
||||
}
|
||||
|
@ -6758,9 +6758,9 @@ DynamicModel::writeJsonXrefsHelper(ostream &output, const map<pair<int, int>, se
|
|||
{
|
||||
if (it != xrefs.begin())
|
||||
output << ", ";
|
||||
output << "{\"name\": \"" << symbol_table.getName(it->first.first) << "\""
|
||||
<< ", \"shift\": " << it->first.second
|
||||
<< ", \"equations\": [";
|
||||
output << R"({"name": ")" << symbol_table.getName(it->first.first) << R"(")"
|
||||
<< R"(, "shift": )" << it->first.second
|
||||
<< R"(, "equations": [)";
|
||||
for (auto it1 = it->second.begin();
|
||||
it1 != it->second.end(); it1++)
|
||||
{
|
||||
|
@ -6775,17 +6775,17 @@ DynamicModel::writeJsonXrefsHelper(ostream &output, const map<pair<int, int>, se
|
|||
void
|
||||
DynamicModel::writeJsonXrefs(ostream &output) const
|
||||
{
|
||||
output << "\"xrefs\": {"
|
||||
<< "\"parameters\": [";
|
||||
output << R"("xrefs": {)"
|
||||
<< R"("parameters": [)";
|
||||
writeJsonXrefsHelper(output, xref_param);
|
||||
output << "]"
|
||||
<< ", \"endogenous\": [";
|
||||
<< R"(, "endogenous": [)";
|
||||
writeJsonXrefsHelper(output, xref_endo);
|
||||
output << "]"
|
||||
<< ", \"exogenous\": [";
|
||||
<< R"(, "exogenous": [)";
|
||||
writeJsonXrefsHelper(output, xref_exo);
|
||||
output << "]"
|
||||
<< ", \"exogenous_deterministic\": [";
|
||||
<< R"(, "exogenous_deterministic": [)";
|
||||
writeJsonXrefsHelper(output, xref_exo_det);
|
||||
output << "]}" << endl;
|
||||
}
|
||||
|
@ -6801,8 +6801,8 @@ DynamicModel::writeJsonOriginalModelOutput(ostream &output) const
|
|||
void
|
||||
DynamicModel::writeJsonDynamicModelInfo(ostream &output) const
|
||||
{
|
||||
output << "\"model_info\": {"
|
||||
<< "\"lead_lag_incidence\": [";
|
||||
output << R"("model_info": {)"
|
||||
<< R"("lead_lag_incidence": [)";
|
||||
// Loop on endogenous variables
|
||||
int nstatic = 0,
|
||||
nfwrd = 0,
|
||||
|
@ -6858,13 +6858,13 @@ DynamicModel::writeJsonDynamicModelInfo(ostream &output) const
|
|||
output << "]";
|
||||
}
|
||||
output << "], "
|
||||
<< "\"nstatic\": " << nstatic << ", "
|
||||
<< "\"nfwrd\": " << nfwrd << ", "
|
||||
<< "\"npred\": " << npred << ", "
|
||||
<< "\"nboth\": " << nboth << ", "
|
||||
<< "\"nsfwrd\": " << nfwrd+nboth << ", "
|
||||
<< "\"nspred\": " << npred+nboth << ", "
|
||||
<< "\"ndynamic\": " << npred+nboth+nfwrd << endl;
|
||||
<< R"("nstatic": )" << nstatic << ", "
|
||||
<< R"("nfwrd": )" << nfwrd << ", "
|
||||
<< R"("npred": )" << npred << ", "
|
||||
<< R"("nboth": )" << nboth << ", "
|
||||
<< R"("nsfwrd": )" << nfwrd+nboth << ", "
|
||||
<< R"("nspred": )" << npred+nboth << ", "
|
||||
<< R"("ndynamic": )" << npred+nboth+nfwrd << endl;
|
||||
output << "}";
|
||||
}
|
||||
|
||||
|
@ -6896,10 +6896,10 @@ DynamicModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) c
|
|||
temp_term_union.insert(temporary_terms_derivatives[1].begin(), temporary_terms_derivatives[1].end());
|
||||
concat = "jacobian";
|
||||
writeJsonTemporaryTerms(temp_term_union, temp_term_union_m_1, jacobian_output, tef_terms, concat);
|
||||
jacobian_output << ", \"jacobian\": {"
|
||||
<< " \"nrows\": " << equations.size()
|
||||
<< ", \"ncols\": " << dynJacobianColsNbr
|
||||
<< ", \"entries\": [";
|
||||
jacobian_output << R"(, "jacobian": {)"
|
||||
<< R"( "nrows": )" << equations.size()
|
||||
<< R"(, "ncols": )" << dynJacobianColsNbr
|
||||
<< R"(, "entries": [)";
|
||||
for (auto it = derivatives[1].begin();
|
||||
it != derivatives[1].end(); it++)
|
||||
{
|
||||
|
@ -6912,19 +6912,19 @@ DynamicModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) c
|
|||
expr_t d1 = it->second;
|
||||
|
||||
if (writeDetails)
|
||||
jacobian_output << "{\"eq\": " << eq + 1;
|
||||
jacobian_output << R"({"eq": )" << eq + 1;
|
||||
else
|
||||
jacobian_output << "{\"row\": " << eq + 1;
|
||||
jacobian_output << R"({"row": )" << eq + 1;
|
||||
|
||||
jacobian_output << ", \"col\": " << col + 1;
|
||||
jacobian_output << R"(, "col": )" << col + 1;
|
||||
|
||||
if (writeDetails)
|
||||
jacobian_output << ", \"var\": \"" << symbol_table.getName(getSymbIDByDerivID(var)) << "\""
|
||||
<< ", \"shift\": " << getLagByDerivID(var);
|
||||
jacobian_output << R"(, "var": ")" << symbol_table.getName(getSymbIDByDerivID(var)) << R"(")"
|
||||
<< R"(, "shift": )" << getLagByDerivID(var);
|
||||
|
||||
jacobian_output << ", \"val\": \"";
|
||||
jacobian_output << R"(, "val": ")";
|
||||
d1->writeJsonOutput(jacobian_output, temp_term_union, tef_terms);
|
||||
jacobian_output << "\"}" << endl;
|
||||
jacobian_output << R"("})" << endl;
|
||||
}
|
||||
jacobian_output << "]}";
|
||||
|
||||
|
@ -6933,10 +6933,10 @@ DynamicModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) c
|
|||
temp_term_union.insert(temporary_terms_derivatives[2].begin(), temporary_terms_derivatives[2].end());
|
||||
concat = "hessian";
|
||||
writeJsonTemporaryTerms(temp_term_union, temp_term_union_m_1, hessian_output, tef_terms, concat);
|
||||
hessian_output << ", \"hessian\": {"
|
||||
<< " \"nrows\": " << equations.size()
|
||||
<< ", \"ncols\": " << hessianColsNbr
|
||||
<< ", \"entries\": [";
|
||||
hessian_output << R"(, "hessian": {)"
|
||||
<< R"( "nrows": )" << equations.size()
|
||||
<< R"(, "ncols": )" << hessianColsNbr
|
||||
<< R"(, "entries": [)";
|
||||
for (auto it = derivatives[2].begin();
|
||||
it != derivatives[2].end(); it++)
|
||||
{
|
||||
|
@ -6952,24 +6952,24 @@ DynamicModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) c
|
|||
int col_nb_sym = id2 * dynJacobianColsNbr + id1;
|
||||
|
||||
if (writeDetails)
|
||||
hessian_output << "{\"eq\": " << eq + 1;
|
||||
hessian_output << R"({"eq": )" << eq + 1;
|
||||
else
|
||||
hessian_output << "{\"row\": " << eq + 1;
|
||||
hessian_output << R"({"row": )" << eq + 1;
|
||||
|
||||
hessian_output << ", \"col\": [" << col_nb + 1;
|
||||
hessian_output << R"(, "col": [)" << col_nb + 1;
|
||||
if (id1 != id2)
|
||||
hessian_output << ", " << col_nb_sym + 1;
|
||||
hessian_output << "]";
|
||||
|
||||
if (writeDetails)
|
||||
hessian_output << ", \"var1\": \"" << symbol_table.getName(getSymbIDByDerivID(var1)) << "\""
|
||||
<< ", \"shift1\": " << getLagByDerivID(var1)
|
||||
<< ", \"var2\": \"" << symbol_table.getName(getSymbIDByDerivID(var2)) << "\""
|
||||
<< ", \"shift2\": " << getLagByDerivID(var2);
|
||||
hessian_output << R"(, "var1": ")" << symbol_table.getName(getSymbIDByDerivID(var1)) << R"(")"
|
||||
<< R"(, "shift1": )" << getLagByDerivID(var1)
|
||||
<< R"(, "var2": ")" << symbol_table.getName(getSymbIDByDerivID(var2)) << R"(")"
|
||||
<< R"(, "shift2": )" << getLagByDerivID(var2);
|
||||
|
||||
hessian_output << ", \"val\": \"";
|
||||
hessian_output << R"(, "val": ")";
|
||||
d2->writeJsonOutput(hessian_output, temp_term_union, tef_terms);
|
||||
hessian_output << "\"}" << endl;
|
||||
hessian_output << R"("})" << endl;
|
||||
}
|
||||
hessian_output << "]}";
|
||||
|
||||
|
@ -6978,10 +6978,10 @@ DynamicModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) c
|
|||
temp_term_union.insert(temporary_terms_derivatives[3].begin(), temporary_terms_derivatives[3].end());
|
||||
concat = "third_derivatives";
|
||||
writeJsonTemporaryTerms(temp_term_union, temp_term_union_m_1, third_derivatives_output, tef_terms, concat);
|
||||
third_derivatives_output << ", \"third_derivative\": {"
|
||||
<< " \"nrows\": " << equations.size()
|
||||
<< ", \"ncols\": " << hessianColsNbr * dynJacobianColsNbr
|
||||
<< ", \"entries\": [";
|
||||
third_derivatives_output << R"(, "third_derivative": {)"
|
||||
<< R"( "nrows": )" << equations.size()
|
||||
<< R"(, "ncols": )" << hessianColsNbr * dynJacobianColsNbr
|
||||
<< R"(, "entries": [)";
|
||||
for (auto it = derivatives[3].begin();
|
||||
it != derivatives[3].end(); it++)
|
||||
{
|
||||
|
@ -6993,9 +6993,9 @@ DynamicModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) c
|
|||
expr_t d3 = it->second;
|
||||
|
||||
if (writeDetails)
|
||||
third_derivatives_output << "{\"eq\": " << eq + 1;
|
||||
third_derivatives_output << R"({"eq": )" << eq + 1;
|
||||
else
|
||||
third_derivatives_output << "{\"row\": " << eq + 1;
|
||||
third_derivatives_output << R"({"row": )" << eq + 1;
|
||||
|
||||
int id1 = getDynJacobianCol(var1);
|
||||
int id2 = getDynJacobianCol(var2);
|
||||
|
@ -7008,7 +7008,7 @@ DynamicModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) c
|
|||
cols.insert(id3 * hessianColsNbr + id1 * dynJacobianColsNbr + id2);
|
||||
cols.insert(id3 * hessianColsNbr + id2 * dynJacobianColsNbr + id1);
|
||||
|
||||
third_derivatives_output << ", \"col\": [";
|
||||
third_derivatives_output << R"(, "col": [)";
|
||||
for (auto it2 = cols.begin(); it2 != cols.end(); it2++)
|
||||
{
|
||||
if (it2 != cols.begin())
|
||||
|
@ -7018,23 +7018,23 @@ DynamicModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) c
|
|||
third_derivatives_output << "]";
|
||||
|
||||
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 << R"(, "var1": ")" << symbol_table.getName(getSymbIDByDerivID(var1)) << R"(")"
|
||||
<< R"(, "shift1": )" << getLagByDerivID(var1)
|
||||
<< R"(, "var2": ")" << symbol_table.getName(getSymbIDByDerivID(var2)) << R"(")"
|
||||
<< R"(, "shift2": )" << getLagByDerivID(var2)
|
||||
<< R"(, "var3": ")" << symbol_table.getName(getSymbIDByDerivID(var3)) << R"(")"
|
||||
<< R"(, "shift3": )" << getLagByDerivID(var3);
|
||||
|
||||
third_derivatives_output << ", \"val\": \"";
|
||||
third_derivatives_output << R"(, "val": ")";
|
||||
d3->writeJsonOutput(third_derivatives_output, temp_term_union, tef_terms);
|
||||
third_derivatives_output << "\"}" << endl;
|
||||
third_derivatives_output << R"("})" << endl;
|
||||
}
|
||||
third_derivatives_output << "]}";
|
||||
|
||||
if (writeDetails)
|
||||
output << "\"dynamic_model\": {";
|
||||
output << R"("dynamic_model": {)";
|
||||
else
|
||||
output << "\"dynamic_model_simple\": {";
|
||||
output << R"("dynamic_model_simple": {)";
|
||||
output << model_local_vars_output.str()
|
||||
<< ", " << model_output.str()
|
||||
<< ", " << jacobian_output.str()
|
||||
|
@ -7065,10 +7065,10 @@ DynamicModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails)
|
|||
for (const auto &it : params_derivs_temporary_terms)
|
||||
writeJsonTemporaryTerms(it.second, temp_term_union, model_output, tef_terms, concat);
|
||||
|
||||
jacobian_output << "\"deriv_wrt_params\": {"
|
||||
<< " \"neqs\": " << equations.size()
|
||||
<< ", \"nparamcols\": " << symbol_table.param_nbr()
|
||||
<< ", \"entries\": [";
|
||||
jacobian_output << R"("deriv_wrt_params": {)"
|
||||
<< R"( "neqs": )" << equations.size()
|
||||
<< R"(, "nparamcols": )" << symbol_table.param_nbr()
|
||||
<< R"(, "entries": [)";
|
||||
auto &rp = params_derivatives.find({ 0, 1 })->second;
|
||||
for (auto it = rp.begin(); it != rp.end(); it++)
|
||||
{
|
||||
|
@ -7082,26 +7082,26 @@ DynamicModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails)
|
|||
int param_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param)) + 1;
|
||||
|
||||
if (writeDetails)
|
||||
jacobian_output << "{\"eq\": " << eq + 1;
|
||||
jacobian_output << R"({"eq": )" << eq + 1;
|
||||
else
|
||||
jacobian_output << "{\"row\": " << eq + 1;
|
||||
jacobian_output << R"({"row": )" << eq + 1;
|
||||
|
||||
jacobian_output << ", \"param_col\": " << param_col + 1;
|
||||
jacobian_output << R"(, "param_col": )" << param_col + 1;
|
||||
|
||||
if (writeDetails)
|
||||
jacobian_output << ", \"param\": \"" << symbol_table.getName(getSymbIDByDerivID(param)) << "\"";
|
||||
jacobian_output << R"(, "param": ")" << symbol_table.getName(getSymbIDByDerivID(param)) << R"(")";
|
||||
|
||||
jacobian_output << ", \"val\": \"";
|
||||
jacobian_output << R"(, "val": ")";
|
||||
d1->writeJsonOutput(jacobian_output, temp_term_union, tef_terms);
|
||||
jacobian_output << "\"}" << endl;
|
||||
jacobian_output << R"("})" << endl;
|
||||
}
|
||||
jacobian_output << "]}";
|
||||
|
||||
hessian_output << "\"deriv_jacobian_wrt_params\": {"
|
||||
<< " \"neqs\": " << equations.size()
|
||||
<< ", \"nvarcols\": " << dynJacobianColsNbr
|
||||
<< ", \"nparamcols\": " << symbol_table.param_nbr()
|
||||
<< ", \"entries\": [";
|
||||
hessian_output << R"("deriv_jacobian_wrt_params": {)"
|
||||
<< R"( "neqs": )" << equations.size()
|
||||
<< R"(, "nvarcols": )" << dynJacobianColsNbr
|
||||
<< R"(, "nparamcols": )" << symbol_table.param_nbr()
|
||||
<< R"(, "entries": [)";
|
||||
auto &gp = params_derivatives.find({ 1, 1 })->second;
|
||||
for (auto it = gp.begin(); it != gp.end(); it++)
|
||||
{
|
||||
|
@ -7116,29 +7116,29 @@ DynamicModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails)
|
|||
int param_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param)) + 1;
|
||||
|
||||
if (writeDetails)
|
||||
hessian_output << "{\"eq\": " << eq + 1;
|
||||
hessian_output << R"({"eq": )" << eq + 1;
|
||||
else
|
||||
hessian_output << "{\"row\": " << eq + 1;
|
||||
hessian_output << R"({"row": )" << eq + 1;
|
||||
|
||||
hessian_output << ", \"var_col\": " << var_col + 1
|
||||
<< ", \"param_col\": " << param_col + 1;
|
||||
hessian_output << R"(, "var_col": )" << var_col + 1
|
||||
<< R"(, "param_col": )" << param_col + 1;
|
||||
|
||||
if (writeDetails)
|
||||
hessian_output << ", \"var\": \"" << symbol_table.getName(getSymbIDByDerivID(var)) << "\""
|
||||
<< ", \"lag\": " << getLagByDerivID(var)
|
||||
<< ", \"param\": \"" << symbol_table.getName(getSymbIDByDerivID(param)) << "\"";
|
||||
hessian_output << R"(, "var": ")" << symbol_table.getName(getSymbIDByDerivID(var)) << R"(")"
|
||||
<< R"(, "lag": )" << getLagByDerivID(var)
|
||||
<< R"(, "param": ")" << symbol_table.getName(getSymbIDByDerivID(param)) << R"(")";
|
||||
|
||||
hessian_output << ", \"val\": \"";
|
||||
hessian_output << R"(, "val": ")";
|
||||
d2->writeJsonOutput(hessian_output, temp_term_union, tef_terms);
|
||||
hessian_output << "\"}" << endl;
|
||||
hessian_output << R"("})" << endl;
|
||||
}
|
||||
hessian_output << "]}";
|
||||
|
||||
hessian1_output << "\"second_deriv_residuals_wrt_params\": {"
|
||||
<< " \"nrows\": " << equations.size()
|
||||
<< ", \"nparam1cols\": " << symbol_table.param_nbr()
|
||||
<< ", \"nparam2cols\": " << symbol_table.param_nbr()
|
||||
<< ", \"entries\": [";
|
||||
hessian1_output << R"("second_deriv_residuals_wrt_params": {)"
|
||||
<< R"( "nrows": )" << equations.size()
|
||||
<< R"(, "nparam1cols": )" << symbol_table.param_nbr()
|
||||
<< R"(, "nparam2cols": )" << symbol_table.param_nbr()
|
||||
<< R"(, "entries": [)";
|
||||
auto &rpp = params_derivatives.find({ 0, 2 })->second;
|
||||
for (auto it = rpp.begin(); it != rpp.end(); ++it)
|
||||
{
|
||||
|
@ -7153,28 +7153,28 @@ DynamicModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails)
|
|||
int param2_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param2)) + 1;
|
||||
|
||||
if (writeDetails)
|
||||
hessian1_output << "{\"eq\": " << eq + 1;
|
||||
hessian1_output << R"({"eq": )" << eq + 1;
|
||||
else
|
||||
hessian1_output << "{\"row\": " << eq + 1;
|
||||
hessian1_output << ", \"param1_col\": " << param1_col + 1
|
||||
<< ", \"param2_col\": " << param2_col + 1;
|
||||
hessian1_output << R"({"row": )" << eq + 1;
|
||||
hessian1_output << R"(, "param1_col": )" << param1_col + 1
|
||||
<< R"(, "param2_col": )" << param2_col + 1;
|
||||
|
||||
if (writeDetails)
|
||||
hessian1_output << ", \"param1\": \"" << symbol_table.getName(getSymbIDByDerivID(param1)) << "\""
|
||||
<< ", \"param2\": \"" << symbol_table.getName(getSymbIDByDerivID(param2)) << "\"";
|
||||
hessian1_output << R"(, "param1": ")" << symbol_table.getName(getSymbIDByDerivID(param1)) << R"(")"
|
||||
<< R"(, "param2": ")" << symbol_table.getName(getSymbIDByDerivID(param2)) << R"(")";
|
||||
|
||||
hessian1_output << ", \"val\": \"";
|
||||
hessian1_output << R"(, "val": ")";
|
||||
d2->writeJsonOutput(hessian1_output, temp_term_union, tef_terms);
|
||||
hessian1_output << "\"}" << endl;
|
||||
hessian1_output << R"("})" << endl;
|
||||
}
|
||||
hessian1_output << "]}";
|
||||
|
||||
third_derivs_output << "\"second_deriv_jacobian_wrt_params\": {"
|
||||
<< " \"neqs\": " << equations.size()
|
||||
<< ", \"nvarcols\": " << dynJacobianColsNbr
|
||||
<< ", \"nparam1cols\": " << symbol_table.param_nbr()
|
||||
<< ", \"nparam2cols\": " << symbol_table.param_nbr()
|
||||
<< ", \"entries\": [";
|
||||
third_derivs_output << R"("second_deriv_jacobian_wrt_params": {)"
|
||||
<< R"( "neqs": )" << equations.size()
|
||||
<< R"(, "nvarcols": )" << dynJacobianColsNbr
|
||||
<< R"(, "nparam1cols": )" << symbol_table.param_nbr()
|
||||
<< R"(, "nparam2cols": )" << symbol_table.param_nbr()
|
||||
<< R"(, "entries": [)";
|
||||
auto &gpp = params_derivatives.find({ 1, 2 })->second;
|
||||
for (auto it = gpp.begin(); it != gpp.end(); ++it)
|
||||
{
|
||||
|
@ -7190,32 +7190,32 @@ DynamicModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails)
|
|||
int param2_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param2)) + 1;
|
||||
|
||||
if (writeDetails)
|
||||
third_derivs_output << "{\"eq\": " << eq + 1;
|
||||
third_derivs_output << R"({"eq": )" << eq + 1;
|
||||
else
|
||||
third_derivs_output << "{\"row\": " << eq + 1;
|
||||
third_derivs_output << R"({"row": )" << eq + 1;
|
||||
|
||||
third_derivs_output << ", \"var_col\": " << var_col + 1
|
||||
<< ", \"param1_col\": " << param1_col + 1
|
||||
<< ", \"param2_col\": " << param2_col + 1;
|
||||
third_derivs_output << R"(, "var_col": )" << var_col + 1
|
||||
<< R"(, "param1_col": )" << param1_col + 1
|
||||
<< R"(, "param2_col": )" << param2_col + 1;
|
||||
|
||||
if (writeDetails)
|
||||
third_derivs_output << ", \"var\": \"" << symbol_table.getName(var) << "\""
|
||||
<< ", \"lag\": " << getLagByDerivID(var)
|
||||
<< ", \"param1\": \"" << symbol_table.getName(getSymbIDByDerivID(param1)) << "\""
|
||||
<< ", \"param2\": \"" << symbol_table.getName(getSymbIDByDerivID(param2)) << "\"";
|
||||
third_derivs_output << R"(, "var": ")" << symbol_table.getName(var) << R"(")"
|
||||
<< R"(, "lag": )" << getLagByDerivID(var)
|
||||
<< R"(, "param1": ")" << symbol_table.getName(getSymbIDByDerivID(param1)) << R"(")"
|
||||
<< R"(, "param2": ")" << symbol_table.getName(getSymbIDByDerivID(param2)) << R"(")";
|
||||
|
||||
third_derivs_output << ", \"val\": \"";
|
||||
third_derivs_output << R"(, "val": ")";
|
||||
d2->writeJsonOutput(third_derivs_output, temp_term_union, tef_terms);
|
||||
third_derivs_output << "\"}" << endl;
|
||||
third_derivs_output << R"("})" << endl;
|
||||
}
|
||||
third_derivs_output << "]}" << endl;
|
||||
|
||||
third_derivs1_output << "\"derivative_hessian_wrt_params\": {"
|
||||
<< " \"neqs\": " << equations.size()
|
||||
<< ", \"nvar1cols\": " << dynJacobianColsNbr
|
||||
<< ", \"nvar2cols\": " << dynJacobianColsNbr
|
||||
<< ", \"nparamcols\": " << symbol_table.param_nbr()
|
||||
<< ", \"entries\": [";
|
||||
third_derivs1_output << R"("derivative_hessian_wrt_params": {)"
|
||||
<< R"( "neqs": )" << equations.size()
|
||||
<< R"(, "nvar1cols": )" << dynJacobianColsNbr
|
||||
<< R"(, "nvar2cols": )" << dynJacobianColsNbr
|
||||
<< R"(, "nparamcols": )" << symbol_table.param_nbr()
|
||||
<< R"(, "entries": [)";
|
||||
auto &hp = params_derivatives.find({ 2, 1 })->second;
|
||||
for (auto it = hp.begin(); it != hp.end(); ++it)
|
||||
{
|
||||
|
@ -7231,31 +7231,31 @@ DynamicModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails)
|
|||
int param_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param)) + 1;
|
||||
|
||||
if (writeDetails)
|
||||
third_derivs1_output << "{\"eq\": " << eq + 1;
|
||||
third_derivs1_output << R"({"eq": )" << eq + 1;
|
||||
else
|
||||
third_derivs1_output << "{\"row\": " << eq + 1;
|
||||
third_derivs1_output << R"({"row": )" << eq + 1;
|
||||
|
||||
third_derivs1_output << ", \"var1_col\": " << var1_col + 1
|
||||
<< ", \"var2_col\": " << var2_col + 1
|
||||
<< ", \"param_col\": " << param_col + 1;
|
||||
third_derivs1_output << R"(, "var1_col": )" << var1_col + 1
|
||||
<< R"(, "var2_col": )" << var2_col + 1
|
||||
<< R"(, "param_col": )" << param_col + 1;
|
||||
|
||||
if (writeDetails)
|
||||
third_derivs1_output << ", \"var1\": \"" << symbol_table.getName(getSymbIDByDerivID(var1)) << "\""
|
||||
<< ", \"lag1\": " << getLagByDerivID(var1)
|
||||
<< ", \"var2\": \"" << symbol_table.getName(getSymbIDByDerivID(var2)) << "\""
|
||||
<< ", \"lag2\": " << getLagByDerivID(var2)
|
||||
<< ", \"param\": \"" << symbol_table.getName(getSymbIDByDerivID(param)) << "\"";
|
||||
third_derivs1_output << R"(, "var1": ")" << symbol_table.getName(getSymbIDByDerivID(var1)) << R"(")"
|
||||
<< R"(, "lag1": )" << getLagByDerivID(var1)
|
||||
<< R"(, "var2": ")" << symbol_table.getName(getSymbIDByDerivID(var2)) << R"(")"
|
||||
<< R"(, "lag2": )" << getLagByDerivID(var2)
|
||||
<< R"(, "param": ")" << symbol_table.getName(getSymbIDByDerivID(param)) << R"(")";
|
||||
|
||||
third_derivs1_output << ", \"val\": \"";
|
||||
third_derivs1_output << R"(, "val": ")";
|
||||
d2->writeJsonOutput(third_derivs1_output, temp_term_union, tef_terms);
|
||||
third_derivs1_output << "\"}" << endl;
|
||||
third_derivs1_output << R"("})" << endl;
|
||||
}
|
||||
third_derivs1_output << "]}" << endl;
|
||||
|
||||
if (writeDetails)
|
||||
output << "\"dynamic_model_params_derivative\": {";
|
||||
output << R"("dynamic_model_params_derivative": {)";
|
||||
else
|
||||
output << "\"dynamic_model_params_derivatives_simple\": {";
|
||||
output << R"("dynamic_model_params_derivatives_simple": {)";
|
||||
output << model_local_vars_output.str()
|
||||
<< ", " << model_output.str()
|
||||
<< ", " << jacobian_output.str()
|
||||
|
|
|
@ -77,12 +77,12 @@ parse_options_line(istream &modfile)
|
|||
string first_line;
|
||||
getline(modfile, first_line);
|
||||
|
||||
regex pat{"^\\s*//\\s*--\\+\\s*options:([^\\+]*)\\+--"};
|
||||
regex pat{R"(^\s*//\s*--\+\s*options:([^\+]*)\+--)"};
|
||||
smatch matches;
|
||||
if (regex_search(first_line, matches, pat))
|
||||
if (matches.size() > 1 && matches[1].matched)
|
||||
{
|
||||
regex pat2{"([^,\\s]+)"};
|
||||
regex pat2{R"(([^,\s]+))"};
|
||||
string s{matches[1]};
|
||||
for (sregex_iterator p(s.begin(), s.end(), pat2);
|
||||
p != sregex_iterator{}; ++p)
|
||||
|
|
160
src/ExprNode.cc
160
src/ExprNode.cc
|
@ -458,7 +458,7 @@ NumConstNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
|||
void
|
||||
NumConstNode::writeJsonAST(ostream &output) const
|
||||
{
|
||||
output << "{\"node_type\" : \"NumConstNode\", \"value\" : ";
|
||||
output << R"({"node_type" : "NumConstNode", "value" : )";
|
||||
double testval = datatree.num_constants.getDouble(id);
|
||||
if (testval < 1.0 && testval > -1.0 && testval != 0.0)
|
||||
output << "0";
|
||||
|
@ -899,8 +899,8 @@ VariableNode::containsExternalFunction() const
|
|||
void
|
||||
VariableNode::writeJsonAST(ostream &output) const
|
||||
{
|
||||
output << "{\"node_type\" : \"VariableNode\", "
|
||||
<< "\"name\" : \"" << datatree.symbol_table.getName(symb_id) << "\", \"type\" : \"";
|
||||
output << R"({"node_type" : "VariableNode", )"
|
||||
<< R"("name" : ")" << datatree.symbol_table.getName(symb_id) << R"(", "type" : ")";
|
||||
switch (get_type())
|
||||
{
|
||||
case SymbolType::endogenous:
|
||||
|
@ -943,7 +943,7 @@ VariableNode::writeJsonAST(ostream &output) const
|
|||
output << "epilogue";
|
||||
break;
|
||||
}
|
||||
output << "\", \"lag\" : " << lag << "}";
|
||||
output << R"(", "lag" : )" << lag << "}";
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -977,7 +977,7 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
|||
if (isLatexOutput(output_type))
|
||||
{
|
||||
if (output_type == ExprNodeOutputType::latexDynamicSteadyStateOperator)
|
||||
output << "\\bar";
|
||||
output << R"(\bar)";
|
||||
output << "{" << datatree.symbol_table.getTeXName(symb_id);
|
||||
if (output_type == ExprNodeOutputType::latexDynamicModel
|
||||
&& (type == SymbolType::endogenous || type == SymbolType::exogenous || type == SymbolType::exogenousDet || type == SymbolType::modelLocalVariable || type == SymbolType::trend || type == SymbolType::logTrend))
|
||||
|
@ -2449,7 +2449,7 @@ UnaryOpNode::containsExternalFunction() const
|
|||
void
|
||||
UnaryOpNode::writeJsonAST(ostream &output) const
|
||||
{
|
||||
output << "{\"node_type\" : \"UnaryOpNode\", \"op\" : \"";
|
||||
output << R"({"node_type" : "UnaryOpNode", "op" : ")";
|
||||
switch (op_code)
|
||||
{
|
||||
case UnaryOpcode::uminus:
|
||||
|
@ -2530,13 +2530,13 @@ UnaryOpNode::writeJsonAST(ostream &output) const
|
|||
output << "erf";
|
||||
break;
|
||||
}
|
||||
output << "\", \"arg\" : ";
|
||||
output << R"(", "arg" : )";
|
||||
arg->writeJsonAST(output);
|
||||
switch (op_code)
|
||||
{
|
||||
case UnaryOpcode::adl:
|
||||
output << ", \"adl_param_name\" : \"" << adl_param_name << "\""
|
||||
<< ", \"lags\" : [";
|
||||
output << R"(, "adl_param_name" : ")" << adl_param_name << R"(")"
|
||||
<< R"(, "lags" : [)";
|
||||
for (auto it = adl_lags.begin(); it != adl_lags.end(); it++)
|
||||
{
|
||||
if (it != adl_lags.begin())
|
||||
|
@ -2728,13 +2728,13 @@ UnaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
|||
break;
|
||||
case UnaryOpcode::log:
|
||||
if (isLatexOutput(output_type))
|
||||
output << "\\log";
|
||||
output << R"(\log)";
|
||||
else
|
||||
output << "log";
|
||||
break;
|
||||
case UnaryOpcode::log10:
|
||||
if (isLatexOutput(output_type))
|
||||
output << "\\log_{10}";
|
||||
output << R"(\log_{10})";
|
||||
else
|
||||
output << "log10";
|
||||
break;
|
||||
|
@ -2846,7 +2846,7 @@ UnaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
|||
cerr << "UnaryOpNode::writeOutput: not implemented on UnaryOpcode::expectation" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
output << "\\mathbb{E}_{t";
|
||||
output << R"(\mathbb{E}_{t)";
|
||||
if (expectation_information_set != 0)
|
||||
{
|
||||
if (expectation_information_set > 0)
|
||||
|
@ -4400,8 +4400,8 @@ BinaryOpNode::containsExternalFunction() const
|
|||
void
|
||||
BinaryOpNode::writeJsonAST(ostream &output) const
|
||||
{
|
||||
output << "{\"node_type\" : \"BinaryOpNode\","
|
||||
<< " \"op\" : \"";
|
||||
output << R"({"node_type" : "BinaryOpNode",)"
|
||||
<< R"( "op" : ")";
|
||||
switch (op_code)
|
||||
{
|
||||
case BinaryOpcode::plus:
|
||||
|
@ -4450,9 +4450,9 @@ BinaryOpNode::writeJsonAST(ostream &output) const
|
|||
output << "power_deriv";
|
||||
break;
|
||||
}
|
||||
output << "\", \"arg1\" : ";
|
||||
output << R"(", "arg1" : )";
|
||||
arg1->writeJsonAST(output);
|
||||
output << ", \"arg2\" : ";
|
||||
output << R"(, "arg2" : )";
|
||||
arg2->writeJsonAST(output);
|
||||
output << "}";
|
||||
}
|
||||
|
@ -4646,7 +4646,7 @@ BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
|||
bool close_parenthesis = false;
|
||||
|
||||
if (isLatexOutput(output_type) && op_code == BinaryOpcode::divide)
|
||||
output << "\\frac{";
|
||||
output << R"(\frac{)";
|
||||
else
|
||||
{
|
||||
// If left argument has a lower precedence, or if current and left argument are both power operators, add parenthesis around left argument
|
||||
|
@ -4679,7 +4679,7 @@ BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
|||
break;
|
||||
case BinaryOpcode::times:
|
||||
if (isLatexOutput(output_type))
|
||||
output << "\\, ";
|
||||
output << R"(\, )";
|
||||
else
|
||||
output << "*";
|
||||
break;
|
||||
|
@ -4698,13 +4698,13 @@ BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
|||
break;
|
||||
case BinaryOpcode::lessEqual:
|
||||
if (isLatexOutput(output_type))
|
||||
output << "\\leq ";
|
||||
output << R"(\leq )";
|
||||
else
|
||||
output << "<=";
|
||||
break;
|
||||
case BinaryOpcode::greaterEqual:
|
||||
if (isLatexOutput(output_type))
|
||||
output << "\\geq ";
|
||||
output << R"(\geq )";
|
||||
else
|
||||
output << ">=";
|
||||
break;
|
||||
|
@ -4719,7 +4719,7 @@ BinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
|
|||
if (isCOutput(output_type) || isJuliaOutput(output_type))
|
||||
output << "!=";
|
||||
else
|
||||
output << "\\neq ";
|
||||
output << R"(\neq )";
|
||||
}
|
||||
break;
|
||||
case BinaryOpcode::equal:
|
||||
|
@ -6293,8 +6293,8 @@ TrinaryOpNode::containsExternalFunction() const
|
|||
void
|
||||
TrinaryOpNode::writeJsonAST(ostream &output) const
|
||||
{
|
||||
output << "{\"node_type\" : \"TrinaryOpNode\", "
|
||||
<< "\"op\" : \"";
|
||||
output << R"({"node_type" : "TrinaryOpNode", )"
|
||||
<< R"("op" : ")";
|
||||
switch (op_code)
|
||||
{
|
||||
case TrinaryOpcode::normcdf:
|
||||
|
@ -6304,11 +6304,11 @@ TrinaryOpNode::writeJsonAST(ostream &output) const
|
|||
output << "normpdf";
|
||||
break;
|
||||
}
|
||||
output << "\", \"arg1\" : ";
|
||||
output << R"(", "arg1" : )";
|
||||
arg1->writeJsonAST(output);
|
||||
output << ", \"arg2\" : ";
|
||||
output << R"(, "arg2" : )";
|
||||
arg2->writeJsonAST(output);
|
||||
output << ", \"arg2\" : ";
|
||||
output << R"(, "arg2" : )";
|
||||
arg3->writeJsonAST(output);
|
||||
output << "}";
|
||||
}
|
||||
|
@ -7440,7 +7440,7 @@ AbstractExternalFunctionNode::writeJsonASTExternalFunctionArguments(ostream &out
|
|||
if (it != arguments.begin())
|
||||
output << ",";
|
||||
|
||||
output << "\"arg" << i << "\" : ";
|
||||
output << R"("arg)" << i << R"(" : )";
|
||||
(*it)->writeJsonAST(output);
|
||||
}
|
||||
output << "}";
|
||||
|
@ -7634,8 +7634,8 @@ ExternalFunctionNode::compileExternalFunctionOutput(ostream &CompileCode, unsign
|
|||
void
|
||||
ExternalFunctionNode::writeJsonAST(ostream &output) const
|
||||
{
|
||||
output << "{\"node_type\" : \"ExternalFunctionNode\", "
|
||||
<< "\"name\" : \"" << datatree.symbol_table.getName(symb_id) << "\", \"args\" : [";
|
||||
output << R"({"node_type" : "ExternalFunctionNode", )"
|
||||
<< R"("name" : ")" << datatree.symbol_table.getName(symb_id) << R"(", "args" : [)";
|
||||
writeJsonASTExternalFunctionArguments(output);
|
||||
output << "]}";
|
||||
}
|
||||
|
@ -7729,8 +7729,8 @@ ExternalFunctionNode::writeExternalFunctionOutput(ostream &output, ExprNodeOutpu
|
|||
<< "nlhs" << ending.str() << ", "
|
||||
<< "plhs" << ending.str() << ", "
|
||||
<< "nrhs" << ending.str() << ", "
|
||||
<< "prhs" << ending.str() << ", \""
|
||||
<< datatree.symbol_table.getName(symb_id) << "\");" << endl;
|
||||
<< "prhs" << ending.str() << R"(, ")"
|
||||
<< datatree.symbol_table.getName(symb_id) << R"(");)" << endl;
|
||||
|
||||
if (symb_id == first_deriv_symb_id
|
||||
&& symb_id == second_deriv_symb_id)
|
||||
|
@ -7781,18 +7781,18 @@ ExternalFunctionNode::writeJsonExternalFunctionOutput(vector<string> &efout,
|
|||
assert(second_deriv_symb_id != ExternalFunctionsTable::IDSetButNoNameProvided);
|
||||
|
||||
stringstream ef;
|
||||
ef << "{\"external_function\": {"
|
||||
<< "\"external_function_term\": \"TEF_" << indx << "\"";
|
||||
ef << R"({"external_function": {)"
|
||||
<< R"("external_function_term": "TEF_)" << indx << R"(")";
|
||||
|
||||
if (symb_id == first_deriv_symb_id)
|
||||
ef << ", \"external_function_term_d\": \"TEFD_" << indx << "\"";
|
||||
ef << R"(, "external_function_term_d": "TEFD_)" << indx << R"(")";
|
||||
|
||||
if (symb_id == second_deriv_symb_id)
|
||||
ef << ", \"external_function_term_dd\": \"TEFDD_" << indx << "\"";
|
||||
ef << R"(, "external_function_term_dd": "TEFDD_)" << indx << R"(")";
|
||||
|
||||
ef << ", \"value\": \"" << datatree.symbol_table.getName(symb_id) << "(";
|
||||
ef << R"(, "value": ")" << datatree.symbol_table.getName(symb_id) << "(";
|
||||
writeJsonExternalFunctionArguments(ef, temporary_terms, tef_terms, isdynamic);
|
||||
ef << ")\"}}";
|
||||
ef << R"lit()"}})lit";
|
||||
efout.push_back(ef.str());
|
||||
}
|
||||
}
|
||||
|
@ -7878,8 +7878,8 @@ FirstDerivExternalFunctionNode::composeDerivatives(const vector<expr_t> &dargs)
|
|||
void
|
||||
FirstDerivExternalFunctionNode::writeJsonAST(ostream &output) const
|
||||
{
|
||||
output << "{\"node_type\" : \"FirstDerivExternalFunctionNode\", "
|
||||
<< "\"name\" : \"" << datatree.symbol_table.getName(symb_id) << "\", \"args\" : [";
|
||||
output << R"({"node_type" : "FirstDerivExternalFunctionNode", )"
|
||||
<< R"("name" : ")" << datatree.symbol_table.getName(symb_id) << R"(", "args" : [)";
|
||||
writeJsonASTExternalFunctionArguments(output);
|
||||
output << "]}";
|
||||
}
|
||||
|
@ -7923,8 +7923,8 @@ FirstDerivExternalFunctionNode::writeOutput(ostream &output, ExprNodeOutputType
|
|||
|
||||
if (isLatexOutput(output_type))
|
||||
{
|
||||
output << "\\frac{\\partial " << datatree.symbol_table.getTeXName(symb_id)
|
||||
<< "}{\\partial " << inputIndex << "}(";
|
||||
output << R"(\frac{\partial )" << datatree.symbol_table.getTeXName(symb_id)
|
||||
<< R"(}{\partial )" << inputIndex << "}(";
|
||||
writeExternalFunctionArguments(output, output_type, temporary_terms, temporary_terms_idxs, tef_terms);
|
||||
output << ")";
|
||||
return;
|
||||
|
@ -8028,7 +8028,7 @@ FirstDerivExternalFunctionNode::writeExternalFunctionOutput(ostream &output, Exp
|
|||
output << "dims" << ending.str() << "[0] = 1;" << endl
|
||||
<< "dims" << ending.str() << "[1] = " << arguments.size() << ";" << endl;
|
||||
|
||||
output << "prhs" << ending.str() << "[0] = mxCreateString(\"" << datatree.symbol_table.getName(symb_id) << "\");" << endl
|
||||
output << "prhs" << ending.str() << R"([0] = mxCreateString(")" << datatree.symbol_table.getName(symb_id) << R"(");)" << endl
|
||||
<< "prhs" << ending.str() << "[1] = mxCreateDoubleScalar(" << inputIndex << ");"<< endl
|
||||
<< "prhs" << ending.str() << "[2] = mxCreateCellArray(2, dims" << ending.str() << ");"<< endl;
|
||||
|
||||
|
@ -8046,8 +8046,8 @@ FirstDerivExternalFunctionNode::writeExternalFunctionOutput(ostream &output, Exp
|
|||
<< "nlhs" << ending.str() << ", "
|
||||
<< "plhs" << ending.str() << ", "
|
||||
<< "nrhs" << ending.str() << ", "
|
||||
<< "prhs" << ending.str() << ", \""
|
||||
<< "jacob_element\");" << endl;
|
||||
<< "prhs" << ending.str() << R"(, ")"
|
||||
<< R"(jacob_element");)" << endl;
|
||||
|
||||
output << "TEFD_fdd_" << getIndxInTefTerms(symb_id, tef_terms) << "_" << inputIndex
|
||||
<< " = mxGetPr(plhs" << ending.str() << "[0]);" << endl;
|
||||
|
@ -8068,8 +8068,8 @@ FirstDerivExternalFunctionNode::writeExternalFunctionOutput(ostream &output, Exp
|
|||
<< "nlhs" << ending.str() << ", "
|
||||
<< "plhs" << ending.str() << ", "
|
||||
<< "nrhs" << ending.str() << ", "
|
||||
<< "prhs" << ending.str() << ", \""
|
||||
<< datatree.symbol_table.getName(first_deriv_symb_id) << "\");" << endl;
|
||||
<< "prhs" << ending.str() << R"(, ")"
|
||||
<< datatree.symbol_table.getName(first_deriv_symb_id) << R"(");)" << endl;
|
||||
|
||||
output << "TEFD_def_" << indx << " = mxGetPr(plhs" << ending.str() << "[0]);" << endl;
|
||||
}
|
||||
|
@ -8116,22 +8116,22 @@ FirstDerivExternalFunctionNode::writeJsonExternalFunctionOutput(vector<string> &
|
|||
|
||||
stringstream ef;
|
||||
if (first_deriv_symb_id == ExternalFunctionsTable::IDNotSet)
|
||||
ef << "{\"first_deriv_external_function\": {"
|
||||
<< "\"external_function_term\": \"TEFD_fdd_" << getIndxInTefTerms(symb_id, tef_terms) << "_" << inputIndex << "\""
|
||||
<< ", \"analytic_derivative\": false"
|
||||
<< ", \"wrt\": " << inputIndex
|
||||
<< ", \"value\": \"" << datatree.symbol_table.getName(symb_id) << "(";
|
||||
ef << R"({"first_deriv_external_function": {)"
|
||||
<< R"("external_function_term": "TEFD_fdd_)" << getIndxInTefTerms(symb_id, tef_terms) << "_" << inputIndex << R"(")"
|
||||
<< R"(, "analytic_derivative": false)"
|
||||
<< R"(, "wrt": )" << inputIndex
|
||||
<< R"(, "value": ")" << datatree.symbol_table.getName(symb_id) << "(";
|
||||
else
|
||||
{
|
||||
tef_terms[{ first_deriv_symb_id, arguments }] = (int) tef_terms.size();
|
||||
ef << "{\"first_deriv_external_function\": {"
|
||||
<< "\"external_function_term\": \"TEFD_def_" << getIndxInTefTerms(first_deriv_symb_id, tef_terms) << "\""
|
||||
<< ", \"analytic_derivative\": true"
|
||||
<< ", \"value\": \"" << datatree.symbol_table.getName(first_deriv_symb_id) << "(";
|
||||
ef << R"({"first_deriv_external_function": {)"
|
||||
<< R"("external_function_term": "TEFD_def_)" << getIndxInTefTerms(first_deriv_symb_id, tef_terms) << R"(")"
|
||||
<< R"(, "analytic_derivative": true)"
|
||||
<< R"(, "value": ")" << datatree.symbol_table.getName(first_deriv_symb_id) << "(";
|
||||
}
|
||||
|
||||
writeJsonExternalFunctionArguments(ef, temporary_terms, tef_terms, isdynamic);
|
||||
ef << ")\"}}";
|
||||
ef << R"lit()"}})lit";
|
||||
efout.push_back(ef.str());
|
||||
}
|
||||
|
||||
|
@ -8267,8 +8267,8 @@ SecondDerivExternalFunctionNode::composeDerivatives(const vector<expr_t> &dargs)
|
|||
void
|
||||
SecondDerivExternalFunctionNode::writeJsonAST(ostream &output) const
|
||||
{
|
||||
output << "{\"node_type\" : \"SecondDerivExternalFunctionNode\", "
|
||||
<< "\"name\" : \"" << datatree.symbol_table.getName(symb_id) << "\", \"args\" : [";
|
||||
output << R"({"node_type" : "SecondDerivExternalFunctionNode", )"
|
||||
<< R"("name" : ")" << datatree.symbol_table.getName(symb_id) << R"(", "args" : [)";
|
||||
writeJsonASTExternalFunctionArguments(output);
|
||||
output << "]}";
|
||||
}
|
||||
|
@ -8313,8 +8313,8 @@ SecondDerivExternalFunctionNode::writeOutput(ostream &output, ExprNodeOutputType
|
|||
|
||||
if (isLatexOutput(output_type))
|
||||
{
|
||||
output << "\\frac{\\partial^2 " << datatree.symbol_table.getTeXName(symb_id)
|
||||
<< "}{\\partial " << inputIndex1 << "\\partial " << inputIndex2 << "}(";
|
||||
output << R"(\frac{\partial^2 )" << datatree.symbol_table.getTeXName(symb_id)
|
||||
<< R"(}{\partial )" << inputIndex1 << R"(\partial )" << inputIndex2 << "}(";
|
||||
writeExternalFunctionArguments(output, output_type, temporary_terms, temporary_terms_idxs, tef_terms);
|
||||
output << ")";
|
||||
return;
|
||||
|
@ -8392,7 +8392,7 @@ SecondDerivExternalFunctionNode::writeExternalFunctionOutput(ostream &output, Ex
|
|||
output << "dims" << ending.str() << "[0] = 1;" << endl
|
||||
<< "dims" << ending.str() << "[1] = " << arguments.size() << ";" << endl;
|
||||
|
||||
output << "prhs" << ending.str() << "[0] = mxCreateString(\"" << datatree.symbol_table.getName(symb_id) << "\");" << endl
|
||||
output << "prhs" << ending.str() << R"([0] = mxCreateString(")" << datatree.symbol_table.getName(symb_id) << R"(");)" << endl
|
||||
<< "prhs" << ending.str() << "[1] = mxCreateDoubleScalar(" << inputIndex1 << ");"<< endl
|
||||
<< "prhs" << ending.str() << "[2] = mxCreateDoubleScalar(" << inputIndex2 << ");"<< endl
|
||||
<< "prhs" << ending.str() << "[3] = mxCreateCellArray(2, dims" << ending.str() << ");"<< endl;
|
||||
|
@ -8411,8 +8411,8 @@ SecondDerivExternalFunctionNode::writeExternalFunctionOutput(ostream &output, Ex
|
|||
<< "nlhs" << ending.str() << ", "
|
||||
<< "plhs" << ending.str() << ", "
|
||||
<< "nrhs" << ending.str() << ", "
|
||||
<< "prhs" << ending.str() << ", \""
|
||||
<< "hess_element\");" << endl;
|
||||
<< "prhs" << ending.str() << R"(, ")"
|
||||
<< R"(hess_element");)" << endl;
|
||||
|
||||
output << "TEFDD_fdd_" << getIndxInTefTerms(symb_id, tef_terms) << "_" << inputIndex1 << "_" << inputIndex2
|
||||
<< " = mxGetPr(plhs" << ending.str() << "[0]);" << endl;
|
||||
|
@ -8434,8 +8434,8 @@ SecondDerivExternalFunctionNode::writeExternalFunctionOutput(ostream &output, Ex
|
|||
<< "nlhs" << ending.str() << ", "
|
||||
<< "plhs" << ending.str() << ", "
|
||||
<< "nrhs" << ending.str() << ", "
|
||||
<< "prhs" << ending.str() << ", \""
|
||||
<< datatree.symbol_table.getName(second_deriv_symb_id) << "\");" << endl;
|
||||
<< "prhs" << ending.str() << R"(, ")"
|
||||
<< datatree.symbol_table.getName(second_deriv_symb_id) << R"(");)" << endl;
|
||||
|
||||
output << "TEFDD_def_" << indx << " = mxGetPr(plhs" << ending.str() << "[0]);" << endl;
|
||||
}
|
||||
|
@ -8483,23 +8483,23 @@ SecondDerivExternalFunctionNode::writeJsonExternalFunctionOutput(vector<string>
|
|||
|
||||
stringstream ef;
|
||||
if (second_deriv_symb_id == ExternalFunctionsTable::IDNotSet)
|
||||
ef << "{\"second_deriv_external_function\": {"
|
||||
<< "\"external_function_term\": \"TEFDD_fdd_" << getIndxInTefTerms(symb_id, tef_terms) << "_" << inputIndex1 << "_" << inputIndex2 << "\""
|
||||
<< ", \"analytic_derivative\": false"
|
||||
<< ", \"wrt1\": " << inputIndex1
|
||||
<< ", \"wrt2\": " << inputIndex2
|
||||
<< ", \"value\": \"" << datatree.symbol_table.getName(symb_id) << "(";
|
||||
ef << R"({"second_deriv_external_function": {)"
|
||||
<< R"("external_function_term": "TEFDD_fdd_)" << getIndxInTefTerms(symb_id, tef_terms) << "_" << inputIndex1 << "_" << inputIndex2 << R"(")"
|
||||
<< R"(, "analytic_derivative": false)"
|
||||
<< R"(, "wrt1": )" << inputIndex1
|
||||
<< R"(, "wrt2": )" << inputIndex2
|
||||
<< R"(, "value": ")" << datatree.symbol_table.getName(symb_id) << "(";
|
||||
else
|
||||
{
|
||||
tef_terms[{ second_deriv_symb_id, arguments }] = (int) tef_terms.size();
|
||||
ef << "{\"second_deriv_external_function\": {"
|
||||
<< "\"external_function_term\": \"TEFDD_def_" << getIndxInTefTerms(second_deriv_symb_id, tef_terms) << "\""
|
||||
<< ", \"analytic_derivative\": true"
|
||||
<< ", \"value\": \"" << datatree.symbol_table.getName(second_deriv_symb_id) << "(";
|
||||
ef << R"({"second_deriv_external_function": {)"
|
||||
<< R"("external_function_term": "TEFDD_def_)" << getIndxInTefTerms(second_deriv_symb_id, tef_terms) << R"(")"
|
||||
<< R"(, "analytic_derivative": true)"
|
||||
<< R"(, "value": ")" << datatree.symbol_table.getName(second_deriv_symb_id) << "(";
|
||||
}
|
||||
|
||||
writeJsonExternalFunctionArguments(ef, temporary_terms, tef_terms, isdynamic);
|
||||
ef << ")\"}}" << endl;
|
||||
ef << R"lit()"}})lit" << endl;
|
||||
efout.push_back(ef.str());
|
||||
}
|
||||
|
||||
|
@ -9012,8 +9012,8 @@ VarExpectationNode::replaceVarsInEquation(map<VariableNode *, NumConstNode *> &t
|
|||
void
|
||||
VarExpectationNode::writeJsonAST(ostream &output) const
|
||||
{
|
||||
output << "{\"node_type\" : \"VarExpectationNode\", "
|
||||
<< "\"name\" : \"" << model_name << "\"}";
|
||||
output << R"({"node_type" : "VarExpectationNode", )"
|
||||
<< R"("name" : ")" << model_name << R"("})";
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -9416,8 +9416,8 @@ PacExpectationNode::replaceVarsInEquation(map<VariableNode *, NumConstNode *> &t
|
|||
void
|
||||
PacExpectationNode::writeJsonAST(ostream &output) const
|
||||
{
|
||||
output << "{\"node_type\" : \"PacExpectationNode\", "
|
||||
<< "\"name\" : \"" << model_name << "\"}";
|
||||
output << R"({"node_type" : "PacExpectationNode", )"
|
||||
<< R"("name" : ")" << model_name << R"("})";
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -301,7 +301,7 @@ ModFile::checkPass(bool nostrict, bool stochastic)
|
|||
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::lessEqual)
|
||||
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::equalEqual)
|
||||
|| dynamic_model.isBinaryOpUsed(BinaryOpcode::different)))
|
||||
warnings << "WARNING: you are using a function (max, min, abs, sign) or an operator (<, >, <=, >=, ==, !=) which is unsuitable for a stochastic context; see the reference manual, section about \"Expressions\", for more details." << endl;
|
||||
warnings << R"(WARNING: you are using a function (max, min, abs, sign) or an operator (<, >, <=, >=, ==, !=) which is unsuitable for a stochastic context; see the reference manual, section about "Expressions", for more details.)" << endl;
|
||||
|
||||
if (linear
|
||||
&& (dynamic_model.isUnaryOpUsed(UnaryOpcode::sign)
|
||||
|
@ -944,7 +944,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
|
|||
mOutputFile << "options_.parallel_info.local_files = {" << endl;
|
||||
for (const auto & parallel_local_file : parallel_local_files)
|
||||
{
|
||||
size_t j = parallel_local_file.find_last_of("/\\");
|
||||
size_t j = parallel_local_file.find_last_of(R"(/\)");
|
||||
if (j == string::npos)
|
||||
mOutputFile << "'', '" << parallel_local_file << "';" << endl;
|
||||
else
|
||||
|
@ -1158,10 +1158,10 @@ ModFile::writeExternalFilesJulia(const string &basename, FileOutputType output)
|
|||
<< "using SteadyState" << endl << endl
|
||||
<< "using " << basename << "Static" << endl
|
||||
<< "using " << basename << "Dynamic" << endl
|
||||
<< "if isfile(\"" << basename << "SteadyState.jl" "\")" << endl
|
||||
<< R"(if isfile(")" << basename << R"(SteadyState.jl"))" << endl
|
||||
<< " using " << basename << "SteadyState" << endl
|
||||
<< "end" << endl
|
||||
<< "if isfile(\"" << basename << "SteadyState2.jl" "\")" << endl
|
||||
<< R"(if isfile(")" << basename << R"(SteadyState2.jl"))" << endl
|
||||
<< " using " << basename << "SteadyState2" << endl
|
||||
<< "end" << endl << endl
|
||||
<< "export model_, options_, oo_" << endl;
|
||||
|
@ -1169,20 +1169,20 @@ ModFile::writeExternalFilesJulia(const string &basename, FileOutputType output)
|
|||
// Write Output
|
||||
jlOutputFile << endl
|
||||
<< "oo_ = dynare_output()" << endl
|
||||
<< "oo_.dynare_version = \"" << PACKAGE_VERSION << "\"" << endl;
|
||||
<< R"(oo_.dynare_version = ")" << PACKAGE_VERSION << R"(")" << endl;
|
||||
|
||||
// Write Options
|
||||
jlOutputFile << endl
|
||||
<< "options_ = dynare_options()" << endl
|
||||
<< "options_.dynare_version = \"" << PACKAGE_VERSION << "\"" << endl;
|
||||
<< R"(options_.dynare_version = ")" << PACKAGE_VERSION << R"(")" << endl;
|
||||
if (linear == 1)
|
||||
jlOutputFile << "options_.linear = true" << endl;
|
||||
|
||||
// Write Model
|
||||
jlOutputFile << endl
|
||||
<< "model_ = dynare_model()" << endl
|
||||
<< "model_.fname = \"" << basename << "\"" << endl
|
||||
<< "model_.dynare_version = \"" << PACKAGE_VERSION << "\"" << endl
|
||||
<< R"(model_.fname = ")" << basename << R"(")" << endl
|
||||
<< R"(model_.dynare_version = ")" << PACKAGE_VERSION << R"(")" << endl
|
||||
<< "model_.sigma_e = zeros(Float64, " << symbol_table.exo_nbr() << ", "
|
||||
<< symbol_table.exo_nbr() << ")" << endl
|
||||
<< "model_.correlation_matrix = ones(Float64, " << symbol_table.exo_nbr() << ", "
|
||||
|
@ -1229,19 +1229,19 @@ ModFile::writeExternalFilesJulia(const string &basename, FileOutputType output)
|
|||
<< "model_.dynamic = " << basename << "Dynamic.dynamic!" << endl
|
||||
<< "model_.temporaries.static = " << basename << "Static.tmp_nbr" << endl
|
||||
<< "model_.temporaries.dynamic = " << basename << "Dynamic.tmp_nbr" << endl
|
||||
<< "if isfile(\"" << basename << "SteadyState.jl" "\")" << endl
|
||||
<< R"(if isfile(")" << basename << R"(SteadyState.jl"))" << endl
|
||||
<< " model_.user_written_analytical_steady_state = true" << endl
|
||||
<< " model_.steady_state = " << basename << "SteadyState.steady_state!" << endl
|
||||
<< "end" << endl
|
||||
<< "if isfile(\"" << basename << "SteadyState2.jl" "\")" << endl
|
||||
<< R"(if isfile(")" << basename << R"(SteadyState2.jl"))" << endl
|
||||
<< " model_.analytical_steady_state = true" << endl
|
||||
<< " model_.steady_state = " << basename << "SteadyState2.steady_state!" << endl
|
||||
<< "end" << endl
|
||||
<< "if isfile(\"" << basename << "StaticParamsDerivs.jl" "\")" << endl
|
||||
<< R"(if isfile(")" << basename << R"(StaticParamsDerivs.jl"))" << endl
|
||||
<< " using " << basename << "StaticParamsDerivs" << endl
|
||||
<< " model_.static_params_derivs = " << basename << "StaticParamsDerivs.params_derivs" << endl
|
||||
<< "end" << endl
|
||||
<< "if isfile(\"" << basename << "DynamicParamsDerivs.jl" "\")" << endl
|
||||
<< R"(if isfile(")" << basename << R"(DynamicParamsDerivs.jl"))" << endl
|
||||
<< " using " << basename << "DynamicParamsDerivs" << endl
|
||||
<< " model_.dynamic_params_derivs = " << basename << "DynamicParamsDerivs.params_derivs" << endl
|
||||
<< "end" << endl
|
||||
|
@ -1312,7 +1312,7 @@ ModFile::writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType
|
|||
|| !var_model_table.empty()
|
||||
|| !trend_component_model_table.empty())
|
||||
{
|
||||
output << ", \"statements\": [";
|
||||
output << R"(, "statements": [)";
|
||||
if (!var_model_table.empty())
|
||||
{
|
||||
var_model_table.writeJsonOutput(output);
|
||||
|
@ -1350,7 +1350,7 @@ ModFile::writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType
|
|||
original_model.writeJsonOriginalModelOutput(original_model_output);
|
||||
if (!statements.empty() || !var_model_table.empty() || !trend_component_model_table.empty())
|
||||
{
|
||||
original_model_output << endl << ", \"statements\": [";
|
||||
original_model_output << endl << R"(, "statements": [)";
|
||||
if (!var_model_table.empty())
|
||||
{
|
||||
var_model_table.writeJsonOutput(original_model_output);
|
||||
|
@ -1381,14 +1381,14 @@ ModFile::writeJsonOutputParsingCheck(const string &basename, JsonFileOutputType
|
|||
if (json_output_mode == JsonFileOutputType::standardout)
|
||||
{
|
||||
if (transformpass || computingpass)
|
||||
cout << "\"transformed_modfile\": ";
|
||||
cout << R"("transformed_modfile": )";
|
||||
else
|
||||
cout << "\"modfile\": ";
|
||||
cout << R"("modfile": )";
|
||||
cout << output.str();
|
||||
if (!original_model_output.str().empty())
|
||||
cout << ", \"original_model\": " << original_model_output.str();
|
||||
cout << R"(, "original_model": )" << original_model_output.str();
|
||||
if (!steady_state_model_output.str().empty())
|
||||
cout << ", \"steady_state_model\": " << steady_state_model_output.str();
|
||||
cout << R"(, "steady_state_model": )" << steady_state_model_output.str();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1492,14 +1492,14 @@ ModFile::writeJsonComputingPassOutput(const string &basename, JsonFileOutputType
|
|||
|
||||
if (json_output_mode == JsonFileOutputType::standardout)
|
||||
{
|
||||
cout << ", \"static_model\": " << static_output.str() << endl
|
||||
<< ", \"dynamic_model\": " << dynamic_output.str() << endl;
|
||||
cout << R"(, "static_model": )" << static_output.str() << endl
|
||||
<< R"(, "dynamic_model": )" << dynamic_output.str() << endl;
|
||||
|
||||
if (!static_paramsd_output.str().empty())
|
||||
cout << ", \"static_params_deriv\": " << static_paramsd_output.str() << endl;
|
||||
cout << R"(, "static_params_deriv": )" << static_paramsd_output.str() << endl;
|
||||
|
||||
if (!dynamic_paramsd_output.str().empty())
|
||||
cout << ", \"dynamic_params_deriv\": " << dynamic_paramsd_output.str() << endl;
|
||||
cout << R"(, "dynamic_params_deriv": )" << dynamic_paramsd_output.str() << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1434,7 +1434,7 @@ ModelTree::writeJsonTemporaryTerms(const temporary_terms_t &tt, const temporary_
|
|||
bool wrote_term = false;
|
||||
temporary_terms_t tt2 = ttm1;
|
||||
|
||||
output << "\"external_functions_temporary_terms_" << concat << "\": [";
|
||||
output << R"("external_functions_temporary_terms_)" << concat << R"(": [)";
|
||||
for (auto it : tt)
|
||||
if (ttm1.find(it) == ttm1.end())
|
||||
{
|
||||
|
@ -1458,19 +1458,19 @@ ModelTree::writeJsonTemporaryTerms(const temporary_terms_t &tt, const temporary_
|
|||
tt2 = ttm1;
|
||||
wrote_term = false;
|
||||
output << "]"
|
||||
<< ", \"temporary_terms_" << concat << "\": [";
|
||||
<< R"(, "temporary_terms_)" << concat << R"(": [)";
|
||||
for (auto it = tt.begin();
|
||||
it != tt.end(); it++)
|
||||
if (ttm1.find(*it) == ttm1.end())
|
||||
{
|
||||
if (wrote_term)
|
||||
output << ", ";
|
||||
output << "{\"temporary_term\": \"";
|
||||
output << R"({"temporary_term": ")";
|
||||
(*it)->writeJsonOutput(output, tt, tef_terms);
|
||||
output << "\""
|
||||
<< ", \"value\": \"";
|
||||
output << R"(")"
|
||||
<< R"(, "value": ")";
|
||||
(*it)->writeJsonOutput(output, tt2, tef_terms);
|
||||
output << "\"}" << endl;
|
||||
output << R"("})" << endl;
|
||||
wrote_term = true;
|
||||
|
||||
// Insert current node into tt2
|
||||
|
@ -1647,7 +1647,7 @@ ModelTree::writeJsonModelLocalVariables(ostream &output, deriv_node_temp_terms_t
|
|||
for (auto equation : equations)
|
||||
equation->collectVariables(SymbolType::modelLocalVariable, used_local_vars);
|
||||
|
||||
output << "\"model_local_variables\": [";
|
||||
output << R"("model_local_variables": [)";
|
||||
bool printed = false;
|
||||
for (int it : local_variables_vector)
|
||||
if (used_local_vars.find(it) != used_local_vars.end())
|
||||
|
@ -1673,10 +1673,10 @@ ModelTree::writeJsonModelLocalVariables(ostream &output, deriv_node_temp_terms_t
|
|||
|
||||
/* We append underscores to avoid name clashes with "g1" or "oo_" (see
|
||||
also VariableNode::writeOutput) */
|
||||
output << "{\"variable\": \"" << symbol_table.getName(id) << "__\""
|
||||
<< ", \"value\": \"";
|
||||
output << R"({"variable": ")" << symbol_table.getName(id) << R"(__")"
|
||||
<< R"(, "value": ")";
|
||||
value->writeJsonOutput(output, tt, tef_terms);
|
||||
output << "\"}" << endl;
|
||||
output << R"("})" << endl;
|
||||
}
|
||||
output << "]";
|
||||
}
|
||||
|
@ -1800,7 +1800,7 @@ ModelTree::Write_Inf_To_Bin_File(const string &filename,
|
|||
SaveCode.open(filename, ios::out | ios::binary);
|
||||
if (!SaveCode.is_open())
|
||||
{
|
||||
cerr << "Error : Can't open file \"" << filename << "\" for writing" << endl;
|
||||
cerr << R"(Error : Can't open file ")" << filename << R"(" for writing)" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
u_count_int = 0;
|
||||
|
@ -1852,24 +1852,24 @@ ModelTree::writeLatexModelFile(const string &basename, ExprNodeOutputType output
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
output << "\\documentclass[10pt,a4paper]{article}" << endl
|
||||
<< "\\usepackage[landscape]{geometry}" << endl
|
||||
<< "\\usepackage{fullpage}" << endl
|
||||
<< "\\usepackage{amsfonts}" << endl
|
||||
<< "\\usepackage{breqn}" << endl
|
||||
<< "\\begin{document}" << endl
|
||||
<< "\\footnotesize" << endl;
|
||||
output << R"(\documentclass[10pt,a4paper]{article})" << endl
|
||||
<< R"(\usepackage[landscape]{geometry})" << endl
|
||||
<< R"(\usepackage{fullpage})" << endl
|
||||
<< R"(\usepackage{amsfonts})" << endl
|
||||
<< R"(\usepackage{breqn})" << endl
|
||||
<< R"(\begin{document})" << endl
|
||||
<< R"(\footnotesize)" << endl;
|
||||
|
||||
// Write model local variables
|
||||
for (int id : local_variables_vector)
|
||||
{
|
||||
expr_t value = local_variables_table.find(id)->second;
|
||||
|
||||
content_output << "\\begin{dmath*}" << endl
|
||||
content_output << R"(\begin{dmath*})" << endl
|
||||
<< symbol_table.getTeXName(id) << " = ";
|
||||
// Use an empty set for the temporary terms
|
||||
value->writeOutput(content_output, output_type);
|
||||
content_output << endl << "\\end{dmath*}" << endl;
|
||||
content_output << endl << R"(\end{dmath*})" << endl;
|
||||
}
|
||||
|
||||
for (int eq = 0; eq < (int) equations.size(); eq++)
|
||||
|
@ -1882,7 +1882,7 @@ ModelTree::writeLatexModelFile(const string &basename, ExprNodeOutputType output
|
|||
if (equation_tag.first == eq)
|
||||
{
|
||||
if (!wrote_eq_tag)
|
||||
content_output << "\\noindent[";
|
||||
content_output << R"(\noindent[)";
|
||||
else
|
||||
content_output << ", ";
|
||||
|
||||
|
@ -1898,14 +1898,14 @@ ModelTree::writeLatexModelFile(const string &basename, ExprNodeOutputType output
|
|||
content_output << "]";
|
||||
}
|
||||
|
||||
content_output << "\\begin{dmath}" << endl;
|
||||
content_output << R"(\begin{dmath})" << endl;
|
||||
// Here it is necessary to cast to superclass ExprNode, otherwise the overloaded writeOutput() method is not found
|
||||
dynamic_cast<ExprNode *>(equations[eq])->writeOutput(content_output, output_type);
|
||||
content_output << endl << "\\end{dmath}" << endl;
|
||||
content_output << endl << R"(\end{dmath})" << endl;
|
||||
}
|
||||
|
||||
output << "\\include{" << content_basename << "}" << endl
|
||||
<< "\\end{document}" << endl;
|
||||
output << R"(\include{)" << content_basename << "}" << endl
|
||||
<< R"(\end{document})" << endl;
|
||||
|
||||
output.close();
|
||||
content_output.close();
|
||||
|
@ -2114,9 +2114,9 @@ ModelTree::writeJsonModelEquations(ostream &output, bool residuals) const
|
|||
vector<pair<string, string>> eqtags;
|
||||
temporary_terms_t tt_empty;
|
||||
if (residuals)
|
||||
output << endl << "\"residuals\":[" << endl;
|
||||
output << endl << R"("residuals":[)" << endl;
|
||||
else
|
||||
output << endl << "\"model\":[" << endl;
|
||||
output << endl << R"("model":[)" << endl;
|
||||
for (int eq = 0; eq < (int) equations.size(); eq++)
|
||||
{
|
||||
if (eq > 0)
|
||||
|
@ -2128,22 +2128,22 @@ ModelTree::writeJsonModelEquations(ostream &output, bool residuals) const
|
|||
|
||||
if (residuals)
|
||||
{
|
||||
output << "{\"residual\": {"
|
||||
<< "\"lhs\": \"";
|
||||
output << R"({"residual": {)"
|
||||
<< R"("lhs": ")";
|
||||
lhs->writeJsonOutput(output, temporary_terms, {});
|
||||
output << "\"";
|
||||
output << R"(")";
|
||||
|
||||
output << ", \"rhs\": \"";
|
||||
output << R"(, "rhs": ")";
|
||||
rhs->writeJsonOutput(output, temporary_terms, {});
|
||||
output << "\"";
|
||||
output << R"(")";
|
||||
try
|
||||
{
|
||||
// Test if the right hand side of the equation is empty.
|
||||
if (rhs->eval(eval_context_t()) != 0)
|
||||
{
|
||||
output << ", \"rhs\": \"";
|
||||
output << R"(, "rhs": ")";
|
||||
rhs->writeJsonOutput(output, temporary_terms, {});
|
||||
output << "\"";
|
||||
output << R"(")";
|
||||
}
|
||||
}
|
||||
catch (ExprNode::EvalException &e)
|
||||
|
@ -2153,12 +2153,12 @@ ModelTree::writeJsonModelEquations(ostream &output, bool residuals) const
|
|||
}
|
||||
else
|
||||
{
|
||||
output << "{\"lhs\": \"";
|
||||
output << R"({"lhs": ")";
|
||||
lhs->writeJsonOutput(output, tt_empty, {});
|
||||
output << "\", \"rhs\": \"";
|
||||
output << R"(", "rhs": ")";
|
||||
rhs->writeJsonOutput(output, tt_empty, {});
|
||||
output << "\""
|
||||
<< ", \"line\": " << equations_lineno[eq];
|
||||
output << R"(")"
|
||||
<< R"(, "line": )" << equations_lineno[eq];
|
||||
|
||||
for (const auto & equation_tag : equation_tags)
|
||||
if (equation_tag.first == eq)
|
||||
|
@ -2166,13 +2166,13 @@ ModelTree::writeJsonModelEquations(ostream &output, bool residuals) const
|
|||
|
||||
if (!eqtags.empty())
|
||||
{
|
||||
output << ", \"tags\": {";
|
||||
output << R"(, "tags": {)";
|
||||
int i = 0;
|
||||
for (vector<pair<string, string>>::const_iterator it = eqtags.begin(); it != eqtags.end(); it++, i++)
|
||||
{
|
||||
if (i != 0)
|
||||
output << ", ";
|
||||
output << "\"" << it->first << "\": \"" << it->second << "\"";
|
||||
output << R"(")" << it->first << R"(": ")" << it->second << R"(")";
|
||||
}
|
||||
output << "}";
|
||||
eqtags.clear();
|
||||
|
|
|
@ -67,9 +67,9 @@ InitParamStatement::writeJuliaOutput(ostream &output, const string &basename)
|
|||
void
|
||||
InitParamStatement::writeJsonOutput(ostream &output) const
|
||||
{
|
||||
output << "{\"statementName\": \"param_init\", \"name\": \"" << symbol_table.getName(symb_id) << "\", " << "\"value\": \"";
|
||||
output << R"({"statementName": "param_init", "name": ")" << symbol_table.getName(symb_id) << R"(", )" << R"("value": ")";
|
||||
param_value->writeJsonOutput(output, {}, {});
|
||||
output << "\"}";
|
||||
output << R"("})";
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -179,9 +179,9 @@ InitOrEndValStatement::writeJsonInitValues(ostream &output) const
|
|||
{
|
||||
if (it != init_values.begin())
|
||||
output << ", ";
|
||||
output << "{\"name\": \"" << symbol_table.getName(it->first) << "\", " << "\"value\": \"";
|
||||
output << R"({"name": ")" << symbol_table.getName(it->first) << R"(", )" << R"("value": ")";
|
||||
it->second->writeJsonOutput(output, {}, {});
|
||||
output << "\"}";
|
||||
output << R"("})";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -233,7 +233,7 @@ InitValStatement::writeOutput(ostream &output, const string &basename, bool mini
|
|||
void
|
||||
InitValStatement::writeJsonOutput(ostream &output) const
|
||||
{
|
||||
output << "{\"statementName\": \"initval\", \"vals\": [";
|
||||
output << R"({"statementName": "initval", "vals": [)";
|
||||
writeJsonInitValues(output);
|
||||
output << "]}";
|
||||
}
|
||||
|
@ -298,7 +298,7 @@ EndValStatement::writeOutput(ostream &output, const string &basename, bool minim
|
|||
void
|
||||
EndValStatement::writeJsonOutput(ostream &output) const
|
||||
{
|
||||
output << "{\"statementName\": \"endval\", \"vals\": [";
|
||||
output << R"({"statementName": "endval", "vals": [)";
|
||||
writeJsonInitValues(output);
|
||||
output << "]}";
|
||||
}
|
||||
|
@ -394,17 +394,17 @@ HistValStatement::writeOutput(ostream &output, const string &basename, bool mini
|
|||
void
|
||||
HistValStatement::writeJsonOutput(ostream &output) const
|
||||
{
|
||||
output << "{\"statementName\": \"histval\", \"vals\": [";
|
||||
output << R"({"statementName": "histval", "vals": [)";
|
||||
for (auto it = hist_values.begin();
|
||||
it != hist_values.end(); it++)
|
||||
{
|
||||
if (it != hist_values.begin())
|
||||
output << ", ";
|
||||
output << "{ \"name\": \"" << symbol_table.getName(it->first.first) << "\""
|
||||
<< ", \"lag\": " << it->first.second
|
||||
<< ", \"value\": \"";
|
||||
output << R"({ "name": ")" << symbol_table.getName(it->first.first) << R"(")"
|
||||
<< R"(, "lag": )" << it->first.second
|
||||
<< R"(, "value": ")";
|
||||
it->second->writeJsonOutput(output, {}, {});
|
||||
output << "\"}";
|
||||
output << R"("})";
|
||||
}
|
||||
output << "]}";
|
||||
}
|
||||
|
@ -427,8 +427,8 @@ InitvalFileStatement::writeOutput(ostream &output, const string &basename, bool
|
|||
void
|
||||
InitvalFileStatement::writeJsonOutput(ostream &output) const
|
||||
{
|
||||
output << "{\"statementName\": \"init_val_file\""
|
||||
<< ", \"filename\": \"" << filename << "\""
|
||||
output << R"({"statementName": "init_val_file")"
|
||||
<< R"(, "filename": ")" << filename << R"(")"
|
||||
<< "}";
|
||||
}
|
||||
|
||||
|
@ -446,8 +446,8 @@ HistvalFileStatement::writeOutput(ostream &output, const string &basename, bool
|
|||
void
|
||||
HistvalFileStatement::writeJsonOutput(ostream &output) const
|
||||
{
|
||||
output << "{\"statementName\": \"hist_val_file\""
|
||||
<< ", \"filename\": \"" << filename << "\""
|
||||
output << R"({"statementName": "hist_val_file")"
|
||||
<< R"(, "filename": ")" << filename << R"(")"
|
||||
<< "}";
|
||||
}
|
||||
|
||||
|
@ -489,8 +489,8 @@ HomotopyStatement::writeOutput(ostream &output, const string &basename, bool min
|
|||
void
|
||||
HomotopyStatement::writeJsonOutput(ostream &output) const
|
||||
{
|
||||
output << "{\"statementName\": \"homotopy\", "
|
||||
<< "\"values\": [";
|
||||
output << R"({"statementName": "homotopy", )"
|
||||
<< R"("values": [)";
|
||||
for (auto it = homotopy_values.begin();
|
||||
it != homotopy_values.end(); ++it)
|
||||
{
|
||||
|
@ -501,15 +501,15 @@ HomotopyStatement::writeJsonOutput(ostream &output) const
|
|||
expr_t expression1, expression2;
|
||||
tie(symb_id, expression1, expression2) = *it;
|
||||
|
||||
output << "{\"name\": \"" << symbol_table.getName(symb_id) << "\""
|
||||
<< ", \"initial_value\": \"";
|
||||
output << R"({"name": ")" << symbol_table.getName(symb_id) << R"(")"
|
||||
<< R"(, "initial_value": ")";
|
||||
if (expression1)
|
||||
expression1->writeJsonOutput(output, {}, {});
|
||||
else
|
||||
output << "NaN";
|
||||
output << "\", \"final_value\": \"";
|
||||
output << R"(", "final_value": ")";
|
||||
expression2->writeJsonOutput(output, {}, {});
|
||||
output << "\"}";
|
||||
output << R"("})";
|
||||
}
|
||||
output << "]"
|
||||
<< "}";
|
||||
|
@ -529,8 +529,8 @@ SaveParamsAndSteadyStateStatement::writeOutput(ostream &output, const string &ba
|
|||
void
|
||||
SaveParamsAndSteadyStateStatement::writeJsonOutput(ostream &output) const
|
||||
{
|
||||
output << "{\"statementName\": \"save_params_and_steady_state\""
|
||||
<< ", \"filename\": \"" << filename << "\""
|
||||
output << R"({"statementName": "save_params_and_steady_state")"
|
||||
<< R"(, "filename": ")" << filename << R"(")"
|
||||
<< "}";
|
||||
}
|
||||
|
||||
|
@ -601,15 +601,15 @@ LoadParamsAndSteadyStateStatement::writeOutput(ostream &output, const string &ba
|
|||
void
|
||||
LoadParamsAndSteadyStateStatement::writeJsonOutput(ostream &output) const
|
||||
{
|
||||
output << "{\"statementName\": \"load_params_and_steady_state\""
|
||||
<< "\"values\": [";
|
||||
output << R"({"statementName": "load_params_and_steady_state")"
|
||||
<< R"("values": [)";
|
||||
for (auto it = content.begin();
|
||||
it != content.end(); it++)
|
||||
{
|
||||
if (it != content.begin())
|
||||
output << ", ";
|
||||
output << "{\"name\": \"" << symbol_table.getName(it->first) << "\""
|
||||
<< ", \"value\": \"" << it->second << "\"}";
|
||||
output << R"({"name": ")" << symbol_table.getName(it->first) << R"(")"
|
||||
<< R"(, "value": ")" << it->second << R"("})";
|
||||
}
|
||||
output << "]"
|
||||
<< "}";
|
||||
|
|
|
@ -70,24 +70,24 @@ AbstractShocksStatement::writeDetShocks(ostream &output) const
|
|||
void
|
||||
AbstractShocksStatement::writeJsonDetShocks(ostream &output) const
|
||||
{
|
||||
output << "\"deterministic_shocks\": [";
|
||||
output << R"("deterministic_shocks": [)";
|
||||
for (auto it = det_shocks.begin();
|
||||
it != det_shocks.end(); it++)
|
||||
{
|
||||
if (it != det_shocks.begin())
|
||||
output << ", ";
|
||||
output << "{\"var\": \"" << symbol_table.getName(it->first) << "\", "
|
||||
<< "\"values\": [";
|
||||
output << R"({"var": ")" << symbol_table.getName(it->first) << R"(", )"
|
||||
<< R"("values": [)";
|
||||
for (auto it1 = it->second.begin();
|
||||
it1 != it->second.end(); it1++)
|
||||
{
|
||||
if (it1 != it->second.begin())
|
||||
output << ", ";
|
||||
output << "{\"period1\": " << it1->period1 << ", "
|
||||
<< "\"period2\": " << it1->period2 << ", "
|
||||
<< "\"value\": \"";
|
||||
output << R"({"period1": )" << it1->period1 << ", "
|
||||
<< R"("period2": )" << it1->period2 << ", "
|
||||
<< R"("value": ")";
|
||||
it1->value->writeJsonOutput(output, {}, {});
|
||||
output << "\"}";
|
||||
output << R"("})";
|
||||
}
|
||||
output << "]}";
|
||||
}
|
||||
|
@ -153,8 +153,8 @@ ShocksStatement::writeOutput(ostream &output, const string &basename, bool minim
|
|||
void
|
||||
ShocksStatement::writeJsonOutput(ostream &output) const
|
||||
{
|
||||
output << "{\"statementName\": \"shocks\""
|
||||
<< ", \"overwrite\": ";
|
||||
output << R"({"statementName": "shocks")"
|
||||
<< R"(, "overwrite": )";
|
||||
if (overwrite)
|
||||
output << "true";
|
||||
else
|
||||
|
@ -164,52 +164,52 @@ ShocksStatement::writeJsonOutput(ostream &output) const
|
|||
output << ", ";
|
||||
writeJsonDetShocks(output);
|
||||
}
|
||||
output<< ", \"variance\": [";
|
||||
output<< R"(, "variance": [)";
|
||||
for (auto it = var_shocks.begin(); it != var_shocks.end(); it++)
|
||||
{
|
||||
if (it != var_shocks.begin())
|
||||
output << ", ";
|
||||
output << "{\"name\": \"" << symbol_table.getName(it->first) << "\", "
|
||||
<< "\"variance\": \"";
|
||||
output << R"({"name": ")" << symbol_table.getName(it->first) << R"(", )"
|
||||
<< R"("variance": ")";
|
||||
it->second->writeJsonOutput(output, {}, {});
|
||||
output << "\"}";
|
||||
output << R"("})";
|
||||
}
|
||||
output << "]"
|
||||
<< ", \"stderr\": [";
|
||||
<< R"(, "stderr": [)";
|
||||
for (auto it = std_shocks.begin(); it != std_shocks.end(); it++)
|
||||
{
|
||||
if (it != std_shocks.begin())
|
||||
output << ", ";
|
||||
output << "{\"name\": \"" << symbol_table.getName(it->first) << "\", "
|
||||
<< "\"stderr\": \"";
|
||||
output << R"({"name": ")" << symbol_table.getName(it->first) << R"(", )"
|
||||
<< R"("stderr": ")";
|
||||
it->second->writeJsonOutput(output, {}, {});
|
||||
output << "\"}";
|
||||
output << R"("})";
|
||||
}
|
||||
output << "]"
|
||||
<< ", \"covariance\": [";
|
||||
<< R"(, "covariance": [)";
|
||||
for (auto it = covar_shocks.begin(); it != covar_shocks.end(); it++)
|
||||
{
|
||||
if (it != covar_shocks.begin())
|
||||
output << ", ";
|
||||
output << "{"
|
||||
<< "\"name\": \"" << symbol_table.getName(it->first.first) << "\", "
|
||||
<< "\"name2\": \"" << symbol_table.getName(it->first.second) << "\", "
|
||||
<< "\"covariance\": \"";
|
||||
<< R"("name": ")" << symbol_table.getName(it->first.first) << R"(", )"
|
||||
<< R"("name2": ")" << symbol_table.getName(it->first.second) << R"(", )"
|
||||
<< R"("covariance": ")";
|
||||
it->second->writeJsonOutput(output, {}, {});
|
||||
output << "\"}";
|
||||
output << R"("})";
|
||||
}
|
||||
output << "]"
|
||||
<< ", \"correlation\": [";
|
||||
<< R"(, "correlation": [)";
|
||||
for (auto it = corr_shocks.begin(); it != corr_shocks.end(); it++)
|
||||
{
|
||||
if (it != corr_shocks.begin())
|
||||
output << ", ";
|
||||
output << "{"
|
||||
<< "\"name\": \"" << symbol_table.getName(it->first.first) << "\", "
|
||||
<< "\"name2\": \"" << symbol_table.getName(it->first.second) << "\", "
|
||||
<< "\"correlation\": \"";
|
||||
<< R"("name": ")" << symbol_table.getName(it->first.first) << R"(", )"
|
||||
<< R"("name2": ")" << symbol_table.getName(it->first.second) << R"(", )"
|
||||
<< R"("correlation": ")";
|
||||
it->second->writeJsonOutput(output, {}, {});
|
||||
output << "\"}";
|
||||
output << R"("})";
|
||||
}
|
||||
output << "]"
|
||||
<< "}";
|
||||
|
@ -487,23 +487,23 @@ ConditionalForecastPathsStatement::writeOutput(ostream &output, const string &ba
|
|||
void
|
||||
ConditionalForecastPathsStatement::writeJsonOutput(ostream &output) const
|
||||
{
|
||||
output << "{\"statementName\": \"conditional_forecast_paths\""
|
||||
<< ", \"paths\": [";
|
||||
output << R"({"statementName": "conditional_forecast_paths")"
|
||||
<< R"(, "paths": [)";
|
||||
for (auto it = paths.begin(); it != paths.end(); it++)
|
||||
{
|
||||
if (it != paths.begin())
|
||||
output << ", ";
|
||||
output << "{\"var\": \"" << symbol_table.getName(it->first) << "\", "
|
||||
<< "\"values\": [";
|
||||
output << R"({"var": ")" << symbol_table.getName(it->first) << R"(", )"
|
||||
<< R"("values": [)";
|
||||
for (auto it1 = it->second.begin(); it1 != it->second.end(); it1++)
|
||||
{
|
||||
if (it1 != it->second.begin())
|
||||
output << ", ";
|
||||
output << "{\"period1\": " << it1->period1 << ", "
|
||||
<< "\"period2\": " << it1->period2 << ", "
|
||||
<< "\"value\": \"";
|
||||
output << R"({"period1": )" << it1->period1 << ", "
|
||||
<< R"("period2": )" << it1->period2 << ", "
|
||||
<< R"("value": ")";
|
||||
it1->value->writeJsonOutput(output, {}, {});
|
||||
output << "\"}";
|
||||
output << R"("})";
|
||||
}
|
||||
output << "]}";
|
||||
}
|
||||
|
@ -534,17 +534,17 @@ MomentCalibration::writeOutput(ostream &output, const string &basename, bool min
|
|||
void
|
||||
MomentCalibration::writeJsonOutput(ostream &output) const
|
||||
{
|
||||
output << "{\"statementName\": \"moment_calibration\""
|
||||
<< ", \"moment_calibration_criteria\": [";
|
||||
output << R"({"statementName": "moment_calibration")"
|
||||
<< R"(, "moment_calibration_criteria": [)";
|
||||
for (auto it = constraints.begin(); it != constraints.end(); it++)
|
||||
{
|
||||
if (it != constraints.begin())
|
||||
output << ", ";
|
||||
output << "{\"endogenous1\": \"" << symbol_table.getName(it->endo1) << "\""
|
||||
<< ", \"endogenous2\": \"" << symbol_table.getName(it->endo2) << "\""
|
||||
<< ", \"lags\": \"" << it->lags << "\""
|
||||
<< ", \"lower_bound\": \"" << it->lower_bound << "\""
|
||||
<< ", \"upper_bound\": \"" << it->upper_bound << "\""
|
||||
output << R"({"endogenous1": ")" << symbol_table.getName(it->endo1) << R"(")"
|
||||
<< R"(, "endogenous2": ")" << symbol_table.getName(it->endo2) << R"(")"
|
||||
<< R"(, "lags": ")" << it->lags << R"(")"
|
||||
<< R"(, "lower_bound": ")" << it->lower_bound << R"(")"
|
||||
<< R"(, "upper_bound": ")" << it->upper_bound << R"(")"
|
||||
<< "}";
|
||||
}
|
||||
output << "]"
|
||||
|
@ -578,23 +578,23 @@ IrfCalibration::writeOutput(ostream &output, const string &basename, bool minima
|
|||
void
|
||||
IrfCalibration::writeJsonOutput(ostream &output) const
|
||||
{
|
||||
output << "{\"statementName\": \"irf_calibration\"";
|
||||
output << R"({"statementName": "irf_calibration")";
|
||||
if (options_list.getNumberOfOptions())
|
||||
{
|
||||
output << ", ";
|
||||
options_list.writeJsonOutput(output);
|
||||
}
|
||||
|
||||
output << ", \"irf_restrictions\": [";
|
||||
output << R"(, "irf_restrictions": [)";
|
||||
for (auto it = constraints.begin(); it != constraints.end(); it++)
|
||||
{
|
||||
if (it != constraints.begin())
|
||||
output << ", ";
|
||||
output << "{\"endogenous\": \"" << symbol_table.getName(it->endo) << "\""
|
||||
<< ", \"exogenous\": \"" << symbol_table.getName(it->exo) << "\""
|
||||
<< ", \"periods\": \"" << it->periods << "\""
|
||||
<< ", \"lower_bound\": \"" << it->lower_bound << "\""
|
||||
<< ", \"upper_bound\": \"" << it->upper_bound << "\""
|
||||
output << R"({"endogenous": ")" << symbol_table.getName(it->endo) << R"(")"
|
||||
<< R"(, "exogenous": ")" << symbol_table.getName(it->exo) << R"(")"
|
||||
<< R"(, "periods": ")" << it->periods << R"(")"
|
||||
<< R"(, "lower_bound": ")" << it->lower_bound << R"(")"
|
||||
<< R"(, "upper_bound": ")" << it->upper_bound << R"(")"
|
||||
<< "}";
|
||||
}
|
||||
output << "]"
|
||||
|
|
|
@ -55,9 +55,9 @@ void
|
|||
NativeStatement::writeOutput(ostream &output, const string &basename, bool minimal_workspace) const
|
||||
{
|
||||
using namespace boost::xpressive;
|
||||
string date_regex = "(-?\\d+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4]\\d|5[0-2])))";
|
||||
sregex regex_lookbehind = sregex::compile("(?<!\\$|\\d|[a-zA-Z_]|\\')" + date_regex);
|
||||
sregex regex_dollar = sregex::compile("(\\$)"+date_regex);
|
||||
string date_regex = R"((-?\d+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4]\d|5[0-2]))))";
|
||||
sregex regex_lookbehind = sregex::compile(R"((?<!\$|\d|[a-zA-Z_]|\'))" + date_regex);
|
||||
sregex regex_dollar = sregex::compile(R"((\$))"+date_regex);
|
||||
|
||||
string ns = regex_replace(native_statement, regex_lookbehind, "dates('$&')");
|
||||
ns = regex_replace(ns, regex_dollar, "$2"); //replace $DATE with DATE
|
||||
|
@ -67,8 +67,8 @@ NativeStatement::writeOutput(ostream &output, const string &basename, bool minim
|
|||
void
|
||||
NativeStatement::writeJsonOutput(ostream &output) const
|
||||
{
|
||||
output << "{\"statementName\": \"native\""
|
||||
<< ", \"string\": \"" << native_statement << "\""
|
||||
output << R"({"statementName": "native")"
|
||||
<< R"(, "string": ")" << native_statement << R"(")"
|
||||
<< "}";
|
||||
}
|
||||
|
||||
|
@ -86,8 +86,8 @@ VerbatimStatement::writeOutput(ostream &output, const string &basename, bool min
|
|||
void
|
||||
VerbatimStatement::writeJsonOutput(ostream &output) const
|
||||
{
|
||||
output << "{\"statementName\": \"verbatim\""
|
||||
<< ", \"string\": \"" << verbatim_statement << "\""
|
||||
output << R"({"statementName": "verbatim")"
|
||||
<< R"(, "string": ")" << verbatim_statement << R"(")"
|
||||
<< "}";
|
||||
}
|
||||
|
||||
|
@ -204,11 +204,11 @@ OptionsList::writeJsonOutput(ostream &output) const
|
|||
if (getNumberOfOptions() == 0)
|
||||
return;
|
||||
|
||||
output << "\"options\": {";
|
||||
output << R"("options": {)";
|
||||
for (auto it = num_options.begin();
|
||||
it != num_options.end();)
|
||||
{
|
||||
output << "\""<< it->first << "\": " << it->second;
|
||||
output << R"(")"<< it->first << R"(": )" << it->second;
|
||||
it++;
|
||||
if (it != num_options.end()
|
||||
|| !(paired_num_options.empty()
|
||||
|
@ -222,7 +222,7 @@ OptionsList::writeJsonOutput(ostream &output) const
|
|||
for (auto it = paired_num_options.begin();
|
||||
it != paired_num_options.end();)
|
||||
{
|
||||
output << "\""<< it->first << "\": [" << it->second.first << " " << it->second.second << "]";
|
||||
output << R"(")"<< it->first << R"(": [)" << it->second.first << " " << it->second.second << "]";
|
||||
it++;
|
||||
if (it != paired_num_options.end()
|
||||
|| !(string_options.empty()
|
||||
|
@ -235,7 +235,7 @@ OptionsList::writeJsonOutput(ostream &output) const
|
|||
for (auto it = string_options.begin();
|
||||
it != string_options.end();)
|
||||
{
|
||||
output << "\""<< it->first << "\": \"" << it->second << "\"";
|
||||
output << R"(")"<< it->first << R"(": ")" << it->second << R"(")";
|
||||
it++;
|
||||
if (it != string_options.end()
|
||||
|| !(date_options.empty()
|
||||
|
@ -247,7 +247,7 @@ OptionsList::writeJsonOutput(ostream &output) const
|
|||
for (auto it = date_options.begin();
|
||||
it != date_options.end();)
|
||||
{
|
||||
output << "\""<< it->first << "\": \"" << it->second << "\"";
|
||||
output << R"(")"<< it->first << R"(": ")" << it->second << R"(")";
|
||||
it++;
|
||||
if (it != date_options.end()
|
||||
|| !(symbol_list_options.empty()
|
||||
|
@ -258,7 +258,7 @@ OptionsList::writeJsonOutput(ostream &output) const
|
|||
for (auto it = symbol_list_options.begin();
|
||||
it != symbol_list_options.end();)
|
||||
{
|
||||
output << "\""<< it->first << "\": {";
|
||||
output << R"(")"<< it->first << R"(": {)";
|
||||
it->second.writeJsonOutput(output);
|
||||
output << "}";
|
||||
it++;
|
||||
|
@ -270,7 +270,7 @@ OptionsList::writeJsonOutput(ostream &output) const
|
|||
for (auto it = vector_int_options.begin();
|
||||
it != vector_int_options.end();)
|
||||
{
|
||||
output << "\""<< it->first << "\": [";
|
||||
output << R"(")"<< it->first << R"(": [)";
|
||||
if (it->second.size() > 1)
|
||||
{
|
||||
for (auto viit = it->second.begin();
|
||||
|
@ -293,13 +293,13 @@ OptionsList::writeJsonOutput(ostream &output) const
|
|||
for (auto it = vector_str_options.begin();
|
||||
it != vector_str_options.end();)
|
||||
{
|
||||
output << "\""<< it->first << "\": [";
|
||||
output << R"(")"<< it->first << R"(": [)";
|
||||
if (it->second.size() > 1)
|
||||
{
|
||||
for (auto viit = it->second.begin();
|
||||
viit != it->second.end();)
|
||||
{
|
||||
output << "\"" << *viit << "\"";
|
||||
output << R"(")" << *viit << R"(")";
|
||||
viit++;
|
||||
if (viit != it->second.end())
|
||||
output << ", ";
|
||||
|
|
|
@ -564,7 +564,7 @@ StaticModel::writeModelEquationsCode(const string &basename, map_idx_t map_idx)
|
|||
code_file.open(main_name, ios::out | ios::binary | ios::ate);
|
||||
if (!code_file.is_open())
|
||||
{
|
||||
cerr << "Error : Can't open file \"" << main_name << "\" for writing" << endl;
|
||||
cerr << R"(Error : Can't open file ")" << main_name << R"(" for writing)" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
int count_u;
|
||||
|
@ -741,7 +741,7 @@ StaticModel::writeModelEquationsCode_Block(const string &basename, map_idx_t map
|
|||
code_file.open(main_name, ios::out | ios::binary | ios::ate);
|
||||
if (!code_file.is_open())
|
||||
{
|
||||
cerr << "Error : Can't open file \"" << main_name << "\" for writing" << endl;
|
||||
cerr << R"(Error : Can't open file ")" << main_name << R"(" for writing)" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
//Temporary variables declaration
|
||||
|
@ -2031,7 +2031,7 @@ StaticModel::writeStaticCFile(const string &basename) const
|
|||
if (external_functions_table.get_total_number_of_unique_model_block_external_functions())
|
||||
// External Matlab function, implies Static function will call mex
|
||||
output << "#include <uchar.h>" << endl // For MATLAB ≤ R2011a
|
||||
<< "#include \"mex.h\"" << endl;
|
||||
<< R"(#include "mex.h")" << endl;
|
||||
|
||||
output << "#define max(a, b) (((a) > (b)) ? (a) : (b))" << endl
|
||||
<< "#define min(a, b) (((a) > (b)) ? (b) : (a))" << endl;
|
||||
|
@ -2067,7 +2067,7 @@ StaticModel::writeStaticCFile(const string &basename) const
|
|||
<< endl
|
||||
<< "#include <stdlib.h>" << endl
|
||||
<< "#include <uchar.h>" << endl // For MATLAB ≤ R2011a
|
||||
<< "#include \"mex.h\"" << endl
|
||||
<< R"(#include "mex.h")" << endl
|
||||
<< endl
|
||||
<< "const int ntt = " << ntt << ";" << endl
|
||||
<< "void static_resid_tt(const double *y, const double *x, int nb_row_x, const double *params, double *T);" << endl
|
||||
|
@ -2557,9 +2557,9 @@ StaticModel::writeLatexAuxVarRecursiveDefinitions(ostream &output) const
|
|||
temporary_terms, temporary_terms_idxs, tef_terms);
|
||||
for (auto aux_equation : aux_equations)
|
||||
{
|
||||
output << "\\begin{dmath}" << endl;
|
||||
output << R"(\begin{dmath})" << endl;
|
||||
dynamic_cast<ExprNode *>(aux_equation->substituteStaticAuxiliaryDefinition())->writeOutput(output, ExprNodeOutputType::latexStaticModel);
|
||||
output << endl << "\\end{dmath}" << endl;
|
||||
output << endl << R"(\end{dmath})" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2587,11 +2587,11 @@ StaticModel::writeJsonAuxVarRecursiveDefinitions(ostream &output) const
|
|||
|
||||
for (auto aux_equation : aux_equations)
|
||||
{
|
||||
output << ", {\"lhs\": \"";
|
||||
output << R"(, {"lhs": ")";
|
||||
aux_equation->arg1->writeJsonOutput(output, temporary_terms, tef_terms, false);
|
||||
output << "\", \"rhs\": \"";
|
||||
output << R"(", "rhs": ")";
|
||||
dynamic_cast<BinaryOpNode *>(aux_equation->substituteStaticAuxiliaryDefinition())->arg2->writeJsonOutput(output, temporary_terms, tef_terms, false);
|
||||
output << "\"}";
|
||||
output << R"("})";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2915,10 +2915,10 @@ StaticModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) co
|
|||
temp_term_union.insert(temporary_terms_derivatives[1].begin(), temporary_terms_derivatives[1].end());
|
||||
concat = "jacobian";
|
||||
writeJsonTemporaryTerms(temp_term_union, temp_term_union_m_1, jacobian_output, tef_terms, concat);
|
||||
jacobian_output << ", \"jacobian\": {"
|
||||
<< " \"nrows\": " << nrows
|
||||
<< ", \"ncols\": " << JacobianColsNbr
|
||||
<< ", \"entries\": [";
|
||||
jacobian_output << R"(, "jacobian": {)"
|
||||
<< R"( "nrows": )" << nrows
|
||||
<< R"(, "ncols": )" << JacobianColsNbr
|
||||
<< R"(, "entries": [)";
|
||||
for (auto it = derivatives[1].begin();
|
||||
it != derivatives[1].end(); it++)
|
||||
{
|
||||
|
@ -2932,18 +2932,18 @@ StaticModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) co
|
|||
expr_t d1 = it->second;
|
||||
|
||||
if (writeDetails)
|
||||
jacobian_output << "{\"eq\": " << eq + 1;
|
||||
jacobian_output << R"({"eq": )" << eq + 1;
|
||||
else
|
||||
jacobian_output << "{\"row\": " << eq + 1;
|
||||
jacobian_output << R"({"row": )" << eq + 1;
|
||||
|
||||
jacobian_output << ", \"col\": " << col + 1;
|
||||
jacobian_output << R"(, "col": )" << col + 1;
|
||||
|
||||
if (writeDetails)
|
||||
jacobian_output << ", \"var\": \"" << symbol_table.getName(symb_id) << "\"";
|
||||
jacobian_output << R"(, "var": ")" << symbol_table.getName(symb_id) << R"(")";
|
||||
|
||||
jacobian_output << ", \"val\": \"";
|
||||
jacobian_output << R"(, "val": ")";
|
||||
d1->writeJsonOutput(jacobian_output, temp_term_union, tef_terms);
|
||||
jacobian_output << "\"}" << endl;
|
||||
jacobian_output << R"("})" << endl;
|
||||
}
|
||||
jacobian_output << "]}";
|
||||
|
||||
|
@ -2953,10 +2953,10 @@ StaticModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) co
|
|||
temp_term_union.insert(temporary_terms_derivatives[2].begin(), temporary_terms_derivatives[2].end());
|
||||
concat = "hessian";
|
||||
writeJsonTemporaryTerms(temp_term_union, temp_term_union_m_1, hessian_output, tef_terms, concat);
|
||||
hessian_output << ", \"hessian\": {"
|
||||
<< " \"nrows\": " << equations.size()
|
||||
<< ", \"ncols\": " << g2ncols
|
||||
<< ", \"entries\": [";
|
||||
hessian_output << R"(, "hessian": {)"
|
||||
<< R"( "nrows": )" << equations.size()
|
||||
<< R"(, "ncols": )" << g2ncols
|
||||
<< R"(, "entries": [)";
|
||||
for (auto it = derivatives[2].begin();
|
||||
it != derivatives[2].end(); it++)
|
||||
{
|
||||
|
@ -2976,22 +2976,22 @@ StaticModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) co
|
|||
int col_sym = tsid2*symbol_table.endo_nbr()+tsid1;
|
||||
|
||||
if (writeDetails)
|
||||
hessian_output << "{\"eq\": " << eq + 1;
|
||||
hessian_output << R"({"eq": )" << eq + 1;
|
||||
else
|
||||
hessian_output << "{\"row\": " << eq + 1;
|
||||
hessian_output << R"({"row": )" << eq + 1;
|
||||
|
||||
hessian_output << ", \"col\": [" << col + 1;
|
||||
hessian_output << R"(, "col": [)" << col + 1;
|
||||
|
||||
if (writeDetails)
|
||||
hessian_output << ", \"var1\": \"" << symbol_table.getName(symb_id1) << "\""
|
||||
<< ", \"var2\": \"" << symbol_table.getName(symb_id2) << "\"";
|
||||
hessian_output << R"(, "var1": ")" << symbol_table.getName(symb_id1) << R"(")"
|
||||
<< R"(, "var2": ")" << symbol_table.getName(symb_id2) << R"(")";
|
||||
|
||||
if (symb_id1 != symb_id2)
|
||||
hessian_output << ", " << col_sym + 1;
|
||||
hessian_output << "]"
|
||||
<< ", \"val\": \"";
|
||||
<< R"(, "val": ")";
|
||||
d2->writeJsonOutput(hessian_output, temp_term_union, tef_terms);
|
||||
hessian_output << "\"}" << endl;
|
||||
hessian_output << R"("})" << endl;
|
||||
}
|
||||
hessian_output << "]}";
|
||||
|
||||
|
@ -3000,10 +3000,10 @@ StaticModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) co
|
|||
temp_term_union.insert(temporary_terms_derivatives[3].begin(), temporary_terms_derivatives[3].end());
|
||||
concat = "third_derivatives";
|
||||
writeJsonTemporaryTerms(temp_term_union, temp_term_union_m_1, third_derivatives_output, tef_terms, concat);
|
||||
third_derivatives_output << ", \"third_derivative\": {"
|
||||
<< " \"nrows\": " << equations.size()
|
||||
<< ", \"ncols\": " << hessianColsNbr * JacobianColsNbr
|
||||
<< ", \"entries\": [";
|
||||
third_derivatives_output << R"(, "third_derivative": {)"
|
||||
<< R"( "nrows": )" << equations.size()
|
||||
<< R"(, "ncols": )" << hessianColsNbr * JacobianColsNbr
|
||||
<< R"(, "entries": [)";
|
||||
for (auto it = derivatives[3].begin();
|
||||
it != derivatives[3].end(); it++)
|
||||
{
|
||||
|
@ -3015,9 +3015,9 @@ StaticModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) co
|
|||
expr_t d3 = it->second;
|
||||
|
||||
if (writeDetails)
|
||||
third_derivatives_output << "{\"eq\": " << eq + 1;
|
||||
third_derivatives_output << R"({"eq": )" << eq + 1;
|
||||
else
|
||||
third_derivatives_output << "{\"row\": " << eq + 1;
|
||||
third_derivatives_output << R"({"row": )" << eq + 1;
|
||||
|
||||
int id1 = getSymbIDByDerivID(var1);
|
||||
int id2 = getSymbIDByDerivID(var2);
|
||||
|
@ -3030,7 +3030,7 @@ StaticModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) co
|
|||
cols.insert(id3 * hessianColsNbr + id1 * JacobianColsNbr + id2);
|
||||
cols.insert(id3 * hessianColsNbr + id2 * JacobianColsNbr + id1);
|
||||
|
||||
third_derivatives_output << ", \"col\": [";
|
||||
third_derivatives_output << R"(, "col": [)";
|
||||
for (auto it2 = cols.begin(); it2 != cols.end(); it2++)
|
||||
{
|
||||
if (it2 != cols.begin())
|
||||
|
@ -3040,20 +3040,20 @@ StaticModel::writeJsonComputingPassOutput(ostream &output, bool writeDetails) co
|
|||
third_derivatives_output << "]";
|
||||
|
||||
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 << R"(, "var1": ")" << symbol_table.getName(getSymbIDByDerivID(var1)) << R"(")"
|
||||
<< R"(, "var2": ")" << symbol_table.getName(getSymbIDByDerivID(var2)) << R"(")"
|
||||
<< R"(, "var3": ")" << symbol_table.getName(getSymbIDByDerivID(var3)) << R"(")";
|
||||
|
||||
third_derivatives_output << ", \"val\": \"";
|
||||
third_derivatives_output << R"(, "val": ")";
|
||||
d3->writeJsonOutput(third_derivatives_output, temp_term_union, tef_terms);
|
||||
third_derivatives_output << "\"}" << endl;
|
||||
third_derivatives_output << R"("})" << endl;
|
||||
}
|
||||
third_derivatives_output << "]}";
|
||||
|
||||
if (writeDetails)
|
||||
output << "\"static_model\": {";
|
||||
output << R"("static_model": {)";
|
||||
else
|
||||
output << "\"static_model_simple\": {";
|
||||
output << R"("static_model_simple": {)";
|
||||
output << model_local_vars_output.str()
|
||||
<< ", " << model_output.str()
|
||||
<< ", " << jacobian_output.str()
|
||||
|
@ -3084,10 +3084,10 @@ StaticModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails)
|
|||
for (const auto &it : params_derivs_temporary_terms)
|
||||
writeJsonTemporaryTerms(it.second, temp_term_union, model_output, tef_terms, concat);
|
||||
|
||||
jacobian_output << "\"deriv_wrt_params\": {"
|
||||
<< " \"neqs\": " << equations.size()
|
||||
<< ", \"nparamcols\": " << symbol_table.param_nbr()
|
||||
<< ", \"entries\": [";
|
||||
jacobian_output << R"("deriv_wrt_params": {)"
|
||||
<< R"( "neqs": )" << equations.size()
|
||||
<< R"(, "nparamcols": )" << symbol_table.param_nbr()
|
||||
<< R"(, "entries": [)";
|
||||
auto &rp = params_derivatives.find({ 0, 1 })->second;
|
||||
for (auto it = rp.begin(); it != rp.end(); it++)
|
||||
{
|
||||
|
@ -3101,26 +3101,26 @@ StaticModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails)
|
|||
int param_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param)) + 1;
|
||||
|
||||
if (writeDetails)
|
||||
jacobian_output << "{\"eq\": " << eq + 1;
|
||||
jacobian_output << R"({"eq": )" << eq + 1;
|
||||
else
|
||||
jacobian_output << "{\"row\": " << eq + 1;
|
||||
jacobian_output << R"({"row": )" << eq + 1;
|
||||
|
||||
if (writeDetails)
|
||||
jacobian_output << ", \"param_col\": " << param_col;
|
||||
jacobian_output << R"(, "param_col": )" << param_col;
|
||||
|
||||
jacobian_output << ", \"param\": \"" << symbol_table.getName(getSymbIDByDerivID(param)) << "\"";
|
||||
jacobian_output << R"(, "param": ")" << symbol_table.getName(getSymbIDByDerivID(param)) << R"(")";
|
||||
|
||||
jacobian_output << ", \"val\": \"";
|
||||
jacobian_output << R"(, "val": ")";
|
||||
d1->writeJsonOutput(jacobian_output, temp_term_union, tef_terms);
|
||||
jacobian_output << "\"}" << endl;
|
||||
jacobian_output << R"("})" << endl;
|
||||
}
|
||||
jacobian_output << "]}";
|
||||
|
||||
hessian_output << "\"deriv_jacobian_wrt_params\": {"
|
||||
<< " \"neqs\": " << equations.size()
|
||||
<< ", \"nvarcols\": " << symbol_table.endo_nbr()
|
||||
<< ", \"nparamcols\": " << symbol_table.param_nbr()
|
||||
<< ", \"entries\": [";
|
||||
hessian_output << R"("deriv_jacobian_wrt_params": {)"
|
||||
<< R"( "neqs": )" << equations.size()
|
||||
<< R"(, "nvarcols": )" << symbol_table.endo_nbr()
|
||||
<< R"(, "nparamcols": )" << symbol_table.param_nbr()
|
||||
<< R"(, "entries": [)";
|
||||
auto &gp = params_derivatives.find({ 1, 1 })->second;
|
||||
for (auto it = gp.begin(); it != gp.end(); it++)
|
||||
{
|
||||
|
@ -3135,27 +3135,27 @@ StaticModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails)
|
|||
int param_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param)) + 1;
|
||||
|
||||
if (writeDetails)
|
||||
hessian_output << "{\"eq\": " << eq + 1;
|
||||
hessian_output << R"({"eq": )" << eq + 1;
|
||||
else
|
||||
hessian_output << "{\"row\": " << eq + 1;
|
||||
hessian_output << R"({"row": )" << eq + 1;
|
||||
|
||||
if (writeDetails)
|
||||
hessian_output << ", \"var\": \"" << symbol_table.getName(getSymbIDByDerivID(var)) << "\""
|
||||
<< ", \"param\": \"" << symbol_table.getName(getSymbIDByDerivID(param)) << "\"";
|
||||
hessian_output << R"(, "var": ")" << symbol_table.getName(getSymbIDByDerivID(var)) << R"(")"
|
||||
<< R"(, "param": ")" << symbol_table.getName(getSymbIDByDerivID(param)) << R"(")";
|
||||
|
||||
hessian_output << ", \"var_col\": " << var_col
|
||||
<< ", \"param_col\": " << param_col
|
||||
<< ", \"val\": \"";
|
||||
hessian_output << R"(, "var_col": )" << var_col
|
||||
<< R"(, "param_col": )" << param_col
|
||||
<< R"(, "val": ")";
|
||||
d2->writeJsonOutput(hessian_output, temp_term_union, tef_terms);
|
||||
hessian_output << "\"}" << endl;
|
||||
hessian_output << R"("})" << endl;
|
||||
}
|
||||
hessian_output << "]}";
|
||||
|
||||
hessian1_output << "\"second_deriv_residuals_wrt_params\": {"
|
||||
<< " \"nrows\": " << equations.size()
|
||||
<< ", \"nparam1cols\": " << symbol_table.param_nbr()
|
||||
<< ", \"nparam2cols\": " << symbol_table.param_nbr()
|
||||
<< ", \"entries\": [";
|
||||
hessian1_output << R"("second_deriv_residuals_wrt_params": {)"
|
||||
<< R"( "nrows": )" << equations.size()
|
||||
<< R"(, "nparam1cols": )" << symbol_table.param_nbr()
|
||||
<< R"(, "nparam2cols": )" << symbol_table.param_nbr()
|
||||
<< R"(, "entries": [)";
|
||||
auto &rpp = params_derivatives.find({ 0, 2 })->second;
|
||||
for (auto it = rpp.begin(); it != rpp.end(); ++it)
|
||||
{
|
||||
|
@ -3170,29 +3170,29 @@ StaticModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails)
|
|||
int param2_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param2)) + 1;
|
||||
|
||||
if (writeDetails)
|
||||
hessian1_output << "{\"eq\": " << eq + 1;
|
||||
hessian1_output << R"({"eq": )" << eq + 1;
|
||||
else
|
||||
hessian1_output << "{\"row\": " << eq + 1;
|
||||
hessian1_output << R"({"row": )" << eq + 1;
|
||||
|
||||
hessian1_output << ", \"param1_col\": " << param1_col
|
||||
<< ", \"param2_col\": " << param2_col;
|
||||
hessian1_output << R"(, "param1_col": )" << param1_col
|
||||
<< R"(, "param2_col": )" << param2_col;
|
||||
|
||||
if (writeDetails)
|
||||
hessian1_output << ", \"param1\": \"" << symbol_table.getName(getSymbIDByDerivID(param1)) << "\""
|
||||
<< ", \"param2\": \"" << symbol_table.getName(getSymbIDByDerivID(param2)) << "\"";
|
||||
hessian1_output << R"(, "param1": ")" << symbol_table.getName(getSymbIDByDerivID(param1)) << R"(")"
|
||||
<< R"(, "param2": ")" << symbol_table.getName(getSymbIDByDerivID(param2)) << R"(")";
|
||||
|
||||
hessian1_output << ", \"val\": \"";
|
||||
hessian1_output << R"(, "val": ")";
|
||||
d2->writeJsonOutput(hessian1_output, temp_term_union, tef_terms);
|
||||
hessian1_output << "\"}" << endl;
|
||||
hessian1_output << R"("})" << endl;
|
||||
}
|
||||
hessian1_output << "]}";
|
||||
|
||||
third_derivs_output << "\"second_deriv_jacobian_wrt_params\": {"
|
||||
<< " \"neqs\": " << equations.size()
|
||||
<< ", \"nvarcols\": " << symbol_table.endo_nbr()
|
||||
<< ", \"nparam1cols\": " << symbol_table.param_nbr()
|
||||
<< ", \"nparam2cols\": " << symbol_table.param_nbr()
|
||||
<< ", \"entries\": [";
|
||||
third_derivs_output << R"("second_deriv_jacobian_wrt_params": {)"
|
||||
<< R"( "neqs": )" << equations.size()
|
||||
<< R"(, "nvarcols": )" << symbol_table.endo_nbr()
|
||||
<< R"(, "nparam1cols": )" << symbol_table.param_nbr()
|
||||
<< R"(, "nparam2cols": )" << symbol_table.param_nbr()
|
||||
<< R"(, "entries": [)";
|
||||
auto &gpp = params_derivatives.find({ 1, 2 })->second;
|
||||
for (auto it = gpp.begin(); it != gpp.end(); ++it)
|
||||
{
|
||||
|
@ -3208,30 +3208,30 @@ StaticModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails)
|
|||
int param2_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param2)) + 1;
|
||||
|
||||
if (writeDetails)
|
||||
third_derivs_output << "{\"eq\": " << eq + 1;
|
||||
third_derivs_output << R"({"eq": )" << eq + 1;
|
||||
else
|
||||
third_derivs_output << "{\"row\": " << eq + 1;
|
||||
third_derivs_output << ", \"var_col\": " << var_col
|
||||
<< ", \"param1_col\": " << param1_col
|
||||
<< ", \"param2_col\": " << param2_col;
|
||||
third_derivs_output << R"({"row": )" << eq + 1;
|
||||
third_derivs_output << R"(, "var_col": )" << var_col
|
||||
<< R"(, "param1_col": )" << param1_col
|
||||
<< R"(, "param2_col": )" << param2_col;
|
||||
|
||||
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 << R"(, "var": ")" << symbol_table.getName(var) << R"(")"
|
||||
<< R"(, "param1": ")" << symbol_table.getName(getSymbIDByDerivID(param1)) << R"(")"
|
||||
<< R"(, "param2": ")" << symbol_table.getName(getSymbIDByDerivID(param2)) << R"(")";
|
||||
|
||||
third_derivs_output << ", \"val\": \"";
|
||||
third_derivs_output << R"(, "val": ")";
|
||||
d2->writeJsonOutput(third_derivs_output, temp_term_union, tef_terms);
|
||||
third_derivs_output << "\"}" << endl;
|
||||
third_derivs_output << R"("})" << endl;
|
||||
}
|
||||
third_derivs_output << "]}" << endl;
|
||||
|
||||
third_derivs1_output << "\"derivative_hessian_wrt_params\": {"
|
||||
<< " \"neqs\": " << equations.size()
|
||||
<< ", \"nvar1cols\": " << symbol_table.endo_nbr()
|
||||
<< ", \"nvar2cols\": " << symbol_table.endo_nbr()
|
||||
<< ", \"nparamcols\": " << symbol_table.param_nbr()
|
||||
<< ", \"entries\": [";
|
||||
third_derivs1_output << R"("derivative_hessian_wrt_params": {)"
|
||||
<< R"( "neqs": )" << equations.size()
|
||||
<< R"(, "nvar1cols": )" << symbol_table.endo_nbr()
|
||||
<< R"(, "nvar2cols": )" << symbol_table.endo_nbr()
|
||||
<< R"(, "nparamcols": )" << symbol_table.param_nbr()
|
||||
<< R"(, "entries": [)";
|
||||
auto &hp = params_derivatives.find({ 2, 1 })->second;
|
||||
for (auto it = hp.begin(); it != hp.end(); ++it)
|
||||
{
|
||||
|
@ -3247,29 +3247,29 @@ StaticModel::writeJsonParamsDerivativesFile(ostream &output, bool writeDetails)
|
|||
int param_col = symbol_table.getTypeSpecificID(getSymbIDByDerivID(param)) + 1;
|
||||
|
||||
if (writeDetails)
|
||||
third_derivs1_output << "{\"eq\": " << eq + 1;
|
||||
third_derivs1_output << R"({"eq": )" << eq + 1;
|
||||
else
|
||||
third_derivs1_output << "{\"row\": " << eq + 1;
|
||||
third_derivs1_output << R"({"row": )" << eq + 1;
|
||||
|
||||
third_derivs1_output << ", \"var1_col\": " << var1_col
|
||||
<< ", \"var2_col\": " << var2_col
|
||||
<< ", \"param_col\": " << param_col;
|
||||
third_derivs1_output << R"(, "var1_col": )" << var1_col
|
||||
<< R"(, "var2_col": )" << var2_col
|
||||
<< R"(, "param_col": )" << param_col;
|
||||
|
||||
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 << R"(, "var1": ")" << symbol_table.getName(getSymbIDByDerivID(var1)) << R"(")"
|
||||
<< R"(, "var2": ")" << symbol_table.getName(getSymbIDByDerivID(var2)) << R"(")"
|
||||
<< R"(, "param1": ")" << symbol_table.getName(getSymbIDByDerivID(param)) << R"(")";
|
||||
|
||||
third_derivs1_output << ", \"val\": \"";
|
||||
third_derivs1_output << R"(, "val": ")";
|
||||
d2->writeJsonOutput(third_derivs1_output, temp_term_union, tef_terms);
|
||||
third_derivs1_output << "\"}" << endl;
|
||||
third_derivs1_output << R"("})" << endl;
|
||||
}
|
||||
third_derivs1_output << "]}" << endl;
|
||||
|
||||
if (writeDetails)
|
||||
output << "\"static_model_params_derivative\": {";
|
||||
output << R"("static_model_params_derivative": {)";
|
||||
else
|
||||
output << "\"static_model_params_derivatives_simple\": {";
|
||||
output << R"("static_model_params_derivatives_simple": {)";
|
||||
output << model_local_vars_output.str()
|
||||
<< ", " << model_output.str()
|
||||
<< ", " << jacobian_output.str()
|
||||
|
|
|
@ -407,19 +407,19 @@ TrendComponentModelTable::writeJsonOutput(ostream &output) const
|
|||
{
|
||||
if (name != *(names.begin()))
|
||||
output << ", ";
|
||||
output << "{\"statementName\": \"trend_component_model\","
|
||||
<< "\"model_name\": \"" << name << "\","
|
||||
<< "\"eqtags\": [";
|
||||
output << R"({"statementName": "trend_component_model",)"
|
||||
<< R"("model_name": ")" << name << R"(",)"
|
||||
<< R"("eqtags": [)";
|
||||
for (const auto &it : eqtags.at(name))
|
||||
{
|
||||
output << "\"" << it << "\"";
|
||||
output << R"(")" << it << R"(")";
|
||||
if (&it != &eqtags.at(name).back())
|
||||
output << ", ";
|
||||
}
|
||||
output << "], \"target_eqtags\": [";
|
||||
output << R"(], "target_eqtags": [)";
|
||||
for (const auto &it : target_eqtags.at(name))
|
||||
{
|
||||
output << "\"" << it << "\"";
|
||||
output << R"(")" << it << R"(")";
|
||||
if (&it != &target_eqtags.at(name).back())
|
||||
output << ", ";
|
||||
}
|
||||
|
@ -547,21 +547,21 @@ VarModelTable::writeJsonOutput(ostream &output) const
|
|||
{
|
||||
if (name != *(names.begin()))
|
||||
output << ", ";
|
||||
output << "{\"statementName\": \"var_model\","
|
||||
<< "\"model_name\": \"" << name << "\",";
|
||||
output << R"({"statementName": "var_model",)"
|
||||
<< R"("model_name": ")" << name << R"(",)";
|
||||
if (symbol_list_and_order.empty())
|
||||
{
|
||||
output << "\"eqtags\": [";
|
||||
output << R"("eqtags": [)";
|
||||
for (const auto &it : eqtags.at(name))
|
||||
{
|
||||
output << "\"" << it << "\"";
|
||||
output << R"(")" << it << R"(")";
|
||||
if (&it != &eqtags.at(name).back())
|
||||
output << ", ";
|
||||
}
|
||||
output << "]";
|
||||
}
|
||||
else
|
||||
output << "\"order\": \"" << symbol_list_and_order.at(name).second << "\"";
|
||||
output << R"("order": ")" << symbol_list_and_order.at(name).second << R"(")";
|
||||
output << "}";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,13 +42,13 @@ SymbolList::writeOutput(const string &varname, ostream &output) const
|
|||
void
|
||||
SymbolList::writeJsonOutput(ostream &output) const
|
||||
{
|
||||
output << "\"symbol_list\": [";
|
||||
output << R"("symbol_list": [)";
|
||||
for (auto it = symbols.begin();
|
||||
it != symbols.end(); ++it)
|
||||
{
|
||||
if (it != symbols.begin())
|
||||
output << ",";
|
||||
output << "\"" << *it << "\"";
|
||||
output << R"(")" << *it << R"(")";
|
||||
}
|
||||
output << "]";
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ SymbolTable::addSymbol(const string &name, SymbolType type, const string &tex_na
|
|||
size_t pos = 0;
|
||||
while ((pos = final_tex_name.find('_', pos)) != string::npos)
|
||||
{
|
||||
final_tex_name.insert(pos, "\\");
|
||||
final_tex_name.insert(pos, R"(\)");
|
||||
pos += 2;
|
||||
}
|
||||
}
|
||||
|
@ -375,7 +375,7 @@ SymbolTable::writeOutput(ostream &output) const noexcept(false)
|
|||
output << "M_.aux_vars(" << i+1 << ").orig_index = " << getTypeSpecificID(aux_vars[i].get_orig_symb_id())+1 << ";" << endl;
|
||||
break;
|
||||
case AuxVarType::expectation:
|
||||
output << "M_.aux_vars(" << i+1 << ").orig_expr = '\\mathbb{E}_{t"
|
||||
output << "M_.aux_vars(" << i+1 << R"().orig_expr = '\mathbb{E}_{t)"
|
||||
<< (aux_vars[i].get_information_set() < 0 ? "" : "+")
|
||||
<< aux_vars[i].get_information_set() << "}(";
|
||||
aux_vars[i].get_expr_node()->writeOutput(output, ExprNodeOutputType::latexDynamicModel);
|
||||
|
@ -440,7 +440,7 @@ SymbolTable::writeCOutput(ostream &output) const noexcept(false)
|
|||
{
|
||||
output << "char *exo_names[" << exo_nbr() << "];" << endl;
|
||||
for (int id = 0; id < exo_nbr(); id++)
|
||||
output << "exo_names[" << id << "] = \"" << getName(exo_ids[id]) << "\";" << endl;
|
||||
output << "exo_names[" << id << R"(] = ")" << getName(exo_ids[id]) << R"(";)" << endl;
|
||||
}
|
||||
|
||||
output << endl
|
||||
|
@ -449,7 +449,7 @@ SymbolTable::writeCOutput(ostream &output) const noexcept(false)
|
|||
{
|
||||
output << "char *exo_det_names[" << exo_det_nbr() << "];" << endl;
|
||||
for (int id = 0; id < exo_det_nbr(); id++)
|
||||
output << "exo_det_names[" << id << "] = \"" << getName(exo_det_ids[id]) << "\";" << endl;
|
||||
output << "exo_det_names[" << id << R"(] = ")" << getName(exo_det_ids[id]) << R"(";)" << endl;
|
||||
}
|
||||
|
||||
output << endl
|
||||
|
@ -458,7 +458,7 @@ SymbolTable::writeCOutput(ostream &output) const noexcept(false)
|
|||
{
|
||||
output << "char *endo_names[" << endo_nbr() << "];" << endl;
|
||||
for (int id = 0; id < endo_nbr(); id++)
|
||||
output << "endo_names[" << id << "] = \"" << getName(endo_ids[id]) << "\";" << endl;
|
||||
output << "endo_names[" << id << R"(] = ")" << getName(endo_ids[id]) << R"(";)" << endl;
|
||||
}
|
||||
|
||||
output << endl
|
||||
|
@ -467,7 +467,7 @@ SymbolTable::writeCOutput(ostream &output) const noexcept(false)
|
|||
{
|
||||
output << "char *param_names[" << param_nbr() << "];" << endl;
|
||||
for (int id = 0; id < param_nbr(); id++)
|
||||
output << "param_names[" << id << "] = \"" << getName(param_ids[id]) << "\";" << endl;
|
||||
output << "param_names[" << id << R"(] = ")" << getName(param_ids[id]) << R"(";)" << endl;
|
||||
}
|
||||
|
||||
// Write the auxiliary variable table
|
||||
|
@ -497,7 +497,7 @@ SymbolTable::writeCOutput(ostream &output) const noexcept(false)
|
|||
if (aux_vars[i].get_orig_symb_id() >= 0)
|
||||
output << "av[" << i << "].orig_index = " << getTypeSpecificID(aux_vars[i].get_orig_symb_id()) << ";" << endl
|
||||
<< "av[" << i << "].orig_lead_lag = " << aux_vars[i].get_orig_lead_lag() << ";" << endl;
|
||||
output << "av[" << i << "].unary_op = \"" << aux_vars[i].get_unary_op() << "\";" << endl;
|
||||
output << "av[" << i << R"(].unary_op = ")" << aux_vars[i].get_unary_op() << R"(";)" << endl;
|
||||
break;
|
||||
case AuxVarType::diff:
|
||||
case AuxVarType::diffLag:
|
||||
|
@ -562,22 +562,22 @@ SymbolTable::writeCCOutput(ostream &output) const noexcept(false)
|
|||
output << endl
|
||||
<< "exo_nbr = " << exo_nbr() << ";" << endl;
|
||||
for (int id = 0; id < exo_nbr(); id++)
|
||||
output << "exo_names[\"" << getName(exo_ids[id]) << "\"] = " << id << ";" << endl;
|
||||
output << R"(exo_names[")" << getName(exo_ids[id]) << R"("] = )" << id << ";" << endl;
|
||||
|
||||
output << endl
|
||||
<< "exo_det_nbr = " << exo_det_nbr() << ";" << endl;
|
||||
for (int id = 0; id < exo_det_nbr(); id++)
|
||||
output << "exo_det_names[\"" << getName(exo_det_ids[id]) << "\"] = " << id << " ;" << endl;
|
||||
output << R"(exo_det_names[")" << getName(exo_det_ids[id]) << R"("] = )" << id << " ;" << endl;
|
||||
|
||||
output << endl
|
||||
<< "endo_nbr = " << endo_nbr() << ";" << endl;
|
||||
for (int id = 0; id < endo_nbr(); id++)
|
||||
output << "endo_names[\"" << getName(endo_ids[id]) << "\"] = " << id << ";" << endl;
|
||||
output << R"(endo_names[")" << getName(endo_ids[id]) << R"("] = )" << id << ";" << endl;
|
||||
|
||||
output << endl
|
||||
<< "param_nbr = " << param_nbr() << ";" << endl;
|
||||
for (int id = 0; id < param_nbr(); id++)
|
||||
output << "param_names[\"" << getName(param_ids[id]) << "\"] = " << id << ";" << endl;
|
||||
output << R"(param_names[")" << getName(param_ids[id]) << R"("] = )" << id << ";" << endl;
|
||||
|
||||
// Write the auxiliary variable table
|
||||
for (int i = 0; i < (int) aux_vars.size(); i++)
|
||||
|
@ -603,7 +603,7 @@ SymbolTable::writeCCOutput(ostream &output) const noexcept(false)
|
|||
if (aux_vars[i].get_orig_symb_id() >= 0)
|
||||
output << "av" << i << ".orig_index = " << getTypeSpecificID(aux_vars[i].get_orig_symb_id()) << ";" << endl
|
||||
<< "av" << i << ".orig_lead_lag = " << aux_vars[i].get_orig_lead_lag() << ";" << endl;
|
||||
output << "av" << i << ".unary_op = \"" << aux_vars[i].get_unary_op() << "\";" << endl;
|
||||
output << "av" << i << R"(.unary_op = ")" << aux_vars[i].get_unary_op() << R"(";)" << endl;
|
||||
break;
|
||||
case AuxVarType::diff:
|
||||
case AuxVarType::diffLag:
|
||||
|
@ -1123,10 +1123,10 @@ SymbolTable::writeJuliaOutput(ostream &output) const noexcept(false)
|
|||
<< "model_.endo = [" << endl;
|
||||
if (endo_nbr() > 0)
|
||||
for (int id = 0; id < endo_nbr(); id++)
|
||||
output << " DynareModel.Endo(\""
|
||||
<< getName(endo_ids[id]) << "\", raw\""
|
||||
<< getTeXName(endo_ids[id]) << "\", \""
|
||||
<< getLongName(endo_ids[id]) << "\")" << endl;
|
||||
output << R"( DynareModel.Endo(")"
|
||||
<< getName(endo_ids[id]) << R"(", raw")"
|
||||
<< getTeXName(endo_ids[id]) << R"(", ")"
|
||||
<< getLongName(endo_ids[id]) << R"("))" << endl;
|
||||
output << " ]" << endl;
|
||||
output << "model_.endo_nbr = " << endo_nbr() << ";" << endl;
|
||||
|
||||
|
@ -1134,10 +1134,10 @@ SymbolTable::writeJuliaOutput(ostream &output) const noexcept(false)
|
|||
<< "model_.exo = [" << endl;
|
||||
if (exo_nbr() > 0)
|
||||
for (int id = 0; id < exo_nbr(); id++)
|
||||
output << " DynareModel.Exo(\""
|
||||
<< getName(exo_ids[id]) << "\", raw\""
|
||||
<< getTeXName(exo_ids[id]) << "\", \""
|
||||
<< getLongName(exo_ids[id]) << "\")" << endl;
|
||||
output << R"( DynareModel.Exo(")"
|
||||
<< getName(exo_ids[id]) << R"(", raw")"
|
||||
<< getTeXName(exo_ids[id]) << R"(", ")"
|
||||
<< getLongName(exo_ids[id]) << R"("))" << endl;
|
||||
output << " ]" << endl;
|
||||
output << "model_.exo_nbr = " << exo_nbr() << ";" << endl;
|
||||
|
||||
|
@ -1147,10 +1147,10 @@ SymbolTable::writeJuliaOutput(ostream &output) const noexcept(false)
|
|||
<< "model_.exo_det = [" << endl;
|
||||
if (exo_det_nbr() > 0)
|
||||
for (int id = 0; id < exo_det_nbr(); id++)
|
||||
output << " DynareModel.ExoDet(\""
|
||||
<< getName(exo_det_ids[id]) << "\", raw\""
|
||||
<< getTeXName(exo_det_ids[id]) << "\", \""
|
||||
<< getLongName(exo_det_ids[id]) << "\")" << endl;
|
||||
output << R"( DynareModel.ExoDet(")"
|
||||
<< getName(exo_det_ids[id]) << R"(", raw")"
|
||||
<< getTeXName(exo_det_ids[id]) << R"(", ")"
|
||||
<< getLongName(exo_det_ids[id]) << R"("))" << endl;
|
||||
output << " ]" << endl;
|
||||
output << "model_.exo_det_nbr = " << exo_det_nbr() << ";" << endl;
|
||||
}
|
||||
|
@ -1159,10 +1159,10 @@ SymbolTable::writeJuliaOutput(ostream &output) const noexcept(false)
|
|||
<< "model_.param = [" << endl;
|
||||
if (param_nbr() > 0)
|
||||
for (int id = 0; id < param_nbr(); id++)
|
||||
output << " DynareModel.Param(\""
|
||||
<< getName(param_ids[id]) << "\", raw\""
|
||||
<< getTeXName(param_ids[id]) << "\", \""
|
||||
<< getLongName(param_ids[id]) << "\")" << endl;
|
||||
output << R"( DynareModel.Param(")"
|
||||
<< getName(param_ids[id]) << R"(", raw")"
|
||||
<< getTeXName(param_ids[id]) << R"(", ")"
|
||||
<< getLongName(param_ids[id]) << R"("))" << endl;
|
||||
output << " ]" << endl;
|
||||
output << "model_.param_nbr = " << param_nbr() << ";" << endl;
|
||||
|
||||
|
@ -1193,7 +1193,7 @@ SymbolTable::writeJuliaOutput(ostream &output) const noexcept(false)
|
|||
else
|
||||
output << "typemin(Int), typemin(Int)";
|
||||
output << ", typemin(Int), string(), "
|
||||
<< "\"" << aux_var.get_unary_op() << "\"" << endl;
|
||||
<< R"(")" << aux_var.get_unary_op() << R"(")" << endl;
|
||||
break;
|
||||
case AuxVarType::diff:
|
||||
case AuxVarType::diffLag:
|
||||
|
@ -1210,11 +1210,11 @@ SymbolTable::writeJuliaOutput(ostream &output) const noexcept(false)
|
|||
output << getTypeSpecificID(aux_var.get_orig_symb_id())+1 << ", typemin(Int), typemin(Int), string(), string()";
|
||||
break;
|
||||
case AuxVarType::expectation:
|
||||
output << "typemin(Int), typemin(Int), typemin(Int), \"\\mathbb{E}_{t"
|
||||
output << R"(typemin(Int), typemin(Int), typemin(Int), "\mathbb{E}_{t)"
|
||||
<< (aux_var.get_information_set() < 0 ? "" : "+")
|
||||
<< aux_var.get_information_set() << "}(";
|
||||
aux_var.get_expr_node()->writeOutput(output, ExprNodeOutputType::latexDynamicModel);
|
||||
output << ")\"";
|
||||
output << R"lit()")lit";
|
||||
break;
|
||||
default:
|
||||
output << " typemin(Int), typemin(Int), typemin(Int), string(), string()";
|
||||
|
@ -1248,16 +1248,16 @@ SymbolTable::writeJuliaOutput(ostream &output) const noexcept(false)
|
|||
void
|
||||
SymbolTable::writeJsonOutput(ostream &output) const
|
||||
{
|
||||
output << "\"endogenous\": ";
|
||||
output << R"("endogenous": )";
|
||||
writeJsonVarVector(output, endo_ids);
|
||||
|
||||
output << ", \"exogenous\":";
|
||||
output << R"(, "exogenous":)";
|
||||
writeJsonVarVector(output, exo_ids);
|
||||
|
||||
output << ", \"exogenous_deterministic\": ";
|
||||
output << R"(, "exogenous_deterministic": )";
|
||||
writeJsonVarVector(output, exo_det_ids);
|
||||
|
||||
output << ", \"parameters\": ";
|
||||
output << R"(, "parameters": )";
|
||||
writeJsonVarVector(output, param_ids);
|
||||
}
|
||||
|
||||
|
@ -1270,9 +1270,9 @@ SymbolTable::writeJsonVarVector(ostream &output, const vector<int> &varvec) cons
|
|||
if (i != 0)
|
||||
output << ", ";
|
||||
output << "{"
|
||||
<< "\"name\":\"" << getName(varvec[i]) << "\", "
|
||||
<< "\"texName\":\"" << boost::replace_all_copy(getTeXName(varvec[i]), "\\", "\\\\") << "\", "
|
||||
<< "\"longName\":\"" << boost::replace_all_copy(getLongName(varvec[i]), "\\", "\\\\") << "\"}"
|
||||
<< R"("name":")" << getName(varvec[i]) << R"(", )"
|
||||
<< R"("texName":")" << boost::replace_all_copy(getTeXName(varvec[i]), R"(\)", R"(\\)") << R"(", )"
|
||||
<< R"("longName":")" << boost::replace_all_copy(getLongName(varvec[i]), R"(\)", R"(\\)") << R"("})"
|
||||
<< endl;
|
||||
}
|
||||
output << "]" << endl;
|
||||
|
|
|
@ -53,7 +53,7 @@ MacroDriver::parse(const string &file_arg, const string &basename_arg, istream &
|
|||
// If the input is an array. Issue #1578
|
||||
file_with_endl << "@#define " << define.first << " = " << define.second << endl;
|
||||
else
|
||||
file_with_endl << "@#define " << define.first << " = \"" << define.second << "\"" << endl;
|
||||
file_with_endl << "@#define " << define.first << R"( = ")" << define.second << R"(")" << endl;
|
||||
}
|
||||
file_with_endl << modfile.rdbuf() << endl;
|
||||
|
||||
|
@ -65,7 +65,7 @@ MacroDriver::parse(const string &file_arg, const string &basename_arg, istream &
|
|||
|
||||
// Output first @#line statement
|
||||
if (!no_line_macro)
|
||||
out << "@#line \"" << file << "\" 1" << endl;
|
||||
out << R"(@#line ")" << file << R"(" 1)" << endl;
|
||||
|
||||
// Launch macro-processing
|
||||
parser.parse();
|
||||
|
@ -88,7 +88,7 @@ MacroDriver::replace_vars_in_str(const string &s) const
|
|||
smatch name;
|
||||
string name_str ("[A-Za-z_][A-Za-z0-9_]*");
|
||||
regex name_regex (name_str); // Matches NAME
|
||||
regex macro_regex ("@\\s*\\{\\s*" + name_str + "\\s*\\}"); // Matches @{NAME} with potential whitespace
|
||||
regex macro_regex (R"(@\s*\{\s*)" + name_str + R"(\s*\})"); // Matches @{NAME} with potential whitespace
|
||||
for(sregex_iterator it = sregex_iterator(s.begin(), s.end(), macro_regex);
|
||||
it != std::sregex_iterator(); ++it)
|
||||
{
|
||||
|
@ -412,7 +412,7 @@ MacroDriver::printvars(const Macro::parser::location_type &l, const bool tostdou
|
|||
|
||||
stringstream intomfile;
|
||||
if (!no_line_macro)
|
||||
intomfile << "@#line \"" << file << "\" " << l.begin.line << endl;
|
||||
intomfile << R"(@#line ")" << file << R"(" )" << l.begin.line << endl;
|
||||
|
||||
for (const auto & it : env)
|
||||
intomfile<< "options_.macrovars_line_" << l.begin.line << "." << it.first << " = " << it.second->print() << ";" << endl;
|
||||
|
|
Loading…
Reference in New Issue