0

I need to distribute calls among employees. Different employees has different weights in the system. For example, one employee has to take two times more calls, than some other.

Now i'm using this scheme:

Employee 1 - rating 10.
Employee 2 - rating 9.
Employee 3 - rating 4.
Employee 4 - rating 3.

I'm using a weighted random function from this answer (Generating random results by weight in PHP?) to select a phone number to call.

Problem is, that there are not many calls a day. About 10-20. The method above would be OK on bigger numbers, but with small amount of calls, Employee 4 could easily recieve no calls on some day.

Is there a way to do weighted distribution, that works well on small numbers? Or the answer above is the best one?

Community
  • 1
  • 1
Taras Bulgakov
  • 543
  • 3
  • 11
  • 21
  • 1
    for small numbers? fill an array with the employees, duplicating them as many times as necessary. e.g. `array('1', '1', '1', '2', '2', '3')`, then shuffle the array and pop off entries as necessary. – Marc B Mar 02 '16 at 15:23
  • So are you saying that _every_ employee needs to take at _least one_ call before _any_ employee can take a second? Meaning there is a minimum of 1 call? If not, then you should be fine with the fact that with 4 employees and only 10 calls, a certain employee might not take any calls. – Patrick Q Mar 02 '16 at 15:31
  • Do calls come in throughout the day? If so, use a priority queue. Do you get all the calls listed at the start of the day and you have to hand them out? If so, you can deal them out using duplication. Since both are very different solutions, it is important to know which you want before answering. – kainaw Mar 02 '16 at 15:32
  • Create tests for the distribitions produced like in @MarcB's comment, like "every employee should occur at least once in the first 10 entries". If the generated distribution fails one of these tests, start again. Of course, you will have to keep the generated distributions for example in a database for the day (if you cannot handle them immediately). – syck Mar 02 '16 at 15:45
  • Patrick Q, it's not really a set in stone requirement. If some manager has no calls one day - in's not good, but it's ok. But now the distribution normalizes on pretty big numbers, about 1000 times. I'm wondering if there is a way to normalize it earlier. – Taras Bulgakov Mar 02 '16 at 15:55
  • Marc B, it is the way I think, thank you. Now the question is how to automatically create such array from the data above. – Taras Bulgakov Mar 02 '16 at 15:57
  • kainaw, thank you! First option. Calls come in throughout the day. But how to use a priority queue in this case? – Taras Bulgakov Mar 02 '16 at 16:04

1 Answers1

2

What you have is calls coming in throughout the day and employees with some sort of priority to handle the calls. To generalize, you have jobs to be done and workers which are not equal. This is a job management system. There is a form of priority queue that handles this. Normally, we consider that the jobs have priority. Here, they are all the same. So, the jobs are in a FIFO queue. The workers are in a priority queue. When a worker is done with a job, the worker goes in the queue. They get in front of anyone who has a lower priority (behind anyone with an equal-to or higher priority). When there is a job to be done and a worker in the queue, the worker takes the job.

That is all good when everyone is busy. It is not good when there is sparse work. The same worker does all the work. We don't care for computers because the CPUs don't complain. However, we want to spread the work out. What is used in node-based systems is a timer. The longer someone waits in the queue, the higher that person's temporary priority gets. The time increment is up to you. You can say that a person's priority goes up by 1 every hour. So, to get their temporary priority, you get their priority and add how many hours they have been in the queue. This helps ensure that every node in a distributed system gets some work at some time.

A problem you will have when researching this is that, based on my experience, about 99% of all job management systems place all priority and weight on the jobs, not the workers. All workers are equal. So, you have to flip it. In one textbook I had many years ago, they simply reversed the roles. Instead of viewing it as a employee taking a call, you think of it as a call taking an employee. The calls become your "workers" and the employees become your "jobs". Then, you can view it as a basic priority-based queue.

kainaw
  • 4,256
  • 1
  • 18
  • 38