prevents gaps between morning and evening

Started by kilindor, October 18, 2026, 12:24:46 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

kilindor

Hello everyone.

I wonder if there is any constraint in morning/evening mode that prevent breaks (or gaps) between morning and evening.
The study periods are: Morning from 8:00 to 12:00 and Evening from 13:00 to 17:00 (4 hours morning and 4 hours evening).
The problem is that, sometimes, students study from 8:00 to 10:00 and rest (or gap) until 15:00 to 17:00.
What I want is if the students study from 8:00 to 10:00, and there are any evening sessions, they must begin at 13:00 or 14:00 NOT 15:00.


There is one more thing.
I want to avoid a situation where students have only two sessions a day and these two sessions are in LAST two hours of the afternoon.
What I mean is, for example, on Monday, you might find a group that only has lessons during the last two hours of the afternoon. I want to prevent this.

Liviu Lalescu

Hello,

For the first problem, you might want to try students max gaps per real day.

For the second problem, we need a new constraint, to ensure that if a students set has activities in some slots, it must have activities in other slots. This is unfortunately more complicated. I'll add this in the TODO.

kilindor

Quote from: Liviu Lalescu on October 18, 2026, 12:32:50 PMHello,

For the first problem, you might want to try students max gaps per real day.

Good it works, thank you

pinnabilli

Hello,

I have a suggestion for the second problem, since I had to face something similar.

In the following, I assume that the timetable spans over 5 real days and consider a sample group of students taking a total of 30 time slots occupied with activities. Hopefully the idea is clearer with explicit values.

  • Create a placeholder activity, with no students and no teachers, consisting of 5 subactivities with duration 1 (A1 to A5). Set "min 1 days between" to make sure the subactivities spread over the week, once every real day.
  • Add constraint "preferred time slots", so that A1 to A5 have to be placed between 8:00 and 15:00 (non-critical hours).
  • Add constraint "a set of activities occupies max time slots from selection" with all real activities of the group and the additional placeholder activity; mark every time slot of the timetable and set 30 as the maximum. The real activities cannot overlap, because of the students assignment, so every placeholder subactivity is forced to be paired with one real (sub)activity; since placeholders are not in the critical hours, at least one real activity per day is kept away as well.

Repeating the steps with every distinct group of students yields the expected constraint overall. Did I miss something?

Liviu Lalescu

Just wow, Lorenzo!  :)  I saw you were an advanced user.

pinnabilli