From 36a40093b84f99fb57ac38520dfa61ee3f23acb6 Mon Sep 17 00:00:00 2001
From: Johannes Pfeifer <jpfeifer@gmx.de>
Date: Tue, 17 May 2022 12:22:54 +0200
Subject: [PATCH] occbin: add warning on spurious regime transitions

(cherry picked from commit 0685e03ecdc0432518249298abda303e41660a4b)
---
 doc/manual/source/the-model-file.rst | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/doc/manual/source/the-model-file.rst b/doc/manual/source/the-model-file.rst
index c550149bb7..86a8a72e37 100644
--- a/doc/manual/source/the-model-file.rst
+++ b/doc/manual/source/the-model-file.rst
@@ -4757,6 +4757,18 @@ All of these elements are discussed in the following.
     the levels, not deviations from the steady state. To access the steady state
     level of a variable, the ``STEADY_STATE()``-operator can be used.
 
+    Finally, it's worth keeping in mind that for each simulation period, Occbin will check 
+    the respective conditions for whether the current regime should be left. Small numerical 
+    differences from the cutoff point for a regime can sometimes lead to oscillations between
+    regimes and cause a spurious periodic solution. Such cases may be prevented by introducing 
+    a small buffer between the two regimes, e.g.
+
+    ::
+
+        occbin_constraints;
+        name 'ELB'; bind inom <= iss-1e8; relax inom > iss+1e-8;
+        end;
+
     The ``error_bind`` and ``error_relax``-options are optional and allow specifying
     numerical criteria for the size of the respective constraint violations employed
     in numerical routines. By default, Dynare will simply use the absolute value of
@@ -4894,7 +4906,9 @@ All of these elements are discussed in the following.
     .. option:: simul_periodic_solution
 
        Accept a periodic solution where the solution alternates between two sets of results
-       across iterations, i.e. is not found to be unique. Default: not enabled.
+       across iterations, i.e. is not found to be unique. This is sometimes caused by spurious numerical errors
+       that lead to oscillations between regiems and may be prevented by allowing for a small buffer in regime 
+       transitions. Default: not enabled.
 
     .. option:: simul_debug
 
-- 
GitLab