Skip to main content

Agent-based modeling framework for social systems and public health applications

Project description

ABM Framework

PyPI version Python 3.9+ License: MIT

A service-centric agent-based modeling framework for social systems and public health applications.

Features

Service-Centric Architecture - Agents are data containers, services contain all behavior logic 🔄 Event-Driven - Flexible event scheduling for complex interactions 🕸️ Network-Based - Built-in support for social networks using NetworkX 🎯 Zero Circular Dependencies - Clean, maintainable architecture 📊 Research-Ready - Designed for epidemiology and public health research 🚀 Extensible - Easy to add custom agents, services, and behaviors

Installation

pip install abm-framework

Quick Example

from layer1_core.entities.agent import Agent
from layer1_core.managers.service import Service
from layer2_simulation.world_builder import WorldBuilder
from layer2_simulation.single_runner import SingleRunner
from layer1_core.managers.schedule import Schedule

# 1. Define agents (data only)
class Student(Agent):
    def __init__(self, agent_id, mood=0.5):
        super().__init__(agent_id)
        self.mood = mood

# 2. Define services (behavior logic)
class InteractionService(Service):
    def interact(self, student1, student2):
        student1.mood += 0.1
        student2.mood += 0.1

    def schedule_interactions(self, schedule, students, steps):
        for step in range(1, steps):
            s1, s2 = random.sample(students, 2)
            schedule.add_event(
                step=step,
                event=lambda: self.interact(s1, s2)
            )

# 3. Build world
class SchoolWorld(WorldBuilder):
    def __init__(self, params):
        super().__init__(params)
        self.schedule = Schedule()

        # Register services
        self.interaction_service = InteractionService()
        self.services.register(self.interaction_service)

        # Create agents
        self.students = [Student(f"s{i}") for i in range(params['n_students'])]

    def setup_events(self):
        self.interaction_service.schedule_interactions(
            self.schedule, self.students, 1000
        )

# 4. Run simulation
world = SchoolWorld({'n_students': 50})
world.setup_events()

runner = SingleRunner(world)
runner.run(stopping_condition=lambda s: s.get_current_step() >= 1000)

print(f"Average mood: {sum(s.mood for s in world.students) / len(world.students):.2f}")

Architecture

The framework follows a layered service-centric architecture:

Core Principles

  1. Agents are data containers - Hold state (age, mood, etc.) with no behavior methods
  2. Services contain all behavior - All logic, interactions, and computations
  3. Services schedule events - Only services add events to the schedule
  4. Zero circular dependencies - Clean imports and dependencies

Layers

  • Layer 1: Core - Agents, Services, Networks, Schedules
  • Layer 2: Simulation - WorldBuilder, SingleRunner, Parameters
  • Layer 3: Parallel - Batch execution (planned)
  • Layer 4: Analysis - Parameter sweeps, calibration, workflows (planned)

Documentation

Use Cases

Perfect for modeling:

  • 🏥 Disease transmission and interventions
  • 🏫 Educational systems and outcomes
  • 🏘️ Neighborhood effects and segregation
  • 👥 Social network dynamics
  • 📊 Policy impact analysis

Requirements

  • Python 3.9+
  • NetworkX 3.0+

Contributing

Contributions welcome! Please read our contributing guidelines.

Citation

If you use this framework in your research, please cite:

@software{abm_framework_2026,
  title = {ABM Framework: Service-Centric Agent-Based Modeling},
  author = {Your Name},
  year = {2026},
  url = {https://github.com/yourusername/abm-framework}
}

License

MIT License - see LICENSE file for details.

Support


Note: This is an early-stage framework under active development. APIs may change.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

abm_framework-0.1.0.tar.gz (82.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

abm_framework-0.1.0-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file abm_framework-0.1.0.tar.gz.

File metadata

  • Download URL: abm_framework-0.1.0.tar.gz
  • Upload date:
  • Size: 82.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for abm_framework-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a08f5751ea1a571f907b8a576b55805b8e8f6fc77512c95610e4869fdfefb30e
MD5 274d2c90de4b9cd0221577fa043079b8
BLAKE2b-256 5d12cf540ee63fbd2c73ee82f60d6e0aeef0c6b7af5453bcfc9f8e5d85524668

See more details on using hashes here.

File details

Details for the file abm_framework-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: abm_framework-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for abm_framework-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7c3e1f9023acc1117f07163f242258110bf0f063740947b9cdc3a68638b2f494
MD5 dbd3da274cec2472d6e21bc50d9a5d57
BLAKE2b-256 8debcd040bc388e60174346b49f24585afbee55d9abdbddf86521e5543d087ab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page