Commit 28582c4a authored by Sébastien Villemot's avatar Sébastien Villemot

Merge branch 'temporary_terms_array'

parents f338e876 59e427cf
......@@ -25,6 +25,7 @@ AM_INIT_AUTOMAKE([1.11 -Wall -Wno-portability foreign no-dist-gzip dist-xz tar-p
AC_PROG_CC
AC_PROG_CXX
AX_CXX_COMPILE_STDCXX_14
AC_CANONICAL_HOST
case ${host_os} in
......
......@@ -21,6 +21,16 @@ Copyright: 2008 Thomas Porschberg <thomas@randspringer.de>
2009 Peter Adolphs
License: permissive-autoconf
Files: m4/ax_cxx_compile_stdcxx.m4
m4/ax_cxx_compile_stdcxx_14.m4
Copyright: 2008 Benjamin Kosnik <bkoz@redhat.com>
2012 Zack Weinberg <zackw@panix.com>
2013 Roy Stogner <roystgnr@ices.utexas.edu>
2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
2015 Paul Norman <penorman@mac.com>
2015 Moritz Klammler <moritz@klammler.eu>
License: permissive-autoconf
Files: m4/ax_latex_class.m4 m4/ax_tex_test.m4
Copyright: 2008 Boretti Mathieu <boretti@eig.unige.ch>
2009 Dynare Team
......
This diff is collapsed.
# ============================================================================
# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_14.html
# ============================================================================
#
# SYNOPSIS
#
# AX_CXX_COMPILE_STDCXX_14([ext|noext], [mandatory|optional])
#
# DESCRIPTION
#
# Check for baseline language coverage in the compiler for the C++14
# standard; if necessary, add switches to CXX and CXXCPP to enable
# support.
#
# This macro is a convenience alias for calling the AX_CXX_COMPILE_STDCXX
# macro with the version set to C++14. The two optional arguments are
# forwarded literally as the second and third argument respectively.
# Please see the documentation for the AX_CXX_COMPILE_STDCXX macro for
# more information. If you want to use this macro, you also need to
# download the ax_cxx_compile_stdcxx.m4 file.
#
# LICENSE
#
# Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 4
AX_REQUIRE_DEFINED([AX_CXX_COMPILE_STDCXX])
AC_DEFUN([AX_CXX_COMPILE_STDCXX_14], [AX_CXX_COMPILE_STDCXX([14], [$1], [$2])])
......@@ -268,6 +268,33 @@ enum NodeTreeReference
eHessianParamsDeriv = 8
};
/*! Lists elements of the NodeTreeReference enum that come “before” the argument.
Used in AbstractExternalFunctionNode::computeTemporaryTerms */
inline auto
nodeTreeReferencesBefore(NodeTreeReference tr)
{
vector<NodeTreeReference> v;
// Should be same order as the one appearing in ModelTree::computeTemporaryTerms()
for (auto tr2 : { eResiduals, eFirstDeriv, eSecondDeriv, eThirdDeriv })
if (tr == tr2)
return v;
else
v.push_back(tr2);
v.clear();
// Should be same order as the one appearing in ModelTree::computeParamsDerivativesTemporaryTerms()
for (auto tr2 : { eResidualsParamsDeriv, eJacobianParamsDeriv, eResidualsParamsSecondDeriv,
eJacobianParamsSecondDeriv, eHessianParamsDeriv})
if (tr == tr2)
return v;
else
v.push_back(tr2);
cerr << "nodeTreeReferencesBelow: impossible case" << endl;
exit(EXIT_FAILURE);
}
struct Block_contain_type
{
int Equation, Variable, Own_Derivative;
......
......@@ -966,7 +966,6 @@ RamseyConstraintsStatement::writeOutput(ostream &output, const string &basename,
void
RamseyConstraintsStatement::writeJsonOutput(ostream &output) const
{
deriv_node_temp_terms_t tef_terms;
output << "{\"statementName\": \"ramsey_constraints\""
<< ", \"ramsey_model_constraints\": [" << endl;
for (RamseyConstraintsStatement::constraints_t::const_iterator it = constraints.begin(); it != constraints.end(); ++it)
......@@ -993,7 +992,7 @@ RamseyConstraintsStatement::writeJsonOutput(ostream &output) const
exit(1);
}
output << " ";
it->expression->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->expression->writeJsonOutput(output, {}, {});
output << "\"}" << endl;
}
output << "]" << endl;
......@@ -1570,7 +1569,6 @@ EstimatedParamsStatement::writeOutput(ostream &output, const string &basename, b
void
EstimatedParamsStatement::writeJsonOutput(ostream &output) const
{
deriv_node_temp_terms_t tef_terms;
output << "{\"statementName\": \"estimated_params\", "
<< "\"params\": [";
for (vector<EstimationParams>::const_iterator it = estim_params_list.begin(); it != estim_params_list.end(); it++)
......@@ -1593,23 +1591,23 @@ EstimatedParamsStatement::writeJsonOutput(ostream &output) const
}
output << ", \"init_val\": \"";
it->init_val->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->init_val->writeJsonOutput(output, {}, {});
output << "\", \"lower_bound\": \"";
it->low_bound->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->low_bound->writeJsonOutput(output, {}, {});
output << "\", \"upper_bound\": \"";
it->up_bound->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->up_bound->writeJsonOutput(output, {}, {});
output << "\", \"prior_distribution\": "
<< it->prior
<< ", \"mean\": \"";
it->mean->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->mean->writeJsonOutput(output, {}, {});
output << "\", \"std\": \"";
it->std->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->std->writeJsonOutput(output, {}, {});
output << "\", \"p3\": \"";
it->p3->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->p3->writeJsonOutput(output, {}, {});
output << "\", \"p4\": \"";
it->p4->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->p4->writeJsonOutput(output, {}, {});
output << "\", \"jscale\": \"";
it->jscale->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->jscale->writeJsonOutput(output, {}, {});
output << "\"}" << endl;
}
output << "]"
......@@ -1692,7 +1690,6 @@ EstimatedParamsInitStatement::writeOutput(ostream &output, const string &basenam
void
EstimatedParamsInitStatement::writeJsonOutput(ostream &output) const
{
deriv_node_temp_terms_t tef_terms;
output << "{\"statementName\": \"estimated_params_init\"";
if (use_calibration)
......@@ -1718,7 +1715,7 @@ EstimatedParamsInitStatement::writeJsonOutput(ostream &output) const
break;
}
output << ", \"init_val\": \"";
it->init_val->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->init_val->writeJsonOutput(output, {}, {});
output << "\"}";
}
output << "]"
......@@ -1814,7 +1811,6 @@ EstimatedParamsBoundsStatement::writeOutput(ostream &output, const string &basen
void
EstimatedParamsBoundsStatement::writeJsonOutput(ostream &output) const
{
deriv_node_temp_terms_t tef_terms;
output << "{\"statementName\": \"estimated_params_bounds\", "
<< "\"params\": [";
......@@ -1836,9 +1832,9 @@ EstimatedParamsBoundsStatement::writeJsonOutput(ostream &output) const
break;
}
output << ", \"lower_bound\": ";
it->low_bound->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->low_bound->writeJsonOutput(output, {}, {});
output << ", \"upper_bound\": ";
it->up_bound->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->up_bound->writeJsonOutput(output, {}, {});
output << "}";
}
output << "]"
......@@ -1874,7 +1870,6 @@ ObservationTrendsStatement::writeOutput(ostream &output, const string &basename,
void
ObservationTrendsStatement::writeJsonOutput(ostream &output) const
{
deriv_node_temp_terms_t tef_terms;
output << "{\"statementName\": \"observation_trends\", "
<< "\"trends\" : {";
bool printed = false;
......@@ -1886,7 +1881,7 @@ ObservationTrendsStatement::writeJsonOutput(ostream &output) const
if (printed)
output << ", ";
output << "\"" << it->first << "\": \"";
it->second->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->second->writeJsonOutput(output, {}, {});
output << "\"" << endl;
printed = true;
}
......@@ -1977,7 +1972,6 @@ OsrParamsBoundsStatement::writeOutput(ostream &output, const string &basename, b
void
OsrParamsBoundsStatement::writeJsonOutput(ostream &output) const
{
deriv_node_temp_terms_t tef_terms;
output << "{\"statementName\": \"osr_params_bounds\""
<< ", \"bounds\": [";
for (vector<OsrParams>::const_iterator it = osr_params_list.begin();
......@@ -1987,9 +1981,9 @@ OsrParamsBoundsStatement::writeJsonOutput(ostream &output) const
output << ", ";
output << "{\"parameter\": \"" << it->name << "\","
<< "\"bounds\": [\"";
it->low_bound->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->low_bound->writeJsonOutput(output, {}, {});
output << "\", \"";
it->up_bound->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->up_bound->writeJsonOutput(output, {}, {});
output << "\"]"
<< "}";
}
......@@ -2105,7 +2099,6 @@ OptimWeightsStatement::writeOutput(ostream &output, const string &basename, bool
void
OptimWeightsStatement::writeJsonOutput(ostream &output) const
{
deriv_node_temp_terms_t tef_terms;
output << "{\"statementName\": \"optim_weights\", "
<< "\"weights\": [";
for (var_weights_t::const_iterator it = var_weights.begin();
......@@ -2115,7 +2108,7 @@ OptimWeightsStatement::writeJsonOutput(ostream &output) const
output << ", ";
output << "{\"name\": \"" << it->first << "\""
<< ", \"value\": \"";
it->second->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->second->writeJsonOutput(output, {}, {});
output << "\"}";
}
......@@ -2127,7 +2120,7 @@ OptimWeightsStatement::writeJsonOutput(ostream &output) const
output << "{\"name1\": \"" << it->first.first << "\""
<< ", \"name2\": \"" << it->first.second << "\""
<< ", \"value\": \"";
it->second->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->second->writeJsonOutput(output, {}, {});
output << "\"}";
}
output << "]"
......@@ -3998,9 +3991,8 @@ BasicPriorStatement::writeJsonPriorOutput(ostream &output) const
writeJsonShape(output);
if (variance != NULL)
{
deriv_node_temp_terms_t tef_terms;
output << ", \"variance\": \"";
variance->writeJsonOutput(output, temporary_terms_t(), tef_terms);
variance->writeJsonOutput(output, {}, {});
output << "\"";
}
if (options_list.getNumberOfOptions())
......
This diff is collapsed.
......@@ -109,6 +109,8 @@ private:
//! Writes the dynamic model equations and its derivatives
/*! \todo add third derivatives handling in C output */
void writeDynamicModel(ostream &DynamicOutput, bool use_dll, bool julia) const;
void writeDynamicModel(const string &dynamic_basename, bool use_dll, bool julia) const;
void writeDynamicModel(const string &dynamic_basename, ostream &DynamicOutput, bool use_dll, bool julia) const;
//! Writes the Block reordred structure of the model in M output
void writeModelEquationsOrdered_M(const string &dynamic_basename) const;
//! Writes the code of the Block reordred structure of the model in virtual machine bytecode
......@@ -161,9 +163,6 @@ private:
/*! Also computes max_{endo,exo}_{lead_lag}, and initializes dynJacobianColsNbr to the number of dynamic endos */
void computeDerivIDs();
//! Write chain rule derivative of a recursive equation w.r. to a variable
void writeChainRuleDerivative(ostream &output, int eq, int var, int lag, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms) const;
//! Collecte the derivatives w.r. to endogenous of the block, to endogenous of previouys blocks and to exogenous
void collect_block_first_order_derivatives();
......@@ -235,6 +234,17 @@ private:
//!Maximum lead and lag for each block on endogenous of the block, endogenous of the previous blocks, exogenous and deterministic exogenous
vector<pair<int, int> > endo_max_leadlag_block, other_endo_max_leadlag_block, exo_max_leadlag_block, exo_det_max_leadlag_block, max_leadlag_block;
void writeWrapperFunctions(const string &name, const string &ending) const;
void writeDynamicModelHelper(const string &name, const string &retvalname,
const string &name_tt, size_t ttlen,
const string &previous_tt_name,
const ostringstream &init_s,
const ostringstream &end_s,
const ostringstream &s, const ostringstream &s_tt) const;
//! Create a legacy *_dynamic.m file for Matlab/Octave not yet using the temporary terms array interface
void writeDynamicMatlabCompatLayer(const string &name) const;
public:
DynamicModel(SymbolTable &symbol_table_arg, NumericalConstants &num_constants_arg, ExternalFunctionsTable &external_functions_table_argx);
//! Adds a variable node
......
This diff is collapsed.
This diff is collapsed.
......@@ -892,6 +892,17 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
unlink((basename + "_steadystate2.m").c_str());
unlink((basename + "_set_auxiliary_variables.m").c_str());
// Clean generated files for temporary terms array interface
for (auto s1 : { "dynamic", "static" })
{
for (auto s2 : { "resid", "g1", "g2", "g3" })
for (auto s3 : { "", "_tt" })
unlink((basename + "_" + s1 + "_" + s2 + s3 + ".m").c_str());
for (auto s2 : { "resid_g1", "resid_g1_g2", "resid_g1_g2_g3" })
unlink((basename + "_" + s1 + "_" + s2 + ".m").c_str());
}
}
if (!use_dll)
......@@ -1399,6 +1410,8 @@ ModFile::writeExternalFilesJulia(const string &basename, FileOutputType output,
jlOutputFile << "model_.static = " << basename << "Static.static!" << endl
<< "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
<< " model_.user_written_analytical_steady_state = true" << endl
<< " model_.steady_state = " << basename << "SteadyState.steady_state!" << endl
......
This diff is collapsed.
/*
* Copyright (C) 2003-2017 Dynare Team
* Copyright (C) 2003-2018 Dynare Team
*
* This file is part of Dynare.
*
......@@ -134,13 +134,16 @@ protected:
*/
third_derivatives_t hessian_params_derivatives;
//! Temporary terms for the static/dynamic file (those which will be noted Txxxx)
//! Temporary terms for the static/dynamic file (those which will be noted T[x])
temporary_terms_t temporary_terms;
map<expr_t, expr_t, ExprNodeLess> temporary_terms_mlv;
temporary_terms_t temporary_terms_res;
temporary_terms_t temporary_terms_g1;
temporary_terms_t temporary_terms_g2;
temporary_terms_t temporary_terms_g3;
temporary_terms_idxs_t temporary_terms_idxs;
//! Temporary terms for the file containing parameters derivatives
temporary_terms_t params_derivs_temporary_terms;
temporary_terms_t params_derivs_temporary_terms_res;
......@@ -149,6 +152,8 @@ protected:
temporary_terms_t params_derivs_temporary_terms_g12;
temporary_terms_t params_derivs_temporary_terms_g2;
temporary_terms_idxs_t params_derivs_temporary_terms_idxs;
//! Trend variables and their growth factors
map<int, expr_t> trend_symbols_map;
......@@ -182,7 +187,7 @@ protected:
//! Computes temporary terms for the file containing parameters derivatives
void computeParamsDerivativesTemporaryTerms();
//! Writes temporary terms
void writeTemporaryTerms(const temporary_terms_t &tt, const temporary_terms_t &ttm1, ostream &output, ExprNodeOutputType output_type, deriv_node_temp_terms_t &tef_terms) const;
void writeTemporaryTerms(const temporary_terms_t &tt, const temporary_terms_t &ttm1, const temporary_terms_idxs_t &tt_idxs, ostream &output, ExprNodeOutputType output_type, deriv_node_temp_terms_t &tef_terms) const;
void writeJsonTemporaryTerms(const temporary_terms_t &tt, const temporary_terms_t &ttm1, ostream &output, deriv_node_temp_terms_t &tef_terms, string &concat) const;
//! Compiles temporary terms
void compileTemporaryTerms(ostream &code_file, unsigned int &instruction_number, const temporary_terms_t &tt, map_idx_t map_idx, bool dynamic, bool steady_dynamic) const;
......@@ -192,11 +197,13 @@ protected:
void fixNestedParenthesis(ostringstream &output, map<string, string> &tmp_paren_vars, bool &message_printed) const;
//! Tests if string contains more than 32 nested parens, Issue #1201
bool testNestedParenthesis(const string &str) const;
//! Writes model local variables
/*! No temporary term is used in the output, so that local parameters declarations can be safely put before temporary terms declaration in the output files */
void writeModelLocalVariables(ostream &output, ExprNodeOutputType output_type, deriv_node_temp_terms_t &tef_terms) const;
void writeModelLocalVariableTemporaryTerms(const temporary_terms_t &tto, const map<expr_t, expr_t, ExprNodeLess> &tt,
ostream &output, ExprNodeOutputType output_type,
deriv_node_temp_terms_t &tef_terms) const;
//! Writes model equations
void writeModelEquations(ostream &output, ExprNodeOutputType output_type) const;
void writeModelEquations(ostream &output, ExprNodeOutputType output_type,
const temporary_terms_t &temporary_terms) const;
//! Writes JSON model equations
//! if residuals = true, we are writing the dynamic/static model.
//! Otherwise, just the model equations (with line numbers, no tmp terms)
......
......@@ -66,9 +66,8 @@ InitParamStatement::writeJuliaOutput(ostream &output, const string &basename)
void
InitParamStatement::writeJsonOutput(ostream &output) const
{
deriv_node_temp_terms_t tef_terms;
output << "{\"statementName\": \"param_init\", \"name\": \"" << symbol_table.getName(symb_id) << "\", " << "\"value\": \"";
param_value->writeJsonOutput(output, temporary_terms_t(), tef_terms);
param_value->writeJsonOutput(output, {}, {});
output << "\"}";
}
......@@ -177,14 +176,13 @@ InitOrEndValStatement::writeInitValues(ostream &output) const
void
InitOrEndValStatement::writeJsonInitValues(ostream &output) const
{
deriv_node_temp_terms_t tef_terms;
for (init_values_t::const_iterator it = init_values.begin();
it != init_values.end(); it++)
{
if (it != init_values.begin())
output << ", ";
output << "{\"name\": \"" << symbol_table.getName(it->first) << "\", " << "\"value\": \"";
it->second->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->second->writeJsonOutput(output, {}, {});
output << "\"}";
}
}
......@@ -419,7 +417,6 @@ HistValStatement::writeOutput(ostream &output, const string &basename, bool mini
void
HistValStatement::writeJsonOutput(ostream &output) const
{
deriv_node_temp_terms_t tef_terms;
output << "{\"statementName\": \"hist_val\", \"vals\": [";
for (hist_values_t::const_iterator it = hist_values.begin();
it != hist_values.end(); it++)
......@@ -429,7 +426,7 @@ HistValStatement::writeJsonOutput(ostream &output) const
output << "{ \"name\": \"" << symbol_table.getName(it->first.first) << "\""
<< ", \"lag\": " << it->first.second
<< ", \"value\": \"";
it->second->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->second->writeJsonOutput(output, {}, {});
output << "\"}";
}
output << "]}";
......@@ -516,7 +513,6 @@ HomotopyStatement::writeOutput(ostream &output, const string &basename, bool min
void
HomotopyStatement::writeJsonOutput(ostream &output) const
{
deriv_node_temp_terms_t tef_terms;
output << "{\"statementName\": \"homotopy\", "
<< "\"values\": [";
for (homotopy_values_t::const_iterator it = homotopy_values.begin();
......@@ -527,11 +523,11 @@ HomotopyStatement::writeJsonOutput(ostream &output) const
output << "{\"name\": \"" << symbol_table.getName(it->first) << "\""
<< ", \"initial_value\": \"";
if (it->second.first != NULL)
it->second.first->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->second.first->writeJsonOutput(output, {}, {});
else
output << "NaN";
output << "\", \"final_value\": \"";
it->second.second->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->second.second->writeJsonOutput(output, {}, {});
output << "\"}";
}
output << "]"
......@@ -625,7 +621,6 @@ LoadParamsAndSteadyStateStatement::writeOutput(ostream &output, const string &ba
void
LoadParamsAndSteadyStateStatement::writeJsonOutput(ostream &output) const
{
deriv_node_temp_terms_t tef_terms;
output << "{\"statementName\": \"load_params_and_steady_state\""
<< "\"values\": [";
for (map<int, string>::const_iterator it = content.begin();
......
......@@ -70,7 +70,6 @@ AbstractShocksStatement::writeDetShocks(ostream &output) const
void
AbstractShocksStatement::writeJsonDetShocks(ostream &output) const
{
deriv_node_temp_terms_t tef_terms;
output << "\"deterministic_shocks\": [";
for (det_shocks_t::const_iterator it = det_shocks.begin();
it != det_shocks.end(); it++)
......@@ -87,7 +86,7 @@ AbstractShocksStatement::writeJsonDetShocks(ostream &output) const
output << "{\"period1\": " << it1->period1 << ", "
<< "\"period2\": " << it1->period2 << ", "
<< "\"value\": \"";
it1->value->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it1->value->writeJsonOutput(output, {}, {});
output << "\"}";
}
output << "]}";
......@@ -154,7 +153,6 @@ ShocksStatement::writeOutput(ostream &output, const string &basename, bool minim
void
ShocksStatement::writeJsonOutput(ostream &output) const
{
deriv_node_temp_terms_t tef_terms;
output << "{\"statementName\": \"shocks\""
<< ", \"overwrite\": ";
if (overwrite)
......@@ -173,7 +171,7 @@ ShocksStatement::writeJsonOutput(ostream &output) const
output << ", ";
output << "{\"name\": \"" << symbol_table.getName(it->first) << "\", "
<< "\"variance\": \"";
it->second->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->second->writeJsonOutput(output, {}, {});
output << "\"}";
}
output << "]"
......@@ -184,7 +182,7 @@ ShocksStatement::writeJsonOutput(ostream &output) const
output << ", ";
output << "{\"name\": \"" << symbol_table.getName(it->first) << "\", "
<< "\"stderr\": \"";
it->second->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->second->writeJsonOutput(output, {}, {});
output << "\"}";
}
output << "]"
......@@ -197,7 +195,7 @@ ShocksStatement::writeJsonOutput(ostream &output) const
<< "\"name\": \"" << symbol_table.getName(it->first.first) << "\", "
<< "\"name2\": \"" << symbol_table.getName(it->first.second) << "\", "
<< "\"covariance\": \"";
it->second->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->second->writeJsonOutput(output, {}, {});
output << "\"}";
}
output << "]"
......@@ -210,7 +208,7 @@ ShocksStatement::writeJsonOutput(ostream &output) const
<< "\"name\": \"" << symbol_table.getName(it->first.first) << "\", "
<< "\"name2\": \"" << symbol_table.getName(it->first.second) << "\", "
<< "\"correlation\": \"";
it->second->writeJsonOutput(output, temporary_terms_t(), tef_terms);
it->second->writeJsonOutput(output, {}, {});
output << "\"}";
}
output << "]"
......
This diff is collapsed.
/*
* Copyright (C) 2003-2017 Dynare Team
* Copyright (C) 2003-2018 Dynare Team
*
* This file is part of Dynare.
*
......@@ -51,7 +51,7 @@ private:
void writeStaticJuliaFile(const string &basename) const;
//! Writes the static model equations and its derivatives
void writeStaticModel(ostream &StaticOutput, bool use_dll, bool julia) const;
void writeStaticModel(const string &basename, ostream &StaticOutput, bool use_dll, bool julia) const;
//! Writes the static function calling the block to solve (Matlab version)
void writeStaticBlockMFSFile(const string &basename) const;
......@@ -101,9 +101,6 @@ private:
//! Collect only the first derivatives
map<pair<int, pair<int, int> >, expr_t> collect_first_order_derivatives_endogenous();
//! Write chain rule derivative of a recursive equation w.r. to a variable
void writeChainRuleDerivative(ostream &output, int eq, int var, int lag, ExprNodeOutputType output_type, const temporary_terms_t &temporary_terms) const;
//! Collecte the derivatives w.r. to endogenous of the block, to endogenous of previouys blocks and to exogenous
void collect_block_first_order_derivatives();
......@@ -148,6 +145,19 @@ protected:
//!Maximum lead and lag for each block on endogenous of the block, endogenous of the previous blocks, exogenous and deterministic exogenous
vector<pair<int, int> > endo_max_leadlag_block, other_endo_max_leadlag_block, exo_max_leadlag_block, exo_det_max_leadlag_block, max_leadlag_block;
//! Helper functions for writeStaticModel
void writeStaticModelHelper(const string &name, const string &retvalname,
const string &name_tt, size_t ttlen,
const string &previous_tt_name,
const ostringstream &init_s, const ostringstream &end_s,
const ostringstream &s, const ostringstream &s_tt) const;
void writeWrapperFunctions(const string &basename, const string &ending) const;
//! Create a legacy *_static.m file for Matlab/Octave not yet using the temporary terms array interface
void writeStaticMatlabCompatLayer(const string &name) const;
void writeStaticModel(ostream &DynamicOutput, bool use_dll, bool julia) const;
void writeStaticModel(const string &dynamic_basename, bool use_dll, bool julia) const;
public:
StaticModel(SymbolTable &symbol_table_arg, NumericalConstants &num_constants, ExternalFunctionsTable &external_functions_table_arg);
......
......@@ -277,9 +277,7 @@ SteadyStateModel::writeJsonSteadyStateFile(ostream &output, bool transformComput
if (def_table.size() == 0)
return;
deriv_node_temp_terms_t tef_terms;
vector<pair<string, string> > eqtags;
temporary_terms_t tt_empty;
output << "{\"steady_state_model\": [";
......@@ -299,13 +297,13 @@ SteadyStateModel::writeJsonSteadyStateFile(ostream &output, bool transformComput
variable_node_map.find(make_pair(symb_ids[j], 0));
assert(it != variable_node_map.end());
output << "\"";
dynamic_cast<ExprNode *>(it->second)->writeJsonOutput(output, tt_empty, tef_terms, false);
dynamic_cast<ExprNode *>(it->second)->writeJsonOutput(output, {}, {}, false);
output << "\"";
}
if (symb_ids.size() > 1)
output << "]";
output << ", \"rhs\":\"";
def_table[i].second->writeJsonOutput(output, tt_empty, tef_terms, false);
def_table[i].second->writeJsonOutput(output, {}, {}, false);
output << "\"}" << endl;
}
......
......@@ -1110,34 +1110,35 @@ SymbolTable::writeJuliaOutput(ostream &output) const throw (NotYetFrozenExceptio
{
case avEndoLead:
case avExoLead:
break;
case avEndoLag:
case avExoLag:
case avVarModel:
case avUnaryOp:
output << getTypeSpecificID(aux_vars[i].get_orig_symb_id()) + 1 << ", "
<< aux_vars[i].get_orig_lead_lag() << ", NaN, NaN";
<< aux_vars[i].get_orig_lead_lag() << ", typemin(Int), string()";
break;
case avDiff:
case avDiffLag:
if (aux_vars[i].get_orig_symb_id() >= 0)
output << getTypeSpecificID(aux_vars[i].get_orig_symb_id()) + 1 << ", "
<< aux_vars[i].get_orig_lead_lag() << ", NaN, NaN";
<< aux_vars[i].get_orig_lead_lag() << ", typemin(Int), string()";
break;
case avMultiplier:
output << "NaN, NaN, " << aux_vars[i].get_equation_number_for_multiplier() + 1
<< ", NaN";
output << "typemin(Int), typemin(Int), " << aux_vars[i].get_equation_number_for_multiplier() + 1
<< ", string()";
break;
case avDiffForward:
output << getTypeSpecificID(aux_vars[i].get_orig_symb_id())+1 << ", NaN, ";
output << getTypeSpecificID(aux_vars[i].get_orig_symb_id())+1 << ", typemin(Int), typemin(Int), string()";
break;
case avExpectation:
output << "NaN, NaN, NaN, \"\\mathbb{E}_{t"
output << "typemin(Int), typemin(Int), typemin(Int), \"\\mathbb{E}_{t"
<< (aux_vars[i].get_information_set() < 0 ? "" : "+")
<< aux_vars[i].get_information_set() << "}(";
aux_vars[i].get_expr_node()->writeOutput(output, oLatexDynamicModel);
output << ")\"";
break;