Home Implementing a G/M/1 Queue in Ciw
Post
Cancel

Implementing a G/M/1 Queue in Ciw

Ciw is a Python package for simulating queueing networks.

Since G in G/M/1 can be any distribution with non-negative support, we will use a gamma distribution for the sake of example. A gamma distribution is the result of a sum of independent exponentially-distributed random variable, and thus for this example we have an interpretation that the arrivals are implicitly the result a multi-step process where each step has an exponentially-distributed completion time.

A G/M/1 queue as described can be implemented and simulated using Ciw in the following way.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import ciw

ciw.seed(2018)

ARRIVAL_SHAPE = 6 / 10
ARRIVAL_SCALE = 12 / 10
SERVICE_TIME = 1
HORIZON = 365

network = ciw.create_network(
    arrival_distributions = [ciw.dists.Gamma(shape=ARRIVAL_SHAPE, scale=ARRIVAL_SCALE)],
    service_distributions = [ciw.dists.Exponential(SERVICE_TIME)],
    number_of_servers = [1]
    )
    
simulation = ciw.Simulation(network)
simulation.simulate_until_max_time(HORIZON)
records = simulation.get_all_records()
This post is licensed under CC BY 4.0 by the author.

Implementing a G/G/1 Queue in Ciw

Implementing a Kelly Network in Ciw