Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Optimal Assignment using the Hungarian Algorithm: An Example, Lecture notes of Operational Research

How to find the optimal assignment in a given matrix using the hungarian algorithm. An example with step-by-step instructions and illustrations. The algorithm is used to minimize the number of lines required to cover all zeros in the matrix.

Typology: Lecture notes

2011/2012

Uploaded on 08/06/2012

anagha
anagha 🇮🇳

4.4

(43)

131 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
MULTIPLE SOLUTIONS
Example 1 Given the following matrix, find the optimal assignment.
1 2 3 4 5
1
2
3
4
5
5 0 3 2 6
0 0 5 4 7
0 3 0 4 0
0 1 0 3 0
6 5 0 0 0
Solution: Note that all the rows and columns have at least one zero.
Row 1 has a single zero in column 2. So make an assignment, delete (mark X) the second zero in column 2.
This is shown in table 7. 0 denotes assignment
Table 7
1 2 3 4 5
1
2
3
4
5
5 0 3 2 6
0 0 5 4 7
0x 3 0 4 0
0x 1 0 3 0
6 5 0x 0 0x
Row 2 has a single zero in the first column. So make an assignment and delete the remaining zeros in column 1 as
shown in table 8.
Table 8
1 2 3 4 5
docsity.com
pf3
pf4
pf5

Partial preview of the text

Download Optimal Assignment using the Hungarian Algorithm: An Example and more Lecture notes Operational Research in PDF only on Docsity!

MULTIPLE SOLUTIONS

Example 1 Given the following matrix, find the optimal assignment.

Solution: Note that all the rows and columns have at least one zero.

Row 1 has a single zero in column 2. So make an assignment, delete (mark X) the second zero in column 2.

This is shown in table 7. 0 denotes assignment

Table 7

1 2 3 4 5 1

2

3

4

5

0x 3 0 4 0

0x 1 0 3 0

6 5 0x 0 0x

Row 2 has a single zero in the first column. So make an assignment and delete the remaining zeros in column 1 as shown in table 8.

Table 8

1 2 3 4 5

0 0x 5 4 7

0x 3 0 4 0

0x 1 0 3 0

6 5 0 0 0

Row 3, 4 and 5 have more than a single zero. So we skip these rows and examine the columns. Columns 3 has three zeros and so omit it. Column 4 has a single zero in row 5. So we make an assignment, deleting the remaining zeros in row 5. The result is as shown in table 9.

Table 9

1 2 3 4 5 1

2

0 0x 5 4 7

0x 3 0 4 0

0x 1 0 3 0

6 5 0x 0 0x

Now we have two zeros in rows 3 and 4 in columns 3 and they occupy the corners of a square. An arbitrary assignment has to be made. If we make an assignment in (3, 3) and delete the remaining zero in row 3 and in column 3, this leaves one zero in the position (4, 5) and an assignment is made there. Thus we have a solution to the problem as in table 10. Table 10

1 2 3 4 5

0 0x 5 4 7

0x 3 0 4 0x

0 1 0x 3 0

Table 11

1 2 3 4 5

0 0x 5 4 7

0x 3 0x 4 0

0x 1 0 3 0x

6 5 0x 0 0x

Remark: All the above markings can be done in a single matrix itself. We need not write the matrix repeatedly. This is done only to clarify the presentation.

HUNGARIAN ALGORITHM

In the two examples above, the first one gave a solution leaving no zeros. It was a case of no ambiguity and in the second, we had more zeros and the tie was broken arbitrarily. Sometimes if we proceed in the steps explained above, we get a maximal assignment, which does not contain an assignment in every row or column. We are faced with a question of how to solve the problem. In such a case, the effectiveness matrix has to be modified, so that after a finite number of iterations an optimal assignment will be in sight. The following is the algorithm to solve a problem of this kind and this is known as Hungarian algorithm. The systematic procedure is explained in different steps and a problem is solved as an illustration.

STEP 1 : Starting with a maximal assignment mark ( ) all rows for which assignments have not been made.

STEP 2 : Mark ( ) columns not already marked which have zeros in the marked-rows.

STEP 3 : Mark ( ) rows not already marked which have assignments in the marked columns.

STEP 4 : Repeat steps 2 and 3 until the chain of markings ends.

STEP5 : Draw lines through all unmarked rows and though all marked columns. (Check: If the above steps have been carried out correctly, there should be as many lines as there were assignments in the maximal assignment and we have atleast one line passing through every zero.) This is a method of drawing minimum number of lines that will pass through all zeros. Thus all the zeros are covered.

STEP 6 : Now examine the elements that do not have a line through them. Choose the smallest element and subtract it form all the elements the intersection or junction of two lines. Leave the remaining elements of the matrix unchanged.

STEP 7 : Now proceed to make an assignment. If a solution is obtained with an assignment for every row, then this will be the optimal solution. Otherwise proceed to draw minimum number of lines to cover all zeros as explained in steps 1 to 5 and repeat iterations if needed.

Consider the following example.