Documentation Index
Fetch the complete documentation index at: https://docs.emergent.community/llms.txt
Use this file to discover all available pages before exploring further.
Overview
AgentModel is the single object that ties your simulation together. It holds:
- A parameter store for controlling model behavior
- A NetworkX graph where each node represents one agent
- A pluggable initial data function and timestep function
- Built-in convergence detection
Parameters
Parameters are stored in an internal key-value dictionary. Four keys are built-in and always present:| Parameter | Default | Description |
|---|---|---|
num_nodes | 3 | Number of agents (nodes) in the graph |
graph_type | "complete" | Graph topology — "complete", "cycle", or "wheel" |
convergence_data_key | None | Node data key to monitor for convergence |
convergence_std_dev | 100 | Std dev threshold below which the model is considered converged |
Accessing parameters
Use dictionary-style access to read or set individual parameters:The graph
Emergent uses NetworkX graphs internally. Each node is an agent; node data is a dictionary you populate via your initial data function and mutate in your timestep function.Built-in graph types
Setgraph_type before calling initialize_graph():
| Value | Topology |
|---|---|
"complete" | Every node connected to every other node |
"cycle" | Each node connected to its two neighbors in a ring |
"wheel" | One central hub connected to all others; outer nodes form a cycle |
Custom graphs
You can bypass the built-in types and provide your own NetworkX graph directly:When using a custom graph, call
set_graph() before initialize_graph(). The initialize_graph() call will populate nodes with data using your initial data function but will not recreate the graph topology.Simulation functions
Initial data function
Called once per node duringinitialize_graph(). Returns a dictionary that is merged into the node’s data store.
Timestep function
Called once per call totimestep(). Receives the model and should mutate graph node data directly.
Convergence
run_to_convergence() runs timesteps in a loop and stops when the standard deviation of a tracked node attribute drops to or below convergence_std_dev.