Modelling Constraints in School Timetabling Using Integer Linear Programming
Modelling Constraints in School Timetabling Using Integer Linear Programming
net/publication/308842155
CITATIONS READS
4 1,922
3 authors, including:
All content following this page was uploaded by S. Ribic on 21 March 2017.
Abstract—Integer linear programming is a popular method to another, more difficult. Paper [5] suggests a solution which
of generating school timetables. Although computationally sim- first assigns lessons to days, then uses the ILP to generate
pler, school timetabling is less developed area than university a timetable within one day, and improves it in the end by
timetabling, because the models which resolve timetabling prob- systematically joining two days at a time and moving lessons
lems proposed thus far have been adjusted to individual cases between them. However, the improvements did not consider
differing from country to country. A proposed model meets most
model expanding to satisfy many less common requirements
of constraints appeared in different school timetabling systems.
for one timetable. There is no need to further elaborate related
Keywords—Integer linear programming, Optimal scheduling work, because paper [6] is very comprehensive related work
survey which analyses 16 methods from 81 papers in which
I. I NTRODUCTION they are modelled. This survey explains 28 constraints, but
until our research maximally 17 were presented in one model.
The automatic timetable generating problem is well known
in research publications, but it is still subject to research III. VARIABLES , EQUATIONS AND OBJECTIVE FUNCTIONS
because of its complexity and practical applicability. Different
mathematical models are used to generate school timetables, Let us define the following sets
university timetables, feasibility timetables for elective courses T = {x | x is teacher}, C = {x | x is course},
and exams timetables. One of early described methods for G = {x | x is class or group},
solving this problem is integer linear programming (ILP) R ={x | x is room} L = {1, 2, 3, ..., M },
[1], but this method gained an increased popularity with the
{x | x is timeslot}
improvements in computer hardware and heuristics for the S=
{x | x is period of multiple slots}
proper branch choice. Unlike many other methods (which are
(1)
heuristic), this one is based on a strict mathematical problem
where M represents the maximum number of sessions for a
description through a series of equations. The main advantage
course that can be held during a week in one class, and set
of this method is the strict distinction between hard problem
S has two alternatives depending on whether we schedule a
constraints (that need to be fulfilled) defined with equations,
lesson into concrete timeslot or into longer period, typically a
and soft constraints (that are desirable, but not mandatory)
day. The complete space of possible lessons is then
defined through the objective function, and smaller dependence
on randomness that happens in heuristic methods. This method F =T ×C ×G×R×L×S (2)
also has disadvantages such as processor requirements, diffi-
culties related to equation formulation , the impossibility of We do not need all ordered sextuples from the set F . It is
formulating some inherently nonlinear constraints and difficul- common that a teacher holds only one or two courses; a
ties in identifying the real reason for a potentially unsolvable class takes only some courses; for most courses the weekly
timetabling problem. In the rest of the paper we will review number of sessions is smaller than M ; it is usually known
the related work, explain the basic descriptions of method, in advance which teacher gives lessons to which class; and
variables, equations and implementation results. it is often the case that a class or course is linked to a
room in advance. If we solve the timetabling problem by
dividing it into periods, we further reduce these sets only to
II. R ELATED WORK
the lessons that take place in the given time (e.g. day) in
The main method equations are defined in [2], but addi- which we look for the timetable. Therefore, we define the
tional research was conducted afterwards in order to improve set of ordered sextuples V ⊂ F that represents only the
the processing power and the quality of generated timetables. lessons whose scheduling makes sense. Let v: N →7 V be
Papers [3] and [4] first apply the ILP to determine the day the partial function that returns different sextuples from set
a lesson belongs to, and then solve each day separately. This V for different values of argument n ≤ card(V ). Let us
approach solved a problem of ILP computational time because introduce the set X = {xi | i ∈ {1, 2, 3, ..., card(V )}} as
of the reduced search space, but it makes timetable improve- a set of binary variables, equipotent to set V , e.g. V ∼ X.
ments, which can be achieved by moving lessons from one day Each variable xi is related to a sextuple from set V , e.g.
∀xi ∈ X, ∃!m ∈ V : m = v(i). Let us also introduce the equation has the value of 1, all other variables automatically
auxiliary functions o: L → N and o: S → N, that return the have the value of 0.
corresponding position number in a chronological order for the P
xi = 1, ∀(t, c, g, l) ∈ T × C × G × L
session number in a week, a time slot or a period. xi ∈Dt,c,g,l
Dt,c,g,l = {xi ∈ X | π1 (v(i)) = t, π2 (v(i)) = c, (4)
Let, for example, x129 corresponds to an ordered sex-
π3 (v(i)) = g, π5 (v(i)) = l},
tuple (Smith, M ath, IIa, M athRoom, 2, F riday3). If this
variable has the value 1 after solving the system, it means This equation group contributes to the reducing of the search
that teacher Smith will give the second mathematics session tree in Branch and Bound algorithms.
for this week to class IIa in the MathRoom in the third time
Scheduling classes for required number of meetings per
slot on Friday, while the value 0 means that he will not.
course: In normal circumstances, equations from the previous
We can access the desired sextuple element by combining
section cover these constraints, since teachers teaching a
the projection operators πi and function v. In the previous
certain course for a certain class are determined in advance. If
example, π3 (v(129)) would return the third ordered sextuple
a timetable needs to determine the teacher as well, instead of
component from set V related to the variable x129 , which is
(4), we should generate HEDT:
class IIa in this case. The approach with this kind of binary P
state variable is introduced by [2], but it is not the only one. xi ≤ 1, ∀(c, g, l) ∈ C × G × L
In [7], variables xi can take values higher than 1 and they xi ∈Dc,g,l
Dc,g,l = {xi ∈ X | π2 (v(i)) = c, π3 (v(i)) = g, (5)
represent the number of classes attending a course at the same
time, in order to reduce the elective courses complexity. Three π5 (v(i)) = l},
types of binary variable exist in [8]: assigning a teacher to a
course, assigning a course to a time slot, and teaching in the Lunch break allocating: Various schools have different
given time slot. In [9], the problem with different length of lunch break definitions. Lunch break is often set between time
lessons and the problem of teacher travel is divided into three slots assigned for lessons, and is not subject to timetabling
subproblems, one integer and two mixed integer subproblems. research as a discrete allocation problem. If the lunch break is
planned as a regular full time slot, it can be modelled at least
We will assume maximization of the objective function. in three ways. In the first approach, lunch break is modelled as
X a free time slot in the timetable for class g in time slot s, using
f= ci xi . (3) the following HETO, where the elements of set K are ordered
xi ∈P
pairs of classes and time slots assigned for lunch break. :
A greater coefficient ci means a greater chance for variable P
xi = 0, ∀(g, s) ∈ K ⊂ G × S
xi to have value equal to 1, and this represents the assign- xi ∈Dg,s (6)
ment of a lesson to a specified time slot or period. This Dg,s = {xi ∈ X | π3 (v(i)) = g, π6 (v(i)) = s},
function can be defined in the problem settings, but it can
be generated dynamically as well. Therefore, [4] shows a way The second way is to model a lunch break as a separate course,
of evolutive improvement of this objective function. Multiple and designate a precise time slot for it. The advantage of this
objective functions exist in paper [8] and they are chosen with approach is the possibility of using the timetable continuity
appropriate preference functions. equations concurrently with these constraints, while the disad-
vantage is the fact that lunch break then requires a dummy
We use the following abbreviations for constraint types def- teacher. The third way uses SCTO. All objective function
initions. Hard constraints HETO (in the form of an equation) coefficients ci multiplied with variables xi , that correspond to
and HNTO (in the form of an inequality) are used only in time slots assigned for lunch break, should have the smallest
equation and inequality systems during assigning of a time possible values.
slot to lessons, and for them set S represents a set of time
slots. Hard constraints HEDO (in the form of an equation) V. M ODELLING CLASH AVOIDANCE CONSTRAINTS
and HNDO (in the form of an inequality) are used only for
assigning a lesson to a period longer than a time slot, typically These constraints only occur in the form of hard con-
a day, and for them set S represents a set of periods. Hard straints. In most of the regular cases a teacher teaches exactly
constraints HEDT (in the form of an equation) and HNDT one class in one room in a given moment. The basic equation
(in the form of an inequality) are used in assigning a time versions given in this section are sufficient to model these
slot as well as in assigning a larger period, and for them set conditions. There are, however, exceptions to this rule in some
S depends on the application. Soft constraints represent the timetables such as lessons given by two teachers to the same
constant ci adjustment in the objective function, whereby we class at the same time (a practical course which demands a
use SCTO during assigning of time slots, we use SCDO during teaching assistant), a teacher holding lessons to two classes
assigning of longer periods, and we use SCDT in both cases. at the same time (merging more classes in a gym), a class
occupying two rooms at the same time with one or two teachers
IV. P ROBLEM REQUIREMENT CONSTRAINTS (e.g. male and female gym). These lessons should be regarded
separately and we will discuss them in a separate section.
The variable presenting a lesson held stays in a consistent
values set with the help of the below listed constraints. Scheduling classes only once per time slot: The following
HNTO limits a class to maximum one lesson in a time slot.
Scheduling teachers for required number of meetings P
xi ≤ 1, ∀(g, s) ∈ G × S
per class: The following HEDT achieves such interdependence xi ∈Dg,s (7)
of variables xi that as soon as one of the variables in the Dg,s = {xi ∈ X | π3 (v(i)) = g, π6 (v(i)) = s},
HNDO set is used if we generate the timetable to determine the patients and the other one teaches. Let the set K ⊂ T × T be
lesson that belongs to a day, where N represents the maximum a set of ordered pairs whose components represent two teachers
number of lessons a single class can have in a day. who cannot teach simultaneously. HTNO which prevents two
P teachers from teaching simultaneously is provided below.
xi ≤ N (g, s), ∀(g, s) ∈ G × S
xi ∈Dg,s (8)
P P
xi + xj ≤ 1,
Dg,s = {xi ∈ X | π3 (v(i)) = g, π6 (v(i)) = s}, xi ∈Dt1,s xj ∈Et2,s
∀(t1, s), (t2, s) ∈ T × S ∧ (t1, t2) ∈ K ⊂ T × T (15)
Scheduling teachers only once per time slot: The fol- Dt1,s = {xi ∈ X | π1 (v(i)) = t1, π6 (v(i)) = s},
lowing HNTO limits a teacher to maximum one lesson in a Et2,s = {xj ∈ X | π1 (v(j)) = t2, π6 (v(j)) = s},
time slot.
P In the corresponding HNDO, N determines the maximum
xi ≤ 1, ∀(t, s) ∈ T × S number of lessons teachers t1 and t2 can teach in a day.
xi ∈Dt,s (9)
Dt,s = {xi ∈ X | π1 (v(i)) = t, π6 (v(i)) = s},
P P
xi + xj ≤ min(N (t1, s), N (t2, s)),
xi ∈Dt1,s xj ∈Et2,s
In the following HNDO, N represents the maximum number ∀(t1, s), (t2, s) ∈ T × S ∧ (t1, t2) ∈ K ⊂ T × T
of lessons a teacher can have in a day. Dt1,s = {xi ∈ X | π1 (v(i)) = t1, π6 (v(i)) = s},
Et2,s = {xj ∈ X | π1 (v(j)) = t2, π6 (v(j)) = s},
P
xi ≤ N (t, s), ∀(t, s) ∈ T × S
xi ∈Dt,s (10) (16)
Dt,s = {xi ∈ X | π1 (v(i)) = t, π6 (v(i)) = s},
Rooms which cannot be active at same time: There is
a requirement, in rare situations, that two rooms should never
Scheduling rooms only once per time slot: With the
be used at the same time (e.g. one is disinfected while the
following HNTO a room is limited to maximum one lesson
other one is used for teaching). While it is possible to have
in a time slot.
P inequalities similar to (15) and (16), it is easier and faster to
xi ≤ 1, ∀(r, s) ∈ R × S model these two rooms as a single room.
xi ∈Dr,s (11)
Dr,s = {xi ∈ X | π4 (v(i)) = r, π6 (v(i)) = s},
VI. M ODELLING RESOURCE UTILIZATION CONSTRAINTS
In the following HNDO, N represents the maximum number
of lessons to be held in a room in a day. Teacher, classes or rooms are often not available all the
P time. Most of these are hard constraints.
xi ≤ N (r, s), ∀(r, s) ∈ R × S
xi ∈Dr,s (12) Scheduling teachers only when available: For certain
Dr,s = {xi ∈ X | π4 (v(i)) = r, π6 (v(i)) = s}, teachers some time slots should be excluded from the gener-
ated timetable. It happens e.g. when a teacher works at another
Classes which cannot be simultaneous: In schools with location in that time slot. If set K represent ordered pairs (t, s)
several elective courses a student can be assigned to different which represent time slots in which a certain teacher cannot
classes at the same time, because the newly created elective teach, the following HEDT are generated:
class consists of all the students which are taking that new P
course. Classes with common students should not have lessons xi = 0, ∀(t, s) ∈ K ⊂ T × S
at the same time. Let the set K ⊂ G × G be a set of ordered
xi ∈Dt,s (17)
Dt,s = {xi ∈ X | π1 (v(i)) = t, π6 (v(i)) = s},
pairs whose components are two classes that cannot have
lessons at the same time. In this case we generate HNTO: If we generate a timetable to determine to which day a
P
xi +
P
xj ≤ 1, lesson belongs, the equations above are used only when a
xi ∈Dg1,s xj ∈Eg2,s teacher is unavailable during the entire day. If the teacher is
∀(g1, s), (g2, s) ∈ G × S ∧ (g1, g2) ∈ K ⊂ G × G (13) unavailable just for a certain period of time during the day, the
Dg1,s = {xi ∈ X | π3 (v(i)) = g1, π6 (v(i)) = s}, corresponding value N in HNDO (10) should be decreased by
Eg2,s = {xj ∈ X | π3 (v(j)) = g2, π6 (v(j)) = s}, the necessary number of lessons.
In the following HNDO, N represents the maximum number Limit of room capacity: Rooms capacity can be viewed
of lessons class g1 or g2 can have in a day. from two aspects. The first one is if the room can satisfy the
P P number of places a class needs. This problem is solved by
xi + xj ≤ min(N (g1, s), N (g2, s)), choosing an appropriate set V whose rooms always suit the
xi ∈Dg1,s xj ∈Eg2,s
∀(g1, s), (g2, s) ∈ G × S ∧ (g1, g2) ∈ K ⊂ G × G class size.
Dg1,s = {xi ∈ X | π3 (v(i)) = g1, π6 (v(i)) = s}, The second aspect are sets of the same rooms. If schools
Eg2,s = {xj ∈ X | π3 (v(j)) = g2, π6 (v(j)) = s}, have N rooms of equal capacity available all the time, in order
(14) to reduce the variable number to be solved in the problem,
Teachers who cannot be simultaneous: The need for this N rooms can be considered as single big room in which M
constraint is quite rare, but it happens in schools were teachers classes can fit. Instead of HNTO (11) we then generate the
have additional duties to attend to besides teaching. In medical following HNTO:
schools, for example, a teacher can be the attending doctor at P
xi ≤ M (r), ∀(r, s) ∈ R × S
the same time, and the timetable should be created so that xi ∈Dr,s (18)
one of the two doctors in the same specialty stays with the Dr,s = {xi ∈ X | π4 (v(i)) = r, π6 (v(i)) = s},
Instead of HNDO (12) we generate HNDO: timetable predicts double sessions for the day, both course
P sessions should be held at a single location. This condition
xi ≤ M (r) · N (s), ∀(r, s) ∈ R × S
xi ∈Dr,s (19) is automatically satisfied if the room is assigned to the lesson
Dr,s = {xi ∈ X | π4 (v(i)) = r, π6 (v(i)) = s}, in advance, rather than when the timetable is generated.
Teaching on separate locations often requires teaching to
All rooms must be used: Some schools pay a lump sum be distributed so as to have lessons on one location held
for heating and maintenance cost and it is in their interest to before lessons on another location. This minimizes moving
have a timetable which uses all the rooms during the day. This the students between from one to another location. If we have
condition can be automatically met if we assign rooms to a for class g, two lessons at two different locations r1 and r2,
teacher or a class in advance through set V . If the timetable whereby lesson at location r2 has to be held at least d lessons
determines rooms as well, this condition can be satisfied with after the lesson on location r1, we generate the HNTO:
the following HEDT: P P
P
xi ≥ 1, ∀(r) ∈ R (o(π6 (v(i)) + d) · xi − o(π6 (v(j)) · xj ≤ 0,
xi ∈Dr1,g,c,l xj ∈Er2,g,c,l
xi ∈Dr (20)
Dr = {xi ∈ X | π4 (v(i)) = r}, ∀(r1, g, c, l), (r2, g, c, l) ∈ R × G × C × L
∧(g, r1, r2) ∈ K ⊂ G × R × R
Room price: Contrary to the previous case, some schools Dr1,g,c,l = {xi ∈ X | π4 (v(i)) = r1, π3 (v(i)) = g,
try to minimize use of rooms, because they settle rental and π2 (v(i)) = c, π5 (v(i)) = l},
maintenance cost, whereby room prices can be differ. These Er2,g,c,l = {xj ∈ X | π4 (v(j)) = r2, π3 (v(j)) = g,
constraints are given as SCDT by decreasing the objective π2 (v(j)) = c, π5 (v(j)) = l}
function coefficients ci for the price of the room connected (23)
with the corresponding variable xi . Time for travel: Schools with lessons at physically remote
Specialized rooms: Some lessons can be taught only in locations can have a free time slot when students need to move
specialized rooms (chemistry labs, gyms). It is solved by from one location to another. The parameter d in HNTO (23)
choosing the appropriate set V which includes only course shoud have a minimum value of 2.
and room combinations that meet the condition.
Unavailable rooms: Some rooms are intended for other VII. M ODELLING WORKLOAD CONSTRAINTS :
purposes and they need to be excluded from certain time slots
at the moment when the timetable is generated (meetings, gym Student and teachers workload constraint can be modelled
rent...). Set K is a set of ordered pairs (r, s) which represent with hard constraints if we generate equations to determine to
time slots when lessons can not be held in a certain room. We which day a lesson belongs.
generate the following HEDT: Different class workload per day and age: The condition
P
xi = 0, ∀(r, s) ∈ K ⊂ R × S from inequality (8) can be reinforce in order to have a uniform
xi ∈Dr,s (21) daily student workload between M 1 and M 2 lessons per day
Dr,s = {xi ∈ X | π4 (v(i)) = r, π6 (v(i)) = s}, with the following HNDO:
If we generate a timetable to determine to which day a lesson
P
M 1(g, s) ≤ xi ≤ M 2(g, s), ∀(g, s) ∈ G × S
belongs, these HEDT are used only if the room is unavailable xi ∈Dg,s (24)
during the entire day. If the room is unavailable for a certain Dg,s = {xi ∈ X | π3 (v(i)) = g, π6 (v(i)) = s},
period of time during the day, value N in HNDO (12) should
be decreased by the necessary number of lessons. Maximum teacher workload: Minimum and maximum
Unavailable classes: Some time slots need to be excluded daily workload can be assigned to teachers in an analogous
from the generated timetable for certain classes. This happens way through the following HNDO:
e.g. in cases when a class has practical lessons outside the P
school. Set K is the set of ordered pairs (c, s) which represent M 1(t, s) ≤ xi ≤ M 2(t, s), ∀(t, s) ∈ T × S
xi ∈Dt,s (25)
time slots when a class is not available. We generate the Dt,s = {xi ∈ X | π1 (v(i)) = t, π6 (v(i)) = s},
following HEDT:
P
xi = 0, ∀(g, s) ∈ K ⊂ G × S Limit of class workload per course category: Course
xi ∈Dg,s (22) type balancing is considered to be a good practice. For exam-
Dg,s = {xi ∈ X | π3 (v(i)) = g, π6 (v(i)) = s},
ple, it is not recommended to have more than three lessons
If we generate a timetable to determine to which day a lesson from the mathematics and physics category. If ordered pair
belongs, these HEDT are used only if the class is unavailable (c1, c2) ∈ C × C represents the pair of courses from the same
during the entire day. If the class is unavailable for a certain category and M 1 represents the daily category lessons limit,
period of time during the day, value N in equation (8) should the required constraint is achieved with the following HNDO:
be decreased by the necessary number of lessons . P P
xi + xj ≤ M 1(c1, c2),
Multiple sites: A school can have multiple locations xi ∈Dc1,g xj ∈Ec2,g
(e.g. more separate schools are integrated in one to reduce ∀(c1, g), (c2, g) ∈ C × G ∧ (c1, c2) ∈ K ⊂ C × C (26)
administrative costs; swimming lessons are held in a pub- Dc1,g = {xi ∈ X | π2 (v(i)) = c1, π3 (v(i)) = g},
lic pool). If the locations are physically separated, and the Ec2,g = {xj ∈ X | π2 (v(j)) = c2, π3 (v(j)) = g},
VIII. T IME SLOT DISTRIBUTION CONSTRAINTS : If we want to have three sessions of the same course with
order numbers l1, l2 and l3 in the same day, we use HEDO
Some of these constraints are modelled with time slot de- (30) for sessions l1 and l2, and HEDO for sessions l1 and l3.
termining equations, while others are modelled with equations
used to determine days. To have two sessions from the same course not appear in
two adjacent days, but to have session l1 at least d days before
Idle timeslots for classes: If a class has k assigned lessons session l2 instead, we use HNDO:
for a period for which a timetable needs to be generated and P P
a total of n time slots available, timetable condensing for (o(π6 (v(i)) + d) · xi − o(π6 (v(j)) · xj ≤ 0,
xi ∈Dl1,c,g xj ∈El2,c,g
all classes from set G1 ⊂ G can be established by forming
∀(l1, c, g), (l2, c, g) ∈ L × C × G
min(k, n − k) HETO and n − k − 1 HNTO like these:
∧(c, l1, l2) ∈ K ⊂ C × L × L
Dl1,c,g = {xi ∈ X | π5 (v(i)) = l1, π2 (v(i)) = c,
P
xi = 1, ∀(g, j) ∈ G1 × {1, 2, ..., min(k, n − k)}
xi ∈Dg,j π3 (v(i)) = g},
Dg.j = {xi ∈ X | π3 (v(i)) = g, El2,c,g = {xj ∈ X | π5 (v(j)) = l2, π2 (v(j)) = c,
o(π
P 6 (v(i))) ∈ {j, j + k, j + 2k, ..., j + pk ≤ n}}, π3 (v(j)) = g}
xi ≤ 1, ∀(g, j) ∈ G1 × {1, 2, ..., n − k − 1} (31)
xi ∈Dg,j The request to limit the number of lessons given by a single
Dg.j = {xi ∈ X | π3 (v(i)) = g, teacher per day between values M 1 and M 2 is fulfilled with
o(π6 (v(i))) ∈ {j, j + k + 1, ..., j + pk + 1 ≤ n}}, the following HNDO:
(27) P
M 1(g, s) ≤ xi ≤ M 2(g, s), ∀(g, t, s) ∈ G × T × S
Condensed timetable as SCTO is made by assigning ob- xi ∈Dg,t,s
jective function coefficients ci to have biggest values for third Dg,t,s = {xi ∈ X | π3 (v(i)) = g, π1 (v(i)) = t,
time slot, and smaller values for earlier and later time slots, π6 (v(i)) = s},
for example by adding −7.5o(i)2 + 40o(i) + 7.5o(i) to ci . (32)
Idle timeslots for teachers: Similarly, timetable conden- Lesson spreading for teachers: A teacher is usually
sation for teachers in set T 1 ⊂ T is established with the related to a course, therefore, (29), (30) and (31) directly
following HETO and HNTO: spread lessons for a teacher as well.
P
xi = 1, ∀(t, j) ∈ T 1 × {1, 2, ..., min(k, n − k)} IX. M ODELLING PREFERENCE CONSTRAINTS
xi ∈Dt,j
Dt.j = {xi ∈ X | π1 (v(i)) = t, Time slot preferences are modelled by setting objective
o(π
P 6 (v(i))) ∈ {j, j + k, j + 2k, ..., j + pk ≤ n}}, function coefficients ci through different SCDT.
xi ≤ 1, ∀(t, j) ∈ T 1 × {1, 2, ..., n − k − 1} Lesson preferences: To express a preference for a certain
xi ∈Dt,j
Dt.j = {xi ∈ X | π1 (v(i)) = t, lesson to take place at a certain time slot, it is sufficient to
o(π6 (v(i))) ∈ {j, j + k + 1, ..., j + pk + 1 ≤ n}}, increase the appropriate coefficient ci in the objective function
(28) which represents this lesson.
Incorporating condensing conditions can lead to unsolvable Teacher preferences: If teachers prefer some time slots
timetables. It has not yet been precisely defined when a and not the other ones, SCDT is modelled using appropriate
timetable can be condensed, although the problem has been increase or decrease of objective function coefficients ci which
researched in [10] on special case bases, i.e. when all teachers correspond to the given teacher lessons xi .
have the same number of lessons per day.
Lesson spreading for classes: The necessary weekly X. L ESSON CONSTRAINTS
number of course sessions can be distributed in different ways. Certain lessons require to be assigned to certain time slots,
If we wish to have all course sessions to be taught on different because, for instance, they use equipment available only at a
days we use HNDO: certain time of the day.
P
xi ≤ 1, ∀(l, c, g, s) ∈ L × C × G × S Scheduling lessons to time slots: To strictly assign a
xi ∈Dl,c,g,s
(29) lesson described by variable xi to a certain time slot, or to
Dl,c,g,s = {xi ∈ X | π5 (v(i)) = l, π2 (v(i)) = c, prevent assigning of a lesson to a given time slot (e.g. sports
π3 (v(i)) = g, π6 (v(i)) = s}, lesson must not be assigned after lunch), we use trivial HEDT
If we want to have two sessions of the same course with order in which M has the value of 0 or 1.
number l1 and l2 in the same day, we use HEDO: xi = M (33)
P P
xi − xj = 0, HEDT of the form (33) , where M = 1 are used in equations
xi ∈Dl1,c,g,s xj ∈El2,c,g,s
which determine the day a lesson belongs to, because when
∀(l1, c, g, s), (l2, c, g, s) ∈ L × C × G × S we strictly assigning a lesson to a time slot, we usually have
∧(c, l1, l2) ∈ K ⊂ C × L × L to assign the day as well. We can use M = 0, for example, in
Dl1,c,g,s = {xi ∈ X | π5 (v(i)) = l1, π2 (v(i)) = c, (30)
cases when a lesson cannot be held at the of a week.
π3 (v(i)) = g, π6 (v(i)) = s},
El2,c,g,s = {xj ∈ X | π5 (v(j)) = l2, π2 (v(j)) = c, Lesson sequences: In some cases we need to assign lessons
π3 (v(j)) = g, π6 (v(j)) = s}, within a day or week so that one lessons type is held after the
other lessons type. An example is the case where practical Simultaneous lessons: HEDT (37) is also used when two
courses come after theoretical courses. Let the set K ⊂ C × C lessons need to be held at the same time for various reasons
be a set of ordered pairs where the first component represents (two teachers teach the same class together in the same room,
a course that comes before a course represented by the second two teachers teach different groups of the same class at the
component, and the distance (in time slots) between these two same time in different rooms, a joint lecture for all classes,
lessons is at least d. For this we use HNDT: etc.). If the variable xj violates any of the clash avoidance
P
(o(π6 (v(i)) + d) · xi −
P
o(π6 (v(j)) · xj ≤ 0, constraints it should be excluded from that constraint.
xi ∈Dc1,g xj ∈Ec2,g
∀(c1, g), (c2, g) ∈ C × G ∧ (c1, c2) ∈ K ⊂ C × C XI. I MPLEMENTATION RESULTS
Dc1,g = {xi ∈ X | π2 (v(i)) = c1, π3 (v(i)) = g}, This model is not only the most complete school
Ec2,g = {xj ∈ X | π2 (v(j)) = c2, π3 (v(j)) = g} timetabling model so far (all 28 constraints from [6] are
(34)
included, and some additional), but it also improved quality
The choice of the parameter d can resolve the problem of
of generated timetables. In our earlier study [4] we developed
impermissible lesson sequences, e.g. three similar consecutive
software in C++ which convert timetable requirements from
lessons, as well.
natural language-like form to ILP model with 12 modeled
Double and triple lessons: If we have a class with two constraints and solves it using GLPK library, once or multiple
or three sessions of the same course on the same day, it is times. We used a test example with 33 teachers, 20 classes, 40
common to have them consecutively. Let us have N time slots groups and 23 courses. While solving one time table, which
in a day. Variables xi , xj , and optional xk , are assigned to the satisfies all hard constraints was quite fast (about 2 s on Core 2
lessons that have to be held consecutively. For two consecutive PC), to get minimal number of idle time slots we had to repeat
lessons we have the following HETO: the calculation multiple times When we added new expressions
(27),(28) and (24) to the model and the program, studet idle
xi − xj = 0 time slots were eliminated, computation time dropped from 1h
π1 (v(i)) = π1 (v(j)), π2 (v(i)) = π2 (v(j)), 14s to 3s, and teacher idle time slots from 85 to 6.
π3 (v(i)) = π3 (v(j)), π4 (v(i)) = π4 (v(j)), (35)
s(π5 (v(i))) = s(π5 (v(j))) + 1,
XII. C ONCLUSION
s(π6 (v(i))) = s(π6 (v(j))) + 1
This paper shows that all the constraints mentioned here
For three consecutive lessons we use the following HETO: and which have appeared in various researches treating the
2xi − xj − xk = 0 school timetabling problem can be modelled with ILP. As this
π1 (v(i)) = π1 (v(j)) = π1 (v(k)), method is deterministic (for non-random objective function
π2 (v(i)) = π2 (v(j)) = π2 (v(k)), coefficients), this means better fulfilment of the supplied
π3 (v(i)) = π3 (v(j)) = π3 (v(k)), (36) constraints compared with heuristic methods. Together with
π4 (v(i)) = π4 (v(j)) = π4 (v(k)), research on reducing the processor requirements it represents
s(π5 (v(i))) = s(π5 (v(j))) + 1 = s(π5 (v(k))) + 2, a significant contribution in this area which is still developing.
s(π6 (v(i))) = s(π6 (v(j))) + 1 = s(π6 (v(k))) + 2,
R EFERENCES
Splitting and merging classes: Dividing a class into [1] T. Arabinda. School timetabling—a case in large binary integer linear
groups (e.g. for teaching an elective course) is modelled by programming. Management science 30.12(1984):1473-1489, 1984.
registering each group as a separate class. Equations (13) and [2] D. Sophia, T. Birbas, and E. Housos. An integer programming formu-
(14) should define that the group representing a part of a class lation for a case study in university timetabling. European Journal of
cannot have lessons at the same time as this entire class. Operational Research 153.1 (2004): 117-135.
[3] S. Daskalaki and T. Birbas. Efficient solutions for a university timetabling
When dividing classes, groups from different classes can problem through integer programming. European Journal of Operational
also be merged in order to take some courses together. For Research, 160(1):106–120, 2005.
example, if only 5 students from 3 classes choose an elective [4] S. Ribić and S. Konjicija. Evolution strategy to make an objective
course, it is rational to have a single lesson for all 15 students. function in two-phase ilp timetabling. In 2011 19thTelecommunications
Forum (TELFOR) Proceedings of Papers, 2011.
If xi and xj represent lessons which have to be held together
[5] P. Epirus. Decomposing the high school timetable problem. PATAT 2012,
(they have the same time slot, the same course, the same page 209.
teacher and the same room, but they have a different class [6] N. Pillay. A survey of school timetabling research. Annals of Operations
and perhaps a different lesson number in the week), we have Research, 218(1):261–293, 2014.
the following HEDT: [7] N. Boland, B D Hughes, L TG Merlot, and P J Stuckey. New integer
linear programming approaches for course timetabling. Computers &
xi − xj = 0 (37) Operations Research, 35(7):2209–2233, 2008.
In merging groups, clash avoidance constraints should be taken [8] N. A. Ismayilova, M. SağIr, and R.N. Gasimov. A multiobjective faculty–
course–time slot assignment problem with preferences. Mathematical
into consideration. Since there are equations which limit a and Computer Modelling, 46(7):1017–1029, 2007.
teacher to teach just one class in a time slot, and equations [9] S.C. Sarin, Y. Wang, and A. Varadarajan. A university-timetabling
which limit a room to one lesson and one class, merging of problem and its solution using benders’ partitioning—a case study.
groups is obviously contradictory to these rules. Therefore, if Journal of Scheduling, 13(2):131–141, 2010.
we want to merge lessons represented by xi and xj , only xi [10] A.M. Magomedov. Condensing timetables with target date divisible
variable and no xj variable should be included in HNDT (9) by each instructor’s number of class hours. Mathematical Notes, 85(1-
(11), and HNDO (10) (12). 2):61–67, 2009.