Restrict the number of shifts worked by a teacher

Started by sergiocastro, July 23, 2025, 10:03:33 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

sergiocastro

Good evening everyone!

This year, I started using the program to develop the school schedule for the educational institution where I work, the Federal Institute of Piauí. I'm a math teacher and don't have much programming experience, so I watch YouTube videos to help me with the specifics I need. While developing the schedules during this period, I encountered a problem: the teachers at my institution cannot teach classes in all three shifts in a single day (morning, afternoon, and evening). They can teach classes in up to two shifts per day (morning and afternoon, morning and evening, or afternoon and evening). As far as I've searched, FET doesn't have a feature that restricts this.

We have courses that are Technical Courses Integrated with High School, and although each class has a preferred shift (which must be full), they still need classes in the afternoon to complete the workload (e.g., 2 INFO (Manhã) is a course that primarily has morning classes, but requires some afternoons to complete the workload). So when I tried using the tags, I couldn't get it to work. Due to my limited experience, instead of dividing the breaks, I simply created the periods and also made the break times for the classes unavailable.

The shift schedules are:
Morning: 7:30 to 12:00
Afternoon: 13:30 to 18:00
Evening: 18:00 to 22:00

Link for my code: https://gist.github.com/sergiocastro9/cfdf3d5fabfdd0ebf58bdf68394e669d


Liviu Lalescu

#1
Good afternoon,

I will add your suggestion in the TODO list. Also, for you a customization might be possible, not so difficult to implement. For the official FET, I am not sure if a new constraint - teacher(s) max (1 or 2) intervals between 3 or more intervals - could be done "perfectly" (I mean efficiently).

sergiocastro

Quote from: Liviu Lalescu on July 24, 2025, 09:00:48 AMGood afternoon,

I will add your suggestion in the TODO list. Also, for you a customization might be possible, not so difficult to implement. For the official FET, I am not sure if a new constraint - teacher(s) max (1 or 2) intervals between 3 or more intervals - could be done "perfectly" (I mean efficiently).


Thank you very much for the reply! I tried to follow Mr. Dirr's guidance, so I added the following restrictions:

Maximum gaps per day for all teachers (setting the maximum to 4 time slots, which within my schedule is equivalent to 2 hours)

Maximum span per day for all teachers (setting the maximum to 16 time slots, which within my schedule is equivalent to 8 hours)

I don't know if this was the most efficient way, but this way, besides not assigning three shifts to the same teacher, also ensured that the shifts worked were always continuous (morning and afternoon or afternoon and evening). The problem is that the schedule already has many class and teacher restrictions, so it's taking increasingly longer to generate the schedule. If I could also allow for the possibility of including morning and evening (although not ideal), it could help with the faster schedule generation.

I'm sending you the link to the current schedule again:https://gist.github.com/sergiocastro9/468427d4786fa9ea6e708858ccf543c6

Liviu Lalescu

Hello again,

I thought about your problem. I might consider adding a constraint "Teacher(s)/students (set)/activities occupy max (1 or 2) sets of time slots from selection". Please tell me if you are still interested and would use it and test it.

I have in mind for the user to have to choose a collection of sets of time slots, and the teacher (or students set or set of activities) can occupy only 1 or 2 sets of time slots from these.

Please let me know.