
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 baseAgent and 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 Agents.addPrimitive().
Initialization Parameters
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.
charwick
May 09, 2020 at 18:02To set up a multi-level model, register a primitive with
MultiLevelas the class. The default'agent'primitive can also optionally be removed.charwick
May 09, 2020 at 18:15Note 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'deme'primitive,Notice in particular that sub-agent behavior has to be hooked with
deme.hooks.addrather thanheli.hooks.add, and themodelargument of the hooked function has been nameddemerather thanmodelto avoid ambiguity between levels.charwick
May 09, 2020 at 18:44An example of using
cutStep()to make sure that eachMultiLevelagent only steps its sub-agents in stage 1 of the top-level model. Notice we callcutStep()ondeme(theMultiLevelobject) and notmodel.