Constructing a course schedule by solving a series of ... - GERAD

38 downloads 2693 Views 1MB Size Report
Keywords: Course scheduling; Assignment type problems ...... F(x)= E E max( 0, E. D(c)x~v-IP(Y'[(cr))l}. ctE~ 3= I cl o-E , subject to. ~ xcv = I. c~ C,. 3=1. E. D(c)xc, ...
EUROPEAN JOURNAL OF OPERATIONAL RESEARCH ELSEVIER

European Journal of Operational Research 108 (1998) 585-603

Theory and Methodology

Constructing a course schedule by solving a series of assignment type problems Alain Hertz

*, V i n c e n t R o b e r t

D~partement de Math~matiques, Ecole Polytechnique F~d~rale de Lausanne, CH-I OI 5 Lausanne, Switzerland

Received 20 April 1995; accepted 3 March 1997

Abstract

We propose in this paper a new approach for tackling constrained course scheduling problems. The main idea is to decompose the problem into a series of easier subproblems. Each subproblem is an assignment type problem in which items have to be assigned to resources subject to some constraints. By solving a first series of assignment type subproblems, we build an initial solution which takes into account the constraints imposing a structure on the schedule. The total number of overlapping situations is reduced in a second phase by means of another series of assignment type problems. The proposed approach was implemented in practice and has proven to be satisfactory. © 1998 Elsevier Science B.V. Keywords: Course scheduling; Assignment type problems

I. Introduction

Many approaches have been proposed for solving the course scheduling problem. Carlson and Nemhauser [2] formulate it as an assignment problem, Tripathy [20] uses Lagrangian relaxation, Mulvey [18] suggests a network model, while de Werra [21] analyses various graph colouring models. Additional approaches are summarised in [10]. When trying to solve real-life course scheduling problems with a set ,~ of constraints, it often turns out that a subset ~" c ~' of constraints cannot easily be taken into account. The constraints in ~" are usually considered as secondary in comparison with availabilities or non overlapping constraints. In such

* Corresponding author. Fax: + 41-21-693-4250.

a case, the scheduling problem is solved in a first phase without taking care of the constraints in ~ ' . Then, in a second phase, the constraints in ~ ' are treated manually while trying not to deteriorate the schedule obtained in the first phase. It may happen that some specific constraints impose a structure on the schedule. For example, important courses should preferably be given in the mornings. Also, most teachers ask for a compact schedule (i.e., they want to give their courses within as few days as possible, and preferably without any break). Relaxing these constraints (i.e., putting them in ~ ' ) may lead to timetables which are considered as non satisfying at all. Efficient adaptations of tabu search techniques have been proposed in [4,15,16] for solving the course scheduling problem. The objective function to be minimised is a weighted sum of components, each one measuring the violation of a given constraint. Since hard constraints (such as availabilities or non

0377-2217/98/$19.00 © 1998 Elsevier Science B.V. All rights reserved. PII S0377-2217(97)00097-0

586

A. Hertz, V. Robert / European Journal of Operational Research 108 (1998) 585-603

overlapping requirements) have large weights, it often turns out that they are satisfied in the first steps of the tabu search procedure. It is then tried to satisfy the other constraints without violating any hard one. This means that the structure of the schedule is built in the early steps, and it can hardly be modified in the subsequent steps. The tabu search approach proposed in [4,15,16] has been experimented on a real-life problem in a Swiss school. This problem will be described in Section 7. We easily got solutions satisfying almost all hard requirements and violating only few secondary ones. However, these theoretically good solutions have been considered as very bad ones by the timetable planner of the considered school. The main reason was that these solutions had no apparent structure. Therefore, the planner was not able to modify part of the schedule manually (for dealing with last minute changes or psychological constraints). We had therefore to develop a different approach which first deals with the constraints imposing a structure on the schedule. In an initialisation phase, we generate a solution that can be considered as a kind of skeleton of the desired schedule. Such an initial solution may violate many hard constraints. Then, in an improvement phase, we try to improve the initial solution without deteriorating the structure of the schedule. In order to be able to play with the structure of the solutions, we propose to decompose the course scheduling problem into a series of easier subproblems. Each subproblem is an assignment type problem (ATP) in which items have to be assigned to resources subject to some constraints. In some special cases, network flow techniques can be used for solving an ATP. Also, small ATP instances can be solved by means of a branch-and-bound algorithm. For the other cases, we suggest the use of tabu search techniques whose flexibility allows to deal with many kinds of constraints. The remainder of the paper is organised as follows. In Section 2, we describe the course scheduling problem in more details, and we give a list of the considered constraints. Section 3 will be devoted to a formal description of an ATP as well as to several solution methods which can tackle such kind of problems. We limit our description to those solution

methods which we used for solving our real-life problem. However, we do not claim that all ATPs should be solved by means of the proposed techniques. As explained above, the course scheduling problem is decomposed into a series of easier assignment type subproblems. All these subproblems are linked together in a general process which is described in Section 4. A precise description of the ATPs solved in the initial and improvement phases is provided in Sections 5 and 6. Some experimental results are given in Section 7, while Section 8 is devoted to final remarks.

2. Description of the course scheduling problem

2.1. Basic definitions and list of constraints In this section, we describe the considered course scheduling problem in more details. Each student of the school has its own curriculum. A curriculum consists of a given set of courses. The courses are divided into lectures of given length, and each lecture must be taught during consecutive time periods. The length of a lecture is its duration which is supposed to be at most two periods. The set of available periods of the week within which all curricula must be completed is given. Each day consists of at most two half days (i.e., morning and afternoon) with a fixed lunch time in-between. The periods in each half day are consecutive and their number is called the length of the half day. Some periods (for example in the late afternoon) are called bad periods in that sense that important courses should not be scheduled at these periods. The students are classified according to their level. The curricula of two students with the same level can be considerably different. In general, a course is followed by students with the same level. The level of a course (respectively level of a lecture) is defined as the level of the students following this course (respectively lecture). Some courses appear in the curriculum of each student having the same level. Such courses are called compulsory courses as opposed to optional courses. Large courses on which numerous students are

A. Hertz. V. Robert~European Journal ¢)fOperational Research 108 (1998) 585-603

587

registered have to be repeated several times during the week. Students registered in such courses must then be assigned to a specific course section. Note that a course which is not repeated has only one section. Given teachers are assigned to each course section. All sections of a course need not be taught by the same teacher. Hence, two sections of a course may have periods in common. The availabilities of the teachers as well as the set of course sections in which they are involved are known in advance. Moreover, each teacher has a set of preferred periods during which he would like to teach. The classrooms may have limited availabilities and some of them can be intended for particular courses (for example, a laboratory for courses on chemistry or physics). All lectures of a course section should be given in the same classroom. We use the following terminology. An assignment of a starting period to each lecture is called a timetable, while an assignment of the students to the sections of the courses is called a grouping. Finally, an assignment of a classroom to each course section is called a classroom assignment. Now, a course schedule is completely characterised by a triplet (t,g,a) where t is a timetable, g is a grouping and a is a classroom assignment. Solving a course scheduling problem is then equivalent to finding a triplet (t,g,a). We consider the following constraints:

3. Constraints on the students The load of a student (i.e. his total number of lecture periods) at any day is bounded by given minimal and maximal amounts. Typically, students should not have a free day in the week. 4. Constraints on the timetable The lectures of a course section must be scheduled in different days and should be distributed as uniformly as possible on the grid. A subset of specified courses should not be scheduled during bad periods. The lectures of length 2 should preferably start at an odd numbered period of a half day (i.e. the first one, or the third one, etc.) 5. Constraints on the grouping The sections of a course should have balanced numbers of students. Moreover, an upper bound on the number of students per section is given for each course. It can be imposed that given students must be assigned to a specific section of a course, or to any section except a specific one. 6. Constraints on the classroom assignment The availabilities of the classrooms should be satisfied. Some courses (for example, physics or chemistry) can only take place in a subset of classrooms. All lectures of a course section should be given in the same classroom.

1. No overlap Two lectures having students in common should not have any period in common. The lectures taught by the same teacher cannot have any period in common. The lectures assigned to the same classroom cannot have any period in common. 2. Constraints on the teachers The availabilities and preferences of the teachers should be taken into account. Because of syndical norms, a teacher must have a minimum number of half days off. The load of a teacher (i.e. his total number of teaching periods) at any working day should be large enough. For example, a teacher will hardly accept to have a working day with only one teaching period.

2.2. Notations Let C be the set of courses. For a course c ~ C we denote S(c) the set of sections of c. The set of lectures of a course section K is denoted A(K). Inversely, given a lecture A, we denote c(A) and K(A) the course and its section to which A belongs. Hence, A ~ A(K(A)) and K(A) ~ S(c(A)). Let ~ be the set of students. For a course c ~ C, we denote 2,. the subset of students registered on c. In a balanced grouping, each section of c should have about lY.,I/IS(c)l students. We denote /~,. the upper bound on the number of students in each section of c. For a student o- ~ ~., we denote S~(c) the subset of S(c) containing all sections of c to which o- can be assigned. Hence, if o- should be assigned to a

588

A. Hertz, V. Robert~European Journal of Operational Research 108 (1998) 585-603

specific section of c, then IS~(c)l = 1. Also, sections of c to which o- should not be assigned do not belong to S,(c). The level of a student o-~ ~, respectively a course c and a lecture h is denoted f ( o - ) , respect i v e l y / ( c ) a n d / ( h ) . These levels are labelled from 1 to L, where L is the number of different levels. The subset of courses having a given level / is denoted C/. The length of a lecture h (i.e., its duration) is denoted d(h). Hence, d ( h ) ~ {1,2} since we assume that each lecture lasts at most two periods. For a course c ~ C we define its duration D(c) as the total length of the lectures of any of its sections. More precisely, we have D(c) = F . ~ A(~)d(h), where K is any section of c. Let T be the set of teachers. For a course section K we denote T~ the subset of T containing all teachers involved in K. Notice that T~ may contain more than one teacher. For example, for courses on foreign languages, it often happens that the students may choose among several languages. Since the different courses must be scheduled at the same time, they are grouped into a block which is considered as a unique course with several teachers involved in it. Now, given a course c ~ C, T,. is defined as the set of teachers involved in at least one section of c. Hence, 7",.= U ~ ~ s(,.)T~. Let R be the set of classrooms. For a course c ~ C, we denote R,. the subset of R containing all classrooms in which c may be given. Let P (respectively A) denote the set of periods (respectively days) during which courses may be scheduled. We denote B the subset of bad periods and C B the subset of courses which should not be scheduled during a bad period. The subset of periods during which a teacher z ~ T, respectively a classroom r e R is not available is denoted N O ( r ) , respectively NO(r). On the basis of these sets, we can define the set NO(A) of periods during which a lecture h cannot be given. It is the set of periods p where at least one teacher in TK(~) or all classrooms in Re(a) are not available (i.e. p ~ N O ( r ) for at least one r e T,,(x), or p ~ N O ( r ) for all r~R,.ca)). Let S T A R T ( h ) denote the set of possible starting periods for a lecture h. If A is of length d ( h ) = 1, then S T A R T ( h ) is any period of P, except those in NO(A). However, if A is of length d ( h ) = 2, then

START(h) is made of all periods in P, except the last period of each half day, the periods in NO(A) and the periods preceding a period in NO(h). For a given teacher r E T, we denote PREF(~-) the subset of P containing the periods during which z would like to teach. Hence, the courses taught by a teacher ~- should preferably be scheduled during periods in PREF(r), and exceptionally during periods in P \ ( P R E F ( r ) tA NO(r)). We denote HD~. the fixed number of half days off that teacher r should have (because of syndical norms). The minimum number of teaching periods of a teacher z ~ T at any working day is denoted W,. For a student o" ~ ~, his minimal, respectively maximal_ workload at any day is denoted W~., respectively

%. The above notations do not depend on a given timetable t, grouping g or classroom assignment a. Given a timetable t and a lecture A, we denote t(h) the starting time of h. Given a grouping g, a course c and a student o - ~ , ~ , , we denote g(c,cr) the section K ~ S(c) to which o- has been assigned. Finally, given a classroom assignment a and a course section K, we denote a(K) the classroom to which K has been assigned. All these notations are summarised in Table 1.

3. Assignment type problems 3.1. A mathematical model An Assignment Type Problem (ATP) can be summarised as follows: Given n items and m resources, the problem is to determine an assignment of the items to the resources optimising an objective function F and satisfying K additional side constraints. The associated mathematical model is the following: (ATP)

Min F ( x )

subject to

l f ( s i) for all s ~ N(si)), than a risk of cycling exists since moving from s i to si+ n with f ( s i + l) > f ( s ) often implies that s i is the best neighbour of s~+ L, and si+ z will then be equal to s r In order to avoid cycling to some extent, a list T of the last modifications is kept and their reverse is considered as 'tabu moves'. We shall say that a solution obtained from s i by performing a tabu move is a tabu solution. The solutions obtained from s i by performing a tabu move are removed from N(si). In some cases, this may however be too absolute. It is shown in [22] that moves to solutions which have not yet been visited may be tabu. For this reason, the tabu status of a move is cancelled as soon as a specified aspiration criterion is satisfied. The most common aspiration criterion is the improvement of the best solution s* encountered so far. Stopping rules may be defined in different ways. Usually, the process is stopped when no improvement of s" has been obtained during a given number nmax of iterations. The basic tabu search technique is summarised in Table 2. Refinement have been proposed for intensifying or diversifying the search in the solution space ..9~. For more details, the reader is referred to [13,14,22].

A. Hertz, V. Robert/European Journal of Operational Research 108 (1998) 585-603

592 Table 2

details about this adaptation of the tabu search technique for the solution of ATPs can be found in [7].

T h e basic tabu search t e c h n i q u e Initialisation C h o o s e an initial solution s ~ : ~ ; set s * := s; ( * current best solution * ) T : = 0 ; ( * tabu list * )

4. Basic ideas

nbiter := 0; ( ' c u r r e n t iteration * ) b e s t _ i t e r := 0; ( * iteration w h e n s * has b e e n found *

while nbiter - b e s t _ i t e r < n m a x do nbiter := nbiter + 1; D e t e r m i n e the best solution ~ in

N(s), w h e r e N(s) c o n t m n s

all n e i g h b o u r s s' o f s such that e i t h e r f ( s ' ) < f ( s * ) o r s' is not tabu. Set s := ~ and update the t a b u list T;

iff(s) < f ( s * ) then set s * := s a n d b e s t _ i t e r := nbiter; end while;

As explained in the introduction, our new proposed solution method is based on a decomposition of the scheduling problem into a series of easier assignment type subproblems. We first give the basic ideas which are used for providing the schedule with a desired structure. We then describe the general process for solving the scheduling problem.

4.1. How to build an initial structure More than one adaptation of the tabu search technique can be defined for dealing with an ATP. We have implemented the approach described in [7] which can be summarised as follows. The set ~ of solutions is defined as the set of assignments satisfying constraints (2.1) and (2.3) (i.e. such that each item i is assigned to exactly one resource j ~ Ji). Given a solution x ~,')~, the total violation of constraints (2.2) is denoted It(x). We have: K

Ir(x)=

EMax{0,Gk(x)}k=l

The function f which is minimised during the tabu search process is a linear combination of the function Ir and of the objective function F of the ATP. More precisely

f ( x) = a F( x) + fl lr( x), where a and /3 are positive parameters which can have variable values during the search process. It is therefore possible to put emphasis on feasibility (i.e. on constraints (2.2)) for a few iterations by using large values of /3. If no assignment can be found which satisfies all constraints (2.2), then the procedure described in [7] delivers a solution which minimises F among those solutions with the smallest lr value. A move is performed by modifying the assignment of exactly one item. If an item i is moved from resource Jl to resource J2, then the pair (i,jl) is introduced into the tabu list in order to forbid the assignment of item i to Jl during ITI iterations. More

When solving real-life course scheduling problems, we have observed that the timetable planner often uses helpful tools for finding an initial solution. For example, by colouring the periods of the grid, he can easily visualise a desired structure on the schedule. Also, in the process of building a first schedule, we have noticed that the main objective of the planner is to give a certain structure to this initial solution so that overlapping situations will be more easily handled in a subsequent improvement phase. In order to imitate this way of doing, we assign a colour to each lecture and to each period of the grid. We impose that all lectures taught by a given teacher must have the same colour. It follows that a colour can be assigned to each teacher. Finally the assignment of a lecture A on the grid is restricted to periods coloured as A. By doing this, it becomes easier to detect overlapping situations where two lectures taught by a given teacher share a common period. Indeed, such an overlapping situation can only occur on periods having the same colour as the considered teacher. More precisely we first colour, at each level, all periods of the grid and we impose that each period must receive different colours at different levels. Formally, let yp/ denote the colour assigned to period p at level / . Given any period p ~ P and given two different levels / l and / 2 , we impose that yp/, ~ yp/,_. We then assign a colour to each lecture with the constraint that all lectures involving any given teacher must receive the same colour. Finally, we assign a

A. Hertz. V. Robert/European Journal of Operational Research 108 (1998) 585-603

starting time to each lecture A in such a way that all periods during which A is given have the same colour as A. According to these rules, two lectures given by a teacher ~- at different levels do not share any common period. Hence, an overlapping situation involving ~" can only occur for two lectures A] and A2 having the same level / . Now, by moving /~1 or /~2 to periods of the grid having the same colour as Al and A2 at level / , we do not create any new overlapping situation involving teacher r at a level

t ' @1. Let P(y,f) denote the set of periods with colour y at level t . Remember that the length d(A) of a lecture A is either 1 or 2. If lectures are given during all periods of a set P(y,/) having an odd cardinality, then at least one lecture A of level / ' and length d(A) = 1 has been assigned to a period of P ( y , / ) . Such a restriction does not exist if P(y,/') is made of pairs of consecutive periods. According to this observation, and in order to have as much flexibility as possible when assigning a starting time to the lectures, we shall only consider sets P(y,t) made of pairs of consecutive periods. Because of the lunch period, the last period in the morning and the first in the afternoon are not considered as consecutive. Hence the partition of P into subsets made of pairs of consecutive periods is not possible if there are half days of odd length. Let H c P be the set containing the last period of each half day having an odd length. We shall only colour the periods of P' = P\H. For example, if a half day has 5 periods, then the first two periods receive the same colour Yl, the third and fourth one receive the same colour Y2 (which is possibly equal to yi), while the last period is not coloured. As mentioned above, all lectures taught by a teacher r ~ T must have the same colour, say y. If r has to give many lectures at a given level / , and if P(y,/) has a small number of periods, then many overlapping situations will necessarily occur. In such a situation, the lectures taught by r will preferably receive a colour y for which IP(y,t)l is large enough. In order not to favour any colour for any teacher, we have decided to use as few colours as possible and to balance the size of all sets P(y,t). More precisely, since the colours of a period at two different levels must be different, at least L colours

Monday

colour 1

Tuesday

~

Wednesday

colour 2



593 Thursday

colour 3



Friday

colour 4

Fig. 1.

are needed. This is exactly the number of colours we use. Moreover, given any pair (yl, Y2)of colours and any pair ( f l , f 2 ) of levels, we impose that Ie(yl,ti)l- Ie(y2,12)l = - 2 , 0 or 2. It follows that a set P(y,f) has either ~/= 211P ' 1 / 2 L] or q = 211P' I/2 L] periods. For example, consider a grid with IP'l = 36. If L = 3, then each colour appears ? / = q = 12 times. If L = 4 , then _q = 2[36/8] = 10 and ~ = 2[36/8] = 8. Moreover, at any level f (1 _ 1, and any period p ~ P', we set: Yp/=

( Ypl + f - - 2) mod L + 1.

In this way, each period p ~ P' has different colours at different levels. Now, remember that each set of periods with a given colour at a given level must be made of pairs of consecutive periods. It is therefore sufficient to determine the colour of each odd numbered period p ~ P' of each half day. Each even numbered period of a half day is then coloured as its preceding period. Let Podd be the subset of P' containing the odd numbered periods of each half day. We define each period p ~ Pond as an item and each colour y (I < y < L) as a resource. The colouring problem is then equivalent to finding an assignment of the items to the resources with the additional constraint that exactly q / 2 or ~ / 2 items must be assigned to each colour. The objective is to have a uniform distribution of each colour on the grid. For an assignment x and a colour y, let s~.(x) (respectively ~y(x)) denote the smallest (respectively largest) number of periods in P' between the end of a pair of consecutive periods with colour y and the beginning of the next one with colour y. For computing these values, the week is considered as cyclic. Consider for example the periods having colour 4 in the assignment represented in Fig. 1. There are 18 periods between the last pair of consecutive periods on Friday and the pair on Wednesday. This is the largest difference between periods having coiour 4. Hence, ~4(x)= 18. The smallest difference occurs on Friday since pairs of consecutive periods are immediately followed by pairs having the same

A. Hertz, V. Robert~European Journal of Operational Research 108 (1998) 585-603

colour. Hence, s 4 ( x ) = 0. The other values for the grid in Fig. 1 are s~.(x) = 0 for each colour y (1 < y < 4), ~l(x) = .~2(x) = 28 and .~3(x) = 24. For comparison, the values for the grid on Fig. 2 are: Sl(X) = ~ ( x ) = ~3(x) = ~4(x) = 6, s3(x) = sa(x) = 4 and S I ( X ) = S 2 ( X ) = 8.

A small difference between ~y(X) and s~.(x) indicates that colour y is uniformly distributed on the grid. We therefore minimise the sum of these differences over all colours. In summary, the colouring problem for the grid at level f = 1 has the following A T P formulation: L Min

subject to

F ( x ) = Y'~ ~ ( x ) - s~.(x) L E Xp3 = 1, q/2
HD~. A lecture A of length d(A) = 2 should preferably start at an odd numbered period of a half day. Also, the subset C B ___C of courses should preferably not be scheduled during bad periods p ~ B. Given a timetable t, we can compute: • the total number EVEN(t) of lectures of length 2 which start at an even numbered period of a half day, and • the total number BAD(t) of lectures A such that c(A) ~ C 8 (i.e. A is a lecture of a course in C B) and A is given during at least one period in B. Minimising EVEN(t) and BAD(t) is part of our objective. The lectures of a course section should be uniformly distributed on the grid. Given a timetable t and a course section K, let s~(t) (respectively ~(t)) denote the smallest (respectively largest) number of periods in P between the end of a lecture A ~ A(K) and the beginning of the next one. For computing these values, the week is considered as cyclic (as in Section 5.1). A small difference between ~ ( t ) and s~(t) indicates that the lectures in A(K) are uniformly distributed on the grid. Two lectures of a course section should not be scheduled on the same day. Given a timetable t, a course section K and a day 8 ~ A, let NLECT~8(t) be the total number of lectures A ~ A(K) which are given at day 8. We impose that NLECT~8(t) cannot be larger than one unit. Given a timetable t, a grouping g, a student o-~ and a day t ~ A , let w~8(t,g) denote the workload of tr at day t~ (i.e. the total duration of the

A. Hertz, V. Robert~European Journal of Operational Research 108 (1998) 585-603

598

courses given to tr at day 6). This amount is bounded by given minimal and maximal loads W~ and W,,. Similarly, for a teacher ~-~ T, let w~8(t) denote the workload of ~" at day 3. If 6 is a working day for ~- (i.e. w ~ ( t ) > 0), then w~(t) must be at least as large as the given lower bound W~. Hence, we impose that w~(t) _> min{l,w~(t)}W~. Let I denote the set of items. We can improve a given timetable t by solving the following ATP: Min F ( x ) = a , E V E N ( t ) + a 2 B A D ( t ) + E (a3NOTPREF~(t) + a4Vz(t)) T~T

+as+

E

E

(~(t)-s(t))

c~C K~S(c)

+ Og6 E V~(t,g) + ~7 Y'- Vr(t,a) o'E2

rER

subject to

6.2.1. Global improvement of the grouping As in Section 5.3.2, we define an item ( c , t r ) for each course c ~ C and each student tr ~ ,~, registered on c. The resources are the course sections. For an item i = (c, tr), we define the set Ji of sections of c to which i can be assigned as being equal to S~,(c). Also, given an assignment x of the items to the resources and an item i = (c,o-), we set g(c, cr) as being equal to the resource K such that xi~ = 1. As in Section 6.1, given a timetable t and a grouping g, we impose that the total workload w,,~(t,g) of any student ~ r ~ X at any day 6 ~ A is bounded given minimal and maximal loads W~, and

w~. Moreover, given a course c ~ C, it is imposed that at most N students can be assigned to any section K ~ S(c). The objective is to minimise the total number of overlapping situations involving the students. By denoting I the set of items, we get the following ATP:

A~I,

E Xap=l, P~ Jx

NLECT.~(t) < 1,

3EA;

KE

U S(c), cEC

OFF.(t) >_ HD.,

~

___Wo