BCAC403_ClassNote_Module-4
BCAC403_ClassNote_Module-4
Study Material
Optimization Techniques
BCAC403
Module-4
_________________________________________________________________________________
Table of Contents
Department of Mathematics
Brainware University, Kolkata 1
Bachelor of Computer Applications and 4th semester
Optimization Techniques (BCAC403)
BCA
2023-2024
Module 4
4.1 Introduction
The Assignment Problem is a classical optimization problem in the field of Operations Research. It is
a special case of linear programming and is widely used in various real-life applications to efficiently
allocate resources or tasks to a group of agents or machines. The main objective of the assignment
problem is to find the most optimal assignment that minimizes or maximizes a given objective function
while satisfying certain constraints.
In a typical assignment problem, we have a set of agents (e.g., workers, machines) and a set of tasks
(e.g., jobs, projects) that need to be completed. Each agent is capable of performing a subset of the
tasks, and each task requires a specific amount of resources or effort to be completed by a particular
agent. The goal is to determine the best assignment of tasks to agents, such that the overall cost, time,
or any other objective measure is minimized or maximized.
The Assignment Problem is a classical optimization problem in the field of Operations Research. It is
a special case of linear programming and is widely used in various real-life applications to efficiently
allocate resources or tasks to a group of agents or machines. The main objective of the assignment
problem is to find the most optimal assignment that minimizes or maximizes a given objective
function while satisfying certain constraints.
In a typical assignment problem, we have a set of agents (e.g., workers, machines) and a set of tasks
(e.g., jobs, projects) that need to be completed. Each agent is capable of performing a subset of the
tasks, and each task requires a specific amount of resources or effort to be completed by a particular
agent. The goal is to determine the best assignment of tasks to agents, such that the overall cost, time,
or any other objective measure is minimized or maximized.
Department of Mathematics
Brainware University, Kolkata 2
Bachelor of Computer Applications and 4th semester
Optimization Techniques (BCAC403)
BCA
2023-2024
3. Assignment Matrix: Create an 'n x m' matrix where each element 'cij' represents the cost,
time, or any other measure associated with assigning the task 'Tj' to the agent 'Ai'.
4. Constraints: Each task can be assigned to exactly one agent, and each agent can be assigned
to at most one task.
The objective is to find an assignment that minimizes or maximizes the total cost, time, or any other
objective function, subject to the constraints mentioned above.
There are various methods to solve the assignment problem, and these methods often leverage
algorithms like the Hungarian algorithm, the shortest path algorithm, or other optimization
techniques to find the optimal assignment efficiently. The Hungarian algorithm, in particular, is a
well-known algorithm that efficiently solves the assignment problem in polynomial time.
Applications of the assignment problem can be found in diverse fields such as workforce
management, transportation planning, project scheduling, and resource allocation. Whether it's
assigning workers to specific tasks, machines to manufacturing jobs, or optimizing the efficiency of a
transportation network, the assignment problem plays a crucial role in streamlining operations and
improving overall productivity.
In summary, the assignment problem in Operations Research is a valuable tool for optimizing the
allocation of resources, tasks, or jobs to agents, and it has broad applications in various industries
and real-world scenarios. By efficiently finding the optimal assignment, businesses and organizations
can minimize costs, maximize productivity, and make well-informed decisions in their daily
operations.
Assumptions:
Department of Mathematics
Brainware University, Kolkata 3
Bachelor of Computer Applications and 4th semester
Optimization Techniques (BCAC403)
BCA
2023-2024
Activity Available
𝐴1 𝐴2 … 𝐴𝑛 1
𝑅1 𝑐11 𝑐12 … 𝑐1𝑛 1
𝑅2 𝑐21 𝑐22 … 𝑐2𝑛
Resource
The cost matrix is same as that of a transportation problem except the availability at each of the
resources and the requirement at each of the destinations is unity (due to the fact that assignments are
made on a one-one basis).
Let 𝑥𝑖𝑗 denote the assignment of i-th resource to j-th activity, such that
Department of Mathematics
Brainware University, Kolkata 4
Bachelor of Computer Applications and 4th semester
Optimization Techniques (BCAC403)
BCA
2023-2024
And where 𝑐𝑖𝑗 is the cost associated with assigning i-th resource of j-th activity.
The Hungarian Method is an efficient algorithm for solving the Assignment Problem and finding the
optimal assignment of tasks to agents with minimum cost. The algorithm was developed by two
Hungarian mathematicians, Dénes Kőnig and Jenő Egerváry, and later independently rediscovered
and popularized by Harold Kuhn in the 1950s. The Hungarian Method is based on the principles of
linear programming and uses the concept of augmenting paths to iteratively find the optimal
assignment.
Here's a step-by-step guide to the Hungarian Method for solving the Assignment Problem:
Step 1: Create the Cost Matrix Given the assignment problem with 'n' agents and 'm' tasks, create an
'n x m' matrix representing the cost of assigning each task to each agent. If the problem involves
maximizing a measure (e.g., profit), convert it to a minimization problem by subtracting each value
from the maximum value in the matrix.
Step 2: Row Reduction In this step, reduce each row of the cost matrix such that each row contains at
least one zero. This is done by subtracting the smallest element in each row from all the elements in
that row.
Step 3: Column Reduction Next, reduce each column of the cost matrix in a similar manner. Subtract
the smallest element in each column from all the elements in that column.
Step 4: Marking the Zeros and Drawing Lines Identify the minimum number of lines (horizontal and
vertical) needed to cover all the zeros in the reduced matrix. If the number of lines is equal to 'n', an
optimal assignment is possible. Proceed to Step 5. If not, go to Step 6.
Step 5: Optimal Assignment Found (or Improve the Solution) If the number of lines drawn is equal
to 'n', an optimal assignment is possible. Assign tasks to agents such that each task has exactly one
assigned agent. If there are multiple assignments possible, any optimal assignment can be chosen.
The total cost of the assignment represents the minimum cost for the problem.
Step 6: Modify the Matrix and Repeat If the number of lines drawn is less than 'n', modify the cost
matrix to create more zeros without violating the line covering constraint. This involves two possible
cases:
Department of Mathematics
Brainware University, Kolkata 5
Bachelor of Computer Applications and 4th semester
Optimization Techniques (BCAC403)
BCA
2023-2024
6a. Create additional zeros: Find the smallest element 'min' not covered by any line. Subtract 'min'
from all uncovered elements and add 'min' to the elements at the intersection of two lines.
6b. Create a zero and delete another: Find the minimum value 'min' of the uncovered elements.
Subtract 'min' from all uncovered elements and add 'min' to the elements at the intersection of two
lines.
After modification, return to Step 4 and repeat the process until an optimal assignment is found.
Step 7: Obtain the Optimal Assignment Once an optimal assignment is achieved (Step 5), the
assignment of tasks to agents represents the optimal solution to the Assignment Problem, with the
minimum total cost or maximum measure achieved.
The Hungarian Method is guaranteed to find the optimal solution to the Assignment Problem in
polynomial time, making it highly efficient even for large-scale problems. It is widely used in
various industries and applications, such as project scheduling, resource allocation, and workforce
management, where optimal task assignment is critical for minimizing costs and maximizing
efficiency.
1. Maximization Problem:
The elements of cost matrix of the assignment problem represent profits instead of costs and the
corresponding cost matrix is called profit matrix. To solve this problem first, the largest element of
the profit matrix is selected. Then we subtract all elements from the largest element to get new cost
matrix which will provide the maximum profit of the original problem.
2. Unbalanced Assignment:
If the number of jobs is not equal to the number of workers or machines, then the problem is
unbalanced. In this case we add a fictitious job or machine with zero cost. Then we apply the
assignment algorithm to the resulting balanced problem.
3. Impossible Assignment:
If some job cannot be assigned by some particular worker, then we avoid this effectively by putting a
large cost in that cell.
Department of Mathematics
Brainware University, Kolkata 6
Bachelor of Computer Applications and 4th semester
Optimization Techniques (BCAC403)
BCA
2023-2024
4. Negative cost:
If the cost matrix contains some negative cost, then we add to each element a quantity to make all
elements non-negative.
Department of Mathematics
Brainware University, Kolkata 7
Bachelor of Computer Applications and 4th semester
Optimization Techniques (BCAC403)
BCA
2023-2024
Iteration-1 of steps 3 to 6
(2) Row wise cell (D, 1) is assigned, so column wise cell (B, 1) crossed off.
(3) Row wise cell (B, 4) is assigned, so column wise cell (C, 4), (E, 4) crossed off.
(4) Column wise cell (C, 3) is assigned, so row wise cell (C, 5) crossed off.
Department of Mathematics
Brainware University, Kolkata 8
Bachelor of Computer Applications and 4th semester
Optimization Techniques (BCAC403)
BCA
2023-2024
Step-4: Number of assignments = 4, number of rows = 5 Which is not equal, so solution is not
optimal.
Step-5: Draw a set of horizontal and vertical lines to cover all the 0
(6) Since no other rows or columns can be marked, therefore draw straight lines through the
unmarked rows A, C and marked columns 1,4
Department of Mathematics
Brainware University, Kolkata 9
Bachelor of Computer Applications and 4th semester
Optimization Techniques (BCAC403)
BCA
2023-2024
Step-6: Develop the new revised table by selecting the smallest element, among the cells not covered
Iteration: 1
Iteration-2 of steps 3 to 6
Department of Mathematics
Brainware University, Kolkata 10
Bachelor of Computer Applications and 4th semester
Optimization Techniques (BCAC403)
BCA
2023-2024
(2) Column wise cell (C, 5) is assigned, so row wise cell (C, 3) crossed off.
(3) Row wise cell (B, 1) is assigned, so column wise cell (D, 1) crossed off., so row wise cell (B, 4)
crossed off.
(4) Row wise cell (D, 3) is assigned, so column wise cell (E, 3) crossed off.
Department of Mathematics
Brainware University, Kolkata 11
Bachelor of Computer Applications and 4th semester
Optimization Techniques (BCAC403)
BCA
2023-2024
Ex: A car hire company has one car at each of five depots a,b,c,d and e. A customer in each of five
towns A, B, C, D and E requires a car. The distance (in kms.) between the depots (origins) and the
towns (destinations), where the customers are, is given in the following distance matrix:
a b c d e
A 160 130 175 190 200
B 135 120 130 160 175
C 140 110 155 170 185
D 50 50 80 80 110
E 55 35 70 80 105
Department of Mathematics
Brainware University, Kolkata 12
Bachelor of Computer Applications and 4th semester
Optimization Techniques (BCAC403)
BCA
2023-2024
How should the cars be assigned to customers so as to minimize the distance travelled?
Department of Mathematics
Brainware University, Kolkata 13
Bachelor of Computer Applications and 4th semester
Optimization Techniques (BCAC403)
BCA
2023-2024
Iteration-1 of steps 3 to 6
(1) Row wise cell (A, 2) is assigned, so column wise cell (B, 2), (C, 2), (D, 2), (E, 2) crossed off.
(2) Column wise cell (D, 1) is assigned, so row wise cell (D, 4) crossed off.
(3) Column wise cell (B, 3) is assigned, so row wise cell (B, 5) crossed off.
Department of Mathematics
Brainware University, Kolkata 14
Bachelor of Computer Applications and 4th semester
Optimization Techniques (BCAC403)
BCA
2023-2024
Step-4: Number of assignments = 3, number of rows = 5 Which is not equal, so solution is not
optimal.
(5) Since no other rows or columns can be marked, therefore draw straight lines through the
unmarked rows B, D and marked columns 2
Department of Mathematics
Brainware University, Kolkata 15
Bachelor of Computer Applications and 4th semester
Optimization Techniques (BCAC403)
BCA
2023-2024
Step-6: Develop the new revised table by selecting the smallest element, among the cells not covered
Iteration: 1
Iteration-2 of steps 3 to 6
(1) Row wise cell (C, 2) is assigned, so column wise cell (1, 2),(E, 2) crossed off.
(2) Row wise cell (4, 5) is assigned, so column wise cell (B, 5),(E, 5) crossed off.
(4) Row wise cell (E, 4) is assigned, so column wise cell (D, 4) crossed off.
Department of Mathematics
Brainware University, Kolkata 16
Bachelor of Computer Applications and 4th semester
Optimization Techniques (BCAC403)
BCA
2023-2024
Department of Mathematics
Brainware University, Kolkata 17
Bachelor of Computer Applications and 4th semester
Optimization Techniques (BCAC403)
BCA
2023-2024
Exercise: A company is producing a single product and selling it through five agencies situated in
different cities. All of a sudden, there is a demand forthe product in five more cities that do not have
any agency of the company.
The company is faced with the problem of deciding on how to assign the existing agencies to
dispatch the product to the additional cities in such a waythat the travelling distance is minimised.
The distances (in km) between the surplus and deficit cities are given in the following distance
matrix.
D 50 50 80 80 110
E 55 35 70 80 105
Department of Mathematics
Brainware University, Kolkata 18
Bachelor of Computer Applications and 4th semester
Optimization Techniques (BCAC403)
BCA
2023-2024
𝑛 𝑚 𝑛 𝑛
𝑥𝑖𝑗 ≥ 0 𝑥𝑖𝑗 ≥ 0
Department of Mathematics
Brainware University, Kolkata 19
Bachelor of Computer Applications and 4th semester
Optimization Techniques (BCAC403)
BCA
2023-2024
Group –A
1 1 4
6 7 2
8 4 3
1
a. 15 b. 18
c. 19 d. 23
5 6 3 50
7 5 8 40
2
30 25 35
a. 570 b. 575
c. 580 d. 595
a. ui + vj = Cij b. ui + vj ≥ Cij
Department of Mathematics
Brainware University, Kolkata 20
Bachelor of Computer Applications and 4th semester
Optimization Techniques (BCAC403)
BCA
2023-2024
a. 20 b. 25
c. 30 d. 35
a. 8 b. 10
c. 12 d. 15
a. 9 b. 10
c. 11 d. 12
a. 15 b. 20
c. 25 d. 30
1 1 4
6 7 2
8 4 3
9
a. 6 b. 7
c. 8 d. 9
Department of Mathematics
Brainware University, Kolkata 21
Bachelor of Computer Applications and 4th semester
Optimization Techniques (BCAC403)
BCA
2023-2024
c. Job 4 to M3 d. Job 4 to M4
1 1 4
6 7 2
8 4 3
5 6 7
13
a. Job 1 b. Job 2
c. Job 3 d. Job 4
Department of Mathematics
Brainware University, Kolkata 22
Bachelor of Computer Applications and 4th semester
Optimization Techniques (BCAC403)
BCA
2023-2024
6 7 2 7
8 4 3 6
5 6 7 8
a. 20 b. 30
c. 32 d. 40
15
Choose the machine that does not get a job in the optimum
15 assignment.
a. 1 b. 2
c. 3 d. 4
a. 9 b. 10
c. 11 d. 12
20 17 22 16
32 29 33 26
26 27 29 28
40 30 35 37
17
a. 2 b. 3
c. 4 d. 5
Department of Mathematics
Brainware University, Kolkata 23
Bachelor of Computer Applications and 4th semester
Optimization Techniques (BCAC403)
BCA
2023-2024
Group – B
7 7 4
2 1 6
0 4 5
2 5 1
3 Explain mathematical form of Assignment Problem.
4 Consider the following assignment problem. When you solve it by hand, estimate the
number of assignments that you get in the first iterations.
20 17 22 16
32 29 33 26
26 27 29 28
40 30 35 37
5 Explain different types of Assignment Problem.
Group – C
1 Consider the problem of assigning four operators to four machines. The assignment
cost in rupees are given below. Operator 1 cannot be assigned to machine 3 and
operator 3 cannot be assigned to the machine 4. Calculate the optimal cost of
assignment.
Machine
1 2 3 4
1 5 5 - 2
2 7 4 2 3
Operator
3 9 3 5 -
4 6 2 6 7
Department of Mathematics
Brainware University, Kolkata 24
Bachelor of Computer Applications and 4th semester
Optimization Techniques (BCAC403)
BCA
2023-2024
Department of Mathematics
Brainware University, Kolkata 25
Bachelor of Computer Applications and 4th semester
Optimization Techniques (BCAC403)
BCA
2023-2024
5 A car hire company has one car at each of five depots a, b, c, d, e. A customer in each
of five towns A, B, C, D, E requires a car. The distance (in kms.) between the
depots(origins) and the towns(destinations), where the customer are, is given in the
following distance matrix:
a b c d e
A 160 130 175 190 200
B 135 120 130 160 175
C 140 110 155 170 185
D 50 50 80 80 110
E 55 35 70 80 105
Predict the assignment of cars to customers would minimize the distance traveled.
6 Estimate the optimum assignments and minimum time for the following Assignment
Problem.
SUBORDINATE I II III
TASK I 9 26 15
II 13 27 6
III 35 20 15
IV 18 30 20
7 The Head of the department has five jobs A, B, C, D, E and five sub-ordinates V, W,
X, Y, and Z. The number of hours each sub-ordinates would take to perform each job
is as follows:
V W X Y Z
A 3 5 10 15 8
B 4 7 15 18 8
C 8 12 20 20 12
D 5 5 8 10 6
E 10 10 15 25 10
Department of Mathematics
Brainware University, Kolkata 26
Bachelor of Computer Applications and 4th semester
Optimization Techniques (BCAC403)
BCA
2023-2024
Department of Mathematics
Brainware University, Kolkata 27