Académique Documents
Professionnel Documents
Culture Documents
Chapter 2
Transportation and Assignment
Problems
Professor of Mathematics
Jadavpur University
West Bengal, India
E-mail : bcgiri.jumath@gmail.com
MODULE-3: Assignment Problem and Its
Solution by Hungarian Method, and
Travelling Salesman Problem
The assignment problem is a special type of transportation problem where the objec-
tive is to minimize the cost of allocating a number of jobs to a number of persons or fa-
cilities so that one person or facility is assigned to only one job. The assignment model
is useful in solving problems such as assignment of machines to jobs, assignment of
salesmen to sales territories, travelling salesman problem, etc. It may be noted that
with n facilities and n jobs, there are n! possible assignments. One way of finding an
optimal assignment is to consider all the n! possible arrangements, evaluate their total
costs, and select the assignment with minimum cost. However, due to heavy compu-
tational burden, this method is not suitable. For solving assignment problem, we will
discuss an efficient method which was developed by a Hungarian Mathematician D.
Konig.
2
Machines Jobs Availability
J1 J2 ··· Jn
M1 c11 c12 ··· c1n 1
M2 c21 c22 ··· c2n 1
.. .. .. .. .. ..
. . . . . .
Mn cn1 cn2 ··· cnn 1
Requirement 1 1 ··· 1
associated with assigning the ith machine to the jth job. To formulate the assignment
problem in mathematical programming terms, we define the activity variables xij =
1, if machine i is assigned to job j
0, otherwise
Then the mathematical model for the assignment problem can be stated as
∑
n ∑
n
Minimize Z = cij xij
i=1 j=1
∑
n
subject to xij = 1 for all i (availability)
j=1
∑n
xij = 1 for all j (requirement)
i=1
This shows that the minimization of the new objective function Z ∗ yields the same
∑ ∑
solution as the minimization of the origin objective function Z, because ui and vj
are independent of xij .
′
cij = cij for all i, j = 1, 2, · · · , n; j , k
′
cik = cik − α, where α = a constant.
Theorem 2.2: If an assignment problem with cost (cij > 0) is such that minimum
∑n ∑n
i=1 j=1 cij xij = 0 then (xij ) provides an optimal assignment.
The Hungarian method is an efficient method for finding the optimal solution of an
assignment problem. The method works on the principle of reducing the given cost
matrix to a matrix of opportunity costs. Opportunity costs show the relative penalties
associated with assigning a machine to a job. Hungarian method reduces the cost
matrix to the extent of having at least one zero in each row and column so as to make
optimal assignment. In the following, an algorithm for finding the optimal solution
of an assignment problem is given.
Step 1 Identify the minimum element in each row and subtract it from each element
of that row.
Step 2 Identify the minimum element in each column and subtract it from each ele-
ment of that column.
Step 3 Draw the least possible number of horizontal and vertical lines to cover all the
zeros. If the number of lines equals the order of the cost matrix then go to step
5; otherwise, go to step 4.
Step 4 Identify the smallest element among the uncovered elements left after draw-
ing the horizontal and vertical lines in step 3. Subtract this element from all
the uncovered elements and add the same element to the elements lying at the
intersections of the horizontal and vertical lines. Then go to step 3.
Step 5 For each row or column with a single zero, box that zero as an assigned cell. For
every zero that becomes assigned, cross out all other zeros in the same column
or row. If for a row or a column, there are two or more zeros then choose one
cell arbitrarily for assignment. The process is to be continued until every zero
is either assigned with box or crossed out. Cells having a box indicate optimal
assignment. In case a zero cell is chosen arbitrarily then there may be alternate
optimal solution.
Example 2.1: A Company has four men available for work on four separate jobs. Only
one man can work on any one job. The cost of assigning each man to each job is given
in Table 2.2. Assign men to jobs in such a way that the total cost of assignment is
minimum.
Job
I II III IV
A 20 25 22 28
B 15 18 23 17
Person
C 19 17 21 24
D 25 23 24 24
Solution: We will use the Hungarian algorithm to solve this problem. Following steps
1 and 2, the cost matrix reduces to the form as shown in Table 2.3.
Now, we draw minimum number of horizontal and vertical lines to cover all the zeros.
The least number of lines is 3 (see Table 2.4 ) which less than 4, the order of the matrix.
I II III IV
A 0 5 1 7
B 0 3 7 1
C 2 0 3 6
D 2 0 0 0
The smallest of the uncovered elements is 1. So, we subtract 1 from all the uncovered
elements and add 1 to the elements lying at the intersections of the horizontal and
vertical lines. Table 2.5 shows the revised matrix. Next, we draw the least number of
horizontal and vertical lines covering all the zeros, see Table 2.6. Since the number of
lines = 4 = the order of the matrix, optimality condition is satisfied.
I II III IV
..
0... 5 1 7 I II III IV
A .
.. A 0 4 0 6
0... 3 7 1
. B 0 2 6 0
B .. V
· · · 2· . · · · · · 0· · · · · · 3· · · · · · 6· · · C 3 0 3 6
..
C . D 3 0 0 0
..
· · · 2· . · · · · · 0· · · · · · 0· · · · · · 0· · ·
..
D . Table 2.5
Table 2.4
I II III IV
· · · 0· · · · · · 4· · · · · · 0· · · · · · 6· · · I II III IV
A A 0 4 0
S
6
· · · 0· · · · · · 2· · · · · · 6· · · · · · 0· · ·
B 0
S
2 6 0
B V
· · · 3· · · · · · 0· · · · · · 3· · · · · · 6· · · C 3 0 3 6
C D 3 0
S
0 0
S
· · · 3· · · · · · 0· · · · · · 0· · · · · · 0· · ·
D Table 2.7
Table 2.6
Negative Cost - If the cost matrix of an assignment problem contains some negative
costs then we add to each element of the rows or columns a quantity sufficient to
make all the cell elements non-negative.
∑
n−1
xij = 1, j = 1, 2, ..., n; i , j
i=1
Again, since the salesman has to leave each city except city n, we have
∑
n
xij = 1, i = 1, 2, ..., n − 1; i , j
j=1
∑
n−1 ∑
n
Minimize Z = cij xij
i=1 j=1
Since cij = cji is not required, therefore, cij = ∞ for i = j. However, all cij ’s must be
non-negative, i.e., cij ≥ 0 and cij + cjk ≥ cjk for all i, j, k.
Example 2.2: A travelling salesman plans to visit five cities I, II, III, IV and V. The
travel time (in hours) between these cities is shown in Table 2.8. How should he sched-
To
I II III IV V
I ∞ 2 5 7 1
II 6 ∞ 3 8 2
From III 8 7 ∞ 4 7
IV 12 4 6 ∞ 5
V 1 3 2 8 ∞
Table 2.8
ule his touring plan in order to minimize the total travel time, if he visits each city once
a week?
Solution: We apply the Hungarian method to solve the given problem treating it as
an assignment problem. The solution is obtained as given in Table 2.9.
I II III IV V
I ∞ 1 3 6 0
II 4 ∞ 0 6 0
III 4 3 ∞ 0 3
IV 8 0 1 ∞ 1
V 0 2 0 7 ∞
Table 2.9
We see that the optimal assignment forms two subloops: I → V → I and II →
III → IV → II. This is not the solution of the traveling salesman problem as the
sequence of cities visited is not in cyclical order. We will now try for the next best
solution which satisfies the restriction of the traveling salesman problem. The next
minimum (non-zero) element in the Table 2.9 is 1 which occurs in the cells (I, II), (IV,
III) and (IV, V). We try make an assignment in any one of these cells. Let us make
an assignment in the cell (I, II) instead of zero assignment in the cell (I,V). Then no
other assignment is possible in the first row and second column. Next, we make an
assignment in the cell (IV, V) instead of the cell (IV, II). Thus we get a feasible solution
as I → II → III → IV → V → I. The assignment is shown in Table 2.10.
I II III IV V
I ∞ 1 3 6 0
II 4 ∞ 0 6 0
III 4 3 ∞ 0 3
IV 8 0 1 ∞ 1
V 0 2 0 7 ∞
Table 2.10
The cost corresponding to the feasible solution is 15. If, instead of making assignment
in the cell (IV, V), we make an assignment in the cell (IV, III) then we do not get a
feasible solution as in that case both II and IV are followed by III.