A class allowing multi-level agent-based models to be constructed, where the agents at one level are themselves full models with sub-agents. This class inherits all the methods and properties from both
Helipad, which will not be reproduced here. See the Deme Selection sample model for an example.
To use a multi-level model, import the class and register it with
breed — str, required
The breed of the newly created agent.
id — int, required
A unique (at the top level) ID for the agent. Unexpected results may occur if non-unique ids are used.
model — Helipad, required
The model object of which this agent is a child.
Notes and Examples
charwickMay 09, 2020 at 18:02
To set up a multi-level model, register a primitive with
MultiLevelas the class. The default
'agent'primitive can also optionally be removed.
charwickMay 09, 2020 at 18:15
Note that any setup that would have been done in the main loop for the main model will have to be done individually for each sub-model, including parameters, hooks, shocks, goods, and breeds. This can be done in the init hook of the MultiLevel primitive in the main model. With
MultiLevelused for a
Notice in particular that sub-agent behavior has to be hooked with
heli.hooks.add, and the
modelargument of the hooked function has been named
modelto avoid ambiguity between levels.
charwickMay 09, 2020 at 18:44
An example of using
cutStep()to make sure that each
MultiLevelagent only steps its sub-agents in stage 1 of the top-level model. Notice we call
MultiLevelobject) and not