Chapter 3 GAs for timetabling William F. Nice Department of Information Technology and Industrial Management University of Vaasa , P.O. Box 700 , FIN-65101 Vaasa , Finland Abstract . This paper is a condensed version of the author 's M.Sc . dissertation which he has done at the University of Newcastle upon Tyne -LSB- 977 -RSB- which investigates the use of genetic algorithms for timetabling . More specifically , a genetic algorithm is devised to schedule the lectures and practicals of the third year honours computing science students at the University of Newcastle upon Tyne . The problem has a number of time slot constraints with respect to students which are to be minimised . This problem is very difficult to solve due to the extremely large number of possible timetables , and the problem of simultaneously satisfying a large number of students . This paper describes , the chromosome representation employed for the problem , and discusses the performance of GAs for solving this timetabling problem . 3.1 Introduction In a scheduling problem , events must be placed into a set of time slots , so as to satisfy a number of constraints and to optimise a set of objectives . The various kinds of scheduling problems differ in the type of constraints and objectives involved . Solving scheduling problems is very challenging due to the following factors : The complete title of this article : Genetic algorithms for timetabling . 35 36 Proceedings of the 1NWGA , Vaasa , Finland , 9 - 12 January 1995 ffl The search space being extremely large and therefore making undirected search techniques unfeasible . ffl Intelligent searching algorithms -LRB- hill-climbing and heuristic searches -RRB- are not guaranteed to find an optimum solution or near-optimum solutions , as in general , scheduling problems have very many local minima . ffl The complexity of a scheduling problem is usually further complicated by the specific characteristics of a particular scheduling job . ffl Real word scheduling can often contain constraints that can not be precisely defined or represented . Scheduling problems are computationally complex tasks usually with domaindependent attributes , and therefore need domain specific optimisation algorithms . GAs provide a mechanism for dividing the optimisation process from the domaindependent attributes , thus should be suited to scheduling problems . 3.2 Timetable problem outline The most important constraint , central to all timetabling problems , is that there should be no clashes between events . That is , any pair of events which share the same students should not be placed in the same time slot . In general , when a timetabling problem is tackled in a University department , it is done by hand by a course organiser . An initial draft of the timetable is produced , followed by several weeks of redrafting after feedback pointing out a particular deficiency with the present draft . The initial draft is generally based on merging different department 's course timetables . However , in large modular degree schemes , students can take courses from many different departments and usually there are different timetables for either semester . This makes this particular scheduling problem full of local minima , which require much repair for the global optimum or just near-global optimum -LRB- better -RRB- solutions to be found . The timetabling problem is extremely complex when you consider that , when a timetable consists of e events and t time slots , then there are te possible timetables . These timetables vary in optimality depending on the type and number of constraint violations . The dissertation applied GAs to the 94/95 third year honours Computing Science ? timetable , hereafter referred to as the 3H timetable problem . The 3H timetable problem has forty time slots and twenty-four events , thus the problem has 4024 possible timetables . The performance of an undirected random search technique on this problem will typically be a function of the search space representing good solutions which is usually extremely small , therefore making this ? Studied at the University of Newcastle upon Tyne . William F. Nice : GAs for timetabling . 37 09:00 10:00 11:00 12:00 13:00 14:00 15:00 16:00 Mon Tue Wed Thu Fri Table 3.1 : 3H 's time slots method useless . Heuristic search techniques usually find an optimum or nearoptimum solution for timetabling , however when the search space is this large this method will be very time consuming . GAs are very good at finding the global optimum solution in hilly problem search spaces , as they are usually fast traversers of a problems search space and are intelligently guided to the optimum solution through a fitness function . Thus GAs should be suited to the 3H timetable problem . The purpose of this project was to investigate the application of GAs to a timetabling problem . The timetabling problem is that of placing 3H 's lectures and practicals into time slots so as to minimise certain constraint violations . A timetabling problem is a scheduling problem were a certain number of events have to be placed into a certain number of time slots , subject to various constraints . Room and lecturer allocation , and specific resource needs are not considered in this dissertation . This is because adding these extra constraints was not considered feasible , due to the small amount of time availabley . However , these extra factors are discussed in the conclusion . 3.3 Timetable problem domain A general timetabling problem is one where events -LRB- e1 , e2 , ... , eN -RRB- have to be placed in time slots which occur at specific times -LRB- t1 , t2 , ... , tN -RRB- . In any particular problem , there are constraints on whether certain events can appear in the same time slot , adjacent time slots , etc. . In the 3H timetabling problem , the events are lectures and practicals , and there are 40 time slots for both semesters -LRB- Table 3.1 -RRB- . The other parameters of the problem , that will effect the performance of the GA -LRB- difficulty of problem -RRB- are : ffl 3H contains 40 students . ffl There are 8 courses per semester . yThree months are allocated for a dissertation in `` Computing Software and Systems Design '' M.Sc . course at the University of Newcastle upon Tyne . 38 Proceedings of the 1NWGA , Vaasa , Finland , 9 - 12 January 1995 ffl A student chooses 4 courses per semester . ffl Each course has two lectures and one practical . 3.3.1 Timetable constraints The constraints can be split into two distinct categories , strong and weak . A strong constraint is one which is unacceptable , that is , can not be used in real life or the course organiser would very strongly prefer it not to happen in a real timetable . A weak constraint is one which is preferred not to be violated , but if this is not possible then it will still be accepted . In the 3H problem there are five constraints , two which are considered strong and three which are considered weak . Strong constraints ffl The same student can not not take two events in the same time slot . ffl A course practical must occur after its respective lectures . Weak constraints ffl All events should avoid lunch time slots . ffl The same student should not have more than four events in the same day . ffl The same student should not have more than two events in a row . 3.4 Timetable representation 3.4.1 Chromosome encoding A timetable -LRB- chromosome -RRB- is an ordered list of positive integers which assign an event to a particular time slot . That is , the list is the time slots and the time slot list position is the event . For example , if ten events are to be scheduled and there are eight time slots available , then one of the chromosomes in the population may be ' 4 1 1 8 7 4 5 6 5 6 ' which represents the timetable were event 1 occurs in time slot 4 , event 2 occurs in time slot 1 , and so on . Some other GA researchers applying GAs to timetabling use a different chromosome representation . This representation is like an actual timetable , the positions in the chromosome are time slots , and an allele within a chromosome represents a set of events that can occur in the allele 's time slot -LRB- the allele 's position in the chromosome -RRB- . This representation is more natural , but leads to a problem called label replacement -LSB- 10 -RSB- . The problem is that crossover can easily William F. Nice : GAs for timetabling . 39 course 1 2 3 4 5 6 7 8 event type L1 L2 P L1 L2 P L1 L2 P L1 L2 P L1 L2 P L1 L2 P L1 L2 P L1 L2 P event 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 time slot 4 33 40 21 7 11 5 16 9 6 15 6 4 14 1 18 27 4 15 26 37 21 25 39 Table 3.2 : The chromosome representation for the 3H timetable problem . produce timetables which leave out many of the events . An algorithm is then needed to modify the chromosome to include all the events in the timetable problem . The analogous situation in this project 's representation is that a chromosome may represent a timetable where not all time slots are assigned an event . However , this still produces a perfectly legal timetable . Therefore , using this representation the GA does not need to be hybridised with the computationally expensive label replacement algorithm . The 3H timetable problem has a chromosome length of 24 , that is , eight courses each having two lectures and one practical . Therefore , course 1 of either semester has its first lecture -LRB- L1 -RRB- represented as event 1 , its second -LRB- L2 -RRB- as event 2 and it 's practical -LRB- P -RRB- as event 3 in the chromosome and so on for all courses -LRB- Table : 3.2 -RRB- . 3.4.2 Fitness function A maximally fit timetable is one with no constraint violations . Timetables are differentiated between , in terms of fitness , based on the number and type of different constraint violations . f -LRB- T -RRB- = 1 1 + X i2C Pivi -LRB- T -RRB- where T is the timetable , C is the set of constraints , Pi is the penalty assigned to constraint i , and vi -LRB- T -RRB- = 1 , if T violates constraint i , else vi -LRB- T -RRB- = 0 . If a constraint violation is judged to be very bad , that is , it is a strong constraint , then the relative number of penalty points it is assigned is high . A constraint violation of the weak variety is awarded a relative small number of penalty points to reflect its low importance . Therefore , the relative penalty points assigned to each type of constraint violation are based on the judgement of the course organiser , concerning the priority of each constraint . 3.5 Experimentation For this project a GA 's performance is judged by the average and best fitness of the population at each generation . As a GA 's run progresses the average and 40 Proceedings of the 1NWGA , Vaasa , Finland , 9 - 12 January 1995 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 20 40 60 80 100 Fitness Generation Traditional GA Best GA Figure 3.1 : The average fitness of the best GA compared with the traditional GA. . best fitness of the population should increase . The best GA will therefore have its average and best fitnesses increasing at a faster rate than the other GAs . The experiments were primarily chosen to test the effect of selection and crossover techniques on the ability of a GA to solve the 3H timetable problem . Other factors such as , the population size in a traditional GA , the tournament size when tournament selection is employed , and if student course choices are uniformly distributed , were also investigated -LSB- 977 -RSB- . Based on these experiments results the best GA was devised and its performance is over twice that of the traditional GA -LRB- Figure 3.1 -RRB- . The traditional GA has a population size of one hundred and employs one point crossover at a rate of sixty percent . It also uses a proportional selection techniquez and mutation with a rate of one over the chromosome length . Whereas , the best GA uses fixed uniform crossoverx , tournament selection with a tournament size of fifty . It also employs elitism , that is , the best chromosome of each generation is guaranteed to survive to the next generation . This is implemented by copying the elite chromosome across to the new population after crossover and mutation have taken place , this is to avoid its possible destruction by these genetic operators . All other characteristics of the best GA are identical to that of the traditional GA. . The first optimum timetable was produced after thirty-eight generations by zStochastic universal sampling . xIn fixed uniform crossover the number of crossover points is the same for each parent pair . William F. Nice : GAs for timetabling . 41 the best GA , and if the GA is allowed to continue then many more alternative optimum timetables are found . From these optimum timetables a human can then select one which meets further constraints . 3.6 Conclusion and future To produce the first draft of a timetable will take a skilled human scheduler many hours , and then many days as he or she receives feedback and redrafts the timetable accordingly . In a GA these redrafts are unnecessary as if there is a possible solution then the GA should find it and in less than an hour for the 3H problem . The main discoveries from the dissertation are as follows : ffl It is possible to encode a timetable for a GA and define a fitness function which allows an optimum timetable to be found quickly -LRB- appr . 30 min -RRB- . ffl Experiments with various GA parameters has shown which parameters to use with the 3H timetabling problem and probably other timetabling problems . Although the GA techniques used worked well it is possible to improve the performance still further and the flexibility of the GA software . The following are possible areas of useful exploration in the field of GAs for timetabling . A GA run usually starts with a randomly created population , known as the initial generation . If the initial population was heuristically chosen , that is , introduce into the initial population a number of chromosomes which are derived from previously found solutions to similar problems . For example , the initial population of the 94/95 3H timetable problem could contain a number of copies of the timetables used in 92/93 and 93/94 . A lecture or a practical is held in a room and is conducted by a lecturer , also , some events need special resources like a television or facilities for the disabled . Therefore , scheduling events also needs to take into account the following factors : ffl Class size . ffl Room capacity . ffl Room availability . ffl Lecturer availability . ffl Resource requirements . These considerations in addition to the time slot constraints vastly complicate a timetable problem . A software tool which solves a timetabling problem of this complexity in a relatively short space of time would truly be a useful tool . GAs seem to provide the best area for any development in such scheduling tools . 42 Proceedings of the 1NWGA , Vaasa , Finland , 9 - 12 January 1995 3.7 Bibliography See chapter bibliography at the end of this proceedings .

O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B I O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O B I O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O B O O O O O O O O O O O O B O O O O O B O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O B O O O O O O O O O O O O O O O O O O O O O O B O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O B O O O O O O O O O O O O O O O O O O O O O O O O O O O O O

genetic algorithms
scheduling
timetabling