Hey,
I want to extend a model used to create timetables for stundents. I would be very grateful for any help I can get. Given the binary decision variable X(c, r, t, s, h, d) which is 1, when class c in room r is taught by teacher t in subject s at hour h on day d and a parameter teaching requirement tr(s, c), which tells you the amount of hours a class c has to be taught in subject s. hl is an alias to h.
I want to:
1.) Limit the amount of hours taught on each subject per day to 2.
2.) Limit the amount of days a subject is taught to the ceil(teaching requirement / 2) → Example: 3 hours of subject s are taught in class c: Max 2 days per class c and week where s is taught , 4 Hours → max two days, 5 hours → max 3 days and so on.
3.) If 2 hours per subject and day are assigned to a class, the teaching is supposed to be in block form, without interruption and in the same room by the same teacher.
My ideas:
1.):
MaxTwo(c, s, d).. sum((t, h, r), X(c, r, t, s, h, d)) =l= 2;
← this works I think
2.)
MaxDays(s,c).. sum((r, t, h, d), X(c,r,t,s,h,d)) =l= ceil(tr(s,c)/2);
← that does not make any sense, because it limits the amount of hours taught per week, not the amount of days taught, but I do not have a better idea.
3.)
DoubleHours(c, r, t, s, h, d).. 2*(1-X(c, r, t, s, h, d)) =G= sum(hl$(ord(hl)>(ord(h)+1)), X(c, r, t, s, hl, d));
← that does not work as intended as it does not prevent, that a different teacher teaches the same subject on the same day or that the room is changed
Do you have any idea how I can modify these equations so that they work as intended? Would be extremely thankful for any help.
Best Regards