From 43fc59a2bcee34f9836c24ec7afea2d67be88d04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org> Date: Mon, 16 Oct 2023 10:24:31 -0400 Subject: [PATCH] =?UTF-8?q?The=20=E2=80=9Cmfs=E2=80=9D=20option=20of=20the?= =?UTF-8?q?=20=E2=80=9Cmodel=E2=80=9D=20block=20no=20longer=20affects=20th?= =?UTF-8?q?e=20static=20model?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a restoration of the behaviour that was present in 5.x. --- src/DynamicModel.cc | 4 +++- src/DynamicModel.hh | 15 +++++++++++++++ src/ModelTree.cc | 8 +++----- src/ModelTree.hh | 6 ++++-- src/ParsingDriver.cc | 2 +- src/StaticModel.cc | 1 - src/StaticModel.hh | 6 ++++++ 7 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/DynamicModel.cc b/src/DynamicModel.cc index e1401abf..7721cdff 100644 --- a/src/DynamicModel.cc +++ b/src/DynamicModel.cc @@ -86,7 +86,8 @@ DynamicModel::DynamicModel(const DynamicModel &m) : nonzero_hessian_eqs{m.nonzero_hessian_eqs}, variableMapping{m.variableMapping}, blocks_jacob_cols_endo{m.blocks_jacob_cols_endo}, - var_expectation_functions_to_write{m.var_expectation_functions_to_write} + var_expectation_functions_to_write{m.var_expectation_functions_to_write}, + mfs{m.mfs} { copyHelper(m); } @@ -133,6 +134,7 @@ DynamicModel::operator=(const DynamicModel &m) blocks_jacob_cols_endo = m.blocks_jacob_cols_endo; var_expectation_functions_to_write = m.var_expectation_functions_to_write; + mfs = m.mfs; copyHelper(m); diff --git a/src/DynamicModel.hh b/src/DynamicModel.hh index 7e53abb5..0d2187b1 100644 --- a/src/DynamicModel.hh +++ b/src/DynamicModel.hh @@ -109,6 +109,9 @@ private: //! Used for var_expectation and var_model map<string, set<int>> var_expectation_functions_to_write; + // Value of the “mfs†option of “model†block (or â€model_options†command) + int mfs{1}; + // Writes dynamic model file (MATLAB/Octave version, legacy representation) void writeDynamicMFile(const string &basename) const; //! Writes the code of the block-decomposed model in virtual machine bytecode @@ -655,6 +658,18 @@ public: // Returns the set of equations (as numbers) which have a pac_expectation operator set<int> findPacExpectationEquationNumbers() const; + + int + getMFS() const override + { + return mfs; + } + + void + setMFS(int mfs_arg) + { + mfs = mfs_arg; + } }; template<bool julia> diff --git a/src/ModelTree.cc b/src/ModelTree.cc index dbc65069..b7a510fd 100644 --- a/src/ModelTree.cc +++ b/src/ModelTree.cc @@ -172,8 +172,7 @@ ModelTree::ModelTree(const ModelTree &m) : eq2block{m.eq2block}, blocks_jacobian_sparse_colptr{m.blocks_jacobian_sparse_colptr}, endo2eq{m.endo2eq}, - cutoff{m.cutoff}, - mfs{m.mfs} + cutoff{m.cutoff} { copyHelper(m); } @@ -221,7 +220,6 @@ ModelTree::operator=(const ModelTree &m) blocks_jacobian_sparse_colptr = m.blocks_jacobian_sparse_colptr; endo2eq = m.endo2eq; cutoff = m.cutoff; - mfs = m.mfs; user_set_add_flags = m.user_set_add_flags; user_set_subst_flags = m.user_set_subst_flags; @@ -539,7 +537,7 @@ ModelTree::equationTypeDetermination(const map<tuple<int, int, int>, expr_t> &fi try { normalized_eq = equations[eq]->normalizeEquation(symbol_table.getID(SymbolType::endogenous, var), 0); - if ((mfs == 2 && variable_not_in_derivative) || mfs == 3) + if ((getMFS() == 2 && variable_not_in_derivative) || getMFS() == 3) Equation_Simulation_Type = EquationType::evaluateRenormalized; } catch (ExprNode::NormalizationFailed &e) @@ -706,7 +704,7 @@ ModelTree::computeBlockDecomposition(int prologue, int epilogue) || variable_lag_lead[endo_idx_block2orig[i+prologue]].second > 0 || equation_lag_lead[eq_idx_block2orig[i+prologue]].first > 0 || equation_lag_lead[eq_idx_block2orig[i+prologue]].second > 0)) - || mfs == 0) + || getMFS() == 0) add_edge(vertex(i, G), vertex(i, G), G); const vector<int> old_eq_idx_block2orig(eq_idx_block2orig), old_endo_idx_block2orig(endo_idx_block2orig); diff --git a/src/ModelTree.hh b/src/ModelTree.hh index c4639860..aa0f6fd8 100644 --- a/src/ModelTree.hh +++ b/src/ModelTree.hh @@ -619,8 +619,6 @@ protected: public: //! Absolute value under which a number is considered to be zero double cutoff{1e-15}; - // Setting for minimum feedback set computation (see the reference manual) - int mfs{1}; //! Declare a node as an equation of the model; also give its line number void addEquation(expr_t eq, optional<int> lineno); //! Declare a node as an equation of the model, also giving its tags @@ -703,6 +701,10 @@ public: return "UNKNOWN "; } } + + /* Returns the minimum feedback set value (see the “mfs†option of the + “model†block in the reference manual for the possible values) */ + virtual int getMFS() const = 0; }; template<ExprNodeOutputType output_type> diff --git a/src/ParsingDriver.cc b/src/ParsingDriver.cc index 8868f3cf..161cc25e 100644 --- a/src/ParsingDriver.cc +++ b/src/ParsingDriver.cc @@ -697,7 +697,7 @@ void ParsingDriver::mfs(const string &value) { int val = stoi(value); - mod_file->dynamic_model.mfs = val; + mod_file->dynamic_model.setMFS(val); } void diff --git a/src/StaticModel.cc b/src/StaticModel.cc index 35076bb0..bfaf0bda 100644 --- a/src/StaticModel.cc +++ b/src/StaticModel.cc @@ -90,7 +90,6 @@ StaticModel::StaticModel(const DynamicModel &m) : addAuxEquation(aux_eq->toStatic(*this)); cutoff = m.cutoff; - mfs = m.mfs; user_set_add_flags = m.user_set_add_flags; user_set_subst_flags = m.user_set_subst_flags; diff --git a/src/StaticModel.hh b/src/StaticModel.hh index 5e98f28f..f940c50b 100644 --- a/src/StaticModel.hh +++ b/src/StaticModel.hh @@ -190,6 +190,12 @@ public: // Writes ramsey_multipliers_derivatives (C version) void writeRamseyMultipliersDerivativesCFile(const string &basename, const string &mexext, const filesystem::path &matlabroot, int ramsey_orig_endo_nbr) const; + + int + getMFS() const override + { + return 0; + } }; template<bool julia> -- GitLab