diff --git a/src/ComputingTasks.cc b/src/ComputingTasks.cc index 686e4194..4266122d 100644 --- a/src/ComputingTasks.cc +++ b/src/ComputingTasks.cc @@ -2167,7 +2167,7 @@ PlannerObjectiveStatement::getPlannerObjective() const void PlannerObjectiveStatement::computingPass() { - model_tree.computingPass(3, 0, {}, false, false, false, false); + model_tree.computingPass(3, 0, {}, false, false, false); computing_pass_called = true; } diff --git a/src/DynamicModel.cc b/src/DynamicModel.cc index 728030f4..d762ffb7 100644 --- a/src/DynamicModel.cc +++ b/src/DynamicModel.cc @@ -4347,7 +4347,7 @@ DynamicModel::substitutePacExpectation() void DynamicModel::computingPass(bool jacobianExo, int derivsOrder, int paramsDerivsOrder, const eval_context_t &eval_context, bool no_tmp_terms, bool block, bool use_dll, - bool bytecode, bool nopreprocessoroutput, bool linear_decomposition) + bool bytecode, bool linear_decomposition) { assert(jacobianExo || (derivsOrder < 2 && paramsDerivsOrder == 0)); @@ -4370,16 +4370,14 @@ DynamicModel::computingPass(bool jacobianExo, int derivsOrder, int paramsDerivsO } // Launch computations - if (!nopreprocessoroutput) - cout << "Computing " << (linear_decomposition ? "nonlinear " : "") - << "dynamic model derivatives (order " << derivsOrder << ")." << endl; + cout << "Computing " << (linear_decomposition ? "nonlinear " : "") + << "dynamic model derivatives (order " << derivsOrder << ")." << endl; computeDerivatives(derivsOrder, vars); if (paramsDerivsOrder > 0) { - if (!nopreprocessoroutput) - cout << "Computing dynamic model derivatives w.r.t. parameters (order " << paramsDerivsOrder << ")." << endl; + cout << "Computing dynamic model derivatives w.r.t. parameters (order " << paramsDerivsOrder << ")." << endl; computeParamsDerivatives(paramsDerivsOrder); } @@ -4439,8 +4437,7 @@ DynamicModel::computingPass(bool jacobianExo, int derivsOrder, int paramsDerivsO equation_type_and_normalized_equation = equationTypeDetermination(first_order_endo_derivatives, variable_reordered, equation_reordered, mfs); - if (!nopreprocessoroutput) - cout << "Finding the optimal block decomposition of the model ..." << endl; + cout << "Finding the optimal block decomposition of the model ..." << endl; lag_lead_vector_t equation_lag_lead, variable_lag_lead; @@ -4958,7 +4955,7 @@ DynamicModel::replaceMyEquations(DynamicModel &dynamic_model) const } void -DynamicModel::computeRamseyPolicyFOCs(const StaticModel &static_model, const bool nopreprocessoroutput) +DynamicModel::computeRamseyPolicyFOCs(const StaticModel &static_model) { // Add aux LM to constraints in equations // equation[i]->lhs = rhs becomes equation[i]->MULT_(i+1)*(lhs-rhs) = 0 @@ -4969,8 +4966,7 @@ DynamicModel::computeRamseyPolicyFOCs(const StaticModel &static_model, const boo assert(substeq != nullptr); equations[i] = substeq; } - if (!nopreprocessoroutput) - cout << "Ramsey Problem: added " << i << " Multipliers." << endl; + cout << "Ramsey Problem: added " << i << " Multipliers." << endl; // Add Planner Objective to equations to include in computeDerivIDs assert(static_model.equations.size() == 1); @@ -5641,31 +5637,31 @@ DynamicModel::writeLatexOriginalFile(const string &basename, const bool write_eq } void -DynamicModel::substituteEndoLeadGreaterThanTwo(bool deterministic_model, bool nopreprocessoroutput) +DynamicModel::substituteEndoLeadGreaterThanTwo(bool deterministic_model) { - substituteLeadLagInternal(AuxVarType::endoLead, deterministic_model, {}, nopreprocessoroutput); + substituteLeadLagInternal(AuxVarType::endoLead, deterministic_model, {}); } void -DynamicModel::substituteEndoLagGreaterThanTwo(bool deterministic_model, bool nopreprocessoroutput) +DynamicModel::substituteEndoLagGreaterThanTwo(bool deterministic_model) { - substituteLeadLagInternal(AuxVarType::endoLag, deterministic_model, {}, nopreprocessoroutput); + substituteLeadLagInternal(AuxVarType::endoLag, deterministic_model, {}); } void -DynamicModel::substituteExoLead(bool deterministic_model, bool nopreprocessoroutput) +DynamicModel::substituteExoLead(bool deterministic_model) { - substituteLeadLagInternal(AuxVarType::exoLead, deterministic_model, {}, nopreprocessoroutput); + substituteLeadLagInternal(AuxVarType::exoLead, deterministic_model, {}); } void -DynamicModel::substituteExoLag(bool deterministic_model, bool nopreprocessoroutput) +DynamicModel::substituteExoLag(bool deterministic_model) { - substituteLeadLagInternal(AuxVarType::exoLag, deterministic_model, {}, nopreprocessoroutput); + substituteLeadLagInternal(AuxVarType::exoLag, deterministic_model, {}); } void -DynamicModel::substituteLeadLagInternal(AuxVarType type, bool deterministic_model, const vector &subset, bool nopreprocessoroutput) +DynamicModel::substituteLeadLagInternal(AuxVarType type, bool deterministic_model, const vector &subset) { ExprNode::subst_table_t subst_table; vector neweqs; @@ -5743,7 +5739,7 @@ DynamicModel::substituteLeadLagInternal(AuxVarType type, bool deterministic_mode // - lag variables from lower lag to higher lag copy(neweqs.begin(), neweqs.end(), back_inserter(aux_equations)); - if (!nopreprocessoroutput && neweqs.size() > 0) + if (neweqs.size() > 0) { cout << "Substitution of "; switch (type) @@ -5808,24 +5804,24 @@ DynamicModel::findPacExpectationEquationNumbers(vector &eqnumbers) const } void -DynamicModel::substituteUnaryOps(StaticModel &static_model, diff_table_t &nodes, ExprNode::subst_table_t &subst_table, bool nopreprocessoroutput) +DynamicModel::substituteUnaryOps(StaticModel &static_model, diff_table_t &nodes, ExprNode::subst_table_t &subst_table) { vector eqnumbers(equations.size()); iota(eqnumbers.begin(), eqnumbers.end(), 0); - substituteUnaryOps(static_model, nodes, subst_table, eqnumbers, nopreprocessoroutput); + substituteUnaryOps(static_model, nodes, subst_table, eqnumbers); } void -DynamicModel::substituteUnaryOps(StaticModel &static_model, diff_table_t &nodes, ExprNode::subst_table_t &subst_table, set &var_model_eqtags, bool nopreprocessoroutput) +DynamicModel::substituteUnaryOps(StaticModel &static_model, diff_table_t &nodes, ExprNode::subst_table_t &subst_table, set &var_model_eqtags) { vector eqnumbers; getEquationNumbersFromTags(eqnumbers, var_model_eqtags); findPacExpectationEquationNumbers(eqnumbers); - substituteUnaryOps(static_model, nodes, subst_table, eqnumbers, nopreprocessoroutput); + substituteUnaryOps(static_model, nodes, subst_table, eqnumbers); } void -DynamicModel::substituteUnaryOps(StaticModel &static_model, diff_table_t &nodes, ExprNode::subst_table_t &subst_table, vector &eqnumbers, bool nopreprocessoroutput) +DynamicModel::substituteUnaryOps(StaticModel &static_model, diff_table_t &nodes, ExprNode::subst_table_t &subst_table, vector &eqnumbers) { // Find matching unary ops that may be outside of diffs (i.e., those with different lags) set used_local_vars; @@ -5860,12 +5856,12 @@ DynamicModel::substituteUnaryOps(StaticModel &static_model, diff_table_t &nodes, copy(neweqs.begin(), neweqs.end(), back_inserter(aux_equations)); - if (!nopreprocessoroutput && subst_table.size() > 0) + if (subst_table.size() > 0) cout << "Substitution of Unary Ops: added " << neweqs.size() << " auxiliary variables and equations." << endl; } void -DynamicModel::substituteDiff(StaticModel &static_model, diff_table_t &diff_table, ExprNode::subst_table_t &diff_subst_table, bool nopreprocessoroutput) +DynamicModel::substituteDiff(StaticModel &static_model, diff_table_t &diff_table, ExprNode::subst_table_t &diff_subst_table) { set used_local_vars; for (const auto & equation : equations) @@ -5922,12 +5918,12 @@ DynamicModel::substituteDiff(StaticModel &static_model, diff_table_t &diff_table copy(neweqs.begin(), neweqs.end(), back_inserter(aux_equations)); - if (!nopreprocessoroutput && diff_subst_table.size() > 0) + if (diff_subst_table.size() > 0) cout << "Substitution of Diff operator: added " << neweqs.size() << " auxiliary variables and equations." << endl; } void -DynamicModel::substituteExpectation(bool partial_information_model, bool nopreprocessoroutput) +DynamicModel::substituteExpectation(bool partial_information_model) { ExprNode::subst_table_t subst_table; vector neweqs; @@ -5951,7 +5947,7 @@ DynamicModel::substituteExpectation(bool partial_information_model, bool noprepr // Add the new set of equations at the *beginning* of aux_equations copy(neweqs.rbegin(), neweqs.rend(), front_inserter(aux_equations)); - if (!nopreprocessoroutput && subst_table.size() > 0) + if (subst_table.size() > 0) { if (partial_information_model) cout << "Substitution of Expectation operator: added " << subst_table.size() << " auxiliary variables and " << neweqs.size() << " auxiliary equations." << endl; @@ -6007,9 +6003,9 @@ DynamicModel::removeTrendVariableFromEquations() } void -DynamicModel::differentiateForwardVars(const vector &subset, bool nopreprocessoroutput) +DynamicModel::differentiateForwardVars(const vector &subset) { - substituteLeadLagInternal(AuxVarType::diffForward, true, subset, nopreprocessoroutput); + substituteLeadLagInternal(AuxVarType::diffForward, true, subset); } void diff --git a/src/DynamicModel.hh b/src/DynamicModel.hh index 02229a66..2bbdb5c7 100644 --- a/src/DynamicModel.hh +++ b/src/DynamicModel.hh @@ -180,7 +180,7 @@ private: \param[in] deterministic_model whether we are in a deterministic model (only for exogenous leads/lags) \param[in] subset variables to which to apply the transformation (only for diff of forward vars) */ - void substituteLeadLagInternal(AuxVarType type, bool deterministic_model, const vector &subset, bool nopreprocessoroutput); + void substituteLeadLagInternal(AuxVarType type, bool deterministic_model, const vector &subset); //! Indicate if the temporary terms are computed for the overall model (true) or not (false). Default value true bool global_temporary_terms{true}; @@ -287,7 +287,7 @@ public: \param no_tmp_terms if true, no temporary terms will be computed in the dynamic files */ void computingPass(bool jacobianExo, int derivsOrder, int paramsDerivsOrder, - const eval_context_t &eval_context, bool no_tmp_terms, bool block, bool use_dll, bool bytecode, bool nopreprocessoroutput, bool linear_decomposition); + const eval_context_t &eval_context, bool no_tmp_terms, bool block, bool use_dll, bool bytecode, bool linear_decomposition); //! Writes model initialization and lead/lag incidence matrix to output void writeOutput(ostream &output, const string &basename, bool block, bool linear_decomposition, bool byte_code, bool use_dll, int order, bool estimation_present, bool compute_xrefs, bool julia) const; @@ -377,7 +377,7 @@ public: void setLeadsLagsOrig(); //! Replaces model equations with derivatives of Lagrangian w.r.t. endogenous - void computeRamseyPolicyFOCs(const StaticModel &static_model, const bool nopreprocessoroutput); + void computeRamseyPolicyFOCs(const StaticModel &static_model); //! Replaces the model equations in dynamic_model with those in this model void replaceMyEquations(DynamicModel &dynamic_model) const; @@ -412,20 +412,20 @@ public: //! Transforms the model by removing all leads greater or equal than 2 on endos /*! Note that this can create new lags on endos and exos */ - void substituteEndoLeadGreaterThanTwo(bool deterministic_model, bool nopreprocessoroutput); + void substituteEndoLeadGreaterThanTwo(bool deterministic_model); //! Transforms the model by removing all lags greater or equal than 2 on endos - void substituteEndoLagGreaterThanTwo(bool deterministic_model, bool nopreprocessoroutput); + void substituteEndoLagGreaterThanTwo(bool deterministic_model); //! Transforms the model by removing all leads on exos /*! Note that this can create new lags on endos and exos */ - void substituteExoLead(bool deterministic_model, bool nopreprocessoroutput); + void substituteExoLead(bool deterministic_model); //! Transforms the model by removing all lags on exos - void substituteExoLag(bool deterministic_model, bool nopreprocessoroutput); + void substituteExoLag(bool deterministic_model); //! Transforms the model by removing all UnaryOpcode::expectation - void substituteExpectation(bool partial_information_model, bool nopreprocessoroutput); + void substituteExpectation(bool partial_information_model); //! Transforms the model by decreasing the lead/lag of predetermined variables in model equations by one void transformPredeterminedVariables(); @@ -437,16 +437,16 @@ public: void substituteAdl(); //! Creates aux vars for all unary operators - void substituteUnaryOps(StaticModel &static_model, diff_table_t &nodes, ExprNode::subst_table_t &subst_table, bool nopreprocessoroutput); + void substituteUnaryOps(StaticModel &static_model, diff_table_t &nodes, ExprNode::subst_table_t &subst_table); //! Creates aux vars for certain unary operators: originally implemented for support of VARs - void substituteUnaryOps(StaticModel &static_model, diff_table_t &nodes, ExprNode::subst_table_t &subst_table, set &eq_tags, bool nopreprocessoroutput); + void substituteUnaryOps(StaticModel &static_model, diff_table_t &nodes, ExprNode::subst_table_t &subst_table, set &eq_tags); //! Creates aux vars for certain unary operators: originally implemented for support of VARs - void substituteUnaryOps(StaticModel &static_model, diff_table_t &nodes, ExprNode::subst_table_t &subst_table, vector &eqnumbers, bool nopreprocessoroutput); + void substituteUnaryOps(StaticModel &static_model, diff_table_t &nodes, ExprNode::subst_table_t &subst_table, vector &eqnumbers); //! Substitutes diff operator - void substituteDiff(StaticModel &static_model, diff_table_t &diff_table, ExprNode::subst_table_t &diff_subst_table, bool nopreprocessoroutput); + void substituteDiff(StaticModel &static_model, diff_table_t &diff_table, ExprNode::subst_table_t &diff_subst_table); //! Substitute VarExpectation operators void substituteVarExpectation(const map &subst_table); @@ -464,7 +464,7 @@ public: //! Transforms the model by creating aux vars for the diff of forward vars /*! If subset is empty, does the transformation for all fwrd vars; otherwise restrict it to the vars in subset */ - void differentiateForwardVars(const vector &subset, bool nopreprocessoroutput); + void differentiateForwardVars(const vector &subset); //! Fills eval context with values of model local variables and auxiliary variables void fillEvalContext(eval_context_t &eval_context) const; diff --git a/src/DynareMain.cc b/src/DynareMain.cc index f74ad6ae..9a87e537 100644 --- a/src/DynareMain.cc +++ b/src/DynareMain.cc @@ -49,7 +49,7 @@ void main2(stringstream &in, const string &basename, bool debug, bool clear_all, bool minimal_workspace, bool compute_xrefs, FileOutputType output_mode, LanguageOutputType lang, int params_derivs_order, bool transform_unary_ops, JsonOutputPointType json, JsonFileOutputType json_output_mode, bool onlyjson, bool jsonderivsimple, - bool nopreprocessoroutput, const string &mexext, const boost::filesystem::path &matlabroot, + const string &mexext, const boost::filesystem::path &matlabroot, const boost::filesystem::path &dynareroot, bool onlymodel); void main1(const string &filename, const string &basename, istream &modfile, bool debug, bool save_macro, string &save_macro_file, @@ -159,7 +159,6 @@ main(int argc, char **argv) bool onlyjson = false; bool jsonderivsimple = false; LanguageOutputType language{LanguageOutputType::matlab}; - bool nopreprocessoroutput = false; string mexext; boost::filesystem::path matlabroot; boost::filesystem::path dynareroot{argv[0]}; @@ -340,7 +339,7 @@ main(int argc, char **argv) else if (s == "onlyjson") onlyjson = true; else if (s == "nopreprocessoroutput") - nopreprocessoroutput = true; + cout.rdbuf(nullptr); else if (s == "jsonderivsimple") jsonderivsimple = true; else if (s.substr(0, 4) == "json") @@ -394,8 +393,7 @@ main(int argc, char **argv) } } - if (!nopreprocessoroutput) - cout << "Starting preprocessing of the model file ..." << endl; + cout << "Starting preprocessing of the model file ..." << endl; // Construct basename (i.e. remove file extension if there is one) string basename = argv[1]; @@ -430,7 +428,7 @@ main(int argc, char **argv) no_tmp_terms, no_log, no_warn, warn_uninit, console, nograph, nointeractive, parallel, config_file, warnings, nostrict, stochastic, check_model_changes, minimal_workspace, compute_xrefs, output_mode, language, params_derivs_order, transform_unary_ops, - json, json_output_mode, onlyjson, jsonderivsimple, nopreprocessoroutput, + json, json_output_mode, onlyjson, jsonderivsimple, mexext, matlabroot, dynareroot, onlymodel); return EXIT_SUCCESS; diff --git a/src/DynareMain2.cc b/src/DynareMain2.cc index 611a4bd4..6c921577 100644 --- a/src/DynareMain2.cc +++ b/src/DynareMain2.cc @@ -34,7 +34,7 @@ main2(stringstream &in, const string &basename, bool debug, bool clear_all, bool bool minimal_workspace, bool compute_xrefs, FileOutputType output_mode, LanguageOutputType language, int params_derivs_order, bool transform_unary_ops, JsonOutputPointType json, JsonFileOutputType json_output_mode, bool onlyjson, bool jsonderivsimple, - bool nopreprocessoroutput, const string &mexext, const boost::filesystem::path &matlabroot, + const string &mexext, const boost::filesystem::path &matlabroot, const boost::filesystem::path &dynareroot, bool onlymodel) { ParsingDriver p(warnings, nostrict); @@ -44,34 +44,33 @@ main2(stringstream &in, const string &basename, bool debug, bool clear_all, bool // Do parsing and construct internal representation of mod file unique_ptr mod_file = p.parse(in, debug); if (json == JsonOutputPointType::parsing) - mod_file->writeJsonOutput(basename, json, json_output_mode, onlyjson, nopreprocessoroutput); + mod_file->writeJsonOutput(basename, json, json_output_mode, onlyjson); // Run checking pass mod_file->checkPass(nostrict, stochastic); if (json == JsonOutputPointType::checkpass) - mod_file->writeJsonOutput(basename, json, json_output_mode, onlyjson, nopreprocessoroutput); + mod_file->writeJsonOutput(basename, json, json_output_mode, onlyjson); // Perform transformations on the model (creation of auxiliary vars and equations) - mod_file->transformPass(nostrict, stochastic, compute_xrefs || json == JsonOutputPointType::transformpass, nopreprocessoroutput, transform_unary_ops); + mod_file->transformPass(nostrict, stochastic, compute_xrefs || json == JsonOutputPointType::transformpass, transform_unary_ops); if (json == JsonOutputPointType::transformpass) - mod_file->writeJsonOutput(basename, json, json_output_mode, onlyjson, nopreprocessoroutput); + mod_file->writeJsonOutput(basename, json, json_output_mode, onlyjson); // Evaluate parameters initialization, initval, endval and pounds - mod_file->evalAllExpressions(warn_uninit, nopreprocessoroutput); + mod_file->evalAllExpressions(warn_uninit); // Do computations - mod_file->computingPass(no_tmp_terms, output_mode, params_derivs_order, nopreprocessoroutput); + mod_file->computingPass(no_tmp_terms, output_mode, params_derivs_order); if (json == JsonOutputPointType::computingpass) - mod_file->writeJsonOutput(basename, json, json_output_mode, onlyjson, nopreprocessoroutput, jsonderivsimple); + mod_file->writeJsonOutput(basename, json, json_output_mode, onlyjson, jsonderivsimple); // Write outputs if (output_mode != FileOutputType::none) - mod_file->writeExternalFiles(basename, output_mode, language, nopreprocessoroutput); + mod_file->writeExternalFiles(basename, output_mode, language); else mod_file->writeOutputFiles(basename, clear_all, clear_global, no_log, no_warn, console, nograph, nointeractive, config_file, check_model_changes, minimal_workspace, compute_xrefs, - nopreprocessoroutput, mexext, matlabroot, dynareroot, onlymodel); + mexext, matlabroot, dynareroot, onlymodel); - if (!nopreprocessoroutput) - cout << "Preprocessing completed." << endl; + cout << "Preprocessing completed." << endl; } diff --git a/src/ModFile.cc b/src/ModFile.cc index 2247f557..348c92be 100644 --- a/src/ModFile.cc +++ b/src/ModFile.cc @@ -56,10 +56,9 @@ ModFile::ModFile(WarningConsolidation &warnings_arg) } void -ModFile::evalAllExpressions(bool warn_uninit, const bool nopreprocessoroutput) +ModFile::evalAllExpressions(bool warn_uninit) { - if (!nopreprocessoroutput) - cout << "Evaluating expressions..."; + cout << "Evaluating expressions..."; // Loop over all statements, and fill global eval context if relevant for (auto &st : statements) @@ -80,8 +79,7 @@ ModFile::evalAllExpressions(bool warn_uninit, const bool nopreprocessoroutput) // Evaluate model local variables dynamic_model.fillEvalContext(global_eval_context); - if (!nopreprocessoroutput) - cout << "done" << endl; + cout << "done" << endl; // Check if some symbols are not initialized, and give them a zero value then for (int id = 0; id <= symbol_table.maxID(); id++) @@ -362,7 +360,7 @@ ModFile::checkPass(bool nostrict, bool stochastic) } void -ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const bool nopreprocessoroutput, const bool transform_unary_ops) +ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const bool transform_unary_ops) { // Save the original model (must be done before any model transformations by preprocessor) // - except adl and diff which we always want expanded @@ -394,15 +392,15 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const diff_table_t unary_ops_nodes; ExprNode::subst_table_t unary_ops_subst_table; if (transform_unary_ops) - dynamic_model.substituteUnaryOps(diff_static_model, unary_ops_nodes, unary_ops_subst_table, nopreprocessoroutput); + dynamic_model.substituteUnaryOps(diff_static_model, unary_ops_nodes, unary_ops_subst_table); else // substitute only those unary ops that appear in auxiliary model equations - dynamic_model.substituteUnaryOps(diff_static_model, unary_ops_nodes, unary_ops_subst_table, eqtags, nopreprocessoroutput); + dynamic_model.substituteUnaryOps(diff_static_model, unary_ops_nodes, unary_ops_subst_table, eqtags); // Create auxiliary variable and equations for Diff operators that appear in VAR equations diff_table_t diff_table; ExprNode::subst_table_t diff_subst_table; - dynamic_model.substituteDiff(diff_static_model, diff_table, diff_subst_table, nopreprocessoroutput); + dynamic_model.substituteDiff(diff_static_model, diff_table, diff_subst_table); // Fill Trend Component Model Table dynamic_model.fillTrendComponentModelTable(); @@ -458,7 +456,7 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const dynamic_model.transformPredeterminedVariables(); // Create auxiliary vars for Expectation operator - dynamic_model.substituteExpectation(mod_file_struct.partial_information, nopreprocessoroutput); + dynamic_model.substituteExpectation(mod_file_struct.partial_information); if (nonstationary_variables) { @@ -493,7 +491,7 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const if (linear) orig_ramsey_dynamic_model = dynamic_model; ramsey_FOC_equations_dynamic_model = dynamic_model; - ramsey_FOC_equations_dynamic_model.computeRamseyPolicyFOCs(planner_objective, nopreprocessoroutput); + ramsey_FOC_equations_dynamic_model.computeRamseyPolicyFOCs(planner_objective); ramsey_FOC_equations_dynamic_model.replaceMyEquations(dynamic_model); mod_file_struct.ramsey_eq_nbr = dynamic_model.equation_number() - mod_file_struct.orig_eq_nbr; } @@ -570,22 +568,22 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const || stochastic ) { // In stochastic models, create auxiliary vars for leads and lags greater than 2, on both endos and exos - dynamic_model.substituteEndoLeadGreaterThanTwo(false, nopreprocessoroutput); - dynamic_model.substituteExoLead(false, nopreprocessoroutput); - dynamic_model.substituteEndoLagGreaterThanTwo(false, nopreprocessoroutput); - dynamic_model.substituteExoLag(false, nopreprocessoroutput); + dynamic_model.substituteEndoLeadGreaterThanTwo(false); + dynamic_model.substituteExoLead(false); + dynamic_model.substituteEndoLagGreaterThanTwo(false); + dynamic_model.substituteExoLag(false); } else { // In deterministic models, create auxiliary vars for leads and lags endogenous greater than 2, only on endos (useless on exos) - dynamic_model.substituteEndoLeadGreaterThanTwo(true, nopreprocessoroutput); - dynamic_model.substituteEndoLagGreaterThanTwo(true, nopreprocessoroutput); + dynamic_model.substituteEndoLeadGreaterThanTwo(true); + dynamic_model.substituteEndoLagGreaterThanTwo(true); } dynamic_model.updateVarAndTrendModel(); if (differentiate_forward_vars) - dynamic_model.differentiateForwardVars(differentiate_forward_vars_subset, nopreprocessoroutput); + dynamic_model.differentiateForwardVars(differentiate_forward_vars_subset); if (mod_file_struct.dsge_var_estimated || !mod_file_struct.dsge_var_calibrated.empty()) try @@ -650,14 +648,13 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const exit(EXIT_FAILURE); } - if (!nopreprocessoroutput) - if (!mod_file_struct.ramsey_model_present) - cout << "Found " << dynamic_model.equation_number() << " equation(s)." << endl; - else - { - cout << "Found " << mod_file_struct.orig_eq_nbr << " equation(s)." << endl; - cout << "Found " << dynamic_model.equation_number() << " FOC equation(s) for Ramsey Problem." << endl; - } + if (!mod_file_struct.ramsey_model_present) + cout << "Found " << dynamic_model.equation_number() << " equation(s)." << endl; + else + { + cout << "Found " << mod_file_struct.orig_eq_nbr << " equation(s)." << endl; + cout << "Found " << dynamic_model.equation_number() << " FOC equation(s) for Ramsey Problem." << endl; + } if (symbol_table.exists("dsge_prior_weight")) if (mod_file_struct.bayesian_irf_present) @@ -679,7 +676,7 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const } void -ModFile::computingPass(bool no_tmp_terms, FileOutputType output, int params_derivs_order, const bool nopreprocessoroutput) +ModFile::computingPass(bool no_tmp_terms, FileOutputType output, int params_derivs_order) { // Mod file may have no equation (for example in a standalone BVAR estimation) if (dynamic_model.equation_number() > 0) @@ -693,7 +690,7 @@ ModFile::computingPass(bool no_tmp_terms, FileOutputType output, int params_deri { non_linear_equations_dynamic_model = dynamic_model; non_linear_equations_dynamic_model.set_cutoff_to_zero(); - non_linear_equations_dynamic_model.computingPass(true, 1, 0, global_eval_context, no_tmp_terms, block, use_dll, byte_code, nopreprocessoroutput, linear_decomposition); + non_linear_equations_dynamic_model.computingPass(true, 1, 0, global_eval_context, no_tmp_terms, block, use_dll, byte_code, linear_decomposition); } if (!no_static) { @@ -710,7 +707,7 @@ ModFile::computingPass(bool no_tmp_terms, FileOutputType output, int params_deri derivsOrder = 2; paramsDerivsOrder = params_derivs_order; } - static_model.computingPass(derivsOrder, paramsDerivsOrder, global_eval_context, no_tmp_terms, block, byte_code, nopreprocessoroutput); + static_model.computingPass(derivsOrder, paramsDerivsOrder, global_eval_context, no_tmp_terms, block, byte_code); } // Set things to compute for dynamic model if (mod_file_struct.perfect_foresight_solver_present || mod_file_struct.check_present @@ -720,7 +717,7 @@ ModFile::computingPass(bool no_tmp_terms, FileOutputType output, int params_deri || mod_file_struct.calib_smoother_present) { if (mod_file_struct.perfect_foresight_solver_present) - dynamic_model.computingPass(true, 1, 0, global_eval_context, no_tmp_terms, block, use_dll, byte_code, nopreprocessoroutput, linear_decomposition); + dynamic_model.computingPass(true, 1, 0, global_eval_context, no_tmp_terms, block, use_dll, byte_code, linear_decomposition); else { if (mod_file_struct.stoch_simul_present @@ -741,13 +738,13 @@ ModFile::computingPass(bool no_tmp_terms, FileOutputType output, int params_deri int paramsDerivsOrder = 0; if (mod_file_struct.identification_present || mod_file_struct.estimation_analytic_derivation) paramsDerivsOrder = params_derivs_order; - dynamic_model.computingPass(true, derivsOrder, paramsDerivsOrder, global_eval_context, no_tmp_terms, block, use_dll, byte_code, nopreprocessoroutput, linear_decomposition); + dynamic_model.computingPass(true, derivsOrder, paramsDerivsOrder, global_eval_context, no_tmp_terms, block, use_dll, byte_code, linear_decomposition); if (linear && mod_file_struct.ramsey_model_present) - orig_ramsey_dynamic_model.computingPass(true, 2, paramsDerivsOrder, global_eval_context, no_tmp_terms, block, use_dll, byte_code, nopreprocessoroutput, linear_decomposition); + orig_ramsey_dynamic_model.computingPass(true, 2, paramsDerivsOrder, global_eval_context, no_tmp_terms, block, use_dll, byte_code, linear_decomposition); } } else // No computing task requested, compute derivatives up to 2nd order by default - dynamic_model.computingPass(true, 2, 0, global_eval_context, no_tmp_terms, block, use_dll, byte_code, nopreprocessoroutput, linear_decomposition); + dynamic_model.computingPass(true, 2, 0, global_eval_context, no_tmp_terms, block, use_dll, byte_code, linear_decomposition); map eqs; if (mod_file_struct.ramsey_model_present) @@ -773,14 +770,18 @@ ModFile::computingPass(bool no_tmp_terms, FileOutputType output, int params_deri for (auto & statement : statements) statement->computingPass(); - epilogue.computingPass(true, 2, 0, global_eval_context, true, false, false, false, true, false); + // Compute epilogue derivatives (but silence standard output) + streambuf *oldcout = cout.rdbuf(); + cout.rdbuf(nullptr); + epilogue.computingPass(true, 2, 0, global_eval_context, true, false, false, false, false); + cout.rdbuf(oldcout); } void ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_global, bool no_log, bool no_warn, bool console, bool nograph, bool nointeractive, const ConfigFile &config_file, bool check_model_changes, bool minimal_workspace, bool compute_xrefs, - const bool nopreprocessoroutput, const string &mexext, + const string &mexext, const boost::filesystem::path &matlabroot, const boost::filesystem::path &dynareroot, bool onlymodel) const { @@ -877,8 +878,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo if (param_used_with_lead_lag) mOutputFile << "M_.parameter_used_with_lead_lag = true;" << endl; - if (!nopreprocessoroutput) - cout << "Processing outputs ..." << endl; + cout << "Processing outputs ..." << endl; symbol_table.writeOutput(mOutputFile); @@ -1060,17 +1060,16 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo epilogue.writeEpilogueFile(basename); } - if (!nopreprocessoroutput) - cout << "done" << endl; + cout << "done" << endl; } void -ModFile::writeExternalFiles(const string &basename, FileOutputType output, LanguageOutputType language, const bool nopreprocessoroutput) const +ModFile::writeExternalFiles(const string &basename, FileOutputType output, LanguageOutputType language) const { switch (language) { case LanguageOutputType::julia: - writeExternalFilesJulia(basename, output, nopreprocessoroutput); + writeExternalFilesJulia(basename, output); break; default: cerr << "This case shouldn't happen. Contact the authors of Dynare" << endl; @@ -1079,7 +1078,7 @@ ModFile::writeExternalFiles(const string &basename, FileOutputType output, Langu } void -ModFile::writeExternalFilesJulia(const string &basename, FileOutputType output, const bool nopreprocessoroutput) const +ModFile::writeExternalFilesJulia(const string &basename, FileOutputType output) const { ofstream jlOutputFile; if (basename.size()) @@ -1156,8 +1155,7 @@ ModFile::writeExternalFilesJulia(const string &basename, FileOutputType output, jlOutputFile << "model_.h = zeros(Float64, 1, 1)" << endl << "model_.correlation_matrix_me = ones(Float64, 1, 1)" << endl; - if (!nopreprocessoroutput) - cout << "Processing outputs ..." << endl; + cout << "Processing outputs ..." << endl; symbol_table.writeJuliaOutput(jlOutputFile); if (dynamic_model.equation_number() > 0) @@ -1202,12 +1200,11 @@ ModFile::writeExternalFilesJulia(const string &basename, FileOutputType output, << "end" << endl << "end" << endl; jlOutputFile.close(); - if (!nopreprocessoroutput) - cout << "done" << endl; + cout << "done" << endl; } void -ModFile::writeJsonOutput(const string &basename, JsonOutputPointType json, JsonFileOutputType json_output_mode, bool onlyjson, const bool nopreprocessoroutput, bool jsonderivsimple) +ModFile::writeJsonOutput(const string &basename, JsonOutputPointType json, JsonFileOutputType json_output_mode, bool onlyjson, bool jsonderivsimple) { if (json == JsonOutputPointType::nojson) return; @@ -1231,25 +1228,24 @@ ModFile::writeJsonOutput(const string &basename, JsonOutputPointType json, JsonF cout << "}" << endl << "//-- END JSON --// " << endl; - if (!nopreprocessoroutput) - switch (json) - { - case JsonOutputPointType::parsing: - cout << "JSON written after Parsing step." << endl; - break; - case JsonOutputPointType::checkpass: - cout << "JSON written after Check step." << endl; - break; - case JsonOutputPointType::transformpass: - cout << "JSON written after Transform step." << endl; - break; - case JsonOutputPointType::computingpass: - cout << "JSON written after Computing step." << endl; - break; - case JsonOutputPointType::nojson: - cerr << "ModFile::writeJsonOutput: should not arrive here." << endl; - exit(EXIT_FAILURE); - } + switch (json) + { + case JsonOutputPointType::parsing: + cout << "JSON written after Parsing step." << endl; + break; + case JsonOutputPointType::checkpass: + cout << "JSON written after Check step." << endl; + break; + case JsonOutputPointType::transformpass: + cout << "JSON written after Transform step." << endl; + break; + case JsonOutputPointType::computingpass: + cout << "JSON written after Computing step." << endl; + break; + case JsonOutputPointType::nojson: + cerr << "ModFile::writeJsonOutput: should not arrive here." << endl; + exit(EXIT_FAILURE); + } if (onlyjson) exit(EXIT_SUCCESS); diff --git a/src/ModFile.hh b/src/ModFile.hh index 5f0f68c3..a7b73f50 100644 --- a/src/ModFile.hh +++ b/src/ModFile.hh @@ -137,17 +137,17 @@ public: void addStatementAtFront(unique_ptr st); //! Evaluate all the statements /*! \param warn_uninit Should a warning be displayed for uninitialized endogenous/exogenous/parameters ? */ - void evalAllExpressions(bool warn_uninit, const bool nopreprocessoroutput); + void evalAllExpressions(bool warn_uninit); //! Do some checking and fills mod_file_struct /*! \todo add check for number of equations and endogenous if ramsey_policy is present */ void checkPass(bool nostrict, bool stochastic); //! Perform some transformations on the model (creation of auxiliary vars and equations) /*! \param compute_xrefs if true, equation cross references will be computed */ - void transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const bool nopreprocessoroutput, const bool transform_unary_ops); + void transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const bool transform_unary_ops); //! Execute computations /*! \param no_tmp_terms if true, no temporary terms will be computed in the static and dynamic files */ /*! \param params_derivs_order compute this order of derivs wrt parameters */ - void computingPass(bool no_tmp_terms, FileOutputType output, int params_derivs_order, const bool nopreprocessoroutput); + void computingPass(bool no_tmp_terms, FileOutputType output, int params_derivs_order); //! Writes Matlab/Octave output files /*! \param basename The base name used for writing output files. Should be the name of the mod file without its extension @@ -163,17 +163,17 @@ public: void writeOutputFiles(const string &basename, bool clear_all, bool clear_global, bool no_log, bool no_warn, bool console, bool nograph, bool nointeractive, const ConfigFile &config_file, bool check_model_changes, bool minimal_workspace, bool compute_xrefs, - const bool nopreprocessoroutput, const string &mexext, const boost::filesystem::path &matlabroot, + const string &mexext, const boost::filesystem::path &matlabroot, const boost::filesystem::path &dynareroot, bool onlymodel) const; - void writeExternalFiles(const string &basename, FileOutputType output, LanguageOutputType language, const bool nopreprocessoroutput) const; - void writeExternalFilesJulia(const string &basename, FileOutputType output, const bool nopreprocessoroutput) const; + void writeExternalFiles(const string &basename, FileOutputType output, LanguageOutputType language) const; + void writeExternalFilesJulia(const string &basename, FileOutputType output) const; void computeChecksum(); //! Write JSON representation of ModFile object //! Initially created to enable Julia to work with .mod files //! Potentially outputs ModFile after the various parts of processing (parsing, checkPass, transformPass, computingPass) //! Allows user of other host language platforms (python, fortran, etc) to provide support for dynare .mod files - void writeJsonOutput(const string &basename, JsonOutputPointType json, JsonFileOutputType json_output_mode, bool onlyjson, const bool nopreprocessoroutput, bool jsonderivsimple = false); + void writeJsonOutput(const string &basename, JsonOutputPointType json, JsonFileOutputType json_output_mode, bool onlyjson, bool jsonderivsimple = false); }; #endif // ! MOD_FILE_HH diff --git a/src/StaticModel.cc b/src/StaticModel.cc index d364a5ff..eb1ebb98 100644 --- a/src/StaticModel.cc +++ b/src/StaticModel.cc @@ -1186,7 +1186,7 @@ StaticModel::collect_first_order_derivatives_endogenous() } void -StaticModel::computingPass(int derivsOrder, int paramsDerivsOrder, const eval_context_t &eval_context, bool no_tmp_terms, bool block, bool bytecode, bool nopreprocessoroutput) +StaticModel::computingPass(int derivsOrder, int paramsDerivsOrder, const eval_context_t &eval_context, bool no_tmp_terms, bool block, bool bytecode) { initializeVariablesAndEquations(); @@ -1216,15 +1216,13 @@ StaticModel::computingPass(int derivsOrder, int paramsDerivsOrder, const eval_co } // Launch computations - if (!nopreprocessoroutput) - cout << "Computing static model derivatives (order " << derivsOrder << ")." << endl; + cout << "Computing static model derivatives (order " << derivsOrder << ")." << endl; computeDerivatives(derivsOrder, vars); if (paramsDerivsOrder > 0) { - if (!nopreprocessoroutput) - cout << "Computing static model derivatives w.r.t. parameters (order " << paramsDerivsOrder << ")." << endl; + cout << "Computing static model derivatives w.r.t. parameters (order " << paramsDerivsOrder << ")." << endl; computeParamsDerivatives(paramsDerivsOrder); } @@ -1246,8 +1244,7 @@ StaticModel::computingPass(int derivsOrder, int paramsDerivsOrder, const eval_co equation_type_and_normalized_equation = equationTypeDetermination(first_order_endo_derivatives, variable_reordered, equation_reordered, mfs); - if (!nopreprocessoroutput) - cout << "Finding the optimal block decomposition of the model ..." << endl; + cout << "Finding the optimal block decomposition of the model ..." << endl; lag_lead_vector_t equation_lag_lead, variable_lag_lead; diff --git a/src/StaticModel.hh b/src/StaticModel.hh index 59bfb319..76bbb882 100644 --- a/src/StaticModel.hh +++ b/src/StaticModel.hh @@ -190,7 +190,7 @@ public: \param derivsOrder order of derivation with respect to endogenous \param paramsDerivsOrder order of derivatives w.r. to a pair (endogenous, parameter) to be computed */ - void computingPass(int derivsOrder, int paramsDerivsOrder, const eval_context_t &eval_context, bool no_tmp_terms, bool block, bool bytecode, bool nopreprocessoroutput); + void computingPass(int derivsOrder, int paramsDerivsOrder, const eval_context_t &eval_context, bool no_tmp_terms, bool block, bool bytecode); //! Adds informations for simulation in a binary file for a block decomposed model void Write_Inf_To_Bin_File_Block(const string &basename, const int &num,