Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Assignment

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

The Assignment Problem and the Hungarian

Algorithm
Jesús Omar Ocegueda González

TABLE I
Abstract— In the last homework we dealt with the
D UMMY VARIABLES FOR ]F < ]D
“Transportation Problem” and used the Simplex Method to
solve it. The Assignment problem is a particular case of this
problem in which we have exactly the same numbre of “factories” d1 d2 ... dn−1 dn
and “distribution centers”, and the capacities of the “factories” f1 c11 c12 ... c1(n−1) c1n
as well as the demand of the “distribution centers” are exactly ... ... ... ... ... ...
one. Then the problem can be stated as “Assign each elemnt fi
fm cm1 cm2 ... cm(n−1) cmn
of a set F to exactly P
one element d(fi ) of another set D, in such
n
a way that the sum i=1
c(fi , d(fi )) takes its minimum value”. fˆm+1 0 0 ... 0 0
Here, c(x, y) is a function F × D → R wich tells us the cost of ... ... ... ... ... ...
assigning the element y to the element x.
fˆn 0 0 ... 0 0
It is expected that, being a so particular problem, this problem
can be solved with a more effitient method than the Simplex
one, this is the case of the Hungarian algorithm. In the first j = 1, 2, ..., n (see table I). We argue that if {xij }, i, j =
part of this homework I discribe the general formulation for
the assignment problem. In the second part I will describe the
1, ..., n are optimum assignments for the new problem,
Hungarian algorithm and some implementation details. I show then the restriction {xij }, i = 1, ..., m; j = 1, ..., n is
the results obtained by applying the Hungarian algorithm when an optimum assignment for the original one. To proof is
proving it with various examples. The conclusions are given in the strightforward by noting that for any {xij },
last part.
n
X n
X
ckj xkj = 0,
k=m+1 j=1
I. I NTRODUCTION then m X
n
ET F and D be two sets with the same finite cardinality
L
X
ckj xkj
n. Let also be cij be the cost of make the assignment
k=1 j=1
i → j, i ∈ F, j ∈ D. Define the variables
 is the minimum value of the objective function for any
1 if we assign the element j ∈ D to the element i ∈ F optimum choice of {xij } for the new problem.
xij =
0 if not 2) In fact, the case n < m is exactly the same as the case
The problem is m < n, we just “change the names” of F and D. This
n X
n is the advantage of stating the problem in terms of sets
instead of “carpets” and “workers”.
X
M inimize tij xij
i=1 j=1
II. T HE H UNGARIAN A LGORITHM
subject to
n
X We can assume that F and D have the same finite cardi-
xij = 1 ∀j = 1, 2, ..., n nality. Let C be the costs matrix whose elements are cij . The
i=1 Hungarian Algorithm consists in the following steps:
n
X 1) For each row in C substract the smallest entry of the row
xij = 1 ∀i = 1, 2, ..., n from all entries of it.
i=j
2) For each column in C substract the smallest entry of the
If the sets F and D have different cardinalities, we can column from all entries of it.
easily find an equivalent problem in which the cardinalities 3) If a solution (assignment) with all zero entries can be
are the same. I will describe the procedure for both cases: let identified, then it is an optimal solution. If not, go to
m and n be the cardinalities of F and D respectively step 4.
4) Redistribute the zeros in the matrix and go back to step
1) Supose m < n. Add the n − m variables F̂ = 3.
{fˆm+1 , ..., fˆn } to F. Define the costs ckj = 0 ∀ k > m, Step 3 can be decompose in the next steps:
TABLE II TABLE III
A SSIGNMENT COSTS FOR PROBLEM 1 S OLUTION MATRIX FOR PROBLEM 1

d1 d2 d3 d4 d5 d6 d7 d8 d9 d10 d1 d2 d3 d4 d5 d6 d7 d8 d9 d10
f1 3 3 10 9 5 2 11 2 11 5 f1 1 2 7 7 3 0 8 0 9 3
f2 6 2 7 11 4 10 4 4 5 4 f2 3 0 3 8 1 7 0 1 2 1
f3 9 7 9 10 4 4 5 5 4 5 f3 5 4 4 6 0 0 0 1 0 1
f4 8 6 7 8 8 8 10 6 3 9 f4 5 4 3 5 5 5 6 3 0 6
f5 7 2 8 6 10 9 6 6 11 10 f5 4 0 4 3 7 6 2 3 8 7
f6 5 11 3 6 10 3 6 7 2 10 f6 3 10 0 4 8 1 3 5 0 8
f7 4 11 11 5 9 11 7 9 10 11 f7 0 8 6 1 5 7 2 5 6 7
f8 11 10 5 4 11 4 7 8 7 3 f8 8 8 1 1 8 1 3 5 4 0
f9 11 5 5 3 2 5 7 10 7 3 f9 9 4 2 1 0 3 4 8 5 1
f10 10 4 5 2 11 6 11 7 8 2 f10 8 3 2 0 9 4 8 5 6 0

TABLE IV
1) Chose the row or column with the minimum positive A SSIGNMENT COSTS FOR PROBLEM 2
number of zeros (if there are more than one with this
d1 d2 d3 d4 d5
minimum number of zeros, choose arbitrarly). If a row
was selected, trace a vertical line through one of the zeros f1 6 8 7 18 6
of the selected row. If a column was selected, trace a f2 9 4 3 4 12
horizontal line through one of the zeros of the selected f3 12 5 2 10 8
column.
2) Repeat step 3 ignoring any zeros with a line through it
until each zero has at least one line through it. In table IV we can see the assignment costs for this problem,
3) If exactly n lines have been drawn, an optimal set of where m = 3, n = 5. In table V I show the solution matrix
zeros is present. If less than n lines were needed, go to for this problem. Note that two rows were added and we have
step 4 (we have no solution at hand yet). (Note that we many posible solutions, one of them is marked on the table.
will draw at most n lines to cross all zeros in the table) The final cost of this solution is 12.
and the step 4 can be decomposed in the next steps (remember
that all zeros have at least one line through it):
1) Substract the minimum entry in the actual table with no C. Problem 3.
line through it from each entry with no line through it. The next is the same as the example 2 taking the transpose
2) Add the number substracted in step 4 − 1 to each entry of the matrix cost. The objective of this example is to show
of the actual table which has two lines through it. simetry of the cases m < n and n < m. We must note that
3) Remove all lines. the solution matrix of one could be different of the transpose
of the solution matrix of the other (this is just a conjeture of
III. R ESULTS mine), in fact depending on the order in which we draw the
Now I will show the results obtained by applying the initial lines, we could have different sets of solutions. In table
Hungarian Algorithm to three problems. The first one is the VII I show the solution matrix for this example, in this case we
example given in the book we are following... could find the same solution as in example 2... and surprisinly,
at least for me, the solution matrices are the same (except by
transpositions).
A. Problem 1.
In table II we can see the costs matrix. In this example both F
and D have the same cardinality. The final matrix (from which TABLE V
we can easily obtain a solution) is shown in table III, in which S OLUTION MATRIX FOR PROBLEM 2
I remarked the selected zeros that form the final solution. The
d1 d2 d3 d4 d5
final cost of this solution is 29, which coincides with the value
of the book in both, the optimum value and the assigments but f1 0 2 2 12 0
the final matrix is indeed different. f2 5 0 0 0 8
f3 9 2 0 7 5

B. Problem 2. f4 0 0 1 0 0
f5 0 0 1 0 0
The next is an example of the case in wich m < n.
TABLE VI
A SSIGNMENT COSTS FOR PROBLEM 3

d1 d2 d3
f1 6 9 12
f2 8 4 5
f3 7 3 2
f4 18 4 10
f5 6 12 8

TABLE VII
S OLUTION MATRIX FOR PROBLEM 3

d1 d2 d3 d4 d5
f1 0 5 9 0 0
f2 2 0 2 0 0
f3 2 0 0 1 1
f4 12 0 7 0 0
f5 0 8 5 0 0

IV. C ONCLUSION
I introduced the Assignment problem, which is a particular
case of the Transportation problem seen in the last homework.
I described the Hungarian Algorithm and applied it to solve
three problems. Finally, I conjectured that if two matrices A
and B are such that AT = B then it is not necesarily true that
the final matrices got using the Hungarian method  and B̂
maintain the property ÂT = B̂.

You might also like