# Hungarian Assignment Method Steps

An assignment problem can be easily solved by applying Hungarian method which consists of two phases. In the first phase, row reductions and column reductions are carried out. In the second phase, the solution is optimized on iterative basis.

*Phase 1*

*Step 0: *Consider the given matrix.*Step 1: *In a given problem, if the number of rows is not equal to the number of columns and vice versa, then add a dummy row or a dummy column. The assignment costs for dummy cells are always assigned as zero.*Step 2: *Reduce the matrix by selecting the smallest element in each row and subtract with other elements in that row.

*Phase 2:*

*Step 3*: Reduce the new matrix column-wise using the same method as given in step 2.*Step 4*: Draw minimum number of lines to cover all zeros.*Step 5*: If Number of lines drawn = order of matrix, then optimally is reached, so proceed to step 7. If optimally is not reached, then go to step 6.*Step 6: *Select the smallest element of the whole matrix, which is **NOT COVERED **by lines. Subtract this smallest element with all other remaining elements that are **NOT COVERED **by lines and add the element at the intersection of lines. Leave the elements covered by single line as it is. Now go to step 4.*Step 7: *Take any row or column which has a single zero and assign by squaring it. Strike off the remaining zeros, if any, in that row and column (X). Repeat the process until all the assignments have been made.*Step 8: *Write down the assignment results and find the minimum cost/time.

**Note: **While assigning, if there is no single zero exists in the row or column, choose any one zero and assign it. Strike off the remaining zeros in that column or row, and repeat the same for other assignments also. If there is no single zero allocation, it means multiple numbers of solutions exist. But the cost will remain the same for different sets of allocations.

** Example : **Assign the four tasks to four operators. The assigning costs are given in Table.

*Assignment Problem*

*Solution:*

*Step 1: *The given matrix is a square matrix and it is not necessary to add a dummy row/column*Step 2: *Reduce the matrix by selecting the smallest value in each row and subtracting from other values in that corresponding row. In row A, the smallest value is 13, row B is 15, row C is 17 and row D is 12. The row wise reduced matrix is shown in table below.

*Row-wise Reduction*

*Step 3: *Reduce the new matrix given in the following table by selecting the smallest value in

each column and subtract from other values in that corresponding column. In column 1, the smallest value is 0, column 2 is 4, column 3 is 3 and column 4 is 0. The column-wise reduction matrix is shown in the following table.

*Column-wise Reduction Matrix*

*Step 4: *Draw minimum number of lines possible to cover all the zeros in the matrix given in Table

*Matrix with all Zeros Covered*

The first line is drawn crossing row C covering three zeros, second line is drawn crossing column 4 covering two zeros and third line is drawn crossing column 1 (or row B) covering a single zero.*Step 5: *Check whether number of lines drawn is equal to the order of the matrix, i.e., 3 ≠ 4. Therefore optimally is not reached. Go to step 6.*Step 6: *Take the smallest element of the matrix that is not covered by single line, which is 3. Subtract 3 from all other values that are not covered and add 3 at the intersection of lines. Leave the values which are covered by single line. The following table shows the details.

*Subtracted or Added to Uncovered Values and Intersection Lines Respectively*

*Step 7: *Now, draw minimum number of lines to cover all the zeros and check for optimality. Here in table minimum number of lines drawn is 4 which are equal to the order of matrix. Hence optimality is reached.

*Optimality Matrix*

*Step 8: *Assign the tasks to the operators. Select a row that has a single zero and assign by squaring it. Strike off remaining zeros if any in that row or column. Repeat the assignment for other tasks. The final assignment is shown in table below.

*Final Assignment*

Therefore, optimal assignment is:

** Example : **Solve the following assignment problem shown in Table using Hungarian method. The matrix entries are processing time of each man in hours.

*Assignment Problem*

**Solution: **The row-wise reductions are shown in Table

*Row-wise Reduction Matrix*

The column wise reductions are shown in Table.

*Column-wise Reduction Matrix*

Matrix with minimum number of lines drawn to cover all zeros is shown in Table.

*Matrix will all Zeros Covered*

The number of lines drawn is 5, which is equal to the order of matrix. Hence optimality is reached. The optimal assignments are shown in Table.

*Optimal Assignment*

Therefore, the optimal solution is:

## The Hungarian algorithm

The Hungarian algorithm consists of the four steps below. The first two steps are executed once, while Steps 3 and 4 are repeated until an optimal assignment is found. The input of the algorithm is an *n* by *n* square matrix with only nonnegative elements.

**Step 1: Subtract row minima**

For each row, find the lowest element and subtract it from each element in that row.

**Step 2: Subtract column minima**

Similarly, for each column, find the lowest element and subtract it from each element in that column.

**Step 3: Cover all zeros with a minimum number of lines**

Cover all zeros in the resulting matrix using a minimum number of horizontal and vertical lines. If *n* lines are required, an optimal assignment exists among the zeros. The algorithm stops.

If less than *n* lines are required, continue with Step 4.

**Step 4: Create additional zeros**

Find the smallest element (call it *k*) that is not covered by a line in Step 3. Subtract *k* from all uncovered elements, and add *k* to all elements that are covered twice.

Continue with:

The Hungarian algorithm explained based on an example.

The Hungarian algorithm explained based on a self chosen or on a random cost matrix.

## 0 Replies to “Hungarian Assignment Method Steps”