Ciw is a discrete event simulation library for open queueing networks. It’s core features include the capability to simulate networks of queues, multiple customer classes, and implementation of Type I blocking for restricted networks.
Install with pip install ciw
.
Current supported version of Python:
- Python 3.7
- Python 3.8
- Python 3.9
Import Ciw:
>>> import ciw
To define an M/M/3 queue, with λ = 0.2 and μ = 0.1:
>>> N = ciw.create_network(
... arrival_distributions=[ciw.dists.Exponential(rate=0.2)],
... service_distributions=[ciw.dists.Exponential(rate=0.1)],
... number_of_servers=[3]
... )
Now set a seed, create a Simulation object, and simulate for 1440 time units:
>>> ciw.seed(1)
>>> Q = ciw.Simulation(N)
>>> Q.simulate_until_max_time(1440)
Collect results:
>>> recs = Q.get_all_records()
Manipulate results to get useful statistics, e.g. average waiting time:
>>> waits = [r.waiting_time for r in recs]
>>> sum(waits) / len(waits)
4.2305...
A number of other features are also implemented, including:
- Type I blocking
- A large range of sampling distributions
- Phase-Type distributions
- Time-dependent and state-dependent distributions
- Batch arrivals
- Baulking customers
- Reneging customers
- Processor sharing
- Multiple customer classes
- Priorities
- Server priorities
- Customers changing classes
- Server schedules
- State tracking
- Stopping the simulation after a certain amount of customers
- Process-based routing
- Deadlock detection