Create a list of expressions for defining a compartmental model in TMB.
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 inmacpan2.cpp
, and numerical literals (e.g.3.14
). The available functions are described inengine_functions
. Names can be provided for the components ofbefore
, and these names do not have to be unique. These names are used by the.simulate_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
.- .simulate_exprs
Character vector of names of expressions to be evaluated within TMB simulate blocks. This is useful when an expression cannot be evaluated during the computation of the objective function and its gradients (e.g. if the expression contains randomness or other discontinuities that will break the automatic differentiation machinery of TMB).
Value
Object of class ExprList
with the following methods.
Methods
$data_arg(...)
: Return the following components of the data structure to pass to C++.expr_output_id
-- Indices into the list of matrices identifying the matrix being produced.expr_sim_block
-- Identified whether or not the expression should be evaluated inside a simulate macro within TMB.expr_num_p_table_rows
-- Number of rows associated with each expression in the parse table (p_table_*
)eval_schedule
-- Vector giving the number of expressions to evaluate in each phase (before, during, or after) of the simulation.p_table_x
-- Parse table column giving an index for looking up either function, matrix, or literal.p_table_n
-- Parse table column giving the number of arguments in functions.p_table_i
-- Parse table column giving indices for looking up the rows in the parse table corresponding with the first argument of the function.