You are on page 1of 10

Course Scheduling As A Constraint

Satisfaction Problem
Juan Jose Blanco and Lina Khatib
Florida Institute of Technology
Melbourne, FL 32901
email:fjblanco,linag@cs. t.edu

Abstract
This paper describes a scheduling system to ful ll the timetabling needs of the Computer
Science program at Florida Institute of Technology. The system handles both general
constraints of timetabling problems and constraints speci c to our problem. It has
the exibility of allowing for either manual or automatic assignments. The scheduling
process is split into two phases; each phase is modeled as a CSP. The rst phase tackles
resource allocation which is, in our case, the problem of assigning faculty to courses.
The second phase tackles the problem of assigning consistent time slots to courses.
Optimization techniques are used in both phases. The rst phase optimizes faculty
assignment to courses in terms of faculty preferences. The second phase optimizes time
slot assignment in terms of di erences with previous term. The main goal of the system
is to provide high quality timetables to the Computer Science program with as little
delay as possible. This goal was ful lled as experiments on real data showed that ideal
solutions are generally obtained in a few seconds.

1 Introduction
The construction of course timetables for universities or other schools can be an extremely complex
problem whose diculty grows exponentially with its size. A manual solution typically requires
much e ort (from hours to days depending on the dimension of the timetable and the number of
restrictions in the domain). It is a process that involves numerous reformulations of the problem's
settings in order to nd a \compromise" solution. The work described in this paper aims to auto-
mate the timetabling needs of the Computer Science program at Florida Institute of Technology.
The problem instance constitutes one in which both general and speci c constraints need to be
handled eciently with as much exibility as possible. The many features that are, typically, left
out by other timetabling systems, in order to decrease complexity, are managed successfully in this
system. Some of these features are:
 Faculty preferences for courses, as well as times, are taken into consideration.
 Sophisticated types of preferences are supported such as a preference to have temporal gaps
between courses.
 Courses can be constrained to not be scheduled at the same time.
 Choices between manual pre-setting or automatic assignments are provided. These assign-
ments include
{ assigning a faculty to a certain course.
{ assigning a time slot to a certain course.
 General and domain-speci c heuristics are applied to speed up the process and provide higher
quality solutions.
The scheduling is split into two phases; each phase is modeled as a CSP. The rst CSP tackles
resource allocation which consists of assigning faculty to courses. The second CSP tackles the
problem of assigning consistent time slots to courses. This allows for a complex problem to be
decomposed into two simpler ones. Optimization techniques are used in both phases. The rst
phase optimizes faculty assignment to courses in terms of faculty preferences. The second phase
optimizes time slot assignment in terms of discrepancies over the previous term. The rst phase
optimization criteria are general but the second phase optimization criteria are problem speci c
and related to the university's procedure for classroom assignment.
The main goal of the project is to provide high quality timetables to the Computer Science
program with as little delay as possible. This goal was ful lled as experiments on real data showed
that ideal solutions are generally obtained in a few seconds. More speci cally, averaged over several
trial cases, with the number of faculty between 10 and 12, and the number of courses between 40
and 50, the rst phase took less than a second and the second phase took 10 to 15 seconds.
The rest of this paper is organized as follows. Section 2 de nes the timetabling problem as CSP.
Section 3 is a detailed description of our course scheduling system. Section 4 closes this paper with
a conclusion and discussion of future work.

2 Background
A Constraint Satisfaction Problem (CSP) is composed of a nite set of variables, each of which is
associated with a nite domain, and a set of constraints that restrict the values that the variables can
simultaneously take. The task is to assign a value to each variable in the problem satisfying all the
constraints. Variation of algorithms have been devised to deal eciently with CSPs encompassing
a broad eld of solving methods. For more details the reader is referred to [4], [5], [6], [8], and [9].
One instance of timetabling problem is the problem of scheduling courses in an educational
institution. In general, one must assign instructors to courses, and then assign courses to classrooms
and time slots. The objective is to obtain a timetable of courses-professors-classrooms-times over
a pre xed period (typically a week), satisfying a set of constraints of various types. The manual
solution of the timetabling problem usually requires several days of work. In addition, the solution
obtained may be unsatisfactory due to limited human oversight. For example, students may not
be allowed to take the courses they want (or need) because they are scheduled at the same time.
For this reason, considerable attention has been devoted to automated timetabling and, over the
last thirty years, many papers related to automated timetabling have appeared in conferences and
journals [7].
Most of the early techniques for solving the timetabling problem were based on simulation of the
human way of solving the problem. All such techniques were based on a successive augmentation,
that is, a partial timetable is extended, course by course, until all the courses have been scheduled.
They are simple search procedures based on backtracking and in heuristics such as scheduling the
most constrained course rst. Later on, researchers started applying general techniques (mainly
borrowed from Operations Research) to this problem, which has led to timetabling algorithms based
on mathematical approaches such as integer programming or network ow, as well as reduction to
graph coloring. More recently, approaches based on search techniques used in Arti cial Intelligence
appeared in the literature. These include simulated annealing, tabu search, genetic algorithms, and
in general constraint-guided search algorithms [7]. The timetabling process consists of two distinct
phases [3]
 The curriculum, i.e. a list of courses o ered for a speci c term, is de ned and various resources
(typically professors and classrooms) are assigned to them.
 A detailed timetable is composed which is compatible with the previously de ned requirements
and with additional constraints as well.
The complexity of the second phase has led to e orts in solving it automatically instead of manually.
On the other hand, not much attention has been paid to automating the rst phase even though, for
many institutions, obtaining coherent or \fair" resource assignments may be a demanding challenge.
The timetabling problem is formulated either as a feasibility problem, where a single feasible
solution is required, or as an optimality problem, where the optimum solution according to an
objective function is sought. Timetabling problems are easily mapped into CSPs. The general
task in timetabling is to assign resources (professors, and sometimes also classrooms) to all courses
o ered in a given term, and then to assign times to those courses. In our scheduling system, both
phases of the timetabling problem were tackled, and both were modeled as a CSP in order to apply
systematic CSOP (Constraint Satisfaction Optimization Problems) techniques to solve them.

3 Course Scheduling System


In this section we give a detailed description of the system we built for Computer Science course
scheduling at Florida Tech. We describe the problem, explain the model and processes, justify our
choices of solving techniques, and present heuristics used for improving the eciency of the system
with experimental results. More details on this system can be found in [2].
3.1 The Problem
The main problem is to automate the process of scheduling courses, for a given school term, for
the computer science program at Florida Tech. In addition to the general constraints imposed on
course scheduling, there are constraints speci c to this institution. We would like to satisfy faculty
preferences in terms of what courses to teach within speci ed time periods. Also, we would like to
be able to specify what courses should not be scheduled at the same time. The exibility of mixing
manual assignments with automatic assignments is needed. Allowing for multiple listings of some
courses is also needed. The di erence between schedules of comparable terms (e.g. between Spring
semester 1996 and 1997) should be minimized, due to the need for continuity.
3.2 Modeling
The scheduler is split into two phases; each phase is modeled as a CSP. Figure 1 shows a graphical
representation of the model. The input to the system are les that specify
1. A set of Faculty where each element includes
 name of the faculty member
Vars: Courses
Domain: Time Slots
Constraints:
Faculty Time Preferences
Course Constraints & Correlations
Con ict Constraints
Vars: Faculty ?
Domain: Courses - CSP
Constraints: CSP @@ Solver -
Faculty Workload
Solver R . .
>
Faculty Courses  Course Time
. .
Faculty Course Preferences .. .. .. ..

Figure 1: The Model of the Scheduler

work load for the term at hand (number of courses)


 course preferences (list of courses associated with a numerical penalty value)
 time preferences (list of time slots during which the faculty would like to teach)
 an indication if the faculty member needs a break between classes (which we refer to as
temporal gaps between assignments for the same professor)
2. A set of o ered courses where each element includes the
 course code
 course name
 optional elds1
{ faculty that has been designated to teach the course
{ time slot when the course will be taught
3. A schedule of the previous corresponding term where each element includes a
 course code and
 time at which the course was scheduled
4. A set of correlated courses where each element consists of a set of courses that, because of
their logical correlation, cannot be taught at the same time.
5. A set of implicit constraints that restricts the time slots of courses. More speci cally, these
constraints are the following:
 courses taught by the same professor should not overlap in time.
 undergraduate courses can be scheduled at any valid time slot, but graduate courses, as
well as undergraduate courses that meet with graduate courses, can only be scheduled
at certain times in the late afternoon and evening.
1
This allows for the exibility of forcing a course to be taught by a speci c faculty or at a speci c time
The output of the system is an optimal valid timetable of courses, faculty assignments, and time
slots. A detailed description of each of the phases follows.
3.2.1 Phase 1: faculty-course assignment
The rst CSP tackles the problem of assigning faculty to courses. This problem is, in general,
tackled manually in timetabling systems [7]. Based on feedback from previous \manual" solutions
to this problem at the Computer Science program of Florida Tech, it was decided that the faculty-
course assignment problem is important enough to include in our timetabling system. The variables
of the problem are faculty members that are teaching during the given term. The domain for each
variable (faculty member) is the set of courses being o ered during the current school term for
which the professor has given a preference value. The constraints on the assignment of courses to
professors are:
 a course is assigned to only one professor.
 each professor should be assigned the number of courses speci ed in the work load of the
given term.
The objective of this phase is to nd an optimal assignment of courses to faculty members. Such an
assignment has to satisfy all the constraints and be minimal in terms of total penalties. Penalties
are speci ed for pairs of faculty and courses; the lower (higher) the penalty is the more (less) willing,
or quali ed, the faculty is to teach the corresponding course. The scheduler reads from the faculty
le their preferences of courses they would like to teach for the term at hand. The preferences are
expressed in a table form, with each record consisting of a penalty value and a list of courses. A
professor lists only the courses that are within his/her ability to teach, assigning lower penalties to
those that are most preferred and higher penalties to those that are least preferred. To preserve
the fairness of the algorithm, the range of penalty values must be the same for all faculty members.
The search procedure looks for a global assignment of courses to faculty that minimizes the
total penalty. The system uses a branch and bound algorithm [9] to reduce the search space and
nd the optimal solution in a reasonable amount of time (The reader is referred to [1] for further
details on the advantages of branch and bound algorithms in CSOPs). The variables of the problem
are the faculty members, and each of them has to be assigned a number of courses speci ed in their
work load. The work load can be di erent for di erent professors. The procedure is initially called
to start with the rst faculty member in the list. At each step of the procedure, M courses for
the current professor are considered. Their penalty is added to the accumulated penalty, and at
this point the search continues or is bounded; if the penalty accumulated so far is larger than the
minimal total penalty obtained in a previous solution, then that branch of the search space can be
pruned because it will not contain any assignment of courses to faculty with a better total penalty.
Note also that the algorithm avoids duplicating course assignments for a given professor; in other
words, symmetrical (although identical) assignments are only considered once.
Once an optimal solution is found, the system will halt waiting for approval from the user. If
the user approves, the system moves to the second phase. If the user does not approve, then a
modi cation to the input should be made. Then phase 1 will be repeated and a new solution found.
This phase 1 cycle is repeated until the user approves the solution. We nd this to be useful in
practice. For example, if a user nds that the scheduler assigned two dicult courses to one faculty,
the user may want to decrease the workload of this faculty or force one easy course to be xed to
this faculty.
Using branch and bound as the optimization technique reduces the computing time needed to
obtain the best solution. For the number of professors teaching in the Computer Science program at
Florida Tech (around 10 to 12), and the number of courses o ered on average in a typical semester
(40-50), the solution to the faculty-course assignment problem is reached in less than one second.
3.2.2 Phase 2: time-course assignment
This phase tackles the problem of assigning consistent time slots to courses. This implies assigning
a time slot to each course so that all faculty time preferences, course correlation restrictions, and
general constraints are satis ed. In our system, time slots can be considered as grouped lectures: all
weekly meetings of one class are considered as one slot, and all the di erent groupings of lectures
allowed by the university are included in the scheduler. For example, 3 credit courses can be
split into 3 lectures of one hour each, or 2 of one and a half; hence, groupings such as Monday-
Wednesday-Friday from 10:00 to 11:00, or Tuesday-Thursday from 10:00 to 11:30, are time slots in
our system.
As noted earlier, the optimization criteria is the discrepancy over previous comparable term.
This means that the optimal schedule is one that is as close as possible to the previous corresponding
term schedule. This optimization criteria is problem speci c and is related to the university's
procedure for classroom assignment. Each semester, the Registrar's oce takes as the initial
classroom assignment the previous corresponding semester schedule. For all the courses that the
department schedules at exactly the same time as the reference semester, the classroom used then
will automatically be used now. Only changes to the old schedule have to be dealt with: new
courses or a course that is scheduled at a di erent time requires a search for an available classroom
in a campus-wide database. If no classroom is available for any of those courses, the timetable
is returned to the department to modify it. Therefore, our system returns the timetable where
the minimum number of changes from the old schedule occur, thus minimizing the possibility of
running into a classroom con ict.
The variables in this second CSP are the courses, whose domains are all possible time slots.
The constraints are the following:
 Courses taught by the same professor should not overlap in time

 Undergraduate courses can be scheduled at any valid time slot, but graduate courses, as well
as undergraduate courses that meet with graduate courses, can only be scheduled in the late
afternoon and evening.
 Faculty preferences have to be satis ed. This includes the time range they specify for their
courses and the possible need for breaks between classes.
 Courses that are correlated cannot be scheduled at the same time. This includes courses that
are usually taken by the same students (e.g. senior required courses).
The goal of this phase is to obtain a valid schedule, i.e. an assignment of time slots to courses that
satis es all the constraints. The number of valid timetables, in the absence of inconsistencies, is
very large. Hence, the result is improved by introducing a goodness function. The idea is that a
given schedule is better than another if it is closer to the previous corresponding term schedule.
Therefore, CSOP techniques are again used to optimize the timetable in relation to an objective
function.
Once the solution to the rst phase is accepted, the system compiles all the courses that are
not TBA (To Be Assigned, i.e. courses for which a professor has not been assigned, due to the lack
of faculty and/or insucient work loads) and begins the process of assigning times to them. The
rst step in the procedure is time preferences consistency checking, a preprocessing of faculty time
preferences to make sure there is no initial inconsistency. Each faculty speci es their preferred time
slots as well as their wishes in having temporal gaps (breaks) between classes. Sometimes, there
are inconsistencies in the speci cation, such as specifying only 3 time slots as preferences with gaps
between classes while the work load is 3 courses.
 Stage 1: Consistency checking
At this stage, the system determines if the speci ed time slots for each professor allow for
sucient slot expansion, where these are de ned as follows.
De nition 1 A slot expansion for a set of time slots is the maximum number of courses
that can be scheduled in these time slots taking into consideration overlaps of time slots, gaps
between classes, and constraints on time range of courses.
De nition 2 Sucient slot expansion. A set of time slots S has a sucient slot expansion
for a faculty F if the work load of F is no more than the slot expansion of S taking into
consideration F 's preference for gaps between classes and the constraints on courses assigned
to F .
In other words, this stage detects if nding times for a speci c professor's courses is impossible
with the current preferences of the faculty member. For a professor's preferences to pass this
consistency phase, the time preferences have to satisfy the inequality
slot expansion  course load
In case a faculty member does not satisfy this condition, the system noti es the user that the
faculty's time preferences need to be relaxed. Otherwise, the second stage starts.
 Stage 2: assigning time to courses
At this stage, each course is assigned a time slot that satis es faculty time preferences, course
correlation restrictions, and general constraints. Also, the assignment should be as close as
possible to the previous corresponding term schedule.
De nition 3 A slot usage is the number of courses scheduled at each time slot.
Slot overuse occurs when more courses are assigned than was assigned for the same slot in
the previous term.
The system reads the reference (history) le and obtains a table of slot usage for the reference
term. A systematic constraint satisfaction method is applied to search through the space of
schedules, coupled with branch and bound to optimize the solution in terms of the number
of changes from the reference timetable. The variables of the problem are the courses. Each
course has to be assigned a time slot which has to be consistent with previously assigned ones
and with all the constraints. The procedure is initially called to start with the rst course in
the list. At each step of the procedure, a time slot is considered for the given course. The
overuse, if any, that would occur if the course is assigned the current slot is added to the
accumulated overuse, and at this point the search continues or is bounded. If the overuse
accumulated is larger than the minimal total overuse obtained in a previous solution, then
that branch of the search space can be pruned. The optimal solution obtained is one with a
minimum slot overuse.
Undergraduate courses rst Graduate courses rst
Day time slots rst 15 minutes 10 seconds
Evening time slots rst 16 minutes 15 seconds

Table 1: Course and Time-slot Ordering Results

Using branch and bound as the optimization technique once again reduces greatly the comput-
ing time needed to obtain the optimal solution. On the average, the rst solution is displayed
in less than one second while the optimal solution is displayed after about 10 seconds. This
is the average of several runs on real data with 10-12 faculty and 40-50 courses with various
constraints. Also, we applied some heuristics related to variable and value ordering that are
explained in the \Heuristic" section below. We choose to display the rst solution to insure
the user that a solution exists while waiting for the optimal solution.
3.3 Heuristics
Initially, the system processed courses in the order in which they appeared in the input le. This
order is based on the course number where undergraduate courses has lower numbers than graduate
courses. However, since graduate courses have a smaller range of time slots at which they can be
scheduled, tests were performed where the system orders the list of courses to place graduate ones
at the top of the list, hence applying the variable ordering heuristic of most-constrained- rst. It
was found that by scheduling the most constrained courses rst, the search space is pruned much
quicker since most inconsistencies arise during the rst nodes of the search tree, which results in
huge performance gains (see Table 1).
Value ordering was also tested in a similar way. Evening time slots, in our domain, have
more demands than day time slots. This is because graduate courses, which equals in number to
undergraduate courses, are restricted to evening slots which are less than day slots. Experiments
were conducted by considering the most con ict-prone values rst, but the response of the system
was actually very similar in both cases of value ordering. Results of tests executed with 10 faculty
40 courses, and 32 time slots (among which 9 are evening slots), are shown in Table 1.
A di erent approach to value ordering was also tested for the purpose of enhancing the output.
Several instances of the problem's solution space could be scored the same by our optimization
function, and the search algorithm would output the rst of those encountered (which serves as
a limit for bounding the search). Hence, we enforced an ordering on the time slots such that the
most preferred one is chosen rst. This will guarantee that the output from the set of optimal
solutions is the one with the most preferred slots (usually, most faculty prefer slots that are around
the middle of the day or early evening).

4 Conclusions
The system presented in this paper exhibits several di erences with timetabling programs from the
literature. In our system, time slots can be considered as a collection of meetings for a course over
a week, where each of those individual meetings is often referred to in the literature as a lecture [7].
By grouping weekly lectures of courses into time slots, the system not only resolves the so called
multiple sections problem, but we have also reduced the size of the domain while including the
common constraint that all lectures of a given course should be taught at the same time and evenly
distributed during the week.
While many other timetabling programs leave out some features to decrease complexity, our
system is able to manage many objectives successfully. Non-standard characteristics of timetabling
systems that are all considered in our course scheduling program are:
 Division of the problem into two easier to tackle, relatively independent, phases.

 Tackling of the faculty-course assignment problem.

 Presence of constraints associated with correlated courses (referred to as the grouping sub-
problem in the literature).
 The exibility of xing a course to a speci c faculty or a speci c time slot.

 Management of simultaneous lectures (linked courses which are taught together).

 Existence of overlapping time slots.

 Accommodating faculty preferences in terms of courses to teach and time slots.

 A domain-dependent ecient treatment of the classroom assignment problem.

 Optimization of the solutions.

Future work includes investigating more elaborate techniques that will allow the system to scale
to larger domains. This includes employing advanced systematic search algorithms [6] coupled with
branch and bound, and constraint relaxation techniques (currently, all the constraints are hard,
so overconstrained problems must be handled by manually relaxing constraints). A web-based
interface to the database is under development. When completed, faculty will have access to their
own records to be able to update them remotely with ease. Other possible enhancements to the
system include providing helpful explanations of inconsistencies, adding schemes to insure proper
rotation of faculty to courses, and exible adjustments to faculty preferences.

References
[1] Stephen Beale, 1997. Using branch-and-bound with constraint satisfaction in optimization
problems. In Proceedings of AAAI-97, pp. 209-214
[2] J. J. Blanco, 1997. Constraint-Based Course Scheduling. M.S. Thesis, Computer Science,
Florida Institute of Technology.
[3] D. de Werra, 1985. An introduction to timetabling. European Journal of Operational Research,
vol. 19, pp. 151-162.
[4] S. Minton, M. Johnston, A. Philips, and P. Laird, 1992. Minimizing con icts: a heuristic repair
method for constraint satisfaction and scheduling problems. Arti cial Intelligence, vol. 58, pp.
161-206.
[5] B. Nadel, 1988. Tree search and arc consistency in constraint satisfaction algorithms. Chapter
9 in Search in Arti cial Intelligence, edited by L. Kanal and V. Kumar, Springer.
[6] P. Prosser, 1993. Hybrid algorithms for the constraint satisfaction problem. Computational
Intelligence, vol. 9, no. 3, pp. 268-299.
[7] A. Schaerf, 1995. A survey of automated timetabling. Technical report CS-R9567, CWI, Am-
sterdam, The Netherlands. Available at http://www.cwi.nl/ftp/CWIreports/AP.
[8] A. Schaerf, 1996. Tabu search techniques for large high-school timetabling problems. In Pro-
ceedings of AAAI-96, pp. 363-368.
[9] E. Tsang, 1993. Foundations of constraint satisfaction. Ed. Academic Press, New York.
[10] Mark Wallace, 1996. Practical applications of constraint programming. In Constraints, an
international journal, 1, 139-168.

You might also like