| name | simpy-sim |
| description | Use when driving SimPy (process-based discrete-event simulation framework in pure Python) via Python scripts — queueing systems, manufacturing lines, network protocols, hospital flow, anything modeled as processes that wait on resources / timeouts / events — through sim runtime one-shot execution. |
simpy-sim
You are connected to SimPy via sim-cli.
SimPy is the canonical Python DES (discrete-event simulation) framework.
Process-based: simulation logic written as Python generator functions
that yield simpy events. Pure Python, no compiled deps.
Pip-installable (pip install simpy).
Scripts are plain .py:
import simpy
def car(env):
while True:
yield env.timeout(5)
print(f'arrived at {env.now}')
env = simpy.Environment()
env.process(car(env))
env.run(until=20)
Same subprocess driver mode as PyBaMM / PyMFEM.
base/ — always relevant
| Path | What's there |
|---|
base/reference/workflow.md | Environment → process generators → resources → run. |
base/reference/resources.md | Resource / Container / Store / PriorityResource. |
base/reference/events.md | timeout / event / process / all_of / any_of. |
base/snippets/01_mm1.py | Verified M/M/1 queue E2E. |
base/known_issues.md | Generators not coroutines, env.now is float, statistical noise. |
sdk/4/ — SimPy 4.x
sdk/4/notes.md — version-specific surface notes.
Hard constraints
- Process functions are generators, not coroutines. Use
yield env.timeout(...),
yield env.process(other(env)), yield resource.request(), etc. NOT await.
env.run(until=T) is the entry point. Without until, it runs
forever (until no more events are scheduled).
- All time arithmetic is in arbitrary units — pick consistent units
(seconds, hours, minutes) and document them.
- Acceptance != "ran without error". Always run for enough time
that statistics converge (rule of thumb: >= 10000 events) and
validate against analytical (M/M/1 L = ρ/(1-ρ)) or against a
simpler reference model.
- Seed
random for reproducibility: random.seed(42).
- Print results as JSON on the last stdout line.
Required protocol
- Gather inputs:
- Category A: processes / arrival rate / service distribution /
resource capacities / acceptance criterion (queue length, throughput,
utilization, ...).
- Category B: simulation horizon, RNG seed, warm-up period.
sim check simpy.
- Write
.py per base/reference/workflow.md.
sim lint script.py.
sim run script.py --solver simpy.
- Validate JSON.