Examples
Complete, runnable examples demonstrating JaxABM capabilities.
Featured Examples
Model Types
Economic Models
Epidemiological Models
Spatial Models
Calibration Examples
These examples focus on parameter calibration and optimization:
Running Examples
All examples can be run directly:
# Clone the repository
git clone https://github.com/username/jaxabm.git
cd jaxabm
# Run any example
python examples/models/predator_prey.py
Or explore them in Jupyter notebooks:
jupyter notebook examples/notebooks/
Example Categories
- Basic Examples (⭐)
Simple models perfect for learning JaxABM basics.
- Intermediate Examples (⭐⭐)
More complex models with multiple agent types and interactions.
- Advanced Examples (⭐⭐⭐)
Sophisticated models showcasing advanced features like RL calibration.
Quick Reference
Code Structure
Each example follows this structure:
import jaxabm as jx
import jax.numpy as jnp
# 1. Model Definition
class ExampleModel:
def __init__(self, params):
# Initialize model parameters
pass
def run(self, steps):
# Run simulation
pass
# 2. Agent Behaviors
def agent_step_function(agents, env_state):
# Define agent behavior
return updated_agents
# 3. Calibration (if applicable)
def setup_calibration():
calibrator = jx.analysis.ModelCalibrator(...)
return calibrator.calibrate()
# 4. Analysis and Visualization
def analyze_results(results):
# Plot and analyze outcomes
pass
if __name__ == "__main__":
# Run the example
main()
Getting Started
Choose an example that matches your interest/domain
Read the documentation to understand the model
Run the code to see it in action
Modify parameters to explore behavior
Extend the model with your own features
Each example includes:
Model description and motivation
Complete source code with comments
Parameter explanations and sensible defaults
Visualization code for results
Extension suggestions for further exploration
Contributing Examples
We welcome new examples! Please see our contribution guidelines for:
Code style requirements
Documentation standards
Testing expectations
Review process
Good examples include:
Clear, well-commented code
Realistic parameter values
Meaningful visualizations
Educational value
Proper citations for published models
Social Models