Skip to content
Snippets Groups Projects
Verified Commit cecc9aad authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

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.
parent 70192aec
Branches
No related tags found
No related merge requests found
...@@ -473,9 +473,9 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, bool ...@@ -473,9 +473,9 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, bool
epilogue.toStatic(); epilogue.toStatic();
mod_file_struct.orig_eq_nbr = dynamic_model.equation_number();
if (mod_file_struct.ramsey_model_present) if (mod_file_struct.ramsey_model_present)
{ {
mod_file_struct.ramsey_orig_eq_nbr = dynamic_model.equation_number();
PlannerObjectiveStatement *pos = nullptr; PlannerObjectiveStatement *pos = nullptr;
for (auto &statement : statements) for (auto &statement : statements)
if (auto pos2 = dynamic_cast<PlannerObjectiveStatement *>(statement.get()); pos2) if (auto pos2 = dynamic_cast<PlannerObjectiveStatement *>(statement.get()); pos2)
...@@ -499,7 +499,6 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, bool ...@@ -499,7 +499,6 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, bool
ramsey_FOC_equations_dynamic_model = dynamic_model; ramsey_FOC_equations_dynamic_model = dynamic_model;
mod_file_struct.ramsey_orig_endo_nbr = ramsey_FOC_equations_dynamic_model.computeRamseyPolicyFOCs(planner_objective); mod_file_struct.ramsey_orig_endo_nbr = ramsey_FOC_equations_dynamic_model.computeRamseyPolicyFOCs(planner_objective);
ramsey_FOC_equations_dynamic_model.replaceMyEquations(dynamic_model); 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(); dynamic_model.createVariableMapping();
...@@ -620,7 +619,7 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, bool ...@@ -620,7 +619,7 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, bool
cout << "Found " << dynamic_model.equation_number() << " equation(s)." << endl; cout << "Found " << dynamic_model.equation_number() << " equation(s)." << endl;
else 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; 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, ...@@ -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 << " error('DYNARE: Can''t find bytecode DLL. Please compile it or remove the ''bytecode'' option.')" << endl
<< "end" << endl; << "end" << endl;
mOutputFile << "M_.orig_eq_nbr = " << mod_file_struct.orig_eq_nbr << ";" << endl mOutputFile << "M_.eq_nbr = " << dynamic_model.equation_number() << ";" << endl
<< "M_.eq_nbr = " << dynamic_model.equation_number() << ";" << endl << "M_.ramsey_orig_eq_nbr = " << mod_file_struct.ramsey_orig_eq_nbr << ";" << endl
<< "M_.ramsey_eq_nbr = " << mod_file_struct.ramsey_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; << "M_.set_auxiliary_variables = exist(['./+' M_.fname '/set_auxiliary_variables.m'], 'file') == 2;" << endl;
epilogue.writeOutput(mOutputFile); epilogue.writeOutput(mOutputFile);
......
...@@ -129,14 +129,19 @@ struct ModFileStructure ...@@ -129,14 +129,19 @@ struct ModFileStructure
bool corr_options_statement_present{false}; bool corr_options_statement_present{false};
//! Whether a Markov Switching DSGE is present //! Whether a Markov Switching DSGE is present
bool ms_dsge_present{false}; bool ms_dsge_present{false};
//! Stores the original number of equations in the model_block /* The number of equations in the model present just before adding the
int orig_eq_nbr{0}; Lagrange multipliers and computing the Ramsey FOC; it is by construction
//! Stores the number of equations added to the Ramsey model equal to the number of Lagrange multipliers that will be added by the
int ramsey_eq_nbr{0}; 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 number of endogenous variables in the model present just before adding
the Lagrange multipliers and computing the Ramsey FOC; it is by the Lagrange multipliers and computing the Ramsey FOC; it is by
construction equal to the number of equations that will be added by the 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}; int ramsey_orig_endo_nbr {0};
//! Whether there was a steady_state_model block //! Whether there was a steady_state_model block
bool steady_state_model_present{false}; bool steady_state_model_present{false};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment