# SpiceGrinder vs. SimPy and Other Code Libraries

Source: https://obsvra.com/compare/simpy

> SimPy gives you a simulation as Python with no ceiling. SpiceGrinder describes queues, state and experiments as text. When to use each.

*Short version: SimPy gives you a discrete-event simulation as ordinary Python, free, with all of Python behind it. SpiceGrinder gives you the common cases as a declarative text model with the statistics and reproducibility already handled. If your logic is unusual, write it in code; if it's a queue, a state machine or a what-if question, describing it is shorter.*

### What the libraries are, and why they're good

SimPy is a process-based discrete-event simulation framework for Python, released under the MIT license. You write each active thing (a customer, a vehicle, an agent) as a Python generator function, and shared things with limited capacity (servers, tellers, tunnels) as resources. It runs as fast as possible, in real time, or one event at a time. Other libraries aim at the same job in different ways: Salabim adds animation, Ciw is built for queueing networks, and simmer does process-oriented simulation in R.

The great strength is that there is no ceiling. A dispatch rule that depends on three other systems, a routing decision that calls a trained model, a service time read from a file: it's just code. You also get the whole language around it for data wrangling and plotting, and the library costs nothing. **If your simulation logic is bespoke, or your team lives in Python already, SimPy is a very good answer.**

### Where the fit breaks

**You write, and own, everything around the model.** SimPy provides the clock and the resources. Random-number management, warm-up handling, replications, confidence intervals and "was that difference real" are yours to build. These are exactly the places where hand-rolled simulations go quietly wrong. SpiceGrinder's `Experiment` tool runs a grid of lever settings over many seeds and reports means with 95% intervals and paired differences from a baseline, using common random numbers so the comparison is tight.

**Reproducibility is a discipline, not a property.** In a typical hand-written model, one extra random draw anywhere shifts every draw after it, so a change to the model changes the "noise" too. SpiceGrinder derives each node's random numbers from the seed and the node's name, so adding a node doesn't disturb the others.

**The model is code, and is reviewed as code.** That's often fine, but a reviewer who isn't a Python programmer, an operations lead or a risk officer, can't check that the model says what the process does. A SpiceGrinder model is a short, declarative description (stations, servers, routing, distributions) that they can read.

**The standard cases take more code than they need to.** A clinic with three stations, routing between them, and a service-time distribution for each is a few dozen lines of generator code, plus the harness around it. In SpiceGrinder it is one node:

```xml
<ProcessFlow name="Clinic" stations="Reception:2, Triage:1, Doctor:3" entry="Reception"
             routing="Reception>Triage:1; Triage>Doctor:0.7, Triage>exit:0.3; Doctor>exit:0.9, Doctor>Triage:0.1"
             output="entities">
  <input name="Gap" role="arrival"/>
  <input name="ReceptionTime" role="service.Reception"/>
  <input name="TriageTime" role="service.Triage"/>
  <input name="DoctorTime" role="service.Doctor"/>
</ProcessFlow>
```

The model (`samples/pro/process-flow-clinic.xml`) also states the closed-form answers for this network, so you can check the simulation against theory. Resource pools, shift schedules, breakdowns, reneging, batching and elevator-style fleets are attributes of the same node. `ProcessFlow` is a Pro feature; the lighter way to simulate a single queue, with `Recur`, is in Free.

### Where the code libraries win outright

- **No ceiling, in one language.** Arbitrary logic, any data source, any decision rule. We offer custom components (a documented extension point, in Java, Pro), but that is more ceremony than a Python function. Section below on how far you can get from Python anyway.
- **Free and open source, with no tiers.** SimPy is MIT licensed. SpiceGrinder Free is numeric-only with a 20-node cap per model, and queueing networks (`ProcessFlow`) and lever-based experiments are Pro, at $199/month.
- **The Python ecosystem.** NumPy, pandas, matplotlib, and your own libraries are an `import` away.
- **Continuous-time and agent-style logic.** You can express it, however awkwardly. SpiceGrinder can't: its time is dimensionless and its models are described, not programmed.

### Using both, from Python

They fit together, and Python can drive SpiceGrinder in several ways:

- **The command line.** Call `grind` and `Experiment` with `subprocess`, read the CSV with pandas. This works in Free.
- **The service (Pro).** A long-running HTTP service loads models once and serves rows on request, with a model registered under different `declare` values giving a different scenario, so a Python notebook or app can ask for a million rows without starting a JVM each time.
- **The JAR, programmatically (Pro).** Pro users can call SpiceGrinder's Java library directly from Python (through a JVM bridge such as JPype) and build or run models in process.
- **Custom Java components (Pro).** When the engine lacks a distribution, filter or business object, write it once as a component and it is available in every model, GUI and tool.
- **`ServiceCall` (Pro), in the other direction.** A model can call out to an HTTP service per row, so the decision rule that needs real code (a dispatch heuristic, a trained model) can be a small Python service that a SpiceGrinder model asks.

So the choice is less either/or than it looks: use SpiceGrinder for the streams, the standard queues and the experiment harness, and put the one bespoke piece in Python where it belongs. You can also feed SpiceGrinder's arrival and service-time streams (a fitted `Empirical` table, or a regime-switching demand series) into a SimPy model as plain CSV, or prototype the process as a `ProcessFlow`, check it against closed forms, and move to code only when you hit something it can't say.

### Try it

**[Download SpiceGrinder Free →](https://obsvra.com/get-spicegrinder)**

*SimPy details per simpy.readthedocs.io and PyPI, checked 2026-10-22.*
