'How to calculate amount of call center's operators? Erlang Calculator on python
I have stuck with a problem of predicting how many operators are needed for call center to answer the calls (80%) in less than 20 seconds (in queue). Just something like this Erlang Calculator
But I need to implement that in a python script. I did found basic Erlang-c formula but it only returns probability that an arriving customer will need to queue.
Appreciate any help!
Solution 1:[1]
def ErlangC(A, N):
if (N-A<=0):
return 1
L = (A**N / factorial(N)) * (N / (N - A))
sum_ = 0
for i in range(N):
sum_ += (A**i) / factorial(i)
return (L / (sum_ + L))
def calc_sl(row):
if row['duration'] == 0:
return 0
A = row['duration']
T = 20 # targeted waiting time
aht = row['duration'] * 3600 / row['calls']
for staff in range(1000):
P = ErlangC(A, staff)
sl = (1 - (P * math.exp(-((staff - A) * (T / aht))))) * 100
if sl >= 80: # percent of calls to be in tagreted waiting time
return staff
Solution 2:[2]
You can use pyworkforce for this problem, you just need to define your parameters and goals (all the time parameters are in minutes), for example:
from pyworkforce.queuing import ErlangC
erlang = ErlangC(transactions=100, asa=20/60, aht=3, interval=30, shrinkage=0.3)
positions_requirements = erlang.required_positions(service_level=0.8, max_occupancy=0.85)
print("positions_requirements: ", positions_requirements)
This will return the needed resources considering shrinkage = 0 (raw_resources), the resources under the provided shrinkage, the probability that a transaction waits in the queue, the expected service level and the expected resources occupancy
Output:
{'raw_positions': 14,
'positions': 20,
'service_level': 0.8883500191794669,
'occupancy': 0.7142857142857143,
'waiting_probability': 0.1741319335950498}
Solution 3:[3]
You didn't even state your criteria of filtering. If I have to guess I guess you want to filter out the third element, which is not a valid JSON. You can wrap JSON.parse() in a try/catch block to silent the JSON parse error, return a null then filter it out.
const arr = [
'{"Topic":"TRACK","SID":"1","GPSlat":"634312740","GPSlong":"104014684","GPSat":"43788","GPSspd":"20","GPShead":"29499222","GPSepoch":"1638451303"}',
'{"Topic":"TRACK","SID":"1","GPSlat":"634312740","GPSlong":"104014684","GPSalt":"43788","GPSspd":"20","GPShead":"29499222","GPSepoch":"1638451303"}',
"{'143567890'}",
'{"Topic":"TRACK","SID":"1","GPSlat":"634312740","GPSlong":"104014684","GPSalt":"43788","GPSspd":"20","GPShead":"29499222","GPSepoch":"1638451303"}',
'{"Topic":"Impact","SID":"1","GPSlat":"634312740","GPSlong":"104014684","GPSalt":"43788","GPSspd":"20","GPShead":"29499222","GPSepoch":"1638451303"}'
];
const output = arr.map( it => {
try{
return JSON.parse(it)
}
catch(e){
return null
}
}).filter(it => !!it);
console.log(output);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Argo |
| Solution 2 | |
| Solution 3 |
