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.):
Code: Select all
MaxTwo(c, s, d).. sum((t, h, r), X(c, r, t, s, h, d)) =l= 2;
2.)
Code: Select all
MaxDays(s,c).. sum((r, t, h, d), X(c,r,t,s,h,d)) =l= ceil(tr(s,c)/2);
3.)
Code: Select all
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));
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