From 70192aec718e5f1e13f1513a7a23e48c31f30714 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Tue, 28 Mar 2023 18:15:32 +0200
Subject: [PATCH] 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_.
---
 src/ComputingTasks.cc | 5 -----
 src/ModFile.cc        | 5 ++++-
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/ComputingTasks.cc b/src/ComputingTasks.cc
index ba134fa8..9d7d5035 100644
--- a/src/ComputingTasks.cc
+++ b/src/ComputingTasks.cc
@@ -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);
 }
 
diff --git a/src/ModFile.cc b/src/ModFile.cc
index 63ef9a43..a5fbc490 100644
--- a/src/ModFile.cc
+++ b/src/ModFile.cc
@@ -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)
     {
-- 
GitLab