Assignment Problem
Assignment Problem
Assignment Problem
The assignment problem is one of the fundamental combinatorial optimization problems in the
branch of optimization or operations research in mathematics. It consists of finding a maximum
weight matching in a weighted bipartite graph.
There are a number of agents and a number of tasks. Any agent can be assigned to
perform any task, incurring some cost that may vary depending on the agent-task
assignment. It is required to perform all tasks by assigning exactly one agent to each task
in such a way that the total cost of the assignment is minimized.
If the numbers of agents and tasks are equal and the total cost of the assignment for all tasks is
equal to the sum of the costs for each agent (or the sum of the costs for each task, which is the
same thing in this case), then the problem is called the Linear assignment problem. Commonly,
when speaking of the Assignment problem without any additional qualification, then the Linear
assignment problem is meant.
Contents
[hide]
The assignment problem is a special case of the transportation problem, which is a special case
of the minimum cost flow problem, which in turn is a special case of a linear program. While it
is possible to solve any of these problems using the simplex algorithm, each specialization has
more efficient algorithms designed to take advantage of its special structure. If the cost function
involves quadratic inequalities it is called the quadratic assignment problem.
[edit] Example
Suppose that a taxi firm has three taxis (the agents) available, and three customers (the tasks)
wishing to be picked up as soon as possible. The firm prides itself on speedy pickups, so for each
taxi the "cost" of picking up a particular customer will depend on the time taken for the taxi to
reach the pickup point. The solution to the assignment problem will be whichever combination
of taxis and customers results in the least total cost.
However, the assignment problem can be made rather more flexible than it first appears. In the
above example, suppose that there are four taxis available, but still only three customers. Then a
fourth dummy task can be invented, perhaps called "sitting still doing nothing", with a cost of 0
for the taxi assigned to it. The assignment problem can then be solved in the usual way and still
give the best solution to the problem.
Similar tricks can be played in order to allow more tasks than agents, tasks to which multiple
agents must be assigned (for instance, a group of more customers than will fit in one taxi), or
maximizing profit rather than minimizing cost.
Given two sets, A and T, of equal size, together with a weight function C : A × T → R.
Find a bijection f : A → T such that the cost function:
is minimized.
Usually the weight function is viewed as a square real-valued matrix C, so that the cost function
is written down as:
The problem is "linear" because the cost function to be optimized as well as all the constraints
contain only linear terms.
The problem can be expressed as a standard linear program with the objective function
for ,
for .
The variable xij represents the assignment of agent i to task j, taking value 1 if the assignment is
done and 0 otherwise. This formulation allows also fractional variable values, but there is always
an optimal solution where the variables take integer values. This is because the constraint matrix
is totally unimodular. The first constraint requires that every agent is assigned to exactly one
task, and the second constraint requires that every task is assigned exactly one agent.
Hungarian algorithm
From Wikipedia, the free encyclopedia
Jump to: navigation, search
The Hungarian method is a combinatorial optimization algorithm which solves the assignment
problem in polynomial time and which anticipated later primal-dual methods. It was developed
and published by Harold Kuhn in 1955, who gave the name "Hungarian method" because the
algorithm was largely based on the earlier works of two Hungarian mathematicians: Dénes
Kőnig and Jenő Egerváry.
James Munkres reviewed the algorithm in 1957 and observed that it is (strongly) polynomial.
Since then the algorithm has been known also as Kuhn-Munkres algorithm or Munkres
assignment algorithm. The time complexity of the original algorithm was O(n4), however
Edmonds and Karp, and independently Tomizawa noticed that it can be modified to achieve an
O(n3) running time. Ford and Fulkerson extended the method to general transportation problems.
In 2006, it was discovered that Carl Gustav Jacobi had solved the assignment problem in the
19th century, and published posthumously in 1890 in Latin.[1]
Contents
[hide]
1 Layman’s Explanation
2 Setting
3 The algorithm in terms of bipartite graphs
4 Matrix interpretation
5 Bibliography
6 References
7 External links
o 7.1 Implementations
Then the Hungarian algorithm, when applied to the above table would give us the minimum cost
it can be done with: Jim cleans the bathroom, Steve sweeps the floors and Alan washes the
windows.
[edit] Setting
We are given a nonnegative n×n matrix, where the element in the i-th row and j-th column
represents the cost of assigning the j-th job to the i-th worker. We have to find an assignment of
the jobs to the workers that has minimum cost. If the goal is to find the assignment that yields the
maximum cost, the problem can be altered to fit the setting by replacing each cost with the
maximum cost subtracted by the cost.[2]
The algorithm is easier to describe if we formulate the problem using a bipartite graph. We have
a complete bipartite graph G=(S, T; E) with n worker vertices (S) and n job vertices (T), and
each edge has a nonnegative cost c(i,j). We want to find a perfect matching with minimum cost.
In a general step, let and be the vertices not covered by M (so RS consists of
the vertices in S with no incoming edge and RT consists of the vertices in T with no outgoing
edge). Let Z be the set of vertices reachable in from RS by a directed path only following
edges that are tight. This can be computed by breadth-first search.
If is nonempty, then reverse the orientation of a directed path in from RS to RT. Thus
the size of the corresponding matching increases by 1.
We repeat these steps until M is a perfect matching, in which case it gives a minimum cost
assignment. The running time of this version of the method is O(n4): M is augmented n times,
and in a phase where M is unchanged, there are at most n potential changes (since Z increases
every time). The time needed for a potential change is O(n2).
Step 1
Then we perform row operations on the matrix. To do this, the lowest of all ai (i belonging to 1-
4) is taken and is subtracted from each element in that row. This will lead to at least one zero in
that row (We get multiple zeros when there are two equal elements which also happen to be the
lowest in that row). This procedure is repeated for all rows. We now have a matrix with at least
one zero per row. Now we try to assign tasks to agents such that each agent is doing only one
task and the penalty incurred in each case is zero. This is illustrated below.
The zeros that are indicated as 0' are the assigned tasks.
Step 2
Sometimes it may turn out that the matrix at this stage cannot be used for assigning, as is the case
in for the matrix below.
In the above case, no assignment can be made. Note that task 1 is done efficiently by both agent
a and c. Both can't be assigned the same task. Also note that no one does task 3 efficiently. To
overcome this, we repeat the above procedure for all columns (i.e. the minimum element in each
column is subtracted from all the elements in that column) and then check if an assignment is
possible.
Step 3
In most situations this will give the result, but if it is still not possible to assign then the
procedure described below must be followed.
Initially assign as many tasks as possible then do the following (assign tasks in rows 2, 3 and 4)
Mark all rows having no assignments (row 1). Then mark all columns having zeros in that row(s)
(column 1). Then mark all rows having assignments in the given column (row 3). Repeat this till
a closed loop is obtained.
×
0 a2' a3' a4' ×
b1' b2' b3' 0'
0' c2' c3' c4' ×
d1' 0' d3' d4'
Now draw lines through all marked columns and unmarked rows.
×
0 a2' a3' a4' ×
b1' b2' b3' 0'
0' c2' c3' c4' ×
d1' 0' d3' d4'
The aforementioned detailed description is just one way to draw the minimum number of lines to
cover all the 0's. Other methods work as well.
Step 4
From the elements that are left, find the lowest value. Subtract this from the marked rows, and
add this to the marked columns.
Repeat the procedure (steps 1 -4) till an assignment is possible; this is when the minimum
number of lines used to cover all the 0's is equal to the max(number of people, number of
assignments), assuming dummy variables (usually the max cost) are used to fill in when the
number of people is greater than the number of assignments.
Basically you find the second minimum cost among the two rows. The procedure is repeated
until you are able to distinguish among the workers in terms of least cost.