• No results found

The basics for developing a timetable for high schools

N/A
N/A
Protected

Academic year: 2021

Share "The basics for developing a timetable for high schools"

Copied!
51
0
0

Bezig met laden.... (Bekijk nu de volledige tekst)

Hele tekst

(1)

Universiteit van Amsterdam

Faculteit economie en bedrijfskunde

MSc in Operations Research

Master Thesis

The basics for developing a timetable for

high schools

Author

Imre van der Woude (studentnummer 6148980)

1

st

supervisor

Dr. C. W. Duin

2

nd

supervisor

Dr. H.J. van der Sluis

1-06-2014

(2)

Contents

1. Introduction

2. C1: The basic class-teacher model

(page 5)

o 1.1 CT1

o 1.2 Solvability of CT1

3. C2: Extensions of CT1

(page 12)

o 2.1 Weekly timetables

o 2.2 Preassignments and unavailability’s

o 2.3 A polynomial case of CT4

o 2.4 Constructive greedy heuristics for CT4

4. C3: Local search

(page 28)

o 3.1 Simulated Annealing

o 3.2 Tabu Search

5. C4: Extensions of the class-teacher model

(page 33)

o 4.1 Cambazard et al.

o 4.2 RCPSP

o 4.3 RCPSP in AIMMS

6. C5: Constraint programming

(page 40)

o 5.1 Constraint programming in general

o 5.2 Constraint programming in practice

- C6: Other research concerning timetabling

(page 46)

7. Summary

(page 48)

References

(page 50)

(3)

Introduction

Every school or university has got to develop a timetable for several weeks that satisfies the needs of students as well as the needs of teachers. This normally is a hard problem to cope with. Special complications can also arise. For example in the Netherlands, students have an individual course package and this makes the timetabling even harder. In this paper, several approaches for creating timetables are discussed.

Students in Dutch high schools can individually choose the courses they want to participate in. This means that students do not attend every course with one and the same class. Dutch students must choose one main study direction out of four, comparable to a well-known major in college. However, the students also particularize their study program by choosing between courses within this main direction. Further, the student’s study program is finalized by choosing elective courses. With the choices in direction and the other decisions the students have to make, the Dutch government tries to achieve that students have a study program with courses that complement each other, while allowing students some room for attending courses that they are interested in, even if such decisions are not in line with the rest of the study program. The disadvantage of such a system is that every student could have a unique study program; it poses difficulties when making a school timetable. In this paper, methods for the construction of timetables at Dutch high schools are considered.

There are several aspects to take into account when constructing a timetable for a Dutch high school. Within these aspects that are to be taken into account, there are underlying restrictions that have to be met, otherwise a timetable will not be feasible.

First of all, at Dutch high schools the students have, as mentioned, the possibility of attending a big variety of courses. The timetables has to be such that each student has the ability (and also the obligation) to attend each course that is in his or her study program. This means that the lectures of these courses cannot be held simultaneously.

Furthermore, there are teachers that have to be taken into account. Teachers are not always available. This means that lectures are not just bounded by the available time slots, the availability of the teacher has to be kept in mind too. The timeslots are for five days, with a certain number of hours each day. Like the students, the teachers cannot attend two lectures simultaneously. This means that lectures taught by the same teacher, must be scheduled during different timeslots, which is just an example of an underlying restriction.

Some courses have special features that can only be exercised in a room with

(4)

special facilities. When there is just one room offering such special facilities then two lectures needing such a room can not be held simultaneously, as well. When there is a limited number of normal rooms, then only a certain number of lectures can be held simultaneously.

These constraints are tricky enough to cope with as such. In addition, however, schools generally want a timetable that doesn’t contain specific undesirability’s like in between hours for both students and teachers, the same teacher teaching one class several times a day, etc. This means that not just a feasible timetable is looked for, but an optimal timetable.

In this paper, the full construction of a timetable will not be presented. However, the methods used in the construction of a timetable will be considered. First, a simple model that is solvable in polynomial time will be addressed. Then, this model will be extended to a model that is not polynomial solvable. Both these models deal with classes having a similar study program, the so-called class-teacher model. Two local search techniques, Simulated Annealing and Tabu Search, will be discussed. Extensions of the class-teacher model will also be considered, among them a more complicated model for which, after being transformed into a RCPSP, the optimization program AIMMS creates a timetable. This program exploits the relatively new technique of constraint programming.

(5)

Chapter 1: The basic class-teacher model

1.1 Model CT1

A well-studied model focusses on timetables for collective classes with a limited number of courses and their corresponding teachers. This is the so-called class-teacher model.

As mentioned, in a Dutch high school, a timetable is created for each individual student, because classmates may not all take the same courses. The timetabling problem for this model is therefore more difficult than the class-teacher model. However, it is useful to investigate this simpler model as basis for more advanced models. The class-teacher model is about:

n teachers, j ∈{t1,……,tn }.

m classes, i ∈{c1,……,cm}.

p periods, k ∈{tt1,…,ttp}.

The requirements are the given number of times each teacher has a class. These session requirements are given in the m times n matrix R with elements rij. The sessions must

be given in the specified periods and each session lasts one period. The aim is to make a timetable that meets the requirements; so there is no optimization involved (the standard version).

The resulting problem, called CT1, requires us to find a solution x satisfying

p

k=1 xijk = rij for all i,j (1)

n

j=1 xijk ≤ 1 for all i,k (2)

m

i=1 xijk ≤ 1 for all j,k (3)

xijk = 0 or 1 for all i,j,k (4)

The first constraint makes sure the session requirements are met for each class-teacher combination. The second constraint ensures that a class will not be taught more than one course in one period. The third constraint is similar to the second constraint, but this applies to the teachers. Hence, no teacher can teach more than one course in one period. The last

constraint ensures that a class can at most be given once in a period and that this cannot happen a fractional or a negative amount of times.

(6)

Modifications to the constraints or objective can be made and some of these models will be covered later on.

In the next paragraph, methods to solve the class-teacher model will be discussed.

1.2 Solvability of CT1

Even et al. (1976) have first introduced the model above and they have shown when it is solvable in polynomial time by defining a bipartite multigraph. On one side m nodes represent the classes, each node representing one class and on the other side n nodes represent the teachers, each node representing a teacher. There are only edges between a node representing a teacher and a node representing a class. The number of edges between the node representing teacher tj and the node representing class ci is rij. Now, one color among p colors, each color

representing a period, must be given to each edge, in such a way that no two edges connected to a common node, have the same color. If such a coloring of the edges is possible, the problem is solvable. In this solution, if the node representing class ci is connected to the node

representing teacher tj with color k, then xijk is equal to one and teacher tj teaches class ci in

period k.

Even et al. (1976) have proved the following:

Theorem 1 (Even et al. 1976)

There exists a solution of CT1 if and only if the following inequalities hold:

m

i=1 rij≤ p for all j

n

j=1 rij≤ p for all i

Furthermore, under these conditions the existing solution can be found in polynomial time. These conditions state that no teacher and no class have to attend more lectures than the number of periods p. It is not difficult to see that the conditions are necessary: if one of these numbers is bigger than p, there is no feasible solution.

In order to explain that these conditions are also sufficient, we will insert a subsection devoted to the famous theorem of Hall.

1.2.1

T

HE THEOREM OF

H

ALL

The theorem of Hall concerns complete matchings in a bipartite graph, G. Before stating and proving the theorem of Hall, some definitions are mandatory:

Let |A| denote the cardinality of a set A. 6

(7)

A bipartite graph is a graph G with two sets of nodes V1 and V2 (|V1|≤|V2|) and

with an edge set, E, such that each edge in E connects a node in V1 to a node in

V2.

A complete matching is an edge set E* in E such that edges of E* do not share nodes and |E*| =|V1|.

Consider an arbitrary subset of nodes S of V1: let Γ(S) denote the set of all

nodes in V2 with edges connected to nodes in S.

Given the above, the theorem of Hall can be stated as follows:

Theorem 2 (Hall):

A complete matching exists in the bipartite graph G if and only if |S|≤|Γ(S)| holds for all possible subsets of nodes S in V1.

A full proof of the theorem of Hall is given below; it applies induction to the number of edges and there is made a division into three possible cases.

Case 1:

The condition of Hall holds in G and for all subsets of nodes S in V1 the strict inequality |S|

<|Γ(S)| holds.

In this case, the condition of Hall will still be met, if one arbitrary edge is removed. The remaining bipartite graph has the same node set V1, but one edge fewer, so it contains a

complete matching by induction.

Case 2:

The condition of Hall holds in G and there is at least one subset of nodes S in V1 such that

|S|=|Γ(S)| and |S|<|V1|.

- Consider G’ as the sub graph in G with only the edges incident to nodes between S and Γ(S). It is easy to see that the condition of Hall also applies to

G’.

(8)

- Consider G” as the sub graph with edges between nodes V1\S, denoted by V1

and the nodes of V2\Γ(S), denoted by V2”. An instance is illustrated in Figure 1

below.

The condition of Hall applies to G”, as well. This is now shown by contradiction. Let the subset of nodes in V2” adjacent to a subset Q in V1” be

denoted by Γ”(Q). Assume that a node set S” exists in V1’’ with |S”|>|Γ”(S”)|.

Note that for S”∪ S, we have |Γ(S”∪ S)|=|Γ”(S”)|+|Γ(S)|, because all nodes in Γ(S”)\Γ”(S”) must be part of Γ(S) and Γ(S) is disjoint from V2”. Now, taking

into account that |Γ(S)|=|S| and |S∪ S”|=|S”|+|S|, there can be concluded that |Γ(S”∪ S)|=|Γ”(S”)|+|S|<|S”|+|S|=|S”∪ S|, which is in contradiction with the condition of Hall on graph G, as given! Therefore our assumption of a node set

S” in V1’’ with |S”|>|Γ”(S”)|, must be false: there does not exist such a node

set. So the condition of Hall applies also to G”.

Figure 1. An illustration to clarify the Theorem of Hall. The red line is not an obstacle in the

proof , but the possibility of an edge incident to a node in V1” and to a node in Γ(S) cannot be

excluded.

(9)

As both G’ and G” satisfy the condition of Hall while having fewer edges than G, we can apply induction on the number of edges on both of them and have a complete matching M’ for

S in G’ and another M” for V1” in G”. Now, E* :=M’∪ M” must be a complete matching for

G.

Case 3:

The condition of Hall holds in G and there exists only one ‘subset’ of nodes S in V1 such that

|S| = |Γ(S)| and S=V1.

In this case there can not exist a node in V1 of degree one. So the node of smallest

degree in V1 in graph G is a node, say node b, with a degree higher than one. We claim that

one edge incident to b can be removed and the condition of Hall still applies to the remaining graph. This can easily be shown. Before the edge removal, for any real subset of nodes Q⊂V1

in V1, we have |Γ(Q)|>|Q|, which implies for Q=V1\b that |Γ(V1\b)|=|V1|. Therefore, after the

removal of the edge, the inequality |Γ(Q)|≥|Q| still holds and further |Γ(V1)|=|V1| remains true.

Thus the condition of Hall remains true.

As the condition of Hall remains valid for the reduced graph having fewer edges than G, we can apply induction on the number of edges. Q.E.D.

A complete matching as due to the condition of Hall is generally not unique. One such matching can be found as a result of applying a max-flow algorithm. The graph G is then complemented by firstly a source node incident to all nodes in V1 with capacity 1, and

secondly a target node incident to all nodes in V2 with capacity 1. This way, the max-flow will

flow through each node with a flow of at most 1; a flow through all nodes in V1 corresponds

to a perfect matching.

1.2.2

P

ROOF OF THEOREM

1

We have proven theorem 2, which is needed for the proof of theorem 1. As mentioned, theorem 1 states that a solution to the problem CT1 exists under these inequalities:

m

i=1 rij ≤ p for all j

n

j=1 rij ≤ p for all i

(10)

To show this, the bipartite multigraph of section 1.2 that represents the class-teacher model, is extended by dummy nodes and dummy edges. The extended graph is constructed in such a way that each node on both sides, including the dummy nodes, has degree p, and such that the extended graph is again a bipartite graph. The steps of the extension are described below; an example is given in Figure 2.

The number of edges incident to a node on the teacher side with a dummy node on the class side, that must be added is called h. Here, h :=(n*p-∑m

i=1nj=1 rij). Since the dummy

nodes will get a degree of p, as well, on the class side [h/p]+ ( [ ]+ means rounded up to an

integer value) dummy nodes are needed. A number of dummy nodes on the teacher side is realized analogously; it will equal to [g/p]+, where g:=m*p-∑mi=1nj=1 rij. Thus, the original

nodes can get degree p by inserting dummy edges, which are orange in figure 2, below. To see that the dummy nodes can get this degree, as well, we note that the number of nodes is equal on both sides, because the number of nodes on the class side is m+[h/p]+ =

m+(n-[∑m

i=1nj=1 rij /p]-)=n+(m-[∑mi=1nj=1 rij /p]-)=n+[g/p]+ which is the number of nodes on the

teacher side. Therefore, to attain that the dummy nodes become of degree p, the number of extra edges that must be connected to the class side’s dummy nodes is equal to the number of extra edges that must be connected to the teacher side’s dummy nodes. So, the graph can be completed with all nodes having degree p by drawing these edges between the dummy nodes. A graph with all nodes having the same degree is called regular. An example of the p-regular graph that results here is shown in Figure 2, to the right.

Now, a p-regular bipartite graph meets the condition of Hall: for each set S of nodes in the class side, the number of edges connected to S is p*|S| and because the degree of the involved nodes on the teacher side is p as well, there must be at least [p*|S|/p]+ =|S| nodes

present in Γ(S); so |Γ(S)|≥ |S|.

Now, due to theorem 2, a complete matching can be found, representing a schedule for the first hour. This hour is idle for a class or teacher, when an edge of the complete matching matches its node to a dummy node. Then, after removing all the edges of the first complete matching, the remaining bipartite graph is again p-regular now having for all nodes a degree of p-1. Hence, this remaining graph meets the conditions of Hall, again. The second hour can be scheduled and so on. So a timetable exists and it can be constructed. According to the Hopcroft-Karp algorithm, a maximum matching can be found in time of O(√(n+h)*|E|).Thus, the timetable is constructed in polynomial time.

(11)

rij= 2 0 0 0 0

0 2 0 1 0 0 0 3 0 0 0 1 0 1 1

Figure 2. How a bipartite class-teacher graph (m=4, n=5) is extended to a p-regular one.

In the next chapter, some extensions of the CT1 problem will be considered.

(12)

Chapter 2: Extensions of CT1

2.1 Weekly timetables

The model CT1 applies to p consecutive periods, e.g., the hours in a week, which is comparable to a timetable that creates the exact schedule for the time-slots of a week. De Werra (1984) discusses another kind of weekly timetables under slightly different conditions. In this weekly model the lectures are to be assigned to days, not to an exact period in the day. Now, p represents the number of days. For each teacher and each class, we assume a given bound on the number p. There is a maximum number of lectures that a class can get and a teacher can give per day. These numbers are respectively ai and bj relating to class ci and

teacher tj. Now, the problem, called CT2, is as CT1, but with the constraints (2) and (3) (these

constraints restrict the teachers and classes to appear in at most one lecture per timeslot) replaced by the following constraints:

n

j=1 xijk ≤ ai for all i,k (5)

m

i=1 xijk ≤ bj for all j,k (6)

xijk is integer for all i,j,k

Again, De Werra (1984) gives necessary and sufficient conditions for the problem to be efficiently solvable. These conditions state that no teacher and no class has to take or give more lectures than the number of days, p, multiplied by respectively bj and ai for teacher tj

and class ci. The proof of existence the timetable uses a similar multi-graph model as for CT1.

When coloring the edges in this graph, the only difference is that an edge incident to node i (representing class ci) may get the same color as at most ai edges incident to node i and an

edge incident to node j (representing teacher tj) shares its color with at most bj edges incident

to node j.

More interesting is that De Werra (1984) demonstrates how a weekly timetable can be constructed with teachers and classes a number of lectures per day, as equally distributed over the week as possible (fractions of lectures cannot be given). Thus problem CT3, the following constraints are to be respected:

[∑m

i=1 rij/p]- ≤ ∑mi=1 xijk ≤ [∑mi=1 rij/p]+ = bj for all j,k (7)

(13)

[∑n

j=1 rij/p]- ≤ ∑nj=1 xijk ≤ [∑nj=1 rij/p]+ = ai for all i,k (8)

[rij/p]- ≤ xijk ≤ [rij/p]+ for all i,j,k (9)

N.B. Here, the right-hand sides of (7) and (8) are like optimal values as computed for bj and ai

(see CT2).

Here, []- means rounding down and []+ means rounding up. The constraints (7) and (8) ensure

that the number of lectures for teachers and classes are correctly distributed and the constraint (9) makes sure that even the number of course-lectures per day are as equally as possible distributed.

Also problem CT3 can be solved through the bipartite graph with class nodes on one side and teacher nodes on the other side; this time by repeatedly constructing specialized feasible flows.

After adding a source node s and a target node t, the scheduling of one day can be transformed to a flow problem. Source s is connected to all nodes representing classes and target t is connected to all nodes representing teachers. The arcs between a class node and a teacher node have a lower bound of [rij/p]- and an upper bound (capacity) of [rij/p]+ (these

bounds are either the same or they differ by one). The arcs between s and the class nodes have on their flow value a lower bound of [∑n

j=1 rij/p]- and an upper bound (a capacity) of [∑nj=1

rij/p]+ and the arcs between the teacher nodes and t have a lower bound of [∑mi=1 rij/p]-

and a

capacity of [∑m

i=1 rij/p]+. A maximum flow from s to t under the flow bounding conditions

constitutes a feasible flow, and this (maximum) feasible flow from s to t, will represent the lectures on the first day.

To find the lectures for the next day, a new flow must be computed with modified flow bounds on the edges, to make sure that constraints (7), (8) and (9) will remain valid; this is to be repeated to schedule each day.

2.1.1

ILLUSTRATING THE ALGORITHM FOR

CT3

The following example will illustrate how a weekly timetable is thus created. Assume a timetable for p =2 days. Furthermore, assume two classes and three teachers and the

following matrix R:

t1 t2 t3

c1 2 3 1

c2 0 3 2

(14)

The first day of the schedule uses Figure 3 below. In the figure’s network, the left number on each arc represents the lower bound and the right numbers represent the capacity. We want to determine a maximum (feasible) flow from s to t, respecting the given lower and upper bounds.

Figure 3. The network to construct the first day of the weekly timetable.

First, we show how this problem can be solved by transforming it to a special kind of min-cost flow problem, one with also lower bounds on the arc flow. To do that we add an arc going from t to s with flow lower bound equal to the sum of outgoing flow lower bounds from

s and with big M as upper bound capacity. The cost per unit flow on this arc will be –1 while

the cost per unit flow is zero on all the other arcs. The balancing value will be zero for each node. The network is shown in Figure 4, below. The numbers on the arcs represent

respectively the cost per flow, the lower bound and the upper bound: (cij, lij, uij).

(15)

Figure 4. The graph of a min-cost flow with lower bound involved.

Now, polynomial time algorithms can solve a min-cost flow problem and we will argue that this is also the case for a min-cost flow problem with next to the upper bound constraints on the arc flow values (the normal capacities) also lower bound constraints. The simplest way to show that is to transform this special kind of min-cost flow problem in polynomial time into a normal min-cost flow problem. We explain the transformation in the next paragraph.

2.1.2 T

HE TRANSFORMATION TO A

MCF

The goal of this special min-cost flow problem (SMCF) is to find a flow, xij, on each arc that

meet the balancing values, bi, the lower and upper bounds of the arcs, lij and uij, and minimize

the costs of the total flow. With a normal min-cost flow (MCF), however, lower bounds are not involved. The SMCF is transformed into the MCF as follows. Under SMCF the

formulation of the special min-cost flow problem and under MCF its corresponding formulation of the normal min-cost flow problem.

SMCF MCF

Min. Σ(i,j) xij cij Min. Σ(i,j) yij cij

(16)

s.t. s.t.

lij≤ xij≤ uij, for all (i,j)ϵ A 0 ≤ yij≤ uij’ = uij – lij, for all (i,j)ϵ A

Σ,j (i,j )ϵ A xji – Σj:(i,j )ϵ A xij = bi for all i Σ j:(i,j )ϵ A, yji – Σ j:(i,j )ϵ A yij = bi’ = bi+ Σ j:(i,j )ϵ A lji –

Σ j:(i,j )ϵ A lij for all i

In both models the optimal solutions x and y will be integer, automatically, as due to the fact that the applied parmeters l, u and b are integer.

2.1.3

T

HE CONSTRUCTION OF A FEASIBLE FLOW

As mentioned, the construction of a maximum flow in a network under lower bound

constraints, as required in Figure 3 is not straightforward. This problem can be transformed to a min-cost flow problem as explained in the previous paragraph. By solving the min-cost flow problem, one finds a flow that corresponds to a feasible flow for the network in Figure 3 and thereby to a timetable for the first day.

For the example, the transformation of the max-flow problem to the normal min-cost flow problem is demonstrated by considering the max-flow graph before the transformation in Figure 3 and the min-cost flow graph after the transformation in Figure 5 below.

(17)

Figure 5. Transformation to the min-cost flow problem.

The left number on the arcs represents the costs of that arc and the right number on the arcs represent the capacity on the arcs. The balancing values of the nodes are given above the nodes. The blue arcs are the arcs that disappear as a result of a lower and upper bound of zero, while the red arcs make up the min-cost flow.

The min-cost flow will be y(c1, t3) = y(t3, t) = y(t, s) = y(s, c2) = y(c2, t2) = 1 (with a

minimum flow cost of –1).

This corresponds to the following schedule in for day one: c1-t1, c1-t2, c1-t3, c2-t2 twice and c2

-t3.

Next, the network of Figure 3 must be modified in order to construct the schedule for day 2. The lower bounds and upper bounds for the flows must be recalculated, taking into account the knowledge of what the first day looks like. The new R becomes:

t1 t2 t3

c1 1 2 0

c2 0 1 1

(18)

The corresponding new bipartite flow network appears like this.

Figure 6. The max-flow graph for day two.

After having performed the same steps as with day 1, the schedule for day 2 appears to be: c1-t1, c1-t2 twice, c2-t2 and c2-t3

Now, a two days weekly timetable has been created.

2.2 Preassignments and unavailability’s

2.2.1

M

ETHOD

A

We return to the problem of CT1, the daily timetable. De Werra (1984) shows how one can cope with preassignments of classes to teachers. This means that one requires that some class

ci and some teacher tj must meet in say period k.

Preassignments can actually be seen as an unavailability for both the teacher tj as the

class ci in period k with the modification that rij decreases by one.

Alternatively, preassignments can be indicated by the binary parameter pijk (=1); if

there is no preassignment for class ci and teacher tj on period k, parameter pijk =0. Now, to

(19)

ensure that the preassignment requirements are met, the problem CT1 is supplemented by the constraint:

xijk ≥ pijk for all i,j,k (10)

In this new problem model, one can also cope with unavailability’s of teachers and classes: by considering unavailability’s as preassignments to a dummy class for teachers and to a dummy teacher for classes.

Another way of modeling unavailability’s, while taking account of preassignments in the problem, is by defining the variables slightly different. The variable xijk* assumes here

value 1 if teacher tj and class ci meet in period k and this is no preassignment; xijk* must be

zero, otherwise. Furthermore, the binary parameters cjk* and bik* are introduced. Only if cjk*

and bik* are one, then respectively teacher tj and classci are available and not preassigned in

period k. The variable rij* is reduced by ∑pk=1 pijk. Now, the constraints of the problem are:

p

k=1 xijk* = rij* for all i,j (11)

n

j=1 xijk* ≤ bik* for all i,k (12)

m

i=1 xijk* ≤ cjk* for all j,k (13)

xijk* = 0 or 1 for all i,j,k (14)

Regrettably, as shown in Even (1976), this problem, denoted as CT4, is NP-complete.

2.2.2

M

ETHOD

B

Schaerf (1999) examines a slightly different problem than the problem CT4. The main idea is more or less the same, but there are three differences.

First, De Werra (1984) takes into account that a certain class can be preassigned to a certain teacher in a certain period, while Schaerf (1999) only takes into account that a certain class is preassigned in a certain period, but not by which teacher (and thus which lecture). Schaerf (1999) treats these restrictions as follows. There are two binary matrices T and C for respectively teachers and classes. There is a one in the jth/ith row and kth column if the teacher

tj/class ci is available in period k; a zero otherwise. Furthermore, there is a binary matrix D

that has a one in its ith row and kth column if class ci is preassigned to period k, a zero

otherwise. This results in the following constraints. 19

(20)

p

k=1 xijk = rij for all i,j

m

i=1 xijk ≤ tjk for all j,k (15)

∑n

j=1 xijk≤ cik for all i,k (16)

xijk = 0 or 1 for all i,j,k

n

j=1 xijk ≥ dik for all i,k (17)

The second difference is that Schaerf (1999) considers that two different lectures might have to be taught at the same time. If this is the case with the pair of lectures (i,j,g,h), which denotes one lecture taught by teacher tjto class ciand the other lecture taught by teacher

th to class cg, then if xijk is one, then so must xghk and vice versa. This is expressed using the

notation: x* is the complement of x: so if x is one, x* is zero and if x is zero, x* is one. Then, for each pair of lectures (i,j,g,h) that have the restriction of being taught in the same period, the constraint is expressed as follows:

xijk xghk + xijk* xghk* = 1 for all i,j,k,g,h (18)

Another difference between the perspective of Schaerf (1999) and the perspective of De Werra (1984) is the objective. The objective of De Werra (1984) is to find a feasible solution. The objective of Schaerf (1999) is to find a feasible and convenient timetable. Schaerf (1999), thus, distinguishes between different feasible timetables. The distinction is based on several aspects such as the number of idle hours, whether lectures are given in convenient periods and whether classes and teachers have to switch between different rooms in between two lectures. Using a cost function, these aspects can be taken into account to find the minimum-cost timetable or at least a timetable with a relatively low cost. Schaerf (1999) shows how it can be implemented in practice and he gives some results, using local search. Local search is considered later in this thesis.

2.2.3

M

ETHOD

C

Neufeld and Tartar (1974) also consider the problem CT1 with preassignment and unavailability’s. They transform it into another model, that of p-colorability of a graph,

similar to De Werra (1984), yet differently represented. Where De Werra (1984) uses nodes to represent the classes and teachers, Neufeld and Tartar use the nodes in the graph to represent 20

(21)

meetings between a class and a teacher. The number of meetings rij are represented by rij

nodes, called vijk for the node representing the kth meeting of teacher tj and class ci. There are

edges between nodes when these nodes can not take place in the same period. Now, a

timetable exists if and only if there exists a p-coloring of the graph. A meeting will be held in the same period as the color of the corresponding node. The p-coloring of a graph entails assigning one color, among p different colors, to nodes, such that each node has a color and no adjacent node has the same color.

Neufeld and Tartar (1974) state that the graph-coloring described above is also applicable for creating a timetable, when preassignment constraints or unavailability constraints become part of the problem.

The unavailability constraints are dealt with in the following way. If tik is one, the

nodes that correspond to a meeting with class ci involved cannot have the color k. The same

holds for the teachers. Hence, if there exists a p-coloring of the graph with the constraints mentioned above, there exists a timetable for the problem with unavailability constraints. For the preassignment constraints, it can be seen the other way around. If there are preassignments for the lectures between class ci and teacher tj in period k and l, the nodes

corresponding to these meetings must be assigned the colors k and l respectively. If a p-coloring exists with these preassignment constraints, there exists a timetable for this problem.

2.3 A polynomial case of CT4

This subsection describes a special case of the CT4 problem that is solvable in polynomial time.

In this case each teacher j is available two periods (kj1 and kj2) and has to teach two

lectures for ij1 and ij2. Interestingly, this problem is polynomial solvable. De Werra (1984)

shows how this is solvable in O(n2) by a graph model.

Each teacher only has two available periods; and two lectures to give, so only two schedules for the teacher are possible. For each teacher j these two possible schedules are represented by two nodes: xj representing i1-k1, i2-k2 and xj’ representing i2-k1, i1-k2. This way,

the number of nodes is twice the number of teachers. Nodes are linked by an edge if the corresponding schedules can appear in the same timetable without violating a constraint. Now, the goal is to mark as many nodes as possible that are not adjacent, so not linked to each other by an edge: this is the independent set problem. If the maximum number of nodes that can be found is equal to the number of teachers, a timetable exists. In this timetable, for each

(22)

teacher the schedule corresponds to its marked node. If a timetable exists, each teacher has a marked node, because two nodes corresponding to the schedules of a teacher are always adjacent. De Werra’s (1984) algorithm to construct such a timetable in O(n2) is as follows.

For one teacher, a node is marked randomly, which is called a decision. Now, as a consequence the nodes adjacent to this node, let’s say xj and xk, cannot be marked, so xj’ and

xk’ must be marked. As a consequence of these marks, there might be other nodes that must

be marked. This goes on until either two nodes corresponding to one teacher cannot be marked, because either both nodes are adjacent to a marked node, (and there are not yet as many marked nodes as the number of teachers), or there are no new nodes to be marked while there are unmarked adjacent nodes left. In the latter case a new decision has to be made and the procedure of marking new nodes can continue until, again, either two nodes corresponding to one teacher cannot be marked or there are unmarked adjacent nodes left. In the case that two nodes corresponding to one teacher cannot be marked, there is no timetable with the last decision made, let’s say xi (this is the case because there is no adjacent marked node to either

xi or xi’ or all the nodes of the not yet scheduled teachers, because there has been made a

decision, so what happens after this decision is not affected by the earlier marked nodes), and

xi has to be cancelled and xi’ must be marked. All the nodes marked as a consequence of the

mark of xi must be cancelled, as well. If, after the mark of xi’, later on, it is concluded that xi’

also has to be cancelled and cannot be in the timetable just like xi, then no timetable exists.

However, if at a certain point, the number of marked nodes equals the number of teachers, a timetable exists and corresponds to the marked nodes.

The timetable can thus be found. The in polynomial time solvability follows from the following argument. For each teacher, at most two decisions must be considered. Each of these decisions leads to a marking in O(1) time of at most n other nodes, so the total amount of time of finding a timetable is O(n2).

To illustrate this algorithm, an example problem is processed below. The table to the left indicates the two available timeslots of five teachers and the two (out of three) classes this teacher has to teach. The table to the right indicates the corresponding scheduling options.

(23)

This results in the graph, shown in Figure 7 below (The nodes xi and xi’can be mutually

exchanged as long as the edges are adjusted).

The nodes are connected by an edge if the two schedules cannot both occur.

Figure 7. A graphical representation of an example of the polynomial case of CT4.

The timetable is now constructed as follows. Choose for each teacher a node (a scheduling option) and make sure that none of these nodes are adjacent with each other. This is done as follows. Make the decision x1. The implied scheduling options are: x2, x3’, x5’ and from the

last one x4’ follows. However, x3’ and x4’ cannot both be scheduled, so the timetable cannot

be with x1. Make the decision x1’, from which these schedules result: x3 , x5’ , x4’, x2. This

timetable does not conflict and is thus the feasible timetable found in polynomial time. classes timeslots t1 c1, c2 1,4 t2 c2, c3 2,4 t3 c1, c2 1,3 t4 c1, c3 2,3 t5 c1, c3 1,2 Class-timeslot Class-timeslot x1 1-1, 2-4 x1’ 1-4, 2-1 x2 2-2, 3-4 x2’ 2-4, 3-2 x3 1-1, 2-3 x3’ 1-3, 2-1 x4 1-2, 3-3 x4’ 1-3, 3-2 x5 1-1, 3-2 x5’ 1-2, 3-1 23

(24)

2.4 Constructive greedy heuristics for CT4

Remember that problem CT4 is NP-complete. Therefore, heuristic procedures are welcome. De Werra (1984) has suggested heuristics for the problem CT4. Each heuristic method starts by fixing one of the three aspects teacher, period or class.

For illustration, suppose that one period, say period k, is fixed.

Then, one constructs a bipartite graph with on one side the nodes corresponding to the teachers that are available and not preassigned in period k and on the other side the classes that are available and not preassigned in period k. The number of edges between the teacher nodes and class nodes are equal to the number of lectures that they can meet. Then, in this constructed bipartite graph, a maximum matching can be found; its edges represent a schedule for period k. Next, this must be done with a different period. However, the number of edges in the constructed bipartite graph for this period is to be adjusted: as some meetings between teachers and classes took place in a previously scheduled period, some values of rij decrease

by one. The algorithm goes on until no period is left. The periods might be chosen in order of difficulty, e.g. the busiest periods first, and so on.

Figure 8 below shows an example.

In the figure, the left nodes in the graphs represent the classes, while the right nodes represent the teachers. As an illustration, the case of being in a period k, where the adjusted matrix R for three teachers and two classes appears as below, as in an earlier example. Next to this graph, the graph for the next period: k+1. Here, in period k class c1 is assigned to teacher t1

and class c2 is assigned to teacher t2. It is assumed that in period k and k+1, no preassignment

or unavailability is found present. The red edges represent a maximum matching.

(25)

.

Figure 8 . The assignment of classes to teachers from one period up to the next period by

extracting a matching.

Matrix R:

t1 t2 t3

c1 2 3 1

c2 0 3 2

A maximum matching can be found by transforming the problem into a max-flow problem, once again. A source node gets arcs to the nodes on the left side. The nodes on the right side are linked to the target node. The edges must be turned into arcs with capacity of one. Now, the arcs that contain flow in the max-flow represent the maximum matching in the bipartite graph.

Alternatively, classes or teachers can be fixed analogous to fixing the periods. So alternative heuristics can fix another aspect: teacher or class. In Figure 9 below, a class is fixed. Therefore, a matching must be found between on one side the periods in which this particular fixed class is available and not preassigned and on the other side the teachers that are not preassigned nor yet scheduled, but do have meetings with the fixed class. In the figure, we assume three available periods and meetings with two teachers, of which two meetings with teacher two. Again, in figure 9, the red edges represent a maximum matching.

(26)

Figure 9. The matching heuristic by fixing a class.

In the assignment above, the class is assigned to teacher 1 in period 1 and to teacher 2 in periods 2 and 3.

De Werra (1984) also presents this heuristic in a different way. He makes use of a flow in a graph. In a directed graph, the available periods of a class are represented by nodes, which have directed arcs of capacity one towards the nodes representing the teachers of this class that are available in this period (as well). Then, a source node s is added with arcs of capacity one towards the nodes representing the periods. As a final node, a trace node t is added, with arcs coming from the nodes representing the teachers; its capacity is of the number of lectures that the teacher gives to this class, as given in the matrix R as mentioned before. The heuristic is to find a maximum flow from s to t. Now, the next class can be considered with adjusted availability of the teachers and so on. Concluding, the difference is that in the maximum flow, several meetings of teachers with classes are dealt with using the capacity of an arc, while in the matching several nodes for the teachers or classes are

implemented. The similarities are easily seen, when one keeps in mind that a maximum matching can be found by turning it into a max-flow problem.

(27)

Again, the periods, classes and teachers must be chosen in sequence of difficulty, being the amount of possible conflicts in a period, class or teacher.

In Figure 10, such an example is given. The example is for a different instance than the one in Figure 9. In this example number of meetings between teacher 1 and the class is 2 and between teacher 2 and the class is 1. Furthermore, teacher 1 is only available in periods 1,2 and 4 and teacher 2 is only available in periods 3 and 4. This is presented by the capacity of an arc, in the figure demonstrated by the number above the arcs. On the right side in the figure, this is presented. On the left side, the figure gives the constructed maximum flow in red lines. The constructed maximum flow is three, which assigns the class in periods 1 and 2 to teacher 1 and in period 3 to teacher 2.

Figure 10. The maximum flow heuristic.

In these heuristics, it is possible that a timetable can at the end not be constructed.

In the next chapter, local search will be considered. Local search is a meta-heuristic to find local optima for optimization problems.

(28)

Chapter 3: Local search

The methods for tackling a timetabling problem that are discussed in the previous two chapters are not suited to create timetables for problems like in Dutch high schools. Other, more sophisticated models or solving techniques are necessary. In this chapter two of these techniques are considered: Simulated Annealing and Tabu Search.

The basic ideas of Simulated Annealing and Tabu Search are discussed and complemented by an application in practice.

3.1 Simulated Annealing

Simulated Annealing is a local search technique for solving optimization problems. Local search methods repeatedly change solutions into neighboring solutions: they cannot guarantee to end in an optimal solution, but they try to find a relatively good solution relatively fast.

Simulated Annealing starts with a given feasible or infeasible solution and initially only considers its neighborhood. A neighborhood of a particular solution is the set of

solutions of which the encoding is very similar to the encoding of this solution. The similarity can be different for different problems or different implementations. Before performing simulated annealing, the neighborhood definition must be specified. To avoid an abstract discussion, the following example is presented.

For instance, consider a partitioning problem: among a set of numbers, a subset must be chosen such that the total sum of the numbers in the subset is half (or as close as possible to half) the sum of all the numbers in the set. Suppose the set of numbers is called N and solution called S (the numbers not in S are in N\S). Now, a neighborhood set of neighboring solutions to a given solution S might be defined as follows: by the shift of a number in S to

N\S, by the shift of a number of N\S to S or by the swap of a number in S with a number in N\S. An alternative definition neighborhood arises if one allows just one of the first two

shifting operations.

Simulated Annealing compares a solution with another solution in its neighborhood. This solution in the neighborhood is randomly chosen. If this other solution is better, this solution is accepted and the neighborhood of this new solution is considered. If the solution is worse or equal, the other solution is to be accepted with some probability, in order to reduce the chances of ending in a relatively poor solution. The exact probability for acceptance depends on two aspects. One is a possible deterioration of the solution’s objective value. The

(29)

larger the deterioration, the smaller the acceptance probability should be. The other aspect is the duration that the Simulated Annealing is already running. The longer that simulated annealing is on the way, the smaller the chances must be to get stuck in a relatively poor local optimum, so the smaller the acceptance probability should be. The proposed acceptance probability to use is e-(delta/T). Here, delta is the deterioration of the objective value of the candidate solution, and T is a parameter that decreases as the number of iterations increases. T is comparable to the temperature of an ‘annealing process’ in physics. Normally T normally decreases every some number of iterations with a certain factor, and its initial value is such that the initial acceptance probability is not too low. If a solution is accepted, a new iteration starts up from that solution using the neighborhood of that new solution. At each point in the process, the best solution encountered so far is kept in memory storage.

The process of Simulated Annealing can stop in several ways. For instance, if a certain desired objective value of a solution is reached, or when there has not been an improvement for a certain number of iterations. But other criteria can stop the process, as well.

To rule out the chance of a bad final solution because of a “weird” starting solution, the process can be repeated for a certain (maximum) number of different starting solutions. For all those parameters, there has to be decided which values make the simulated annealing process more successful and robust.

As just noted, in Simulated Annealing, there is a lot of freedom to adjust the process. This might be nice to specialize the process to the problem, but note that this can pose difficulties, as well. More freedom also implies a bigger chance of adjusting the process in a bad way.

3.1.1

SIMULATED ANNEALING IN PRACTICE

Zhang et al. (2010) have done research on the creation of a daily timetable at a high school using Simulated Annealing.

At this high school, the following so-called hard constraint must be met:

• A teacher cannot teach more than one class in the same period nor can a class be taught by more than one teacher in the same period.

• A teacher is assigned to each class a certain number of times a week and a class has to attend a certain number of lectures per week.

• Teachers can only teach during a timeslot in which this teacher is available.

(30)

• A class is not allowed to have idle timeslots except for the last timeslot of a day.

So far, only the last constraint differs from the earlier mentioned CT4 problem. The hard constraints are important and must be met: desirable but not necessary are the following soft constraints:

• Teachers list timeslots that are not favorable (although possible) and they want to have as few lectures as possible scheduled on these timeslots.

• Furthermore, teachers don’t like free hours in between lectures.

• Teachers don’t like to teach a class twice a day in non-consecutive hours. • Teachers want the lectures to a class to be spread out as equally as possible

during a week.

• Teachers don’t like to teach the last timeslot of a day.

• Teachers want the number of teaching hours per day spread out as equally as possible during the week.

All these soft constraints are given a weight of importance and in this way a value can be given to each timetable. This value is the objective that one wants to minimize.

Zhang et al. (2010) encoded a timetable by a matrix. The row denotes the class that is concerned and the column denotes the timeslot that is concerned. An element in the matrix denotes the course and the teacher the course is taught by and is therefore denoted by two figures, say (a,b). Here, a denotes the concerned course and b the concerned teacher of that course. A teacher is thus identified not just by the second number, but the combination of the two numbers. A teacher is associated with a course.

Zhang et al. (2010) define a neighbor as the swap of an element in the matrix with another element concerning the same class, but a different timeslot within the same day. A neighbor is found by ordering the classes randomly and then picking the first class and making the most profitable swap between the first timeslot element of that class with another timeslot of that class that day. One of these timeslots may be idle hours, but not both. Next, the second class in the ordering is considered, etcetera.

A swap is accepted only in the following cases. If the swap decreases the number of violated hard constraints, it is always accepted. If the current solution is infeasible, an increase of violated hard constraints is accepted with probability e-(delta/T). This is also the acceptance probability if a current solution is feasible as well as the considered new solution, but the

(31)

considered new solution deteriorates the objective by delta. A decrease in the objective is always accepted as long as the number of violated hard constraints do not increase.

The performance of the considered neighborhood is measured as follows. For different benchmark instances, the solutions generated are compared with existing relatively good performing approaches, by speed and objective. For all the benchmark instances, the proposed neighborhood of Zhang et al. (2010) performs better on speed and at least as good on

objective as the existing approaches. It can thus be concluded that the approach of Zhang et al. (2010) improves the existing local search for timetables at high schools that use simulated annealing with these benchmark instances, though with different neighborhoods.

3.2 Tabu Search

In this section, Tabu Search is considered.

Tabu Search is a local search technique, as well. Tabu Search has some similarities to simulated annealing. The main similarity is that Tabu Search makes use of neighborhoods as well. Again infeasible solutions are punished by relatively large cost terms for violation in the cost function (similar to simulated annealing); costs at least as high as other costs as defined for inconvenient yet feasible aspects in the timetable.

The Tabu Search process starts with an initial solution. The (possibly infeasible) neighborhood solutions of this solution are examined and its least costly solution is chosen as new solution. This repeats itself, one again moves from one solution to another solution in the neighborhood, but, to make sure that the same solutions are not repeated, the reversal of each ‘move’ (a change that would restore an old solution), is temporarily added to a so-called Tabu list. When a move is on the Tabu list of moves, this move may not be executed by the

algorithm. There can be exceptions, though, in which case a Tabu-move is allowed after all. One of those exceptions is when the new solution has best costs so far.

The costs for an infeasible solution can be adjusted periodically during the search after a certain number of iterations. These costs increase by a punishment factor, if, during these iterations, all solutions are infeasible, while these costs decrease by that factor, if, during these iterations, all solutions are feasible. The number of iterations that a move is on a Tabu list can be a constant or randomly determined.

(32)

3.2.1.

T

ABU

S

EARCH IN PRACTICE

Schaerf (1996) has implemented Tabu Search in practice for a timetabling problem at a school, as follows.

The punishment factor is randomly chosen between 1.8 and 2.2. The number of iterations that a move is on the Tabu list, is randomly determined between two numbers indicated by Imin and Imax.

Schaerf (1996) takes into consideration that a move may also lead to the same

solution, because of the fact that some lectures must be held several times a week.: he makes such moves impossible, or ‘illegal’. The Tabu Search stops when there has not been an improving solution for a certain number of iterations.

To find a better solution faster, Schaerf (1996) used the local search method

randomized non-ascendant method (RNA) to find a solution that is a relatively good solution in a relatively small amount of time. RNA analyzes a random neighbor and accepts the movement if it is an improvement. This is done until no improvement is found for a certain number of searches. From that point on, a normal Tabu Search is implemented to find an even better solution.

The results thus found show that this method is able to produce quickly good timetables.

In the next chapter, some extensions to the class-teacher model are discussed.

(33)

Chapter 4: Extensions of the class-teacher model

4.1 Cambazard et al.

In the paper of Cambazard et al. (2005) a weekly timetable is constructed for the third year of an engineering school. Here, the problem does not focus on classes, but on students. Each student chooses a different combination of courses than most other students. This makes the problem more complex and not solvable in polynomial time.

At the engineering school, students have to choose a major, a minor (both consisting of various courses), and elective courses. Thirty courses resort to nine main topics. The engineering school employs a maximum number of rooms R in each time slot, which are hard constraints. Furthermore, courses within the same major or minor of some student cannot be held in the same timeslot; these are hard constraints, as well.

The possible combinations of a major and a minor (different from the major) are called options o. For student s, the courses in the major are denoted by set R1o(s) and the chosen

courses in a minor of an option o by R2o(s); alternatively we may write R1s and R2s. Adding

to the option of a student his elective courses, the entire set of chosen courses, denoted by Choice(s), of a student s is realized.

There are restrictions with regard to availability of the teachers, but these restrictions are treated as soft constraints, which means that these constraints are only considered if all the hard constraints are met. The teachers only give one course once a week. Some courses cannot be held at the same time, indicated by a matrix, which links the non-simultaneous courses. There is a conflict when a student has two courses of Choices in the same timeslot.

Distinguishing between conflicts is possible, for example through the number of students involved in the conflict, or whether for those students the courses are elective, or courses in the minor or courses in the major. Thus, one can give a weight wi1,i2 to a conflict

between courses i1 and i2.

To put the problem into variables, a binary variable xik is introduced, like before in

chapter 2, it is 1 if course i is held in timeslot k (there are p timeslots), and zero, otherwise. The constraints are given as below. (Note that courses are already associated with teachers, in this case.)

Constraints assigning courses to a period: ∑p

k=1 xik = 1 for all i

(34)

Hard constraints, imposing non-simultaneous courses: ∑(iin R1s) xi k≤ 1 for all k

xi1k+xi2k≤ 1 for all k and i1,i2 in linked courses

all courses xik≤ R for all k

Soft constraints:

xik = 0 if teacher of course i is rather absent in timeslot k

(∑i1in R1s (∑i2 inR2s xi1k+xi2k ))≤1 for all k, s

∑iin choices(s) xik≤1 for all k, s

The objective is to meet the hard constraints, firstly, and to minimize the sum of weighted conflicts, secondly. Another requirement is that the model must be dynamic, which means that it must be easily adaptable to small changes in, for example, teacher availability, without resulting in big changes in the timetable.

A way to deal with this problem is treated in the next chapter, which considers constraint programming.

4.2 RCPSP

The class-teacher model as described by De Werra (1984) is inadequate for Dutch high schools. It could however be extended, for dealing with the different study programs of individual students.

Like in 4.1, we choose to consider courses and each student participates in a particular set of courses. Now, two lectures of courses that contain the same students cannot be held in the same timeslot. The model of De Werra (1984) is then supplemented by additional constraints concerning the courses. For each course i, let the set of participating students be denoted by studentsof(i). The number of students that attends in both course i and course i’ can be denoted by n(i,i’), where n (i,i’) =|studentsof(i)∩ studentsof(i)|. Further, to make the problem similar to the problem in Dutch high schools, a different constraint must be added, as well: room availability. The total number of rooms available per timeslot is R. The constraints for a feasible timetable, then are as follows.

p

k=1 xijk = rij for all i,j (1)

(35)

n

j=1 xijk ≤ 1 for all i,k (2)

m

i=1 xijk ≤ 1 for all j,k (3)

n

j=1 xijk+∑nj’=1 xi’j’k ≤ 1 for all k and for all i,i’ with n(i,i’) >0 (19)

n

j=1mi=1 xijk ≤ R for all k (20)

Note that because of (1) xijk = 0 for i,j with rij = 0.

The problem that results is no longer solvable in polynomial time, because of the added constraints (19) and (20). However, the problem is now ready to be transformed to a special case of a well known problem, the resource-constrained project scheduling problem (RCPSP).

In RCPSP, tasks must be scheduled. These tasks all have a certain duration and require certain resources. The capacity of resources per timeslot is limited. Sometimes, certain tasks can only start after specific other tasks are finished, the so-called predecessor(s) of this task. The goal is to schedule all the tasks in a feasible way either within a certain interval of timeslots or to finish all the tasks as soon as possible.

The described high school scheduling problem can be reformulated into a RCPSP under the first objective, as follows.

The tasks are the meetings of courses that need to be scheduled within p timeslots. The resources are an available room, which is limited by R for each timeslot, and an available teacher. The resource room(s) is a parallel resource, meaning that the rooms are mutually exchangeable. The resource teachers is different; each teacher is a separate, sequential

resource, meaning that a particular teacher can only teach once in each timeslot, and after that the teacher is re-available.

Normally, the duration of each meeting within a course is 1 and there are few or no predecessor(s).

4.3 Implementing a solution method in AIMMS

4.3.1

A

SIMPLIFIED EXAMPLE

The above mentioned model is applied here to a fictive scheduling task at a fictive school to demonstrate the use of RCPSP.

This example considers a very small school in order to achieve that the overview is orderly and the results are easily interpreted. However, the school must still contain all the basic difficulties that a real school is faced with. This means that there must be teachers with 35

(36)

their own timeslots of absences, there must be courses which are chosen by some students and lectures for these courses may take place multiple times a week. To reduce difficulties, there will be less students, teachers and timeslots than in a real problem. The example problem is presented below.

There are three teachers, seven students and five courses in our example problem. We assume a maximum of four students per room and therefore per lecture. In each timeslot, in total four rooms are available. The next table represents which course is taken by which student in the problem. The first column denotes the different students and the first row denotes the different courses. A one is placed in a cell if that student takes that course and a zero if not. The last three students have the same choice in order to see whether these students get the same schedule.

A B C D E 1: 1 0 1 0 1 2: 1 1 0 1 0 3: 1 1 0 0 1 4: 0 1 0 1 0 5: 1 0 1 0 0 6: 1 0 1 0 0 7: 1 0 1 0 0

The next table shows which courses can be given by which teachers and how many times the course is held in one week. Hereby, T1, T2, T3 represent the three teachers. The course A is doubled for two groups of students, one taught by teacher T1 and the other by teacher T3.

teacher Number of classes per week A T1 and T3 1 B T2 2 C T1 1 D T2 3 E T3 3 36

(37)

Also, there are, like in CT4, timeslots in which the teachers are not available. We consider twenty timeslots: the end of a day is after each fourth timeslot. Twenty timeslots is rather ample, but this way it is easier to make a fitting timetable and results for different ways of computation can be compared.

In the next table, the teacher availability is shown. The first row represents the timeslots. A one is in the cell if the teacher is present and a zero if the teacher is absent.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 T1 1 1 1 1 0 0 0 1 1 1 1 1 0 0 0 0 1 1 0 0 T2 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1 0 0 1 T3 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1

4.3.2

THE IMPLEMENTATION IN AIMMS

For the execution of the problem as an RCPSP, the optimization problem AIMMS is used. AIMMS has a build in function to effectively cope with RCPSP. Objects can be defined as task (or activity) or resource. Among other specifications, these resources can be specified as parallel or sequential resources, which simplifies the formulation of the scheduling problem into AIMMS.

The implementation into AIMMS is summarized below with in italic a short explanation.

SETS

- iSubjects “to represent the courses”

- cCopies “to cope with multiple lectures a week for one course”

- jTeachers “to represent the teachers”

- sStudents “to represent the students”

- tTimeSlots “to represent the timeslots”

- SlotsOf(j) “to represent the availability of teacher j”

- SubjectsOf(s) “to represent the subset of courses student s participates in” - StudentsOf(i) “the inverse matrix of SubjectsOf(s)”

- Students(i,ii) “the students that participates in both course i and course ii”

PARAMETERS

(38)

- n “the number of students”

- m “the number of teachers”

- tt “the number of timeslots”

- Duration(i) “the duration of course i”

- nStudents(i,ii) “equal to n(i,i’)

- Required(i,j) “the number of lectures course i is taught by teacher j a week”

CONSTRAINTS

- studentconstraint(i,ii,j,jj,c,cc) “to make sure no two courses containing the same students are held in the same timeslot”

ACTIVITY

- act(i,j,c) “All tasks must be scheduled for which c<=Required(i,j)>0”

RESOURCES

- teacher(j) “the sequential resource teacher j with schedule domain SlotsOf(j)”

- room “the parallel resource room”

AIMMS is now able to find a feasible, if possible, timetable for the example using constraint programming (constraint programming is covered in the next chapter).

To help AIMMS speeding up the solving process, an extra constraint can be added. This constraint imposes that the first lecture of a course comes before a second lecture of that course and the second lecture of a course comes before a third lecture of the course and so on.

Furthermore, the satisfaction problem can be transformed into a optimization problem by adding a variable. This variable can keep track of the total number of free hours in between two lectures for all teachers combined, which can be calculated using some build in functions of AIMMS concerning resources. This variable can be minimized. The minimization of this variable promotes among feasible timetables more desirable timetables. If a problem is infeasible, AIMMS does not give a timetable. If, however, one wants a timetable to be

constructed anyway, a constraint can be retracted and a penalty can be given for violating this constraint. Thus, the problem becomes an optimization problem and an infeasible problem will still present a optimal solution.

(39)

There is a problem with the implementation as presented above. AIMMS will operate as if a lecture of course A taught by teacher 1 and a lecture of course A taught by teacher 3 are not able to be held at once, because AIMMS treats these lectures as though they are both participated by students 1,2,3,5,6 and 7, although this is not the case. There is no problem if one needs a feasible solution and a feasible solution is found. Namely, the students can consider one of the lecture hours as an idle hour. However, if no feasible solution is found, it is not certain, if one does not exist. Additionally, for an optimization problem, the solution found might not be optimal.

In the next chapter, the principles of constraint programming are considered. These principles are in fact also applied by AIMMS when executing the RCPSP model.

Referenties

GERELATEERDE DOCUMENTEN

It is shown that by exploiting the space and frequency-selective nature of crosstalk channels this crosstalk cancellation scheme can achieve the majority of the performance gains

Receiver operating characteristic (ROC) curves 22 were drawn for endometrial thickness, endometrial area, endometrial color score, vascularized area, MIEIUM, MIVA,

De focus bij de hieronder beschreven maturity modellen ligt grotendeels op modellen die specifiek zijn ontwikkeld in het kader van BIM, aangezien hiermee is gewaarborgd dat de

Figure 84 shows the displacement of femur IV towards the femoral groove (femur III). The carina of the trochanter and femur is clearly visible, which will permit the tarsus and

Uit de resultaten is ten eerste gebleken dat flexibiliteit binnen een training niet zorgt voor een grotere toename in cognitief functioneren; deelnemers in de experimentele

When a disclosure is placed before or during the sponsored content it positively influences cognitive responses (Boerman, Reijersdal &amp; Neijens, 2014; Van Reijmersdal, Tutaj &amp;

Effects of Combined Power Band Resistance Training on Sprint Speed, Agility, Vertical Jump Height, and Strength in Collegiate Soccer Players..

To this purpose, the Indian Council of Forest Research and Education carries out applied research dealing with specific issues regarding forest ecosystems, including potential