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

Assignment Method

The assignment problem involves assigning n agents to n tasks to minimize the total cost, where each agent can be assigned to any task with a given cost. It can be modeled as finding a minimum cost matching in a weighted bipartite graph. The Hungarian algorithm solves it in polynomial time by finding augmenting paths to improve the matching. The unbalanced version with unequal numbers of agents and tasks can be reduced to the balanced case.

Uploaded by

ziontesalona2
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Assignment Method

The assignment problem involves assigning n agents to n tasks to minimize the total cost, where each agent can be assigned to any task with a given cost. It can be modeled as finding a minimum cost matching in a weighted bipartite graph. The Hungarian algorithm solves it in polynomial time by finding augmenting paths to improve the matching. The unbalanced version with unequal numbers of agents and tasks can be reduced to the balanced case.

Uploaded by

ziontesalona2
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

The assignment problem is a fundamental combinatorial optimization problem.

In its most The problem is "linear" because the cost function to be optimized as well as all the
general form, the problem is as follows: constraints contain only linear terms.

The problem instance has 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- AlgorithmsEdit
task assignment. It is required to perform as many tasks as possible by assigning at most one
A naive solution for the assignment problem is to check all the assignments and calculate
agent to each task and at most one task to each agent, in such a way that the total cost of
the cost of each one. This may be very inefficient since, with n agents and n tasks, there
the assignment is minimized.
are n! (factorial of n) different assignments. Fortunately, there are many algorithms for
Alternatively, describing the problem using graph theory: solving the problem in time polynomial in n.

The assignment problem consists of finding, in a weighted bipartite graph, a matching of a The assignment problem is a special case of the transportation problem, which is a special
given size, in which the sum of weights of the edges is minimum. 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
If the numbers of agents and tasks are equal, then the problem is called balanced
specialization has a small solution space and thus more efficient algorithms designed to take
assignment. Otherwise, it is called unbalanced assignment.[1] If the total cost of the
advantage of its special structure.
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 linear Balanced assignmentEdit
assignment. Commonly, when speaking of the assignment problem without any additional
In the balanced assignment problem, both parts of the bipartite graph have the same
qualification, then the linear balanced assignment problem is meant.
number of vertices, denoted by n.

One of the first polynomial-time algorithms for balanced assignment was the Hungarian
algorithm. It is a global algorithm – it is based on improving a matching along augmenting
Formal definitionEdit paths (alternating paths between unmatched vertices). Its run-time complexity, when
using Fibonacci heaps, is ,[2] where m is a number of edges. This is currently the fastest run-
The formal definition of the assignment problem (or linear assignment problem) is
time of a strongly polynomial algorithm for this problem. If all weights are integers, then the
Given two sets, A and T, of equal size, together with a weight function C : A × T → R. Find run-time can be improved to , but the resulting algorithm is only weakly-polynomial.[3] If
a bijection f : A → T such that the cost function: is minimized. the weights are integers, and all weights are at most C (where C>1 is some integer), then the
problem can be solved in weakly-polynomial time in a method called weight scaling.[4][5]
Usually the weight function is viewed as a square real-valued matrix C, so that the cost [6]
function is written down as:
In addition to the global methods, there are local methods which are based on finding local
updates (rather than full augmenting paths). These methods have worse asymptotic runtime
guarantees, but they often work better in practice. These algorithms are called auction
algorithms, push-relabel algorithms, or preflow-push algorithms. Some of these algorithms All in all, at most new edges are required. The resulting graph always has a perfect
were shown to be equivalent.[7] matching of size . A minimum-cost perfect matching in this graph must consist of minimum-
cost maximum-cardinality matchings in Gf and Gb. The main problem with this doubling
Some of the local methods assume that the graph admits a perfect matching; if this is not
technique is that there is no speed gain when .
the case, then some of these methods might run forever.[1]: 3 A simple technical way to
solve this problem is to extend the input graph to a complete bipartite graph, by adding Instead of using reduction, the unbalanced assignment problem can be solved by directly
artificial edges with very large weights. These weights should exceed the weights of all generalizing existing algorithms for balanced assignment. The Hungarian algorithm can be
existing matchings, to prevent appearance of artificial edges in the possible solution. generalized to solve the problem in strongly-polynomial time. In particular, if s=r then the
runtime is . If the weights are integers, then Thorup's method can be used to get a runtime
As shown by Mulmuley, Vazirani and Vazirani,[8] the problem of minimum weight perfect
of .[1]: 6
matching is converted to finding minors in the adjacency matrix of a graph. Using
the isolation lemma, a minimum weight perfect matching in a graph can be found with Solution by linear programmingEdit
probability at least ½. For a graph with n vertices, it requires time.
The assignment problem can be solved by presenting it as a linear program. For convenience
Unbalanced assignmentEdit we will present the maximization problem. Each edge (i,j), where i is in A and j is in T, has a
weight . For each edge we have a variable . The variable is 1 if the edge is contained in the
In the unbalanced assignment problem, the larger part of the bipartite graph has n vertices
matching and 0 otherwise, so we set the domain constraints:
and the smaller part has r<n vertices. There is also a constant s which is at most the
cardinality of a maximum matching in the graph. The goal is to find a minimum-cost
matching of size exactly s. The most common case is the case in which the graph admits a
one-sided-perfect matching (i.e., a matching of size r), and s=r.
The total weight of the matching is: . The goal is to find a maximum-weight perfect
Unbalanced assignment can be reduced to a balanced assignment. The naive reduction is to
matching.
add new vertices to the smaller part and connect them to the larger part using edges of
cost 0. However, this requires new edges. A more efficient reduction is called the doubling To guarantee that the variables indeed represent a perfect matching, we add constraints
technique. Here, a new graph G' is built from two copies of the original graph G: a forward saying that each vertex is adjacent to exactly one edge in the matching, i.e,
copy Gf and a backward copy Gb. The backward copy is "flipped", so that, in each side of G',
there are now n+r vertices. Between the copies, we need to add two kinds of linking edges:
[1]: 4–6 .
 Large-to-large: from each vertex in the larger part of Gf, add a zero-cost edge to the All in all we have the following LP:
corresponding vertex in Gb.
This is an integer linear program. However, we can solve it without the integrality
 Small-to-small: if the original graph does not have a one-sided-perfect matching, constraints (i.e., drop the last constraint), using standard methods for solving continuous
then from each vertex in the smaller part of Gf, add a very-high-cost edge to the linear programs. While this formulation allows also fractional variable values, in this special
corresponding vertex in Gb.
case, the LP always has an optimal solution where the variables take integer values. This is problem (and the more general maximum weight matching problem), which runs in linear
because the constraint matrix of the fractional LP is totally unimodular – it satisfies the four time for any fixed error bound.
conditions of Hoffman and Gale.
Assignment Problem: Meaning, Methods and Variations | Operations Research
This can also be proved directly.[9]: 31–37 Let x be an optimal solution of the fractional
Meaning of Assignment Problem:
LP, be its total weight, and be the number of non-integral variables. If we are done.
Otherwise, there is a fractional variable, say . Because the sum of variables adjacent to is 1, An assignment problem is a particular case of transportation problem where the objective is
which in an integer, there must be another variable adjacent to j2 with a fractional value, to assign a number of resources to an equal number of activities so as to minimise total cost
say . By similar considerations on i3, there must be another variable adjacent to i3 with a or maximize total profit of allocation.
fractional value, say . By similar considerations we move from one vertex to another,
collecting edges with fractional values. Since the graph is finite, at some point we must have The problem of assignment arises because available resources such as men, machines etc.
a cycle. Without loss of generality we can assume that the cycle ends at vertex i1, so the last have varying degrees of efficiency for performing different activities, therefore, cost, profit
fractional variable in the cycle is . So the number of edges in the cycle is 2m – it must be or loss of performing the different activities is different.
even since the graph is bipartite. Thus, the problem is “How should the assignments be made so as to optimize the given
Suppose we add a certain constant e to all even variables in the cycle, and remove the same objective”. Some of the problem where the assignment technique may be useful are
constant e from all odd variables in the cycle. For any such e, the sum of variables near each assignment of workers to machines, salesman to different sales areas.
vertex remains the same (1), so the vertex constraints are still satisfied. Moreover, if e is Definition of Assignment Problem:
sufficiently small, all variables remain between 0 and 1, so the domain constraints are still
satisfied too. It is easy to find a largest e that maintains the domain constraints: it is either Suppose there are n jobs to be performed and n persons are available for doing these jobs.
the smallest difference between an odd variable and 0, or the smallest difference between Assume that each person can do each job at a term, though with varying degree of
an even variable and 1. Now, we have one less fractional variable, so k(x) decreases by 1. efficiency, let cij be the cost if the i-th person is assigned to the j-th job. The problem is to
The objective value remains the same, since otherwise we could increase it by selecting e to find an assignment (which job should be assigned to which person one on-one basis) So that
be positive or negative, in contradiction to the assumption that it is maximal. the total cost of performing all jobs is minimum, problem of this kind are known as
assignment problem.
By repeating the cycle-removal process we arrive, after at most n steps, at a solution in
which all variables are integral

Other methods and approximation algorithmsEdit

Other approaches for the assignment problem exist and are reviewed by Duan and
Pettie[10] (see Table II). Their work proposes an approximation algorithm for the assignment
The assignment problem can be stated in the form of n x n cost matrix C real members as The Hungarian method of assignment provides us with an efficient method of finding the
given in the following table: optimal solution without having to make a-direct comparison of every solution. It works on
the principle of reducing the given cost matrix to a matrix of opportunity costs.

Opportunity cost show the relative penalties associated with assigning resources to an
activity as opposed to making the best or least cost assignment. If we can reduce the cost
matrix to the extent of having at least one zero in each row and column, it will be possible to
make optimal assignment.

The Hungarian method can be summarized in the following steps:

Step 1: Develop the Cost Table from the given Problem:

ADVERTISEMENTS:
Mathematical Formulation of the Assignment Problem:
If the no of rows are not equal to the no of columns and vice versa, a dummy row or dummy
column must be added. The assignment cost for dummy cells are always zero.

Step 2: Find the Opportunity Cost Table:

(a) Locate the smallest element in each row of the given cost table and then subtract that
from each element of that row, and

(b) In the reduced matrix obtained from 2 (a) locate the smallest element in each column
and then subtract that from each element. Each row and column now have at least one zero
value.

Step 3: Make Assignment in the Opportunity Cost Matrix:

The procedure of making assignment is as follows:

(a) Examine rows successively until a row with exactly one unmarked zero is obtained. Make
an assignment single zero by making a square around it.

(b) For each zero value that becomes assigned, eliminate (Strike off) all other zeros in the
same row and/ or column
Hungarian Method for Solving Assignment Problem:
(c) Repeat step 3 (a) and 3 (b) for each column also with exactly single zero value all that has (b) Subtract K from every element in the cell not covered by line.
not been assigned.
(c) Add K to very element in the cell covered by the two lines, i.e., intersection of two lines.
(d) If a row and/or column has two or more unmarked zeros and one cannot be chosen by
(d) Elements in cells covered by one line remain unchanged.
inspection, then choose the assigned zero cell arbitrarily.
Step 7: Repeat Step 3 to 6 Unlit an Optimal Solution is Obtained:
(e) Continue this process until all zeros in row column are either enclosed (Assigned) or
struck off (x)

Step 4: Optimality Criterion:

If the member of assigned cells is equal to the numbers of rows column then it is optimal
solution. The total cost associated with this solution is obtained by adding original cost
figures in the occupied cells.

If a zero cell was chosen arbitrarily in step (3), there exists an alternative optimal solution.
But if no optimal solution is found, then go to step (5).

Step 5: Revise the Opportunity Cost Table:

Draw a set of horizontal and vertical lines to cover all the zeros in the revised cost table
obtained from step (3), by using the following procedure:

(a) For each row in which no assignment was made, mark a tick (√)

(b) Examine the marked rows. If any zero occurs in those columns, tick the respective rows
that contain those assigned zeros.

(c) Repeat this process until no more rows or columns can be marked.

(d) Draw a straight line through each marked column and each unmarked row.

If a no of lines drawn is equal to the no of (or columns) the current solution is the optimal
solution, otherwise go to step 6.

Step 6: Develop the New Revised Opportunity Cost Table:

(a) From among the cells not covered by any line, choose the smallest element, call this
value K
Example:

1. In a computer centre after studying carefully the three expert programmes, the head of
computer centre, estimates the computer time in minutes required by the experts for the
application programmes as follows:

Assign the programmers to the programmes in such a way that the total computer time is
minimum.

Solution:

The Hungarian method is used to obtain an optimal solution.

Step (1) & (2):

The minimum time element in row 1, 2 and 3 is 80, 80 and 110. resp. Subtract these
elements from all elements in this respective row.

The reduced time matrix is shown in following table (1) Table 1:

In reduced Table (1) the minimum time element in columns A, B, and C is 0,10 and 0 resp,
subtract these elements from all elements in this resp. column to get the reduced time
matrix as shown in Table 2.
Step 3 (a):
Example 2:
Examine all the rows starting from first one- until a row containing only single zero element
is located, Here, rows 1 and 3 have only one zero in the cells (1, C) and (3,A) resp, we A department has five employees with five jobs to be performed. The time in hours) each
assigned these zeros. All zeros in the assigned column are crossed off as shown in table 3. men will take to perform each job is given in the effectiveness matrix.

(b) We now examine each column starting from A in table 3, There is one zero in column B in
the cell (2, B). Assign this cell as shown in table 4.
How should the jobs be allocated one per employee so as to minimize the total man- hours?

Solution:

Step (1) & (2) Applying step (2) of the algorithm, we get the reduced opportunity time
matrix as shown in Table (1).

(c) Since the no of Assignments (= 3) equal the no of rows (= 3), the optimal solution is
obtained.

The pattern of assignment among programmers and programmes with their respective line
(in minutes) is given below.
Cover the zeros with minimum numbers of lines (= 4) as explained below.

(a) Mark (√) row D since it has no assignment then.

(b) Mark (√) columns I and IV since row D has zero element in these columns.

(c) Mark (√) rows B & E since column 1 and (IV) have an assignment in rows B and E resp.

(d) Since no other rows or columns can be marked draw straight lines through the unmarked
rows A & C and the marked columns I and IV as shown in Table 3.
In reduced table (1) the minimum time element in column I,II,III, IV, and V is 0,0,0,0,0 resp,
subtracting these from the elements of the resp. column we get same reduced matrix.

Step 3 (a):

We examine all the row starting from A one-by-one until a row containing only single zero
element is located. Here rows A, B and E have only one zero element in the cells (A, II), (B, I)
and (E, IV), Assignment is made in these cells. All zeros in the assigned columns are now
crossed off as shown in table 2.

Step 5:

Develop the new revised table by selecting the smallest element among all uncovered
elements by the lines in table 3 viz., 2. subtract K = 2 from uncovered elements including
itself and add it to elements 5,10,8 and 0 in cells (A, 1), (A,IV), (C, 1)< and (E,IV) resp. which
lie at the intersection of two lines. Another’s revised table so obtained is shown in table 4.

(b) We now examine each column starting from column. 1. There is one zero in column III,
cell (C, III) Assignment is made in this cell. Thus cell (C, V) is Crossed off. All zeros in the table
now are either assigned or crossed off as shown in Table 2.

The solution is not optimal because only four assignments are made.

Step 4:
Step 7:
Repeat step (3) to (5) to find a new solution. The new assignment is shown in Table 5.

Find an optimum assignment of jobs to the machines to minimize the total processing time
and also find for which machine no job is assigned. What is the total processing time to
Since the no. of assignment (= 5) equals the no of rows (or columns), the solution is optimal. complete all the jobs.
The pattern of assignments among jobs and employees with their respective time (in hour) Solution:
is given below:
Since the cost matrix is not a square matrix the problem is unbalanced. We add a dummy
job 5 with corresponding entries zero. Modified matrix.

Variations of the Assignment Problems:


Step 1 & 2:
Unbalanced Assignment Problem:
We subtract the smallest element from all the elements in the respective row and column.
Any assignment problem is said to be unbalanced if the cost matrix is not a square matrix,
i.e. the no of rows and the no of columns are not equal. To make it balanced we add a
dummy row or dummy column with all the entries is zero.

Example 3:

There are four jobs to be assigned to the machines. Only one job could be assigned to one
machine are given in following matrix.
The no of lines to cover all zeros = 4 < the order of matrix. We form the 2nd modified matrix
by subtracting the smallest uncovered element (i) from the remaining uncovered elements
and add to the element at the point of intersection of lines.

Step 3 & 4:

Now we give the zero assignment in our usual manners & get the following matrix.

Step 6:

Again Repeat step (3) & (4) and find following matrix.

But the solution is not optimal because only four assignments are made

Step 5:

In this step we draw minimum no. of lines to cover all zeros.


Here total no of assignment (= 5) which is equal to no of rows or no of columns. Then this is
optimal solution.

The pattern of assignment is given below:


For machines E no job is assigned, optimum (minimum)

Cost = 10 + 3 + 6 + 1

= Rs.20

Example 4:

(Airline Crew Assignment).

An airline, that operates seven days a week, has a time table shown below, crews must have Similarly we now construct layover table for crews based at Calcutta.
a minimum layover of 6 hours between flights. Obtain the pairing of flights that minimizes
layover time away from home. For any given pairing the crew will 1 be based at the city that
results in the smaller layover.

As per the given constraint, minimum layover time is now given in the table below.

Solution:

Let us first construct the table for the possible layovers between flights, when crews are
based at Delhi. The time difference between flight I and 101 is 24 hrs. i.e., 1,440 minutes,
whereas minimum layover required is 6 hours or 360 minutes. The figures circled indicate layover for crew based at Calcutta, whereas not circled figures
are for Delhi based crew.
When crew is based at Delhi, the layover table will be as follows:
Step 1:

Subtracting the smallest element of each row from every element of the corresponding
row, we get the following:
Identify the smallest uncovered element and subtracting it from all uncovered elements,
with addition to the elements at points of intersection, the matrix will be revised as follows
(Min. element = 60).

Step 2:

Subtracting column minima from all the elements of the column.

Step 5:

(Repeat step 3) Drawing horizontal vertical lines to cover all zeros, we get.

Step 3:

Making assignment on zero elements because in given situation optimal assignment is not
possible then we draw minimum no of horizontal or vertical lines to cover all zeros then we
get 3 lines as given below.

No. of lines are now equal to no of rows columns (i.e.4) Hence, the solution is optimal,
Proceed to step (6)

We get 3 lines since this no is not equal to the no of row/columns the solution is not optimal
proceed to step (4).

Step 4:
Step 6: Solution of assignment problems (Hungarian Method)

Making assignment on zero elements. Solution of assignment problems (Hungarian Method)

First check whether the number of rows is equal to the numbers of columns, if it is so, the
assignment problem is said to be balanced.

Step :1 Choose the least element in each row and subtract it from all the elements of
that row.

Step :2 Choose the least element in each column and subtract it from all the elements of
that column. Step 2 has to be performed from the table obtained in step 1.

Step:3 Check whether there is atleast one zero in each row and each column and make
an assignment as follows.

(i) Examine the rows successively until a row with exactly one zero is found. Mark that zero

by , that means an assignment is made there . Cross ( ×) all other zeros in its column.
Continue this until all the rows have been examined.

(ii) Examine the columns successively until a columns with exactly one zero is found. Mark

that zero by , that means an assignment is made there . Cross ( × ) all other zeros in its
row. Continue this until all the columns have been examined

Step :4 If each row and each column contains exactly one assignment, then the solution is
optimal.
Lesson 9 number of assignments is less. It becomes unsuitable for manual calculations if number of
assignments is large
SOLUTION OF ASSIGNMENT PROBLEM
9.2.2 Simplex method
9.1 Introduction
This can be solved as a linear programming problem as discussed in section 8.1.3 of the last
Although assignment problem can be solved either by using the techniques of Linear
lesson and as such can be solved by the simplex algorithm.
Programming or by the transportation method yet the assignment method developed by
D. Konig, a Hungarian mathematician known as the Hungarian method of assignment 9.2.3 Transportation method
problem is much faster and efficient. In order to use this method, one needs to know only
As assignment is a special case of transportation problem, it can also be solved using
the cost of making all the possible assignments. Each assignment problem has a matrix
transportation model discussed in module 3. The solution obtained by applying this method
(table) associated with it. Normally, the objects (or people) one wishes to assign are
would be degenerate. This is because the optimality test in the transportation method
expressed in rows, whereas the columns represent the tasks (or things) assigned to them.
requires that there must be m+n-1= (2n-1) basic variables. For an assignment problem of
The number in the table would then be the costs associated with each particular
order n x n there would be only n basic variables in the solution because here n assignments
assignment. It may be noted that the assignment problem is a variation of transportation
are required to be made. This degeneracy problem of solution makes the transportation
problem with two characteristics firstly the cost matrix is a square matrix and secondly the
method computationally inefficient for solving the assignment problem.
optimum solution for the problem would be such that there would be only one assignment
in a row or column of the cost matrix. 9.2.4 Hungarian assignment method
9.2 Solution of Assignment Problem The Hungarian method of assignment provides us with an efficient means of finding the
optimal solution. The Hungarian method is based upon the following principles:
The assignment problem can be solved by the following four methods:
(i) If a constant is added to every element of a row and/or column of the cost matrix of an
a) Complete enumeration method
assignment problem the resulting assignment problem has the same optimum solution as
b) Simplex Method the original problem or vice versa.

c) Transportation method (ii) The solution having zero total cost is considered as optimum solution.

d) Hungarian method Hungarian method of assignment problem (minimization case) can be summarized in the
following steps:
9.2.1 Complete enumeration method
Step I: Subtract the minimum cost of each row of the cost (effectiveness) matrix from all
In this method, a list of all possible assignments among the given resources and activities is
the elements of the respective row so as to get first reduced matrix.
prepared. Then an assignment involving the minimum cost, time or distance or maximum
profits is selected. If two or more assignments have the same minimum cost, time or Step II: Similarly subtract the minimum cost of each column of the cost matrix from all the
distance, the problem has multiple optimal solutions. This method can be used only if the elements of the respective column of the first reduced matrix. This is first modified matrix.
Step III: Starting with row 1 of the first modified matrix, examine the rows one by one until Step VIII: In this step, we
a row containing exactly single zero elements is found. Make any assignment by making that
1. � Select the smallest element, say X, among all the not covered by any of the lines of
zero in or enclose the zero inside a. Then cross (X) all other zeros in the column in which the
the table; and
assignment was made. This eliminates the possibility of making further assignments in that
column. 2. Subtract this value X from all of the elements in the matrix not covered by lines and add
X to all those elements that lie at the intersection of the horizontal and vertical lines, thus
Step IV: When the set of rows have been completely examined, an identical procedure is
obtaining the second modified cost matrix.
applied successively to columns that is examine columns one by one until a column
containing exactly single zero element is found. Then make an experimental assignment in Step IX: Repeat Steps IV, V and VI until we get the number of lines equal to the order of
that position and cross other zeros in the row in which the assignment has been made. matrix I, till an optimum solution is attained.
Step V: Continue these successive operations on rows and columns until all zeros have been Step X: We now have exactly one encircled zero in each row and each column of the cost
either assigned or crossed out and there is exactly one assignment in each row and in each matrix. The assignment schedule corresponding to these zeros is the optimum assignment.
column. In such case optimal assignment for the given problem is obtained. The above technique is explained by taking the following examples
Step VI: There may be some rows (or columns) without assignment i.e. the total number of
marked zeros is less than the order of the matrix. In such case proceed to step VII.

Step VII: Draw the least possible number of horizontal and vertical lines to cover all zeros of
the starting table. This can be done as follows:

1. Mark (√) in the rows in which assignments has not been made.

2. Mark column with (√) which have zeros in the marked rows.

3. Mark rows with (√) which contains assignment in the marked column.

4. Repeat 2 and 3 until the chain of marking is completed.

5. Draw straight lines through marked columns.

6. Draw straight lines through unmarked rows.

By this way we draw the minimum number of horizontal and vertical lines necessary to
cover all zeros at least once. It should, however, be observed that in all n x n matrices less
than n lines will cover the zeros only when there is no solution among them. Conversely, if
the minimum number of lines is n, there is a solution.

You might also like