Week2 Assignment Problem
Week2 Assignment Problem
J1 J2 J3 J4
M1 1 4 6 3
M2 9 7 10 9
M3 4 5 11 7
M4 8 7 8 5
Statement of problem:
Week 2 Page 1
Subject to:
Notice that:
Hungarian Method
Based on the idea obtained from above, that is, the optimal assignment is not
affected if a constant is added or subtracted from any row or column of the
standard assignment cost matrix (be aware that optimal cost will surely be
affected).
Now if all cij ¿ 0 and we can find a set of assignments x ij for which cij = 0 if
xij = 1, then these assignments xij got to be optimal.
Objective of procedure: To subtract a sufficiently large cost from several rows
or columns in such a way that an optimal (assignment) is found by inspection.
Note, this is possible only if we are able to produce sufficient number of
elements in the cost matrix which are zero. These zero elements are called
admissible elements (or cells) for allocations.
Steps:
1. For each row identify the smallest element. If the smallest element is
positive subtract it from the corresponding row. We next identify the
smallest element of each column. If the smallest element is positive
subtract it from the corresponding column.
2. To find some initial allocations
Allocations can be made among admissible cells only, and each row and
column can have at most one allocation. We first look for a row or
column in the array that has a single admissible cell. Make an allocation
is this admissible cell by under lining it and strike off all other
admissible cells in the column or row of the allocated cell. Repeat this
procedure until we reach a stage where each row and column without
allocations so far has two or more admissible cells (which have not been
struck off so far), make an allocation arbitrarily in one of these
admissible cells and strike off all the other admissible cells in the row
Week 2 Page 2
and the column of the allocated cell, and continue the procedure. The
procedure terminates when all the admissible cells are either allocated or
struck off. If each column (and therefore each row) has an allocation at
this stage, we stop as these allocations define an assignment which is
optimal. On the other hand, if some column has no allocation we remove
all the striking made and go to step 3.
3. The labeling Routine
1. Label every row that has no allocation at this stage with S.
2. Consider any labeled row, say row i. Look for an admissible cell in
this row. Suppose this cell is (i, j). If column j is unlabeled so far,
label this column with Ri, if column j is already labeled simply
skip this cell.
3. Consider any labeled column say column j. Look for an allocated
zero in this column. Let the position of this zero be (i, j). If row i is
unlabeled so far, label this column with Cj, if row i is already
labeled simply skip this cell.
Go through labeling rules 3.2 and 3.3 as often as possible. If at the
end of this process all the unallocated columns are still unlabeled we
have a non-break through and we go to step 4. On the other hand, if
during the labeling process an unallocated column gets a label we
have a break through (i.e. we can get one more allocation into the
array) and we go to step 5.
4. Further Reduction Routine
Cross out all labeled columns and all unlabeled rows (in fact these are
minimum number of lines that covered all the zeros and the number
of these lines is equal to the number of present allocations) and do the
following:
1. Select the smallest element that is not covered by the lines.
2. Subtract this number from all the elements that are not covered.
3. Add this number to all those covered elements that are at the
intersection of two lines.
4. Go back to step 3 and resume the labeling routine.
Week 2 Page 3
is Ck. Delete the present allocation in the cell (i, k), then look at the
label of column k and continue until a row with the label S is reached.
If all the columns have allocations stop, have found optimal
assignment, otherwise erase all the labels and go back to step 3, i.e.
start the labeling routine afresh.
Example 1:
J1 J2 J3
M1 5 7 9
M2 14 10 12
M3 15 13 16
J1 J2 J3
M1 0 2 4
M2 4 0 2
M3 2 0 3
M1 0 2 2
M2 4 0 0
M3 2 0 1
Week 2 Page 4
Then, the optimal assignment is: x11 = 1, x23 = 1, x32 = 1, with a total cost of 5
+ 12 +13 =30.
Example 2:
J1 J2 J3
M1 6 8 9
M2 5 10 12
M3 18 19 22
J1 J2 J3
M1 0 2 3
M2 0 5 7
M3 0 1 4
J1 J2 J3
M1 0 1 0
M2 0 4 4
M3 0 0 1
J1 J2 J3
M1 x 1 0
0
M2 0 4 4
M3 x 0 1
0
Week 2 Page 5
Then, the optimal assignment is: x13 = x21 = x32 = 1, with a total cost of 9 + 5
+19 =33.
Example 3:
J1 J2 J3 J4
M1 8 7 9 9
M2 5 2 7 8
M3 6 1 4 9
M4 2 3 2 6
M1 1 0 2 2
M2 3 0 5 6
M3 5 0 3 8
M4 0 1 0 4
M1 1 0 2 0
M2 3 0 5 4
M3 5 0 3 6
M4 0 1 0 2
M1 1 0 2 0
M2 3 0 5 4 C2
M3 5 0 3 6 S
Week 2 Page 6
M4 0 1 0 2
Column Labels R3
We next subtract 3 from each uncrossed cell and add 3 to doubly crossed cell
to get the following (after applying step 3) and resume labelling process:
J1 J2 J3 J4 Row Labels
M1 1 3 2 0
M2 0 0 2 1 C2
M3 2 0 0 3 S
M4 0 4 0 2
Column Labels R3 R3
Since an unallocated column has a label, we have a break through and execute
step 5:
J1 J2 J3 J4 Row Labels
M1 1 3 2 0
M2 0 0 2 1 C2
M3 2 0 0 3 S
M4 0 4 0 2
Column Labels R3 R3
As all the columns have allocations we stop. The optimal assignment is shown
above and the cost of the optimal assignment is: C 14 + C22 + C33 + C41 =
9+2+4+2=17. Note, there is an alternate optimal solution which is C 14 + C21 +
C22 + C41 = 9+5+1+2=17.
Example 4:
J1 J2 J3 J4
M1 1 4 6 3
M2 9 7 10 9
M3 4 5 11 7
Week 2 Page 7
M4 8 7 8 5
M1 0 3 5 2
M2 2 0 3 2
M3 0 1 7 3
M4 3 2 3 0
M1 0 3 2 2
M2 2 0 0 2
M3 0 1 4 3
M4 3 2 0 0
M1 0 3 2 2
x
M2 2 0 0 2
x
M3 0 1 4 3
x
M4 3 2 0 0
Week 2 Page 8
Column Labels R3
Due to non-break through case we execute the cross out phase of step 4
(crossed out labeled columns and unlabeled rows are shown colored):
J1 J2 J3 J4 Row Labels
M1 0 3 2 2 C1
M2 2 0 0 2
M3 0 1 4 3 S
M4 3 2 0 0
Column Labels R3
We next subtract 1 from each uncrossed cell and add 1 to doubly crossed cell
to get the following:
J1 J2 J3 J4 Row Labels
M1 0 2 1 1 C1
M2 3 0 0 2
M3 0 0 3 2 S
M4 4 2 0 0
Column Labels R3
We continue step 3:
J1 J2 J3 J4 Row Labels
M1 0 2 1 1 C1
M2 3 0 0 2 C2
M3 0 0 3 2 S
M4 4 2 0 0 C3
Column Labels R3 R3 R2 R4
Week 2 Page 9
Since an unallocated column has a label, we have a break through and execute
step 5:
J1 J2 J3 J4 Row Labels
M1 0 2 1 1 C1
M2 3 0 0 2 C2
M3 0 0 3 2 S
M4 4 2 0 0 C3
Column Labels R3 R3 R2 R4
As all the columns have allocations we stop. The optimal assignment is shown
above and the cost of the optimal assignment is = C11 + C23 + C32 + C44 =
1+10+5+5=21.
Example 5:
J1 J2 J3 J4 J5
M1 1 4 5 6 7
M2 1 8 3 4 5
M3 3 7 8 9 2
M4 4 5 6 7 8
M5 2 2 2 2 3
J1 J2 J3 J4 J5
M1 0 3 4 5 6
M2 0 7 2 3 4
M3 1 5 6 7 0
M4 0 1 2 3 4
M5 0 0 0 0 1
Week 2 Page 10
Since all columns have at least one zero in it we apply step 2 to get the
following tableau:
J1 J2 J3 J4 J5
M1 0 3 4 5 6
x
M2 0 7 2 3 4
M3 1 5 6 7 0
x
M4 0 1 2 3 4
x x x
M5 0 0 0 0 1
We then apply step 3 (the labeling routine):
J1 J2 J3 J4 J5 Row Labels
M1 0 3 4 5 6 C1
M2 0 7 2 3 4 S
M3 1 5 6 7 0
M4 0 1 2 3 4 S
M5 0 0 0 0 1
Column Labels R2
Due to non-break through case we execute the cross out phase of step 4
(crossed out labeled columns and unlabeled rows are shown colored):
J1 J2 J3 J4 J5 Row Labels
M1 0 3 4 5 6 C1
M2 0 7 2 3 4 S
M3 1 5 6 7 0
M4 0 1 2 3 4 S
x
M5 0 0 0 0 1
Column Labels R2
Week 2 Page 11
We next subtract 1 from each uncrossed cell and add 1 to doubly crossed cell
to get the following:
J1 J2 J3 J4 J5 Row Labels
M1 0 2 3 4 5 C1
M2 0 6 1 2 3 S
M3 2 5 6 7 0
M4 0 0 1 2 3 S
M5 1 0 0 0 1
Column Labels R2
We continue step 3:
J1 J2 J3 J4 J5 Row Labels
M1 0 2 3 4 5 C1
M2 0 6 1 2 3 S
M3 2 5 6 7 0
M4 0 0 1 2 3 S
M5 1 0 0 0 1 C2
Column Labels R2 R4 R5 R5
Since an unallocated column has a label, we have a break through and execute
step 5:
J1 J2 J3 J4 J5 Row Labels
M1 0 2 3 4 5 C1
M2 0 6 1 2 3 S
M3 2 5 6 7 0
M4 0 0 1 2 3 S
M5 1 0 0 0 1 C2
Column Labels R2 R4 R5 R5
Week 2 Page 12
Since column 4 is still without an allocation we erase all the existing labels
and go back to step 3 (i.e. start the labeling routine afresh).
J1 J2 J3 J4 J5 Row Labels
M1 0 2 3 4 5 C1
M2 0 6 1 2 3 S
M3 2 5 6 7 0
M4 0 0 1 2 3
M5 1 0 0 0 1
Column Labels R2
Due to non-break through case we execute the cross out phase of step 4
(crossed out labeled columns and unlabeled rows are shown colored):
J1 J2 J3 J4 J5 Row Labels
M1 0 2 3 4 5 C1
M2 0 6 1 2 3 S
M3 2 5 6 7 0
M4 0 0 1 2 3
M5 1 0 0 0 1
Column Labels R2
We next subtract 1 from each uncrossed cell and add 1 to doubly crossed cell
to get the following:
J1 J2 J3 J4 J5 Row Labels
M1 0 1 2 3 4 C1
M2 0 5 0 1 2 S
M3 3 5 6 7 0
M4 1 0 1 2 3
M5 2 0 0 0 1
Column Labels R2
We continue step 3:
Week 2 Page 13
J1 J2 J3 J4 J5 Row Labels
M1 0 1 2 3 4 C1
M2 0 5 0 1 2 S
M3 3 5 6 7 0
M4 1 0 1 2 3
M5 2 0 0 0 1 C3
Column Labels R2 R2 R5
Since an unallocated column has a label, we have a break through and execute
step 5:
J1 J2 J3 J4 J5 Row Labels
M1 0 1 2 3 4 C1
M2 0 5 0 1 2 S
M3 3 5 6 7 0
M4 1 0 1 2 3
M5 2 0 0 0 1 C3
Column Labels R2 R2 R5
As all the columns have allocations we stop. The optimal assignment is shown
above and the cost of the optimal assignment is = C 11 + C23 + C35 + C42 + C54=
1+3+2+5+2=13.
Exercise 6: Solve the Following Assignment Problem
J1 J2 J3 J4 J5
M1 2 5 7 6 8
M2 3 5 2 7 9
M3 6 3 2 4 3
M4 4 5 6 8 9
M5 9 8 1 7 4
Week 2 Page 14
Suppose there are n persons available for n jobs. Let p ij be the value you get
when person i works at job j. The problem is to choose an assignment of
persons to jobs to maximize the total value.
How to solve this problem?
We can convert this problem into a minimization problem by multiplying all
the entries of the matrix by –1. But this minimization problem can not be
solved by the algorithm developed earlier. The problem is of negative
elements. The problem can be overcome by adding suitable positive numbers
to the respective rows. These positive numbers can be taken as the maximum
of all the original elements in the respective rows.
Example 7: Solve the following (maximization) version of Assignment
Problem of Example 3:
J1 J2 J3 J4
M1 8 7 9 9
M2 5 2 7 8
M3 6 1 4 9
M4 2 3 2 6
J1 J2 J3 J4
M1 –8 –7 –9 –9
M2 –5 –2 –7 –8
M3 –6 –1 –4 –9
M4 –2 –3 –2 –6
Now add 9 to all the elements of the first row; 8 to all the elements of the
second row; 9 to all the elements of the third row; and 6 to all the elements of
the fourth row:
J1 J2 J3 J4
Week 2 Page 15
M1 1 2 0 0
M2 3 6 1 0
M3 3 8 5 0
M4 4 3 4 0
Now the algorithm can be applied to this matrix. Step 1 demand that we
should subtract 1 from column 1, and 2 from column 2 to get the following
matrix (where the result of step 2, 3 and 4 are also shown):
J1 J2 J3 J4 Row Labels
M1 x
0 0 x
0 x
0
M2 2 4 1 0 C4
M3 2 6 5 x
0 S
M4 3 1 4 x
0 S
Column Labels R3
We next subtract 1 from each uncrossed cell and add 1 to doubly crossed cell
to get the following (where continuation of step 3 is also shown):
J1 J2 J3 J4 Row Labels
M1 0 0 0 1 C2
M2 1 3 0 0 C4
M3 1 5 4 0 S
M4 2 0 3 0 S
Column Labels R4 R2 R3
Since an unallocated column (3) has a label ( R2), we have a break through and
execute step 5.
Week 2 Page 16
J1 J2 J3 J4 Row Labels
M1 0 0 0 1 C2
M2 1 3 0 0 C4
M3 1 5 4 0 S
M4 2 0 3 0 S
Column Labels R4 R2 R3
Since column 1 is still without an allocation we erase all the existing labels
and go back to step 3 (i.e. start the labeling routine afresh).
J1 J2 J3 J4 Row Labels
M1 0 0 0 1 C2
M2 1 3 0 0
M3 1 5 4 0 S
M4 2 0 3 0 C4
Column Labels R1 R4 R3
Since an unallocated column (1) has a label ( R1), we have a break through and
execute step 5.
J1 J2 J3 J4 Row Labels
M1 0 0 0 1 C2
M2 1 3 0 0
M3 1 5 4 0 S
M4 2 0 3 0 C4
Column Labels R1 R4 R3
As all the columns have allocations we stop. The optimal assignment is shown
above and the cost of the optimal assignment is = C 11 + C23 + C34 + C42 = 8 +
7 + 9 + 3 = 27.
Week 2 Page 17
Example 8: Solve the following (maximization) Assignment Problem.
Persons
P1 P2 P3 P4 P5 P6
Job 1 3 7 6 7 9 9
Job 2 12 8 9 3 4 6
Job 3 3 5 8 3 11 15
Job 4 6 4 2 3 8 5
Job 5 7 9 15 11 13 17
Job 6 3 4 6 7 9 10
P1 P2 P3 P4 P5 P6
Job 1 –3 –7 –6 –7 –9 –9
Job 2 –12 –8 –9 –3 –4 –6
Job 3 –3 –5 –8 –3 –11 –15
Job 4 –6 –4 –2 –3 –8 –5
Job 5 –7 –9 –15 –11 –13 –17
Job 6 –3 –4 –6 –7 –9 –10
Now add 9 to all the elements of the first row; 12 to all the elements of the
second row; 15 to all the elements of the third row; 8 to all the elements of the
fourth row; 17 to all the elements of the fifth row; 10 to all the elements of the
sixth row:
P1 P2 P3 P4 P5 P6
Job 1 6 2 3 2 0 0
Job 2 0 4 3 9 8 6
Job 3 12 10 7 12 4 0
Week 2 Page 18
Job 4 2 4 6 5 0 3
Job 5 10 8 2 6 4 0
Job 6 7 6 4 3 1 0
Now the algorithm can be applied to this matrix. Step 1 demand that we
should subtract 2 from columns 2, 3, and 4 to get the following matrix (where
the result of step 2 is also shown):
P1 P2 P3 P4 P5 P6
Job 1 6 0 1 x x x
0 0 0
Job 2 0 2 1 7 8 6
Job 3 12 8 5 10 4 0
Job 4 2 2 4 3 0 3
Job 5 10 6 0 4 4 x
0
Job 6 7 4 2 1 1 x
0
We then apply step 3 (the labeling routine) and due to non-break through case
we execute the cross out phase of step 4 as well (crossed out labeled columns
and unlabeled rows are shown colored):
P1 P2 P3 P4 P5 P6 Row Labels
Job 1 6 0 1 0 0 0
Job 2 0 2 1 7 8 6
Job 3 12 8 5 10 4 0 C6
Job 4 2 2 4 3 0 3
Job 5 10 6 0 4 4 0
Job 6 7 4 2 1 1 0 S
Column Labels R
6
Week 2 Page 19
We next subtract 1 from each uncrossed cell and add 1 to doubly crossed cell
to get the following (where continuation of step 3 is also shown):
P1 P2 P3 P4 P5 P6 Row Labels
Job 1 6 0 1 0 0 1
Job 2 0 2 1 7 8 7
Job 3 11 7 4 9 3 0 C6
Job 4 2 2 4 3 0 4 C5
Job 5 10 6 0 4 4 1
Job 6 6 3 1 0 0 0 S
Column Labels R R R
6 6 6
Since an unallocated column has a label, we have a break through and execute
step 5. This simply means that cell C64 can now be allocated. Hence optimal
assignment is given by X12 = X21 = X36 = X45 = X53 = X64 = 1. The value of his
assignment is C12 + C21 + C36 + C45 + C53 + C64 = 7 + 12 + 15 + 8 + 15 + 7 =
64.
Example 6: Transportation Problem Revisited
Prob. 3 (Ravindran, Phillips and Solberg)
Consider the problem of scheduling the weekly production of a certain item
for the next four weeks. The production cost for the item is $10 for the first
two weeks and $15 for the last two weeks. The weekly demands are 300, 700,
900 and 800, which must be met. The plant can produce a maximum of 700
units each week. In addition, the company can employ overtime during the
second and third week. This increases the daily production by an additional
200 units, but the production cost increases by $5 per item. Excess production
can be stored at a unit cost of $3/week.
How should production be scheduled so as to minimize the total costs?
This problem can be expressed as a transportation problem as follows:
Week 2 Page 20
10 13 16 19
Week 2-n 700
M 10 13 16
Week 2-o 200
M 15 18 21
Week 3-n 700
M M 15 18
Week 3-o 200
M M 20 23
Week 4-n 700
M M M 15
Supplies 300 700 900 800
Week 2 Page 21
M M 20 23 0
Week 4-n 700
M M M 15 0
Supplies 300 700 900 800 500
Week 2 Page 22
Week 2-n M 300 400 0 –1 –3
M 10 13 16 0
Week 2-o M 0 200 4 –6 2
M 15 18 21 0
Week 3-n M M 300 400 –3 –1
M M 15 18 0
Week 3-o M M 8 8 200 –4
M M 20 23 0
Week 4-n M M M 400 300 –4
M M M 15 0
V 10 13 16 19 4
Cost of above solution: 37,700. After adding 200 to recipient cell and
subtracting it from donor cell we get the following tableau:
Demands U
Supplies Week 1 Week 2 Week 3 Week 4 Dummy
300 400 0 0 –4 0
Week 1-n
10 13 16 19 0
M 300 400 0 –1 –3
Week 2-n
M 10 13 16 0
Week 2-o M 6 6 6 200 –4
M 15 18 21 0
M M 500 200 –3 –1
Week 3-n
M M 15 18 0
Week 3-o M M 8 8 200 –4
Week 2 Page 23
M M 20 23 0
M M M 600 100 –4
Week 4-n
M M M 15 0
v 10 13 16 19 4
Cost of above solution: 36,500. After adding 100 to recipient cell and
subtracting it from donor cell we get the following tableau:
Demands U
Supplies Week 1 Week 2 Week 3 Week 4 Dummy
300 300 0 0 100 0
Week 1-n
10 13 16 19 0
M 400 300 0 3 –3
Week 2-n
M 10 13 16 0
Week 2-o M 2 2 2 200 0
M 15 18 21 0
M M 600 100 1 –1
Week 3-n
M M 15 18 0
Week 3-o M M 4 4 200 0
M M 20 23 0
M M M 700 4 –4
Week 4-n
M M M 15 0
v 10 13 16 19 0
As the entire relative cost co-efficient are non-negative, the current solution is
optimal and the minimum cost solution is 36,100.
Week 2 Page 24
Week 2 Page 25