Sorting people into groups

linkgoron

Platinum Member
Mar 9, 2005
2,601
1,238
136
hmm, I've got a problem and I thought maybe you guys know of an easy way to sort this out.


I've got jobs that need a certain amount of people to be completed. each job has a priority (meaning some are more important than other).
I've also got people that are qualified to work.

What I need to do is assign people that are qualified (some people are qualified in more than one job, others just one) to those job. A person can be assigned to only one qualification.

So basically I need to read what people can do, and then start assigning them into jobs. IF there aren't enough people to staff all jobs, and a person is qualified to do more than one job then he's sent to the job with the higher priority.


I'm not sure how to approach this problem... I don't want to create somethings that goes over all of the options. I'm looking for something efficent, but I haven't found anything that's good enough.


first of all I check who can be assigned to only one job, and then I assign them to it.
After that I'm not sure how to continue...

This will be implemented in SQL server 2005.


to illustarte the problem. These are quite simple, but this will get ugly, once I start having 4 or 5 jobs...

I've got Jobs:
A (needs 3 people), B (2) , C (1) [ordered by priority]

and people:
1 (qualified in A)
2 (B)
3 (A)
4 (AC)
5 (AB)
6 (AB)
-------- this is a situation that I can fill all jobs. ------

or this:

1)A
2)B
3)AC
4)CB
5)AB
6)B
 

techfuzz

Diamond Member
Feb 11, 2001
3,107
0
76
I think you're on the right path. I would also first assign people to jobs if they only have one qualification. Then I would iterate through the jobs from highest priority to lowest and fill them with the remaining people who are qualified. It will get tricky if you MUST fill all the jobs with at least one person, but that doesn't appear to be a requirement (yet).

techfuzz
 

presidentender

Golden Member
Jan 23, 2008
1,166
0
76
This is a system of distinct representatives (SDR) problem, specifically the Marriage problem. I just had to do this last semester. Google for either of those terms (I found a link, but the reply button isn't working, and I don't remember the tag to do a hyperlink), and you'll find what you are looking for.
 

linkgoron

Platinum Member
Mar 9, 2005
2,601
1,238
136
I don't need to assign one person to a group.

I need to fill all groups, or if impossible, I need to assign as many people to the highest priority jobs as possible.
 

presidentender

Golden Member
Jan 23, 2008
1,166
0
76
Maybe try the marriage problem repeatedly? Remove the people who've been assigned jobs from the pool, and do it again.
 

linkgoron

Platinum Member
Mar 9, 2005
2,601
1,238
136
Originally posted by: presidentender
Maybe try the marriage problem repeatedly? Remove the people who've been assigned jobs from the pool, and do it again.

That will not work, because there are situation when you can assign people that qualify to more than one job, and because you assigned them to one job and not the other, you won't be able to fill all jobs, even though you actually can fill all jobs.