Agent-based modelling, Konstanz, 2024
14 May 2024
pop
, using an array comprehensionrand(pop)
to sample random agentsinteract!
to make two agents interact1:100
and (1:100) .^ 2
are positional argumentsseriestype = :scatter
and color = :blue
are keyword arguments;
):@agent
keyword)AgentBasedModel
(50, 50)
is a data structure known as a tupleGridSpaceSingle
comes from Agents.jl and defines a grid space in which each node can carry at most one agent (hence, Single
)Note
When initializing a GridSpaceSingle
, you must use a tuple!
@agent
is a special “macro” (more on these later) that introduces all agents in Agents.jlGridAgent{2}
instructs Agents.jl that this agent is to be used in a 2-dimensional grid spaceinteract!
function we have already written:VariationalLearner(1, (4, 27), 0.1, 0.01, 0.4, 0.1)
p
, gamma
etc.) are specified as keyword arguments!StandardABM with 2500 agents of type VariationalLearner
agents container: Dict
space: GridSpaceSingle with size (50, 50), metric=chebyshev, periodic=true
scheduler: fastest
Important
Stepping in Agents.jl is controlled by a so-called scheduler. You can decide which scheduler to use when initializing your model; for now, we will stick to the default scheduler.
This is important to know: when the default scheduler steps a model, every agent gets updated. In the case of our model, this means that every agent undergoes exactly one interaction as the “listening” party, i.e. every agent gets to learn from exactly one interaction during one time step.
abmplot(model)
plots model
in its current state. It has two return values:
abmplot
how we want our model to be visualizedp
, i.e. each learner’s internal “grammatical state”p
getp
function as the value of the agent_color
keyword argument to abmplot
:as
keyword argument specifies the size of the dots that represent the agents):abmvideo
functionp = 0.1
in the beginningp = 1
(uses \(G_1\) all the time),p = 0
(uses \(G_2\) all the time)?