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

Binária. Abstract: 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.


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.
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.

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.

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).
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.

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 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.

5/23
Optimization in timetabling in schools… Gest.Prod., São Carlos, v. 26, n. 4, e3421, 2019Fonseca 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.

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.
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.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.satisfied, while those at the bottom of the list have fewer chances of having their preferences met.Therefore, the value of the coefficient t CT 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.
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 t CT is also a function of the number of teachers in the problem.
The coefficient W is defined by the sum of the coefficients '  ' '' , . , 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.

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: Indexes: t = 1, ..., T: T is the total number of teachers; . .
To define the values of the coefficient , t d CD , 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 t CT , 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 The heuristic created to generate the initial solution used as a base for LS and ILS will now be explained.

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.

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); For ' n t W and '' w t W , 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. , , , , , , , , , , , , , , , , , , 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 , , , 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.

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).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.

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.
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.1.Otherwise, if there is an unanalyzed option for Teaching Time 1, then return to Step 3; 5.2.Otherwise, if there is an unanalyzed option for Subject 1, then return to Step 2; 5.3.Otherwise, if there is an unanalyzed option for Teacher 1, then return to Step 1; 5.4.Otherwise, end of process.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

9/23
Optimization in timetabling in schools… Gest.Prod., São Carlos, v. 26, n. 4, e3421, 2019 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.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.
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.
If it is not possible to make the exchange described, the process continues with a teacher who is free at the 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.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.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; 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.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.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.
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.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.
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.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;
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.
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, 12/23

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.
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.

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.

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).
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.

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.

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.

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.2and 5.1.3,below.In this solution, only 2 teachers did not have a fully optimized timetable: Geography Teacher 2 and History Teacher 3.
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.

Tue
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 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.

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.
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  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.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).

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 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.
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 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 , t d CD and t CT , 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.

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

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

Table 2 .
Selected articles with timetabling.

Table 3
illustrates the Local Search process.

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

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

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

Table 14 .
Results for all 14 problems -Exact Method.

Table 15 .
Summary of the results of all 14 problems.

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