Two-stage Heuristic for Primary School Timetabling Problem with Combined Classes Consideration

This research focuses on a primary school timetabling problem, a small-scale primary school that is located at Pengerang, Johor. In this small-scale primary school, six classes have been allotted, from standard one until standard six. Most of the primary school timetables are manually developed, which is extremely time-consuming. According to the new policy announced on 12 th Dec 2017by the Ministry of Education (MoE) Malaysia, due to the shortage of teachers, combined-classes should be implemented in lowenrolment schools with fewer than 30 students. MoE has introduced another policy on 30 th June 2018 that recommends schools to reduce the number of subjects that are being taught in a day to solve the overloaded school bag issue. There is a set of hard constraints in this primary school timetabling problem due to the stipulation that a teacher can only teach one subject at a time; each subject must satisfy the total weekly period(s), and the combined classes can only combine one subject at a time. The main objective of this study is to propose a heuristic solution to this solves primary school timetabling problem with the consideration of combinedclasses. A two-stage timetabling heuristic approaches been offered due to its simplicity in dealing with numerous constraints. The twostage heuristic method was clustered into subject groups in the first stage to ease the timeslots allocation in the second stage. A clashfree timetable can be obtained from this proposed algorithm. The result generated by this proposed solution outperforms the current manual practice in solution quality and computing efficiency. Keywords— combined classes; government policy; primary school timetabling; small scale primary school; two-stage heuristic.


I. INTRODUCTION
Timetabling issues can be categorized into three main categories, which are university course timetabling, university examination timetabling, and school timetabling [1], [2]. School timetabling is the arranging of subjects for a week for all classes in a school [2]. Scheduling a list of subjects at a fixed time that must fulfill all the constraints is always a challenge. School timetabling is a vital activity for each school, and it is a time-consuming task. The quality of the school timetables has a huge impact on its educational system [3]- [5]. The complexity of timetabling has gained the attention of researchers in the Operational Research and Artificial Intelligence field [6]. School timetabling problem is a complex combinational optimization problem. A school timetabling problem is an NP-hard problem. Many constraints need to be considered in a school timetabling problem [7].
Some previous studies exposed general timetabling models [7]- [11]. Other previous findings revealed the real cases of the timetabling problem [12]- [16]. While many methods and approaches that can be used to solve a school timetabling problem. There is no fixed algorithm or method to solve the scheduling problem [17]. Different approaches may have different results. The distinct uniqueness of the problem may require different algorithms [17]. Therefore, a new approach to satisfy a set of constraints will be studied in this paper.

II. MATERIALS AND METHOD
The primary timetabling problem in this research is an actual case study of a small-scale primary school that is located at Pengerang, Johor. This small-scale primary school has a small number of teachers and students. Table I shows the number of students, teachers, and classes in this primary school from the year 2017 until 2019. As stated in Table I above, the total amount of students in this primary school for the last few years has been less than 30 people. Due to the shortage of teachers, the Ministry of Education (MoE) has announced a new policy on 12 th Dec 2017 for combine classes in low-enrollment schools with fewer than 30 students.
Moreover, on 30 th June 2018, The Ministry of Education (MoE) has also introduced a new policy to solve the overloaded school bag issue. MoE suggests that teachers make a clear statement or announcement as to what the students should bring to his or her class and has recommended for schools to teach only three to four subjects each day.
There are many subjects offered in this primary school. The government fixes the weekly periods of each subject for the school, and the students, based on their respective standards, must learn all the subjects. The weekly period also varies from standard one (S1) to standard six (S6). Standard one to standard three is grouped as group one, whereas group two is standard four to standard six. The total weekly periods for group one are 46, while group two has 50 weekly periods. Additional weekly periods for certain subjects in group this primary school makes one to meet the 50 weekly periods. Table II shows the subject list and total weekly periods for each standard. This small-scale primary school has predetermined that each teaching slot is 30 minutes with a 20 minutes break time for students. There will be ten teaching slots each day. There are five school days weekly, beginning from Sunday to Thursday. Assembly is set on the first slot on every Sunday.

A. Problem Formulation
The following notation is used in the mathematical modeling for this primary school timetabling problem. A set of constraints must be satisfied to develop a suitable timetable. Two types of constraints are involved in the primary school timetabling problem. Hard constraints (HC) are the constraints that must be fulfilled while soft constraints (SC) are the constraints that are preferred but are not necessary to be satisfied. HC 1 Teachers can only teach one subject at a time. HC 2 Students can only attend one subject at a time. HC 3 Each subject must satisfy the total weekly period(s). HC 4 Combined classes can only combine one subject at a time SC 1 Reduce the number of subjects taught in a day SC 2 Spread teaching slots evenly for each teacher. SC 3 Solving for preference periods such as allocate physical education and language subject before the recess. SC 4 Spread evenly for each subject.
The complexity of the school timetabling problem (STP) was well known due to the STP being either Nondeterministic Polynomial-time complete (NP-complete) or Non-deterministic Polynomial-time hard (NP-hard) problem [14], [18]- [20].
The difficulty of the school timetabling problem could be decreased by dividing the problem into a few stages, which enable the algorithm to concentrate on one or a few constraints at each stage [21]. This causes many researchers to propose a multi-stage heuristic methodology in their study [22], such as studied in [23]. The amount of computation time for solving the problem increases exponentially according to the problem size [24]. The complexity of the school timetabling problem increases exponentially as the problem size increases and the number of constraints increases. Therefore, decrease problem size can reduce the complexity of the school timetabling problem.
The heuristic method is a method that can produce an optimal or near-optimal solution, which can meet as much as possible, and it is a good solution for practical use [25]. Hence, a two-stage heuristic method is applied in this study. In stage I, teacher clustering is conducted with consideration of combined-class. Clustering is a method of grouping a set of similar objects into the same group, which is very useful and efficient to scale down the problem size. Timeslots allocation stage is the second stage that allocates timeslots for each smaller cluster generated at the first stage.

B. Stage I: Teacher clustering stage
A set of the subject group is defined as and g is the total number of subject groups. The teacher clustering stage assigns n subjects into g subject groups, where n>g. It decreases the problem size from n subjects to g subject groups, which also decreases the difficulty of the school timetabling problem. The teacher clustering stage algorithm is shown in Fig. 1. The teacher clustering stage assigns the subjects with no common teachers into a subject group. Number of subject groups, g is not prefixed by the two-stage heuristics algorithm that is proposed in this study. The number of subject groups is calculated through the following sub-step according to the total weekly periods of teachers. The subjects will be defined as either a single period or consecutive periods. Based on the input, those sets of the subject have been categorized into two clusters. The single period cluster will be named as the "Odd session subject" cluster, which is a cluster of the subject that only has one period in a week or is conducted in a single session. For consecutive periods, it will be named as the "Even session subject" cluster. The "Even session subject" had been carried out through two successive periods in each session. There have some subjects that wish to carry out in two consecutive periods, but the weekly periods are an odd number. Hence, an equation was required to classify the subject into a single period and successive periods. The remainder of the weekly periods will cluster as a single period.
Let subject A has x weekly periods, z ∴ weekly periods of subject A will be cluster in "Even session subject" cluster while y will be a cluster in the "Odd session subject" cluster and renamed as subject A2.

2)
Step 2: Generate Individual Subject Groups: A few subject group G from a set of n subjects was generated. Individual subject groups g generated in this sub-step. A required step before the generated number of individual subject groups is the calculation of the total teaching slots for each teacher. The total teaching slots for each teacher will be calculated according to the "Even session subject" cluster and "Odd session subject" cluster. An equation was formulated to calculate the number of individual subject groups required in this sub-step. The total timeslots in timetables of this small-scale primary were 50 timeslots, but one timeslot had been fixed for assembly. Thus, the total available timeslots left was 49. Fig. 2 shows the pseudo-code of the equation for calculating the number of individual subject groups.

3) Step 4: Assign Subjects and Teachers into Subject
Groups: The most important part of the teacher clustering stage algorithm was to assign the subjects with no common teacher into a subject group. The teacher with the highest teaching slots will be considered first in the assigning into a subject group. Every individual subject group will only consist of one subject from standard one to standard six without any repeated teacher being sorted into the same subject group. However, the combined-class will be sorted into the subject group as a block set. These subjects are assigned to the same subject group if these two conditions are met. The first condition is when there is no conflict with other assigned subject group teachers. The second condition is when subjects are from the identical cluster, either "Even session subject" or "Odd session subject" cluster. This is to ensure that the methodology can fulfill the hard constraints of this project, which is each teacher can only teach one class or one subject at the same time. The assigning subjects and teachers into each subject group process will be repeated until all subjects have been completely assigned to individual subject groups. Fig. 3 and Fig. 4 show the concept of assign subjects and teachers with and without combinedclass into individual subject groups. Algorithm 1: Generate GE and GO total available timeslots = at at = 49 maximum total even teaching slots = max even maximum total odd teaching slots = max odd smaller even group = GE smaller odd group = GO odd at

C. Stage II: Timeslots Allocation Stage
Timeslots allocation stage allocates the assigned subject group generated in Stage I into available timeslots. There are three sub-steps in the timeslot's allocation stage.

1) Step 1: Preference Subject:
The government has offered a list of subjects for primary schools which consists of more than 10 subjects for each standard. Due to the many subjects offered by the government, the primary school would have some preference subjects to carry out before recess time after considering the situation and environment of the primary school. This school timetabling system will allocate the subject groups into timeslots with the consideration of preference subject.

2)
Step 2: Generate Matching Matrix: A matching matrix is a matrix to identify the pairing ability of subject groups to be allocated into timeslots. For g number of subject groups G, a g x g matrix will be generated. An example of a matching matrix was shown in Fig. 5.  Fig. 5 above, each element of the matching matrix representing data between G i and G j . This matching matrix checks the common subject between two subject groups, G i and G j . The element of the matrix returns 1 when G i and G j do not have common subject while it returns 0 when G i and G j have a common subject. The subject group has the highest number of element 0 has the greatest pairing ability.

3) Step 3: Timeslot Allocation for Subject Groups:
Timeslot allocation stage is the stage for allocating the subject groups into available timeslots. Outcome from the previous sub-step will be carried forward to this sub-step. The subject group with preference subject will be allocated in timeslots before recess. After that, the timeslot allocation will allocate subject groups with the highest number of element 0 first to meet and maximise the soft constraints. Before allocating any subject group to an available timeslot, the algorithm will check the condition of the subject to identify the suitable timeslot as shown in Fig. 5. The process was repeated until all subject groups were allocated in the timeslots. A master timetable was generated by allocating the individual subject groups into the timeslots on the same day accordingly as shown in Fig. 6. This will ensure that different teachers teach different standards at the same time without any clash.

A. Dataset
This small-scale primary school has a total number of 10 teachers in year 2017 while eight teachers in year 2018 and 2019. This small-scale primary school has six classes. There were 11 subjects offered by government for standard one to standard three while 13 subjects were offered for standard four to standard six. All teachers are assigned to teach different multiple classes and subjects.
There are three datasets collected from the small-scale primary school located at Johor for year 2017 until year 2019. All the teachers have a different amount of total teaching slot. The teaching slots for each teacher in this small-scale primary school are affected by the position factor and their academic course major. The principal and vice principal of this primary school have lesser teaching slots compared with other teachers. Hence, the teaching slots of the principal and vice principal will be excluded in the analysis section later, as the bias data for the plotted graph below. The average teaching slot for each teacher throughout these three years is equal to 27 teaching slots which equivalent to 13.5 hours per week.  Fig. 7 shows the number of teaching slot for each teacher of this small-scale primary school based on these three years dataset. There are 8 teachers who have been excluded the principal and the vice principal in year 2017, and 6 teachers in the following two years, in 2018 and 2019. Teacher I and J in Fig. 7 are vice principal and principal, respectively.

B. Data Analysis
A two-stage heuristic algorithm has been applied on the real datasets that are provided by the school. The timetable that has been generated by this two-stage heuristic algorithm outperforms the current manual practice. The total computational time to generate a timetable by this two-stage heuristic school timetabling system is bounded to ten seconds as compared to the current manual practice solution, which may take days to develop a timetable. It also takes few rounds to consider adjustment. This two-stage heuristic school timetabling system has solved the time consuming problem. Besides that, this system could generate a clashfree timetable, which fulfils the constraints of the timetabling problem.
According to Fig.7 above, the average teaching slots for each teacher according to the three real datasets that are given are 27 teaching slots. There were five school days in a week. Hence, an average teaching slot for each teacher in a day is between four to six teaching slots per day. The timetable that had been generated using manual solution was facing the problem of spreading teaching slot unevenly where some teachers have eight or nine teaching slots in a day. The two-stage heuristic algorithm is able to reduce the high number of teaching slots in a day. The improvement for the problem of spreading the teaching slot evenly was plotted in the graph in Fig. 8, Fig. 9 and Fig. 10. Fig. 8, Fig. 9 and Fig. 10 shows that the two-stage heuristic method improve the spreading teaching slot more evenly. All three plotted graphs show that some teachers are having eight or nine teaching slots in a day for manual solution. The simulation model of the two-stage heuristic algorithm manages to reduce the high teaching slots. The statistics show that there are 68% teaching slots in the year 2017, which was in the acceptable range, and 70% for both 2018 and 2019. For solving the overloaded school bag issue, the twostage heuristic algorithm has considered the new policy of decreasing the number of subjects being taught in a day. The policy is by adding a sub-step of generating a matching matrix to identify the pairing ability of subject groups. A comparison between the number of subjects that are taught in a day by the using current manual practice and the twostage heuristic method is studied and is shown in Fig. 11, Fig.  12 and Fig. 13. Based on Fig. 11, Fig. 12, and Fig. 13, there are many days where seven or eight subjects per day have been generated in the timetable by the manual solution. The simulation model of the two-stage heuristic algorithm has improved the timetable by decreasing the number of subjects that are taught in a day with a minimum of four subjects. This way also could eliminate the highest number of subjects that are taught in a day, i.e., eight subjects generated by the manual solution. For example, there is a reduction of 56% of seven and eight subjects to a maximum of six subjects being taught in a day for the 2019 dataset.
Another policy was announced by the Ministry of Education (MoE) on 12 th Dec 2017, which is to combine classes in low-enrollment schools that have fewer than 30 students, due to the shortage of teachers. The total amount of students in this small-scale primary school was less than 30 students. Hence, this small primary school must follow the policy. Therefore, this two-stage heuristic school timetabling system was developed with combined class consideration. This two-stage heuristic school timetabling system proved that it could successfully solve the combined-class.

IV. CONCLUSION
This research project investigated a real case study i.e. a small-scale government primary school. A two-stage heuristic approach for the primary school with combinedclasses consideration had been proposed, based on a teacher clustering stage and timeslots allocation stage. By using this proposed solution, a feasible solution for the timetabling scheduling problem was successfully obtained. The result generated by this two-stage heuristic approach had outperformed the current manual practice in solution quality and computing efficiency. This two-stage heuristic school timetabling system provides an easy and faster way to generate a primary school timetable. This two-stage heuristic school timetabling system allows the timetable planner to replace a time-consuming job and increases their work efficiency indirectly. It also increases manpower utilization. Even though the result generated by this two-stage heuristic school timetabling system is better than the current manual practice, there is some limitation in this system. This system is only applicable for small-scale primary schools. Therefore, an addition in constraints or the changing of the project's scope may improve the two-stage heuristic school timetabling system to be more applicable in all primary schools in Malaysia.