Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1import openqtsim 

2import pandas as pd 

3import numpy as np 

4from collections import namedtuple 

5 

6Task = namedtuple('Task','A, S, c, nr_arr, lam, mu') 

7 

8def worker(task:Task): 

9 # calculate the appropriate service rate per server 

10 srv_rate = task.mu/task.c 

11 

12 # create Arrival and Service processes and specify the number of servers 

13 A = openqtsim.ArrivalProcess(task.A, arr_rate=task.lam) 

14 S = openqtsim.ServiceProcess(task.S, srv_rate=srv_rate) 

15 c = task.c 

16 

17 # create the queue object 

18 q = openqtsim.Queue(A, S, c) 

19 

20 # use the queue object to create a simulation object and run simulation with the specified number of arrivals 

21 sim = openqtsim.Simulation(q) 

22 sim.run(task.nr_arr) 

23 

24 # retrieve the logs (df1: customer log, df2: system log) 

25 df1, df2 = sim.return_log() 

26 

27 # use the customer log to determine the average waiting time as a factor of service time  

28 factor = np.mean(df1["TCWQ"]) / np.mean(df1["ST"]) 

29 

30 return factor 

31