You are on page 1of 12

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/2562732

An Evolutionary Algorithm for Solving the School Time-Tabling Problem

Conference Paper · February 2001


DOI: 10.1007/3-540-45365-2_47 · Source: CiteSeer

CITATIONS READS
25 105

2 authors, including:

Andrea G. B. Tettamanzi
University of Nice Sophia Antipolis
250 PUBLICATIONS   2,223 CITATIONS   

SEE PROFILE

Some of the authors of this publication are also working on these related projects:

Transport Oriented Model for urban denSification Analysis (TOMSA) View project

Distributed Artificial Intelligence for Uncertain Linked Data Management on the Semantic Web View project

All content following this page was uploaded by Andrea G. B. Tettamanzi on 28 November 2018.

The user has requested enhancement of the downloaded file.


An Evolutionary Algorithm for solving the
S hool Time-Tabling Problem

Calogero Di Stefano1 and Andrea G. B. Tettamanzi2


1
Geneti a S.r.l.
Via San Dionigi 15, I-20139 Milan, Italy
E-mail: distefanogeneti a-soft. om
2
Universita degli Studi di Milano
Dipartimento di Te nologie dell'Informazione
Via Bramante 65, I-26013 Crema (CR), Italy
E-mail: tettamandsi.unimi.it

Abstra t. This paper des ribes an evolutionary algorithm for s hool


time-tabling, demonstrated through appli ations to the Italian s hool
system. Heuristi s have been found and perfe ted whi h o er good gen-
eralization apabilities. A parti ular attention has been devoted to prob-
lem formulation, also in terms of fuzzy logi , as well as to testing di erent
geneti operators and parameter settings. This work has obtained results
of remarkable pra ti al relevan e on real-world problem instan es illus-
trated in the paper, and eventually gave rise to a su essful ommer ial
produ t.

1 Introdu tion
The time-table problem (TTP) is the planning of a number of meetings (e.g.,
exams, lessons, mat hes) involving a group of people (e.g., students, tea hers,
athlets) for a given period and requiring given resour es (e.g., rooms, laborato-
ries, sports fa ilities) a ording with their availability and respe ting some other
onstraints.
The TTP is an ex iting hallenge for omputational intelligen e and opera-
tions resear h, essentially be ause it is NP- omplete [7℄. S hool time-tabling is
often even more ompli ated by the details of a given real situation and real-
world problem instan es often involve onstraints es aping an exa t representa-
tion, su h as onstraints related to user personal preferen es. Advan ed sear h
te hniques exploit various heuristi s in order to rule out from the sear h spa e
those regions where an optimum is not expe ted to exist. One of these heuristi s,
namely evolutionary algorithms, have been su essfully applied to various types
of TTP [6, 1, 4℄ and are among the most promising te hniques available to date
for solving this kind of problem.
This paper is organized as follows: Se tion 2 presents the data and the on-
straints that make up a problem instan e and the form of a solution, in order to
identify its hara terizing aspe ts. Se tion 3 des ribes the evolutionary algorithm
implemented. Finally, Se tion 4 demonstrated the experiments arried out with
the algorithm on some real-world problem instan es, and Se tion 5 dis usses the
results.

2 The Problem
2.1 Instan e Representation

S hool time-tabling is generally based on a signi ant volume of data and on


di erent types of onstraints. A problem instan e is identi ed by the following
entities and relationships:
{ rooms, de ned by their type, apa ity and lo ation;
{ subje ts, identi ed by the room type they require and by a priority with
respe t to other subje ts;
{ tea hers, hara terized by the subje ts they tea h and by their fuzzy avail-
ability matrix, de ning the degree to whi h ea h tea her is available in ea h
period (see Figure 1);

Fig. 1. An example of a fuzzy availability matrix for a tea her.

{ lasses (i.e., groups of students, in luding the degenerate ase of single stu-
dents), assigned to a given lo ation (e.g., building) and having their avail-
ability matrix, su h as the one in Figure 2;
{ lessons, meaning the relation ht; s; ; li, where t is a tea her, s is the subje t,
is the lass attending the lesson and l is the duration in periods. More than
one tea her and more than one lass an parti ipate in a lesson, in whi h
ase we speak of grouping.
As the reader will have noti ed, some onstraints of the s hool TTP are most
naturally expressed in fuzzy terms [11℄.
Fig. 2. An availability matrix for a lass.

A andidate solution to this TTP is an assignment of a starting period to


every lesson.

2.2 Constraints

A andidate solution an be onsidered satisfa tory if it meets the tea hers'


and students' requirements, and if it respe ts the availability of resour es. These
properties are formalized through a number of onstraints.
Constraints an be of two types: hard or soft, depending on whether their
satisfa tion is mandatory or just desirable. A ordingly, a solution will be said
to be feasible if it satis es all the hard onstraints, and a feasible solution will
be said to be more or less a eptable depending on the degree to whi h soft
onstrains are satis ed.
An important thing to noti e is that the lassi ation of ea h onstraint as
hard or soft is to some extent arbitrary, and may be thought as being part of
the problem instan e de nition pro ess.
For the s hool TTP, based on a thorough analysis of the Italian system, the
following set of general onstraints was identi ed.
{ Constraints on rooms: in ea h period, the number of rooms used per type
annot be larger than the number of available rooms of that type (bounded
rooms ); rooms of some types are not available for a ertain time before or
after use for preparation or tidying up (room availability ).
{ Constraints on subje ts: some subje ts are better taught before others, or
earlier in the day when students are fresh, or lessons of some other subje ts
should not take pla e after one another, e.g., similar subje ts (priority ).
{ Constraints on tea hers: a tea her annot tea h more than one lesson at a
time (physi al availability ); a tea her must tea h a given number of lessons
to ea h lass as provided for by the programme for every subje t ( ontra tual
availability ); a tea her should be assigned lessons only in the periods he or
she has marked as available (subje tive availability ); if the s hool has more
than one building or lo ation, appropriate time must be allowed for a tea her
to travel between buildings when required (displa ement ); nally, tea hers
prefer that their lessons be on entrated in time, minimizing gaps or isolated
lessons ( on entration ).
{ Constraints on lasses: if the s hool has more than one lo ation, ea h lass
belongs to just one lo ation and lasses parti ipating in a lesson must be
from the same lo ation ( o-lo ation ); a lesson annot take pla e when one of
the parti ipating lasses is not at s hool (presen e ); while at s hool, a lass
should always be attending a lesson, ex ept for breaks (no gaps )|this is a
strong requirement in the Italian system, but may not be so important in
other systems.
{ Constraints on lessons: some lessons must sti k to a pre-assigned s hedule for
organizational reasons (pre-assignment ); lessons of the same subje t should
be uniformly distributed over the week (distribution ); the total weight of
lessons for ea h day should be as uniform as possible over the week (u-
niformity ); lesson weight (i.e., priority) should be de reasing within a day
(de reasing burden ); multiple lessons on the same subje t, with the same
lasses on the same day should be s heduled sequentially or, put another
way, only a single lesson on a subje t is allowed per day for a lass (sequen-
tiality ); subsequent lessons on the same subje t must take pla e in the same
room (lo ality ); di erent lessons involving the same tea her or the same lass
annot overlap (non-overlap ).
{ Other organizational onstraints: for instan e, on ea h day, lasses take their
lun h break at di erent hours in order to avoid over rowding of the lun h
room (break balan e );

The sear h for an a eptable timetable strongly depends on how onstraints


are lassi ed. The ase where all onstraints are soft brings forth an ex eedingly
broad sear h spa e, whereas the opposite ase where all onstraints are hard is
pra ti ally meaningless, for it gives rise to a very sparse if not even empty sear h
spa e.
For a standard problem instan e relevant to a typi al Italian se ondary
s hool, a possible partition of the onstraints des ribed above into hard and
soft onstraints might be the one reported in Table 1.

3 The Evolutionary Algorithm

The approa h adopted to solve the problem des ribed in Se tion 2 is a quite
standard elitist evolutionary algorithm, ex ept for the perturbation operator,
whi h alternates between an intelligent mutation operator and an improvement
operator, whose details are given below.
hard onstraints soft onstraints
Constraint Entity Constraint Entity
bounded rooms rooms room availability rooms
physi al availability tea hers priority subje ts
ontra tual availability tea hers subje tive availability tea hers
o-lo ation lasses displa ement tea hers
presen e lasses on entration tea hers
pre-assignment lessons distribution lessons
sequentiality lessons de reasing burden lessons
no gaps lasses lo ality lessons
non overlap lessons uniformity lessons

Table 1. A possible lassi ation of onstraints for the Italian s hool system.

3.1 Geneti Representation

A dire t representation has been hosen, along the lines of [4, 1, 2, 5℄, even though
re ent work [10℄ would suggest indire t representation to work mu h better.
However, given the use of the improvement operator, whi h is a Lamar kian
lo al sear h operator, one might argue that our method should not really be
lassed as having a dire t representation. If this operator were always applied
then one ould possibly des ribe our algorithm as having an indire t represen-
tation with the hromosome providing a parameterisation to the improvement
operator.
So, in the end, our approa h might show the advantages both of an indire -
t representation and of a dire t representation. Moreover, su h representation
lends itself to spe ializations of the kinds required by a many-fa eted reality like
the Italian s hool system.

The ith gene correspond to the ith


lesson scheduled starting from period 0

Gene 1 Gene 2 Gene 3 Gene 4 Gene i Gene |L|-1 Gene |L|

Fig. 3. Representation s heme of a genotype.

An individual in the population is a ve tor of integers, as depi ted in Figure 3,


having the same size as the number of lessons to be s heduled. Ea h integer
en odes the starting period of the asso iated lesson.
The values ea h gene an take up depends on data like the length of the
relevant lesson in periods, the number of days in the s hool week, the number of
periods in ea h day, and so on.
Other advantages of this dire t representation are:

1. a simple pro edure for al ulating the penalties to assign to the violation of
ea h onstraint;
2. easy design of operators whi h preserve feasibility, thus allowing signi ant
savings of omputational power;
3. last but not least, a parti ularly eÆ ient de oding fun tion whi h, given a
genotype, re onstru ts the orresponding timetable.

3.2 Initialization

The population is seeded with genotypes generated by a randomly driven greedy


algorithm, whi h pla es the lessons one by one by sele ting at random a starting
period among those that would not violate any onstraint. This in remental
pro edure goes on until the set of \open" starting periods be omes empty, and
then pla es all remaining lessons at random.
The main advantage of this seeding heuristi s is that it gives the evolutionary
algorithm a jump start, by produ ing mu h better timetables than a ompletely
random initialization would do|pra ti ally at the same omputational ost.

3.3 Fitness

The tness fun tion employed by our evolutionary algorithm for s hool timetabling
is of the form
f (g) =
1
P +
P
1 + i i hi 1 + j j sj
; (1)

where hi 2 IR+ is the penalty asso iated to the violation of the ith hard on-
straint, whose relative weight is i 2 IR+ , and sj 2 IR+ is the penalty asso iated
to the degree of violation of the j th soft onstraint, whose relative weight is
j 2 IR+ ; nally, 2 f0; 1g is zero until all hard onstraints are satis ed, and
one sin e.
The weights atta hed to ea h hard and soft onstraint allow the algorithm
to be ne-tuned to better dire t sear h. In pra ti e, the weights were hosen
a ording to the relative importan e of onstraints in the problem instan es
treated. It should be stressed that the results are very sensitive to the hoi e of
the weights, be ause soft onstraints orrespond to on i ting riteria.
Satisfa tion of soft onstraints begins only after at least one feasible solution
has been found, and is swit hed to one: this devi e does not let evolution trade
o slight violations of hard onstraints with high satisfa tion of soft onstraints.
3.4 Sele tion

The individuals are hosen for reprodu tion using tournament sele tion [3℄, with
tournament size k  2, whi h is a parameter of the algorithm. The implementa-
tion of this sele tion s heme enfor es elitism by introdu ing at least one opy of
the best individual into the next generation, without perturbation. Apart from
this detail, the algorithm uses a generational repla ement reprodu tion strategy.

3.5 Re ombination

Among the ross-over operators des ribed in the literature for an integer rep-
resentation like the one adopted by our algorithm (see e.g. [9℄), the one that
proved to be best suited for the TTP, based on experiments on the three sample
problem instan es dis ussed in Se tion 4, was uniform ross-over, whose me ha-
nism is illustrated in Figure 4: this operator treats the integer genes atomi ally.
Re ombination is performed on ea h pair of individuals with probability p ross ,
whi h is a parameter of the algorithm.

Gene 1 Gene 2 Gene 3 Gene 4 Gene i Gene |L|-1 Gene |L|

parent 1

Gene 1 Gene 2 Gene 3 Gene 4 Gene i Gene |L|-1 Gene |L|

child 1

pcross
1/2 1/2 1/2 1/2
child 2
Gene 1 Gene 2 Gene 3 Gene 4 Gene i Gene |L|-1 Gene |L|

parent 2
Gene 1 Gene 2 Gene 3 Gene 4 Gene i Gene |L|-1 Gene |L|

Fig. 4. Illustration of uniform rossover on the geneti representation of a s hool


timetable.

3.6 Perturbation

Typi ally, mutation in EAs is a blind operator, in the sense that it produ es
random perturbations, regardless of the fa t that they improve or worsen the
solution represented by the a e ted individual.
In ontrast with that, the two perturbation operators employed in ombina-
tion by our algorithm are rather of the Lamar kian type, i.e., based on the law
of use and disuse whi h, if wrong when referred to natural geneti s, sometimes
leads to more eÆ ient sear h in arti ial evolutionary systems.
The two mutually ex lusive perturbation operators are:
{ intelligent mutation , applied with probability pmut , and
{ improvement , applied with probability pimprove .
At ea h generation, the de ision whether to enable the intelligent mutation or
the improvement operator is made by tossing a biased oin. The bias ppert, in
favor of intelligent mutation, is a parameter of the algorithm.

Intelligent Mutation This operator, while retaining a random nature, is di-


re ted towards performing hanges that do not de rease the tness of the indi-
vidual. In parti ular, if the operator a e ts the ith gene, it will indire tly a e t
all the other lessons involving the same lass, tea her or room. The hoi e of the
\a tion range" of this operator is random and the variation su ered by the ith
gene is su h as to make tness in rease. In pra ti e, intelligent mutation aims
at redu ing onstraint violation.

Improvement This operator, whi h is the perturbing alternative to intelligent


mutation, restru tures an individual to a major extent.
Restru turing ommen es by randomly sele ting a gene (i.e., a lesson) and
on entrates on the partial timetables for the relevant lass, tea her and room.
First of all, it aims at making periods for whi h no lesson has been s heduled
ontiguous (i.e., ompa ting \gaps" in the lass, tea her, and room timetable).
Then it allo ates the ontiguous free spa e thus laimed to the the lesson orre-
sponding to the sele ted gene.
Appli ation of this operator generally results in a tness in rease and pre-
serves the feasibility of a solution. Furthermore, this operator is responsible for
inje ting substantially novel geneti material into the population.

4 Experiments and results


Experiments have been arried out on a onstru ted problem instan e, designed
to test most aspe ts of the problem. The instan e is a realisti model of a generi
Italian \industrial te hni al high-s hool", whi h we will all \G. Mar oni" for
onvenien e, summarized in Table 4. A total of 942 lessons are to be s heduled.
Further experiments have been arried out on two real state ly ees lo ated
in Milan, namely the G. Cardu i lassi state ly ee and the Leonardo da Vin i
s ienti state ly ee, both enrolling a. 1,000 students.
Data for the G. Cardu i ly ee refer to the s hool year 1997/1998, with 924
lessons to s hedule. Data for the Leonardo da Vin i ly ee refer to s hool year
1996/1997, with 1003 lessons to s hedule. Table 4 summarizes information on
these two s hools.
The parameter settings for the evolutionary algorithm reported in Table 4,
are the ones that onsistently gave the best results on the three problem instan es
used for experiments.
A typi al run for these problem instan es takes 40 minutes on average to
ome up with a feasible solution and 5 12 hours to devise an a eptable solution
on a 500 MHz PC with 64 Mbyte RAM and the Mi rosoft NT operating system.
Resour es Main Building Bran h Building Remarks
lasses 12 18 6 se tions of 5 lasses
tea hers 35 27 3 Physi al Edu ation tea hers
work in both buildings
subje ts 10 13 6 subje ts are taught in both
buildings
lessons 558 384 no lesson requires lass grouping
labs 8 4
gyms 2 1 the gures refer to the number
lasses whi h an use the gym at
one time

Table 2. Summary of the G. Mar oni model industrial te hni al high-s hool.

Resour es G. Cardu i Leonardo da Vin i


lasses 33 35
tea hers 60 71
subje ts 13 23
lessons 924 1003
labs 1 3
gyms 2 2
Table 3. Summary of the G. Cardu i and Leonardo da Vin i ly ees.

Parameter Value
Population size 100
p ross 0.3
ppert 0.5
pmut 0.02
pimprove 0.02
Tournament size k 30
i , j 1 for all i, j
Table 4. Optimal parameter settings for the evolutionary algorithm.
Figure 5 plots the tness and the penalties asso iated to onstraint violations
during a run of the algorithm on the Leonardo ly ee. The rst feasible solution
was found at generation 2,001, and the run was stopped at generation 10,200
when the degree of satisfa tion of soft onstraints did not look likely to in rease
anymore.

200
180 constraint satisfaction
1,4
160
fitness
1,2 140
120
1
100
0,8 80
60
0,6
40
0,4 20
0
0,2 0 600
conflicts (classes) 1200 1800 2200 2800
conflicts (teachers) 3400
0 4600 6000
0
conflicts (rooms) 8800
600 1200 1800 2200 10200
2800 3400 4600 6000
dissatisfaction (teachers)
worst 8800 10200 distribution (subjects)
average
generation
daily weight (teachers) generation
best distribution (lessons)

Fig. 5.Fitness graph and evolution of onstraint satisfa tion during a run for the
Leonardo ly ee.

5 Dis ussion
The algorithm des ribed in Se tion 3 annot be onsidered a \pure" evolutionary
algorithm; instead, its eÆ ien y and e e tiveness rely riti ally on the hybridiza-
tion with two heuristi s based on lo al sear h, implemented by the intelligent
mutation and improvement operators.
Even without ne tuning of the algorithm parameters and of the relative
onstraint weights i and j , the quality of the results obtained, whi h annot
be shown here for la k of spa e, was remarkable, all the more so be ause no
simplifying assumption or onstraint elimination had to be made to obtain them.
The timetables obtained were submitted to the timetable ommittee of the
Leonardo da Vin i s ienti state ly ee, whi h has been in harge for years of
assembling the s hool timetable at every opening of the s hool year. Their expert
assessment of the results was highly positive and their implementation did not
require any manual adjustment.
The pra ti al relevan e of the results obtained led Geneti a S.r.l. to pa k-
age the approa h de ribed in this paper into a full- edged ommer ial software
produ t, EvoS hool, whi h has been su essfully laun hed on the Italian market.
Adaptations for other ountries are also under way. EvoS hool, version 2.0, is
freely available for evaluation at the URL
http://www.geneti a-soft. om/eng/evos hool.html
The demo omes with the datasets for the three examples des ribed in Se tion 4.
Referen es
1. P. Adamidis and P. Arakapis. Weekly le ture timetabling with geneti algorithms.
Pro eedings of the 2nd International Conferen e on the Pra ti e and Theory of
Automated Timetabling, University of Toronto, Canada, 1997.
2. A.M. Barham and J.B. Westwood. A Simple Heuristi to Fa ilitate Course
Timetabling. J. Opnl. Res. So . 29, 1055-1060.
3. A. Brindle. Geneti algorithms for fun tion optimization. Te hni al Report TR81-
2, Department of Computer S ien e, University of Alberta, Edmonton, 1981.
4. J.P. Caldeira and A.C Rosa. S hool timetabling using geneti sear h. Pro eedings
of the 2nd International Conferen e on the Pra ti e and Theory of Automated
Timetabling, University of Toronto, Canada, 1997.
5. D. Corne,P. Ross, H. Fang. Evolutionary Timetabling: Pra ti e, Prospe ts and
Work in Progress. Presented at the UK Planning and S heduling SIG Workshop,
(Strath lyde, UK, September 1994), organised by P Prosser.
6. W. Erben. A Grouping Geneti Algorithm for Graph Colouring and Exam
Timetabling. Pro eedings of the Third International Conferen e on the Pra -
ti e and Theory of Automated Timetabling, Constan e, Germany, August 16{18,
2000.
7. S. Even, A. Itai, A. Shamir. On the Complexity of Timetable and Multi ommodity
Flow Problems. Siam Journal of Computing, Vol. 5, No.4, De ember 1976, 691-
703.
8. D.E. Goldberg. Geneti Algorithms in Sear h, Optimization and Ma hine Learn-
ing. Addison-Wesley, Reading, MA, 1989.
9. Z. Mi halewi z. Geneti Algorithms + Data Stru tures = Evolution Programs.
Springer-Verlag, Berlin, 1992.
10. B. Pae hter, R. C. Rankin, A. Cumming. Improving a Le ture Timetabling System
for University Wide Use. Pra ti e and Theory of Automated Timetabling II,
Springer-Verlag, LNCS 1408, Berlin, 1998.
11. L.A. Zadeh. Fuzzy Sets and Appli ations: Sele ted Papers. John Wiley & Sons,
New York, 1987.

View publication stats

You might also like