本文へスキップ
Skillpedia
分析とスプレッドシート51k · #3574

simpy

できること

SimPyは、待ち行列や生産ラインなど、時間の流れとともに進行するシステムのシミュレーションを作成するためのツールです。こうしたシステムの仕組みを理解し、起こりうる問題を予測するのに役立ちます。

使う場面

  • ✓銀行の待ち時間をシミュレーションしたいとき。
  • ✓工場での製品の流れをモデル化したいとき。
  • ✓コンピュータネットワークのトラフィックを分析したいとき。

スキルのリンク

https://github.com/K-Dense-AI/scientific-agent-skills/blob/main/skills/simpy/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/K-Dense-AI/scientific-agent-skills/blob/main/skills/simpy/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“5分ごとにお客さんが到着し、対応に平均3分かかる窓口の待ち行列をシミュレーションしてください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

まず、起こる出来事(お客さんの到着など)と、それが利用可能なリソース(窓口の担当者など)とどのように関わるかを記述します。SimPyが出来事の順序や発生するタイミングを管理します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

SimPy

Scope

Use this skill for process-based discrete-event models where active entities yield events and contend for resources: queues, production systems, logistics, networks, service operations, inventory, and other event-driven systems.

SimPy supplies an event scheduler and modeling primitives. It does not choose a scientifically valid conceptual model, input distribution, warm-up, run length, replication count, estimand, or causal interpretation. Treat those as simulation-study methodology, not SimPy API behavior.

Current release and installation

Reviewed 2026-10-01 against current official documentation and the released source:

  • Latest stable: SimPy 4.1.2, released on PyPI 2026-05-24; source tag 4.1.2 points to commit f4381649.
  • Package metadata requires Python >=3.8 and classifies CPython 3.8-3.14 plus PyPy. SimPy has no runtime dependencies.
  • 4.1.2 adds Python 3.13/3.14 support and modern-interpreter test fixes.
  • Upstream and this skill are MIT-licensed.

Create a reproducible environment:

uv venv --python 3.13
source .venv/bin/activate
uv pip install "simpy==4.1.2"
python -c "import importlib.metadata; print(importlib.metadata.version('simpy'))"

Do not silently substitute the latest documentation build: it may describe an unreleased development revision. Use the versioned 4.1.2 links in references/sources.md.

Model workflow

  1. Define purpose and estimands. State the decision/question, system boundary, entities, resources, state, outputs, time units, and terminating event or steady-state target.
  2. Write a conceptual model first. Record assumptions, distributions, routing, priorities, initial conditions, and omitted mechanisms.
  3. Implement generators. A SimPy process is an event-yielding Python generator. Register the generator object with env.process(...).
  4. Bound execution. Give every production run explicit time, entity, event, and replication caps. Never call env.run() on a model containing an endless process. A time horizon alone cannot stop an endless yield env.timeout(0) loop: events keep running at the same simulation time. Add an event-count or no-time-progress guard, and wait on state-change events instead of zero-delay busy polling.
  5. Separate random streams. Use local RNG instances for logically distinct stochastic sources; retain a seed manifest.
  6. Instrument deliberately. Observe state after the transition of interest, close time-weighted intervals at the horizon, and test that monitoring does not alter event order.
  7. Verify and validate. Test deterministic edge cases, conservation identities, traces, queue discipline, and analytical benchmarks; compare against system or expert evidence for the stated purpose.
  8. Run independent replications. Make intervals from replication-level estimates, not correlated entities within one run.
  9. Report limitations. Include initialization, unfinished entities, run length, seeds/streams, precision, sensitivity, and validation evidence. Never convert simulation association into a causal claim.

Read references/simulation-methodology.md before making inferential claims.

Minimal bounded model

import random
import simpy

HORIZON = 480.0
arrival_rng = random.Random(101)
service_rng = random.Random(202)
env = simpy.Environment()
server = simpy.Resource(env, capacity=2)
completed = []

def customer(arrival):
    with server.request() as request:
        yield request
        wait = env.now - arrival
        yield env.timeout(service_rng.expovariate(1 / 6.0))
    completed.append((env.now, wait))

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

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

The numeric horizon is half-open: normal events scheduled exactly at 480.0 are not processed. Report unfinished entities rather than silently treating them as completed observations.

Core semantics

Environment and deterministic ordering

Environment is single-threaded. The queue is ordered by simulation time, event priority, then a strictly increasing event ID. Same-time, same-priority events are therefore processed FIFO in scheduling order. Model processes may represent

…

よくある質問

SimPyの「process」とは何ですか?

processは、シミュレーション上のシステムで起こる一連の動作のことです。例えば、お客さんが列に並び、その後対応を受ける流れなどが該当します。

SimPyはどうやって出来事が起こるタイミングを把握するのですか?

「イベントスケジューラ」を使います。これは今後のすべての動作を管理し、正しい時間順に実行します。

同時に起こる出来事もシミュレーションできますか?

はい、同時に発生する複数の出来事や相互作用をモデル化できます。ただし、内部では整理された方法で一つずつ処理されます。

詳細

作者による元の説明

Builds, inspects, tests, and analyzes bounded process-based discrete-event simulations with SimPy. Use for event scheduling, resource queues, interrupts, monitoring, independent replications, warm-up, and reproducible output analysis.

repo: K-Dense-AI/scientific-agent-skills

人気

GitHubのスター
51k
ランキング
#3574
ライセンス
MIT
更新日
2026/10/15

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル