0% found this document useful (0 votes)
38 views

Assignment Problem

The document discusses the assignment problem, which aims to assign resources to activities to minimize costs. It describes the Hungarian method for solving assignment problems, which involves constructing a cost matrix and using a series of steps like identifying row/column minimums and making assignments to eventually find an optimal solution. The method is demonstrated on two examples, finding the optimal assignments and their total costs.

Uploaded by

NANDINI GUPTA
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

Assignment Problem

The document discusses the assignment problem, which aims to assign resources to activities to minimize costs. It describes the Hungarian method for solving assignment problems, which involves constructing a cost matrix and using a series of steps like identifying row/column minimums and making assignments to eventually find an optimal solution. The method is demonstrated on two examples, finding the optimal assignments and their total costs.

Uploaded by

NANDINI GUPTA
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 82

Assignment Problem

Amit Prakash Jha


Assignment Problem
An assignment problem is a particular case of
transportation problem.

The objective is to assign a number of resources


to an equal number of activities so as to
minimise total cost or maximize total profit of
allocation.
Assignment Problem

P1 J1

P2 J2

P3 J3
Assignment Problem

COST MATRIX
Job J1 J2 J3
Person
P1 120 100 80
P2 80 90 110
P3 110 140 120
Assignment Problem

COST MATRIX
Job J1 J2 J3
Person
P1 [X11] 120 [X12] 100 [X13] 80
P2 [X21] 80 [X22] 90 [X23] 110
P3 [X31] 110 [X32] 140 [X33] 120
Assignment Problem
Hungarian Method [Steps]
Step 1:
Your problem should be balanced. Number of
rows should be equal to number of columns. If it
is not the case then add a dummy row (or
column) with zero cost elements.
Hungarian Method [Steps]
Step 2:
Subtract the smallest cost element of each row
from each element of the row (You will get first
reduced cost matrix).
Hungarian Method [Steps]
Step 3:
Subtract the smallest cost element of each
column from each element of the column (You
will get second reduced cost matrix).
Hungarian Method [Steps]
Step 4a:
Examine the rows successively and make
assignment where exactly one zero is found.
Cross all the zeros in the column corresponding
to the cell where assignment is made. Continue
till all the rows are examined.
Hungarian Method [Steps]
Step 4b:
Examine the columns successively and make
assignment where exactly one zero is found. If
you find multiple zeros then you could assign
arbitrarily where you have minimum zeros and
you may repeat the process until all zeros are
assigned or crossed.
Hungarian Method [Steps]
Step 5:
An optimal solution is found if the number of
assigned cells is equal to number of rows (or
columns). If you assigned in a cell arbitrarily then
there are multiple assignments possible. If some
rows (or columns) are left without assignment
then optimality isn’t achieved. Proceed further.
Hungarian Method [Steps]
Step 6:
Draw the minimum number of horizontal and/or
vertical lines through all the zeros. There is a
procedure to achieve this...

The Steps 6 to 9 are optional.


You are required to solve the problem through R.
Hungarian Method [Steps]
Step 6:
Draw the minimum number of horizontal and/or vertical lines through all the
zeros. There is a procedure to achieve this...
i. Mark (√) to those rows where no assignments are made
ii. Mark (√) to those columns which have zeros in marked rows
iii. Mark (√) to the rows which have assignments in marked columns (do this
step to the rows not already marked)
iv. Repeat until no more rows or columns can be checked
v. Draw straight lines through unmarked rows and marked columns
Hungarian Method [Steps]
Step 7:
If the minimum number of lines through all the
zeros is equal to the number of rows (or
columns) then optimal solution is achieved. You
may arbitrarily make assignments at the
position of zeros not crossed earlier. Else proceed
further.
Hungarian Method [Steps]
Step 8:
Revise the cost matrix
i. Find the smallest element uncovered by lines
and subtract it from all uncrossed elements
ii. Add that smallest element at the point of
intersection of two lines
Hungarian Method [Steps]
Step 9:
Go to step 4 and repeat the process till optimal
solution is reached.
Hungarian Method [Example1]

  I II III IV

A 10 5 13 15
B 3 9 18 3
C 10 7 3 2
D 5 11 9 7

Cost Matrix
Hungarian Method [Example1]

  I II III IV

A 10 5 13 15
B 3 9 18 3
C 10 7 3 2
D 5 11 9 7

Cost Matrix (Identify Row Minimum)


Hungarian Method [Example1]

  I II III IV

A 5 0 8 10
B 0 6 15 0
C 8 5 1 0
D 0 6 4 2

First Reduced Matrix


Hungarian Method [Example1]

  I II III IV

A 5 0 8 10
B 0 6 15 0
C 8 5 1 0
D 0 6 4 2

First Reduced Matrix (Identify Column Minimum)


Hungarian Method [Example1]

  I II III IV

A 5 0 7 10
B 0 6 14 0
C 8 5 0 0
D 0 6 3 2

Second Reduced Matrix


Hungarian Method [Example1]

  I II III IV

A 5 0 7 10
B 0 6 14 0
C 8 5 0 0
D 0 6 3 2

Second Reduced Matrix


Hungarian Method [Example1]

  I II III IV

A 5 0 7 10
B 0 6 14 0
C 8 5 0 0
D 0 6 3 2

Assignment in first row


Hungarian Method [Example1]

  I II III IV

A 5 0 7 10
B 0 6 14 0
C 8 5 0 0
D 0 6 3 2

Ignore second row


Hungarian Method [Example1]

  I II III IV

A 5 0 7 10
B 0 6 14 0
C 8 5 0 0
D 0 6 3 2

Ignore third row


Hungarian Method [Example1]

  I II III IV

A 5 0 7 10
B 0 6 14 0
C 8 5 0 0
D 0 6 3 2

Assignment in fourth row


Hungarian Method [Example1]

  I II III IV

A 5 0 7 10
B 0 6 14 0
C 8 5 0 0
D 0 6 3 2

Assignment in fourth row and cross the


zeros in the assigned column
Hungarian Method [Example1]

  I II III IV

A 5 0 7 10
B 0 6 14 0
C 8 5 0 0
D 0 6 3 2

Assignment in second row


Hungarian Method [Example1]

  I II III IV

A 5 0 7 10
B 0 6 14 0
C 8 5 0 0
D 0 6 3 2

Assignment in second row and cross the


zeros in assigned column
Hungarian Method [Example1]

  I II III IV

A 5 0 7 10
B 0 6 14 0
C 8 5 0 0
D 0 6 3 2

Assignment in third row


Hungarian Method [Example1]

  I II III IV

A 5 0 7 10
B 0 6 14 0
C 8 5 0 0
D 0 6 3 2

All zeros are either assigned or crossed


Hungarian Method [Example1]

  I II III IV

A 5 0 7 10
B 0 6 14 0
C 8 5 0 0
D 0 6 3 2
Each row and each column has exactly
one assigned zero. There are four rows
and four columns and four assignments.
Hence, it is optimal assignment
Hungarian Method [Example1]

  I II III IV

A 5 0 7 10
B 0 6 14 0
C 8 5 0 0
D 0 6 3 2

A-II B-IV C-III D-I


Hungarian Method [Example1]

  I II III IV

A 5 0 7 10
B 0 6 14 0
C 8 5 0 0
D 0 6 3 2

A-II B-IV C-III D-I


Cost (Optimal): 5+3+3+5 = 16
Hungarian Method [Example2]

  I II III IV V VI
A 9 22 58 11 19 27
B 43 78 72 50 63 48
C 41 28 91 37 45 33
D 74 42 27 49 39 32
E 36 11 57 22 25 18
F 3 56 53 31 17 28

Cost Matrix
Hungarian Method [Example2]

  I II III IV V VI
A 9 22 58 11 19 27
B 43 78 72 50 63 48
C 41 28 91 37 45 33
D 74 42 27 49 39 32
E 36 11 57 22 25 18
F 3 56 53 31 17 28

Cost Matrix (Row Minimum Identified)


Hungarian Method [Example2]

  I II III IV V VI
A 0 13 49 2 10 18
B 0 35 29 7 20 5
C 13 0 63 9 17 5
D 47 15 0 22 12 5
E 25 0 46 11 14 7
F 0 53 50 28 14 25

First Reduced Matrix


Hungarian Method [Example2]

  I II III IV V VI
A 0 13 49 2 10 18
B 0 35 29 7 20 5
C 13 0 63 9 17 5
D 47 15 0 22 12 5
E 25 0 46 11 14 7
F 0 53 50 28 14 25

First Reduced Matrix (Column Minimum Identified)


Hungarian Method [Example2]

  I II III IV V VI
A 0 13 49 0 0 13
B 0 35 29 5 10 0
C 13 0 63 7 7 0
D 47 15 0 20 2 0
E 25 0 46 9 4 2
F 0 53 50 26 4 20

Second Reduced Matrix


Hungarian Method [Example2]

  I II III IV V VI
A 0 13 49 0 0 13
B 0 35 29 5 10 0
C 13 0 63 7 7 0
D 47 15 0 20 2 0
E 25 0 46 9 4 2
F 0 53 50 26 4 20

Now, Start Making Assignments


Hungarian Method [Example2]

  I II III IV V VI
A 0 13 49 0 0 13
B 0 35 29 5 10 0
C 13 0 63 7 7 0
D 47 15 0 20 2 0
E 25 0 46 9 4 2
F 0 53 50 26 4 20
Ignore first four rows because there are multiple zeros.
Make assignment in the fifth row and cross the zeros in the
assigned column
Hungarian Method [Example2]

  I II III IV V VI
A 0 13 49 0 0 13
B 0 35 29 5 10 0
C 13 0 63 7 7 0
D 47 15 0 20 2 0
E 25 0 46 9 4 2
F 0 53 50 26 4 20
Make assignment in the sixth row and cross the zeros in
the assigned column
Hungarian Method [Example2]

  I II III IV V VI
A 0 13 49 0 0 13
B 0 35 29 5 10 0
C 13 0 63 7 7 0
D 47 15 0 20 2 0
E 25 0 46 9 4 2
F 0 53 50 26 4 20
Now, proceed column wise and make assignment in the
third column and cross the zeros in the assigned row
Hungarian Method [Example2]

  I II III IV V VI
A 0 13 49 0 0 13
B 0 35 29 5 10 0
C 13 0 63 7 7 0
D 47 15 0 20 2 0
E 25 0 46 9 4 2
F 0 53 50 26 4 20
Make assignment in the fourth column and cross the zeros
in the assigned row
Hungarian Method [Example2]

  I II III IV V VI
A 0 13 49 0 0 13
B 0 35 29 5 10 0
C 13 0 63 7 7 0
D 47 15 0 20 2 0
E 25 0 46 9 4 2
F 0 53 50 26 4 20

You can EITHER do this OR


Hungarian Method [Example2]

  I II III IV V VI
A 0 13 49 0 0 13
B 0 35 29 5 10 0
C 13 0 63 7 7 0
D 47 15 0 20 2 0
E 25 0 46 9 4 2
F 0 53 50 26 4 20

You can do this


Hungarian Method [Example2]

  I II III IV V VI
A 0 13 49 0 0 13
B 0 35 29 5 10 0
C 13 0 63 7 7 0
D 47 15 0 20 2 0
E 25 0 46 9 4 2
F 0 53 50 26 4 20
You can stick to a systematic procedure to make
assignments or if the need arise you can decide arbitrarily
Hungarian Method [Example2]

  I II III IV V VI
A 0 13 49 0 0 13
B 0 35 29 5 10 0
C 13 0 63 7 7 0
D 47 15 0 20 2 0
E 25 0 46 9 4 2
F 0 53 50 26 4 20
Now, there are only five assignments but there are six
rows and six columns and hence, this is not optimal
Hungarian Method [Example2]

  I II III IV V VI
A 0 13 49 0 0 13
B 0 35 29 5 10 0
C 13 0 63 7 7 0
D 47 15 0 20 2 0
E 25 0 46 9 4 2
F 0 53 50 26 4 20
Our aim now is to cover the zeros with minimum
horizontal and/or vertical lines
Hungarian Method [Example2]

  I II III IV V VI
A 0 13 49 0 0 13
B 0 35 29 5 10 0
C 13 0 63 7 7 0
D 47 15 0 20 2 0
E 25 0 46 9 4 2
F 0 53 50 26 4 20
Our aim now is to cover the zeros with minimum
horizontal and/or vertical lines. There is a systematic
procedure for the same
Hungarian Method [Example2]

  I II III IV V VI
A 0 13 49 0 0 13
B 0 35 29 5 10 0 √
C 13 0 63 7 7 0
D 47 15 0 20 2 0
E 25 0 46 9 4 2
F 0 53 50 26 4 20

Mark un-assigned rows


Hungarian Method [Example2]

  I II III IV V VI
A 0 13 49 0 0 13
B 0 35 29 5 10 0 √
C 13 0 63 7 7 0
D 47 15 0 20 2 0
E 25 0 46 9 4 2
F 0 53 50 26 4 20
√ √
Mark columns with zeros in marked rows
Hungarian Method [Example2]

  I II III IV V VI
A 0 13 49 0 0 13
B 0 35 29 5 10 0 √
C 13 0 63 7 7 0 √
D 47 15 0 20 2 0
E 25 0 46 9 4 2
F 0 53 50 26 4 20 √
√ √
Mark rows (not already marked) which have
assignments in marked columns
Hungarian Method [Example2]

  I II III IV V VI
A 0 13 49 0 0 13
B 0 35 29 5 10 0 √
C 13 0 63 7 7 0 √
D 47 15 0 20 2 0
E 25 0 46 9 4 2
F 0 53 50 26 4 20 √
√ √ √
Mark columns with zeros in marked rows
Hungarian Method [Example2]

  I II III IV V VI
A 0 13 49 0 0 13
B 0 35 29 5 10 0 √
C 13 0 63 7 7 0 √
D 47 15 0 20 2 0
E 25 0 46 9 4 2 √
F 0 53 50 26 4 20 √
√ √ √
Mark rows (not already marked) which have
assignments in marked columns
Hungarian Method [Example2]

  I II III IV V VI
A 0 13 49 0 0 13
B 0 35 29 5 10 0 √
C 13 0 63 7 7 0 √
D 47 15 0 20 2 0
E 25 0 46 9 4 2 √
F 0 53 50 26 4 20 √
√ √ √
DONE. Draw straight lines with unmarked row and
marked columns
Hungarian Method [Example2]

  I II III IV V VI
A 0 13 49 0 0 13
B 0 35 29 5 10 0 √
C 13 0 63 7 7 0 √
D 47 15 0 20 2 0
E 25 0 46 9 4 2 √
F 0 53 50 26 4 20 √

√ √ √
Number of lines (5) < Number of rows or columns,
hence this is not optimal
Hungarian Method [Example2]

  I II III IV V VI
A 0 13 49 0 0 13
B 0 35 29 5 10 0 √
C 13 0 63 7 7 0 √
D 47 15 0 20 2 0
E 25 0 46 9 4 2 √
F 0 53 50 26 4 20 √

√ √ √
Look for smallest uncovered element (it is 4)
Hungarian Method [Example2]

  I II III IV V VI
A 0 13 49 0 0 13
B 0 35 29 5 10 0 √
C 13 0 63 7 7 0 √
D 47 15 0 20 2 0
E 25 0 46 9 4 2 √
F 0 53 50 26 4 20 √

√ √ √
Subtract 4 from uncovered elements and add 4 where lines
intersect
Hungarian Method [Example2]

  I II III IV V VI
A 4 17 49 0 0 17
B 0 35 25 1 6 0 √
C 13 0 59 3 3 0 √
D 51 19 0 20 2 4
E 25 0 42 5 0 2 √
F 0 53 46 22 0 20 √

√ √ √
Subtract 4 from uncovered elements and add 4 where lines
intersect
Hungarian Method [Example2]

  I II III IV V VI
A 4 17 49 0 0 17
B 0 35 25 1 6 0
C 13 0 59 3 3 0
D 51 19 0 20 2 4
E 25 0 42 5 0 2
F 0 53 46 22 0 20

Reduced Matrix
Hungarian Method [Example2]

  I II III IV V VI
A 4 17 49 0 0 17
B 0 35 25 1 6 0
C 13 0 59 3 3 0
D 51 19 0 20 2 4
E 25 0 42 5 0 2
F 0 53 46 22 0 20

Reduced Matrix (Now, we will make assignments)


Hungarian Method [Example2]

  I II III IV V VI
A 4 17 49 0 0 17
B 0 35 25 1 6 0
C 13 0 59 3 3 0
D 51 19 0 20 2 4
E 25 0 42 5 0 2
F 0 53 46 22 0 20

Row fourth
Hungarian Method [Example2]

  I II III IV V VI
A 4 17 49 0 0 17
B 0 35 25 1 6 0
C 13 0 59 3 3 0
D 51 19 0 20 2 4
E 25 0 42 5 0 2
F 0 53 46 22 0 20

Column fourth
Hungarian Method [Example2]

  I II III IV V VI
A 4 17 49 0 0 17
B 0 35 25 1 6 0
C 13 0 59 3 3 0
D 51 19 0 20 2 4
E 25 0 42 5 0 2
F 0 53 46 22 0 20

Row second (arbitrarily) [KEEP A NOTE]


Hungarian Method [Example2]

  I II III IV V VI
A 4 17 49 0 0 17
B 0 35 25 1 6 0
C 13 0 59 3 3 0
D 51 19 0 20 2 4
E 25 0 42 5 0 2
F 0 53 46 22 0 20

Row sixth
Hungarian Method [Example2]

  I II III IV V VI
A 4 17 49 0 0 17
B 0 35 25 1 6 0
C 13 0 59 3 3 0
D 51 19 0 20 2 4
E 25 0 42 5 0 2
F 0 53 46 22 0 20

Column sixth
Hungarian Method [Example2]

  I II III IV V VI
A 4 17 49 0 0 17
B 0 35 25 1 6 0
C 13 0 59 3 3 0
D 51 19 0 20 2 4
E 25 0 42 5 0 2
F 0 53 46 22 0 20

Row fifth
Hungarian Method [Example2]

  I II III IV V VI
A 4 17 49 0 0 17
B 0 35 25 1 6 0
C 13 0 59 3 3 0
D 51 19 0 20 2 4
E 25 0 42 5 0 2
F 0 53 46 22 0 20
Each row and each column has exactly one assignment.
Hence, this is optimal
Hungarian Method [Example2]

  I II III IV V VI
A 4 17 49 0 0 17
B 0 35 25 1 6 0
C 13 0 59 3 3 0
D 51 19 0 20 2 4
E 25 0 42 5 0 2
F 0 53 46 22 0 20

A-IV B-I C-VI D-III E-II F-V


Hungarian Method [Example2]

  I II III IV V VI
A 9 22 58 11 19 27
B 43 78 72 50 63 48
C 41 28 91 37 45 33
D 74 42 27 49 39 32
E 36 11 57 22 25 18
F 3 56 53 31 17 28
COST 142
[ORIGINAL COST MATRIX] A-IV B-I C-VI D-III E-II F-
V
OPTIMAL ALLOCATION
Hungarian Method [Example2]

  I II III IV V VI
A 9 22 58 11 19 27
B 43 78 72 50 63 48
C 41 28 91 37 45 33
D 74 42 27 49 39 32
E 36 11 57 22 25 18
F 3 56 53 31 17 28
COST 142
[ORIGINAL COST MATRIX] A-IV B-VI C-II D-III E-V F-
I
ATERNATE SOLUTION [YOU WERE ASKED TO KEEP A NOTE]
Hungarian Method [Steps]
Step 6: The Critical Step
Draw the minimum number of horizontal and/or vertical lines through all the
zeros. There is a procedure to achieve this...
i. Mark (√) to those rows where no assignments are made
ii. Mark (√) to those columns which have zeros in marked rows
iii. Mark (√) to the rows which have assignments in marked columns (do this
step to the rows not already marked)
iv. Repeat until no more rows or columns can be checked
v. Draw straight lines through unmarked rows and marked columns
Hungarian Method [Steps]
Step 6: The Critical Step
Draw the minimum number of horizontal and/or vertical lines through all the
zeros. There is a procedure to achieve this...
i. Mark (√) to those rows where no assignments are made
ii. Mark (√) to those columns which have zeros in marked rows
iii. Mark (√) to the rows which have assignments in marked columns (do this
step to the rows not already marked)
iv. Repeat until no more rows or columns can be checked
v. Draw straight lines through unmarked rows and marked columns
Hungarian Method [Steps]
Step 6: The Critical Step
Draw the minimum number of horizontal and/or vertical lines through all the
zeros. There is a procedure to achieve this...
i. Mark (√) to those rows where no assignments are made
ii. Mark (√) to those columns which have zeros in marked rows
iii. Mark (√) to the rows which have assignments in marked columns (do
this step to the rows not already marked)
iv. Repeat until no more rows or columns can be checked
v. Draw straight lines through unmarked rows and marked columns
Hungarian Method [Steps]
Step 6: The Critical Step
Draw the minimum number of horizontal and/or vertical lines through all the
zeros. There is a procedure to achieve this...
i. Mark (√) to those rows where no assignments are made
ii. Mark (√) to those columns which have zeros in marked rows
iii. Mark (√) to the rows which have assignments in marked columns (do this
step to the rows not already marked)
iv. Repeat until no more rows or columns can be checked
v. Draw straight lines through unmarked rows and marked columns
Hungarian Method [Steps]
Step 6: The Critical Step
Draw the minimum number of horizontal and/or vertical lines through all the
zeros. There is a procedure to achieve this...
i. Mark (√) to those rows where no assignments are made
ii. Mark (√) to those columns which have zeros in marked rows
iii. Mark (√) to the rows which have assignments in marked columns (do this
step to the rows not already marked)
iv. Repeat until no more rows or columns can be checked
v. Draw straight lines through unmarked rows and marked columns
Hungarian Method [Other Important Points]

• Multiple solutions are possible


• Normally assignment problem is a cost minimization problem but we may
have to maximize profit in some cases... To solve a maximization type
assignment problem
– Either multiply all elements by -1
– Or subtract all elements from the highest entry
– And proceed as usual
• To solve unbalanced problems add dummy row or column
• If it is not possible to assign a machine to a location (say) then
we may model it by giving a huge (infinite) cost
Hungarian Method [Solution through R]

Package lpSolve

and

Function lp.assign
Hungarian Method [Solution through R]
Hungarian Method [Solution through R]

You might also like