The local employment exchange has received 20 applications from 20 different people. They also had 20 different positions (numbered 1 through 20) they could employ people as.
After going through the applications, they made a list of which person is suitable for which position. Below is the list, where each line contains the positions each applicant is suited for.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
Unfortunately, since each position can be offered to at most one candidate, not all candidates might end up getting a position.
What is the maximum number of people who can each be assigned a position?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
A complete matching is possible, making the answer 2 0 :
C a n d . 1 2 3 4 5 P o s t 1 2 0 9 6 7 C a n d . 6 7 8 9 1 0 P o s t 1 2 1 3 2 1 7 1 6 C a n d . 1 1 1 2 1 3 1 4 1 5 P o s t 1 1 1 4 5 4 1 5 C a n d . 1 6 1 7 1 8 1 9 2 0 P o s t 1 9 8 3 1 8 1 0
That is nice. Great job on finding a constructive solution.
I posted a new version of this problem with slightly different data, here
https://clip2net.com/s/3S7578A i went row by row from the bottom ant got this one
The answer for this particular data is 2 0 . I came up with a solution based on integer programming. Let X i , j be a binary variable that assumes the value 1 if candidate i is assigned for job j and 0 otherwise. Then, our objective function is as follows:
M a x i m i z e : ∑ i = 1 2 0 ∑ j = 1 2 0 X i , j
Subject to the following contraints:
∑ j = 1 2 0 X i , j = 1 , i = 1 , 2 , . . . , 2 0
∑ i = 1 2 0 X i , j = 1 , j = 1 , 2 , . . . , 2 0
X 1 8 , 2 = 0 , X 1 8 , 8 = 0 , X 1 8 , 1 4 = 0 , X 1 8 , 1 5 = 0 , and X 1 8 , 1 7 = 0
And so on, for the other candidates.
No complex algorithms used. I took the position with the fewest candidates qualified and assigned that position to the candidate that had the smallest skill set...from there i worked my way up till reaching skills found amongst more candidates but always tried to match that position to the candidate that had the fewest skills.
If you look at the eligible candidates, you realize that all positions can be filled by all the 20 candidates in a way that no one is left out. You need not do the arduous task of making a table and eliminating options.
While it is true that for this particular problem it is not too difficult to find such a matching by hand, this task of eliminating options might quickly get extremely tedious for some problems. Hence, it is important to develop an algorithmic approach.
You may try to solve this problem to see what I mean.
Problem Loading...
Note Loading...
Set Loading...
Unfortunately LaTeX doesn't let me draw bipartite graphs so I'll try explaining this the best I can.
Let the matching of a person to a job be denoted as ( P e r s o n , J o b ) .
Going down the list and selecting the first available job, we find an initial matching:
( 1 , 1 ) , ( 2 , 1 0 ) , ( 3 , 3 ) , ( 4 , 2 ) , ( 5 , 5 ) , ( 6 , 4 ) , ( 7 , 7 ) , ( 8 , 8 ) , ( 9 , 9 ) , ( 1 0 , 1 1 ) , ( 1 1 , 1 3 ) , ( 1 2 , 1 4 ) , ( 1 3 , 1 2 ) , ( 1 4 , 6 ) , ( 1 5 , 1 5 ) , ( 1 6 , 1 7 ) , ( 1 7 , N o n e ) , ( 1 8 , 1 6 ) , ( 1 9 , 1 8 ) , ( 2 0 , N o n e ) .
Using the maximum matching algorithm we construct a path from an unassigned person to an unassigned job.
2 0 − 1 = 1 − 3 = 3 − 2 0 → 2 0 = 1 − 1 = 3 − 3 = 2 0
Where ( = ) means is assigned to and ( − ) means could be assigned to.
We now have an improved matching:
( 1 , 3 ) , ( 2 , 1 0 ) , ( 3 , 2 0 ) , ( 4 , 2 ) , ( 5 , 5 ) , ( 6 , 4 ) , ( 7 , 7 ) , ( 8 , 8 ) , ( 9 , 9 ) , ( 1 0 , 1 1 ) , ( 1 1 , 1 3 ) , ( 1 2 , 1 4 ) , ( 1 3 , 1 2 ) , ( 1 4 , 6 ) , ( 1 5 , 1 5 ) , ( 1 6 , 1 7 ) , ( 1 7 , N o n e ) , ( 1 8 , 1 6 ) , ( 1 9 , 1 8 ) , ( 2 0 , 1 ) .
We use the maximum matching algorithm once more and get:
1 7 − 2 = 4 − 1 = 2 0 − 7 = 7 − 1 7 = 1 6 − 1 9 → 1 7 = 2 − 4 = 1 − 2 0 = 7 − 7 = 1 7 − 1 6 = 1 9 .
This gives us a final and complete matching of:
( 1 , 3 ) , ( 2 , 1 0 ) , ( 3 , 2 0 ) , ( 4 , 1 ) , ( 5 , 5 ) , ( 6 , 4 ) , ( 7 , 1 7 ) , ( 8 , 8 ) , ( 9 , 9 ) , ( 1 0 , 1 1 ) , ( 1 1 , 1 3 ) , ( 1 2 , 1 4 ) , ( 1 3 , 1 2 ) , ( 1 4 , 6 ) , ( 1 5 , 1 5 ) , ( 1 6 , 1 9 ) , ( 1 7 , 2 ) , ( 1 8 , 1 6 ) , ( 1 9 , 1 8 ) , ( 2 0 , 7 ) .
Since everyone is assigned, the answer is 2 0