0% found this document useful (0 votes)
49 views4 pages

Hungarian Method

Uploaded by

Shivani Guvvala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views4 pages

Hungarian Method

Uploaded by

Shivani Guvvala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Hungarian Method for Solving the Assignment Problem (AP)

The Hungarian Method is an efficient algorithm specifically designed to solve the Assignment
Problem (AP). It minimizes the total cost of assigning resources (such as workers) to tasks
(jobs) in a one-to-one manner. The method is based on transforming the cost matrix by reducing
it to ensure that a solution can be easily derived through assignments at zero cost cells.

Steps of the Hungarian Method


Step 1: Row Reduction
 Process: For each row in the cost matrix, find the smallest element
and subtract it from every element in that row. This ensures that at
least one zero appears in every row of the matrix.

 Purpose: Row reduction normalizes the cost matrix, ensuring that the
smallest cost in each row is zero, laying the foundation for further
simplification.

 Example: Suppose we have the following cost matrix:

Worker/Job Job 1 Job 2 Job 3 Job 4


Worker 1 9 2 7 8
Worker 2 6 4 3 7
Worker 3 5 8 1 8
Worker 4 7 6 9 4
Subtracting the smallest element from each row:

Worker/Job Job 1 Job 2 Job 3 Job 4


Worker 1 7 0 5 6
Worker 2 3 1 0 4
Worker 3 4 7 0 7
Worker 4 3 2 5 0
Step 2: Column Reduction
 Process: In the matrix obtained from the row reduction step, subtract
the smallest element in each column from all the elements in that
column. This ensures that each column also has at least one zero.

 Purpose: Like row reduction, column reduction helps normalize the


matrix, allowing for easier identification of zero-cost assignments.

 Example: After column reduction of the above matrix:

Worker/Job Job 1 Job 2 Job 3 Job 4


Worker 1 4 0 5 6
Worker/Job Job 1 Job 2 Job 3 Job 4
Worker 2 0 1 0 4
Worker 3 1 7 0 7
Worker 4 0 2 5 0
Step 3: Cover All Zeros with Minimum Number of Lines
 Process: Cover all the zero entries in the matrix using the minimum
number of horizontal and vertical lines. If the number of lines equals
the size of the matrix (i.e., n for an n × n matrix), an optimal assignment
can be made. If fewer lines are required, move to Step 4.

 Purpose: Covering the zeros helps identify whether the current matrix
already contains an optimal solution or if further steps are required to
adjust the matrix.
 Example: In this example, we attempt to cover all zeros with vertical
or horizontal lines. If all zeros can be covered with 4 lines, we can
proceed to make assignments; otherwise, we go to Step 4.

Step 4: Adjust the Matrix if Necessary


 Process: If the number of lines is less than n, select the smallest
uncovered element, subtract it from all uncovered elements, and add it
to the elements at the intersection of the lines. The covered elements
remain unchanged.

 Purpose: This adjustment step refines the matrix further, enabling us


to generate additional zeros, ultimately leading to an optimal
assignment.

 Example: Suppose the smallest uncovered element is 1. Subtract 1


from all uncovered elements and add 1 to elements at the intersection
of the lines.

Step 5: Make Optimal Assignments


 Process: Once the number of covering lines equals n , assignments can
be made. These assignments correspond to the zero elements in the
matrix. The assignment is made in such a way that each row and each
column contains exactly one assignment.

 Purpose: This step identifies the final optimal assignment, where the
total cost is minimized.

 Example: After the matrix is reduced and optimized, we can assign


each worker to a job based on the zeros in the matrix, ensuring that no
two workers are assigned the same job.
Key Features of the Hungarian Method
1. Efficiency: The Hungarian Method provides an efficient algorithm for
solving assignment problems. Unlike brute-force methods that require
evaluating all possible assignments, this method uses matrix
transformations and iterative refinements to arrive at the optimal
solution with reduced computational complexity.

2. Application to Both Balanced and Unbalanced Problems: The


Hungarian Method can be applied to both balanced (where the number
of workers equals the number of jobs) and unbalanced problems. In the
unbalanced case, dummy rows or columns are added to balance the
matrix before applying the method.

3. Optimality: The method guarantees that the final solution is optimal,


meaning that the total cost of assignment is minimized. If multiple
optimal solutions exist, the method can identify them by revealing
multiple zeros across different rows and columns.

Example of the Hungarian Method


Let’s consider a simplified example:

Worker/Job Job 1 Job 2 Job 3


Worker A 10 12 19
Worker B 14 13 20
Worker C 15 16 12
1. Row Reduction: Subtract the smallest value in each row:

Worker/Job Job 1 Job 2 Job 3


Worker A 0 2 9
Worker B 1 0 7
Worker C 3 4 0
2. Column Reduction: Subtract the smallest value in each column:

Worker/Job Job 1 Job 2 Job 3


Worker A 0 2 9
Worker B 0 0 7
Worker C 2 4 0
3. Cover Zeros with Lines: Cover the zeros with two lines (less than 3),
so proceed to Step 4.
4. Adjust the Matrix: Subtract the smallest uncovered value (2) from all
uncovered elements and add it to the elements at intersections:

Worker/Job Job 1 Job 2 Job 3


Worker A 0 0 7
Worker B 0 0 5
Worker C 0 2 0
5. Make Assignments: Assign jobs based on the zero positions:

o Worker A → Job 2
o Worker B → Job 1
o Worker C → Job 3
The total minimized cost is 12+14+ 12=38.

Summary
The Hungarian Method is a powerful algorithm for solving the assignment problem,
guaranteeing an optimal solution by minimizing total costs. By systematically reducing the cost
matrix through row and column adjustments and refining the matrix with iterative steps, this
method efficiently identifies the best assignments, even for complex or large problems.

Questions
1. How does the Hungarian Method minimize the total cost of an assignment problem
efficiently compared to other methods like enumeration?
2. Why is it necessary to adjust the matrix when the number of covering lines is fewer than
n?

You might also like