Coverage for C:\checkouts\github\OpenQTSim\openqtsim\mt_engine.py : 38%

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
6Task = namedtuple('Task','A, S, c, nr_arr, lam, mu')
8def worker(task:Task):
9 # calculate the appropriate service rate per server
10 srv_rate = task.mu/task.c
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
17 # create the queue object
18 q = openqtsim.Queue(A, S, c)
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)
24 # retrieve the logs (df1: customer log, df2: system log)
25 df1, df2 = sim.return_log()
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"])
30 return factor