4.1 Algorithms Description
The school timetabling problem can be defined by a
mathematical formulation (Schaerf, 1999), which de-
scribes the feasible regions through a solution space;
and an objective function, which allows to lead the
search process towards an optimal solution. The
constraints that define such space are the hard con-
straints. On the other hand, each soft constraint
has usually an assigned weight and contributes to the
value of the objective function. However, in practice,
we are interested in managing both kind of constraints
with a function called cost function that assigns a cost
to each solution depending on the number of failed
constraints. Each constraint has associated a weight
(higher in hard constraints to lead the search process
towards feasible regions). Then, the objective of the
school timetabling generation problem is to find the
solution that minimizes such function.
As we noted before, the timetabling problem we
consider admits a mathematical programming repre-
sentation, so an exact solution could be obtained by
applying well-known techniques in this field. Never-
theless, it has been shown that this is a NP-complete
problem (de Werra, 1985; Even et al., 1976). In prac-
tice, the high dimensionality of the problem makes
it impossible to find an exact solution, and approxi-
mated methods are needed to tackle it (de Haan et al.,
2006; Schaerf, 1999; Keppler and Erben, 1996). We
propose and study the performance of three different
algorithms based on heuristic search techniques.
We use a teacher-oriented representation of the
problem, and therefore a timetable is represented as
a two-dimensional matrix where each cell (i, j) con-
tains the class given by the i
th
teacher at the j
th
pe-
riod. This representation avoids implicitly the case of
a teacher giving more than one class at a same time.
We also define two kind of moves: i) simple-moves,
that are obtained by swapping two distinct values in a
given row of the timetable; and ii) double-moves that
are the combination of two simple-moves when the
first move leads to an unfeasible scenario.
RNA Search. Following the RNA local search tech-
nique, we have developed an algorithm which, start-
ing from an initial solution, iteratively moves from
a solution to another doing double-moves. It keeps
track of the current best solution at each stage. The
process is repeated until there are no improvements
during a given number of iterations.
Genetic Algorithms. Genetic algorithms base their
operation on the evolution mechanism. Starting with
a population, a set of individuals or potential solutions
(timetables, in our case), best candidates are selected
based on their fitness value (given by the cost func-
tion). These will be the parents of a new group of
individuals obtained by modifying the previous ones
by using crossovers and mutations, which allow ex-
ploring the search space and guaranteeing the genetic
diversity, respectively. The new population will be
processed in the same way in the next iteration.
In our case, a crossover consists of selecting a
certain number of rows from each of the parents,
given by a randomly chosen crossover point in the
timetable. A mutation is done by means of a simple
move. We have developed two different approaches:
i) Tournament (GT): starting with a population ran-
domly generated, two pairs of individuals are selected
and then the best candidate of each pair is chosen.
The parents of the next generation are obtained in this
way; ii) Four Children Tournament (GT4C): once two
individuals are chosen to form a pair they are dis-
carded, so they will never be chosen again.
Furthermore, we have combined the previous al-
gorithms obtaining two hybrid ones, Tournament &
RNA (GT & RNA) and Four Children Tournament
& RNA (GT4C & RNA). Moreover, we have created
some variants of our genetic-based algorithms follow-
ing the strategies: v1) To increase dynamically the
number of mutations after a given number of itera-
tions without improvements; v2) To apply a more eli-
tist selection technique of the best candidates, so re-
ducing its proportion to a given percentage, and v3)
Not to eliminate the loser candidates when we work
with a GT4C phase, in such a way, all the individuals
could be parents at least once.
4.2 Algorithms Evaluation
To properly evaluate the algorithms performance, dif-
ferent experiments were run over two sets of synthetic
test cases with different size and configurations. Data
set A is composed of 10 files of 6 groups, 70 classes
and 15 teachers. Table 1 shows the average value of
unsatisfied constraints and the standard deviation for
10 runs, limited in time to 30 minutes. Results show
that most algorithms obtain good results and perform
quite similarly, with the exception of a small group
that perform very badly: variants v1 and v1+v2 of the
genetic algorithms and variant v3. The best choices
seem to be RNA and GT4C.
After discarding the algorithms that behaved badly
in the previous case, we studied the performance of
the remaining over a bigger scenario (B) involving 27
groups, 333 classes and 71 teachers. The different al-
gorithms were run 4 times, limiting the time to 5 hours
each. Table 2 shows that variant v2 obtains very good
results, especially version GT & RNA, that reduces
the variability. RNA and variant v1+v2+v3 behave
AN INTEGRATED SYSTEM FOR SCHOOL TIMETABLING
601