Skip to main content

Discrete event simulation in using synchronous Python.

Project description

DESimpy

A synchronous discrete event simulation (DES) framework in Python (DESimpy).

Overview

DESimPy provides the core components of DES.

Processes in DESimPy are defined by methods owned by Python objects inherited from the Event abstract base class. These processes can be used to model system-level or component level changes in a modelled system. Such systems might include customers or patients flowing through services, vehicles in traffic, or agents competing in games.

DESimPy implements time-to-event simulation where the next event in a schedule is processed next regardless of the amount of time in the simulated present to that event. This constrasts with "time sweeping" in which a step size is used to increment foreward in time. It is possible to combine time-to-event with time sweeping (see Palmer & Tian 2021), however this package does not provide any explicit support for that.

Installation

pip install desimpy

Quickstart

Here is a small example to show the basic logic. This example is the simple clock process presented in the SimPy documentation.

from desimpy import EventScheduler

def clock(env, name, tick) -> None:
    """Clock simulation process."""

    def action() -> None:
        """Schedule next tick of the clock."""
        print(name, env.current_time)
        env.timeout(tick, action)

    env.timeout(0, action=action)

env = EventScheduler()

clock(env, "fast", 0.5)
clock(env, "slow", 1)

env.run_until_max_time(2, logging=False)

Design

  • Avoid performance overhead of coroutines.
  • Do not change the past (i.e. event log should not be changed during simulation).
  • WET when performant.
    • While tongue-and-cheek, some repetition in this project is intentional to improve performance.
    • Core components are small, so repetition is not as difficult to maintain.
    • Projects based on DESimpy are not at all required to follow this pattern (and probably shouldn't if they are sufficiently complicated or need to be indefinitely extended).
    • For some amusement, see The Wet Codebase.

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

desimpy-0.46.5.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

desimpy-0.46.5-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file desimpy-0.46.5.tar.gz.

File metadata

  • Download URL: desimpy-0.46.5.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for desimpy-0.46.5.tar.gz
Algorithm Hash digest
SHA256 34bfd8aecf12833f506e236de0134a1c6e61ebd2af08b805fd5326459b0486ce
MD5 75b84c4c89bfc7c854e356290dad619f
BLAKE2b-256 ce140a1fc02d6e20d0e08d718176b67d6171b128bda78f264caf8d65f59fc2cc

See more details on using hashes here.

File details

Details for the file desimpy-0.46.5-py3-none-any.whl.

File metadata

  • Download URL: desimpy-0.46.5-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for desimpy-0.46.5-py3-none-any.whl
Algorithm Hash digest
SHA256 dd37a3be5f11231f22c9f30a5254ffe6ac43ba7972f74a24330117363927dba6
MD5 8266cd36f60e5d665abcd78bb66745fd
BLAKE2b-256 e2ba1c8b721cddf263e06d624843e7456fb25a879c895be481932014096460d0

See more details on using hashes here.

Supported by

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