Creates and/or destroys agents to get a population number. This function is used as a setter function for agent population parameters, and also at the beginning of a model to create the initial agent set.
WARNING: This is an internal function. Its use in user code is not recommended or supported, and its signature can change in future updates without warning. Use one of the suggested functions above instead, if applicable.
Parameters
val — int, required
A new population number. If the current population is less than
val
, the function creates the difference. If the current population is less thanval
, the function destroys agents, maintaining the current proportion between breeds, until the population equalsval
.prim — str, required
The primitive whose agents to create or destroy
model — Helipad, required
The model object. Redundant strictly speaking, but necessary to use the function as a slider callback. See the
callback
argument ofParams.add()
.force — bool, optional
Because this function is used as a callback for the
num_agents
parameter, if called whenmodel.hasModel==False
, the function normally returns the current parameter value ofmodel.param('num_{prim}')
and does not create agents unless a model is already instantiated. This argument is used during model launch to force the initial creation of agents.Default value: False
Notes and Examples