Skip to content
Automation
Skill

/simpy

Process-based discrete-event simulation framework in Python. Use this skill when building simulations of systems with processes, queues, resources, and time-based events such as manufacturing systems, service operations, network traffic, logistics, or any system where entities

From plugin
vibe-skills
2.7k200 skills8 agents3 commands
Install
$ npx -y skills add foryourhealth111-pixel/Vibe-Skills --skill simpy --agent claude-code

How it fires

How this skill gets triggered: by you, by Claude, or both.

  • Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
  • You can call itInvoke it directly when you want it.
  • Slash command/simpy

Context preview

The summary Claude sees to decide when to auto-load this skill.

Process-based discrete-event simulation framework in Python. Use this skill when building simulations of systems with processes, queues, resources, and time-based events such as manufacturing systems, service operations, network traffic, logistics, or any system where entities

SKILL.md

simpy.SKILL.md
name: simpy
description: Process-based discrete-event simulation framework in Python. Use this skill when building simulations of systems with processes, queues, resources, and time-based events such as manufacturing systems, service operations, network traffic, logistics, or any system where entities interact with shared resources over time.
license: MIT license
metadata:
    skill-author: K-Dense Inc.

SimPy - Discrete-Event Simulation

Routing Boundary

Use this skill only for SimPy or explicit discrete-event simulation work involving SimPy environments, resources, processes, queues, and event scheduling. Do not use it for generic simulation, Monte Carlo work, agent-based modeling, physics simulation, animation, or SymPy symbolic math unless the user explicitly asks for SimPy.

Overview

SimPy is a process-based discrete-event simulation framework based on standard Python. Use SimPy to model systems where entities (customers, vehicles, packets, etc.) interact with each other and compete for shared resources (servers, machines, bandwidth, etc.) over time.

**Core capabilities:**

  • Process modeling using Python generator functions
  • Shared resource management (servers, containers, stores)
  • Event-driven scheduling and synchronization
  • Real-time simulations synchronized with wall-clock time
  • Comprehensive monitoring and data collection

When to Use This Skill

Use the SimPy skill when:

1. **Modeling discrete-event systems** - Systems where events occur at irregular intervals 2. **Resource contention** - Entities compete for limited resources (servers, machines, staff) 3. **Queue analysis** - Studying waiting lines, service times, and throughput 4. **Process optimization** - Analyzing manufacturing, logistics, or service processes 5. **Network simulation** - Packet routing, bandwidth allocation, latency analysis 6. **Capacity planning** - Determining optimal resource levels for desired performance 7. **System validation** - Testing system behavior before implementation

**Not suitable for:**

  • Continuous simulations with fixed time steps (consider SciPy ODE solvers)
  • Independent processes without resource sharing
  • Pure mathematical optimization (consider SciPy optimize)

Quick Start

Basic Simulation Structure

import simpy

def process(env, name):
    """A simple process that waits and prints."""
    print(f'{name} starting at {env.now}')
    yield env.timeout(5)
    print(f'{name} finishing at {env.now}')

# Create environment
env = simpy.Environment()

# Start processes
env.process(process(env, 'Process 1'))
env.process(process(env, 'Process 2'))

# Run simulation
env.run(until=10)

Resource Usage Pattern

import simpy

def customer(env, name, resource):
    """Customer requests resource, uses it, then releases."""
    with resource.request() as req:
        yield req  # Wait for resource
        print(f'{name} got resource at {env.now}')
        yield env.timeout(3)  # Use resource
        print(f'{name} released resource at {env.now}')

env = simpy.Environment()
server = simpy.Resource(env, capacity=1)

env.process(customer(env, 'Customer 1', server))
env.process(customer(env, 'Customer 2', server))
env.run()

Core Concepts

1. Environment

The simulation environment manages time and schedules events.

import simpy

# Standard environment (runs as fast as possible)
env = simpy.Environment(initial_time=0)

# Real-time environment (synchronized with wall-clock)
import simpy.rt
env_rt = simpy.rt.RealtimeEnvironment(factor=1.0)

# Run simulation
env.run(until=100)  # Run until time 100
env.run()  # Run until no events remain

2. Processes

Processes are defined using Python generator functions (functions with `yield` statements).

def my_process(env, param1, param2):
    """Process that yields events to pause execution."""
    print(f'Starting at {env.now}')

    # Wait for time to pass
    yield env.timeout(5)

    print(f'Resumed at {env.now}')

    # Wait for another event
    yield env.timeout(3)

    print(f'Done at {env.now}')
    return 'result'

# Start the process
env.process(my_process(env, 'value1', 'value2'))

3. Events

Events are the fundamental mechanism for process synchronization. Processes yield events and resume when those events are triggered.

**Common event types:**

  • `env.timeout(delay)` - Wait for time to pass
  • `resource.request()` - Request a resource
  • `env.event()` - Create a custom event
  • `env.process(func())` - Process as an event
  • `event1 & event2` - Wait for all events (AllOf)
  • `event1 | event2` - Wait for any event (AnyOf)

Resources

SimPy provides several resource types for different scenarios. For comprehensive details, see `references/resources.md`.

Resource Types Summary

| Resource Type | Use Case | |---------------|----------| | Resource | Limited capacity (servers, machines) | | PriorityResource | Priority-based queuing | | PreemptiveResource | High-priority can interrupt low-priority | | Container | Bulk materials (fuel, water) | | Store | Python object storage (FIFO) | | FilterStore | Selective item retrieval | | PriorityStore | Priority-ordered items |

Quick Reference

import simpy

env = simpy.Environment()

# Basic resource (e.g., servers)
resource = simpy.Resource(env, capacity=2)

# Priority resource
priority_resource = simpy.PriorityResource(env, capacity=1)

# Container (e.g., fuel tank)
fuel_tank = simpy.Container(env, capacity=100, init=50)

# Store (e.g., warehouse)
warehouse = simpy.Store(env, capacity=10)

Common Simulation Patterns

Pattern 1: Customer-Server Queue

import simpy
import random

def customer(env, name, server):
    arrival = env.now
    with server.request() as req:
        yield req
        wait = env.now - arrival
        print(f'{name} waited {wait:.2f}, served at {env.now}')
        yield env.timeout(random.uniform(2, 4))

def customer_generator(env, server):
Read more
Ships withvibe-skills

VibeSkills is a general-purpose Skill that automatically routes local Skills and intelligently orchestrates harness workflows.

Get the whole plugin

Other skills on vibe-skills.