Postprocessing the solution
Using postprocessing statements and scripting capabilities.
To present the solution, the model uses OPL postprocessing statements and scripting capabilities.
To specify postprocessing:
- Define the
Coursetuple which is used to aggregate information from theroom,teacherandstartdecision variable arrays.{Course} timetable[t in Time][c in Class] = { <p,d,r,i,n> | d in Discipline , r in Room , x in InstanceSet , n in x.repetition..x.repetition , p in Teacher , i in x.id..x.id : (t >= startOf(courses[x])) && (t < endOf(courses[x])) && (x.Class == c) && (roomRes[x] == ord(Room,r)) && (ord(Teacher,p) == teacherRes[x]) && (d == x.discipline) }; - Write the postprocessing script which iterates over the
solution-derived course set to pretty-print, for each class, what
will be the courses, the dedicated teacher, and the assigned room.
execute POST_PROCESS { timetable; for(var c in Class) { writeln("Class ", c); var day = 0; for(var t = 0; t < makespan; t++) { if(t % DayDuration == 0) { day++; writeln("Day ", day); } if(t % DayDuration == HalfDayDuration) writeln("Lunch break"); var activity = 0; for(var x in timetable[t][c]) { activity++; writeln((t % DayDuration)+1, "\t", x.room, "\t", x.discipline, "\t", x.id, "/", x.repetition, "\t", x.teacher); } if(activity == 0) writeln((t % DayDuration)+1, "\tFree time"); } } }