Learn R Programming

mizer (version 2.0.0)

setRateFunction: Set own rate function to replace mizer rate function

Description

If the way mizer calculates a fundamental rate entering the model is not flexible enough for you (for example if you need to introduce time dependence) then you can write your own functions for calculating that rate and use setRateFunction() to register it with mizer.

Usage

setRateFunction(params, rate, fun)

getRateFunction(params, rate)

Arguments

params

A MizerParams object

rate

Name of the rate for which a new function is to be set.

fun

Name of the function to use to calculate the rate.

Value

For setRateFunction(): An updated MizerParams object

For getRateFunction(): The name of the registered rate function for the requested rate, or the list of all rate functions if called without rate argument.

Details

At each time step during a simulation with the project() function, mizer needs to calculate the instantaneous values of the various rates. By default it calls the mizerRates() function which creates a list with the following components:

For each of these you can substitute your own function. So for example if you have written your own function for calculating the total mortality rate and have called it myMort and have a mizer model stored in a MizerParams object called params that you want to run with your new mortality rate, then you would call

params <- setRateFunction(params, "Mort", "myMort")

In some extreme cases you may need to swap out the entire mizerRates() function for your own function called myRates(). That you can do with

params <- setRateFunction(params, "Rates", "myRates")