SciELO - Scientific Electronic Library Online

vol.26 número4Desenvolvimento de empresas de base tecnológica da região do Vale do Paraíba Paulista: pesquisa com gestores de incubadoras e empresas incubadasEnergy planning and management during battery manufacturing índice de autoresíndice de assuntospesquisa de artigos
Home Pagelista alfabética de periódicos  

Serviços Personalizados




Links relacionados


Gestão & Produção

versão impressa ISSN 0104-530Xversão On-line ISSN 1806-9649

Gest. Prod. vol.26 no.4 São Carlos  2019  Epub 07-Out-2019 

Original Article

Optimization in timetabling in schools using a mathematical model, local search and Iterated Local Search procedures

Otimização na geração de grade horária escolar através de um modelo matemático e dos procedimentos busca local e Iterated Local Search

Pedro Rochavetz de Lara Andrade1

Maria Teresinha Arns Steiner2 

Anderson Roges Teixeira Góes3 

1Departamento de Engenharia de Produção, Universidade Tecnológica Federal do Paraná – UTFPR, Av. Pioneiros, 3131, Jardim Morumbi, CEP 86036-370, Londrina, PR, Brasil, e-mail:

2Programa de Pós-graduação em Engenharia de Produção e Sistemas, Pontifícia Universidade Católica do Paraná – PUCPR, Rua Imaculada Conceição, 1155, Prado Velho, CEP 80215-901, Curitiba, PR, Brasil, e-mail:

3Departamento de Expressão Gráfica, Universidade Federal do Paraná – UFPR, Centro Politécnico, CP 19081, CEP 81531-990, Curitiba, PR, Brasil, e-mail:



This paper addresses the school timetabling problem, which consists of defining the date and time in which classes will be given by teachers in educational institutions. For this purpose, a tool that uses Operational Research (OR) techniques was developed, focused on generating and optimizing Elementary and High School timetables, taking into account teachers’ preferences for certain days or for sequenced (twinned) classes. Conductive to solving the problem, a Non Linear Binary Integer Programming mathematical model (NLBIP) and Local Search (LS) and Iterated Local Search (ILS) procedures were comparatively applied. A real problem with 14 timetables of public schools in the city of Araucária (in Paraná State, Brazil) was analyzed. The results indicate that the computational time required by the mathematical model is feasible for the problems in question. The ILS technique has the potential for testing larger scale problems, as it presents a dispersion of 3.5% to 7.7% relative to the optimal solution (obtained by the NLBIP) and a computational time that is 15 to 338 times faster.

Keywords:  Timetabling; Iterated Local Search; Local search; Non-Linear Binary Integer Programming



Este artigo aborda o problema de otimização na geração da grade horária escolar. Tal problema consiste em definir os dias e horários das disciplinas a serem ministradas por cada um dos professores de instituições de ensino. Para isto foi desenvolvida uma ferramenta que faz uso de técnicas de Pesquisa Operacional (PO), com foco na geração e otimização de grade horária de instituições de Ensino Fundamental, considerando as preferências dos professores, tais como, preferências por dias de aula e por aulas em sequência (geminadas). Para a resolução do problema foi utilizado um modelo matemático de Programação Não Linear Inteira Binária (PNLIB) e os procedimentos Busca Local (BL) e Iterated Local Search (ILS), comparativamente. Foi aqui analisado um problema real com 14 grades horárias de escolas públicas da cidade de Araucária, PR. Os resultados indicam que o tempo computacional demandado pelo modelo matemático é viável para os problemas analisados. A técnica ILS possui potencial para testes em problemas de maior porte, já que apresenta uma dispersão de 3,5% a 7,7% em relação à solução ótima (obtida pelo PNLIB), com tempo computacional de 15 a 338 vezes mais rápido.

Palavras-chave:  Grade horária; Iterated Local Search; Busca local; Programação Não Linear Inteira Binária

1 Introduction

The need to optimize the use of every type of resource is as much a requirement in teaching institutions as in any other type of institution. Among the resources of schools that can be optimized are the classrooms and the time available for teachers to define the times of their commitments, in other words, their timetable.

Timetabling involves a number of variables, including preferences for times, days of teaching (or not teaching), twinned classes (or not), daily workload of subjects and, finally, minimization of school days. Therefore, manual timetabling is often highly complex, and merely achieving a feasible solution is considered satisfactory, as is the case in many schools nowadays. Thus, the creation of a system capable of automating timetabling allows schools to prepare their timetables more quickly and with better quality.

Several works on this topic, some of which will be discussed in more detail later, may be cited, including Saviniec et al. (2018), Fonseca et al. (2017), Soria-Alcaraz et al. (2014), Andrade et al. (2012), Góes et al. (2010), Sousa et al. (2008), Cooper & Kingston (1995), Souza et al. (2001) and Gotlieb (1963).

In this work, the development of a computer program is presented that makes use of Operational Research (OR) techniques, created to produce timetables with maximum optimization for elementary schools. It is based on three techniques: a mathematical model of Non Linear Binary Integer Programming (NLBIP); the Local Search (LS) heuristic; and the Iterated Local Search (ILS) meta-heuristic. As ILS contains LS, the gain that it provides in relation to the application of isolated (pure) local search is analyzed, as is the dispersion of techniques for the optimal solution. To illustrate the use of this tool better, it was applied to 14 timetables at three schools in the municipality of Araucária in Paraná State, Brazil.

This article is organized into five section, including this introduction. In Section 2, the timetabling problem and the 14 case studies analyzed are described. In Section 3, the methodology is described, i.e., how each technique (NLBIP; LS; ILS) was applied to the problem. The results are presented in Section 4, and the conclusions in Section 5.

2 Description of the problem

Timetabling is a Combinatorial Optimization problem, classified as NP-Complete (Cooper & Kingston, 1995). According to Babaei et al. (2015), the computational processing time required to generate a timetable using exact methods increases exponentially as the number of students increases. This problem involves some factors that must be respected for the timetable to be considered feasible (“hard constraints”). Of these, the following may be mentioned: 1) a class cannot have more than one teacher at the same time; 2) a teacher cannot teach more than one class at the same time; 3) groups of students must have a fully occupied weekly timetable; 4) a teacher’s weekly workload with each class must be equal to the sum of the workload of subjects that he teaches to this class.

Other factors are considered in different timetabling problems, but only need to be complied with as far as is possible, so-called “soft” constraints (Silva et al., 2004). They are: 1) complying with teachers’ preferences for twinned classes (or not); 2) complying with the preferences of each teacher regarding the days when they teach; 3) allocating the minimum possible number of school days to each teacher.

2.1 Case study of schools in Araucária, Paraná State

To gauge the efficiency of the proposed techniques when it comes to optimizing timetabling, the techniques were applied to 14 different scenarios of public schools in the municipality of Araucária, Paraná State, which differ from one another only in the number of classes and teachers. Table 1, below, illustrates for one of these scenarios the subjects taught by teachers to each class, as well as their workload and preferences in terms of their day off and day for class preparation. A day off is the day the teacher chooses not to have any commitments at the school, and the day for class preparation is a day the teacher sets aside for preparing lessons. The remaining 13 scenarios, containing all the data, are available and illustrated in Andrade (2014).

Table 1 Subjects taught by the teachers and their preferences – Problem 1. 

Teacher Subject 6D 6E 6F 7D 7E 7F 8D 8E 8F 9D 9E 9F Day off Class Preparation Number of classes
ArtTeach1 Art X X X X X X X 14
ArtTeach2 Art X X X X X 10
SciTeach1 Sciences X X X X X 15
SciTeach2 Sciences X X X X X 15
SciTeach3 Sciences X X 6
PhyEdTeach1 Physical Education X X X X X 15
PhyEdTeach2 Physical Education X X X X X 15
PhyEdTeach3 Physical Education X X 6
GeoTeach1 Geography X X X X X X 15
GeoTeach2 Geography X X X X X X 15
HistTeach1 History X X X X X 15
HistTeach2 History X X X X 12
HistTeach3 History X X X 9
EngTeach1 English X X X X X X X 14
EngTeach2 English X X X X X 10
MathTeach1 Mathematics X X X 12
MathTeach2 Mathematics X X X 15
MathTeach3 Mathematics X X X 15
MathTeach4 Mathematics X X X 15
PortTeach1 Portuguese X X X 12
PortTeach2 Portuguese X X X 15
PortTeach3 Portuguese X X X 15
PortTeach4 Portuguese X X X 15

Source: Andrade (2014).

As highlighted in Line 9 of Table 1, the first geography teacher (GEOTEACH1) teaches the three seventh grade classes (7D, 7E and 7F) and the three ninth grade classes (9D, 9E and 9F). Furthermore, his day off is Monday and his class preparation activities are on Fridays. Finally, his workload in the classroom is 15 hours of teaching. It should be noted that the sixth and eighth grade classes are taught by the second geography teacher. It should be highlighted that the names of the teachers are not shown to protect their identities.

In the teaching network associated with Table 1, the teachers have a workload of up to 20 hours per week (up to 15 hours in the classroom and 5 hours for class preparation). As each class lasts one hour, and teachers can work up to five hours per day, their workload in the classroom should preferably be distributed over a period of up to 3 days, leaving two days without classes, one for class preparation and one as their day off. Thus, one of the aims in generating timetables for this problem is to minimize the number of days that teachers spend in the classroom.

In this problem, no teacher exceeded the limit of fifteen hours of teaching per week (last column in Table 1). However, this did not occur in all 14 case studies, as in 11 problems there is at least one teacher with a heavier workload, exceeding 15 hours of teaching per week. Of these, in eight problems, there is at least one teacher with over 20 hours of teaching per week. In these cases, depending on the workload, the teacher will not have a day off or a day for preparing classes. However, he will be paid more for working overtime.

Considering the specific features of the teaching network in question and current legislation, other hard constraints were added: 1) every subject must be taught by only one teacher; 2) each group of students cannot have more than two classes on the same subject per day, whether twinned or not; 3) specific subjects, selected by the user cannot have more than 50% of their workload concentrated in a single day. The latter constraint is intended to make specific subjects with a light workload (2 or 3 hours per week) be taught at a maximum of one hour per day, when this is the preference.

3 Correlated works

Here, an analysis will be presented of some correlated works in the literature, in chronological order, which are summarized in Table 2. Two Linear Binary Integer Programming (LBIP) mathematical models, in addition to a Taboo Search (TS) associated with a Random Local Search (RLS) were presented in the study conducted by Sousa et al. (2008) to generate school timetables. The approaches are compared in real cases of Brazilian state schools, and the processing time of the exact techniques was limited to 6 hours. The authors conclude that the three techniques had a similar performance with regard to small problems. However, for large problems, the meta-heuristics outperformed the exact approach with a lower computational time. The school timetabling problem was solved by Soria-Alcaraz et al. (2014) through a learning hyper-heuristic. The proposed technique is based on an ILS procedure with autonomy to combine diverse statistical and dynamic operators. The approach was tested on 44 problems of the International Timetabling Competition (ITC), showing that the dynamic operators exceed the statistical ones, as they are competitive with other techniques applied in the literature, since this approach generated the best-known solution for one of the cases.

Table 2 Selected articles with timetabling.  

Researchers (Year) Problem Addressed Techniques Used
Sousa et al. (2008) School timetabling. TS with RLS and two LBIP mathematical models.
Soria-Alcaraz et al. (2014) School timetabling. ILS-based hyper-heuristics.
Babaei et al. (2015) Timetabling and classroom distribution in universities. Multiple agents based on hybrid techniques with graph coloring and LS.
Lewis & Thompson (2015) University timetabling. Own meta-heuristic with operators to increase solution space connectivity.
Veenstra & Vis (2016) Reprogramming school timetabling. ILP mathematical model; Simple general rule; and Heuristic.
Jardim et al. (2016) Timetabling for a department of the UFF ILS meta-heuristic.
Bucco et al. (2017) University timetabling. MILP model.
Fonseca et al. (2017) School timetabling. ILP model with new cutting algorithms.
Ghiani et al. (2017) Course timetabling for remedial education in high schools. ILP mathematical model; and Heuristic.
Lindahl et al. (2018) University timetabling. e-constraint algorithm applied to bi-objective MILP mathematical models.
Liu & Dessouky (2019) Railway timetabling. B&B with hybrid heuristic in the solving of a mathematical model.
Saviniec et al. (2018) School timetabling. Parallel LS algorithms, ILS, TS, SA.

B&B = Branch-and-Bound; LS = Local Search; RLS = Random Local Search; TS = Taboo Search; ILS = Iterated Local Search; ILP = Integer Linear Programming; LBIP = Linear Binary Integer Programming; MILP = Mixed Integer Linear Programming; SA = Simulated Annealing. Source: The authors (2019).

Babaei et al. (2015) introduced a new approach to solving the timetabling problem in universities, a multiple agent technique based on multiple hybrid meta-heuristics with LS graph coloring. Tests were performed to compare different techniques in instances from the literature with diverse characteristics. The authors conclude that exact approaches do not have good efficiency in solving this problem because of the growing complexity with a higher number of students. Furthermore, they highlight the advantages of using multi-agent approaches, such as greater independence in the allocation of classes between different departments of the university. Lewis & Thompson (2015) proposed a two-stage meta-heuristic for the university timetabling problem. The first stage is intended to achieve a feasible solution without considering soft constraints. The second stage, considering hard and soft constraints, seeks to improve the solution by increasing solution space connectivity using a neighborhood operator. The approach was tested in instances of the ITC 2007, and the authors found that the quality of the solution is generally better with increased solution space connectivity, as the technique generated better results than the methods in the literature for most of the instances that were analyzed.

Veenstra & Vis (2016) analyzed the performance of three proposed techniques to reprogram a school timetable: an exact method of Integer Linear Programming (ILP) method, a simple general rule and a heuristic technique. The techniques were tested with the data of five schools in the Netherlands in two scenarios (minor or major alterations to the timetable). The results show that, for minor alterations, the heuristic achieved the optimal solution in 50% of the tests. When major alterations were required, the ILP method could not find the optimal solution in the established computational time (12 hours). Jardim et al. (2016) solved and optimized the timetabling problem of a department of the Federal Fluminense University (UFF) using the ILS heuristic, which had better results than those of the tool used by the department at the time when the study took place. In the article written by Bucco et al. (2017), a Mixed Integer Linear programming (MILP) model was applied to the timetabling problem of university courses, focusing on optimizing the use of classrooms. To enable the processing of the proposed approach, the problem was divided into two sub-problems. The first addressed the generation of the timetable, while the second focused on classroom distribution. Tests were conducted with real data from a Brazilian university, demonstrating that the proposed approach could reduce the number of classrooms required.

Fonseca et al. (2017) studied ILP techniques to generate school timetables, proposing cutting techniques and new formulations for the problem. The authors achieved notable results in the solving of diverse instances, including the ITC 2011, as the optimal solution, hitherto unknown, was obtained for two instances. Furthermore, the approach found the best-known solution for some instances, and for the linear relaxation of 14 instances, it found the best upper and lower bounds. The problem of course timetabling for remedial education was analyzed by Ghiani et al. (2017), deciding which courses should be offered and at what time. An ILP mathematical model and a heuristic technique were compared based on randomly generated instances. The authors concluded that the heuristic achieves a balance between execution time and solution quality.

The timetabling and classroom distribution problem in universities was studied by Lindahl et al. (2018), analyzing the relationship between three factors that influenced the solution: teaching period; room distribution; and quality. The authors proposed three bi-objective MILP models and an algorithm to solve them called the e-constraint method. The models and solution method were evaluated based on the solution of the instances of the ITC 2007. The authors positively evaluated the techniques, as they are applicable to almost all the instances, enabling an analysis of the relationship between each of the factors and their influence on solution quality. Liu & Dessouky (2019) used a mathematical model to optimize the timetable of a passenger and cargo railway network. The authors proposed a solution based on Branch-and-Bound (B&B) with hybrid heuristic procedures to solve the nodes in the search tree and to return to a feasible solution. Computational experiments with real data show the feasibility of the proposed technique, outdoing other heuristics in the literature. Saviniec et al. (2018) solved the school timetabling problem using the parallel processing of LS heuristics with an exchange of information between agents. The solutions were compared with the solution of the instances by the ILS meta-heuristics, TS and Simulated Annealing (SA), in addition to techniques from the literature. The most efficient parallel algorithm was considered promising, as it achieved good quality solutions consistently, outperforming the state-of-the-art algorithms in the literature in two variants of the problem.

4 Description of techniques applied to the timetabling problem

In this section, the techniques applied to the 14 problems described in Section 2.1 are described: the NLBIP mathematical model and the ILS and LS procedures.

4.1 Mathematical model

In the proposed model, the aim is to maximize the satisfaction of teachers’ preferences for the days that they teach and for twinned classes, as well as to minimize the number of days that each teacher gives classes. The terms used in the modeling will now be defined:


t = 1, ..., T: T is the total number of teachers;

tn = t'1 , t'2 , ..., t'n : tn is a subgroup of t , with t'n representing the t index of the last teaching that does not have a preference for twinned classes;

tw = t''1 , t''2 , ..., t''w : tw is a subgroup of t , with t''w representing the t index of the last teacher with a preference for twinned classes;

g = 1, ..., G: G is the number of groups;

d = 1, ..., D: D is the number of school days in a week;

h = 1, ..., H: H is the number of teaching periods in a school day;


CDt,d : Coefficient of preference of the teacher t to teach each day d ;

CTt : Coefficient of the hierarchy of the teacher t ;

CTtw : Coefficient of the hierarchy of a teacher with preference for twinned classes;

CTtn : Coefficient of the hierarchy of a teacher without a preference for twinned classes;

DMt : Minimum number of day of teaching that teacher t may have;

Kt,g : Workload of the subject that the teacher t teaches to the group g ;


Xt,g,d,h : Binary variable representing whether a teacher t teaches the group g on day d, time h, or not;

D: Penalty in the case of a teacher having more days of teaching than the minimum;

DDt : Number of days of teaching designated to the teacher t.

W: Total coefficient of twinned classes;

W'tn : Coefficient of satisfaction of preferences for not having twinned classes;

W''tw : Coefficient of satisfaction of preferences for twinned classes;

Thus, the Objective Function (OF) is represented by Equation 1, below.

MaxZX=t=1Tg=1Gd=1Dh=1HCDt,d.CTt.Xt,g,d,hD+W (1)

To define the values of the coefficient CDt,d , the day off has a value of 1; the class preparation day “4”; and for the other days the value is “10”. Meanwhile, the hierarchy of teachers represented by CTt , is defined by the decision maker using a list of teachers, with the first teachers on the list being those higher up in the hierarchy, i.e., more likely to have their preferences satisfied, while those at the bottom of the list have fewer chances of having their preferences met. Therefore, the value of the coefficient CTt is “10” for the teacher lowest down in the hierarchy. The next teacher has a weight equal to “11”, and so forth, up to the first teacher in the hierarchy, who will have the highest value for this coefficient.

D is calculated based on the workload allocated to each teacher. The minimum number of school days is calculated: up to 5 hours a week (inclusive), the minimum is 1 day of teaching; between 6 and 10 hours a week (inclusive), the minimum is 2 days; between 11 and 15 hours a week (inclusive), 3 days; between 16 and 20 hours a week (inclusive), 4 days; and from 21 hours a week (inclusive), the minimum is 5 days of teaching. Thus, the difference is calculated between the minimum number of teaching days and the days allocated, as shown in Equation 2.

D=t=1T10.CTt.DDtDMt (2)

The multiplication of the number of days over by the weight of the teachers’ hierarchy prioritizes the quality of the timetable of teachers higher up in the hierarchy and makes the value of D adapt to the size of each problem, given that CTt is also a function of the number of teachers in the problem.

The coefficient W is defined by the sum of the coefficients W'tn and W''tw (Equations 3, 4 and 5).

W=tn=1t'nW'tn+tw=1t''wW''tw (3)
W'tn=g=1GCTtn.d=1Dh=1H1Xtn,g,d,h.Xtn,g,d,h+112.2,tn (4)
W''tw=g=1GCTtw.d=1Dh=1H1Xtw,g,d,h.Xtw,g,d,h+112.2,tw (5)

The product between a variable and the variable of the following period, as shown in Equations 4 and 5, despite making the model non-linear, in this case does not significantly affect the complexity of the model. As the variables are binaries, the result will also be 0 or 1. The product results in 0 when the teacher does not have twinned classes and in 1 when he does. Therefore, in Equation 4, 1 is the result for each day that the teacher does not have twinned classes (in accordance with his preference), and the result is “-1” if he is allocated to a twinned class on the day. As the difference between Equations 4 and 5 is only a sign, the results will be opposites. Thus, it can be said that in both cases, positive results are achieved on the days when preferences are satisfied and negative ones on the days when they are not.

For W'tn and W''tw , the sum of each teacher is multiplied by the hierarchy coefficient. Thus, the choices of the first teachers are given priority.

The constraints developed in the mathematical models are presented below in Equations 6 to 10.

t=1TXt,g,d,h=1,g,d,h (6)
g=1GXt,g,d,h1,t,d,h (7)
d=1Dh=1HXt,g,d,h=Kt,g,t,g (8)
h=1HXt,g,d,h2,t,g,d (9)
Xt,g,d,h=0;1 (10)

The constraints in (6) ensure that all class times are filled and that for each period only one teacher will teach each group. The constraints in (7) prevent teachers from teaching more than one group in the same teaching period. The constraints in (8) guarantee that one teacher will teach the whole workload of the subject to which he was allocated for each group. The constraints in (9) prevent groups from having more than two classes in the same subject per day. Equation 10 guarantees that the variables Xt,g,d,h are binary.

All the hard constraints presented in Sections 2 and 2.1 are considered in Constraints (6) to (9) above, with the exception of hard constraint 3, which is optional. This constraint alters Equation 9: subjects chosen come to have at most 1 lesson per day rather than 2, like all the other subjects.

4.2 Local search and Iterated Local Search procedures

For a better visualization of the techniques that will be presented, LS and ILS, a fictitious problem was created with only 3 groups of students (6A, 7A and 8A), 5 teachers (of Portuguese, Mathematics, Science, History and Geography), 3 days of classes per week and 3 teaching periods per day.

The aim of the LS, starting form an initial solution, is to find the best solution for a restricted search area (Resende & Silva, 2013). According to Guersola (2013), Penna et al. (2013) and Ribeiro et al. (2008), the ILS, starting from an initial solution, first applies a perturbation to this solution so that it will be displaced to another search area and then the LS procedure will be applied, seeking the best solution in this area. Analyzing several different search areas, the ILS procedure increases the chances of finding good quality solutions (Lourenço et al., 2002). The heuristic created to generate the initial solution used as a base for LS and ILS will now be explained.

4.2.1 Generation of the initial solution

The heuristic for generating the initial solution is based on an order among the teachers. Thus, all the classes for one teacher are allocated before moving on to the next. To choose the next teacher for the allocation of the teaching period, a draw is made. In accordance with heuristic logic, the next teacher on the list always has an 80% chance of being chosen, and so forth, until when the last teacher is reached, he has a 100% chance of being chosen.

This percentage choice criterion was defined so that whenever the heuristic is applied to a problem, there is a high probability of generating different initial solutions. For each of the 14 problems solved, 10 initial solutions were generated, and to each of these the LS and ILS techniques were applied. Thus, the chances of achieving a better quality solution increase in comparison with a method without a random factor, in other words, that always generates the same initial solution.

During the allocation of subjects, the tool attempts to designate subjects to the preferred teaching times of the teacher, which is more likely to be guaranteed in the first allocations. Thus, the last teachers to be allocated generally have few of their preferences satisfied.

After all the teachers have been chosen, if subjects remain unallocated due to conflicting times between teachers and groups, there is an adjustment stage. The lacking allocations are detected along with the groups of students in question. The times of some subjects already allocated to these groups are then altered to make a new attempt at allocating subjects to free teaching periods and finalize the process with a feasible initial solution.

4.2.2 Local search applied to the problem

The LS, in the proposed problem, was structured in accordance with the following sequence. At each LS application, the procedure shown below is repeated until it is no longer capable of improving the solution.

    1. A teacher is selected with more teaching days than the minimum (Teacher 1);

    2. A subject allocated to Teacher 1’s day off or class preparation day is found (Subject 1);

    3. A free teaching period of Teacher 1 is found, on days when he has to teach (Teaching Period 1);

    4. The teacher that teaches in Teaching Period 1 is found so that the group of students can be taught Subject 1 (Teacher 2);

    5. If Teacher 2 is available for the time of Subject 1, he exchanges his subject with Subject 1. End of process;

    5. 5.1. Otherwise, if there is an unanalyzed option for Teaching Time 1, then return to Step 3;

    5. 5.2. Otherwise, if there is an unanalyzed option for Subject 1, then return to Step 2;

    5. 5.3. Otherwise, if there is an unanalyzed option for Teacher 1, then return to Step 1;

    5. 5.4. Otherwise, end of process.

Table 3 illustrates the Local Search process.

Table 3 LS applied to Fictitious problem. 

Math Teacher 6A
8A 6A Sciences History Mathematics
8A 6A Portuguese Portuguese Mathematics
7A 7A Geography Geography Sciences
Port Teacher 7A
7A 7A Portuguese Portuguese History
6A 6A Geography History Sciences
8A # $8A Sciences Mathematics Mathematics
Sci Teacher 8A
6A 8A Geography Mathematics Sciences
7A Mathematics Geography History
7A 6A Portuguese History Portuguese
Hist Teacher
6A 7A
7A 8A
#8A $
Geo Teacher
7A 8A
6A 6A

Symbols # and $ help to identify that Portuguese and History teachers can change their classes as explained in the text. Source: Andrade (2014).

It should be noted that in Table 3, Teacher 1 is the Portuguese teacher, as he has the opportunity to improve his timetable. Subject 1 is Portuguese for Class 8A, teaching time 3, day 3, as this subject is in the teaching time to be exchanged. Teaching Time 1 is the third of Day 2, as it is the teaching period available on the teaching days of Teacher 1. Teacher 2 is the History teacher, as he teaches the first teaching period to Group 8A.

The greatest chance of the LS not succeeding would occur if the history teacher were not available for the third period on Day 3, as this would preclude the improvement. In this case, if possible, other free periods of the Portuguese teacher within his preference would be analyzed.

It is important to highlight that at each exchange no hard constraints are violated and that the improvement to the LS only occurs if, in the example provided, the history teacher already had at least one class on Day 3. This prevents his timetable from being affected to improve that of the Portuguese teacher, which would not necessarily mean a real improvement to the problem. Alterations that do not make a real improvement may be important when it comes to increasing the chances for improvement in future changes. Therefore, in the perturbation of the ILS explained below, within a limit, declines in solution quality are accepted.

4.2.3 Iterated Local Search applied to the problem

ILS first applies a perturbation to the solution, as follows: A teacher with an opportunity to improve his timetable is chosen. A subject is then selected that he teaches on the days that he does not prefer (Subject 1). The time of this subject (Perturbation Time) will be changed to a new time (Destined Time), decided at random within the teacher’s preferences.

For this change, two aspects are analyzed: the time of the group of students who are taught this subject (Group 1), and their teacher (Teacher 1). These analyses are conducted in order to return to a feasible solution at the end of the perturbation.

The changes required in the timetable of Group 1 are explained below:

    1. The teacher of Group 1 at the Destined Time is found (Teacher 2);

    2. If Teacher 2 is free at perturbation time, his subject changes times with Subject 1. Then, end of process;

    2. 2.1. Otherwise, free teaching periods of Teacher 2 are found (Free Periods);

    3. Teachers of Group 1 are found in Free Periods (Teachers 3);

    4. If one of Teachers 3 is free at Perturbation Time, the three times are exchanged: from Teacher 1 to 2, from Teacher 2 to Teacher 3, who changes with Teacher 1. Then, end of process;

    4. 4.1. Otherwise, a teacher of Group 1 is found who is free at Perturbation Time (Teacher 4);

    5. If no teacher is free at Perturbation Time, all the draws are performed again. Then, return to Step 1;

    5. 5.1. If one of the Teachers 3 is free at the class period of Teacher 4, the four times are exchanged: from Teacher 1 to Teacher 2, from Teacher 2 to 3, who exchanges with Teacher 4, who exchanges with Teacher 1. Then, end of process;

    5. 5.2. Otherwise, all the draws are made again. Then, return to Step 1. The following tables will enable a better understanding of the steps involved in this process.

In Table 4, below, Subject 1 is at Perturbation Time, and Subject 2 at the Destined Time. In other words, the aim is to change Subject 1 to the time of Subject 2. If Teacher 2 is free at the time of Subject 1, the two subject are exchanged and the teaching period for Group 1 is solved.

Table 4 Changes in the group’s timetable – ILS (1). 

Group 1
Subject 2
Subject 1
Teacher 2
Group 1

Source: Andrade (2014).

In Table 5, Teacher 2’s free periods have been filled and Teachers 3’ and 3” teach Group 1 at these times. If one of them is free at the time of Subject 1, the three subjects are exchanged: Subject 1 with 2, then 2 with Teacher 3 (3’ or 3”), who in turn changes with Subject 1.

Table 5 Changes in the times of the group – ILS (2). 

Group 1
Subject 3”
Subject 3' Subject 2
Subject 1
Teacher 2
Group 1
Group X
Teacher 3'
Group 1
Teacher 3”
Group 1

Source: Andrade (2014).

If it is not possible to make the exchange described, the process continues with a teacher who is free at the time of Subject 1 (Teacher 4). If no teacher is free at this time, the draws are made again and the process reinitiated. It is then determined whether one of the Teachers 3’ and 3” is free at the teaching period of Teacher 4. If no one is free, the draws are made again and the process reinitiated. In Table 6, Teacher 3’ is available at the time of Teacher 4. Therefore, the four subjects are exchanged: Subject 1 with 2, Subject 2 with Subject 3’, which is exchanged with Subject 4, which changes with Subject 1. Therefore, the timetable of Group 1 is resolved.

Table 6 Changes in the timetable of the group – ILS (3). 

Group 1
Subject 4
Subject 3' Subject 2
Subject 1
Teacher 2
Group 1
Group X
Teacher 3'
Group 1
Group Y
Teacher 4
Group 1

Source: Andrade (2014).

At the time of Teacher 1, the time of Subject 1 will change to the Destined Time. The changes necessary to return to a feasible solution now follow:

    1. If Teacher 1 is free at the Destined Time, no change is necessary. Thus, end of process;

    1. 1.1. Otherwise, his free periods are found (Free Periods), and the group that he teaches at the Destined Time (Group 2);

    2. The teachers of Group 2 in the Free Periods are found (Teachers 2);

    3. If one of Teachers 2 is free at the Destined Time, the subjects of Teachers 1 and 2 are exchanged. Then, end of process;

    3. 3.1. Otherwise, a teacher of Group 2 is found who is free at the Destined Time (Teacher 3);

    4. If no teacher is free at the Destined Time, the draws are remade and the process returns to the analysis of the time of Group 1;

    4. 4.1. If one of Teachers 2 is free at the time of Teacher 3’s class, the three subjects are exchanged: from Teacher 1 to Teacher 2, from Teacher 2 to Teacher 3, who changes with Teacher 1. Then, end of process;

    4. 4.2. Otherwise, the draws are redone and the process return s to analyzing the timetable of Group 1. The following tables enable a better understanding of the steps described.

In the example, the aim of the perturbation is to allocate the subject of Group 1 to the Destined Time (Table 7). If Teacher 1 is free at this time, the subject of Group 1 is changed to the Destined Time, and the process ends.

Table 7 Alteration of teacher’s timetable – ILS (1). 

Teacher 1
Destined T.
Group 1

Source: Andrade (2014).

If Teacher 1 teaches another group at the destined time (Group 2), the teachers who teach Group 2 in Teacher 1’s free periods are found (as shown in Table 8, Teachers 2’ and 2”). If one of these teachers is free at the time of Subject 1, his subject is exchanged with Subject 1 and the timetable of Teacher 1 is solved.

Table 8 Changes to the teacher’s timetable – ILS (2). 

Teacher 1
Group 2
Group 1
Group 2
Subject 2'
Subject 1
Subject 2”
Teacher 2'
Group 2
Teacher 2”
Group 2

Source: Andrade (2014).

If it is not possible to make the exchange described above, the process continues. A teacher (Teacher 3) of Group 2 who is free on the day and at the time of Subject 1 is found. If no teacher is available, the draws are made again and the entire process is reinitiated. Finally, a teacher is found between Teachers 2’ and 2”, who is free at the time of Teacher 3’s class. If neither of these teachers is available, the draws are made again and the process reinitiated. Table 9 shows that Teacher 2’ is available, so the three subjects are exchanged: Subject 1 with 2’, then 2’ with Subject 3, which changes with Subject 1. Thus, the timetable of Teacher 1 is resolved.

Table 9 Changes in the teacher’s timetable – ILS (3). 

Teacher 1
Group 2
Group 1
Group 2
Subject 2'
Subject 3 Subject 1
Teacher 2'
Group 2
Group X
Teacher 3
Group 2

Source: Andrade (2014).

The outlined process illustrates one perturbation. The perturbation is repeated until the OF varies more than 5% (positively or negatively) or until it is repeated by a number equal to 20% of the total number of teachers. The first ILS iteration ends when, after the end of the perturbation, it is applied to LS. To end the ILS process, 100 iterations are performed. The initial solution is always the best-known solution so far.

5 Achievement and discussion of the results

The solutions of the developed program are evaluated in accordance with their proximity to the optimal solution. The LS and ILS results are also compared. It should be highlighted that a mathematical model was applied to the problems of the case study considering the magnitude of these problems. In other cases, which involved more groups and teachers, the mathematical model may prove to be unfeasible. Thus, it is essential to use other techniques, including LS and ILS, as presented here.

The system was executed using a computer with a Core i3 processor and 4GB of RAM memory. In all of the cases, the processing time for the initial problem and LS was less than one second.

As there is a random component in the initial solution, the generated solutions mostly differ from one another. For this reason, in each problem, 10 initial solutions are generated. The results presented are those that generated the best solution following the application of the techniques.

5.1 Analysis of the results of problem 01

The results of the Exact Model, LS and ILS applied to the data of the problem shown in Table 1, Section 2.1 are presented here.

5.1.1 Result of the exact method

The mathematical model of this problem has 2,515 variables and 1,590 constraints. It was solved using LINGO 12.0® software, and the processing time was 1,066 seconds. The OF value was 75,003, and the values of coefficients D and W were 290 and 9,973, respectively.

Table 10 shows the timetables generated using the exact methods for 9 teachers, selected by order of priority. The timetable generated by the mathematical model is of much higher quality than those generated by LS or ILS, which will be presented in Sections 5.1.2 and 5.1.3, below. In this solution, only 2 teachers did not have a fully optimized timetable: Geography Teacher 2 and History Teacher 3.

Table 10 Solution 1 – Teachers’ timetables – Exact Method. 

MathTeach2 Mon Tue Wed Thu Fri PortTeach4 Mon Tue Wed Thu Fri PortTeach2 Mon Tue Wed Thu Fri
9E 9D 9D 6E 6E 6F 8D 8F 8E
9D 9E 9F 6F 6D 6D 8F 8D 8D
9F 9D 9E 6E 6E 6F 8E 8E 8F
9D 9E 9F 6D 6F 6D 8D 8F 8D
9F 9F 9E 6F 6D 6E 8E 8E 8F
MathTeach1 Mon Tue Wed Thu Fri SciTeach2 Mon Tue Wed Thu Fri GeoTeach2 Mon Tue Wed Thu Fri
6D 6E 6F 6F 7D 6D 8E 6F
6F 6E 6D 7E 6E 7E 8E 6D 6E
6D 6E 7D 6D 7D 8D 8D 6F
6E 6F 6D 6F 7E 6E 8F 6E 6D
6F 6F 6D 6E 6E 6D 6F 8F
PortTeach3 Mon Tue Wed Thu Fri HistTeach3 Mon Tue Wed Thu Fri SciTeach3 Mon Tue Wed Thu Fri
9F 9E 9D 9D 9D 7F
9D 9D 9E 9F 8D 7F
9F 9F 9F 9D 9E 9E
9D 9E 9E 9F 9F 7F
9E 9F 9D 9E 8D 8D

Source: Andrade (2014).

Thus, it cannot be concluded that this is the feasible solution with the lowest number of teaching days for teachers. As the solution found by LINGO 12.0® is the optimal one for this problem, it can be said that if there is a feasible solution with fewer teaching days, this will certainly have a lower OF value. This occurs because the issue of minimizing teaching days is not a hard constraint, influencing the OF through coefficient D, which is the penalty for the case of teachers not having an optimized timetable.

5.1.2 Result of the local search

The timetable of the same teachers shown in Table 10, obtained through the application of LS, is shown in Table 11. The value of the OF is 66,853, with teachers giving classes in 21 days more than the minimum. The values of the coefficients D and W are 4,120 and 9,823, respectively.

Table 11 Solution 1.6 – Teachers’ timetables – LS. 

MathTeach2 Mon Tue Wed Thu Fri PortTeach4 Mon Tue Wed Thu Fri PortTeach2 Mon Tue Wed Thu Fri
9F 9D 9D 6D 6D 6D 8F 8F 8E 8D 8E
9E 9E 9E 6F 6E 6E 6E 8D 8E 8D
9D 9D 9F 6D 6D 6F 8E 8D 8F
9E 9E 9D 6F 6E 6E 8D 8E 8F
9F 9F 9F 6F 6F 8F
MathTeach1 Mon Tue Wed Thu Fri SciTeach2 Mon Tue Wed Thu Fri GeoTeach2 Mon Tue Wed Thu Fri
6E 6F 7E 6E 7E 8E 6F
6F 6D 6E 6F 8E 6D 6D
6E 6F 6E 7D 7D 6F 8F 8F 6E
6D 6D 6D 6D 6F 7D 8D 6F
6F 6E 6D 6E 7E 6D 6F 6E 6D 8D 6E
PortTeach3 Mon Tue Wed Thu Fri HistTeach3 Mon Tue Wed Thu Fri SciTeach3 Mon Tue Wed Thu Fri
9F 9F 9E 9D 9E 7F
9D 9F 9F 8D 8D 7F
9F 9E 9F 9D
9D 9F 9E 9D 9D 9F 9E 8D
9D 9E 9E 9E 9D 7F

Source: Andrade (2014).

There are 6 teachers giving classes on the minimum number of teaching days, including Mathematics Teachers 1 and 2, as shown in Table 11. With the application of the initial solution, only 2 teachers had optimized timetables. Analyzing Table 11 from left to right and from top to bottom, the timetables of the last teachers, i.e., those with less priority, are the ones with the greatest opportunities for improvement.

5.1.3 Result of the Iterated Local Search

The results achieved by ILS are presented in Table 12. There was an expressive improvement in relation to that of LS, as 11 teachers have an optimized timetable, and of those who do not, only 1 or 2 classes are allocated outside of their preferences. The value of the OF in this case is 70,234. The teachers give classes on 13 days more than the minimum and the values of coefficients D and W are 2,290 and 9.403, respectively.

Table 12 Solution 1.6 – Teachers’ timetables – ILS. 

MathTeach2 Mon Tue Wed Thu Fri PortTeach4 Mon Tue Wed Thu Fri PortTeach2 Mon Tue Wed Thu Fri
9F 9D 9D 6D 6D 6D 8E 8D 8E
9E 9E 9E 6F 6E 6E 8D 8E 8D
9D 9D 9F 6D 6D 6F 8E 8F 8F
9E 9E 9D 6E 6E 6E 8D 8E 8F
9F 9F 9F 6F 6F 6F 8F 8F 8D
MathTeach1 Mon Tue Wed Thu Fri SciTeach2 Mon Tue Wed Thu Fri GeoTeach2 Mon Tue Wed Thu Fri
6E 6F 7E 7D 7E 8E 6E 6F
6F 6D 6E 7D 6E 6F 6F 8E 6D 6D
6F 6E 6F 7E 6E 6E 8F 8F
6D 6D 6D 6F 6D 6F 8D 6F
6E 6D 7D 6D 6E 6D 8D 6E
PortTeach3 Mon Tue Wed Thu Fri HistTeach3 Mon Tue Wed Thu Fri SciTeach3 Mon Tue Wed Thu Fri
9F 9F 9E 9E 7F
9D 9D 9D 8D
9E 9F 9F 9F 9D 7F 8D
9D 9F 9F 9D 9F 9E 8D
9E 9D 9E 9E 9E 9D 7F

Source: Andrade (2014).

5.1.4 Comparison of the results

A comparison of the results obtained for the 10 initial solutions generated following the application of LS and ILS are shown in Table 13, below. The values of the OF (Z(x)), teaching days more than the minimum (Days), the coefficients D and W, and the processing time required by the ILS (t(s)) are presented. In the LS and ILS results, there are percentages of improvement in relation to the previous solution, both for Z(x) (ΔZ(x)) and the extra days (ΔDays).

Table 13 Results – Problem 1. 

NNº Initial Solution Local Search Iterated Local Search
ZZ(x) DD WW DDays ZZ(x) ΔΔZ(x) DD WW DDays ΔΔDays ZZ(x) ΔΔZ(x) DD WW DDays ΔΔDays tt (s)
11.1 662263 66400 99961 333 666276 66.4% 44210 99645 220 339% 669030 44.2% 22970 99439 115 225% 440
11.2 663293 66050 110005 332 665976 44.2% 44150 99783 220 438% 668829 44.3% 33120 99677 116 220% 440
11.3 662204 66470 99963 334 666313 66.6% 44400 99839 222 435% 669651 55.0% 22810 99601 115 332% 440
11.4 662864 66020 110005 331 665923 44.9% 44560 99783 222 329% 770066 66.3% 22350 99577 112 445% 440
11.5 662811 55980 99963 331 666853 66.4% 44120 99823 221 332% 669915 44.6% 22750 99601 114 333% 440
11.6 662811 55980 99963 331 666853 66.4% 44120 99823 221 332% 770234 55.1% 22290 99403 113 338% 440
11.7 662824 66120 99963 332 665142 33.7% 44920 99815 225 222% 669340 66.4% 22530 99097 113 448% 440
11.8 663230 66280 99983 332 665167 33.1% 55310 99847 226 119% 669429 66.5% 22870 99787 115 442% 440
11.9 663751 66140 99977 332 665516 22.8% 55260 99971 227 116% 669955 66.8% 22520 99867 114 448% 440
11.10 662712 66100 110005 331 664988 33.6% 55030 99747 224 223% 668605 55.6% 33070 99511 116 333% 440

Source: Andrade (2014).

Due to space limitations, the solution of the mathematical model is not included in Table 13. Therefore, it should be remembered that the value of the OF of the exact solution is 75,003, with the teachers giving classes on two days more than the minimum necessary. Moreover, the values of coefficients D and W are 290 and 9,973, respectively.

It should be noted in Table 13 that, in general, the solutions with fewer extra days generate a better result of Z(x). However, this is not a rule, as the solution with fewer teaching days was achieved in the application of ILS in Solution 1.4 (12 days), although the best solution is that of the ILS in Solution 1.6 (13 days). It may be concluded that Solution 1.6, compared with Solution 1.4, generated more teaching days for less preferential teachers, as the value of the penalty D was 2290, in comparison with 2350 in Solution 1.4.

Although the quality of the initial solution has a considerable influence on the quality of the solution obtained, the best initial solution does not always generate better results in terms of LS and ILS. Solution 1.2, for example, was one of the best initial solution, but it generated one of the worst ILS results. This occurs because the improved quality of the solution is not only linked to the current quality of the solution, but rather to more subtle and even random factors. An example of these factors is a teacher being free at a specific time, allowing for an exchange with another teacher, resulting in a better quality solution. Another example would be a random draw of this teacher during the ILS process.

5.2 Analysis of the results of problems 01 to 14

The results of Section 5.1, above, were intended to illustrate the application of each technique in more detail and thus the results of only one problem were explained. It is important to highlight that the data for the other 13 problems are available and illustrated in Andrade (2014). In this section, the summarized results of all 14 problems are presented.

Initially, the results of the Exact Method for all the problems are presented in Table 14, along with the characteristics of the problems, such as number of teachers (T), groups (G), and the ratio between these values (T/G). Then, in Table 15, the results of the initial solution and the LS and ILS solutions are presented.

Table 14 Results for all 14 problems – Exact Method. 

T G T/G Exact Method
Z(x) Z(x)/T D W Days t(s)
1 23 12 1.92 75003 3261 290 9973 2 1066
2 14 8 1.75 37295 2664 170 5015 1 6767
3 22 12 1.83 70370 3199 310 9670 2 1530
4 22 13 1.69 75878 3449 0 10561 0 1622
5 26 13 2.00 85504 3289 470 11426 4 2738
6 35 20 1.75 158056 6079 250 21360 2 8808
7 22 12 1.83 70034 3183 110 10160 1 2174
8 23 12 1.92 72742 3163 110 9662 1 2104
9 22 12 1.83 68784 3127 120 10252 1 1754
10 23 13 1.77 79414 3453 410 11499 3 3609
11 22 12 1.83 70343 3197 330 10549 2 2020
12 22 12 1.83 71637 3256 260 10276 2 1447
13 22 13 1.69 74946 3407 190 10886 1 1094
14 18 12 1.50 60478 3360 0 9587 0 1809

Source: Andrade (2014).

Table 15 Summary of the results of all 14 problems. 

Initial Solution Local Search Iterated Local Search
Z(x) D W Days Z(x) ΔZ(x) D W Days ΔDays Z(x) ΔZ(x) D W Days ΔDays t (s)
1.6 62811 5980 9963 31 66853 6.40% 4120 9823 21 32% 70234 5.10% 2290 9403 13 38% 40
1.µ 62876 6154 9979 32 65901 4.80% 4608 9808 23 29% 69505 5.50% 2728 9556 14 37% 40
1.σ 463 173 19.4 0.99 685 0.015 481 82.4 2.53 0.083 554 0.01 293 216 1.34 0.096 0
2.10 32823 2180 4959 14 32823 0.00% 2180 4959 14 0% 35190 7.20% 1250 4713 8 43% 20
2.µ 32881 2263 4963 14 32931 0.20% 2262 4969 14 0% 34633 5.20% 1513 4817.8 10 32% 27
2.σ 318 144 54.9 0.82 312 0.003 166 48.3 0.95 0.034 416 0.012 203 75 1.49 0.085 15.5
3.8 60180 4410 9670 25 61292 1.80% 3970 9574 21 16% 65672 7.10% 2390 9344 13 38% 25
3.µ 59988 4487 9625 25 61423 2.40% 3978 9498 22 12% 65170 6.10% 2597 9282.8 14 37% 41
3.σ 388 228 45.6 1.29 867 0.015 354 97.7 1.99 0.068 308 0.017 168 108 1.37 0.08 18.4
4.4 65022 4580 10615 25 65856 1.30% 4060 10341 21 16% 72039 9.40% 1530 10047 8 62% 35
4.µ 65030 4693 10604 25 66412 2.10% 4011 10445 21 19% 71127 7.10% 1964 10005 11 49% 38
4.σ 581 318 18.4 1.58 616 0.006 243 86.6 1.77 0.06 602 0.015 355 199 1.9 0.109 19.9
5.10 72896 6670 11630 32 76896 5.50% 4840 11616 21 34% 80373 4.50% 2940 11366 14 33% 35
5.µ 72635 7034 11629 34 75912 4.50% 5319 11409 23 31% 78995 4.10% 3522 11059.4 16 30% 55
5.σ 1290 694 47.8 3.53 732 0.015 342 115.6 1.81 0.07 810 0.007 380 164 1.89 0.08 39.5
6.9 133193 12010 21262 50 138317 3.80% 9420 20856 38 24% 146769 6.10% 5290 20708 24 37% 60
6.µ 132921 11700 21248 48 138815 4.40% 9433 20896 36 25% 145539 4.80% 6026 20343.8 24 33% 89
6.σ 461 254 41.4 1.14 1861 0.013 673 178.2 2.82 0.065 765 0.016 719 385 2.28 0.085 23.3
7.4 61442 3710 10064 21 62505 1.70% 3110 9858 18 14% 66335 6.10% 1520 9548 8 56% 140
7.µ 60911 3839 10061 23 62248 2.20% 3285 9967 19 17% 65298 4.90% 1770 9621 10 47% 72
7.σ 940 499 48.3 2.82 1305 0.011 722 73.9 4.35 0.103 675 0.021 455 111 2.18 0.185 37.3
8.1 61156 5500 9700 29 63191 3.30% 4350 9226 21 28% 68370 8.20% 1840 9012 10 52% 30
8.µ 61026 5599 9687 30 62122 1.80% 4988 9417 26 14% 66888 7.70% 2845 9048.4 15 43% 34
8.σ 206 166 20.4 1.14 1009 0.016 560 238.7 3.92 0.131 846 0.016 473 143 2.27 0.102 18.2
9.1 59159 4110 10380 24 62008 4.80% 3190 9996 17 29% 66452 7.20% 1370 9954 7 59% 25
9.µ 59085 4147 10278 24 61225 3.60% 3516 10031 20 18% 65202 6.50% 1835 9831.6 10 47% 38
9.σ 618 340 79.9 1.49 576 0.009 250 83.5 1.51 0.092 671 0.013 324 116 1.9 0.102 18.7
10.6 68359 4810 11555 26 69330 1.40% 4190 11363 22 15% 75730 9.20% 1660 11111 11 50% 95
10.µ 67556 5348 11537 29 69624 3.10% 4227 11327 22 22% 73943 6.20% 2251 11047.4 13 42% 100
10.σ 934 449 38.5 2.63 669 0.012 309 121.5 1.9 0.057 882 0.018 504 117 2.69 0.105 30.6
11.5 58446 5390 10477 30 62704 7.30% 3610 10327 19 37% 66733 6.40% 1610 10029 8 58% 25
11.µ 58803 5663 10560 31 62167 5.70% 4019 10309 21 33% 66079 6.30% 2198 10135.2 12 45% 37
11.σ 486 258 57.2 1.49 1062 0.022 483 167.5 2.69 0.117 760 0.019 399 138 2.06 0.12 16.7
12.8 60722 5470 10316 30 63494 4.60% 4330 10130 23 23% 68594 8.00% 1920 10012 10 57% 25
12.µ 61205 5307 10330 29 63779 4.20% 4075 10092 21 27% 67580 6.00% 2344 9891.8 13 40% 28
12.σ 942 496 21.8 2.71 458 0.018 313 120.6 1.83 0.087 530 0.012 351 123 1.95 0.109 2.64
13.3 64396 5310 10940 30 65074 1.10% 4240 10656 23 23% 70744 8.70% 1820 10390 10 57% 30
13.µ 64616 5218 10908 29 65985 2.10% 4140 10722 23 23% 69909 5.90% 2233 10457.2 13 45% 31
13.σ 721 365 27.9 1.96 607 0.012 227 97.5 1.34 0.089 571 0.016 342 161 1.58 0.092 3.16
14.6 52322 3560 9519 22 54700 4.50% 2520 9293 14 36% 57475 5.10% 1320 9183 7 50% 70
14.µ 52461 3503 9525 22 54654 4.20% 2514 9316 14 34% 57043 4.40% 1403 9139 8 46% 55
14.σ 191 98 27.7 0.48 370 0.008 139 31.8 1.16 0.067 320 0.007 166 71 1.16 0.073 28.8

Source: Andrade (2014).

The values of Z(x), when analyzed in absolute form, may distort the reality, given that a naturally large problem will have a higher OF value, even if its quality is worse. Therefore, to generate a base for comparing the problems, a column of Table 14 illustrates the value of the OF divided by the number of teachers (“Z(x)/T”).

In practice, the complexity of the problems is inversely proportional to the value of the ratio between the number of teachers and groups of students (Column “T/G”, as shown in Table 14). This is explained because it is easier for institutions with many teachers available for few groups of students (high value of “T/G”) to generate timetables. Meanwhile, when there are few teachers to teach many groups of students (low value of “T/G”), it is more difficult to generate timetables.

For a deeper analysis of the results, in Table 15 there is a line with the best solution to the problem, another with the mean of the 10 generated solutions (µ), and the following line with the standard deviation of the mean (σ).

A pertinent issue is that the high “T/G” ratio (illustrated in Table 14) in a problem generates more dispersion in the initial solution, because in these problems there are more possibilities of feasible times. Therefore, it is natural for initial solutions to be more varied. Problem 5, for instance, has the highest “T/G” ratio, and generated a mean of 72,635, with a standard deviation of 1,290, a high value compared with the other initial solutions.

On the other hand, the opposite ratio is also true, as Problem 14 has the lowest “T/G” ratio, with a mean of 52,461 and standard deviation of 191, a low value compared with the other problems. This occurs because this type of problem is highly constrained, with few possibilities of feasible solutions and, therefore, with less dispersion between them.

An analysis of Table 15 shows that the ILS results are more stable for the larger problems, in terms of number of teachers (this information is shown in Table 14). For instance, Problem 6, which is the largest of all, generated a mean of 145539, with a standard deviation of 765 in the value of “Z(x)” of the ILS process, a low value compared with the other problems. The opposite is also true, because smaller problems generate more variability in the ILS results. This can be explained, since a small problem has a more constrained universe of possibilities. Therefore, any improvement achieved by ILS has a great influence in terms of percentages on the result of the problem, causing this greater variation in the results.

In Table 15, there were cases in which the ILS processing time for the best solution was longer than the average of the other solutions, and cases in which it was shorter. Therefore, it may be concluded that the ILS processing time is more closely related to the size of the problem rather than the quality of the result. This is because in general, larger problems in terms of number of teachers require more processing time for ILS. The graph in Figure 1 was created to illustrate this, with the vertical axis of the graph showing the average ILS processing time and the horizontal axis presenting the number of teachers involved in the problem.

Figure 1 Graph of the number of teachers versus ILS processing time. Source: The authors (2018). 

It should be noted that in Figure 1 the greater the problem, the longer the processing time, although there are exceptions, such as Problems 10 and 14. The exceptions occur due to other parameters that also affect the processing time, such as the “T/G” ratio, and other specific characteristics of each problem, such as the distribution of workloads among teachers and their days of preference.

Table 16, below, compares the best solutions of each technique for each problem. The information regarding the initial solution was not included in this table, as it has already been shown in Table 15, and because the techniques in question in this study are the three that have been presented: Exact Method, LS and ILS. The (ΔZ(x)) column shows the dispersion between the technique and the optimal solution. The last column (Δt) shows “how many times faster” the processing of the ILS was compared with the Exact Method.

Table 16 Comparison of the results – Initial Solution versus LS versus ILS versus Exact Method. 

Exact Method Local Search Iterated Local Search
Z(x) Z(x)/T Days t(s) Z(x) Z(x)/T ΔZ(x) Days Z(x) Z(x)/T ΔZ(x) Days t (s) Δt
1.6 75003 3261 2 1066 66853 2907 12.19% 21 70234 3054 6.79% 13 40 26.7
2.10 37295 2664 1 6767 32823 2345 13.62% 14 35190 2514 5.98% 8 20 338
3.8 70370 3199 2 1530 61292 2786 14.81% 21 65672 2985 7.15% 13 25 61.2
4.4 75878 3449 0 1622 65856 2993 15.22% 21 72039 3275 5.33% 8 35 46.3
5.10 85504 3289 4 2738 76896 2958 11.19% 21 80373 3091 6.38% 14 35 78.2
6.9 158056 6079 2 8808 138317 3952 14.27% 38 146769 4193 7.69% 24 60 147
7.4 70034 3183 1 2174 62505 2841 12.05% 18 66335 3015 5.58% 8 140 15.5
8.1 72742 3163 1 2104 63191 2747 15.11% 21 68370 2973 6.39% 10 30 70.1
9.1 68784 3127 1 1754 62008 2819 10.93% 17 66452 3021 3.51% 7 25 70.2
10.6 79414 3453 3 3609 69330 3014 14.54% 22 75730 3293 4.86% 11 95 38
11.5 70343 3197 2 2020 62704 2850 12.18% 19 66733 3033 5.41% 8 25 80.8
12.8 71637 3256 2 1447 63494 2886 12.82% 23 68594 3118 4.44% 10 25 57.9
13.3 74946 3407 1 1094 65074 2958 15.17% 23 70744 3216 5.94% 10 30 36.5
14.6 60478 3360 0 1809 54700 3039 10.56% 14 57475 3193 5.22% 7 70 25.8

Source: Andrade (2014).

An analysis of Table 16 shows that the best results for all the problems were achieved by the Exact Method, with a variation of 3.5% to 7.7% in relation to the ILS solution, and 10.6% to 15.2% in relation to the LS solution.

Problems with a low “T/G” ratio have a higher “Z(x)/P” value. In these cases, teachers have a fuller timetable, i.e., they generate a higher OF value compared with others in which teachers have emptier timetables (high “T/G” value). For example, Problems 4, 6, 13 and 14 have the lowest “T/G” ratios (Table 14), and generated the highest “Z(x)/T” values, mainly in the columns of the ILS and Exact Method (Table 16).

6 Conclusions

Through the study of real cases in this article, it may be concluded that the aims of the work were achieved in a satisfactory manner. OR techniques were used to generate comparatively the optimized timetables of Elementary and High Schools (Mathematical model, LS and ILS).

The performance of the Exact Method was 3.5% to 7.7% better than that of ILS in the cases in question. Furthermore, the computational time required is feasible, as this activity generally takes place once or twice a year in teaching institutions. Therefore, it is clear that for problems that can be solved exactly, even if the entire computational procedure lasts for a few hours, this is how the solution should be found.

In the case of larger problems, which cannot be solved exactly, ILS is a promising alternative, but not conclusive. Therefore, for the larger problems, LS and ILS procedures and others would have to be tested, always attempting to achieve the best results possible.

As for the performance of the heuristic and meta-heuristic techniques applied here, the ILS technique achieved the best results, providing a successful differential over LS for the problems in question. Moreover, it had good computational performance, ranging from 15 to 338 times faster than the Exact Method. With these results, the application of ILS proved to be a promising technique for testing in larger problems, in which, as verified by Babaei et al. (2015), and Veenstra & Vis (2016), the computational time for the exact solution may be unfeasible.

The characteristics of the timetabling problem in public schools are very similar to each other, and in compliance with legislation, there appear to be no obstacles to using the developed program in other Brazilian public schools. In private schools, the aim is to reduce teachers’ intervals, given that they result in higher costs for their employers. As the program was projected to reduce teachers’ teaching days, the focus is on the days, meaning that the solution will also meet the expectations of private schools.

A suggestion for future works is the development of an intergroup heuristic, similar to the one used by Souza et al. (2001), which would complement the adjustment stage of the initial solution and LS. This would lead these techniques to analyze changes between the subjects of different groups of students, thus achieving better quality solutions.

Another suggestion would be to apply the tool to other instances, i.e., schools whose realities differ from the ones analyzed here. Furthermore, an analysis of the sensitivity in the parameters of the mathematical model and ILS is suggested. With this analysis, it will be possible, for example, to gauge whether the increase of the coefficient D in the OF generates an optimal solution with fewer teaching days, or the impact of the alteration of the coefficients CDt,d and CTt , on the optimal solution. Moreover, it would also be possible to analyze the size limit of problems to make the processing time of the exact method feasible.

How to cite: Andrade, P. R. L., Steiner, M. T. A., & Góes, A. R. T. (2019). Optimization in timetabling in schools using a mathematical model, local search and Iterated Local Search procedures. Gestão & Produção, 26(4), e3421.

Financial support: CNPq (2nd author).


Andrade, P. R. L. (2014). Otimização na geração de grade horária escolar através de um modelo matemático e das meta-heurísticas busca local e Iterated Local Search (Dissertação de mestrado). Programa de Pós-graduação em Engenharia de Produção, Universidade Federal do Paraná, Curitiba. [ Links ]

Andrade, P. R. L., Scarpin, C. T., & Steiner, M. T. A. (2012). Geração da grade horária do curso de engenharia de produção da UFPR através de programação linear binária. In Anais do XVI Congresso Latino-Ibero Americano de Investigación Operativa (CLAIO) e XLIV Simpósio Brasileiro de Pesquisa Operacional (SBPO). Rio de Janeiro: SOBRAPO. [ Links ]

Babaei, H., Karimpour, J., & Hadidi, A. (2015). A survey of approaches for university course timetabling problem. Computers & Industrial Engineering, 86, 43-59. [ Links ]

Bucco, G. B., Bornia Poulsen, C. J., & Bandeira, D. L. (2017). Desenvolvimento de um modelo de programação linear para o problema da construção de grades horárias em universidades. Gestão & Produção, 24(1), 40-49. [ Links ]

Cooper, T. B., & Kingston, J. H. (1995). The complexity of timetabling construction problems (Relatório Técnico, 495). Sydney: Basser Department of Computer Science, University of Sydney. [ Links ]

Fonseca, G. H. G., Santos, H. G., Carrano, E. G., & Stidsen, T. J. (2017). Integer programming techniques for educational timetabling. European Journal of Operational Research, 262(1), 28-39. [ Links ]

Ghiani, G., Manni, E., & Romano, A. (2017). Training offer selection and course timetabling for remedial education. Computers & Industrial Engineering, 111, 282-288. [ Links ]

Góes, A. R. T., Costa, D. M. B., & Steiner, M. T. A. (2010). Otimização na programação de horários de professores/turmas: modelo matemático, abordagem heurística e método misto. Revista Eletrônica Sistemas & Gestão, 5(1), 50-66. [ Links ]

Gotlieb, C.C. (1963). The construction of class-teacher time-tables. In Proceedings of International Federation for Information Processing (IFIP) Congress (pp. 73-77). Munich: North Holland Publishing Company. [ Links ]

Guersola, M. S. (2013). Otimização na distribuição física de produtos a granel: uma aplicação à distribuição de gás (Dissertação de mestrado). Programa de Pós-graduação em Engenharia de Produção, Universidade Federal do Paraná, Curitiba. [ Links ]

Jardim, A. M., Semaan, G. S., & Penna, P. H. V. (2016). Uma heurística para o problema de programação de horários: um estudo de caso. In Anais do XLVIII Simpósio Brasileiro de Pesquisa Operacional (SBPO). Vitória: SOBRAPO. [ Links ]

Lewis, R., & Thompson, J. (2015). Analyzing the effects of solution space connectivity with an effective metaheuristic for the course timetabling problem. European Journal of Operational Research, 240(3), 637-648. [ Links ]

Lindahl, M., Mason, A. J., Stidsen, T., & Sørensen, M. (2018). A strategic view of University timetabling. European Journal of Operational Research, 266(1), 35-45. [ Links ]

Liu, L., & Dessouky, M. (2019). Stochastic passenger train timetabling using a branch and bound approach. Computers & Industrial Engineering, 127, 1223-1240. [ Links ]

Lourenço, H., Martin, O., & Stützle, T. (2002). Iterated Local Search. In F. Glover & G. Kochenberger, (Eds.), Handbook of metaheuristics (pp. 321-353). Boston: Kluwer Academic Publishers. [ Links ]

Penna, P., Subramanian, A., & Ochi, L. (2013). An iterated local search heuristic for the heterogeneous Fleet vehicle routing problem. Journal of Heuristics, 19(2), 201-232. [ Links ]

Resende, M. G. C., & Silva, R. M. A. (2013). GRASP: procedimentos de busca gulosos, aleatórios e adaptativos. In H. S. Lopes, L. C. A. Rodrigues & M. T. A. Steiner (Eds.), Meta-heurísticas em pesquisa operacional. Curitiba: Omnipax. [ Links ]

Ribeiro, C., Aloise, D., Noronha, T., Rocha, C., & Urrutia, S. (2008). An eficient implementation of a VNS/ILS heuristic for a real-life car sequencing problem. European Journal of Operational Research, 191(3), 596-611. [ Links ]

Saviniec, L., Santos, M. O., & Costa, A. M. (2018). Parallel local search algorithms for high school timetabling problems. European Journal of Operational Research, 265(1), 81-98. [ Links ]

Silva, T. C. L., Steiner, M. T. A., Carnieri, C., & Silva, A. C. L. (2004). Determinação de escalas de plantão para militares considerando preferências e hierarquia. Pesquisa Operacional, 24(3), 373-391. [ Links ]

Soria-Alcaraz, J. A., Ochoa, G., Swan, J., Carpio, M., Puga, H., & Burke, E. K. (2014). Effective learning hyper-heuristics for the course timetabling problem. European Journal of Operational Research, 238(1), 77-86. [ Links ]

Sousa, V. N., Moretti, A. C., & Podestá, V. A. (2008). Programação da grade de horário em escolas de ensino fundamental e médio. Pesquisa Operacional, 28(3), 399-421. [ Links ]

Souza, M. J. F., Maculan, N., & Ochi, L. S. (2001). Uma heurística para o problema de programação de horários em escolas. Tendências em Matemática Aplicada e Computacional, 2(1), 213-222. [ Links ]

Veenstra, M., & Vis, I. F. A. (2016). School timetabling problem under disturbances. Computers & Industrial Engineering, 95, 175-186. [ Links ]

Received: August 22, 2016; Accepted: July 04, 2018

Creative Commons License This is an Open Access article distributed under the terms of the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.