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

Lecture 21

The document explains the assignment model, which involves assigning n workers to n jobs with the goal of minimizing costs or time. It details the Hungarian algorithm as a method to solve assignment problems, including steps for reducing cost matrices and making optimal assignments. Examples illustrate the process and outcomes of applying the algorithm to various assignment scenarios.

Uploaded by

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

Lecture 21

The document explains the assignment model, which involves assigning n workers to n jobs with the goal of minimizing costs or time. It details the Hungarian algorithm as a method to solve assignment problems, including steps for reducing cost matrices and making optimal assignments. Examples illustrate the process and outcomes of applying the algorithm to various assignment scenarios.

Uploaded by

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

The assignment Model

The Assignment Model


"The best person for job" is an apt description of
the assignment model.
The general assignment model with n workers and
n jobs is presented below:
Jobs
1 2 …. n
1 c11 c12 … c1n
Workers 2 c21 c22 … c2n

n cn1 cn2 … cnn


• The element cij is the “cost” of assigning the worker i
to the job j.
• More meaningfully, it may be thought of as the time
taken by the worker i to complete the job j.
• There is no loss of generality in assuming that the
number of workers = the number of jobs.
• If there are more workers, we may introduce dummy
jobs and if there are less workers, we may introduce
dummy workers.
• One important assumption we make is that each
worker is assigned to one and only one job. And
each job is done by one and only one worker.
• The assignment model is actually a special case of
the transportation model.
• Also from the last assumption we get that the
availabilities at each source equals 1 and the demand
at each destination equals 1.
• xij =1 if worker i assigned to job j and = 0 otherwise.
• Though we can apply the transportation
algorithm to solve the assignment model, a special
simple algorithm, called the Hungarian algorithm,
is used to solve such models.
Consider the assignment problem:

4 0 1 2

3 5 2 0

0 4 1 5

1 2 0 3
The solution is obvious:

W1  J2, W2  J4, W3  J1, W4  J3


• We note that in any assignment problem, if a constant c
is subtracted from the costs of any row ( or column), the
optimum solution does not change, but the assignment
cost decreases by c.
• This is because in each row we have to assign ‘1’ to one
and only one cell.
• The Hungarian algorithm exploits this fact and tries to
get a zero in each row (column) by subtracting the
minimum value in that row (column) to get at least one
zero.
The Hungarian algorithm
Row
Consider the assignment problem: Min

8 6 5 7 p1 = 5

6 5 3 4 p2 = 3

7 8 4 6 p3 = 4

6 7 5 6 p4 = 5
Step 1: From each entry of a row, we subtract the
minimum value in that row and get the following
reduced cost matrix:

3 1 0 2

3 2 0 1

3 4 0 2

1 2 0 1
Column q1=1 q2=1 q3=0 q4=1
Minimum
Step 2: From each entry of a column, we subtract
the minimum value in that column and get the
following reduced cost matrix:

2 0 0 1

2 1 0 0

2 3 0 1

0 1 0 0
Step 3: Now we test whether an assignment can
be made as follows. If such an assignment is
possible, it is the optimal assignment.
(a) Examine the first row. If there is only one
zero in that row, surround it by a square ( 0 )
and cross (  ) all the other zeros in the
column passing through the surrounded zero.
Next examine the other rows and repeat the above
procedure for each row having only one zero.
If a row has more than one zero, do nothing to
that row and pass on to the next row.
Step 3(a) gives the following table.

2 0 0 1

2 1 0 0

2 3 0 1

0 1 0 0

Step 3(b): Now repeat the above procedure for


columns. (Remember to interchange row and
column in that step.)
Step 3(b) gives the following table.

2 0 0 1

2 1 0 0

2 3 0 1

0 1 0 0
If there is now a surrounded zero in each row and
each column, the optimal assignment is obtained.
In our example, there is a surrounded zero in each
row and each column and so the optimal
assignment is:
Worker 1 is assigned to Job 2
Worker 2 is assigned to Job 4
Worker 3 is assigned to Job 3
Worker 4 is assigned to Job 1
And the optimal cost =
p1+p2+p3+p4+q1+q2+q3+q4= 20
If the final stage is reached (that is all the zeros
are either surrounded or crossed) and if there is no
surrounded zero in each row and column, it is not
possible to get the optimal solution at this stage.
We have to do some more work. Again we
illustrate with a numerical example.
Solve the following unbalanced assignment
problem (Only one job to one man and only one
man to one job):
7 5 8 4
5 6 7 4
8 7 9 8
Since the problem is unbalanced, we add a dummy
worker 4 with cost 0 and get the following starting
cost matrix:

7 5 8 4 p1=4
5 6 7 4 p2=4
8 7 9 8 p3=7
0 0 0 0 p4=0

Applying Step 1, we get the reduced cost matrix


3 1 4 0

1 2 3 0

1 0 2 1

0 0 0 0

Now Step 2 is Not needed. We now apply Step


3(a) and get the following table.
3 1 4 0

1 2 3 0

1 0 2 1

0 0 0 0

Now all the zeros are either surrounded or


crossed but there is no surrounded zero in Row 2.
Hence assignment is NOT possible. We go to
Step 4.
Step 4 (a) We now draw minimum number m of
vertical and horizontal lines to cover all the zeros.
Thus we draw 3 (2 vertical and one horizontal)
lines to cover all the zeros and get the following
table.
3 1 4 0

1 2 3 0

1 0 2 1

0 0 0 0
Step 4(b) Select the smallest element, say, u, from
among all elements uncovered by all the lines.
In our example, u = 1.
Step 4(c) Now subtract this u from all uncovered
elements but add this to all elements that lie at the
intersection of two lines. Doing this, we get the table:

2 1 3 0
0 2 2 0
0 0 1 1
0 1 0 1
Step 5: Reapply Step 3.
We thus get the table
2 1 3 0
0 2 2 0
0 0 1 1
0 1 0 1
Thus the optimum allocation is:
W1  J4 W2  J1 W3  J2 W4  J3
Hence Job 3 is not done by any (real) worker.
And the optimal cost = 16 (= p1+p2+p3+p4+u)
Problem 1(i) Problem Set 5.33 Page 243
Solve the Assignment Model

3 8 2 10 3 p1= 2
8 7 2 9 7 p2= 2
6 4 2 7 5 p3= 2
8 4 2 3 5 p4= 2

9 10 6 9 10 p5= 6

Applying Step 1, we get the reduced cost matrix


1 6 0 8 1

6 5 0 7 5

4 2 0 5 3

6 2 0 1 3

3 4 0 3 4

q 1 = 1 q 2 = 2 q 3 = 0 q 4 = 1 q5 = 1

Applying Step 2, we get the reduced cost matrix


0 4 0 7 0

5 3 0 6 4

3 0 0 4 2

5 0 0 0 2

2 2 0 2 3

Applying Step 3, we get the table


0 4 0 7 0

5 3 0 6 4

3 0 0 4 2

5 0 0 0 2

2 2 0 2 3

Now all the zeros are either surrounded or crossed


but there is no surrounded zero in Row 5. Hence
assignment is NOT possible. We go to Step 4.
0 4 0 7 0

5 3 0 6 4

3 0 0 4 2

5 0 0 0 2

2 2 0 2 3

Step 4(a) Thus we draw 4 (3 vertical and one


horizontal) lines to cover all the zeros and get
the above table.
Step 4(b) The smallest element, say, u, from among
all elements uncovered by all the lines is 2
Step 4(c) Now subtract this u(2) from all uncovered
elements but add this to all elements that lie at the
intersection of two lines. Doing this, we get the table:
0 6 2 9 0

3 3 0 6 2

1 0 0 4 0

3 0 0 0 0

0 2 0 2 1
We reapply Step 3.
0 6 2 9 0

3 3 0 6 2

1 0 0 4 0

3 0 0 0 0

0 2 0 2 1

Thus the optimum allocation is:


W1  J5, W2  J3, W3  J2, W4  J4, W5 J1
And the optimal cost = 21
Problem 1(ii) Problem Set 5.33 Page 243
Solve the Assignment Model

3 9 2 3 7 p1= 2
6 1 5 6 6 p2= 1
9 4 7 10 3 p3= 3
2 5 4 2 1 p4= 1

9 6 2 4 5 p5= 2

Applying Step 1, we get the reduced cost matrix


1 7 0 1 5

5 0 4 5 5

6 1 4 7 0

1 4 3 1 0

7 4 0 2 3

q 1 = 1 q 2 = 0 q 3 = 0 q 4 = 1 q5 = 0

Applying Step 2, we get the reduced cost matrix


0 7 0 0 5

4 0 4 4 5

5 1 4 6 0

0 4 3 0 0

6 4 0 1 3

Applying Step 3, we get the table


0 7 0 0 5

4 0 4 4 5

5 1 4 6 0

0 4 3 0 0

6 4 0 1 3

Remark: Now in Rows 1 and 4 (and also in


columns 1 and 4) there is no single zero. Now we
modify the step 3 for this situation as follows.
In row 1 we arbitrarily surround a zero and cross
all the remaining zeros in that row and in column 1.
Thus we get the table:
W J
0 7 0 0 5
1 1
4 0 4 4 5
2 3
5 1 4 6 0 3 5
0 4 3 0 0 4 4
6 4 0 1 3 5 3
Opt. Cost = 11
Now we are left with only one zero in row 4 and
surround it with a square and thus get the
optimum allocation:

You might also like