From 97189a6f97f4979371a9d41d588e7d40171cf4ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Tue, 6 Jun 2023 17:54:04 +0200
Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Homotopy=20for=20extended=20path?=
 =?UTF-8?q?=20(order=200)=20was=20utterly=20broken?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The convergence test was wrong.

(manually cherry picked from commit 6ed90b3dbff232e26122a8eeba2da7faf6a9c770)
---
 matlab/ep/extended_path_homotopy.m | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/matlab/ep/extended_path_homotopy.m b/matlab/ep/extended_path_homotopy.m
index 6af8c2ed86..dca98a178e 100644
--- a/matlab/ep/extended_path_homotopy.m
+++ b/matlab/ep/extended_path_homotopy.m
@@ -1,6 +1,6 @@
 function [info_convergence, endo_simul] = extended_path_homotopy(endo_simul, exo_simul, M, options, oo, pfm, ep, order, algo, method, debug)
 
-% Copyright (C) 2016-2017 Dynare Team
+% Copyright © 2016-2023 Dynare Team
 %
 % This file is part of Dynare.
 %
@@ -48,7 +48,7 @@ if ismember(method, [1, 2])
         end
         if isequal(order, 0)
             % Logical variable flag is false iff the solver fails.
-            flag = ~tmp.deterministic_simulation.status;
+            flag = tmp.deterministic_simulation.status;
         else
             % Fix convention issue on the value of flag.
             flag = ~flag;
@@ -115,7 +115,7 @@ if isequal(method, 3) || (isequal(method, 2) && noconvergence)
         end
         if isequal(order, 0)
             % Logical variable flag is false iff the solver fails.
-            flag = ~tmp.deterministic_simulation.status;
+            flag = tmp.deterministic_simulation.status;
         else
             % Fix convention issue on the value of flag.
             flag = ~flag;
@@ -136,4 +136,4 @@ if isequal(method, 3) || (isequal(method, 2) && noconvergence)
         end
     end
     info_convergence = ~noconvergence;
-end
\ No newline at end of file
+end
-- 
GitLab