LATEST TRENDS on COMPUTERS (Volume II)
Towards a Deterministic Model for Course Timetabling PILAR POZOS PARRA
OSCAR CHAVEZ BOSQUEZ JOSE LUIS GOMES RAMOS University of Tabasco Department of Informatics and Systems Carretera Cunduac´an - Jalpa Km. 1, Cunduacn, Tabasco MEXICO
[email protected] [email protected] [email protected] Abstract: The Course Timetabling Problem consists in the weekly scheduling for all the lectures (events) of a set of university courses, subject to certain constraints. Unfortunately, course timetabling problems vary from university to university, and as far as we know, no standard formulation has been proposed from the community. Nevertheless, the International Timetabling Competitions, ITC-2002 and ITC-2007, have been organized with the aim of creating the common formulation for comparison. The formulation has become quite standard, and many solutions have been proposed in the literature. Most of the provided solutions utilize non-deterministic techniques. In this paper, we introduce a new deterministic algorithm for the solution of timetabling problems. The instances upon which the algorithm was tested are the official ones of the ITC-2002 web page. Almost all solutions run in less than 10% of the ITC-2002 benchmark time. The analysis is still ongoing, and it includes suitable extensions for tackling problems of the ITC-2007. Key–Words: Course Timetabling Problem, International Timetabling Competition, STF Algorithm, Scheduling Problem, Deterministic Search, Implementation.
1
Introduction
solutions and effectively participate in the contest. The motivation of this work was to develop a deterministic algorithm that solves the hard constraints of the 20 instances of the ITC-2002 in a timely manner, so we introduce a new deterministic algorithm, called the Sort Then Fix (STF) algorithm, for solving the timetabling problems. The instances upon which the algorithm was tested are the official ones of the ITC-2002. Even when the proposal solves only instances from ITC-2002, the analysis is still ongoing, and we expect suitable extension of the algorithm for ITC-2007. One of the major advantages of the proposal is that the best and worst cases are the same; this means that the running time does not need to be averaged over some number of runs. Although there is evidence of the implementation of an initial algorithm that preprocess the information problem in order to find a feasible solution [6, 7], authors do not provide the overall penalty nor the time spent in this initial phase. This deterministic algorithm may create standard feasible inputs for other metaheuristics in order to measure their real performance. This paper is organized as follows, the next section introduces the target problem; the third section presents the deterministic algorithm; the fourth section provides the results in detail, and finally we conclude and discuss some possible research directions.
The Course Timetabling Problem consists of fixing a sequence of events (lectures) of a set of university courses within a number of rooms and time periods, usually weekly, satisfying some constraints. During the recent years a large number of works has been directed to automated timetabling. Unfortunately, course timetabling problems vary from university to university, and as far as we know, no standard formulation has been proposed from the community. Nevertheless, throughout the years it has been possible to characterize common underlying formulations that could be used for comparing algorithms. In particular the International Timetabling Competitions, ITC-2002 and ITC-2007, have been organized with the aim of creating the common formulation for comparison. The formulations have become quite standard, and many solutions have been proposed in the literature [14, 6]. Even when the competition is open to stochastic and deterministic approaches, all the proposed solutions appearing in the competition web pages are stochastic [4], they utilize non-deterministic techniques, such as tabu search, genetic algorithms, simulated annealing, ant colony optimization, etc., thus the competitions missed of deterministic approaches; as far as we know there is no record of some deterministic approach to find feasible
ISSN: 1792-4251
434
ISBN: 978-960-474-213-4
LATEST TRENDS on COMPUTERS (Volume II)
2
Target Problem
• let F = {F1 , F2 , ..., FnF } be a set of symbols representing the features;
We consider the problem of weekly scheduling a set of single events (or lectures). The problem has been discussed in [1] and it was the topic of ITC-2002 [2], where twenty artificial instances were proposed. The instances are available from the ITC-2002 web page. In addition, some instances have been proposed and made available via web in [5]. The data format used is an ad hoc fixed-structure text-only one. The input data comes in a single file containing the scalar values (number of events, rooms, room features, and students), followed by the elements of the input arrays, one per line. The output format must be done in a single file containing two scalar values (room and timeslot) per line, which indicate the schedule for events. Formally, the problem consists of finding an optimal timetable within the following framework: there is a set of events E = {E1 , E2 , ..., EnE } to be scheduled in a set of rooms R = {R1 , R2 , ..., RnR }, where each room has 45 available timeslots, nine for each day in a five day week. There is a set of students S = {S1 , S2 , ..., SnS } who attend the events, and a set of features F = {F1 , F2 , ..., FnF } satisfied by rooms and required by events. Each event is attended by a number of students, and each room has a given size, which is the maximum number of students the room can accommodate. A feasible timetable is one in which all events have been assigned a timeslot and a room so that the following hard constraints are satisfied:
0
0
0
• N = {N1 , ..., NnR } be a set of integer numbers indicating the maximum of students each room can accommodate; 00
00
00
00
• Ei = {F1 , F2 , ..., FnE } where Fj ∈ F for i j = 1, ..., nEi and nEi is the number of features required by event Ei ; 0
0
0
0
• Si = {E1 , E2 , ..., EnS } where Ej ∈ E for j = i 1, ..., nSi and nSi is the number of events student Si attends; and • T = {T1 , ..., T45 } be a set of timeslots. Find a feasible solution, i.e. a set of pairs {(T10 , R10 ), ..., (Tn0 E , Rn0 E )} such that: • Ti0 ∈ T and Ri0 ∈ R • ¬(Ti0 = Tj0 ) if Ei , Ej ∈ Sk and ¬(i = j) • Ei ⊆ Ri0 and |{Sj |j = 1, ..., nS and Ei ∈ Sj }| ≤ Nk where Ri0 = Rk ; • ¬∃i∃j (¬(i = j) ∧ Ti0 = Tj0 ∧ Ri0 = Rj0 ).
(1) no student attends more than one event at the same time;
The competition adds a constraint over execution time, i.e. given the information about rooms, events, features, and students, find the best possible feasible solution within a given time limit. The time limit is given by a benchmark tool provided by the organizers.
(2) the room is big enough for all the attending students and satisfies all the features required by the event; and (3) only one event is scheduled in each room at any timeslot.
3
In contest instance files there were typically 1011 rooms, hence there are 450-495 available places. There were typically 350-400 events, 5-10 features and 200-300 students. The problem proposes to penalize a timetable for each occurrence of some soft constraint violations, which are the followings:
Algorithm ST F
We propose the Algorithm 1 to solve timetabling problems, it is based on events and rooms sorting. The first step in the algorithm, apart from the obvious actions such as reading the problem file, is to find a binary matrix that represents the available rooms for every event. The following actions are performed:
(1) a student has to attend an event in the last timeslot on a day;
• the number of students for each event is calculated and stored, ni = |{Sj |j = 1, ..., nS and Ei ∈ Sj }|
(2) a student has more than two classes in a row; and (3) a student has to attend solely an event in a day.
• a list of available rooms is created for each event, ei = {Rj |Ei ⊆ Rj and ni ≤ Nj }
The problem may be precisely formulated as:
ISSN: 1792-4251
0
• Ri = {F1 , F2 , ..., FnR } where Fj ∈ F for i j = 1, ..., nRi and nRi is the number of features satisfied by room Ri ;
435
ISBN: 978-960-474-213-4
LATEST TRENDS on COMPUTERS (Volume II)
This first step allows us to reduce the problem by eliminating the information concerning features and room capacity, defining a new event set {e1 , ..., enE }, called in the algorithm Event Room, that includes the eliminated information. The new event set will be used for defining the most constrained event. Our approach differs from direct heuristics [13], which usually fill up the complete timetable with one event at a time as far as no-conflicts arise, and then at that point they start making some swapping so as to accommodate other events. Our approach does not consider swapping; if an event cannot be schedule then the next most constrained event is scheduled letting the event in question without room and timeslot. Thus we focus in the definition of the “most constrained event” as precise as possible in order to avoid letting an event without schedule. The core strategy of the algorithm is to assign the most constrained event to the least constrained timeslot found for that event. In order to avoid strategies of movement that provide a limited form of backtracking to recover from mistakes, our aim is not to make mistakes of selection of placement and event. Algorithm 2 finds the most constrained event, the intuitive ideas is as follows: sort IX Rest (indexes of the unassigned events) in ascending order for the number of free slots, then for any index with equal number of free slots, sort them in descending order for the number students attending the event, then for any index with equal number of student attending the associated event, sort them in ascending order for the number of available rooms for the event, then for any index with equal number of suitable rooms associated to the event, sort them in ascending order for the number of potential accommodation of events in its available rooms, finally the most constrained event is the one appearing in the first place of the sorted IX Rest.
4
the soft constraints, the time in seconds taken by the algorithm running on GNU Octave 3.0, an the time R taken running on a trial version of Matlab R2009b. As the Table 1 shows, the STF algorithm finds a feasible solution in a timely manner, according to the benchmark program. It is worth noticing that the alR almost gorithm has a better performance on Matlab , all solutions run in less than 10% of the benchmark time. In order to verify the results, the participants of the ITC-2002 provide the executable file of their implementations. Nevertheless, the details are hidden in this file format. Our results can be reproduced using the source code of the STF algorithm.1
5
STF algorithm has been proposed and appears to solve timetabling problems in a natural way. The idea is intended to sort the events before scheduling. Unlike other approaches STF is defined in a deterministic manner. The STF algorithm solves effectively the 20 instances of the ITC-2002 within the time established by the benchmark program provided by the organizers of the contest. The approach utilized in the algorithm focuses only in the hard constraints, so the algorithm finds feasible solutions to the problem regardless the soft constraints. As a main contribution, the STF algorithm may be used to find an initial solution to another optimization algorithm, so it can be combined with a nondeterministic approach, such as a metaheuristic, to build a hybrid algorithm that can find a better solution faster than a metaheuristic by itself. The metaheuristics used by te other participants of the contest do a preprocessing of the problem data before starting the search process, so all of the algorithms start with a different initial solution. To tackle this issue, the timetables generated by the STF algorithm can be used as an initial solution for all of these metaheuristics, in order to measure the real effectiveness of each metaheuristic with respect to the other ones. The STF algorithm finds a feasible timetable in much less than the time available, so the next version of the algorithm intend to solve both hard and soft constraints to find perfect solutions to the 20 problem instances. Also, the STF algorithm will be extended for solving instances of the ITC-2007, in order to manage the new constraints proposed in the competition and thus close the gap between the real problems and theoretical solutions.
Results
The STF algorithm was developed in GNU Octave 3.0 R on a Toshiba Satellite A105-S433 laptop computer, with a 1.60 GHz Centrino Duo proccesor T5200, MoR bile Intel 945GM Express Chipset, 2 GB in RAM, 160 GB in HDD and the Ubuntu Linux 9.10 operating system. All tests were done in this box, according to the time provided by the benchmark tool provided by the organizers of the ITC-2002. The benchmark program took 558 seconds to end, so the STF algorithm has this time to find a feasible solution. The Table 1 shows the results obtained by the STF algorithm in the 20 problem instances of the ITC2002. The table display the hard constraints broken,
ISSN: 1792-4251
Conclusion
1 The STF implementation is available under request via email.
436
ISBN: 978-960-474-213-4
LATEST TRENDS on COMPUTERS (Volume II)
Data: Data f ile Result: Solution f ile begin T imesolots ← 45 Read from Data f ile : [ Events : Number of events Rooms : Number of rooms F ectures : Number of fectures Students : Number of students RoomCapacity Vector of number of available places of rooms Event Student Matrix of attendance to events by students F eature Room Matrix of satisfied features by rooms F eature Event Matrix of required features by events ] EventCapacity ← find number of places required by every event Event Room ← find binary matrix of suitable rooms for events Events4Room ← find for every room the number of potential events to be allocated in Room Slot ← create a matrix of onesRooms×T imeslots Event Slot ← create a matrix of onesEvents×T imeslots R S ← create a matrix of zeros2×Events IX Rest ← indexes of events for i=1 . . . Events do IXi ← find the index of the most constrained event in IX Rest IX Room ← find the indexes of suitable rooms for event IXi sort IX Room from the least to the most constrained room Events4Room ← Events4Room − Event RoomIXi for r ∈ IX Room do for s = 0 . . . T imeslots − 1 do OK ← 1, k ← 1 IX Student ← find indexes of students associeted to event IXi while k < i and OK do if R S2,IXk = r and R S1,IXk = s then OK ← 0, break for j ∈ IX Student do if Event StudentIXk ,j and R S1,IXk = s then OK ← 0, break k ←k+1 if OK then R S1,IXi = s Room Slotr,s ← 0 for j = 1 . . . Events do if any(Event Studentj,IX Event Slotj,s ← 0
Student )
then
break if OK then R S2,IXi ← r, break IX Rest ← IX Rest − IXi write to Solution f ile : [ R S ] end Algorithm 1: ST F
ISSN: 1792-4251
437
ISBN: 978-960-474-213-4
LATEST TRENDS on COMPUTERS (Volume II)
Data: IX Rest Event Room Room Slot Event Slot EventCapacity Events4Room Result: IX i begin sort IX Rest in ascending order for Event RoomIX Rest ∗ Room Slot. ∗ Event SlotIX for in case of tie do sort indexes with equal values in descending order for EventCapacityIX Rest for in case of tie do P sort idexes with equal values in ascending order for Rooms Event RoomIX Rest for in case of tie do sort indexes with equal values in ascending order for Event RoomIX IXi ← first index of the sorted IX Rest end
Rest
Rest
∗ Events4Room
Algorithm 2: find the index of the most constrained event
Table 1: Results of the STF algorithm in the 20 problem instances. Time in seconds Instance Hard constraints Soft constraints GNU Octave time Matlab time 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20
ISSN: 1792-4251
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
940 870 926 1191 1395 1387 1736 1135 937 952 958 829 1097 1605 1448 1032 1491 926 1325 1450
438
139.491 129.923 132.475 144.784 130.249 128.457 104.068 135.687 154.627 145.488 138.342 126.545 141.385 125.638 131.486 163.606 134.854 138.835 156.347 141.738
35.775 33.507 34.354 40.401 33.199 32.857 27.671 35.811 40.409 36.641 35.398 32.471 36.905 30.660 31.743 42.263 35.476 35.992 40.449 34.448
ISBN: 978-960-474-213-4
LATEST TRENDS on COMPUTERS (Volume II)
[14] Chiarandini, M., Birattari, M., Socha, K., RossiDoria, O.: An effective hybrid approach for the university course timetabling problem. Journal of Scheduling, 9 (2006) 403–432 [15] Chavez Bosquez, O., Pozos Parra, P., Lengyel, F.: Towards a Deterministic Algorithm for the International Timetabling Competition. Proceedings of the 17th International Workshop on Experimental Evaluation of Algorithms for Solving Problems with Combinatorial Explosion, RCRA (2010)
References: [1] Rossi-Doria, O., Sampels, M., Birattari, M., Chiarandini, M., Dorigo, M., Gambardello, L.M., Knowles, J., Manfrin, M., Mastrolilli, M., Paechter, B., Paquette, L., Stutzle, T.: A comparison of the performance of dfferent metaheuristics on the timetabling problem. PATAT 2002, LNCS, 2740 (2003) 329–351 [2] Paechter, B., Gambardella, L.M., RossiDoria, O.: International Timetabling Competition Webpage (2003) (viewed January, 2010) (updated July 10, 2003), http://www.idsia.ch/Files/ttcomp2002/ [3] McCollumn, B.: International Timetabling Competition Webpage (2007) (viewed January, 2010) (updated October 1, 2008), http://www.idsia.ch/Files/ttcomp2002/ [4] di Gaspero, L., Schaerf, A.: Timetabling Competition TTComp 2002: Solver Description, (viewed January, 2010) (updated July 10, 2003), http://www.idsia.ch/Files/ttcomp2002/schaerf.pdf [5] Socha, K., Knowles, J., Sampels, M.: A MAX − MIN Ant System for the University Timetabling Problem. Algorithmic Number Theory. LNCS, 2369 (2002) [6] Kostuch, P: The university course timetabling problem with a three-phase approach. PATAT 2004, LNCS, 3616 (2005) [7] Frausto-Solis, J.F., Alonso-Pecina, F., Larre, M. Gonzalez-Segura, C., Gomez-Ramos, J.L.: Solving the timetabling problem with three heuristics. WSEAS Transactions on Computers. 11-5 (2006) [8] de Werra, D.: An introduction to timetabling, European Journal of Operational Research, (1985) [9] Gotlieb, H.: The construction of class-teacher timetables. IFIP Congress, (1963) [10] Kostuch, P. Socha, K.:, Hardness prediction for the University Course Timetabling problem. Proceedings of the Evolutionary Computation in Combinatorial Optimization, EvoCOP (2004) [11] Rossi-Doria, O., Blum, C., Knowles, J., Sampels, M., Socha, K., Paechter, B.:, A local search for the timetabling problem, PATAT (2002) [12] Socha, K.: Metaheuristics for the Timetabling Problem. DEA Thesis, Universite Libre de Bruxelles, (2003) [13] Schaerf, A.: A survey of automated timetabling, Technical Report. Centrum voor Wiskunde en Informatica, (1995) ISSN: 1792-4251
439
ISBN: 978-960-474-213-4