From 7449d26e51df33a91abd9807443294c2daf40224 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Fri, 20 Oct 2023 14:57:22 -0400
Subject: [PATCH] Perfect foresight with homotopy + marginal linearization:
 improve info messages

---
 .../perfect-foresight-models/perfect_foresight_solver.m  | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/matlab/perfect-foresight-models/perfect_foresight_solver.m b/matlab/perfect-foresight-models/perfect_foresight_solver.m
index 031e235f36..1f2586524e 100644
--- a/matlab/perfect-foresight-models/perfect_foresight_solver.m
+++ b/matlab/perfect-foresight-models/perfect_foresight_solver.m
@@ -160,13 +160,20 @@ elseif options_.simul.homotopy_linearization_fallback && completed_share > 0
 elseif options_.simul.homotopy_marginal_linearization_fallback > 0 && completed_share > options_.simul.homotopy_marginal_linearization_fallback
     % Now compute extra simulation. First try using the first simulation as guess value.
     extra_share = completed_share - options_.simul.homotopy_marginal_linearization_fallback;
+    if ~options_.noprint
+        fprintf('Only %.1f%% of the shock could be simulated. Since marginal linearization was requested as a fallback, now running an extra simulation for %.1f%% of the shock\n\n', completed_share, extra_share)
+        fprintf('%s\n\n', repmat('*', 1, 80))
+    end
     extra_simul_time_counter = tic;
     [extra_success, extra_endo_simul, extra_exo_simul, extra_steady_state, extra_exo_steady_state] = create_scenario(extra_share, endoorig, exoorig, endobase, exobase, initperiods, lastperiods, recompute_final_steady_state, endo_simul, steady_state, exo_steady_state);
     if extra_success
         [extra_endo_simul, extra_success] = perfect_foresight_solver_core(extra_endo_simul, extra_exo_simul, extra_steady_state, extra_exo_steady_state, M_, options_);
     end
     if ~extra_success
-        fprintf('The extra simulation for %.1f%% of the shock did not run when using the first simulation as a guess value. Now trying a full homotopy loop to get that extra simulation working\n\n', extra_share)
+        if ~options_.noprint
+            fprintf('The extra simulation for %.1f%% of the shock did not run when using the first simulation as a guess value. Now trying a full homotopy loop to get that extra simulation working\n\n', extra_share)
+            fprintf('%s\n\n', repmat('*', 1, 80))
+        end
         [extra_completed_share, extra_endo_simul] = homotopy_loop(extra_share, endoorig, exoorig, endobase, exobase, initperiods, simperiods, lastperiods, recompute_final_steady_state, oo_.endo_simul, oo_.steady_state, oo_.exo_steady_state);
         extra_success = (extra_completed_share == extra_share);
     end
-- 
GitLab