Skip to contents

Construct an object with methods for simulating from and optimizing a compartmental model made using TMBModel.

Usage

TMBSimulator(tmb_model, tmb_cpp = "macpan2", initialize_ad_fun = TRUE)

Arguments

tmb_model

An object of class TMBModel.

tmb_cpp

Name of a C++ program using TMB as the simulation engine.

initialize_ad_fun

Should the TMB AD function be intialized? This should usually be set to TRUE unless you want to hack the data structure passed to TMB (which can be acquired using $tmb_model$make_ad_fun_arg()) before passing it yourself to TMB::MakeADFun. This is particularly useful if you want to modify tmb_cpp.

Value

Object of class TMBSimulator with the following methods.

Methods

  • $report(): Runs simulations and returns a data frame with the following columns.

    • matrix: Name of the matrix with values returned.

    • time: Time step of the values.

    • row: Row in the matrix containing the value.

    • col: Column in the matrix containing the value.

    • value: Numerical value being reported.

  • $error_code(): If the simulations result in an engine error then the code associated with this error is returned, otherwise the code 0 is returned.

  • $ad_fun(): Return the underlying TMB object.