Home Implementing a Kelly Network in Ciw
Post
Cancel

Implementing a Kelly Network in Ciw

Ciw is a Python package for simulating queueing networks.

Suppose there are two classes of patient, “Baby” and “Child”, and three service nodes. Both are registered at a receptionist’s desk where a single receptionist works. Babies arrived every hour on average and children arrive every half of an hour on average at the receptionist’s desk. It takes 15 minutes on average for babies to get registered, and an average of 10 minutes for children to get registered. Once registered, babies and children go into separate waiting clinics where they wait to be seen by separate specialists. It takes an average of an hour for either babies or children to complete their appointments with their respective specialists. There are two specialists in the babies’ room, and three specialists in the childrens’ room. Each specialist has their own working room where they serve their patient.

An example of a Kelly network can be implemented and simulated for 9 hours using Ciw in the following way.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import ciw

ciw.seed(2018)

N = ciw.create_network(
    arrival_distributions={
        'Baby': [ciw.dists.Exponential(rate=1.0),
                 None,
                 None],
        'Child': [ciw.dists.Exponential(rate=2.0),
                  None,
                  None]
    },
    service_distributions={
        'Baby': [ciw.dists.Exponential(rate=4.0),
                 ciw.dists.Exponential(rate=1.0),
                 ciw.dists.Deterministic(value=0.0)],
        'Child': [ciw.dists.Exponential(rate=6.0),
                  ciw.dists.Deterministic(value=0.0),
                  ciw.dists.Exponential(rate=1.0)]
    },
    routing={'Baby': [[0.0, 1.0, 0.0],
                      [0.0, 0.0, 0.0],
                      [0.0, 0.0, 0.0]],
             'Child': [[0.0, 0.0, 1.0],
                       [0.0, 0.0, 0.0],
                       [0.0, 0.0, 0.0]]
    },
    number_of_servers=[1, 2, 3],
)

Q = ciw.Simulation(N)

Q.simulate_until_max_time(9)

recs = Q.get_all_records()
This post is licensed under CC BY 4.0 by the author.

Implementing a G/M/1 Queue in Ciw

List of Example Implementations of Some Classic Queue Models in Ciw