Schedule Generator Demo
Branch-and-Prune Discrete Optimization
Companion blog article can be found here.
This was an exercise at creating a class schedule generator using branch-and-prune optimization and constraint propogation.
I initially used Kotlin with ojAlgo, which turned out to be effective. However, I found implementing from scratch gave me more control and allowed me to optimize for the specific problem. Both implementations are in this repo.
For now, the model just assumes we are scheduling against one room.
Here is the starting data set:
- Psych 101 (1 hour, 2 sessions/week)
- English 101 (1.5 hours, 2 sessions/week)
- Math 300 (1.5 hours, 2 sessions/week)
- Psych 300 (3 hours, 1 session/week)
- Calculus I (2 hours, 2 sessions/week)
- Linear Algebra I (2 hours, 3 sessions/week)
- Sociology 101 (1 hour, 2 sessions/week)
- Biology 101 (1 hour, 2 sessions/week)
- Supply Chain 300 (2.5 hours, 2 sessions/week)
- Orientation 101 (1 hours, 1 session/week)
I set the model to put each recurring session 48 hours apart.
Availability for each day Monday-Friday:
Psych 101- MONDAY/WEDNESDAY 13:00-14:00 English 101- MONDAY/WEDNESDAY/FRIDAY 08:00-09:30 Math 300- MONDAY/WEDNESDAY 14:00-15:30 Psych 300- FRIDAY 13:00-16:00 Calculus I- TUESDAY/THURSDAY 08:00-10:00 Linear Algebra I- MONDAY/WEDNESDAY/FRIDAY 09:30-11:30 Sociology 101- MONDAY/WEDNESDAY 15:30-16:30 Biology 101- TUESDAY/THURSDAY 10:00-11:00 Supply Chain 300- TUESDAY/THURSDAY 13:00-15:30 Orientation 101- TUESDAY 15:30-16:30
Obviously, a room cannot be occupied by more than one class at any time. The solver does this successfully and prevents any overlap in scheduling.
How to Execute
Build the Kotlin project with Gradle, then run the
main() function inside the
InputAndRun.kt file. You can also change the hardcoded inputs in that file too.
The optimizer should hopefully run in a few seconds and then display the schedule in the console output.