I'm trying to build a scheduling app for a friend, but am stuck on how to sort the employees.
I have three holidays each with their own employee_need:
I have employees who have a predetermined number of days they will work. The sum of the employee’s predetermined work days will always add up to the sum of the three holiday’s employee_need. They also have ranked the holidays by preference, which should guide the scheduling process. The data looks something like this:
preferences: [christmas, new_years_eve, thanks_giving]
preferences: [thanks_giving, christmas, new_years_eve]
Right now my process of sorting is to
Fill each holiday with a list of all employees.
Loop through the employees, starting with those who have the most days off.
Loop through the employee's preferences and pull them from the one they most desire to have off that also has room for them to be taken off
Continue looping until the days are properly scheduled. If there is room to remove them from that day, I do so, until they are working the number of days they are supposed to.
The algorithm works a decent amount of time, but I really need it to work all the time.
Is anyone familiar with this kind of problem, and can point me toward a better methodology?