From 4f6344e64ab98f8bbf705c3b26f3ed414ad4e3b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org> Date: Wed, 5 Jun 2024 16:17:14 +0200 Subject: [PATCH] Allow model-local variables with leads or lags Closes: #1929 --- doc/manual/source/the-model-file.rst | 5 ++++- preprocessor | 2 +- tests/preprocessor_checks/example1_mlv.mod | 11 +++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/doc/manual/source/the-model-file.rst b/doc/manual/source/the-model-file.rst index e85e77d745..8c0b4b72bf 100644 --- a/doc/manual/source/the-model-file.rst +++ b/doc/manual/source/the-model-file.rst @@ -962,7 +962,10 @@ The model is declared inside a ``model`` block: equal sign, and the expression for which this new variable will stand. Later on, every time this variable appears in the model, Dynare will substitute it by the expression assigned to the - variable. Note that the scope of this variable is restricted to + variable (if the model-local variable appears with a lead or a lag + attached to it between parenthesis, the substitution will be done by + shifting the expression accordingly). + Note that the scope of this variable is restricted to the model block; it cannot be used outside. To assign a LaTeX name to the model local variable, use the declaration syntax outlined by :comm:`model_local_variable`. A model local variable declaration diff --git a/preprocessor b/preprocessor index 31080eed6c..84d792bced 160000 --- a/preprocessor +++ b/preprocessor @@ -1 +1 @@ -Subproject commit 31080eed6ce6c623863850d4e2da5f8317f2b5d0 +Subproject commit 84d792bced340c52d90cd962e51e22eec605cea0 diff --git a/tests/preprocessor_checks/example1_mlv.mod b/tests/preprocessor_checks/example1_mlv.mod index ea9dbf029c..be97a81c5b 100644 --- a/tests/preprocessor_checks/example1_mlv.mod +++ b/tests/preprocessor_checks/example1_mlv.mod @@ -1,5 +1,8 @@ -// Tests for model local variables -// (including in params derivs file, i.e. with identification, see Dynare/preprocessor#13) +/* Tests for model-local variables + (including in params derivs file, i.e. with identification, see Dynare/preprocessor#13) + Also tests the possibility of having a lead/lag on a model-local variable + (recursively in the definition of another such variable) (see #1929) +*/ var c, y, k, a, h, b; varexo e, u; @@ -22,8 +25,8 @@ phi = 0.1; model_local_variable foo $\text{foo}$; model; -#bar = exp(b)*c; -#foo = bar/(exp(b(+1))*c(+1)); +#bar = exp(b(+1))*c(+1); +#foo = bar(-1)/(exp(b(+1))*c(+1)); c*theta*h^(1+psi)=(1-alpha)*y; k = beta*(foo *(exp(b(+1))*alpha*y(+1)+(1-delta)*k)); -- GitLab