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)
other_params(params)
other_params(params) <- value
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.
For other_params()
: A named list with all the parameters for which
you have set values.
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:
encounter
frommizerEncounter()
feeding_level
frommizerFeedingLevel()
pred_rate
frommizerPredRate()
pred_mort
frommizerPredMort()
f_mort
frommizerFMort()
mort
frommizerMort()
resource_mort
frommizerResourceMort()
e
frommizerEReproAndGrowth()
e_repro
frommizerERepro()
e_growth
frommizerEGrowth()
rdi
frommizerRDI()
rdd
fromBevertonHoltRDD()
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
In general if you want to replace a function mizerSomeRateFunc()
with
a function myVersionOfThis()
you would call
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
Your new rate functions may need their own model parameters. These you
can store in other_params(params)
. For example
Note that your own rate functions need to be defined in the global environment or in a package. If they are defined within a function then mizer will not find them.