Skip to main content

Discrete-event simulation framework

Project description

DSSim — Discrete-Event Simulation Framework

DSSim is a Python framework for discrete-event simulation (DES). It advances time by jumping from one scheduled event to the next, making it well-suited for modelling systems where behavior is driven by events: hardware protocols, queuing systems, resource contention, multi-process coordination, and more.

Full documentation: majvan.github.io/DSSim

Who It Is For

DSSim targets a wide audience — not just software engineers:

  • Hardware engineers — describe bus protocols, pipeline stages, and signal flows using component endpoints wired together, close to how hardware is assembled.
  • Scientists and researchers — model experiments, queuing phenomena, or multi-agent systems without writing a scheduler from scratch.
  • Software engineers — build process-oriented models using Python generators and coroutines with familiar async idioms.

Key Features

  • Two layer profilesLiteLayer2 for maximum throughput; PubSubLayer2 for routing-rich pub/sub with delivery tiers, condition filtering, and composable filter circuits.
  • Any Python object as an event — no base class, no wrapping required.
  • Timeout on every blocking callwait, get, put, sleep all accept timeout; None is the universal "nothing happened" sentinel.
  • Condition filtering — wake a process only when an event matches a predicate, a filter, a circuit of filters (AND/OR/reset), or a future's completion. No spurious wakeups in PubSubLayer2.
  • Publisher-subscriber with tiers — PRE (observe), CONSUME (first-accept wins), POST_HIT, POST_MISS.
  • Built-in componentsDSQueue, DSResource, DSPriorityResource, DSContainer, DSState, DSTimer, and hardware models (UART, etc.).
  • Probes and statistics — attach QueueStatsProbe / ResourceStatsProbe without modifying component code; custom probe types supported.
  • SimPy / salabim / asyncio shims — migrate existing models without rewriting; migrated code and native DSSim code share the same event loop.
  • No external dependencies — stdlib only at the core.

Quick Start

pip install dssim
from dssim import DSSimulation, LiteLayer2

sim = DSSimulation(layer2=LiteLayer2)

async def producer():
    for i in range(3):
        print(f"t={sim.time}  produce {i}")
        await sim.wait(2)

async def consumer():
    for _ in range(3):
        event = await sim.wait(3)
        print(f"t={sim.time}  tick")

sim.schedule(0, producer())
sim.schedule(0, consumer())
sim.run(until=10)

For local development from source, use editable mode:

pip install -e .

More examples in examples/lite/ and examples/pubsub/.

Choosing a Profile

Situation Profile
Small or exploratory project PubSubLayer2 (default)
Debugging, probes, condition filtering needed PubSubLayer2
Maximum throughput is the primary goal LiteLayer2
Unsure Start with LiteLayer2; switch when you hit the first blocker
sim = DSSimulation()                   # PubSubLayer2 — default
sim = DSSimulation(layer2=LiteLayer2)  # LiteLayer2

Switching is a one-line change at construction time.

Documentation

Full documentation: majvan.github.io/DSSim

License

Apache 2.0

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

dssim-1.2.0.tar.gz (136.8 kB view details)

Uploaded Source

Built Distribution

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

dssim-1.2.0-py3-none-any.whl (111.2 kB view details)

Uploaded Python 3

File details

Details for the file dssim-1.2.0.tar.gz.

File metadata

  • Download URL: dssim-1.2.0.tar.gz
  • Upload date:
  • Size: 136.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for dssim-1.2.0.tar.gz
Algorithm Hash digest
SHA256 6c3cd61f96a2d7969142306d75429ffb44cbbf5f8c5c361126b11677b95aaf2e
MD5 a509696e76b5c458888826bdeb45cb0a
BLAKE2b-256 6a4951b60fcf2321da6a74f5fced4289556af9d7468513577de9efcb49e2a0e3

See more details on using hashes here.

File details

Details for the file dssim-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: dssim-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 111.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for dssim-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 30c5bcd475b9eded87f15807f1d56e24c1ca856be83cd6d84c30c5fdad1d4a5a
MD5 1622ef30fc7dc13e6b9af07bb0b52be2
BLAKE2b-256 466426d25962f42b760f48b3e45d68400787c68441074a11cb11d1a56cfa3523

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