# Solve Assignment Problem Using Hungarian Methodology

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:

Now we will examine a few highly simplified illustrations of **Hungarian Method** for solving an **assignment problem**.

Later in the chapter, you will find more practical versions of assignment models like Crew assignment problem, Travelling salesman problem, etc.

## Example 1: Hungarian Method

The Funny Toys 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 the following table. The objective is to assign men to jobs in such a way that the total cost of assignment is minimum.

Job | ||||
---|---|---|---|---|

Person | 1 | 2 | 3 | 4 |

A | 20 | 25 | 22 | 28 |

B | 15 | 18 | 23 | 17 |

C | 19 | 17 | 21 | 24 |

D | 25 | 23 | 24 | 24 |

Solution.

This is a **minimization example** of assignment problem. We will use the **Hungarian Algorithm** to solve this problem.

#### Step 1

Identify the minimum element in each row and **subtract** it from every element of that row. The result is shown in the following table.

"A man has one hundred dollars and you leave him with two dollars, that's subtraction." -Mae West

Table

On small screens, scroll horizontally to view full calculation

Job | ||||
---|---|---|---|---|

Person | 1 | 2 | 3 | 4 |

A | 0 | 5 | 2 | 8 |

B | 0 | 3 | 8 | 2 |

C | 2 | 0 | 4 | 7 |

D | 2 | 0 | 1 | 1 |

Step 2

Identify the minimum element in each column and subtract it from every element of that column.

Table

Job | ||||
---|---|---|---|---|

Person | 1 | 2 | 3 | 4 |

A | 0 | 5 | 1 | 7 |

B | 0 | 3 | 7 | 1 |

C | 2 | 0 | 3 | 6 |

D | 2 | 0 | 0 | 0 |

Step 3

Make the assignments for the reduced matrix obtained from **steps 1 and 2** in the following way:

- For each row or column with a single zero value cell that has not be assigned or eliminated, box that zero value as an assigned cell.
- For every zero that becomes assigned, cross out (X) all other zeros in the same row and the same column.
- If for a row and a column, there are two or more zeros and one cannot be chosen by inspection, choose the cell arbitrarily for assignment.
- The above process may be continued until every zero cell is either assigned or crossed (X).

#### Step 4

An optimal assignment is found, if the number of assigned cells equals the number of rows (and columns). In case you have chosen a zero cell arbitrarily, there may be alternate optimal solutions. If no optimal solution is found, go to step 5.

Table

Use Horizontal Scrollbar to View Full Table Calculation

#### Step 5

Draw the minimum number of vertical and horizontal lines necessary to cover all the zeros in the reduced matrix obtained from step 3 by adopting the following procedure:

- Mark all the rows that do not have assignments.
- Mark all the columns (not already marked) which have zeros in the marked rows.
- Mark all the rows (not already marked) that have assignments in marked columns.
- Repeat steps 5 (ii) and (iii) until no more rows or columns can be marked.
- Draw straight lines through all unmarked rows and marked columns.

You can also draw the minimum number of lines by inspection.

Table

#### Step 6

Select the smallest element (i.e., 1) from all the uncovered elements. Subtract this smallest element from all the uncovered elements and add it to the elements, which lie at the intersection of two lines. Thus, we obtain another reduced matrix for fresh assignment.

Table

Job | ||||
---|---|---|---|---|

Person | 1 | 2 | 3 | 4 |

A | 0 | 4 | 0 | 6 |

B | 0 | 2 | 6 | 0 |

C | 3 | 0 | 3 | 6 |

D | 3 | 0 | 0 | 0 |

Now again make the assignments for the reduced matrix.

#### Final Table: Hungarian Method

Since the number of assignments is equal to the number of rows (& columns), this is the optimal solution.

The total cost of assignment = A1 + B4 + C2 + D3

Substituting values from original table:

20 + 17 + 17 + 24 = Rs. 78.

## 0 Replies to “Solve Assignment Problem Using Hungarian Methodology”