diff --git a/preprocessor/ComputingTasks.cc b/preprocessor/ComputingTasks.cc index 126729ed6b5669268e5f70940e2233130c91afd8..359a1b033b5d9e68e8e848028bd03adb51ca2d3d 100644 --- a/preprocessor/ComputingTasks.cc +++ b/preprocessor/ComputingTasks.cc @@ -895,7 +895,7 @@ void PlannerObjectiveStatement::computingPass() { model_tree->computeStaticHessian = true; - model_tree->computingPass(eval_context_type()); + model_tree->computingPass(eval_context_type(), false); } void diff --git a/preprocessor/DynareMain.cc b/preprocessor/DynareMain.cc index 176085d34270bf62a1fe1fb8d05cb96f2a506640..e99b48c6191a2d7d7201d3bb5f613a56c040dc6e 100644 --- a/preprocessor/DynareMain.cc +++ b/preprocessor/DynareMain.cc @@ -32,7 +32,7 @@ using namespace std; Splitting main() in two parts was necessary because ParsingDriver.h and MacroDriver.h can't be included simultaneously (because of Bison limitations). */ -void main2(stringstream &in, string &basename, bool debug, bool clear_all); +void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tmp_terms); void usage() @@ -53,6 +53,7 @@ main(int argc, char** argv) bool clear_all = true; bool save_macro = false; bool debug = false; + bool no_tmp_terms = false; // Parse options for (int arg = 2; arg < argc; arg++) @@ -63,6 +64,8 @@ main(int argc, char** argv) clear_all = false; else if (string(argv[arg]) == string("savemacro")) save_macro = true; + else if (string(argv[arg]) == string("notmpterms")) + no_tmp_terms = true; else { cerr << "Unknown option: " << argv[arg] << endl; @@ -97,7 +100,7 @@ main(int argc, char** argv) } // Do the rest - main2(macro_output, basename, debug, clear_all); + main2(macro_output, basename, debug, clear_all, no_tmp_terms); return 0; } diff --git a/preprocessor/DynareMain2.cc b/preprocessor/DynareMain2.cc index 53a5584d2219384b0cda3f24777f41c5291fb027..e6111e910291d07b7672eea28117460e24f50e52 100644 --- a/preprocessor/DynareMain2.cc +++ b/preprocessor/DynareMain2.cc @@ -25,7 +25,7 @@ using namespace std; #include "ModFile.hh" void -main2(stringstream &in, string &basename, bool debug, bool clear_all) +main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tmp_terms) { ParsingDriver p; @@ -36,7 +36,7 @@ main2(stringstream &in, string &basename, bool debug, bool clear_all) mod_file->checkPass(); // Do computations - mod_file->computingPass(); + mod_file->computingPass(no_tmp_terms); // Write outputs mod_file->writeOutputFiles(basename, clear_all); diff --git a/preprocessor/ModFile.cc b/preprocessor/ModFile.cc index 738805f0d5549bdcbd2727ac2f66c3eb16308dfb..9dbc1451d2580c9dc30e3de9bb1caa5a9bb0aa47 100644 --- a/preprocessor/ModFile.cc +++ b/preprocessor/ModFile.cc @@ -91,7 +91,7 @@ ModFile::checkPass() } void -ModFile::computingPass() +ModFile::computingPass(bool no_tmp_terms) { // Mod file may have no equation (for example in a standalone BVAR estimation) if (model_tree.equation_number() > 0) @@ -113,7 +113,7 @@ ModFile::computingPass() model_tree.computeThirdDerivatives = true; } - model_tree.computingPass(global_eval_context); + model_tree.computingPass(global_eval_context, no_tmp_terms); } for(vector<Statement *>::iterator it = statements.begin(); diff --git a/preprocessor/ModelTree.cc b/preprocessor/ModelTree.cc index bc478680c737ac41d8cfe78b54fbcfea03822118..21df8f0f2e9206e81aea6bbf207aed52f4c7bd6f 100644 --- a/preprocessor/ModelTree.cc +++ b/preprocessor/ModelTree.cc @@ -3965,7 +3965,7 @@ ModelTree::BlockLinear(Model_Block *ModelBlock) } void -ModelTree::computingPass(const eval_context_type &eval_context) +ModelTree::computingPass(const eval_context_type &eval_context, bool no_tmp_terms) { cout << equations.size() << " equation(s) found" << endl; @@ -3996,10 +3996,12 @@ ModelTree::computingPass(const eval_context_type &eval_context) block_triangular.Normalize_and_BlockDecompose_Static_0_Model(j_m); BlockLinear(block_triangular.ModelBlock); - computeTemporaryTermsOrdered(order, block_triangular.ModelBlock); + if (!no_tmp_terms) + computeTemporaryTermsOrdered(order, block_triangular.ModelBlock); } else - computeTemporaryTerms(order); + if (!no_tmp_terms) + computeTemporaryTerms(order); } void diff --git a/preprocessor/include/ComputingTasks.hh b/preprocessor/include/ComputingTasks.hh index cb2170e6cbf1ea0d4e607f6134f7539587b9cb1f..fd37a16f9d832100beeeb2e418b13fb3711b3eed 100644 --- a/preprocessor/include/ComputingTasks.hh +++ b/preprocessor/include/ComputingTasks.hh @@ -436,6 +436,7 @@ public: /*! \todo check there are only endogenous variables at the current period in the objective (no exogenous, no lead/lag) */ virtual void checkPass(ModFileStructure &mod_file_struct); + /*! \todo allow for the possibility of disabling temporary terms */ virtual void computingPass(); virtual void writeOutput(ostream &output, const string &basename) const; }; diff --git a/preprocessor/include/ModFile.hh b/preprocessor/include/ModFile.hh index 6dde1452291a0d6ec6d2c14e9083e24639c5ca42..1a3f3a3b2d6eecaad3c68e15f60ef2bd464e5672 100644 --- a/preprocessor/include/ModFile.hh +++ b/preprocessor/include/ModFile.hh @@ -63,7 +63,8 @@ public: /*! \todo add check for number of equations and endogenous if ramsey_policy is present */ void checkPass(); //! Execute computations - void computingPass(); + /*! \param no_tmp_terms if true, no temporary terms will be computed in the static and dynamic files */ + void computingPass(bool no_tmp_terms); //! Writes Matlab/Scilab output files /*! \param basename The base name used for writing output files. Should be the name of the mod file without its extension diff --git a/preprocessor/include/ModelTree.hh b/preprocessor/include/ModelTree.hh index 1e4fbcea3c1c8cc0601ad978be1f05f9d0673178..dcea224786b81b82f4e67c9482f181a3789a4bf0 100644 --- a/preprocessor/include/ModelTree.hh +++ b/preprocessor/include/ModelTree.hh @@ -168,8 +168,9 @@ public: //! Whether dynamic third order derivatives (w.r. to endogenous and exogenous) should be written bool computeThirdDerivatives; //! Execute computations (variable sorting + derivation) - /*! You must set computeJacobian, computeJacobianExo, computeHessian, computeStaticHessian and computeThirdDerivatives to correct values before calling this function */ - void computingPass(const eval_context_type &eval_context); + /*! You must set computeJacobian, computeJacobianExo, computeHessian, computeStaticHessian and computeThirdDerivatives to correct values before calling this function + \param no_tmp_terms if true, no temporary terms will be computed in the static and dynamic files */ + void computingPass(const eval_context_type &eval_context, bool no_tmp_terms); //! Writes model initialization and lead/lag incidence matrix to output void writeOutput(ostream &output) const; //! Writes static model file