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 interact with shared resources over time.

Install

Hot:5

Download and extract to your skills directory

Copy command and send to AI Agent for auto-install:

Download and install this skill https://openskills.cc/api/download?slug=k-dense-ai-skills-simpy&locale=en&source=copy

SimPy - Python Discrete-Event Simulation Framework

Skills Overview


SimPy is a process-based discrete-event simulation framework built on standard Python. It is used to model systems in which entities interact and compete for shared resources over time. It supports simulation analysis for a wide range of scenarios, including manufacturing systems, service operations, network traffic, and logistics.

Applicable Scenarios

1. Manufacturing and Logistics System Simulation


Model production lines, machine scheduling, inventory management, and logistics networks. Analyze equipment utilization, production bottlenecks, and system throughput, and optimize resource allocation and production processes.

2. Service Operations and Queue Analysis


Simulate service scenarios such as call centers, emergency departments, and retail checkout. Study customer arrival patterns, waiting times, staffing levels, and capacity planning to improve service efficiency and customer experience.

3. Network and Communication System Modeling


Simulate network traffic, packet routing, bandwidth allocation, and delay analysis. Test network protocol performance, evaluate system capacity, and optimize network architecture design.

Core Features

1. Process Modeling and Event Scheduling


Use Python generator functions to define process logic. Implement event-driven scheduling via yield statements, supporting timeout waits, resource requests, custom events, and synchronization between processes. This enables flexible modeling of complex system behavior.

2. Multi-Type Resource Management


Provides multiple resource types, such as Resource (servers, machines), PriorityResource (priority queues), PreemptiveResource (preemptive), Container (bulk materials), and Store (object storage). These meet different systems’ needs for resource contention and sharing.

3. Monitoring and Data Collection


Supports real-time tracking of resource status, queue lengths, waiting times, and other metrics. Offers monkey patching, event tracing, and statistical collection tools. Data can be exported to CSV for in-depth analysis, facilitating performance evaluation and optimization decisions.

Frequently Asked Questions

What types of systems is SimPy suitable for simulating?


SimPy is designed specifically for discrete-event systems. It is suitable for systems where event times are irregular, there is resource contention, and queue behavior needs to be analyzed. Typical use cases include manufacturing systems, service operations, network communications, logistics and transportation, and computer system scheduling. It is not suitable for continuous simulation that requires fixed time steps (recommended: SciPy ODE solvers) or for independent process simulation with no shared resources.

How can I collect and analyze statistical data in SimPy?


SimPy provides multiple monitoring approaches: use ResourceMonitor to track resource utilization, queue lengths, and waiting times; record custom metrics using state variables; use event tracing to capture system behavior; and use statistical tools to automatically compute metrics such as means, maxima, and throughput. Data can be exported in CSV format for further analysis and visualization. Refer to references/monitoring.md for detailed technical information.

Does SimPy support real-time simulation?


Yes. SimPy provides a RealtimeEnvironment, which synchronizes simulation time with wall-clock time to achieve a 1:1 mapping or a configurable speed factor. It is suitable for hardware-in-the-loop testing, interactive demonstrations, and scenarios requiring integration with real systems. Real-time simulation progresses according to real time, making it easier to observe and control the simulation process.