Comput. & 0~s. I&. Printed in the U.S.A.
Vol. II, No. 4. pp. 351-360,
1984 Q
EXAMINATION TIMETABLIN~
03Osa548/84 1984 Pergamcn
$3.00 + .ra Press Ltd.
BY COMPUTERS
GILBERT LAPORTE~ and SYLVAIN DESROCH@ hole des Hautes Etudes Commerciales de Montreal, 5255 avenue Decelles, Montreal, Canada H3T 1V6 Ah&at%--This paper describes an automatic procedure for constructing examination timetables in universities. The program produces schedules in which there are no conflicts and such that examinations are spaced out as evenly as possible for most students. Various constraints regarding room utilization and time restrictions for certain examinations can be taken into account. The program is efficient and reliable. It is accessed through a simple and comprehensive input routine. The output provides enough information to enable the user to make changes by hand if necessary. The implementation of the program in a business school is described.
I. INTRODUCTION
Examination timetabling is becoming an important operations management problem in universities. The complexity of the problem depends largely on the amount of freedom students have in the choice of courses. In general, greater freedom of choice increases the difficulty of producing an examination schedule to fit into a limited time interval without creating timetable conflicts for some students. As well as avoiding conflicts, timetables must be built to respect room capacities, and to space out examinations as evenly as possible for most students. There may also be other criteria or restrictions that complicate the problem further: some examinations must be held on specified days, other examinations may not take place at given periods, or in certain rooms, etc. The examination timetabling problem has been studied by several authors[2, 3, 6, 7, 9-111 in the Operational Research literature. These studies are, in our opinion, never entirely satisfactory since they generally address themselves to special cases of the problem corresponding to very specific situations and do not offer enough flexibility to make them generally useful. While our work is not perfect in this respect, we believe it offers more generality and flexibility than previous studies. The interactive computer-assisted system recently described by Romero[S] belongs to a different category: instead of being completely automated as are most methods, this system is based upon constant negotiation between all parties involved into the construction of examination timetables (administration, departments, students), until a suitable timetable has been obtained. This method assumes that some constraints may be relaxed in the course of the process. Whereas such a method may be appropriate in a context where some constraints can easily be removed, it may prove infeasible in tighter problems such as those tackled by our method. 2. MAIN
FEATURES
OF THE HORHEC
SYSTEM
The system (HORHECY) described in this paper is currently in use at the Ecole des Hautes Etudes Commerciales de Montreal (HEC) and is also being implemented at the London School of Economics. It incorporates the following features:
fThis work was supported by the Canadian Natural Science and Engineering Research Council (grant A4747) and by the Ecole des Hautes Etudes Commerciales de Montreal. $Gilbert Laporte obtained the Ph.D. in Operational Research from the London School of Economics in 197.5. He is now associate professor at the EcoIe des Hautes Etudes Commerciales de Mont&l. His main research interests lie in the areas of scheduling, location and routing. He is the author or the co-author of several publications in O.R. journals. @ylvain Desroches holds a B.Sc. in Computer Science from the University of Montreal. He has worked for several years as a programmer on various projects including automatic translation and examination timetabling. llSystbme d’HORaires d’examens de I’Ecole des HEC. 351
352
G.
LAP~RTE and S. DBSROCHES
2.1 The schedule (i) A lower bound and an upper bound for the length of the schedule are specified by the user. The program attempts to produce the shortest possible schedule within these bounds. (ii) Examinations can be scheduled for several different periods (AM, PM, evening) each day. (In this paper, a list will be attached to each period on a given day. Thus, if there are D days in the schedule, and P periods per day, the total number of lists in which examinations may be placed is equal to D x P.) Currently, only three periods are being considered, but there is no reason why more could not be included. (iii) Examinations are scheduled so that there are no conJticfs (i.e. students are never required to take more than one examination at the same time). If the program fails to produce a conflict-free solution, a partial schedule is then printed, together with a list of all examinations which cannot be scheduled. (In[6], solutions containing conflicts were allowed.) (iv) Examinations are also spaced out as evenly as possible (for as many students as possible) in the timetable. This will be explained in more detail in Section 3.2. (v) Constraints restricting (or forbidding) the positioning of certain exams in a specified subset of lists may be set. (vi) Similarly, it is possible to define a set ofpreferred lists for each examination. (There is no guarantee that such preferences will be respected in the final timetable, although some attempt is made to do so.)
(i) The set of rooms in which examinations are held may vary from list to list. (ii) There may be T types of mxns. Some examinations may only be held in certain types of rooms. (iii) Examinations are allocated to rooms in such a way that: room capacities are never exceeded; as far as possible, only one examination is allocated to a room; each examination is held in as few rooms as possible; when an examination must be split into two or more rooms, the distribution of students over the rooms is relatively uniform. 2.3 Users’ options (i) The user controls many of the parameters of the program and can, to a large extent, influence the design of the timetable. (ii) Input data are specified through a simple format. These data are displayed by the program to allow corrections to be made. (iii) The program produces as many solutions as requested by the user. (In theory, some of these solutions could be identical although this possibility is remote in practice.) (iv) Various tables are produced in order to enable the user to make minor manual changes to the schedule if he so wishes. HORHEC differs from a previous system (HOREX) developed by the authors and Rousseau[3] in the following ways: in HOREX there were only AM and PM exams, no room specifications (only the total capacity was considered), and no constraints or preferences on the positioning of examinations in specified lists; moreover HOREX attempted to move examinations to AM periods in as much as possible and did not contain an opti~zation procedure as general as that used in HORHEC.
3. PROBLEM
FORMULATION
The production of examination schedules is a complex combinatorial problem which can be broken down into three main parts: (i) construction of an initial feasible schedule; (ii) improvement of the initial schedule; (iii) room allocation. We first present the notation and formulation associated with the first two parts. (The third part which is executed in accordance with the principles listed in Section 2.2 (iii) does not require any particular notation for the understanding of this paper.) The associated algorithm is described in Section 4.
Examination timetabling by computer
353
3.1 Construction of an initial feasible schedule Basically, the problem consists of scheduling E examinations in L lists without creating conflicts. We use the following notation: examinations: lists:l-
i = 1, . . . ,E
l,...,L.
L is an integer lying between a lower bound &,, and an upper bound L_, specified by the user. Each examination i may only be assigned to a prespeeified subset Li of lists. types of rooms: t = 1,. . ,T. Each examination i may only be held in a prespecified subset q of types of rooms. For each list 1, we define a set of blots (1, t), one for each type of room allowed for that list. The final solution consists of an enumeration of the examinations assigned to each sublist, together with their precise room allocations.
total number of seats available in rooms of type t for list 1. number of students entered in examination i number of students simul~neously entered in ex~nations i and j(i cii; i, j = 1, . . . ,E and i < j). Formally, we seek values of x,, satisfying the following ~nstrain~: xti, + x,r(< 2 - c,/M
(i, j = 1, . . , ,E and i
(1) (2) (3)
x,=Oorl
(i=l,.,,, t=l
E;l=l,...,
, . . . ,T).
L; (4)
Constraints (1) ensure that if any students are entered in examinations i and& then these two examinations may not be scheduled in the same list (if cQ= 0, the constraint is ineffective; if Cij> 0, it is equivalent to xi!, + xirt 5 1). Constraints (2) guarantee that the capacity of each type of room is never exceeded. Constraints (3) and (4) assign each examination to one and only one sublist. 3.2 Irnprovernent of the initial schedule In most practical situations, there are several feasible solutions to the examination scheduling problem. It is therefore advisable to define a function which assigns a cost to each potential schedule. We consider two kinds of costs: aversion costs and proximity costs. (i) Aversion costs. For each examination i and each list 1, the user can specify an aversion cost pti The larger the aversion cost, the less desirable it is to assign the
354
G.
LAPORTE
and S. DESROCHFS
examination to the list. (Currently, the program uses only two values: pi, = 0 or 0.75. The user needs only specify pairs (i, I) for which pu = 0. In all other cases, pi, = 0.75.) (ii) Proximity costs. As a rule, a good examination schedule will be such that most students will have their examinations spaced out as much as possible in the schedule. If a student has to take two examinations, then these two examinations should ideally be separated by a reasonable amount of time (one or two days, say). In practice, the program assigns to each pair of examinations a cost w, which depends on s, the number of lists separating the two examinations. The program uses 5 different values of w,. Since examinations can be scheduled over three different periods each day, this means that in practice, any spread of two days or more between two examinations generates no penalty. The penalty is a decreasing function of the number of lists between two examinations. We currently use the following weights: w, = 16, w, = 8, w, = 4, w, = 2, w5= 1. For example, two examinations taken by the same student and separated by only two lists (one in the morning and one in the same evening, say) will cause a cost of 8 for that student; two examinations separated by a full day will create a cost of 4, etc. The objective of minimizing “second order conflicts”, i.e. students having to take two examinations in a row is present in some algorithms [2,3,6, 10, 1l] although this notion is generally restricted to examinations taken in the morning and the afternoon of the same day. No weight is given to higher order conflicts. (iii) Cost function. The cost function which is minimized by the algorithm includes two main terms, one related to the aversion costs and the other to the proximity costs. It is given by F = f: F 9, xi/reiPi/ + i k I-1 I-1 t-1 i-l
I? $
?
1,1’-I
ij=l
s-l
(xi,lxj,/-s.r’+ xilrxj,l+s.r’)cij’+‘s.
In this expression x~,,_~,,,and x~,~+~,,,are not defined for 1 - s < 1 and 1 + s > L respectively. Variables xi,, which are not defined are obviously not included in the sums. Note that each student registered for an examination contributes towards the aversion cost but that only the number of conflicts between pairs of examinations is included in the proximity cost. Room allocation has no bearing on the cost.
4. ALGORITHM
Constraints (l), (3) and (4) define a graph coloring problem [ 1,9,12]. Each examination is represented by a vertex in a graph; vertices i andjare joined by an edge if and only if cii > 0. The problem consists of coloring each vertex with one of L colors in such a way that no two connected vertices have the same color. The minimum number of colors required is called the chromatic number of the graph[l2]. This problem is NP-hard[l]. Our problem is more complex due to the presence of capacity constraints (constraints (2)) and of particular list and type of room specifications. Classical algorithms for graph coloring are therefore not directly applicable to our case. Further, the problem cannot be solved by classical integer programming methods as the execution time would be prohibitive for most problems of realistic dimensions. It is also unrealistic to look for the optimal solution in a problem in which the objective function is largely arbitrary and does not reflect a true cost. We seek an algorithm with the following characteristics: (i) the algorithm must be reliable: whenever there exists a feasible solution to the examination timetabling problem, there must be a high probability that at least one solution will be found; (ii) a reasonable attempt must be made to minimize F; (iii) the algorithm must be efficient and polynomially bounded. The program is accessed through a simple and comprehensive input routine. The output is clear and complete: it provides the user with pertinent tables and sufficient information to make last minute changes (by hand) to the solution[4].
Examination timetabling by computer
355
The algorithm is divided into four parts: Part 1: Construction of an initial feasible schedule Step 1. Set L, the number of lists, to &, - 1. Step 2. Increase L by 1. If L > L_, no feasible schedule can be found. (The program terminates by printing a partial schedule.) Step 3. Take an examination (examination i, say) from the waiting list, i.e. the list of all examinations not already scheduled. If the waiting list is empty, all examinations have been scheduled and the program proceeds to part 2. Step 4. Go through all sublists (l, t). Identify all sublists to which examination i can be assigned, i.e. CELLand &r; the allocation would create no conflicts (constraints (1)); room capacities are not exceeded (constraints (2)). If no such sublist can be found, go to step 6. Step 5. For each list 1 identified in step 4, calculate the increase in F which would result in assigning examination i to that list. Assign the examination to the list 1 which creates the smallest cost increase (and to any sublist (1, t) of 1). Go to step 3. Step 6. Examination i could not be placed in any sublist. Consider all sublists (1, t) for which kLi and tETp For each such sublist set b,, = CDand consider all examinations j already in (1, t) for which cii > 0 and all those which would also have to be removed from sublist (1, t) in order to create enough room for i to be assigned to (1, t). For eachj, identify the sublist to which j could be moved at least cost without creating any infeasibility. (This cost includes the gain made by removingj from (1, t) and the loss incurred by moving it to a different sublist and inserting i in its place.) Let m,, be the cost incurred by moving in this fashion all moveable examinations to a different sublist. Each examination j which cannot be moved to a different sublist has to be bumped back into the waiting list. In order to ensure that the algorithm converges, no examination j can be bumped by the same examination i more than a specified number of times (currently 3 in the program). Examination i cannot be assigned to sublist (1, t) if this causes this limit to be exceeded. The cost b,, of bumping a set S of examinations from sublist (1, t) is equal to ZiEsni where ni is the number of examinations in conflict with i. When it is not necessary to bump examinations from sublist (1, t), b,, is set equal to 0. At the end of this search, three outcomes are possible: (i)
min b,, = CO. ItL,.rt:T,
Examination (ii)
i cannot be assigned to any sublist and the algorithm proceeds to step 2.
min b,, = 0. IEL,JET,
Then min mh is computed. Let (I*, t *) be the sublist yielding the minimum. It is possible It LJE T, to assign examination i to (I*, t*) without bumping any examinations into the waiting list. Examination i is then assigned to sublist (I*, t *) and the necessary examinations are moved to other sublists as previously identified. The algorithm then proceeds to step 3. (iii) 0 < min b,, < co. kL,sT,
Let (I*, t*) be the sublist yielding the minimum. Examinations removed from (I*, t*) are bumped into the waiting list or moved to different lists, as the case may be. Examination i is assigned to (l*, t*) and the algorithm proceeds to step 3. Part 2: Improvement of the initial schedule The algorithm repeatedly inspects all sublists, identifying the examination which would
356
G.
hPOR?E
and S. DFSROCHFS
yield the largest decrease in cost if moved to a different sublist without creating any infeasibility; each time, the best move is executed. This process terminates when no move can decrease further the value of the objective function. Part 3: Room allocation
After the (locally) optimal schedule has been found, each examination is assigned to a room. Step 2. For each sublist, rooms (and examinations) are ranked in decreasing order of capacity (number of students). The following instruction is repeated until all examinations have been assigned to a room: let s, be the size of the largest room and ei the number of students in the largest examination. (i) If ei < s,, assign examination i to room r. The unused portion of the room is considered as a “new” room having a capacity of s, - ei; it is moved to its appropriate position in the list of rooms. (ii) If ei 2 s,, s, students of examination i are assigned to room r. This automatically creates a “new” examination with ei - s, students. This new examination is moved to its appropriate rank in the list of examinations. Step 2. After all examinations have been assigned to rooms, the program identifies all examinations which have been split between several rooms. Whenever possible, students taking these examinations will be reallocated between these rooms to roughly equalize the numbers of students per room, taking into account the various room sizes. This is done in order to avoid over-utilization and under-utilization of rooms and to equalize the workload of examination proctors. Part 4: Output
Apart from producing the actual schedule, the program also provides the user with various tables on daily room utilization, the set of lists to which each examination could be moved without creating any infeasibility, and the set of examinations which could be moved to every list without creating any infeasibility, etc. The last two tables are particularly useful as users often wish to make minor changes in the schedule, even if this results in a higher overall cost. Here are some comments on the algorithm. (i) As can be observed from steps 1 and 2 of part 1, the program will always find a schedule spreading over as few lists as possible. Whereas this may be desirable from some points of view, such a schedule will generally have a higher cost than one spread over more lists. (ii) When designing the initial feasible schedule, the algorithm constantly takes account of the effect on costs, thus increasing the probability that the cost of the final solution will be near the “global optimum”. (iii) The initial ordering of examinations has no impact on the cost of the final solution. Several strategies were attempted, but all yielded solutions with roughly the same cost. This is illustrated in Table 1. In order to construct Table 1, 5 real or realistic problems were solved by using 4 strategies for the initial ordering of examinations. In strategy A, examinations were ranked in decreasing order of the number of conflicting examinations. This is the strategy currently used in HORHEC. Strategy B is similar, except that it considers the total number of student-conflicts for each examination. Strategy C ranks the examinations in decreasing order of the number of students. Strategy D uses a random order. The first entry in each cell is the value of the objective function in the final solution while the second entry is the CPU time (in seconds) required to solve the problem on the University of Montreal CYBER 173 computer. It can be seen that these values have a small coefficient of variation and that there is no dominant strategy. All problems were solved by using the prescribed minimum number of lists (L,,). (iv) Many different schedules can be obtained by merely shuflling the examinations in the initial waiting list. Our experience shows that the probability of the same schedule being repeated is extremely small.
Examination timetabling by cumputer
357
Table 1. Influence of the initial ordering on the cost of the tinal solution
flitting examinations B. Total number of conflicts C. Number of students entered in examination D. Random order :oefficientof lariation (o/p)
(v) Step 6 or part 1 is designed to minimize the number of bumpings and to converge rapidly towards a feasible solution. The size of the parameter limiting the number of times an examination can be bumped by the same examination has been found to have little effect on the overall quality of the solution. Our experience has shown that a value of 3 is sufficiently high, in the sense that it does not normally impede the finding of a solution when one exists. (vi) In part 2, efforts to improve the initial solution are relatively modest. More sophisticated moves could have been attempted (2-opt or 3-opt type exchanges [!5l)but this would have resulted in large increases in computer time. Further, our experience indicates that it is better to produce a series of different schedules (and pick the best one) rather than spending the same time improving one schedule. (vii) Part 3 ensures that only one examination will be assigned to each room whenever this is possible. (viii) The description of the algorithm is not quite complete as some details and refinements have been left out in order to simplify the presentation.
5. IMPLEMENTATION
HORHEC has now been in use at the Ecole des Hautes Etudes Commerciales de Montreal (HEC-the University of Montreal Business School) for nearly a year. The school offers various programs in the field of business administration in five of which examinations are held once or twice per semester: (i) B.A.A. (d) (Bachelors degree in Business administration-day). (ii) B.A.A. (e) (Bachelors degree in Business administration-evening). (iii) M.B.A. (iv) M.Sc. (v) Certificates (evening program roughly equivalent to one third of the B.A.A. degree). Most of these programs may have courses (and hence examinations) in common. Table 2 summarizes the data used for the construction of the examination timetable for December 1981. In December 1981, the examination period included 13 days (i.e. J&, was equal to L_), 2 of which were Saturdays. All days except Saturdays had three periods in which examinations could be held; Saturdays only had two (AM, PM). Apart from specific
!
---
Cert.
n.sc.
Y.B.A.
8.A.A. (e)
B.A.A. (d)
Program
9 62
15
28
26
43
Number of examinations
26
15
15
26
Number of lists allowed
17682
0.2(.004)
1.21.028)
7258
0.4(.009)
8.2(.191)
18.9f.440)
B.A.A.(d)
86
__
O.O(.OOO) -_
0.0(.000)
0.0(.000)
l.ll.119) 2.9(.321)
3.3(.119)
0.1(.009)
0.3(.028)
13.7(.490)
0.0(.001)
0.3(.009)
n.sc.
0.2(.009)
0.0(.001)
11.5(.444)
5.0(.191)
M.B.A.
of conflict matrix
B.A.A.(e)
Sumary
1981 examinations
1612
152s
7201
Number of student examinations
Table 2. Data for the December
i
'O.kq.325)
O.O(.OoO)
0.0(.000)
0.0(.000)
0.3(.004)
Cert.
Examination timetabling by computer
359
restrictions, B.A.A. (d) and MSc. examinations could be held in the morning or in the afternoon of any day; other examinations could only take place in the evening or on Saturdays. The summary of the conflict matrix given in Table 2 was obtained in the following way. Let C, be the conflict matrix between examinations of program p (rows) and those of program q (columns). The first entry in row p and column q of the table indicates the average number of examinations of program q in conflict with examinations of program p. It is the average number of non-zero entries in rows of C,. For example, M.B.A. examinations conflicted with an average of 1.1 M.Sc. examinations while M.Sc. examinations conflicted with an average of 3.3 M.B.A. examinations. The second entry (in parenthesis) of the table is the density of conflicts between examinations of program p and those of program q. It is equal to the percentage of non-zero elements in C,. Although the conflict matrix for the 168 examinations had a density of only 11.8x, this density was much higher within each program and reached 49% for the M.B.A. (The overall density was 29.4% in[6].) Some programs involving many conflicts had to be scheduled within relatively few lists and in few rooms. Further, particular restrictions were imposed for many examinations (some of them could only take place in one given period or on one given day). The task of building a feasible examination schedule was therefore far from trivial. Until 1981, the schedule was constructed by hand but was not always free of conflicts: there were often conflicts involving 1 or 2 students for whom special arrangements had to be made. Furthermore, before HORHEC was used to produce the schedule, it was not possible to handle as many room or time restrictions. The examination schedules that were constructed by hand did not use an explicit objective function (the quality of each schedule was appraised in a global way by checking that large groups of students did not have to take two “difficult” exams in succession). Moreover, as we mentioned, these schedules were strictly speaking infeasible since they contained conflicts. The introduction of a reliable automatic method which could “guarantee” a good feasible solution, handle various restrictions and produce useful data and reports, was therefore welcome. In December 1981, HORHEC was used to produce 10 (different) schedules. This proved useful: although all these schedules had roughly the same objective function value and were quite satisfactory as far as the spread of examinations was concerned, not all of them were equally acceptable to program administrators and student representatives to whom they were presented. For example, some schedules were rejected because the most difficult examinations (typically those of a quantitative nature) had all been placed in the first half of the schedule. (Presently, HORHEC does not handle constraints imposing a minimum elapsed time between various pairs of examinations. It is felt that the introduction of such an improvement to the program would prove worthwhile if it did not result in excessive additional input specifications or computational complexity.) Further tests demonstrated that all examinations could be scheduled in only 10 days by keeping only the constraints that all B.A.A. (d) and M.Sc. examinations had to be scheduled in the daytime while other examinations had to be held in the evenings or on Saturdays. (The value of F was of course much higher.) Apart from printing the actual schedule (a comprehensive schedule and one for each program), as well as various information pertaining to room utilization, cross-reference tables, etc., HORHEC produces tables describing various ways in which the schedule could be altered while remaining feasible. This allows the user to make a few last minute changes without rerunning the program and thus taking the risk of losing a schedule which is otherwise satisfactory. HORHEC is fairly efficient and cheap to run. In December 1981, it took about 30 seconds of CPU time to produce 10 schedules on the University of Montreal CYBER 173 computer. The program has been tested on several real and artificial problems presenting realistic characteristics. In all cases, several good feasible solutions were easily obtained. The authors would be glad to discuss the applicability of their program to other universities.
360
G. LAPORT~and S. D~R~CHES
REFERENCES 1. D. Brelaz, New methods to color the vertices of a graph. C.A.C.M. 22(4), 251-256 (1979). 2. P. W. Chan and G. M. White, An algorithm for examination scheduling: Theory and practice. Proc. CPS Session 1978, CanaaYan Computer Conference, Edmonton, pp. 244-249 (1978). 3. S. Desroches, G. Laporte and J. M. Rousseau, HORBX: a computer program for the construction of examination schedules. ZNFOR 16(3), 294298 (1978). 4. S. Desroches and G. Laporte, Manuel d’utilisation du systhe HOZUZEC. Ecole des Hautes Etudes Commerciales de Montreal, 38 pp., 1981. (English translation: Mrmual of the HORHEC System, by M. P. Argyle, The London School of Economics and Political Science, 1981.) 5. S. Lin, Computer solution of the travelling salesman problem. Bell System Tech. J. 44,2245-2269 (1965). 6. N. K. Mehta, The application of a graph coloring method to an examination scheduling problem. Interfaces 11(5), 57-64 (1981). 7. J. E. L. Peck and M. R. Williams, Algorithm 286-examination scheduling. C.A.C.M. 9(6), 433434 (1966). 8. B. P. Romero, Examination scheduling in a large engineering school: a computer-assisted participative procedure. Interfaces 12(2), 17-24 (1982). 9. D. J. A. Welsh and M. B. Powell, An upper bound for the chromatic number of a graph and its application to timetabling problems. Comput. J. 10, 8586 (1967). 10. G. M. White and P. W. Chart, Towards the construction of optimal examination schedules. ZNFOR 17(3), 219-229 (1979). 11. D. C. Wood, A system for computing university examination timetables. Comput. J. 11,4147 (1968). 12. D. C. Wood, A technique for coloring a graph applicable to large scale timetabling problems. Comput. J. 12, 317-319 (1969).