Metadata-Version: 2.4
Name: abmax
Version: 0.0.1
Summary: ABM package in JAX.
Author-email: Siddharth Chaturvedi <sidchat.sc@gmail.com>
License: MIT License
        
        Copyright (c) 2025 Siddharth Chaturvedi
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE.md
Keywords: ABM,Agent-Based-Modeling,abm,abmax,agent-based-modeling,jax,simulation
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: ~=3.10
Requires-Dist: flax>=0.7.4
Requires-Dist: jax>=0.4.13
Description-Content-Type: text/markdown

# Abmax
Abmax is an agent-based modeling(ABM) framework in Jax, focused on dynamic population size.
It provides:
- Datastructures and functions that can be used to define sets of agents and their manipulations.
    * Adding and removing arbitrary number of agents.
    * Searching and sorting agents based on their attributes.
    * Updating an arbitrary number of agents to a specific state.
    * Stepping agents in a vectorized way.
    * Running multiple such simulations in parallel.
- Implementation of common algorithms used in ABM implemented in Vmap and Jit friendly way.

# Installation
```bash
pip install abmax
```
Dependencies:
- Python
- Jax
- Flax

# Benchmark
A comparison of the performance of Abmax with other ABM frameworks: [Agents.jl](https://juliadynamics.github.io/Agents.jl/stable/) and [Mesa](https://mesa.readthedocs.io/en/stable/) based on the [Wolf-Sheep (Grid space) and Bird-Flock (Continuous space) models](https://github.com/JuliaDynamics/ABMFrameworksComparison). These simulations are run for 100 steps and the median time taken for 10 runs is logged. The benchmark is run on a [gcn GPU node](https://servicedesk.surf.nl/wiki/display/WIKI/Snellius+hardware)(Intel Xeon Platinum 8360Y + Nvidia A100) of the [Snelius cluster](https://www.surf.nl/en/services/snellius-the-national-supercomputer)
The number of initial agents for these simulations are as follows:
- Wolf-Sheep small: 1000 sheep, 500 wolves
- Wolf-Sheep large: 10000 sheep, 5000 wolves
- Bird-Flock small: 1000 birds
- Bird-Flock large: 10000 birds

| Model | Abmax | Agents.jl | Mesa |
| ----- | ----- | --------- | ---- |
| Wolf-Sheep small | 5X | X~140(ms) | 29X |
| Wolf-Sheep large | 60X | 60X~6420(ms) | >1hr |
| Bird-Flock small | 3Y | Y~126(ms) | 126Y |
| Bird-Flock large | 3Y | 17Y~2179(ms) | >1hr |

In Abmax, we can run multiple simulations in parallel because of automatic batching and vectorization. 
Here is a trend in running different number of wolf-sheep small models in parallel.

| Number of models | 10 | 20 | 50 | 100 | 200 | 500 |
| ----------------- | -- | -- | -- | --- | --- | --- |
| time taken (s) | 5.75 | 6.81 | 7.32 | 8.52 | 8.617 | 14.32 |

Note: All times that are reported, are exluding the model setup time.


# Tutorial
A basic tutorial on how to use Abmax is available [here](https://github.com/i-m-iron-man/abmax/blob/master/tutorials/getting_started.ipynb)


# Citation


