New fields: M_.ramsey_orig_{eq,endo}_nbr

– M_.ramsey_orig_endo_nbr is 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
– M_.ramsey_orig_eq_nbr is 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

Note that both may be greater than the number of endogenous/equations written
by the user, because some auxiliary variables may have already been added.

Also note that the number of policy instruments in M_.ramsey_orig_endo_nbr −
M_.ramsey_orig_eq_nbr

As a consequence, drop M_.ramsey_eq_nbr (which was actually equal to
M_.ramsey_orig_endo_nbr) and M_.orig_eq_nbr (which was actually equal to
M_.ramsey_orig_eq_nbr, but would also be set in the non-Ramsey case). The new
names are clearer.
master
Sébastien Villemot 2023-03-28 18:45:16 +02:00
parent 70192aec71
commit cecc9aad69
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
2 changed files with 15 additions and 11 deletions

View File

@ -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);

View File

@ -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};