A Python library for Discrete Event and Stochastic Simulation
Project description
DESTLib
DESTLib is a Python library for Discrete Event Simulation (DES) and Discrete Stochastic Simulation (DST). It provides flexible tools to model, simulate, and analyze queueing systems and other event-driven processes, supporting both single-server and multi-server scenarios, as well as priority levels.
Features
-
DES (Discrete Event Simulation):
- Simulate queueing systems with customizable arrival and service time distributions.
- Support for multiple servers and priority levels.
- Built-in statistics and plotting for simulation results.
- Save and load simulation metadata and results.
-
DST (Discrete Stochastic Simulation):
- Generic simulation engine for stochastic processes.
- Customizable behaviors, argument ranges, and weighted random choices.
-
Time Unit Utilities:
- Convert between different time units (seconds, minutes, hours, etc.).
Installation
pip install destlib
Usage
Basic DES Example
from destlib import DES, uniform, TimeUnit
sim = (
DES()
.set_sample_size(30)
.set_time_between_distro(uniform, a=1, b=7)
.set_service_time_distro(uniform, a=1, b=7)
.set_seed(7122004)
.set_system_name("TollBooth")
.set_entity_name("Car")
.set_time_unit(TimeUnit.Min)
)
sim.set_num_servers(2)
sim.run()
sim.plot(v_lines=True)
print(sim.df.head())
Running Multiple Simulations
from destlib import run_simulations
for i, sim in enumerate(run_simulations(sim, 3)):
sim.set_num_servers(i + 1)
sim.run()
sim.plot()
Priority Levels Example
from matplotlib.pylab import poisson
from destlib import DES, uniform, TimeUnit
patients = (
DES()
.set_sample_size(30)
.set_time_between_distro(poisson, lam=8.0)
.set_service_time_distro(uniform, a=1, b=30)
.set_num_servers(3)
.set_levels(
levels=["Critical", "Severe", "Moderate"],
levels_prob=[0.2, 0.4, 0.4],
)
.set_seed(7122004)
.set_system_name("Hospital")
.set_entity_name("Patient")
.set_time_unit(TimeUnit.Min)
)
patients.run()
patients.plot()
print(patients.df.groupby("level")["wait_time"].mean())
patients.save_to("csv", True, True)
Outputs
Generated Data:
Some Statistics:
{
"mean_time_between": 8.333,
"mean_service_time": 13.633,
"mean_idle_time": 12.333,
"mean_waiting_time for each Patient": 0.933,
"mean_waiting_time for levels": {
"Critical": 0.143,
"Moderate": 1.0,
"Severe": 1.444
}
}
System Flow:
Modules
- destlib.des: DES simulation engine (DES)
- destlib.dst: DST simulation engine (DST)
- destlib.time_units: Time unit utilities (TimeUnit)
License
MIT License
For more details, see the code and docstrings in each module.
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 destlib-1.1.2.tar.gz.
File metadata
- Download URL: destlib-1.1.2.tar.gz
- Upload date:
- Size: 12.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b70cfad7b8f9a5c31033e752daf6e2d53a4bb3f4fc3f4bbaf10af809e9f7af8a
|
|
| MD5 |
0ef856de1d4fee8d8d8b5ed749ee81ea
|
|
| BLAKE2b-256 |
3cafff2b15773dfbfb6eb4d4612cbd8ca51cc682b7b466b3f68c092b8b8b4418
|
File details
Details for the file destlib-1.1.2-py3-none-any.whl.
File metadata
- Download URL: destlib-1.1.2-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c613600b7d7e413376fb8001d28ab2eff3d6c8b2a8bc2e5b73099700bbf3516d
|
|
| MD5 |
331249187d178bd0dd0998ba763ccff9
|
|
| BLAKE2b-256 |
ee43656f49c28a2cdd74f6d2de020c4a19fe36f527a658accef7b4f39d2a6cc9
|