Registers an agent primitive. A primitive, like a breed, is a way of introducing heterogeneity into a model, but there are several differences.
- Breeds do not affect the order of stepping. All agents of a primitive are stepped before any agents of another (this order can be changed with the
priorityargument). - Breed is set as a property of the agent, which can be used with conditional logic in agent hooks. Building a primitive requires building a new agent class, which allows cleaner separation of logic where different types of agents behave in completely different ways.
- A use case of breeds would be different types of consumers. A use case of primitives would be consumers versus stores.
Parameters
name — str, required
The name of the primitive.
class — class, required
A class, defined in user code, that re-instantiates the functions of
Agent. It is a good idea to have this class inherit fromBaseAgent.plural — str, optional
The plural form of
name. Ifpluralis not specified, the plural will be constructed by placing an 's' at the end of the name.Default value: None
dflt — int, optional
Registering a primitive adds a slider to the control panel indicating how many of the primitive to instantiate at the beginning of the model.
dfltis the default value on this slider.Default value: 50
low — int, optional
The slider's lower limit
Default value: 1
high — int, optional
The slider's upper limit
Default value: 100
step — int, optional
The increment in which the slider moves. For example, set to 2 to enforce only an even number of agents of this primitive.
Default value: 1
hidden — bool, optional
Whether to hide the slider for altering the number of agents of this primitive from the control panel. If
hidden = True, the initial number instantiated will bedflt.Default value: False
priority — int, optional
The order in which to step the primitives. Primitives with lower numbers are stepped first.
Default value: 100
order — str, optional
Allows the order of activation to be specified on a per-primitive basis, overriding
model.order. Possible values are:'random', which shuffles the list of agents before each stage'linear', which preserves the order of activation between periods.'match-n', which steps agents in groups ofnand passes them to thematchhook. Iforder=='match'(without the-n), agents will pair off at random (i.e.n==2).
[primitive]Orderhook. If not specified, defaults to the value of model.order.Default value: None
Notes and Examples