'Allocating students with specific skills to projects in the best possible way
I have a list of students with specific skills that I would like to allocate to a list of projects that are in need of those specific skills. I would like to find the best possible allocation of resources (students).
The list of students looks like this:
Edit: Apologies, the table is not working (although the preview renders it correctly)
- Mary; Skills: Java, Python; No. of projects they can be part of: 3
- John; Skills: Python, C; No. of projects they can be part of: 2
- Chris; Skills: Python, Java; No. of projects they can be part of: 3
- Kate; Skills: C, Java, Python; No. of projects they can be part of: 3
- ...
The list of projects looks like this:
- P001; Skills required: Python, Java; No. of students needed: 4; Payment if successful: 500
- P002; Skills required: Java, C; No. of students needed: 3; Payment if successful: 490
- P003; Skills required: Java, Python, C; No. of students needed: 3; Payment if successful: 450
- P004; Skills required: C, Python; No. of students needed: 3; Payment if successful: 460
- ...
Some more info:
- There are 3 possible skills overall (Python, Java, C). There aren't any other skills.
- The order of the skills in the tables doesn't matter (e.g. Mary has exactly the same skills as Chris).
- For a project to receive payment, there has to be at least one unique student for each skill listed, and the required number of people has to be met. E.g. project 001 is successful with Mary (fulfills the Java requirement), Kate (fulfills the Python requirement), Chris & John (fulfill the no. of people requirement). A student cannot fulfill multiple requirements in one project (e.g. Mary cannot fulfill both the Java and the Python requirement by herself).
- Students don't need to use all their skills (e.g. Mary can fulfill the Java requirement for 3 different projects and never fulfill the Python requirement for any project).
Goal:
- Find the optimal allocation of students to the projects so that all successful projects pay as much as possible (→ maximize payment).
My idea is:
- Find the rarest skill (e.g. C: 2 students have the skill C, and since students can be part of more than one project, the total number of those "available" C skills is 5) and allocate that first (starting with the project with the highest payment → project 002, then project 004, then project 003). Afterwards, drop all other projects that need that skill (none in this case), since there are no more C skills available.
- Find the second rarest skill (e.g. Java, since 3 students have that skill for a total of 3+3+3=9 possible allocations) and allocate that, starting with the project with the highest payment (that already has a member, so project 002, then project 003), and then continue with the project with the highest payment (that doesn't have a member, so project 001). Assure that a person cannot be assigned to a project more than once. Drop all other projects that need that skill (none in this case).
- Do the same again for the last skill
- Fill the projects with the rest of the required number of people, starting with the project with the highest payment. If there are no more students available, take a student from the project with the lowest payment and assign him to a project with higher payment (again, assure that a student cannot be assigned more than once to the same project).
- Do this until there is no more possibility to "up-shuffle" students
I would like to code this in Python. But I'm not looking for code, I'm just looking for some validation or suggestions if my idea has any merit or if there is something else that would work better (or that I forgot to consider). I sadly don't know a lot about math (and am somewhat new to programming), so I have no idea if this approach is in any way ideal for arriving at the optimal (or at least optimal-ish) solution. Any input is appreciated!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
