| Name | DESimpy JSON |
| Version |
0.46.5
JSON |
| download |
| home_page | None |
| Summary | Discrete event simulation in using synchronous Python. |
| upload_time | 2024-10-20 23:24:01 |
| maintainer | None |
| docs_url | None |
| author | None |
| requires_python | >=3.7 |
| license | Apache 2.0 |
| keywords |
|
| VCS |
|
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
# DESimpy
A synchronous [discrete event simulation](https://en.wikipedia.org/wiki/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](https://www.semanticscholar.org/paper/Implementing-hybrid-simulations-that-integrate-in-Palmer-Tian/bea73e8d6c828e15290bc4f01c8dd1a4347c46d0)), however this package does not provide any explicit support for that.
## Installation
```bash
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](https://simpy.readthedocs.io/en/stable/index.html).
```python
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](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself#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](https://www.deconstructconf.com/2019/dan-abramov-the-wet-codebase).
Raw data
{
"_id": null,
"home_page": null,
"name": "DESimpy",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": "galenseilis <galen.seilis@seilis.ca>",
"download_url": "https://files.pythonhosted.org/packages/ce/14/0a1fc02d6e20d0e08d718176b67d6171b128bda78f264caf8d65f59fc2cc/desimpy-0.46.5.tar.gz",
"platform": null,
"description": "# DESimpy\nA synchronous [discrete event simulation](https://en.wikipedia.org/wiki/Discrete-event_simulation) (DES) framework in Python (DESimpy).\n\n## Overview\n\nDESimPy provides the core components of DES.\n\nProcesses 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.\n\nDESimPy 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](https://www.semanticscholar.org/paper/Implementing-hybrid-simulations-that-integrate-in-Palmer-Tian/bea73e8d6c828e15290bc4f01c8dd1a4347c46d0)), however this package does not provide any explicit support for that.\n\n## Installation\n\n```bash\npip install desimpy\n```\n\n## Quickstart\n\nHere is a small example to show the basic logic. This example is the simple clock process presented in the [SimPy documentation](https://simpy.readthedocs.io/en/stable/index.html).\n\n```python\nfrom desimpy import EventScheduler\n\ndef clock(env, name, tick) -> None:\n \"\"\"Clock simulation process.\"\"\"\n\n def action() -> None:\n \"\"\"Schedule next tick of the clock.\"\"\"\n print(name, env.current_time)\n env.timeout(tick, action)\n\n env.timeout(0, action=action)\n\nenv = EventScheduler()\n\nclock(env, \"fast\", 0.5)\nclock(env, \"slow\", 1)\n\nenv.run_until_max_time(2, logging=False)\n```\n\n# Design\n\n- Avoid performance overhead of coroutines.\n- Do not change the past (i.e. event log should not be changed during simulation).\n- [WET](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself#WET) when performant.\n - While tongue-and-cheek, some repetition in this project is intentional to improve performance.\n - Core components are small, so repetition is not as difficult to maintain.\n - 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).\n - For some amusement, see [The Wet Codebase](https://www.deconstructconf.com/2019/dan-abramov-the-wet-codebase).\n",
"bugtrack_url": null,
"license": "Apache 2.0",
"summary": "Discrete event simulation in using synchronous Python.",
"version": "0.46.5",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e2ba1c8b721cddf263e06d624843e7456fb25a879c895be481932014096460d0",
"md5": "8266cd36f60e5d665abcd78bb66745fd",
"sha256": "dd37a3be5f11231f22c9f30a5254ffe6ac43ba7972f74a24330117363927dba6"
},
"downloads": -1,
"filename": "desimpy-0.46.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8266cd36f60e5d665abcd78bb66745fd",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 10658,
"upload_time": "2024-10-20T23:24:00",
"upload_time_iso_8601": "2024-10-20T23:24:00.192230Z",
"url": "https://files.pythonhosted.org/packages/e2/ba/1c8b721cddf263e06d624843e7456fb25a879c895be481932014096460d0/desimpy-0.46.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ce140a1fc02d6e20d0e08d718176b67d6171b128bda78f264caf8d65f59fc2cc",
"md5": "75b84c4c89bfc7c854e356290dad619f",
"sha256": "34bfd8aecf12833f506e236de0134a1c6e61ebd2af08b805fd5326459b0486ce"
},
"downloads": -1,
"filename": "desimpy-0.46.5.tar.gz",
"has_sig": false,
"md5_digest": "75b84c4c89bfc7c854e356290dad619f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 14138,
"upload_time": "2024-10-20T23:24:01",
"upload_time_iso_8601": "2024-10-20T23:24:01.873418Z",
"url": "https://files.pythonhosted.org/packages/ce/14/0a1fc02d6e20d0e08d718176b67d6171b128bda78f264caf8d65f59fc2cc/desimpy-0.46.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-20 23:24:01",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "desimpy"
}