A Discrete Event Simulation (DES) framework for modeling systems where state changes occur at discrete points in time.
Project description
DeSim (Discrete Event Simulator)
A Discrete Event Simulation (DES) framework for modeling systems where state changes occur at discrete points in time.
Description
to be added
Features
- 📦 OOP: Object-oriented paradigm was taken in mind in order to allow flexibility while modeling dynamic systems.
- ⏱️ Discrete time: Time updates are based on occurrences of events, and not on delta times.
- ⏩ Queue-based: Events are retrieved from a priority queue that sorts them based on their time of occurrence.
- 🍃 Lightweight: DeSim has no external dependencies.
Quick Example
from desim import DiscreteEvent, DiscreteEventQueue, run_to_end
#
# ...
#
class CustomerArrivalEvent(DiscreteEvent):
def __init__(self, t):
super().__init__(t)
def _run(self, env):
store, stats = env
if store.is_open():
store.customer_enters()
print(f"{store.customers=}")
next_arrival = CustomerArrivalEvent(self._after(stats.random_arrival_time()))
customer_done = CustomerDoneEvent(self._after(stats.random_shopping_time()))
return [next_arrival, customer_done]
else:
print("Oops, too late")
return []
#
# ...
#
store = Store()
stats = Stats(mean_arrival_time=1, mean_shopping_time=5)
queue = DiscreteEventQueue()
queue.add_events(
[
OpenStoreEvent(0),
ChangeArrivalTimeEvent(20, 0.5), # rush-hour
ChangeArrivalTimeEvent(45, 1.5), # end of rush-hour
CloseStoreEvent(60),
]
)
t = []
customers = []
def callback(_, __):
t.append(queue.t)
customers.append(store.customers)
run_to_end(queue, (store, stats), callback)
Installation
You can install DeSim using either PyPI or clone it from GitHub.
From PyPI (recommended):
pip install desim-python
From GitHub:
git clone https://github.com/larias95/desim-python.git
cd desim-python
pip install .
Examples
After installation you can run examples from the examples/ folder. E.g: python store_example.py.
You may need to install some dependencies before running the examples by using pip install -r requirements.txt from examples/ folder.
Links
to be added
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file desim_python-0.0.1.tar.gz.
File metadata
- Download URL: desim_python-0.0.1.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80c8766c5161bc6a925d2b0a2b48376bff22398f89cc16af8d09d5d867f870ab
|
|
| MD5 |
70961e36bf679430df250c796d6c5e51
|
|
| BLAKE2b-256 |
004ed5bda224cf482ada53b8c87fe32b1aaf1c89684acdbb4bd2293f67b2c227
|
File details
Details for the file desim_python-0.0.1-py3-none-any.whl.
File metadata
- Download URL: desim_python-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8b650f065e3a0542890d5e5ebb5e08038ed7ca990326995dd3debf6bc86ebc6
|
|
| MD5 |
378e24b14cbc3756bfb9a7987e1b0f2f
|
|
| BLAKE2b-256 |
9b4a35d96f8b877d22d4913ba4538e37725712a89d396a9d1be02a9cb24d537a
|