cimba
Compiled Python models for the Cimba discrete-event simulation engine
Downloads & Community Adoption
Health & Engineering Analysis (5 Pillars)
1. Governance & Community50 / 200 ▾
2. PEP Metadata & Packaging200 / 200 ▾
3. Security & Supply Chain200 / 200 ▾
4. Documentation, SEO & Ecosystem155 / 200 ▾
5. Engineering, CI & Quality165 / 200 ▾
Official Documentation & Usage Guide — cimba
Show full original documentation (English README) ▾
PyCimba
PyCimba is an object-oriented discrete-event simulation library for python. It allows the user to use Python tooling whilst avoiding the JIT overhead of Python, achieving more that one level of magnitude faster speed than alternatives like Simpy. A model declares its variability as inputs. The same compiled model can use distributions, recorded traces, bootstrap resamples, or fitted sources.
Python 3.11 or newer is required. Linux x86_64 and aarch64, Windows AMD64, and macOS arm64 wheels include the native engine.
pip install cimba # core: models, experiments, inputs
pip install "cimba[analysis,optimize]" # + statistics, input fitting, optimization
The core depends only on Numba and typing_extensions. The analysis extra
(SciPy, statsmodels) adds cimba.analysis, inputs.fit and the AR/seasonal
fitted sources. The optimize extra (SciPy) adds cimba.Optimization. Use
cimba[all] to get everything, including matplotlib for plotting.
A queue model
import cimba as cb
from cimba import inputs
class MM1(cb.Model):
interarrival: cb.Input[float] = inputs.dist.exponential(mean=1 / 0.75)
service_time: cb.Input[float] = inputs.dist.exponential(mean=1)
queue: cb.Container
mean_queue: cb.Output[float]
@cb.process
def arrivals(self):
while True:
cb.hold(self.interarrival.next())
self.queue.put(1)
@cb.process
def server(self):
while True:
self.queue.get(1)
cb.hold(self.service_time.next())
@cb.on_end
def measure(self):
self.mean_queue = self.queue.mean_level()
model = MM1()
results = cb.Experiment(
model, replications=100,
window=cb.Window(warmup=100, duration=1000), seed=123,
).run()
print(cb.analysis.summary(results[model].mean_queue))
To replay observed arrival gaps, assign model.interarrival = inputs.trace(gaps). To resample them, assign inputs.bootstrap.stationary(gaps, mean_block=7). The process code and compiled class stay the same. Input sources are independent streams, and results record their provenance and consumption.
See the documentation, standalone tutorials, and 0.6 to 0.7 migration guide.
Development
git submodule update --init --recursive
uv sync --locked
uv run pytest
The Cimba C library is an unchanged submodule. Cimba Python is Apache-2.0 licensed; see LICENSE and NOTICE.