Skip to content

populations

Agent populations: a type, a count and an initial placement.

In the model file this key holds a list of population entries, each named by its name.

A scenario, an experiment or an optimizer can set a field by the path populations.<name>.<field>.

Typical uses

These sections add agent-based modelling. An agent_type is a statechart: attributes, states and the transitions between them. A population is a number of agents of one type, with an initial placement. Use them for individuals that decide and interact, such as people in an epidemic, drivers or machines with their own behaviour.

Behaviour and rules

A transition has exactly one trigger: a timeout, a rate, a condition, a message or a tick. A rate must be shared by all agents, own to the agent, or a product of the two. A rate that changes continuously with time is refused. A condition or rate that reads model state outside the agents is re-checked only at agent events, unless it sets scan.

A population has a count and can have a max_count. A spawn into a full population stops the run with an error. The agents live in a space that is continuous, a grid or a network. The functions that read neighbours need a space of the matching kind. Agents can be linked to each other.

A CREATE block with population set gives each entity an agent. A SEND block or a send action delivers a message that a message transition waits for. A message nobody sends is reported by a check. Each agent draws random numbers from its own stream, so one agent's draws do not depend on the others.

Fields

Field Type Required Default Unit Description
name string yes The population's name.
description string What the population stands for; the run does not read it.
type string yes The agent type its agents follow.
count integer or object yes 0 count How many agents start: a number, or the rows of a table.
max_count integer count The most agents alive at once when spawn actions add some (>= count); default count.
tick agent tick A fixed-step schedule, ticks at phase + k * dt (k an integer, strictly after the run start). synchronous: every agent reads the tick-start state (on_tick for all, then tick transitions for all); random: a fresh permutation per tick; sequential: index order. A population's keys override its type's.
network object The initial links between this population's agents, drawn at run start from its own network stream. random: G(n, p) (p, or mean_degree = p (n - 1)); small_world: Watts-Strogatz ring of k neighbours, each link rewired with probability beta; scale_free: Barabasi-Albert, m links per new agent; table: a model table's "from"/"to" columns (agent indices); none: no initial links.
color_by string A declared categorical attribute; playback colours the population's tokens by its current category instead of by state (2D and 3D).
colors object {category: colour name}, the palette color_by draws from -- the same names a statechart state's own "color" uses. Presentational only, like that field.
initial list of object The first agents by index start in these states, the rest in the type's initial state.
placement object Only meaningful when the type has a space: default {"kind": "random"} (uniform over the space's own bounds, or a uniform random network node, both from the agent's own stream).

A field of a nested object is described in the JSON Schema (naga schema).

Example

The fragment refers to entries that are defined elsewhere in the same file:

{"agent_types": [{"name": "Person", "states": [{"name": "Healthy"}], "initial_state": "Healthy"}]}

The fragment:

{"populations": [{"name": "People", "type": "Person", "count": 100}]}

In the Python builder:

from nagasim import build as nb
m = nb.Model()
m.add_population(name='People', type='Person', count=100)

Used in

Bundled models: Boids flock (continuous, heading), Nagel-Schreckenberg traffic (ring), Schelling segregation (grid), SIR on a small-world network, Sugarscape with regrowth (grid, patches), Wolf-Sheep predation with grass (grid) and 8 more.

Guides: Agent-based modelling, Coming from AnyLogic, Coming from Mesa, Coming from NetLogo, How do I let an agent read the agents it is linked to?, How do I let an agent react to the agents near it? and 2 more.

See also