Add timekeeping to a g3 model
g3a_time(
start_year,
end_year,
step_lengths = c(12),
final_year_steps = quote( length(step_lengths) ),
project_years = g3_parameterized("project_years", value = 0, optimise = FALSE),
retro_years = g3_parameterized("retro_years", value = 0, optimise = FALSE),
run_at = g3_action_order$initial,
run_stop_at = g3_action_order$time)An action (i.e. list of formula objects) that will...
Define cur_* variables listed above
If we've reached the end of the model, return nll
Year model run will start.
After this year, model run will stop.
Either an MFDB time grouping, e.g. mfdb::mfdb_timestep_quarterly, or a
vector of step lengths which should should sum to 12,
for example, c(3,3,3,3) for quarterly steps within a year.
Number of steps of final year to include. Either as an integer or quoted code, in which case it will be calcuated when the model runs. For example:
0Model stops before the start of end_year (it is exclusive)
length(step_lengths)Model stops at the end of end_year (it is inclusive)
2Model stops at the second step of end_year, mid-year if step_lengths is quarterly
Number of years to continue running after the "end" of the model. Must be >= 0
Defaults to an unoptimized project_years parameter, set to 0 (i.e. no projection).
Generally, you would change this parameter in the parameter template, rather than changing here.
Adjust end_year to finish model early. Must be >= 0
Can be used in conjunction with project_years to project instead.
The true end year of the model will be end_year - retro_years + project_years.
Defaults to an unoptimized retro_years parameter, set to 0.
Generally, you would change this parameter in the parameter template, rather than changing here.
Integer order that actions will be run within model, see g3_action_order.
run_at does year variable accounting,
run_stop_at is when the model will finish if past the final step in the model.
The actions will define the following variables in your model:
Current iteration of model, starts at 0 and increments until finished
Current step within individual year
Proportion of year this step contains, e.g. quarterly = 3/12
Current year
TRUE iff this is the final step of the year
TRUE iff we are currently projecting past end_year
Total # of iterations (including projection) before model stops
Total # of years (including projection) before model stops
# Run model 2000..2004, in quarterly steps
time_action <- g3a_time(
start_year = 2000,
end_year = 2004,
c(3, 3, 3, 3))
Run the code above in your browser using DataLab