Always set options_.{ramsey,discretionary}_policy at the preprocessor level

And set them before any computation is done.

These fields should rather be in M_.
master
Sébastien Villemot 2023-03-28 18:15:32 +02:00
parent 2f353a3c62
commit 70192aec71
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
2 changed files with 4 additions and 6 deletions

View File

@ -515,17 +515,12 @@ void
RamseyModelStatement::writeOutput(ostream &output, [[maybe_unused]] const string &basename,
[[maybe_unused]] bool minimal_workspace) const
{
// options_.ramsey_policy indicates that a Ramsey model is present in the *.mod file
// this affects the computation of the steady state that uses a special algorithm
// It should probably rather be a M_ field, but we leave it in options_ for historical reason
// Ensure that order 3 implies k_order (#844)
if (auto opt1 = options_list.get_if<OptionsList::NumVal>("order"),
opt2 = options_list.get_if<OptionsList::NumVal>("k_order_solver");
(opt2 && *opt2 == "true") || (opt1 && stoi(*opt1) >= 3))
output << "options_.k_order_solver = true;" << endl;
output << "options_.ramsey_policy = true;" << endl;
options_list.writeOutput(output);
}

View File

@ -892,11 +892,14 @@ ModFile::writeMOutput(const string &basename, bool clear_all, bool clear_global,
<< "M_.heteroskedastic_shocks.Qvalue_orig = [];" << endl
<< "M_.heteroskedastic_shocks.Qscale_orig = [];" << endl;
// NB: options_.{ramsey,discretionary}_policy should rather be fields of M_
mOutputFile << boolalpha
<< "options_.linear = " << linear << ";" << endl
<< "options_.block = " << block << ";" << endl
<< "options_.bytecode = " << bytecode << ";" << endl
<< "options_.use_dll = " << use_dll << ";" << endl;
<< "options_.use_dll = " << use_dll << ";" << endl
<< "options_.ramsey_policy = " << (mod_file_struct.ramsey_model_present || mod_file_struct.ramsey_policy_present) << ";" << endl
<< "options_.discretionary_policy = " << mod_file_struct.discretionary_policy_present << ";" << endl;
if (parallel_local_files.size() > 0)
{