Provide mapping between model local variable names and indices in the T vector
Per a request from a DynareOBC user, today I started working on making DynareOBC compatible with Dynare 4.6.
This is proving harder than expected due to the changes to preprocessor output.
Previously, DynareOBC relied on the *_static.m and *_dynamic.m files containing lines giving the value of model local variables (MLVs). This is used in multiple places, e.g. for obtaining the steady state of the augmented model, or for generating code for MLV simulation.
Of course, it is not your duty to support DynareOBC, but having this information in the static and dynamic files was generally useful. For example, in code prepared for the Dynare summer school I used to teach, I used this feature to facilitate writing code for a "perturbation plus" type simulation algorithm (i.e. perturbation used for next period values conditional on today's state and future shock, but given this approximation, the full nonlinear equations + cubature were used to derive today's value).
To make things easy again, it would be sufficient if the generated _tt.m added comments at the end of each line defining a temporary variable (i.e. T()) definition with the name of the MLV to which the given element T(*) corresponds. E.g.:
#dynareOBCMaxFunc1=max(dynareOBCMaxArgA1,dynareOBCMaxArgB1);
would become:
T(14) = max(T(12),T(13)); % dynareOBCMaxFunc1
Alternatively, the optionally generated JSON could contain this information.
However, I guess that for either of these approaches to be viable as a strategy for DynareOBC to support Dynare 4.6, this would need to be added to Dynare fairly quickly (e.g. for 4.6.2), which may not be viable.
If this is not possible, (and in any case), it would be good to have some documentation of what users can safely assume about the elements of the T vector. A few relevant questions follow:
- Are all MLVs defined in the model block and used somewhere in the model guaranteed to be in the T vector?
- If MLV A is defined before MLV B in the model block, then will A definitely be before B in the T vector?
- Are the MLVs guaranteed to be the first elements of the T vector, or could MLVs and generated temporaries be interspersed?