Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
LYNN, Editor
Matrix Reduction Using the elements of A, i.e. r nonzero elements such t h a t no two
occur in the same row or colmnn. An n-partial solution
Hungarian Method For The defines a solution or possible schedule for the class, teacher
or hour which owns the array A. An examination of A
Generation of School Timetables has two stages:
Stage 1. T h e existence of at least one possible sched-
JOHN LIONS ule is determined (Feasibility Test);
J. Kates & Associates, Toronto, Ontario, Canada Stage 2. Any nonzero element which does not be-
long to some possible schedule is changed to zero
(Matrix Reduction).
The application of Kuhn's Hungarian Method to the problem
The problem of Stage 1 is already well known as part of
of matrix reduction as needed in Gotlieb's method for time-
the Assignment problem (for which a bibliography is
table generation is described. The method is suited to both
given in [2]). This paper is based on the " H u n g a r i a n
hand and computer calculation. Devices to improve the effi-
M e t h o d " for the Assignment problem first given b y H. W.
ciency of the basic algorithm are discussed.
K u h n [3], and also described by Friedman and Yaspan [4].
1. I n t r o d u c t i o n I n the context of the timetable problem, Stage 2 is the
important problem, consuming a very high percentage of
The scheme proposed by C.. C. Gotlieb [1] for the solu-
the computation effort, and the need for an efficient al-
tion of the high school timetable problem envisages the
gorithm for its execution paramount. For Stage 2, Gotlieb
construction of a 3-dimensional array, each point of which
proposed the method of the "tight set search," whose
represents the meeting of a particular class with a particu-
theoretical basis is a theorem by P. Hall [5] on the exist-
lar teacher at a particular hour of the day. The array
ence of sets of distinct representatives. The tight set
elements m a y be divided into two groups, according as
search is quite efficient when n is small (say n K 10), but
their values are zero or nonzero. (For convenience the
since it requires of the order of 2 = operations it rapidly be-
nonzero values are usually m a p p e d into the single value
comes impractical once n exceeds about 20. Yet m a n y
unity.) An element value of zero signifies the impossibility
schools have over 50 classes, and schools with more than
of the class and teacher meeting at the hour. An element
100 classes are not unknown.
whose value is nonzero signifies the possibility t h a t the
class and teacher m a y meet at the hour. Initially the 3-di- 2. T h e H u n g a r i a n M e t h o d
lnensional array is filled with ones, indicating the possi-
bility t h a t any teacher can meet any class at any hour, but The Hungarian Method for the Feasibility Test in-
as the calculation proceeds ones are changed to zeros volves the iterative application of a procedure called here
according to set rules and predetermined conditions so "EXPAND," whose function is as follows:
t h a t by the end of the computation, at each hour it is Suppose an r-partial solution for the (n X n) array A
possible for each teacher to meet only one class and for is given where r < n, and suppose, in particular, t h a t there
each class to meet only one teacher, and each teacher can is no element of the partial solution in the ith row of A.
meet each class a number of times predetermined for t h a t Then E X P A N D can be used to txT to generate a new,
teacher and t h a t class. The timetable is then inherent in (r--t-1)-partial solution b y choosing an element from the
the resulting 3-dimensional array. ith row and rearranging part or all of the original r-partial
At regular intervals during the computation, Gotlieb's solution. The (rq-1)-partiM solution will involve all the
method requires the examination of each plane section of rows and colulnns involved in the r-partial solution to-
the 3-dimensional array. A plane section belongs to some gether with the ith row and some new colunm. If
class or teacher or hour, and is a 2-dimensional array of E X P A N D fails to generate an (rq-1)-partial solution,
zeros and ones. Moreover it m a y be shown t h a t each array then it can be shown t h a t it will never be possible to find a
is effectively square, in that any seeming excess of rows or solution for the array A. (It m a y be possible to find an
colunms can always be eliminated. (rq-1)-partial solution by choosing another row instead
Suppose A is an (n × n) array of ones and zeros. An of the ith row for E X P A N D , but this possibility is not of
r-partial solution of A is a set of r independent nonzero interest in the present problem.)
the matrix. The latter is because the matrix must be FIG. 7 FIG. 8
searched b y column as well as by row. If the array is
stored as lists of nonzero elements per row, then unless
the array is symmetric it will be necessary for efficient I l 0 1 1
0 1 1 0 0
1 0 1 0 I ~Q~ 0
For the timetable problem E X P A N D is the most highly
0 0 0 0 0 0 ,~
nested p a r t of the program; so as well as being coded
1 2 3 4 5 6
efficiently it should also be used efficiently. If after each
examination of an array a solution is stored, then at the FIG. 9
time of the next examination a substantial p a r t if not all
of the solution can be restored to form a partial solution
for Stage 1; after t h a t an application of E X P A N D is
needed for each row which lacks a solution element. How- i=i
ever it is in Stage 2 where the greatest improvement can
be made.
?
i ) ~ ,=--i
If an application of E X P A N D is made to test the feasi- I
.----.a
bility of an element and it succeeds, then subsequently the
J_ _
6 L- b--
solution m a y be rearranged, introducing several new ele-
ments and elinfinating several of the old. The feasibility
I
-/--1 1 I l I I---
of each of the new elements is demonstrated as surely as 1 2 3 4 5 6 7 1 2 3 4 5 6 77
t h a t of the element raider test. If these elements are FiG. lOa FIG. 10b
tagged as being feasible and not tested again, then this
alone will on the average reduce the n u m b e r of calls on
E X P A N D b y about half. However, as is demonstrated Suppose it is desired to test the feasibility of the ele-
now, it is possible to do even better than this. m e n t A [1, 2]. Since it is not already in the solution one
Figure 7 shows an array for which a solution is defined can a t t e m p t to force it into the solution by turning all the
by the elements of the main diagonM. other nonzero elements in row 1 to zero temporarily. This