开发者

Randomly Assigning Positions

开发者 https://www.devze.com 2023-01-06 02:49 出处:网络
Here\'s my basic problem. Let\'s say I have 50 employees working on a certain day, and I want my program to randomly d开发者_C百科istribute them to a \"position\" (I.e.: front desk, phones, etc) based

Here's my basic problem. Let's say I have 50 employees working on a certain day, and I want my program to randomly d开发者_C百科istribute 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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号