From 656c130036706849e7d08d9411b352b45a19eccb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Wed, 22 May 2024 12:24:39 +0200
Subject: [PATCH] More flexible syntax for complementarity conditions

---
 doc/manual/source/the-model-file.rst | 12 +++++++-----
 preprocessor                         |  2 +-
 tests/lmmcp/rbcii.mod                |  8 +++++++-
 3 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/doc/manual/source/the-model-file.rst b/doc/manual/source/the-model-file.rst
index 04921d89ac..a1437afa68 100644
--- a/doc/manual/source/the-model-file.rst
+++ b/doc/manual/source/the-model-file.rst
@@ -3929,11 +3929,13 @@ speed-up on large models.
 
        would be wrong.
 
-       Note that in the current implementation, the content of the
-       complementarity condition is not parsed by the preprocessor. The
-       inequalities must therefore be as simple as possible: an
-       endogenous variable, followed by a relational operator,
-       followed by a number (not a variable, parameter or expression).
+       Note that both the lower and the upper bounds can be specified at the
+       same time in a given complementarity condition. Moreover, arbitrary
+       functions of parameters can appear in the bounds. As an example, the
+       following complementarity condition is syntactically correct (assuming
+       that ``alpha`` is a parameter):
+
+            ``… ⟂ -1.94478 < r < 1+2*alpha;``
 
     .. option:: endogenous_terminal_period
 
diff --git a/preprocessor b/preprocessor
index dc1ec15fc6..fab3b682c3 160000
--- a/preprocessor
+++ b/preprocessor
@@ -1 +1 @@
-Subproject commit dc1ec15fc6fec59cc4c70fdb719bf731d7a57c9c
+Subproject commit fab3b682c386b9ab7ff26fbb432338e5d1bcf615
diff --git a/tests/lmmcp/rbcii.mod b/tests/lmmcp/rbcii.mod
index 03590cabd3..a61f1d8256 100644
--- a/tests/lmmcp/rbcii.mod
+++ b/tests/lmmcp/rbcii.mod
@@ -1,3 +1,9 @@
+/* Tests the MCP solver on a RBC model with irreversible investment.
+
+   An additional (dummy) upper bound on investment has been added, to test the
+   extended syntax with both lower and upper bounds, and parameters in the
+   bound. */
+
 var k, y, L, c, i, A, a, mu;
 varexo epsilon;
 parameters beta, theta, tau, alpha, psi, delta, rho, Astar, sigma;
@@ -21,7 +27,7 @@ model;
  k = y-c+(1-delta)*k(-1);
  i = k-(1-delta)*k(-1);
 
- mu = 0 ⟂ i > 0;
+ mu = 0 ⟂ 1+2*alpha > i > 0;
 end;
 
 steady_state_model;
-- 
GitLab