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.
setRateFunction(params, rate, fun)getRateFunction(params, rate)
A MizerParams object
Name of the rate for which a new function is to be set.
Name of the function to use to calculate the rate.
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.
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 from mizerEncounter()
feeding_level from mizerFeedingLevel()
pred_rate from mizerPredRate()
pred_mort from mizerPredMort()
fishing_mort from mizerFMort()
mort from mizerMort()
resource_mort from mizerResourceMort()
e from mizerEReproAndGrowth()
e_repro from mizerERepro()
e_growth from mizerEGrowth()
rdi from mizerRDI()
rdd from BevertonHoltRDD()
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")