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:9

Download and extract to your skills directory

Copy command and send to OpenClaw for auto-install:

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

SimPy - Python Discrete-Event Simulation Framework

Overview


SimPy is a Python-standard-library-based discrete-event simulation framework for modeling complex systems where entities (customers, vehicles, packets, etc.) interact over time and compete for shared resources (servers, machines, bandwidth, etc.).

Use Cases

1. Manufacturing and Service System Modeling


Suitable for scenarios such as production line scheduling, machine utilization analysis, inventory management, patient flow in hospital emergency departments, call center queuing, retail checkouts, and other situations that require simulating entities queuing, waiting, and undergoing service.

2. Network and Communication System Simulation


Suitable for scenarios like network packet routing, bandwidth allocation policies, latency analysis, and traffic control that require simulating competition and resource allocation among network nodes.

3. Capacity Planning and System Validation


Suitable for scenarios that need forecasting and analysis to determine the optimal number of resources to meet performance targets, evaluate different configurations, and test system designs before deployment.

Core Features

1. Process Modeling and Event Scheduling


Define processes using Python generator functions and use yield to pause and resume in an event-driven manner. Supports various event types (timeouts, resource requests, custom events) and coordination of parallel tasks (AllOf/AnyOf).

2. Shared Resource Management


Provides multiple resource types to model real-world constraints: Resource (limited capacity like servers), PriorityResource (priority queuing), PreemptiveResource (preemption by higher priority), Container (bulk materials like fuel), Store (object storage), and FilterStore/PriorityStore (selective retrieval).

3. Monitoring and Data Collection


Built-in tracking of resource usage, state variable logging, and event tracing. Supports automatic statistical calculations and CSV export, and can be combined with a real-time environment (RealtimeEnvironment) for hardware-in-the-loop simulations synchronized with wall-clock time.

Frequently Asked Questions

What is SimPy? What is it suitable for?


SimPy is a Python-based discrete-event simulation framework. It is suitable for modeling scenarios where entities interact over time and compete for shared resources, such as manufacturing systems, service operations, network traffic, logistics, and more. Unlike traditional continuous simulation, SimPy focuses on discrete systems where events occur at irregular times.

How do I model a queuing system with SimPy?


Use simpy.Resource to define a resource with limited capacity (e.g., servers). Create process functions and request the resource with with resource.request() as req:; the resource is automatically released when the block completes. Combine with env.timeout() to model service times, and use monitoring tools to collect statistics like wait times and utilization.

What application scenarios is SimPy suitable for?


Typical scenarios include: production flows and machine scheduling in manufacturing systems, patient flow in healthcare emergency departments, network traffic and bandwidth allocation in telecom systems, logistics and vehicle routing in transportation systems, queuing at call centers and checkouts in service operations, and CPU scheduling and memory management in computer systems. SimPy is not suited for fixed time-step continuous simulations or simulations of independent processes that do not share resources.