The Central Idea

An agent-based model begins with individuals rather than only aggregate totals.

The basic structure is

\[ \boxed{ \text{agents} + \text{local rules} + \text{interactions} \longrightarrow \text{system-level behavior} }. \]

The model asks how collective outcomes arise when many agents repeatedly act, move, adapt, compete, cooperate, transmit information, or respond to changing conditions.

What Is an Agent-Based Model?

An agent-based model, often abbreviated ABM, is a computational model in which a system is represented as a collection of individual agents that follow specified rules.

Agents may represent:

Agents Have State

Each agent usually carries information describing its current condition.

For an agent \(i\), we can write the state abstractly as

\[ \mathbf{s}_i. \]

This state might include:

Agents Follow Rules

An agent's next state is determined by a rule.

In general form,

\[ \boxed{ \mathbf{s}_i^{\,n+1} = F_i\!\left( \mathbf{s}_i^{\,n}, \text{neighbors}, \text{environment}, \text{parameters}, \text{randomness} \right) }. \]

The function \(F_i\) represents the agent's update behavior.

Local Information

Agents often respond to only a small part of the entire system.

An agent may observe:

System-wide behavior can therefore arise from decisions based on limited local information.

The Environment

Agents usually operate inside an environment.

The environment may be:

The environment may itself change as agents interact with it.

Agent-Environment Interaction

An agent may both respond to and modify its environment.

For example:

This creates feedback between individual behavior and the surrounding system.

Interactions Between Agents

Agent-agent interactions are often the central mechanism in an ABM.

An interaction may involve:

Neighborhoods

A neighborhood defines which other agents can influence a given agent.

If agents occupy positions in space, agent \(j\) may be considered a neighbor of agent \(i\) when

\[ d(i,j)\le r, \]

where \(d(i,j)\) is the distance between the agents and \(r\) is an interaction radius.

The neighborhood structure determines which local interactions are possible.

Network Neighborhoods

Agents do not have to be neighbors geometrically.

In a network model, two agents may interact if an edge connects them.

If

\[ A_{ij}=1, \]

the adjacency matrix may indicate that agents \(i\) and \(j\) are connected.

Social, communication, transportation, and organizational systems are often modeled this way.

Homogeneous and Heterogeneous Agents

Agents may be identical in structure or may differ substantially.

Homogeneous agents share the same parameters and rules. Heterogeneous agents may differ in:

Heterogeneity is one reason agent-based models can represent complex populations naturally.

Example: A Simple Movement Model

Suppose agent \(i\) has position

\[ \mathbf{x}_i^n \]

and velocity

\[ \mathbf{v}_i^n. \]

A basic movement rule is

\[ \mathbf{x}_i^{n+1} = \mathbf{x}_i^n + \Delta t\,\mathbf{v}_i^n. \]

Each agent updates its own position according to its current velocity.

Movement with Local Interaction

Velocity may itself depend on nearby agents.

For example,

\[ \mathbf{v}_i^{n+1} = \mathbf{v}_i^n + \alpha\mathbf{a}_i^n, \]

where \(\mathbf{a}_i^n\) represents an interaction effect such as attraction, repulsion, alignment, or avoidance.

Repeated local adjustments can generate coordinated group motion.

Emergent Behavior

Emergent behavior is a large-scale pattern that arises from many local interactions rather than being directly specified as a system-wide rule.

Examples can include:

Micro Rules and Macro Outcomes

Agent-based modeling distinguishes between the micro level and the macro level.

The micro level contains individual states and rules. The macro level contains aggregate patterns and statistics.

Conceptually,

\[ \boxed{ \text{micro-level behavior} \longrightarrow \text{interaction} \longrightarrow \text{macro-level pattern} }. \]

Aggregation

Even though an ABM stores individual agents, outputs are often summarized statistically.

If \(x_i\) is a quantity associated with agent \(i\), the population mean is

\[ \bar{x} = \frac{1}{N} \sum_{i=1}^{N}x_i. \]

Other aggregate outputs may include totals, proportions, variances, distributions, cluster sizes, network measures, or spatial densities.

Example: Binary Agent States

Suppose each agent has a binary state

\[ s_i\in\{0,1\}. \]

The proportion of agents in state \(1\) is

\[ p = \frac{1}{N} \sum_{i=1}^{N}s_i. \]

The model tracks individual states but can report a system-wide fraction.

Threshold Rules

Agents often change behavior when a local condition crosses a threshold.

For example, agent \(i\) might adopt a new state when

\[ \frac{\text{neighbors in state }1} {\text{total neighbors}} \ge \theta, \]

where \(\theta\) is the agent's threshold parameter.

Threshold models can produce cascades and abrupt system-level transitions.

Rule-Based Decision Making

Some agent rules are deterministic.

For example:

IF inventory < reorder_level
    PLACE order
ELSE
    DO nothing
END IF

The same local condition always produces the same decision.

Probabilistic Decision Making

Other agent rules include randomness.

An agent might choose action \(A\) with probability

\[ P(A)=p \]

and action \(B\) with probability

\[ P(B)=1-p. \]

Stochastic rules allow the model to represent uncertainty, variation, and non-identical decisions among otherwise similar agents.

Example: Probabilistic Transmission

Suppose an infectious agent interacts with a susceptible neighbor.

Let

\[ p=0.08 \]

be the probability of transmission during one qualifying contact.

The model can draw a random number \(U\) uniformly from \([0,1]\) and transmit if

\[ U Individual outcomes are random even though the transmission rule is precisely specified.

Synchronous Updating

In synchronous updating, all agents evaluate their rules from the same current system state.

Conceptually:

  1. inspect the current state;
  2. compute every agent's proposed next state;
  3. replace all current states simultaneously.

This prevents agents updated early from influencing agents that have not yet been updated during the same step.

Asynchronous Updating

In asynchronous updating, agents are updated one at a time or in subsets.

Later updates may therefore observe changes made earlier in the same simulation cycle.

Asynchronous updating can be appropriate when events occur sequentially, but it defines a different computational process from synchronous updating.

Update Order Can Matter

Suppose agent \(A\) changes state and agent \(B\) responds to \(A\).

Under synchronous updating, \(B\) sees the old state of \(A\). Under sequential updating, \(B\) may see the new state.

Therefore,

\[ \boxed{ \text{update schedule is part of the model} }. \]

It should be chosen deliberately and documented.

Randomized Update Order

Some asynchronous models randomize the order in which agents are updated.

This can reduce systematic bias caused by always updating the same agents first.

A simulation cycle might therefore:

  1. randomly shuffle the agent list;
  2. update agents in that order;
  3. record the resulting state.

Agent Creation and Removal

The number of agents does not always remain constant.

Models may include:

Creation and removal rules change the population dynamically.

Agent Types

A model may contain several classes of agents.

For example, a transportation model might contain:

Each type can have distinct state variables, rules, and interaction mechanisms.

Resources and Competition

Agents may compete for limited resources.

If total resource supply is \(R\) and agent \(i\) consumes \(r_i\), then a basic resource constraint is

\[ \sum_{i=1}^{N}r_i\le R. \]

Competition rules determine how the available resource is allocated and how shortages affect agent behavior.

Markets as Agent-Based Systems

Economic systems can be modeled with buyers, sellers, firms, lenders, or other participants as agents.

Individual agents may have:

Transactions then generate aggregate prices, volumes, shortages, surpluses, or other market outcomes.

Spatial Agent-Based Models

In spatial ABMs, each agent may occupy a location

\[ \mathbf{x}_i=(x_i,y_i) \]

or

\[ \mathbf{x}_i=(x_i,y_i,z_i). \]

Movement, interaction range, obstacles, resources, and boundaries can then be modeled geometrically.

Grid-Based Agent Models

Agents can also occupy cells of a discrete grid.

A two-dimensional agent position may be indexed as

\[ (i,j). \]

Rules can determine whether the agent moves to neighboring cells, remains in place, interacts locally, or modifies the cell state.

Continuous-Space Agent Models

Not every agent must be restricted to a grid.

In continuous-space models, position coordinates may take real values:

\[ x_i,y_i\in\mathbb{R}. \]

Movement can then be represented by vector updates, differential equations, or geometric rules.

Agent-Based Models and Networks

A network ABM combines agent states with graph structure.

Agents correspond to vertices and interactions occur along edges.

This allows the model to study how behavior depends on:

Simple ABM Pseudocode

INITIALIZE environment
CREATE agents
ASSIGN initial agent states

REPEAT for each simulation step
    FOR each agent
        IDENTIFY neighbors
        OBSERVE local environment
        COMPUTE proposed action
    END FOR

    APPLY agent updates
    UPDATE environment
    RECORD outputs
END REPEAT

The exact sequence depends on whether the model uses synchronous or asynchronous updating.

Initial Conditions

ABMs are often sensitive to how agents are initialized.

Initial conditions may specify:

Different initial arrangements can lead to different system trajectories.

Random Initialization

Some models initialize agents randomly.

For example, positions might be sampled from a region, while binary states may be assigned with

\[ P(s_i=1)=p. \]

Because initialization is stochastic, repeated runs may begin from different microscopic configurations even when they share the same parameter values.

Random Seeds

A pseudorandom agent-based simulation can often be reproduced by fixing a random seed.

This is especially useful when:

One Run Is Usually Not Enough

When an ABM contains stochastic rules, one simulation trajectory may not represent typical behavior.

Instead, the model may be run many times.

If an output from run \(r\) is \(Y_r\), an estimated mean can be computed as

\[ \bar{Y} = \frac{1}{R} \sum_{r=1}^{R}Y_r. \]

Variation across runs is itself important information.

Distributions of Outcomes

A stochastic ABM may produce an entire distribution of possible outcomes rather than one deterministic prediction.

Useful summaries include:

Calibration

Calibration is the process of choosing parameter values so that model behavior is consistent with relevant observations or target statistics.

Suppose the model depends on parameter vector

\[ \boldsymbol{\theta}. \]

Calibration seeks values of \(\boldsymbol{\theta}\) that produce outputs reasonably close to selected empirical features.

Calibration Does Not Prove Correctness

A model can match one set of observed statistics for the wrong reasons.

Several different parameter combinations or rule structures may generate similar aggregate results.

Calibration is therefore useful, but it does not by itself establish that the model's mechanisms are correct.

Validation

Validation asks whether the ABM represents the intended real or conceptual system well enough for its stated purpose.

Validation may compare:

Verification

Verification asks whether the implemented agent rules actually match the model specification.

Useful verification checks include:

Unit Tests for Agent Rules

Individual rules should be testable before the full model is run.

If an agent should move one unit right when a condition is true, then a simple reference case can verify that

\[ x_{\text{new}}=x_{\text{old}}+1. \]

Testing simple rules independently makes debugging a large ABM much easier.

Sensitivity Analysis

ABM outputs may depend strongly on behavioral parameters.

If \(\theta\) is a parameter, a sensitivity study compares outputs under values such as

\[ \theta_1,\ \theta_2,\ \theta_3. \]

The goal is to determine which assumptions and parameters most strongly influence the results.

Parameter Sweeps

A parameter sweep runs the model repeatedly across a collection of parameter values.

For two parameters \(a\) and \(b\), a grid of experiments might use

\[ a\in\{a_1,a_2,a_3\}, \qquad b\in\{b_1,b_2,b_3,b_4\}. \]

This produces

\[ 3\cdot4=12 \]

parameter combinations before accounting for repeated stochastic runs.

Computational Cost

The computational cost of an ABM often grows with:

Interaction search can be especially expensive when every agent potentially interacts with every other agent.

Pairwise Interaction Growth

If every pair of \(N\) agents must be checked, the number of unordered pairs is

\[ \binom{N}{2} = \frac{N(N-1)}{2}. \]

For

\[ N=1000, \]

this gives

\[ \frac{1000\cdot999}{2} = 499{,}500 \]

possible pairs in one interaction sweep.

Local Search Can Reduce Cost

If agents interact only with nearby neighbors, the model does not necessarily need to compare every agent with every other agent.

Spatial partitions, grids, trees, or network adjacency structures can restrict interaction checks to plausible neighbors.

Efficient representation becomes increasingly important as the model scales.

Model Outputs

An ABM can generate outputs at several levels.

Agent-level outputs describe individual histories. System-level outputs describe the population as a whole.

Common outputs include:

Visualization

Visualization can reveal agent behavior that aggregate statistics hide.

Useful visualizations include:

Visualization should support interpretation rather than replace quantitative analysis.

Common Error: Encoding the Outcome Instead of the Mechanism

If the purpose of an ABM is to study whether a pattern emerges, the model should not directly force that pattern into the agent rules.

Otherwise, the simulation merely reproduces an assumed result.

Agent rules should represent plausible local mechanisms, while system-level outcomes should be measured from the resulting simulation.

Common Error: Hidden Update-Order Effects

A model may appear to use simultaneous behavior while its implementation updates agents sequentially.

This can create artificial advantages for agents updated earlier or later.

The update schedule should be explicit and tested.

Common Error: Treating One Stochastic Run as a Prediction

A single random simulation path may be unusually high, low, early, late, clustered, or dispersed.

When randomness matters, results should usually be summarized across repeated runs rather than interpreted from one realization alone.

Common Error: Overcomplicating Agent Rules

Detailed rules are not automatically better rules.

Adding unnecessary parameters and behaviors can make a model harder to interpret, calibrate, verify, and validate.

A useful ABM should contain enough mechanism to address its modeling purpose without adding complexity that does not materially support that purpose.

Common Error: Ignoring Scale

An agent rule may behave sensibly for \(100\) agents but become computationally expensive or qualitatively different for \(1{,}000{,}000\) agents.

Population size, spatial scale, interaction radius, network density, and time resolution should therefore be considered together.

Common Error: Confusing Calibration with Validation

Calibration chooses parameter values to reproduce selected targets.

Validation asks whether the model performs adequately beyond those calibration targets for its intended use.

A model should not be declared validated merely because it can be tuned to fit one dataset.

A Reliable Agent-Based Modeling Workflow

  1. Define the system-level question.
  2. Identify the entities that should be represented as agents.
  3. Define each agent's state variables.
  4. Specify the environment and interaction structure.
  5. Write local behavioral and decision rules.
  6. Choose synchronous, asynchronous, or event-driven updating.
  7. Specify stochastic mechanisms and random seeds.
  8. Define initial conditions.
  9. Implement simple agent and interaction tests.
  10. Run the full model.
  11. Record both micro-level and macro-level outputs.
  12. Repeat stochastic simulations.
  13. perform sensitivity and parameter studies;
  14. verify, calibrate, and validate according to the modeling purpose.

Practice 1: Identify the Agent

A traffic simulation represents every vehicle individually.

What is the agent?

Practice 2: Identify State Variables

A vehicle agent stores its current road position, speed, and destination.

Which of these are agent state variables?

Practice 3: Neighborhood Rule

Agent \(j\) is considered a neighbor of agent \(i\) when

\[ d(i,j)\le 5. \]

If \(d(i,j)=4.2\), is \(j\) in the neighborhood of \(i\)?

Practice 4: Aggregate a Binary State

Five agents have states

\[ 1,\ 0,\ 1,\ 1,\ 0. \]

What proportion of agents are in state \(1\)?

Practice 5: Count Pairwise Interactions

If every pair among \(10\) agents must be checked once, how many unordered pairs are there?

Practice 6: Synchronous Update

Explain why proposed next states should be stored separately from current states during synchronous updating.

Practice 7: Stochastic Runs

A model contains probabilistic agent decisions. Two runs with the same parameters produce different totals.

Does this difference alone show that the implementation is incorrect?

Practice 8: Emergence

Individual agents follow only local alignment and separation rules, but the population forms coordinated moving groups.

What modeling concept does this illustrate?

Practice Answers

Practice 1

Each individual vehicle is an agent.

Practice 2

Position, speed, and destination are all components of the vehicle agent's state.

Practice 3

Yes. Since

\[ 4.2\le5, \]

agent \(j\) satisfies the neighborhood condition.

Practice 4

Three of the five agents are in state \(1\):

\[ p=\frac{3}{5}=\boxed{0.6}. \]

Practice 5

\[ \binom{10}{2} = \frac{10\cdot9}{2} = \boxed{45}. \]

Practice 6

Synchronous updating requires every agent to respond to the same old system state. Storing proposed states separately prevents early updates from influencing later agents during the same step.

Practice 7

No. Different outputs are expected when randomness is part of the model. The stochastic rule, probability distribution, and random-number implementation should be checked instead.

Practice 8

This illustrates emergent behavior: coordinated system-level structure arises from local agent rules.

What to Remember

Agent-based models represent systems from the bottom up using interacting individual entities.

The central principle is: define the local mechanisms clearly, then measure the collective behavior that emerges from their interaction.

Where We Go Next

Agent-based models frequently include randomness in initialization, interaction, movement, transmission, and decision rules. More broadly, many computational models use repeated random sampling to estimate probabilities, expectations, integrals, risks, and distributions.

The next lesson, Monte Carlo Simulation, develops the systematic use of random sampling to approximate quantities that may be difficult to compute directly.