model_replace, model_remove: allow selecting an equation with several (conjunct) tags

NB: does not (yet) works with Occbin regime-specific equations.

Ref. #1890
remove-priordens
Sébastien Villemot 2023-11-15 12:08:21 +01:00
parent 0e5f9defbc
commit 4b4cfba2dc
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
3 changed files with 18 additions and 11 deletions

View File

@ -1189,7 +1189,10 @@ The model is declared inside a ``model`` block:
The equations must be specified by a list of tag values, separated by
commas. Each element of the list is either a simple quoted string, in which
case it designates an equation by its ``name`` tag; or a tag name (without
quotes), followed by an equal sign, then by the tag value (within quotes).
quotes), followed by an equal sign, then by the tag value (within quotes);
or a list of tag-equals-value pairs separated by commas and enclosed
within brackets, in which case this element removes the equation(s) that
has all these tags with the corresponding values.
Each removed equation must either have an ``endogenous`` tag, or have a
left hand side containing a single endogenous variable. The corresponding
@ -1201,7 +1204,7 @@ The model is declared inside a ``model`` block:
::
var c k dummy1 dummy2;
var c k dummy1 dummy2 dummy3;
model;
c + k - aa*x*k(-1)^alph - (1-delt)*k(-1) + dummy1;
@ -1210,13 +1213,15 @@ The model is declared inside a ``model`` block:
c*k = dummy1;
[ foo = 'eq:dummy2' ]
log(dummy2) = k + 2;
[ name = 'eq:dummy3', bar = 'baz' ]
dummy3 = c + 3;
end;
model_remove('eq:dummy1', foo = 'eq:dummy2');
model_remove('eq:dummy1', foo = 'eq:dummy2', [ name = 'eq:dummy3', bar = 'baz' ]);
In the above example, the last two equations will be removed,
``dummy1`` will be turned into an exogenous, and ``dummy2`` will be
removed.
In the above example, the last three equations will be removed,
``dummy1`` will be turned into an exogenous, and ``dummy2`` and
``dummy3`` will be removed.
.. block:: model_replace (TAGS...);

@ -1 +1 @@
Subproject commit ac35ef610143695ec5e1e9b74a8fdff4803b6ac0
Subproject commit 46aa6610ab13f449ba4423e02e5df3a2cb6f7e01

View File

@ -15,7 +15,8 @@ bet=0.05;
aa=0.5;
model;
c + k - aa*x*k(-1)^alph - (1-delt)*k(-1);
[ name = 'ressource constraint' ]
c + k = aa*x*k(-1)^alph;
end;
model;
@ -23,7 +24,7 @@ model;
dummy1 = c + 1;
[ foo = 'eq:dummy2' ] // Since dummy2 is alone on the LHS, it is considered as the variable set by this equation
log(dummy2) = k + 2;
[ name = 'eq:dummy3' ]
[ name = 'eq:dummy3', bar = 'baz' ]
c(+1) = c;
end;
@ -31,8 +32,9 @@ model_options(block);
model_remove('eq:dummy1', foo = 'eq:dummy2');
model_replace('eq:dummy3');
c^(-gam) - (1+bet)^(-1)*(aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam);
model_replace('ressource constraint', [ name = 'eq:dummy3', bar = 'baz' ]);
c + k - aa*x*k(-1)^alph - (1-delt)*k(-1);
c^(-gam) - (1+bet)^(-1)*(aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam);
end;
var_remove dummy3;