We have implemented a fairly complex rule-based expert system for solving the timetabling problem, for three reasons. Firstly, it gives us a benchmark as to how well simulated annealing does in comparison to this standard technique. Secondly, a modified version of this system us used to provide sensible choices for moves in the annealing algorithm, rather than choosing the moves at random. Thirdly, we have used this system as a preprocessor to provide a good starting point for the simulated annealing algorithm.
The rule-based expert system consists of a number of rules (or heuristics) and conventional recursion to assist in carrying out class assignments. We have developed this system specifically for the problem of academic scheduling. The basic data structures or components of the system are:
The basic function of the system is as follows: given data files of classes, rooms and buildings, department-to-building distance matrix, student data, and the inclusion data, using the abovementioned data structures, the system builds an internal database which in turn is used in carrying out the scheduling process. This process involves a number of essential sub-processes such as checking the distance given in the distance matrix, checking building, room type and hours occupied, checking and comparing time slots for any conflicts, checking rooms for any space conflict, and keeping track of and updating the hours already scheduled.
The rule-based system uses an iterative approach. The basic procedure for each iteration is as follows. The scheduling of classes is done by department, so each iteration consists of a loop over all departments. The departments are chosen in order of size, with those having the most classes being scheduled first. The system first loops over all the currently unscheduled classes, and attempts to assign them to the first unoccupied room and timeslot that satisfies all the rules governing the constraints. The classes are chosen in a specific order. We chose to separate the updates into independent sets based on room type, so for example, laboratories are scheduled separately from lectures. We carry out the scheduling of lectures first, followed by scheduling of laboratories, making sure that during the course of this process no lecture and its associated laboratory are scheduled in the same time period. Also, since constraints involving capacity of rooms are very difficult to satisy, larger classes are scheduled first, to try to avoid not having large enough rooms later for those class sections with large enrollments.
In some cases the only rooms and timeslots that satisfy all the rules will already by occupied by previously scheduled classes. In that case, the system attempts to move one of these classes into a free room and timeslot, to allow the unscheduled class to be scheduled.
Next, the system searches through all the scheduled classes, and selects those that have a high cost, by checking the medium and soft constraints such as how closely the room size matches the class size, how many students have time conflicts, whether the class is in a preferred time period or a preferred building, and so on. Selecting threshold values for defining what is considered a ``high'' cost in each case is a subjective procedure, but it is straightforward to choose reasonable values. When a poorly scheduled class is identified, the system searches for a class to swap it with, so that the hard constraints are still satisfied, but the overall cost of the medium and soft constraints is reduced.
Our strategy is to first try to swap a class with another class in the same department. If this cannot be achieved within the rules, we attempt to swap classes within different departments in the same school, and finally we try swaps between classes in different schools. We refer to the first two types of swaps as local, while the third is considered global. Local swaps have the advantage that classes in the same departments or schools are associated with the same subset of rooms that will usually satisfy constraints involving distance and department preference, however global swaps are less likely to have students and professors in common, which may help alleviate time conflicts. A department may specify that they do not want any classes scheduled outside their home buildings, so global swaps will not be used on their classes.
This process of swapping rooms continues provided all the rules are satisfied and no ``cycling'' (swapping of the same classes) occurs. Once all the departments have been considered, this completes one iteration. The system continues to follow this iterative procedure until a complete iteration produces no changes to the schedule.
The rule-based system is usually unable to legally assign all of the classes, and thus produces a partial schedule as an output, which is divided into two parts: a list of scheduled classes and their assigned rooms and timeslots; and a list of classes that could not be assigned due to constraint conflicts. This is what is used as input for the simulated annealing program.