Commit ec215e2a authored by Houtan Bastani's avatar Houtan Bastani
Browse files

separate temporary terms: WIP

parent 7cbd7b6e
This diff is collapsed.
...@@ -109,6 +109,8 @@ private: ...@@ -109,6 +109,8 @@ private:
//! Writes the dynamic model equations and its derivatives //! Writes the dynamic model equations and its derivatives
/*! \todo add third derivatives handling in C output */ /*! \todo add third derivatives handling in C output */
void writeDynamicModel(ostream &DynamicOutput, bool use_dll, bool julia) const; 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 //! Writes the Block reordred structure of the model in M output
void writeModelEquationsOrdered_M(const string &dynamic_basename) const; void writeModelEquationsOrdered_M(const string &dynamic_basename) const;
//! Writes the code of the Block reordred structure of the model in virtual machine bytecode //! Writes the code of the Block reordred structure of the model in virtual machine bytecode
...@@ -235,6 +237,14 @@ private: ...@@ -235,6 +237,14 @@ private:
//!Maximum lead and lag for each block on endogenous of the block, endogenous of the previous blocks, exogenous and deterministic exogenous //!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; 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;
public: public:
DynamicModel(SymbolTable &symbol_table_arg, NumericalConstants &num_constants_arg, ExternalFunctionsTable &external_functions_table_argx); DynamicModel(SymbolTable &symbol_table_arg, NumericalConstants &num_constants_arg, ExternalFunctionsTable &external_functions_table_argx);
//! Adds a variable node //! Adds a variable node
......
This diff is collapsed.
This diff is collapsed.
/* /*
* Copyright (C) 2003-2017 Dynare Team * Copyright (C) 2003-2018 Dynare Team
* *
* This file is part of Dynare. * This file is part of Dynare.
* *
...@@ -1120,10 +1120,25 @@ ModelTree::computeTemporaryTerms(bool is_matlab) ...@@ -1120,10 +1120,25 @@ ModelTree::computeTemporaryTerms(bool is_matlab)
{ {
map<expr_t, pair<int, NodeTreeReference> > reference_count; map<expr_t, pair<int, NodeTreeReference> > reference_count;
temporary_terms.clear(); temporary_terms.clear();
temporary_terms_mlv.clear();
temporary_terms_res.clear(); temporary_terms_res.clear();
temporary_terms_g1.clear(); temporary_terms_g1.clear();
temporary_terms_g2.clear(); temporary_terms_g2.clear();
temporary_terms_g3.clear(); temporary_terms_g3.clear();
// Collect all model local variables appearing in equations. See #101
// All used model local variables are automatically set as temporary variables
map<int, expr_t> used_local_vars;
for (size_t i = 0; i < equations.size(); i++)
equations[i]->collectModelLocalVariables(used_local_vars);
for (map<int, expr_t>::const_iterator it = used_local_vars.begin();
it != used_local_vars.end(); it++)
{
temporary_terms_mlv[it->second] = local_variables_table.find(it->first)->second;
reference_count[it->second] = make_pair(MIN_COST(is_matlab)+1, eResiduals);
}
map<NodeTreeReference, temporary_terms_t> temp_terms_map; map<NodeTreeReference, temporary_terms_t> temp_terms_map;
temp_terms_map[eResiduals] = temporary_terms_res; temp_terms_map[eResiduals] = temporary_terms_res;
temp_terms_map[eFirstDeriv] = temporary_terms_g1; temp_terms_map[eFirstDeriv] = temporary_terms_g1;
...@@ -1154,20 +1169,54 @@ ModelTree::computeTemporaryTerms(bool is_matlab) ...@@ -1154,20 +1169,54 @@ ModelTree::computeTemporaryTerms(bool is_matlab)
temp_terms_map, temp_terms_map,
is_matlab, eThirdDeriv); is_matlab, eThirdDeriv);
int idx = 0;
for (map<NodeTreeReference, temporary_terms_t>::const_iterator it = temp_terms_map.begin(); for (map<NodeTreeReference, temporary_terms_t>::const_iterator it = temp_terms_map.begin();
it != temp_terms_map.end(); it++) it != temp_terms_map.end(); it++)
temporary_terms.insert(it->second.begin(), it->second.end()); {
temporary_terms.insert(it->second.begin(), it->second.end());
temporary_terms_idxs.push_back(idx++);
}
temporary_terms_res = temp_terms_map[eResiduals]; temporary_terms_res = temp_terms_map[eResiduals];
temporary_terms_g1 = temp_terms_map[eFirstDeriv]; temporary_terms_g1 = temp_terms_map[eFirstDeriv];
temporary_terms_g2 = temp_terms_map[eSecondDeriv]; temporary_terms_g2 = temp_terms_map[eSecondDeriv];
temporary_terms_g3 = temp_terms_map[eThirdDeriv]; temporary_terms_g3 = temp_terms_map[eThirdDeriv];
temporary_terms_mlv_idxs.clear();
temporary_terms_res_idxs.clear();
temporary_terms_g1_idxs.clear();
temporary_terms_g2_idxs.clear();
temporary_terms_g3_idxs.clear();
idx = 0;
for (map<expr_t, expr_t>::const_iterator it = temporary_terms_mlv.begin();
it != temporary_terms_mlv.end(); it++)
temporary_terms_mlv_idxs.push_back(idx++);
for (temporary_terms_t::const_iterator it = temporary_terms_res.begin();
it != temporary_terms_res.end(); it++)
temporary_terms_res_idxs.push_back(idx++);
for (temporary_terms_t::const_iterator it = temporary_terms_g1.begin();
it != temporary_terms_g1.end(); it++)
temporary_terms_g1_idxs.push_back(idx++);
for (temporary_terms_t::const_iterator it = temporary_terms_g2.begin();
it != temporary_terms_g2.end(); it++)
temporary_terms_g2_idxs.push_back(idx++);
for (temporary_terms_t::const_iterator it = temporary_terms_g3.begin();
it != temporary_terms_g3.end(); it++)
temporary_terms_g3_idxs.push_back(idx++);
} }
void void
ModelTree::writeTemporaryTerms(const temporary_terms_t &tt, const temporary_terms_t &ttm1, ostream &output, ModelTree::writeTemporaryTerms(const temporary_terms_t &tt, const temporary_terms_t &ttm1, ostream &output,
ExprNodeOutputType output_type, deriv_node_temp_terms_t &tef_terms) const ExprNodeOutputType output_type, deriv_node_temp_terms_t &tef_terms) const
{ {
temporary_terms_idxs_t tti, ttm1i;
writeTemporaryTerms(tt, tti, ttm1, ttm1i, output, output_type, tef_terms);
/*
// Local var used to keep track of temp nodes already written // Local var used to keep track of temp nodes already written
temporary_terms_t tt2 = ttm1; temporary_terms_t tt2 = ttm1;
for (temporary_terms_t::const_iterator it = tt.begin(); for (temporary_terms_t::const_iterator it = tt.begin();
...@@ -1193,6 +1242,72 @@ ModelTree::writeTemporaryTerms(const temporary_terms_t &tt, const temporary_term ...@@ -1193,6 +1242,72 @@ ModelTree::writeTemporaryTerms(const temporary_terms_t &tt, const temporary_term
// Insert current node into tt2 // Insert current node into tt2
tt2.insert(*it); tt2.insert(*it);
} }
*/
}
void
ModelTree::writeModelLocalVariableTemporaryTerms(const temporary_terms_t &tto, const map<expr_t, expr_t> &tt,
const temporary_terms_idxs_t &ttidxs,
ostream &output, ExprNodeOutputType output_type,
deriv_node_temp_terms_t &tef_terms) const
{
temporary_terms_t tt2;
temporary_terms_idxs_t tt2idxs;
int ttidx = 0;
for (map<expr_t, expr_t>::const_iterator it = tt.begin();
it != tt.end(); it++, ttidx++)
{
if (IS_C(output_type))
output << "double ";
else if (IS_JULIA(output_type))
output << " @inbounds const ";
it->first->writeOutput(output, output_type, tto, ttidxs, tef_terms);
output << " = ";
it->second->writeOutput(output, output_type, tt2, tt2idxs, tef_terms);
if (IS_C(output_type) || IS_MATLAB(output_type))
output << ";";
output << endl;
// Insert current node into tt2
tt2.insert(it->first);
tt2idxs.push_back(ttidxs[ttidx]);
}
}
void
ModelTree::writeTemporaryTerms(const temporary_terms_t &tt, const temporary_terms_idxs_t &ttidxs,
const temporary_terms_t &ttm1, const temporary_terms_idxs_t &ttm1idxs,
ostream &output, ExprNodeOutputType output_type, deriv_node_temp_terms_t &tef_terms) const
{
// Local var used to keep track of temp nodes already written
temporary_terms_t tt2 = ttm1;
temporary_terms_idxs_t tt2idxs = ttm1idxs;
int ttidx = 0;
for (temporary_terms_t::const_iterator it = tt.begin();
it != tt.end(); it++, ttidx++)
{
if (dynamic_cast<AbstractExternalFunctionNode *>(*it) != NULL)
(*it)->writeExternalFunctionOutput(output, output_type, tt2, tt2idxs, tef_terms);
if (IS_C(output_type))
output << "double ";
else if (IS_JULIA(output_type))
output << " @inbounds ";
(*it)->writeOutput(output, output_type, tt, ttidxs, tef_terms);
output << " = ";
(*it)->writeOutput(output, output_type, tt2, tt2idxs, tef_terms);
if (IS_C(output_type) || IS_MATLAB(output_type))
output << ";";
output << endl;
// Insert current node into tt2
tt2.insert(*it);
tt2idxs.push_back(ttidxs[ttidx]);
}
} }
void void
...@@ -1407,14 +1522,13 @@ ModelTree::compileTemporaryTerms(ostream &code_file, unsigned int &instruction_n ...@@ -1407,14 +1522,13 @@ ModelTree::compileTemporaryTerms(ostream &code_file, unsigned int &instruction_n
void void
ModelTree::writeModelLocalVariables(ostream &output, ExprNodeOutputType output_type, deriv_node_temp_terms_t &tef_terms) const ModelTree::writeModelLocalVariables(ostream &output, ExprNodeOutputType output_type, deriv_node_temp_terms_t &tef_terms) const
{ {
return;
/* Collect all model local variables appearing in equations, and print only /* Collect all model local variables appearing in equations, and print only
them. Printing unused model local variables can lead to a crash (see them. Printing unused model local variables can lead to a crash (see
ticket #101). */ ticket #101). */
set<int> used_local_vars; set<int> used_local_vars;
// Use an empty set for the temporary terms
const temporary_terms_t tt; const temporary_terms_t tt;
const temporary_terms_idxs_t tti;
for (size_t i = 0; i < equations.size(); i++) for (size_t i = 0; i < equations.size(); i++)
equations[i]->collectVariables(eModelLocalVariable, used_local_vars); equations[i]->collectVariables(eModelLocalVariable, used_local_vars);
...@@ -1424,17 +1538,17 @@ ModelTree::writeModelLocalVariables(ostream &output, ExprNodeOutputType output_t ...@@ -1424,17 +1538,17 @@ ModelTree::writeModelLocalVariables(ostream &output, ExprNodeOutputType output_t
{ {
int id = *it; int id = *it;
expr_t value = local_variables_table.find(id)->second; expr_t value = local_variables_table.find(id)->second;
value->writeExternalFunctionOutput(output, output_type, tt, tef_terms); value->writeExternalFunctionOutput(output, output_type, tt, tti, tef_terms);
if (IS_C(output_type)) if (IS_C(output_type))
output << "double "; output << "double ";
else if (IS_JULIA(output_type)) else if (IS_JULIA(output_type))
output << " @inbounds "; output << " @inbounds ";
/* We append underscores to avoid name clashes with "g1" or "oo_" (see /* We append underscores to avoid name clashes with "g1" or "oo_" (see
also VariableNode::writeOutput) */ also VariableNode::writeOutput) */
output << symbol_table.getName(id) << "__ = "; output << symbol_table.getName(id) << "__ = ";
value->writeOutput(output, output_type, tt, tef_terms); value->writeOutput(output, output_type, tt, tti, tef_terms);
output << ";" << endl; output << ";" << endl;
} }
} }
...@@ -1491,12 +1605,16 @@ ModelTree::writeJsonModelLocalVariables(ostream &output, deriv_node_temp_terms_t ...@@ -1491,12 +1605,16 @@ ModelTree::writeJsonModelLocalVariables(ostream &output, deriv_node_temp_terms_t
void void
ModelTree::writeModelEquations(ostream &output, ExprNodeOutputType output_type) const ModelTree::writeModelEquations(ostream &output, ExprNodeOutputType output_type) const
{ {
temporary_terms_t temp_terms; temporary_terms_t tt;
if (IS_JULIA(output_type)) temporary_terms_idxs_t ttidxs;
temp_terms = temporary_terms_res; writeModelEquations(output, output_type, tt, ttidxs);
else }
temp_terms = temporary_terms;
void
ModelTree::writeModelEquations(ostream &output, ExprNodeOutputType output_type,
const temporary_terms_t &temporary_terms,
const temporary_terms_idxs_t &temporary_terms_idxs) const
{
for (int eq = 0; eq < (int) equations.size(); eq++) for (int eq = 0; eq < (int) equations.size(); eq++)
{ {
BinaryOpNode *eq_node = equations[eq]; BinaryOpNode *eq_node = equations[eq];
...@@ -1514,35 +1632,39 @@ ModelTree::writeModelEquations(ostream &output, ExprNodeOutputType output_type) ...@@ -1514,35 +1632,39 @@ ModelTree::writeModelEquations(ostream &output, ExprNodeOutputType output_type)
} }
if (vrhs != 0) // The right hand side of the equation is not empty ==> residual=lhs-rhs; if (vrhs != 0) // The right hand side of the equation is not empty ==> residual=lhs-rhs;
{ if (IS_JULIA(output_type))
if (IS_JULIA(output_type)) {
output << " @inbounds "; output << " @inbounds residual" << LEFT_ARRAY_SUBSCRIPT(output_type)
output << "lhs ="; << eq + ARRAY_SUBSCRIPT_OFFSET(output_type)
lhs->writeOutput(output, output_type, temp_terms); << RIGHT_ARRAY_SUBSCRIPT(output_type)
output << ";" << endl; << " = (";
lhs->writeOutput(output, output_type, temporary_terms, temporary_terms_idxs);
if (IS_JULIA(output_type)) output << ") - (";
output << " @inbounds "; rhs->writeOutput(output, output_type, temporary_terms, temporary_terms_idxs);
output << "rhs ="; output << ")" << endl;
rhs->writeOutput(output, output_type, temp_terms); }
output << ";" << endl; else
{
if (IS_JULIA(output_type)) output << "lhs = ";
output << " @inbounds "; lhs->writeOutput(output, output_type, temporary_terms, temporary_terms_idxs);
output << "residual" << LEFT_ARRAY_SUBSCRIPT(output_type) output << ";" << endl
<< eq + ARRAY_SUBSCRIPT_OFFSET(output_type) << "rhs = ";
<< RIGHT_ARRAY_SUBSCRIPT(output_type) rhs->writeOutput(output, output_type, temporary_terms, temporary_terms_idxs);
<< "= lhs-rhs;" << endl; output << ";" << endl
} << "residual" << LEFT_ARRAY_SUBSCRIPT(output_type)
<< eq + ARRAY_SUBSCRIPT_OFFSET(output_type)
<< RIGHT_ARRAY_SUBSCRIPT(output_type)
<< " = lhs - rhs;" << endl;
}
else // The right hand side of the equation is empty ==> residual=lhs; else // The right hand side of the equation is empty ==> residual=lhs;
{ {
if (IS_JULIA(output_type)) if (IS_JULIA(output_type))
output << " @inbounds "; output << " @inbounds ";
output << "residual" << LEFT_ARRAY_SUBSCRIPT(output_type) output << "residual" << LEFT_ARRAY_SUBSCRIPT(output_type)
<< eq + ARRAY_SUBSCRIPT_OFFSET(output_type) << eq + ARRAY_SUBSCRIPT_OFFSET(output_type)
<< RIGHT_ARRAY_SUBSCRIPT(output_type) << RIGHT_ARRAY_SUBSCRIPT(output_type)
<< " = "; << " = ";
lhs->writeOutput(output, output_type, temp_terms); lhs->writeOutput(output, output_type, temporary_terms, temporary_terms_idxs);
output << ";" << endl; output << ";" << endl;
} }
} }
...@@ -1787,9 +1909,8 @@ ModelTree::set_cutoff_to_zero() ...@@ -1787,9 +1909,8 @@ ModelTree::set_cutoff_to_zero()
void void
ModelTree::jacobianHelper(ostream &output, int eq_nb, int col_nb, ExprNodeOutputType output_type) const ModelTree::jacobianHelper(ostream &output, int eq_nb, int col_nb, ExprNodeOutputType output_type) const
{ {
output << " ";
if (IS_JULIA(output_type)) if (IS_JULIA(output_type))
output << "@inbounds "; output << " @inbounds ";
output << "g1" << LEFT_ARRAY_SUBSCRIPT(output_type); output << "g1" << LEFT_ARRAY_SUBSCRIPT(output_type);
if (IS_MATLAB(output_type) || IS_JULIA(output_type)) if (IS_MATLAB(output_type) || IS_JULIA(output_type))
output << eq_nb + 1 << "," << col_nb + 1; output << eq_nb + 1 << "," << col_nb + 1;
...@@ -1801,7 +1922,7 @@ ModelTree::jacobianHelper(ostream &output, int eq_nb, int col_nb, ExprNodeOutput ...@@ -1801,7 +1922,7 @@ ModelTree::jacobianHelper(ostream &output, int eq_nb, int col_nb, ExprNodeOutput
void void
ModelTree::sparseHelper(int order, ostream &output, int row_nb, int col_nb, ExprNodeOutputType output_type) const ModelTree::sparseHelper(int order, ostream &output, int row_nb, int col_nb, ExprNodeOutputType output_type) const
{ {
output << " v" << order << LEFT_ARRAY_SUBSCRIPT(output_type); output << "v" << order << LEFT_ARRAY_SUBSCRIPT(output_type);
if (IS_MATLAB(output_type) || IS_JULIA(output_type)) if (IS_MATLAB(output_type) || IS_JULIA(output_type))
output << row_nb + 1 << "," << col_nb + 1; output << row_nb + 1 << "," << col_nb + 1;
else else
......
/* /*
* Copyright (C) 2003-2017 Dynare Team * Copyright (C) 2003-2018 Dynare Team
* *
* This file is part of Dynare. * This file is part of Dynare.
* *
...@@ -134,13 +134,21 @@ protected: ...@@ -134,13 +134,21 @@ protected:
*/ */
third_derivatives_t hessian_params_derivatives; 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; temporary_terms_t temporary_terms;
map<expr_t, expr_t> temporary_terms_mlv;
temporary_terms_t temporary_terms_res; temporary_terms_t temporary_terms_res;
temporary_terms_t temporary_terms_g1; temporary_terms_t temporary_terms_g1;
temporary_terms_t temporary_terms_g2; temporary_terms_t temporary_terms_g2;
temporary_terms_t temporary_terms_g3; temporary_terms_t temporary_terms_g3;
temporary_terms_idxs_t temporary_terms_idxs;
temporary_terms_idxs_t temporary_terms_mlv_idxs;
temporary_terms_idxs_t temporary_terms_res_idxs;
temporary_terms_idxs_t temporary_terms_g1_idxs;
temporary_terms_idxs_t temporary_terms_g2_idxs;
temporary_terms_idxs_t temporary_terms_g3_idxs;
//! Temporary terms for the file containing parameters derivatives //! Temporary terms for the file containing parameters derivatives
temporary_terms_t params_derivs_temporary_terms; temporary_terms_t params_derivs_temporary_terms;
temporary_terms_t params_derivs_temporary_terms_res; temporary_terms_t params_derivs_temporary_terms_res;
...@@ -183,6 +191,9 @@ protected: ...@@ -183,6 +191,9 @@ protected:
void computeParamsDerivativesTemporaryTerms(); void computeParamsDerivativesTemporaryTerms();
//! Writes temporary terms //! 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, ostream &output, ExprNodeOutputType output_type, deriv_node_temp_terms_t &tef_terms) const;
void writeTemporaryTerms(const temporary_terms_t &tt, const temporary_terms_idxs_t &ttidxs,
const temporary_terms_t &ttm1, const temporary_terms_idxs_t &ttm1idxs,
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; 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 //! 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; 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;
...@@ -195,8 +206,15 @@ protected: ...@@ -195,8 +206,15 @@ protected:
//! Writes model local variables //! 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 */ /*! 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 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> &tt,
const temporary_terms_idxs_t &ttidxs,
ostream &output, ExprNodeOutputType output_type,
deriv_node_temp_terms_t &tef_terms) const;
//! Writes model equations //! Writes model equations
void writeModelEquations(ostream &output, ExprNodeOutputType output_type) const; void writeModelEquations(ostream &output, ExprNodeOutputType output_type) const;
void writeModelEquations(ostream &output, ExprNodeOutputType output_type,
const temporary_terms_t &temporary_terms,
const temporary_terms_idxs_t &temporary_terms_idxs) const;
//! Writes JSON model equations //! Writes JSON model equations
//! if residuals = true, we are writing the dynamic/static model. //! if residuals = true, we are writing the dynamic/static model.
//! Otherwise, just the model equations (with line numbers, no tmp terms) //! Otherwise, just the model equations (with line numbers, no tmp terms)
......
This diff is collapsed.
/* /*
* Copyright (C) 2003-2017 Dynare Team * Copyright (C) 2003-2018 Dynare Team
* *
* This file is part of Dynare. * This file is part of Dynare.
* *
...@@ -51,7 +51,7 @@ private: ...@@ -51,7 +51,7 @@ private:
void writeStaticJuliaFile(const string &basename) const; void writeStaticJuliaFile(const string &basename) const;
//! Writes the static model equations and its derivatives //! 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) //! Writes the static function calling the block to solve (Matlab version)
void writeStaticBlockMFSFile(const string &basename) const; void writeStaticBlockMFSFile(const string &basename) const;
...@@ -148,6 +148,15 @@ protected: ...@@ -148,6 +148,15 @@ protected:
//!Maximum lead and lag for each block on endogenous of the block, endogenous of the previous blocks, exogenous and deterministic exogenous //!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; 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;
void writeStaticModel(ostream &DynamicOutput, bool use_dll, bool julia) const;
void writeStaticModel(const string &dynamic_basename, bool use_dll, bool julia) const;
public: public:
StaticModel(SymbolTable &symbol_table_arg, NumericalConstants &num_constants, ExternalFunctionsTable &external_functions_table_arg); StaticModel(SymbolTable &symbol_table_arg, NumericalConstants &num_constants, ExternalFunctionsTable &external_functions_table_arg);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment