This is used to use the results from one simulation as the starting values for another simulation.
setInitialValues(params, sim, time_range, geometric_mean = FALSE)
The params
object with updated initial values and initial effort.
Because of the way the
R language works, setInitialValues()
does not make the changes to the
params object that you pass to it but instead returns a new params object.
So to affect the change you call the function in the form
params <- setInitialValues(params, sim)
.
A MizerParams
object in which to set the initial values
A MizerSim
object from which to take the values.
The time range to average the abundances over. Can be a vector of values, a vector of min and max time, or a single value. Only the range of times is relevant, i.e., all times between the smallest and largest will be selected. Default is the final time step.
If TRUE then the average of the abundances over the
time range is a geometric mean instead of the default arithmetic mean. This
does not affect the average of the effort or of other components, which is
always arithmetic.
The initial abundances (for both species and resource) in the params
object are set to the abundances in a MizerSim object, averaged over
a range of times. Similarly, the initial effort in the params
object is
set to the effort in the MizerSim object, again averaged over that range
of times.
When no time range is specified, the initial values are taken from the final
time step of the simulation.
If the model described by sim
and params
has additional components
created with setComponent()
then the values of these components are also
averaged and copied to params
.
The MizerSim object must come from a model with the same set of species and gears and other components and the same size bins as the MizerParams object. Otherwise an error is raised.
Other functions for setting parameters:
gear_params()
,
setExtEncounter()
,
setExtMort()
,
setFishing()
,
setInteraction()
,
setMaxIntakeRate()
,
setMetabolicRate()
,
setParams()
,
setPredKernel()
,
setReproduction()
,
setSearchVolume()
,
species_params()
# \donttest{
params <- NS_params
sim <- project(params, t_max = 20, effort = 0.5)
params <- setInitialValues(params, sim)
# }
Run the code above in your browser using DataLab