Agents.jl: High-Performance Agent-Based Modeling in Julia for Social System Simulation
Agent-based modeling (ABM) has become indispensable for studying emergent social phenomena—from opinion dynamics and market behavior to epidemic spread and urban segregation. While Python's Mesa and Java-based Repast Simphony dominate many research workflows, Agents.jl has emerged as a compelling alternative for practitioners who need both expressive model design and computational performance. Built on the Julia programming language, Agents.jl delivers near-C execution speeds without sacrificing the interactive, exploratory workflow that social scientists depend on.
Why Julia for Agent-Based Modeling?
Julia's design philosophy—"walk like Python, run like C"—makes it uniquely suited to ABM. Social system models often require running thousands of Monte Carlo replicates or sweeping large parameter spaces; in Python-based frameworks, this typically means offloading to Cython, Numba, or multiprocessing wrappers. In Agents.jl, the same pure-Julia model code that you prototype interactively compiles to efficient machine code via LLVM, often achieving 10–100× speedups over equivalent Mesa implementations with no additional effort.
Agents.jl is part of the broader SciML (Scientific Machine Learning) ecosystem, meaning it integrates naturally with DifferentialEquations.jl for hybrid ODE/ABM models, Distributions.jl for stochastic processes, and Plots.jl or Makie.jl for publication-quality visualization.
Core Architecture

Agents.jl organizes models around three primitives:
AgentBasedModel— the container holding all agents, the space, and global model properties.AbstractAgentsubtypes — user-defined structs that carry per-agent state (e.g.,wealth,opinion,health_status).- Space types —
GridSpace,ContinuousSpace,GraphSpace, orOpenStreetMapSpace, each optimized for different interaction geometries.
A minimal Schelling segregation model in Agents.jl illustrates the conciseness:
using Agents
@agent struct SchellingAgent(GridAgent{2})
mood::Bool = false
group::Int
end
function agent_step!(agent, model)
minhappy = model.min_to_be_happy
count_neighbors_same_group = count(
a -> a.group == agent.group,
nearby_agents(agent, model)
)
agent.mood = count_neighbors_same_group ≥ minhappy
if !agent.mood
move_agent_single!(agent, model)
end
end
model = StandardABM(SchellingAgent, GridSpace((20, 20));
properties = Dict(:min_to_be_happy => 3))

The @agent macro automatically handles agent ID management and spatial bookkeeping, eliminating boilerplate that plagues lower-level frameworks.
Key Features for Social System Research
1. Multi-Space and Network Models
Agents.jl supports GraphSpace backed by Graphs.jl, enabling social network models where agents occupy nodes and interact only with graph neighbors. This is essential for diffusion-of-innovation, rumor propagation, and social influence studies. Switching from a grid to a scale-free Barabási–Albert network requires changing a single constructor call—the agent step logic remains identical.
2. OpenStreetMap Integration
The OpenStreetMapSpace type loads real road networks from OSM data, allowing pedestrian or vehicle agents to navigate actual city geometries. Researchers studying urban mobility, protest dynamics, or disease spread in specific cities can ground their models in empirical geography without external GIS preprocessing.
3. Ensemble Runs and Parameter Sweeps
The ensemblerun! and paramscan functions provide built-in support for replicated runs and parameter sweeps, returning tidy DataFrame objects compatible with the Julia data science stack (DataFrames.jl, AlgebraOfGraphics.jl). A full Latin hypercube sweep over five parameters with 50 replicates each can be expressed in under ten lines of code and executed in parallel across CPU cores via Julia's native threading.
4. Schedulers and Activation Order
Social dynamics are sensitive to agent activation order. Agents.jl ships with multiple schedulers—Schedulers.Randomly, Schedulers.ByProperty, Schedulers.ByType—and supports custom schedulers. Researchers studying turn-order effects in negotiation or voting models can swap schedulers without restructuring model logic.
5. Interactive Exploration with InteractiveDynamics.jl
The companion package InteractiveDynamics.jl provides a one-call interactive dashboard:
using InteractiveDynamics, GLMakie
abmexploration(model; agent_step!, params, alabels, mlabels)
This launches a live GUI with sliders for all model parameters, real-time spatial visualization, and time-series plots—comparable to NetLogo's interface tab but operating on compiled Julia code.
Performance Benchmarks
Independent benchmarks (Datseris et al., 2022, JOSS) show Agents.jl outperforming Mesa by 8–50× on standard ABM benchmarks (Schelling, Flocking, Forest Fire) and matching or exceeding MASON on grid-based models, while requiring significantly less boilerplate code. For models with 10⁶+ agents—common in epidemiological or financial market simulations—this performance gap translates directly into feasible vs. infeasible research timelines.

Practical Workflow
A typical Agents.jl research workflow proceeds as follows:
- Prototype the model interactively in a Jupyter or Pluto notebook.
- Validate against analytical results or stylized facts using
run!with data collection. - Sweep parameters with
paramscanon a local multi-core machine or HPC cluster. - Visualize results using AlgebraOfGraphics.jl or export to CSV for R/Python post-processing.
- Reproduce by sharing the Julia environment (
Project.toml+Manifest.toml), ensuring exact package version pinning.
Limitations and When to Choose Alternatives
Agents.jl requires familiarity with Julia, which has a steeper initial learning curve than Python for researchers already fluent in Mesa. The ecosystem, while growing rapidly, is smaller than Python's for domain-specific social science libraries. For models requiring GPU parallelism across millions of agents, FLAME GPU 2 remains the better choice. For spatially explicit environmental models with GIS-heavy workflows, GAMA Platform's built-in GIS tooling may be more productive.
Getting Started
- Documentation: agents.jl.org
- Paper: Datseris et al. (2022), Journal of Open Source Software, doi:10.21105/joss.03722
- Tutorials: The official docs include step-by-step tutorials for Schelling segregation, SIR epidemics, opinion dynamics, and financial market models.
- Community: Julia Discourse (
#agents-jltag) and the JuliaDynamics GitHub organization.
Agents.jl represents the current state of the art for researchers who need the expressiveness of a high-level ABM framework combined with the raw computational throughput required for large-scale social system simulation. As Julia's adoption in computational social science grows, Agents.jl is well-positioned to become the framework of choice for performance-critical ABM research.