Created
October 26, 2020 13:22
-
-
Save sXakil/8bebdcaf35b7e9279a08b115e70ac92e to your computer and use it in GitHub Desktop.
Queue System Simulation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
a_mean = 10.0 | |
a_sd = 1.5 | |
s_mean = 9.5 | |
s_sd = 1.0 | |
lim = 15 | |
NR1 = [0] * lim | |
NR2 = [0] * lim | |
IAT = [0] * lim | |
ST = [0] * lim | |
SB = [0] * lim | |
SE = [0] * lim | |
WT = [0] * lim | |
IT = [0] * lim | |
def getCommulatives(nums): | |
comm = [0] * len(nums) | |
com_prob = 0.0 | |
for idx, num in enumerate(nums): | |
com_prob += num | |
comm[idx] = round(com_prob, 3) | |
return comm | |
for i in range(0, lim): | |
num1 = random.random() * random.randint(-1, 3) | |
NR1[i] = round(num1, 2) | |
IAT[i] = round(a_mean + a_sd * num1, 3) | |
num2 = random.random() * random.randint(-1, 3) | |
NR2[i] = round(num2, 2) | |
ST[i] = round(s_mean + s_sd * num2, 2) | |
CAT = getCommulatives(IAT) | |
for idx, cat in enumerate(CAT): | |
SB[idx] = max(cat, SE[idx - 1] or 0) | |
SE[idx] = round(SB[idx] + ST[idx], 3) | |
wt = (SE[idx-1] or 0) - cat | |
WT[idx] = round(wt, 3) if wt > 0 else 0 | |
it = cat - (SE[idx-1] or 0) | |
IT[idx] = round(it, 3) if it > 0 else 0 | |
print('i'.rjust(4) + 'r\''.rjust(8) + 'IAT'.rjust(10) + 'CAT'.rjust(10) | |
+ 'r"'.rjust(10) + 'ST'.rjust(10) + 'SB'.rjust(10) + 'SE'.rjust(10) | |
+ 'WT'.rjust(10) + 'IT'.rjust(10)) | |
print('-' * 92) | |
for i in range(0, lim): | |
print(str(i+1).rjust(4) + str(NR1[i]).rjust(8) + str(IAT[i]).rjust(10) | |
+ str(CAT[i]).rjust(10) + str(NR2[i]).rjust(10) + str(ST[i]).rjust(10) | |
+ str(SB[i]).rjust(10) + str(SE[i]).rjust(10) + str(WT[i]).rjust(10) | |
+ str(IT[i]).rjust(10)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment