I solved the problem of assigning shifts for a large production plant recently. First, we tried to generate purely random graphs and return any passed is_schedule_valid test - a backup algorithm. It was, of course, slow and uncertain.
Next, we tried to use genetic algorithms (as you said), but could not find a good fitness function that closed on any viable solution (since the smallest change can make the entire schedule CORRECT or INCORRECT - no points for almost).
Finally, we chose the following method (which works great!):
- Randomize a set of input data (i.e. jobs, shift, personnel, etc.).
- Create the correct tuple and add it to the preliminary schedule.
- If the correct tuple could not be created, rollback (and increase) the last tuple added.
- Pass a partial schedule to a function that checks
could_schedule_be_valid , that is, can this schedule be valid if the remaining tuples were filled in a possible way. - If
!could_schedule_be_valid , just rollback (and increase) the tuple added to (2). - If
schedule_is_complete , return schedule - Go (2)
You gradually create a partial shift in this way. The advantage is that some tests for a valid schedule can be easily performed in step 2 (preliminary tests), while others should remain in step 5 (post-tests).
Good luck. We spent days trying the first two algorithms, but got the recommended algorithm that generates valid schedules instantly in 5 hours of development.
In addition, we supported pre-commit and post-commit assignments that the algorithm would follow. You simply did not randomize these slots in step 1. You will find that solutions should not be anywhere near optimal. Our O (N * M) solution is at least, but implemented in PHP (!) In less than half a second for the entire production factory. Beauty quickly eliminates bad graphics using the good could_schedule_be_valid test.
People who are used to doing it manually do not care if it takes an hour - they just know that they no longer need to do it manually.
Andy Feb 21 '09 at 21:52 2009-02-21 21:52
source share