Skip to contents

Specify a model in the TMB engine.

Usage

mp_tmb_model_spec(
  before = list(),
  during = list(),
  after = list(),
  default = list(),
  integers = list(),
  must_save = character(),
  must_not_save = character(),
  sim_exprs = character(),
  state_update = c("euler", "rk4", "euler_multinomial", "hazard")
)

Arguments

before

List of formulas to be evaluated (in the order provided) before the simulation loop begins. Each formula must have a left hand side that gives the name of the matrix being updated, and a right hand side giving an expression containing only the names of matrices in the model, functions defined in the TMB engine, and numerical literals (e.g. 3.14). The available functions in the TMB engine can be described in engine_functions. Names can be provided for the components of before, and these names do not have to be unique. These names are used by the sim_exprs argument.

during

List of formulas to be evaluated at every iteration of the simulation loop, with the same rules as before.

after

List of formulas to be evaluated after the simulation loop, with the same rules as before.

default

Named list of objects, each of which can be coerced into a numeric matrix. The names refer to variables that appear in before, during, and after.

integers

Named list of vectors that can be coerced to integer vectors. These integer vectors can be used by name in model formulas to provide indexing of matrices and as grouping factors in group_sums.

must_save

Character vector of the names of matrices that must have their values stored at every iteration of the simulation loop. For example, a matrix that the user does not want to be returned but that impacts dynamics with a time lag must be saved and therefore in this list.

must_not_save

Character vector of the names of matrices that must not have their values stored at every iteration of the simulation loop. For example, the user may ask to return a very large matrix that would create performance issues if stored at each iteration. The creator of the model can mark such matrices making it impossible for the user of the model to save their full simulation history.

sim_exprs

Character vector of the names of before, during, and after expressions that must only be evaluated when simulations are being produced and not when the objective function is being evaluated. For example, expressions that generate stochasticity should be listed in sim_exprs because TMB objective functions must be continuous.

state_update

(experimental) Optional character vector for how to update the state variables when it is relevant. Options include "euler", "rk4", and "euler_multinomial".