diff --git a/src/ModFile.cc b/src/ModFile.cc index a5fbc490a74c5c45a764cf6f2e30cf5ae4390673..8e4a9736d1bd571c2f1e4905c9454dde875ff957 100644 --- a/src/ModFile.cc +++ b/src/ModFile.cc @@ -473,9 +473,9 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, bool epilogue.toStatic(); - mod_file_struct.orig_eq_nbr = dynamic_model.equation_number(); if (mod_file_struct.ramsey_model_present) { + mod_file_struct.ramsey_orig_eq_nbr = dynamic_model.equation_number(); PlannerObjectiveStatement *pos = nullptr; for (auto &statement : statements) if (auto pos2 = dynamic_cast<PlannerObjectiveStatement *>(statement.get()); pos2) @@ -499,7 +499,6 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, bool ramsey_FOC_equations_dynamic_model = dynamic_model; mod_file_struct.ramsey_orig_endo_nbr = 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; } dynamic_model.createVariableMapping(); @@ -620,7 +619,7 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, bool cout << "Found " << dynamic_model.equation_number() << " equation(s)." << endl; else { - cout << "Found " << mod_file_struct.orig_eq_nbr << " equation(s)." << endl; + cout << "Found " << mod_file_struct.ramsey_orig_eq_nbr << " equation(s)." << endl; cout << "Found " << dynamic_model.equation_number() << " FOC equation(s) for Ramsey Problem." << endl; } @@ -932,9 +931,9 @@ ModFile::writeMOutput(const string &basename, bool clear_all, bool clear_global, << " error('DYNARE: Can''t find bytecode DLL. Please compile it or remove the ''bytecode'' option.')" << endl << "end" << endl; - mOutputFile << "M_.orig_eq_nbr = " << mod_file_struct.orig_eq_nbr << ";" << endl - << "M_.eq_nbr = " << dynamic_model.equation_number() << ";" << endl - << "M_.ramsey_eq_nbr = " << mod_file_struct.ramsey_eq_nbr << ";" << endl + mOutputFile << "M_.eq_nbr = " << dynamic_model.equation_number() << ";" << endl + << "M_.ramsey_orig_eq_nbr = " << mod_file_struct.ramsey_orig_eq_nbr << ";" << endl + << "M_.ramsey_orig_endo_nbr = " << mod_file_struct.ramsey_orig_endo_nbr << ";" << endl << "M_.set_auxiliary_variables = exist(['./+' M_.fname '/set_auxiliary_variables.m'], 'file') == 2;" << endl; epilogue.writeOutput(mOutputFile); diff --git a/src/Statement.hh b/src/Statement.hh index 083a1b9c050be6b996b9dae8061df838d4c624af..ce8e1eed592f3beeb37408babaaac4e8a78358a5 100644 --- a/src/Statement.hh +++ b/src/Statement.hh @@ -129,14 +129,19 @@ struct ModFileStructure bool corr_options_statement_present{false}; //! Whether a Markov Switching DSGE is present bool ms_dsge_present{false}; - //! Stores the original number of equations in the model_block - int orig_eq_nbr{0}; - //! Stores the number of equations added to the Ramsey model - int ramsey_eq_nbr{0}; + /* The number of equations in the model present just before adding the + Lagrange multipliers and computing the Ramsey FOC; it is by construction + equal to the number of Lagrange multipliers that will be added by the + process of computing the FOCs. May be greater than the number of equations + written by the user, because some auxiliary variables may have already + been added. */ + int ramsey_orig_eq_nbr {0}; /* The number of endogenous variables in the model present just before adding the Lagrange multipliers and computing the Ramsey FOC; it is by construction equal to the number of equations that will be added by the - process of computing the FOCs */ + process of computing the FOCs. May be greater than the number of + endogenous declared by the user, because some auxiliary variables may have + already been added. */ int ramsey_orig_endo_nbr {0}; //! Whether there was a steady_state_model block bool steady_state_model_present{false};