Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Little's law, the traffic intensity in an M/M/c queue
- # Parameters:
- # lam: lambda, the poisson parameter
- # mu : mu/W, the average time spent in the queue/using the server/product
- def Little(lam, mu):
- return ceil(lam * mu)
- # Erlang-C function, the probability that a user must queue
- # Parameters
- # c : the number of queues/servers/products
- # rho: the average load of each queue/server/product
- def E_2c(c,rho):
- crho = c * rho
- a = crho**c / factorial(c)
- b = 1 / (1 - rho)
- var('k')
- d = sum( crho** k / factorial(k), k, 0, c-1)
- ab = a * b
- return ab / (d+ab)
- # Expected exploitation
- # Find the expected number of users in system
- # Parameters:
- # c : the number of queues/servers/products
- # rho: the average load of each queue/server/product
- def Expe_t(c,rho):
- a = rho / (1-rho)
- return a*E_2c(c,rho)+(c*rho)
- # Little Allocation by Probability for an M/M/c queue
- # Find the number of queues/servers/products needed to ensure the following conditions:
- # *the probability of queueing is less than p_q.
- # Parameters
- # lam: lambda, the poisson parameter
- # mu : the average time spent in the queue/using the server/product
- # n : the number of users interacting with the system
- # p_q: the probability that the user will have to wait in the queue/for the server/product
- def Little_alloc_p(lam,mu,n,p_q):
- L = Little(lam,mu) #traffic intensity
- c = L + 1
- rho = L / c
- p = E_2c(c,rho)
- while p_q < p:
- c = c + 1 #a more advanced method should be used for large values of c
- rho = L / c
- p = E_2c(c,rho)
- return c
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement