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 Agent
and Helipad
, which will not be reproduced here. See the Deme Selection sample model for an example.
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.
Properties
dontStepAgents — bool
By default, all sub-agents are stepped each stage of the main model. This property can be set on a per-stage basis to prevent the sub-agents from being stepped. It is reset to
False
at the beginning of each stage.Initial value: False
charwick
May 09, 2020 at 18:02To set up a multi-level model, register a primitive with
MultiLevel
as 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
MultiLevel
used for a'deme'
primitive,Notice in particular that sub-agent behavior has to be hooked with
deme.addHook
rather thanheli.addHook
, and themodel
argument of the hooked function has been nameddeme
rather thanmodel
to avoid ambiguity between levels.charwick
May 09, 2020 at 18:44An example of
dontStepAgents
to make sure that eachMultiLevel
agent only steps its sub-agents in stage 1 of the top-level model.