Last active
January 4, 2016 04:59
-
-
Save selenamarie/8572567 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env python | |
from decimal import Decimal, getcontext | |
from math import factorial | |
#a = float(500000) # total traffic offered | |
#n = 10 # number of servers | |
# 500000 per day | |
# Ts = 2 seconds per crash | |
# lambda = 5.78 crashes per second | |
# (a, n) pairs | |
test_values = [ (48, 55, 240), (11.56, 10, 2), (115.6, 10, 2), (117.4, 30, 2), (117.4, 50, 2) ] | |
getcontext().prec = 50 | |
for test in test_values: | |
u, m, t = test | |
u = Decimal(u) | |
m = Decimal(m) | |
sum = 0 | |
print "traffic intensity (u): ", u | |
print "number of agents (m): ", m | |
print "average processing duration (in seconds): ", t | |
agent_occupancy = u / m | |
print "agent occupancy: %0.6f" % agent_occupancy | |
for i in range(0, int(m)-1): | |
sum += ( u**i / factorial(i) ) | |
p = (u**m / factorial(m)) / ((u**m / factorial(m)) + ((1 - agent_occupancy) * sum)) | |
print "probability that an arriving crash will need to queue: %0.8f" % (p * 100) | |
x = (p * t ) / (m * (1-agent_occupancy)) | |
print "average waiting time for %s servers: %0.6f" % (m,x) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment