Hi,
In my timetable, each class has exactly one primary teacher (each primary teacher has exactly one class, though they may also teach other classes).
I want to add a constraint: every primary teacher should have at least one day per week when they teach the first two hours of their own class.
How can I model this constraint in FET?
Hello!
If you want to put a certain activity at a certain time, use preferred times. But I assume the situation is more complicated, because you don't want to choose an activity or a day, to leave more freedom for the program.
Maybe you could use the constraint activities occupy min time slots from selection. Unfortunately, I am not sure it is perfect for you. You could select all the primary activities of a teacher, and select the first two slots of each day, min occupied = 2. But the occupied slots may be on different days... hmm.
Maybe select only the first slot of each day, min occupied = 1? In this way, you ensure the teacher has one first hour with his own class.
We can talk some more if the solution above is not perfect. Maybe we can find other tricks.
I think you should use some tricks in order to get an exact solution for your problem.
1) Assign an activity tag for the primary activities of each teacher. For example if Teacher1 is the primary teacher for Class1 and Class2, you should assign the activity tag Teacher1_Class1 for his/her (primary) activities with Class1, and the activity tag Teacher2_Class2, for his/her (primary) activities with Class2.
2) Create a pseudo activity, split=1, duration=2, no teacher, no student group, subject=PseudoActivity for each one of these primary teachers, and each one of his/her primary Classes. Assign the above mentioned activity tag for each one of these activities respectively to the teacher. For example the pseudo activities for Teacher1 should have the activity tag Teacher1_Class1 (for the pseudo activity you created respectively to the primary activities of this teacher for Class1), and the activity tag Teacher1_Class2 (for the pseudo activity you created respectively to the primary activities of this teacher for Class1).
3) Use the constraint "an activity has a set of preferred time slots" for each one of the pseudo activities, selected time slots = the first two hours of each day. For example, for Teacher 1, add one constraint with the pseudo activity with the activity tag Teacher1_Class1, and another one for the pseudo activity with the activity tag Teacher1_Class2. The weight should be 100%. You can easily filter the activities using the activity tag filter. Repeat this step for each one of the pseudo activities. This is going to place these pseudo activities (with duration = 2) exactly on the first two hours of any day.
4) Use the constraint "a set of activities occupies max time slots from selection". Select (by filter - activity tag) the above groups of activities + the respective pseudo activity. For example select all the activities + the pseudo activity with activity tag = Teacher1_Class1. Select all time slots. If the number of the REAL primary activities of Teacher1 with Class1 is n, set max time slots = n. The weight should be 100%. This is going to make the pseudo activity of Class1 for Teacher 1 (which should be placed in the first two hours of any day), coincide with any two real activities of Teacher1 with Class1, which is what you need (or at least this is what I understood).
Vangelis.
P.S. Liviu... Unfortunately my eye still hurts... Could you check my answer in detail. I can't spend much time in front of my PC in order to check by myself in detail what I wrote..
Vangelis, I think I got the idea. You add an activity with duration 2, locked in the first two hours of any day, and constrain it to overlap with two hours of primary activities of a teacher. Great work! Better than mine!
I wish you good health!
Thank you Liviu.
I think there is a variant for step 3.
We could use the constraint "an activity has a set of preferred starting times" instead of the constraint "an activity has a set of preferred time slots". In this scenario the preferred starting times should be the first hour of each day. What do you think? Is this going to work? Which variant is the optimal one?
Vangelis.
Thank you as well, Vangelis! :)
Preferred times have the same generation speed, if they are similar. It is the same.