domains / science / discrete-event-simulation / simpy

simpy

Skill card

combined

The K-Dense-AI copy is a distinct, more rigorous methodology skill (version 1.6) that adds installation pinning, bounded execution guards, RNG separation, and validation steps not present in the others. The other three copies (zLanqing, foryourhealth111, FreedomIntelligence) are near-identical reproductions of a simpler API reference, with foryourhealth111 adding a routing boundary. Because the K-Dense copy contains material steps and constraints the others lack, and the others contain a routing boundary the K-Dense copy lacks, crowning one would hide a real alternative.

Repositories

RepositoryPath
zLanqing/codex-claude-academic-skillsscientific-toolkit-skill/references/scientific-skills/simpy/SKILL.md
K-Dense-AI/scientific-agent-skillsskills/simpy/SKILL.md
foryourhealth111-pixel/Vibe-Skillsbundled/skills/simpy/SKILL.md
FreedomIntelligence/OpenClaw-Medical-Skillsskills/simpy/SKILL.md

Other copies

RoleRepositoryPath
peerzLanqing/codex-claude-academic-skillsscientific-toolkit-skill/references/scientific-skills/simpy/SKILL.md
peerK-Dense-AI/scientific-agent-skillsskills/simpy/SKILL.md
peerforyourhealth111-pixel/Vibe-Skillsbundled/skills/simpy/SKILL.md
peerFreedomIntelligence/OpenClaw-Medical-Skillsskills/simpy/SKILL.md

Combined skill

---
name: simpy
description: Process-based discrete-event simulation framework in Python. Use for building, inspecting, and analyzing bounded simulations with processes, queues, and resources.
license: MIT
---

# SimPy - Discrete-Event Simulation

## Routing Boundary
Use this skill only for SimPy or explicit discrete-event simulation work. Do not use for generic simulation, Monte Carlo, or agent-based modeling unless SimPy is explicitly requested.

## Setup
1. Create a reproducible environment: `uv venv --python 3.13` and `uv pip install "simpy==4.1.2"`.
2. Verify the version: `python -c "import importlib.metadata; print(importlib.metadata.version('simpy'))"`.

## Model Workflow
1. **Define Purpose:** State the decision, system boundary, entities, and time units.
2. **Conceptual Model:** Record assumptions, distributions, and routing logic.
3. **Implement Generators:** Define processes as Python generator functions using `yield`.
4. **Bound Execution:** Use explicit time and entity caps. Never call `env.run()` on endless processes without a guard.
5. **Separate RNGs:** Use local `random.Random` instances for distinct stochastic sources.
6. **Instrument:** Observe state after transitions and test that monitoring does not alter event order.
7. **Validate:** Test deterministic edge cases and conservation identities.

## Core Concepts
- **Environment:** `simpy.Environment()` manages the simulation clock.
- **Processes:** Functions with `yield` statements. Start with `env.process(func())`.
- **Resources:** Use `simpy.Resource` for capacity limits, `simpy.Container` for bulk materials, and `simpy.Store` for object storage.

## Minimal Bounded Example
```python
import random
import simpy

HORIZON = 480.0
arrival_rng = random.Random(101)
env = simpy.Environment()
server = simpy.Resource(env, capacity=2)

def customer():
    with server.request() as req:
        yield req
        yield env.timeout(arrival_rng.expovariate(1 / 6.0))

def arrivals():
    for _ in range(10_000):
        if env.now >= HORIZON: return
        yield env.timeout(arrival_rng.expovariate(1 / 4.0))
        env.process(customer())

env.process(arrivals())
env.run(until=HORIZON)
```