Parsing
The Parsing
submodule provides macros used for automatic code generation, structs, indexes, etc. These map, e.g., deviations from steady state of aggregate variables to equations lines in the non-linear difference equation that describe the economy.
Collect variables: macros
BASEforHANK.Parsing.@writeXSS
— Macro@writeXSS()
Write all single steady state variables into vectors XSS / XSSaggr.
Requires
(module) globals state_names
, control_names
, aggr_names
BASEforHANK.Parsing.@make_fn
— Macro@make_fn(fn_name)
Create function fn_name
that returns an instance of struct
IndexStruct
(created by @make_struct
), mapping states and controls to indexes inferred from numerical parameters and compression indexes.
Requires
(module) global state_names
, control_names
BASEforHANK.Parsing.@make_fnaggr
— Macro@make_fnaggr(fn_name)
Create function fn_name
that returns an instance of struct
IndexStructAggr
(created by @make_struct_aggr
), mapping aggregate states and controls to values 1
to length(aggr_names)
(both steady state and deviation from it).
Requires
(module) global aggr_names
BASEforHANK.Parsing.@make_struct
— Macro@make_struct(struct_name)
Make struct
struct_name
with two fields for every variable name in s_names
(state variables) and c_names
(control variables), together with fields for distribution-states and marginal value function-controls.
Requires
(module) globals state_names
, control_names
BASEforHANK.Parsing.@make_struct_aggr
— Macro@make_struct_aggr(struct_name)
Make struct
struct_name
with two fields for every variable name in aggr_names
(for steady state value and for deviation from it).
Requires
(module) global aggr_names
BASEforHANK.Parsing.@generate_equations
— Macro@generate_equations()
Write out the expansions around steady state for all variables in aggr_names
, i.e. generate code that reads aggregate states/controls from steady state deviations.
Equations take the form of (with variable r
as example):
r = exp.(XSS[indexes.rSS] .+ X[indexes.r])
rPrime = exp.(XSS[indexes.rSS] .+ XPrime[indexes.r])
Requires
(module) global aggr_names