0% found this document useful (0 votes)
55 views

Speeding Up The Hungarian Algorithm: Computers & Operations Research December 1990

This document discusses a modification to the Hungarian algorithm that can significantly reduce execution times. Specifically, it avoids repeatedly altering the cost matrix during computations by instead directly using the formula for the altered matrix values. Experimental tests show the modified algorithm, which does not explicitly store the altered matrix, can achieve execution time reductions of up to 90% compared to the standard implementation that explicitly updates the matrix. The modification provides a simple way to substantially speed up implementations of the Hungarian algorithm for the linear assignment problem.

Uploaded by

James Templeton
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views

Speeding Up The Hungarian Algorithm: Computers & Operations Research December 1990

This document discusses a modification to the Hungarian algorithm that can significantly reduce execution times. Specifically, it avoids repeatedly altering the cost matrix during computations by instead directly using the formula for the altered matrix values. Experimental tests show the modified algorithm, which does not explicitly store the altered matrix, can achieve execution time reductions of up to 90% compared to the standard implementation that explicitly updates the matrix. The modification provides a simple way to substantially speed up implementations of the Hungarian algorithm for the linear assignment problem.

Uploaded by

James Templeton
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/220469495

Speeding up the Hungarian algorithm

Article  in  Computers & Operations Research · December 1990


DOI: 10.1016/0305-0548(90)90031-2 · Source: DBLP

CITATIONS READS

28 1,094

1 author:

Mike Wright
Lancaster University
51 PUBLICATIONS   920 CITATIONS   

SEE PROFILE

Some of the authors of this publication are also working on these related projects:

Sports scheduling View project

Phd - Modelling the Outcomes of Professional Snooker matches View project

All content following this page was uploaded by Mike Wright on 03 May 2018.

The user has requested enhancement of the downloaded file.


Computers Opns Rrs. Vol. 17. No. I. pp. 95-96. 1990 0305-0548 90 s3 00 + 0 00
Prmted 10 Great Brttam All rights reserved Cop>rtpht t. 1990 Pcrgamon Press plc

SPEEDING UP THE HUNGARIAN ALGORITHM

M. B. WRIGHT*
Department of Operational Research and Operations Management, University of Lancaster. Lancaster LA1 4YX.
England

(Received April 1988; rerised January 19891

Scope and Purpose-This paper shows how a minor modilication to the Hungarian algorithm for the
linear assignment problem can drastically reduce execution times. This may be useful not only to academic
studies which compare the performances of different algorithms. but also for the many implementations
which use the Hungarian algorithm.

Abstract-A simple modification to the “Hungarian” algorithm for the linear assignment problem reduces
execution time by up to 90”/0.

INTRODUCTION

The linear assignment problem is a standard OR problem. Given an N by N cost matrix. N entries
must be chosen, exactly one from each row and one from each column, in such a way as to minimize
the total cost of the selection.
The algorithm most widely used for the solution of this problem is generally known as the
Hungarian algorithm [I], although other algorithms have since been devised which are claimed
to be faster [2, 3-J.
However. execution time is detcrmincd not only by the algorithm itself but also by the computer
code used. For example, Jonker and Volgenant [4] showed that minor modifications to the original
codes used for the Hungarian algorithm can cause large reductions in execution time. This paper
assesses the effect of another minor modification.
In practical terms, it may be argued that all the algorithms and computer codes used are quick
anyway, so that there is no need for further improvement. However, there are occasions where a
result is required very quickly, as in an interactive system, or where a long series of successive
assignments needs to be made [S], when it is important to use as quick a method as possible.

THE MODIFICATION

Let c[i, j] be the initial cost matrix. The standard codes for the Hungarian algorithm proceed
by making successive alterations to this matrix, by means of subtractions from or additions to
whole rows and columns. So, if u[i] is the total amount subtracted from row i, and c[j] is the
total amount subtracted from column j, the altered matrix is given by:

a[i, j] = c[i, j] - u[i] - r[j].

For most linear assignment problems, the arrays u and c are changed frequently during the
course of the algorithm, and so a[i, j] must also be frequently altered. These alterations are generally
by far the most time-consuming part of the algorithm.
The modification tested in this paper does not use an altered matrix at all. So all computer
statements that would have used a[i, j] now use (c[i. j] - u[i] - cfj]). The time spent altering
the matrix is therefore saved, but the other parts of the process take slightly longer.

EXPERIMENTAL TESTS

Two codes for the Hungarian algorithm were compared, the lirst (“OLD”) without the above
modification, and the second (“NEW”) with it. Both codes were otherwise fairly eflicient,

‘M. B. Wright is a Lecturer in operational research at the University of Lancaster, England. Before that he was with
the operational research group at the Headquarters of British Rail. His main research interests are the practical uses
of heuristics and the application of OR to transport. health services and sport.
cm 17:1-G
95
96 M. 8. WRIGHT

Tdblr I Computer r~r~utmn times txcl for “OLD” and “NEW”

OLD NEW NEW OLD

r n Mean SD Mean SD Mean SD

loo 50 1.88 0.31 0.82 0.16 043 0.04


100 100 8.52 0.87 3.53 0.53 0.41 0.04
100 150 18.49 2.61 7.88 1.05 0.43 0.04
100 200 30.78 3.96 14.77 I.85 0.48 0.05
100 250 46.02 4.51 27.96 4.78 0.61 0.08
IOIl 300 63.37 7.51 47.42 4.75 0.76 0.09
Ian0 50 3.18 0.85 I.00 0.23 0.32 0.03
1.000 100 21.03 3.41 4.66 0.84 0.22 0.02
l.ooo I50 59.09 8.47 II.15 2.0X 0.19 0.02
l.OOG ml I27 32 15.4.i ,? 1')
__.__ 3.01 0.18 0.02
l.CQO 250 215.02 21.24 34.58 4.93 0.16 0.01
1.000 300 32963 25.43 51.68 6.65 0.16 0.02
10.000 50 4.25 0.83 1.23 0.23 0.29 0.02
lO.OOfI loo 3190 5.03 5.78 0.85 O.IR 0.01
lO.OOG 150 IO5 76 I596 14.36 2.17 0.14 001
IO.OMl 200 235 27 28.73 26.99 3.88 0.11 0.01
10.000 250 432.56 46.42 44.43 5.93 0.10 0.01
IO.MXI 300 742.03 50.x1 67.44 5.51 0.09 0.01

incorporating pointers and the first two of the improvements described by Jonker and Volkenant [4].
Six values of n, the number of rows in the cost matrix, and three values of r, the range of values
in the matrix, were used, giving I8 combinations. For each combination 20 runs of OLD and
NEW were made.
For each of the 360 runs, a cost matrix was created by choosing a random integer between 0
and r for each matrix element c[i, j]. OLD and NEW were then run successively on this matrix
and the execution times were recorded. The computer used was an Amstrad PC1512, and the
language used was Pascal, using Borland’s TURBO system, version 4. The results are summarized
in Table I.

COMMENTS

These results show that NEW is substantially quicker than OLD, especially for large values of
n and r, where the improvement is as high as 90%. Regression analysis shows that the execution
time for NEW is O(n2~22ro~“), compared with O(n2.48r0.38) for OLD. In addition, when each value
of r is considered separately, the power of n for NEW is almost constant (between 2.20 and 2.23),
whereas for OLD it ranges from 1.95 (for r = 100, when virtually no matrix alteration is ever
necessary) to 2.88 (for r = 10,000).
So NEW is not only quicker than OLD, it is also less sensitive to variation in the size of the
matrix and the range of costs within it.

REFERENCES

I. H. W. Kuhn, The Hungarian method for the assignment problem. Naval Rcs. Loyisr. Q. 2, 83-97 (1955).
2. M. S. Hung and W. 0. Rom, Solving the assignment problem by relaxation. Opns Res. 28, 969-982 (1980).
3. R. Jonker and A. Volgenant. A shortest augmenting path algorithm (or dense and sparse-linear assignment problems.
Compuring 38.325340 (1987).
4. R. Jonker and A. Volgenant. Improving the Hungarian assignment algorithm. Opl Res. Lett. 5. 171-175 (1986).
5. M. B. Wright. Applying stochasticalgorithms to a locomotivescheduling problem. J. Opl Res. Soc.40.187-192 (1989).

View publication stats

You might also like