Lecture 4-5: Assignment Problem: Feng Pan
Lecture 4-5: Assignment Problem: Feng Pan
Hungarian Algorithm
Auction Algorithm
1/26/2012, 1/31/2012
Feng Pan
Outline
Hungarian Algorithm
Auction Algorithm
Feng Pan
Breaststroke (1)
7
6
5
8
Backstroke (2)
6
10
7
5
Butterfly (3)
5
7
10
6
Feng Pan
Freestyle (4)
5
4
7
10
LP Formulation
Let I = {1, 2, 3, 4} be the index set for the swimmers and
J = {1, 2, 3, 4} be the index set for strokes.
Let aij be the average time for 100 meter by swimmer i with
stroke j.
xij is a binary decision variable. xij = 1 if assigning swimmer i to
stroke j.
min
x
s.t.
XX
aij xij
(1)
iI jJ
xij = 1,
i I
(2)
xij = 1,
j J
(3)
i I, j J.
(4)
jJ
X
iI
xij 0,
Feng Pan
Job Assignment
Product 1
12
6
8
9
10
Product 2
6
8
11
12
7
Product 3
8
7
12
6
12
Product 4
7
10
5
11
9
Feng Pan
LP Formulation
Let I = {1, 2, 3, 4, 5} be the index set for the factories and
J = {1, 2, 3, 4, 5} be the index set for the products with 5 being a
dummy product.
Let aij be production rate of product j at factory i. Set ai5 = 0 for
i I.
xij is a binary decision variable. xij = 1 if factory i manufacture
product j.
max
x
s.t.
XX
aij xij
(5)
iI jJ
xij = 1,
i I
(6)
xij = 1,
j J
(7)
i I, j J.
(8)
jJ
X
iI
xij 0,
Feng Pan
iI jJ
iI jJ
iI jJ
Feng Pan
iI jJ
Hungarian Algorithm
Given the cost matrix for an n n assignment problem.
1
Goto step 3.
Feng Pan
Example 1a
2
6
2
3
3
7
0
1
3
0
1
5
6
0
2
0
5
0
0
2
4
1
3
2
Feng Pan
jJ
jJ
Feng Pan
Example 1b-1
2
6
7
3
3
2
1
0
2
4
1
5
6
0
2
0
0
0
0
2
4
1
3
2
Feng Pan
Example 1b-2
0
2
4
2
0
0
2
4
X
X
For each row with one 0, circle the 0 and cross out the 0s in the
column.
For each column with one 0, circle the 0 and cross out the 0s in
the row.
Example 1b-3
X
0
2
4
2
0
0
0
0
2
4
0
2
X
X
4
0
0
0
2
X
X
Feng Pan
Example 1b-3
Feng Pan
Example 1b
0
0
0
2
Feng Pan
3
3
2
1
0
2
4
1
5
6
0
2
0
0
0
0
2
4
1
3
2
Feng Pan
Primal-Dual Solution: RP
0
2
4
2
0
0
2
4
X
X
Feng Pan
0
0
2
4
0
0
0
2
X
X
= +
Feng Pan
0
0
2
4
0
0
0
2
X
X
= +
Feng Pan
Example 2a
7
6
5
8
6
10
7
5
5
7
10
6
0
2
2
0
3
5
4
7
10
0
1
6
2
0
0
0
3
5
1
0
0
0
2
5
5
4
5
5
Feng Pan
Example 2b-1
7
7
8
8
6
10
7
6
5
7
10
10
2
0
1
1
1
5
4
5
5
1
0
5
1
0
0
0
3
5
5
0
0
0
0
0
5
4
5
5
Feng Pan
Example 2b-2
2
0
1
1
1
X
5
3
5
0
0
4
5
1
1
5
1
0
5
1
0
3
5
0
0
X
X
Example 2b-3
X
0
1
1
5
1
0
3
5
0
0
0
X
X
X
0
0
4
0
0
2
4
1
0
0
X
X
Example 2b
7
7
8
8
6
10
7
6
5
7
10
10
5
4
5
5
0
0
0
0
For each row with one 0, circle the 0 and cross out the 0s in the
column.
For each column with one 0, circle the 0 and cross out the 0s in
the row.
Auction Algorithm
Consider a maximum assignment problem.
XX
max
aij xij
x
s.t.
(9)
iI jJ
xij = 1,
i I
(10)
xij = 1,
j J
(11)
i I, j J.
(12)
jJ
X
iI
xij 0,
Example 1a-1
Convert Example 1a to a maximum assignment problem. Rows are
people and columns are items. The number cij is the prize of item j to
person i.
6
2
6
5
5
1
7
3
2
Feng Pan
The difference between the highest profit and the second highest
profit is
ij = (cij pj ) max
{cij pj }.
j6=j
Feng Pan
Auction Algorithm
Feng Pan
Example 1a-2
6
2
6
5
5
1
7
3
2
bid bij
1
2
3
b13 = 1
b2,2 = 3
b31 = 5
Feng Pan
price
(0,0,0)
(0, 0, 1)
(0,3,1)
(5,3,1)
assignment
{(1, 3)}
{(1, 3), (2, 2)}
{(1, 3), (2, 2), (3, 1)}
Example 1a-3
6
2
6
5
5
1
7
3
2
Assignment: {(1, 3), (2, 2), (3, 1)} and prices: (1,2,4).
Feng Pan
bid bij
1
2
3
2
b13 = 1
b22 = 3
b32 = 3 + 2
b21 = 0
5
5
6
7
3
2
price
(0,0,0)
(0,0,1)
(0,3,1)
(0,5,1)
(0,5,1)
Feng Pan
assignment
{(1, 3)}
{(1, 3), (2, 2)}
{(1, 3), (3, 2)}
{(1, 3), (3, 2), (2, 1)}
5
5
6
7
3
2
4
5
5
5
6
7
3
2
bid bij
1
2
3
2
1
2
b13 = 1
b22 = 3
b32 = 3 + 2
b23 = 1 + 0
b13 = 1 + 0
b23 = 1 + 0
..
.
price
(0,0,0)
(0,0,1)
(0,3,1)
(0,5,1)
(0,5,1)
(0,5,1)
(0,5,1)
assignment
{(1, 3)}
{(1, 3), (2, 2)}
{(1, 3), (3, 2)}
{(2, 3), (3, 2)}
{(1, 3), (3, 2)}
{(2, 3), (3, 2)}
j6=j
Feng Pan
Example 1b-3
Two items have the same value for two persons. Bidding price is
not changing.
Break the tie by adding = 0.2 to each bid.
6
2
1
person
bid bij
1
2
3
2
b13 = 0 + 1 + 0.2
b22 = 0 + 3 + 0.2
b32 = 3.2 + 1.8 + 0.2
b21 = 0 + 0.2 + 0.2
Feng Pan
5
5
6
7
3
2
price
(0,0,0)
(0,0,1.2)
(0,3.2,1.2)
(0,5.2,1.2)
(0.4,5.2,1.2)
assignment
{(1, 3)}
{(1, 3), (2, 2)}
{(1, 3), (3, 2)}
{(1, 3), (3, 2), (2, 3)}
Feng Pan