views:

59

answers:

2

Hey, Here's my basic problem. Let's say I have 50 employees working on a certain day, and I want my program to randomly distribute them to a "position" (I.e.: front desk, phones, etc) based on what they have been trained on. The program already knows what each employee has been trained on. What is the best method pragmatically to go through and assign an employee to each of the 50 positions?

P.s. I am programming this into Access using VBA, but this is more a question of process than actual code.

+2  A: 

Hi lukewarm,

You are looking for a maximum bipartite matching. This is a problem from graph theory. It boils down to determining the maximum flow in an undirected, bipartite graph with constant edge weights of 1:

  1. You divide all vertices in Your graph in two separate sets. The first set contains all Your workers, the second one all available positions.
  2. Now You insert an edge from every worker to every position she/he is able to work on.
  3. Insert two more vertices: A source and a sink. Connect the source with every worker vertex and the sink with every position vertex.
  4. Determine the maximum flow from source to sink
Hope I could help, greetings.

EDIT: Support for randomness

Since finding the maximum bipartite matching/maximum flow is a deterministic algorithm, it would always return the same result. In order to change that You could mix/shuffle the order of the edges in the graph before applying the algorithm.

Dave
A: 

In your position table have a sequence, 1, 2, 3, 4 and a count of positions to be filled. Then look at what the person did yesterday, and 1 to the position sequence and now they're assigned to the next position. If there are enough for that position today then go to the next priority position.

Not random but maybe close enough.

Tony Toews
Not every person is able to fill every position. Extending Your approach by a condition that tests exactly that won't be sufficient either, as this naive method can lead to people being unassigned to any position.
Dave
Sure, you'd have to test for that as well. I didn't bother mentioning that in my posting as it was mentioned in the initial posting. Hmm, yes I see what you mean in your second sentence. You should start folks based on the position with the fewest number of foilks trained for it. Trouble is what if you need 5 positions and only have six people trained. You're going to be repeating 4 people every day.
Tony Toews
@Tony unfortunately yes.
Dave