I have a school scheduing problem.
Problem description:
schedule each course into a timeslot. (ps: not need into a room).
Hard constraint:
-
same course in a class need consecutive. the length consecutive of course is 2. for example, Math course in class A, may need one that consecutive length is 1 and other one that consecutive length is 2. so there are two math course in class A, that total count timeslot of math needing is 3.
-
same course in different class that has same teacher need to be taken together. for example , music course in class A and class B, amd the teacher of music course is same one teacher Ann. when timeslot of music course in class A is slotA, the timeslot of music course in class B must be slotA.
my solution is building one model using build-in hard constraint to handle the hard constraints.
Are there any other effective ways to solve this problem?
School timetabling can contain many constraints. The Timefold Quickstarts repository already has a few pre-implemented so I would suggest having a look at those for further inspiration.
As per your questions:
-
“same course in a class need consecutive”: You could take the studentGroupSubjectVariety constraint in the file I liked above and invert it (because now it does the opposite of what you want) + change it to a hard constraint. You could also just leave it as a soft constraint and have a look at the results.
-
“same course in different class that has same teacher need to be taken together.”: This is a trickier request since on a larger dataset and you should think about additional questions:
- How many students can 1 teacher handle? (If there is also a Class C, D and E and all of them have music teacher Ann… are they all at the same time?). This introduces a form of “capacity”, which could be a constraint by itself.
- While rooms are not a concern for you, still something you should think about when building your constraints.
When trying to model that 2nd part, you run into the issue that you introduced a Many-to-Many relationship between a Lesson/Timeslot and StudentGroups/Class. Looking at the modeling guidelines, this is not a good strategy. I do not have a clear answer for that one yet, but I’ll see what I can come up with.
2