From 1cfce804a6627a7b07bbde35c5d7866b4af44726 Mon Sep 17 00:00:00 2001
From: Johannes Pfeifer <jpfeifer@gmx.de>
Date: Sun, 10 Dec 2023 09:42:51 +0100
Subject: [PATCH] Perfect foresight: remove globals

---
 src/ComputingTasks.cc | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/ComputingTasks.cc b/src/ComputingTasks.cc
index 2ff25dc0..fa65f44c 100644
--- a/src/ComputingTasks.cc
+++ b/src/ComputingTasks.cc
@@ -153,7 +153,8 @@ SimulStatement::writeOutput(ostream& output, [[maybe_unused]] const string& base
       options_list_new.erase("datafile");
     }
   options_list_new.writeOutput(output);
-  output << "perfect_foresight_setup;" << endl << "perfect_foresight_solver;" << endl;
+  output << "oo_ = perfect_foresight_setup(M_, options_, oo_);" << endl
+         << "[oo_, Simulated_time_series] = perfect_foresight_solver(M_, options_, oo_);" << endl;
 }
 
 void
@@ -188,7 +189,7 @@ PerfectForesightSetupStatement::writeOutput(ostream& output,
       options_list_new.erase("datafile");
     }
   options_list_new.writeOutput(output);
-  output << "perfect_foresight_setup;" << endl;
+  output << "oo_ = perfect_foresight_setup(M_, options_, oo_);" << endl;
 }
 
 void
@@ -221,7 +222,7 @@ PerfectForesightSolverStatement::writeOutput(ostream& output,
                                              [[maybe_unused]] bool minimal_workspace) const
 {
   options_list.writeOutput(output);
-  output << "perfect_foresight_solver;" << endl;
+  output << "[oo_, Simulated_time_series] = perfect_foresight_solver(M_, options_, oo_);" << endl;
 }
 
 void
@@ -248,7 +249,7 @@ PerfectForesightWithExpectationErrorsSetupStatement::writeOutput(
     [[maybe_unused]] bool minimal_workspace) const
 {
   options_list.writeOutput(output);
-  output << "perfect_foresight_with_expectation_errors_setup;" << endl;
+  output << "oo_ = perfect_foresight_with_expectation_errors_setup(M_, options_, oo_);" << endl;
 }
 
 void
@@ -282,7 +283,7 @@ PerfectForesightWithExpectationErrorsSolverStatement::writeOutput(
     [[maybe_unused]] bool minimal_workspace) const
 {
   options_list.writeOutput(output);
-  output << "perfect_foresight_with_expectation_errors_solver;" << endl;
+  output << "oo_ = perfect_foresight_with_expectation_errors_solver(M_, options_, oo_);" << endl;
 }
 
 void
-- 
GitLab