Most-Queue
Queueing theory in Python: exact analytical solvers paired with discrete-event simulation — for 40+ models from M/M/1 to SRPT scheduling, vacations, negative customers and queueing networks.
Why Most-Queue?
- Analytics and simulation together. Nearly every analytical calculator ships with a paired discrete-event simulator, and the test suite cross-validates them against each other. You get fast exact numbers and a way to check them.
- Models you won't find elsewhere in open source: size-based scheduling analytics (SRPT, SJF, PSJF, SPJF with ML-style size predictions, FB/LAS), M/G/1 vacation models, negative customers (RCS / disasters), unreliable servers, multi-server phase-type systems solved by the Takahashi–Takami method (including CV < 1 via complex-fit H₂).
- Moments, not just means: waiting/sojourn time raw moments, state probabilities,
utilization — with a uniform
set_sources() / set_servers() / run()API across all models. - Pure Python + NumPy/SciPy, pip-installable, MIT license.
Installation
pip install most-queue
Requires Python ≥ 3.9. For network visualization you may also need the system graphviz package.
Quick start: theory vs simulation in 20 lines
from most_queue.theory.fifo.mmnr import MMnrCalc
from most_queue.sim.base import QsSim
# Analytical M/M/3 with a finite queue
calc = MMnrCalc(n=3, r=100)
calc.set_sources(l=2.0)
calc.set_servers(mu=1.0)
theory = calc.run()
# The same system, simulated
sim = QsSim(3)
sim.set_sources(2.0, "M")
sim.set_servers(1.0, "M")
experiment = sim.run(100_000)
print(f"Mean waiting time: theory {theory.w[0]:.3f} vs simulation {experiment.w[0]:.3f}")
# Mean waiting time: theory 0.444 vs simulation 0.448
Showcase: who pays for the scheduling discipline?
Computed by the library's own calculators — conditional slowdown E[T(x)]/x by job size
for FCFS, PS, FB (blind) and SRPT (size-aware):
See the executable comparison of 9 disciplines in
tutorials/disciplines_comparison.ipynb.
What's inside
| Family | Models | Method |
|---|---|---|
| Classic FIFO | M/M/c, M/M/c/r, Erlang B/C, M/G/1, GI/M/c, M/D/c, Eₖ/D/c, M/G/∞ | exact |
| Multi-server phase-type | M/H₂/c, H₂/M/c, H₂/H₂/c (CV < 1 via complex fit) | Takahashi–Takami |
| Size-based scheduling | M/G/1 SRPT, SJF, PSJF, SPJF (with size predictors), FB/LAS, PS, LCFS-PR | exact (Schrage–Miller, Mitzenmacher) |
| Priorities | M/G/1 PR/NP multi-class, M/G/c PR/NP, M/Ph/c PR | exact / invariant approximation |
| Vacations & warm-up | M/G/1 multiple vacations, N-policy, warm-up/cooling/delay (M/Ph/c) | Fuhrmann–Cooper, Takahashi–Takami |
| Negative customers | M/G/1 and M/G/c with RCS or disasters | exact / Takahashi–Takami |
| Reliability | M/G/1 with breakdowns & repairs | Avi-Itzhak–Naor |
| Matrix-analytic | MAP/PH/1, M/PH/1, PH/PH/1 — correlated (bursty) arrivals | QBD, logarithmic reduction |
| Retrial & abandonment | M/M/1 and M/G/1 retrial (orbit), Erlang-A (M/M/n+M) with staffing | exact / Falin–Templeton |
| GI/G approximations | GI/G/1, GI/G/m mean waiting time | Kingman, Krämer–Langenbach-Belz, Allen–Cunneen |
| Batch, impatience, closed | Mˣ/M/1, M/M/1+M, Engset | exact |
| Parallel service | Fork-Join, Split-Join | Markovian / order statistics |
| Networks | open networks, priority networks, networks with negative customers, routing optimization | decomposition |
Every model comes with a plain-language explanation and a diagram in the illustrated model catalog.
Documentation & tutorials
- 📖 Documentation — concepts, calculation and simulation guides (English; Russian versions available via in-page switchers)
- 🎓 Jupyter tutorials — from a first M/M/1 to Takahashi–Takami and SRPT
- 🗺 Development roadmaps — what's next (matrix-analytic MAP/PH stack, retrial queues, Erlang-A)
- 🧪 Tests — every model validated against simulation; run with
pytest -m "not slow"
Applications
Capacity planning for cloud services and data centers · call-center staffing · manufacturing lines · telecom traffic · healthcare resource planning · scheduling research (SRPT/LAS with ML size predictions).
Recent highlights
- 2026 — Matrix-analytic stack: PH distributions and MAPs (
most_queue.random.map_ph), QBD solver with logarithmic reduction, exact MAP/PH/1 / M/PH/1 / PH/PH/1 calculators, MAP and PH sources in the simulator; plus retrial queues (orbit) and Erlang-A abandonment with a staffing helper. Seetutorials/map_ph_correlation.ipynb. - 2026 — Wave of exact classics: Erlang B/C, M/G/∞, GI/G approximations, M/G/1 vacation models (multiple vacations, N-policy), PS, LCFS-PR, FB/LAS, unreliable server — each with a paired simulator and tests. Illustrated model catalog with generated diagrams.
- 2026 — Size-based scheduling analytics: SRPT / SJF / PSJF / SPJF with prediction models
(reproduces the Mitzenmacher–Shahout 2025 table in tests) +
SizeBasedQsSim. - 2026 (preprint) — Multi-server queues with negative customers via Takahashi–Takami: preprint & reproduction code.
- 2025 (paper) — Multi-channel system with warm-up, cooling and cooling delay: Lokhvitsky, Khabarov, Yakovlev, DOI 10.25791/aviakosmos.1.2025.1456.
Contributing
Issues and pull requests are welcome! Open an issue for bugs or model requests. Development conventions: docs/PROJECT.md, definition of done: docs/DOD.md.
Citation
If you use Most-Queue in research, please cite it (see CITATION.cff):
@software{most_queue,
author = {Khabarov, Roman},
title = {Most-Queue: queueing theory calculations and simulation in Python},
url = {https://github.com/xabarov/most-queue},
license = {MIT}
}
License
MIT © Roman Khabarov
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 most_queue-2.8.tar.gz.
File metadata
- Download URL: most_queue-2.8.tar.gz
- Upload date:
- Size: 44.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d2b108d50fbbf4d21626dac162d6b42ab74999ade84f30e02c2b5e401e989b0
|
|
| MD5 |
f76a8880128dad7eb4b4b31ea1a158b8
|
|
| BLAKE2b-256 |
e716501c271396b120f9ad2836ab628baaa1c4a7ef7a634d37e5f13bfe327df1
|
File details
Details for the file most_queue-2.8-py3-none-any.whl.
File metadata
- Download URL: most_queue-2.8-py3-none-any.whl
- Upload date:
- Size: 286.9 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 |
d8b4424e7eacd6eeb2aab0437828373a2865d992e52f360145f152be9c23b8c4
|
|
| MD5 |
b110414474d222ab8a6748a108138098
|
|
| BLAKE2b-256 |
6a7a2117a80561683d787e78c937df6eca5e4e279a820566247f468a8b7a81bb
|