The “mfs” option of the “model” block no longer affects the static model

This is a restoration of the behaviour that was present in 5.x.
master
Sébastien Villemot 2023-10-16 10:24:31 -04:00
parent db3a6bc301
commit 43fc59a2bc
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
7 changed files with 32 additions and 10 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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