Problem Statement:
Maximize Z = 3x1 + 4x2
Subject to the constraints:
x1 + 2x2 ≤ 4
3x1 + 2x2 ≤ 6
x1, x2 ≥ 0 (Non-negativity constraint)
Problem Statement:
Minimize Z = 3x1 + 4x2
Subject to the constraints:
x1 + 2x2 ≥ 4
3x1 + 2x2 ≥ 6
x1, x2 ≥ 0 (Non-negativity constraint)
Problem Statement:
Maximize Z = 3x1 + 2x2
Subject to the constraints:
x1 + 2x2 ≤ 4
3x1 + 2x2 ≤ 6
x1, x2 ≥ 0 (Non-negativity constraint)
Problem Statement:
Maximize Z = 6x1 + 4x2
Subject to the constraints:
2x1 + 4x2 ≤ 4
4x1 + 8x2 ≥ 16
x1, x2 ≥ 0 (Non-negativity constraint)
Maximize Z = 5x1 + 3x2
Subject to the constraints:
3x1 + 5x2 ≤ 15
5x1 + 2x2 ≤ 10
x1, x2 ≥ 0
| Cj | 5 | 3 | 0 | 0 |
CB | Xb | B | x1 | x2 | x3 | x4 |
----------------------------------------------
0 | x3 | 15 | 3 | 5 | 1 | 0 |
0 | x4 | 10 | 5 | 2 | 0 | 1 |
Here:
| Cj | 5 | 3 | 0 | 0 |
CB | Xb | B | x1 | x2 | x3 | x4 |
----------------------------------------------
0 | x3 | 15 | 3 | 5 | 1 | 0 | (Row 1)
0 | x4 | 10 | 5 | 2 | 0 | 1 | (Row 2)
----------------------------------------------
Zj | | 0 | 0 | 0 | 0 |
Cj | | 5 | 3 | 0 | 0 |
Zj - Cj | | -5 | -3 | 0 | 0 |
To calculate Zj, we use the formula Zj = CB × B, where:
After calculating Zj, we compute Zj - Cj, which shows the difference between the calculated and actual costs. The most negative value, -5 (in the x1 column), indicates that x1 should enter the basis.
To decide which variable to remove from the basis (x3 or x4), we compute the minimum ratio of b values and the coefficients in the x1 column:
| Cj | 5 | 3 | 0 | 0 |
CB | Xb | b | x1 | x2 | x3 | x4 | min ratio
--------------------------------------------------------
0 | x3 | 15 | 3 | 5 | 1 | 0 | 15/3 = 5
0 | x4 | 10 | 5 | 2 | 0 | 1 | 10/5 = 2 → smallest ratio
As 2 is the smallest ratio, x4 is the outgoing variable, and x1 will replace x4 in the basis.
| Cj | 5 | 3 | 0 | 0 |
CB | Xb | b | x1 | x2 | x3 | x4 |
----------------------------------------------
0 | x3 | 9 | 0 | 19/5 | 1 | -3/5 | (Row 1)
5 | x1 | 2 | 1 | 2/5 | 0 | 1/5 | (Row 2)
----------------------------------------------
Row 2 was divided by 5, and row 1 was updated using row 1 - 3 * (new row 2).
| Cj | 5 | 3 | 0 | 0 |
CB | Xb | b | x1 | x2 | x3 | x4 | min ratio
--------------------------------------------------------
0 | x3 | 9 | 0 | 19/5 | 1 | -3/5 | 45/19 → smallest ratio
5 | x1 | 2 | 1 | 2/5 | 0 | 1/5 | 10/2
--------------------------------------------------------
Zj | | 5 | 2 | 0 | 1 |
Cj | | 5 | 3 | 0 | 0 |
Zj - Cj | | 0 | -1 | 0 | 1 |
The next entering variable is x2 (as -1 is the most negative value in Zj - Cj), and the
outgoing variable is x3 (smallest ratio). We perform another pivot operation.
| Cj | 5 | 3 | 0 | 0 |
CB | Xb | b | x1 | x2 | x3 | x4 |
--------------------------------------------------------
3 | x2 | 45/19 | 0 | 1 | 5/19 |-3/19 | (Row 1) new
5 | x1 | 20/19 | 1 | 0 | -2/19 | 5/19 | (Row 2)
--------------------------------------------------------
Zj | | 5 | 3 | 5/19 | 16/19
Cj | | 5 | 3 | 0 | 0
Zj - Cj | | 0 | 0 | 5/19 | 16/19
Since there are no more negative values in the Zj - Cj row, the optimal solution has been
reached.
Maximize Z = 3x1 + 2x2 + 5x3
Subject to the constraints:
x1 + x2 + x3 ≤ 9
2x1 + 3x2 + 5x3 ≤ 30
2x1 - x2 - x3 ≤ 8
xi ≥ 0
| Cj | 3 | 2 | 5 | 0 | 0 | 0 |
CB | Xb | b | x1 | x2 | x3 | x4 | x5 | x6 |
----------------------------------------------------------------------
0 | x4 | 9 | 1 | 1 | 1 | 1 | 0 | 0 | (Row 1)
0 | x5 | 30 | 2 | 3 | 5 | 0 | 1 | 0 | (Row 2)
0 | x6 | 8 | 2 | -1 | -1 | 0 | 0 | 1 | (Row 3)
| Cj | 3 | 2 | 5 | 0 | 0 | 0 |
CB | Xb | b | x1 | x2 | x3 | x4 | x5 | x6 |
------------------------------------------------------------------------
0 | x4 | 9 | 1 | 1 | 1 | 1 | 0 | 0 | (Row 1)
0 | x5 | 30 | 2 | 3 | 5 | 0 | 1 | 0 | (Row 2)
0 | x6 | 8 | 2 | -1 | -1 | 0 | 0 | 1 | (Row 3)
------------------------------------------------------------------------
Zj | | 0 | 0 | 0 | 0 | 0 | 0 |
Cj | | 3 | 2 | 5 | 0 | 0 | 0 |
Zj - Cj | | -3 | -2 | -5 | 0 | 0 | 0 |
The most negative value in Zj - Cj is -5, so x3 enters the basis. We calculate the minimum
ratio to determine the exiting variable:
| Cj | 3 | 2 | 5 | 0 | 0 | 0 |
CB | Xb | b | x1 | x2 | x3 | x4 | x5 | x6 |
-------------------------------------------------------------------
0 | x4 | 3 | 3/5| 2/5| 0 | 1 | -1/5| 0 | (Row 1)
5 | x3 | 6 | 2/5| 3/5| 1 | 0 | 1/5| 0 | (Row 2)
0 | x6 | 14 | 12/5| -2/5| 0 | 0 | 1/5| 1 | (Row 3)
--------------------------------------------------------------------
| Cj | 3 | 2 | 5 | 0 | 0 | 0 |
CB | Xb | b | x1 | x2 | x3 | x4 | x5 | x6 |
---------------------------------------------------------------------
0 | x4 | 3 | 3/5| 2/5| 0 | 1 | -1/5| 0 | (Row 1)
5 | x3 | 6 | 2/5| 3/5| 1 | 0 | 1/5| 0 | (Row 2)
0 | x6 | 14 | 12/5| -2/5| 0 | 0 | 1/5| 1 | (Row 3)
---------------------------------------------------------------------
Zj | | 2 | 3 | 5 | 0 | 1 | 0 |
Cj | | 3 | 2 | 5 | 0 | 0 | 0 |
Zj - Cj | | -1 | 1 | 0 | 0 | 1 | 0 |
The most negative value in Zj - Cj is -1, so x1 enters the basis. We calculate the minimum
ratio to determine the exiting variable:
| Cj | 3 | 2 | 5 | 0 | 0 | 0 |
CB | Xb | b | x1 | x2 | x3 | x4 | x5 | x6 |
-------------------------------------------------------------------
3 | x1 | 5 | 1 | 2/3| 0 | 5/3 | -1/3| 0 | (Row 1) new
5 | x3 | 4 | 0 | 1/3| 1 | -2/3 | 1/3| 0 | (Row 2)
0 | x6 | 2 | 0 | -2 | 0 | -4 | 1 | 1 | (Row 3)
--------------------------------------------------------------------
Zj - Cj | | 0 | 5/3| 0 | 5/3| 2/3| 0 |
As now all Zj - Cj values are postive, hence we have our optimal solution
The Big M Method is an approach used to solve linear programming problems (LPP) involving artificial variables when the problem includes greater-than-or-equal-to (≥) or equality (=) constraints. It allows converting such constraints into a standard form suitable for solving using the Simplex method.
Min Z = x1 + x2
Constraints:
2x1 + x2 ≥ 4
x1 + 7x2 ≥ 7
x1 ≥ 0
| Cj | -1 | -1 | 0 | 0 | -M | -M |
CB | Xb | b | x1 | x2 | x3 | x4 | x5 | x6 |
------------------------------------------------------------------------
-M | x5 | 4 | 2 | 1 | -1 | 0 | 1 | 0 | (Row 1)
-M | x6 | 7 | 1 | 7 | 0 | -1 | 0 | 1 | (Row 2)
------------------------------------------------------------------------
Zj | | -3M | -8M | M | M | -M | -M |
Cj | | -1 | -1 | 0 | 0 | 0 | 0 |
Zj - Cj | | -3M+1 | -8M+1 | M | M | 0 | 0 |
Since M is a large value, suppose it is 100, then the most negative value will be -8M+1. So
in this column, x2 is the entering variable.
| Cj | -1 | -1 | 0 | 0 | -M
CB | Xb | b | x1 | x2 | x3 | x4 | x5
---------------------------------------------------------------
-M | x5 | 3 | 13/7 | 0 | -1 | 1/7 | 1 (Row 1)
-1 | x2 | 1 | 1/7 | 1 | 0 | -1/7 | 0 (Row 2) new
---------------------------------------------------------------
Zj | |(-13M-1)/7 | -1 | M |(-M+1)/7 | -M
Cj | | -1 | -1 | 0 | 0 | 0
Zj - Cj | |(-13M-8)/7 | 0 | M |(-M+1)/7 | 0
Here, (-13M-8)/7 is the most negative, which makes x1 the entering variable.
| Cj | -1 | -1 | 0 | 0
CB | Xb | b | x1 | x2 | x3 | x4
---------------------------------------------------
-1 | x1 | 21/13 | 1 | 0 | -7/13 | 1/13 (Row 1) new
-1 | x2 | 10/13 | 0 | 1 | 1/13 | -2/13 (Row 2)
----------------------------------------------------
Zj | | -1 | -1 | 6/13 | 1/13
Cj | | -1 | -1 | 0 | 0
Zj - Cj | | 0 | 0 | 6/13 | 1/13
Now, as all Zj - Cj values are ≥ 0, we have found our optimal solution.
The Two-Phase Method is used to solve Linear Programming Problems (LPP) when the problem involves artificial variables, typically in the case of equality constraints or greater-than-or-equal-to (≥) constraints. It ensures that a feasible solution is found even when such variables are introduced. The method is divided into two phases:
Min Z = x1 + x2
Constraints:
2x1 + x2 ≥ 4
x1 + 7x2 ≥ 7
x1 ≥ 0
| Cj | 0 | 0 | 0 | 0 | -1 | -1 |
CB | Xb | b | x1 | x2 | x3 | x4 | x5 | x6 |
------------------------------------------------------------------------
-1 | x5 | 4 | 2 | 1 | -1 | 0 | 1 | 0 | (Row 1)
-1 | x6 | 7 | 1 | 7 | 0 | -1 | 0 | 1 | (Row 2)
------------------------------------------------------------------------
Zj | | -3 | -8 | 1 | 1 | -1 | -1 |
Cj | | 0 | 0 | 0 | 0 | -1 | -1 |
Zj - Cj | | -3 | -8 | 1 | 1 | 0 | 0 |
The most negative value will be -8. So
in this column, x2 is the entering variable.
| Cj | 0 | 0 | 0 | 0 | -1
CB | Xb | b | x1 | x2 | x3 | x4 | x5
---------------------------------------------------------------
-1 | x5 | 3 | 13/7 | 0 | -1 | 1/7 | 1 (Row 1)
0 | x2 | 1 | 1/7 | 1 | 0 | -1/7 | 0 (Row 2) new
---------------------------------------------------------------
Zj | | -13/7 | -1 | 1 | -1/7 | -1
Cj | | 0 | 0 | 0 | 0 | -1
Zj - Cj | | -13/7 | -1 | 1 | -1/7 | 0
Here, -13/7 is the most negative, which makes x1 the entering variable.
| Cj | 0 | 0 | 0 | 0
CB | Xb | b | x1 | x2 | x3 | x4
---------------------------------------------------
0 | x1 | 21/13 | 1 | 0 | -7/13 | 1/13 (Row 1) new
0 | x2 | 10/13 | 0 | 1 | 1/13 | -2/13 (Row 2)
----------------------------------------------------
Zj | | 0 | 0 | 0 | 0
Cj | | 0 | 0 | 0 | 0
Zj - Cj | | 0 | 0 | 0 | 0
Now, as all Zj - Cj values are ≥ 0, so our phase 1 is ended
| Cj | -1 | -1 | 0 | 0
CB | Xb | b | x1 | x2 | x3 | x4
---------------------------------------------------
-1 | x1 | 21/13 | 1 | 0 | -7/13 | 1/13 (Row 1) new
-1 | x2 | 10/13 | 0 | 1 | 1/13 | -2/13 (Row 2)
----------------------------------------------------
Zj - Cj | | 0 | 0 | 6/13 | 1/13
Now, as all Zj-Cj values are >= 0, so we have found our optimal solution
Basic Feasible Solution (BFS):
Example Problem - Find the Initial BFS (Basic Feasible Solution) of the Following Transportation Problem:
| Warehouse
Factory | w1 | w2 | w3 | w4 | Capacity
----------------------------------------------------
F1 | 19 | 30 | 50 | 10 | 7
F2 | 70 | 30 | 40 | 60 | 9
F3 | 40 | 8 | 70 | 20 | 18
----------------------------------------------------
Warehouse | 5 | 8 | 7 | 14 |
Requirement |
Factory | w1 | w2 | w3 | w4 | Capacity
----------------------------------------------------
F1 | 19 (5) | 30 | 50 | 10 | 7-5=2
F2 | 70 | 30 | 40 | 60 | 9
F3 | 40 | 8 | 70 | 20 | 18
----------------------------------------------------
Requirement | 5-5=0 | 8 | 7 | 14 |
now we will remove the column 1
Factory | w2 | w3 | w4 | Capacity
----------------------------------------------------
F1 | 30(2) | 50 | 10 | 2-2=0
F2 | 30 | 40 | 60 | 9
F3 | 8 | 70 | 20 | 18
----------------------------------------------------
Requirement | 8-2=6 | 7 | 14 |
now we remove row 1
Factory | w2 | w3 | w4 | Capacity
----------------------------------------------------
F2 | 30(6) | 40 | 60 | 9-6=3
F3 | 8 | 70 | 20 | 18
----------------------------------------------------
Requirement | 6-6=0 | 7 | 14 |
now we remove column 1
Factory | w3 | w4 | Capacity
--------------------------------------------
F2 | 40(3) | 60 | 3-3=0
F3 | 70 | 20 | 18
--------------------------------------------
Requirement | 7-3=4 | 14 |
now we remove row 1
Factory | w3 | w4 | Capacity
-----------------------------------------------
F3 | 70(4) | 20(14) | 18-4-14=0
-----------------------------------------------
Requirement | 4-4=0 | 14-14=0 |
so finaly we have:
Factory | w1 | w2 | w3 | w4 | Capacity
----------------------------------------------------------------
F1 | 19 (5) | 30(2) | 50 | 10 | 7
F2 | 70 | 30(6) | 40(3) | 60 | 9
F3 | 40 | 8 | 70(4) | 20(14) | 18
----------------------------------------------------------------
Requirement | 5 | 8 | 7 | 14 |
Now we will find its transportation cost:
Solving the Same Question Using the Least Cost Method
Factory | w1 | w2 | w3 | w4 | D
-------------------------------------------------
F1 | 19 | 30 | 50 | 10 | 7
F2 | 70 | 30 | 40 | 60 | 9
F3 | 40 | 8(8) | 70 | 20 | 18-8=10
-------------------------------------------------
S | 5 | 8-8=0 | 7 | 14 | 34
Now, we remove the w2 column.
Factory | w1 | w3 | w4 | D
-------------------------------------------------
F1 | 19 | 50 | 10(7) | 7-7=0
F2 | 70 | 40 | 60 | 9
F3 | 40 | 70 | 20 | 10
-------------------------------------------------
S | 5 | 7 | 14-7=7 | 34
Now, we remove row 1.
Factory | w1 | w3 | w4 | D
-----------------------------------------
F2 | 70 | 40 | 60 | 9
F3 | 40 | 70 | 20(7) | 10-7=3
-----------------------------------------
S | 5 | 7 | 7-7=0 | 34
Now, we remove the w4 column.
Factory | w1 | w3 | D
-------------------------------
F2 | 70 | 40(7) | 9-7=2
F3 | 40 | 70 | 3
-------------------------------
S | 5 | 7-7=0 |
Now, we remove the w3 column.
Factory | w1 | D
-----------------------
F2 | 70(2) | 2-2=0
F3 | 40(3) | 3-3=0
-----------------------
S | 5-2-3=0 |
So finally, we have:
Factory | w1 | w2 | w3 | w4
----------------------------------------------
F1 | 19 | 30 | 50 | 10(7)
F2 | 70(2) | 30 | 40(7) | 60
F3 | 40(3) | 8(8) | 70 | 20(7)
The number of allocations should be m + n - 1:
Again Solving this above question using Vogel's Approximation Method
Factory | w1 | w2 | w3 | w4 | D
---------------------------------------------
F1 | 19 | 30 | 50 | 10 | 7
F2 | 70 | 30 | 40 | 60 | 9
F3 | 40 | 8 | 70 | 20 | 18
---------------------------------------------
S | 5 | 8 | 7 | 14 | 34
Factory | w1 | w2 | w3 | w4 | D | P
---------------------------------------------------------
F1 | 19 | 30 | 50 | 10 | 7 | (9)
F2 | 70 | 30 | 40 | 60 | 9 | (10)
F3 | 40 | 8(8) | 70 | 20 | 18-8=10 | (12)
---------------------------------------------------------
S | 5 | 8-8=0 | 7 | 14 |
P | (21) | (22) | (10) | (10) |
↓
Biggest Penalty
Now we will remove w2 column
Factory | w1 | w3 | w4 | D | P
------------------------------------------------------
F1 | 19(5) | 50 | 10 | 7-5=2 | (9)
F2 | 70 | 40 | 60 | 9 | (20)
F3 | 40 | 70 | 20 | 10 | (20)
------------------------------------------------------
S | 5-5=0 | 7 | 14 |
P | (21) | (10) | (10) |
↓
Biggest Penalty
Now we remove the w1 column
Factory | w3 | w4 | D | P
-------------------------------------------
F1 | 50 | 10 | 2 | (40)
F2 | 40 | 60 | 9 | (20)
F3 | 70 | 20(10) | 10-10=0 | (50) → Biggest Penalty
-------------------------------------------
S | 7 | 14-10=4|
P | (10) | (10) |
Now we remove row 3
Factory | w3 | w4 | D | P
-------------------------------------------
F1 | 50 | 10(2) | 2-2=0 | (40)
F2 | 40 | 60 | 9 | (20)
-------------------------------------------
S | 7 | 4-2=2 |
P | (10) | (50) |
↓
Biggest Penalty
Now we will remove row 1
Factory | w3 | w4 | D | P
-------------------------------------------
F2 | 40(7) | 60(2) | 9-7-2=0 | (20)
-------------------------------------------
S | 7-7=0 | 2-2=0 |
Finally we have:
Factory | w1 | w2 | w3 | w4
-------------------------------------
F1 | 19(5) | 30 | 50 | 10(2)
F2 | 70 | 30 | 40(7) | 60(2)
F3 | 40 | 8(8) | 70 | 20(10)
Transportation cost:
Example Problem - Find the Initial BFS (Basic Feasible Solution) of the Following Transportation Problem:
| w1 | w2 | w3 | Capacity
------------------------------------------------------------
F1 | 10 | 0 | 0 | 10
F2 | 0 | 14 | 1 | 15
F3 | 2 | 0 | 9 | 20
------------------------------------------------------------
Warehouse | 12 | 14 | 10 |
Requirement |
| w1 | w2 | w3 | w4 | Capacity
------------------------------------------------------------
F1 | 10 | 0 | 0 | 0 | 10
F2 | 0 | 14 | 1 | 0 | 15
F3 | 2 | 0 | 9 | 0 | 20
------------------------------------------------------------
Warehouse | 12 | 14 | 10 | 9 |
Requirement |
This test helps in determining whether the current solution to an optimization problem is optimal. It evaluates if any further improvements can be made to the solution. If the solution satisfies the optimality criteria, it is declared the best possible solution; otherwise, adjustments are made to improve the results, and the process is repeated.
| D1 | D2 | D3 | D4 | Avail
-------------------------------------
O1 | 1 | 2 | 1 | 4 | 30
O2 | 3 | 3 | 2 | 1 | 50
O3 | 4 | 2 | 5 | 9 | 20
-------------------------------------
Req | 20 | 40 | 30 | 10 | 100
Writing penalities
| D1 | D2 | D3 | D4 | Avail | P
----------------------------------------------------
O1 | 1 | 2 | 1 | 4 | 30 | (1)
O2 | 3 | 3 | 2 | 1(10) | 50-10=40 | (1)
O3 | 4 | 2 | 5 | 9 | 20 | (2)
---------------------------------------------------
Req | 20 | 40 | 30 | 10-10=0
P | (2) | (1) | (1) | (3)
↓
Biggest Penalty
Remove D4 column
| D1 | D2 | D3 | Avail | P
-----------------------------------------------
O1 | 1(20) | 2 | 1 | 30-20=10 | (1)
O2 | 3 | 3 | 2 | 40 | (1)
O3 | 4 | 2 | 5 | 20 | (2)
-----------------------------------------------
Req | 20-20=0 | 40 | 30 |
P | (2) | (1) | (1) |
↓
Biggest Penalty
Remove D1 column
| D2 | D3 | Avail | P
----------------------------------------------------
O1 | 2 | 1 | 10 | (1)
O2 | 3 | 2 | 40 | (1)
O3 | 2(20) | 5 | 20-20=0 | (2) → Biggest Penalty
---------------------------------------------------
Req | 40-20=20 | 30 |
P | (1) | (1) |
Remove row 3
| D2 | D3 | Avail | P
------------------------------------------
O1 | 2 | 1(10) | 10-10=0 | (1)
O2 | 3 | 2 | 40 | (1)
------------------------------------------
Req | 20 | 30-10=20 |
P | (1) | (1) |
remove row 1
| D2 | D3 | Avail | P
------------------------------------------
O2 | 3(20) | 2(20) | 40-20-20=0 | (1)
------------------------------------------
Req | 20-20=0 | 20-20=0 |
P | (1) | (1)
Finally we have
| D1 | D2 | D3 | D4
-------------------------------------------
O1 | 1(20) | 2 | 1(10) | 4
O2 | 3 | 3(20) | 2(20) | 1(10)
O3 | 4 | 2(20) | 5 | 9
Total transportation cost = 20 + 10 + 60 + 40 + 10 + 40 = 180
| D1 | D2 | D3 | D4 |
-------------------------------------------------
O1 | 1(20) | . | 1(10) | . | u1 = -1
O2 | . | 3(20) | 2(20) | 1(10) | u2 = 0
O3 | . | 2(20) | . | . | u3 = -1
-------------------------------------------
v1 v2 v3 v4
2 3 2 1
We put vi or ui as zero where there are most allocated cost in a row or column. so in the above
table at row 3 we have the most allocated cost so we will put u2 = 0
| D1 | D2 | D3 | D4 |
-------------------------------------------
O1 | . | 2(2) | . | 4(0) | u1 = -1
O2 | 3(2) | . | . | . | u2 = 0
O3 | 4(1) | . | 5(1) | 9(0) | u3 = -1
------------------------------------------
v1 v2 v3 v4
2 3 2 1
Now here for all cij - (ui + vj) the difference is >= 0
Application of Assignment Problem:
Example problem:
Q- Solve the following assignment problem using the Hungarian Method:
| J1 | J2 | J3 |
--------------------
P1 | 10 | 20 | 30 |
P2 | 20 | 10 | 40 |
P3 | 50 | 30 | 20 |
--------------------
| J1 | J2 | J3 |
--------------------
P1 | 10 | 20 | 30 | row 1's minimum cost = 10
P2 | 20 | 10 | 40 | row 2's minimum cost = 10
P3 | 50 | 30 | 20 | row 3's minimum cost = 20
--------------------
| J1 | J2 | J3 |
--------------------------------------
P1 | 10-10=0 | 20-10=10 | 30-10=20 |
P2 | 20-10=10 | 10-10=0 | 40-10=30 |
P3 | 50-20=30 | 30-20=10 | 20-20=0 |
---------------------------------------
| J1 | J2 | J3 |
--------------------
P1 | 0 | 10 | 20 |
P2 | 10 | 0 | 30 |
P3 | 30 | 10 | 0 |
--------------------
| J1 | J2 | J3 |
--------------------
P1 | 0 | 10 | 20 |
P2 | 10 | 0 | 30 |
P3 | 30 | 10 | 0 |
--------------------
| Cost |
-----------------------------
P1-J1 | 10 |
P2-J2 | 10 |
P3-J3 | 20 |
-----------------------------
Total Assignment Cost: 40
Another Example:
Q- Solve the following problem using the Hungarian Assignment Method:
| J1 | J2 | J3 | J4 |
----+----+----+----+----+
P1 | 12 | 30 | 21 | 15 |
P2 | 18 | 33 | 9 | 31 |
P3 | 44 | 25 | 24 | 21 |
P4 | 23 | 30 | 28 | 14 |
----+----+----+----+----+
| J1 | J2 | J3 | J4 |
----+----------+----------+----------+----------+
P1 | 12-12=0 | 30-12=18 | 21-12=9 | 15-12=3 |
P2 | 18-9=9 | 33-9=24 | 9-9=0 | 31-9=22 |
P3 | 44-21=23 | 25-21=4 | 24-21=3 | 21-21=0 |
P4 | 23-14=9 | 30-14=16 | 28-14=14 | 14-14=0 |
----+----------+----------+----------+----------+
It becomes:
| J1 | J2 | J3 | J4 |
----+----+----+----+----+
P1 | 0 | 18 | 9 | 3 |
P2 | 9 | 24 | 0 | 22 |
P3 | 23 | 4 | 3 | 0 |
P4 | 9 | 16 | 14 | 0 |
----+----+----+----+----+
| J1 | J2 | J3 | J4 |
----+----+---------+----+----+
P1 | 0 | 18-4=14 | 9 | 3 |
P2 | 9 | 24-4=20 | 0 | 22 |
P3 | 23 | 4-4=0 | 3 | 0 |
P4 | 9 | 16-4=12 | 14 | 0 |
----+----+----+----+---------+
It becomes:
| J1 | J2 | J3 | J4 |
----+----+----+----+----+
P1 | 0 | 14 | 9 | 3 |
P2 | 9 | 20 | 0 | 22 |
P3 | 23 | 0 | 3 | 0 |
P4 | 9 | 12 | 14 | 0 |
----+----+----+----+----+
| J1 | J2 | J3 | J4 |
----+------+------+------+-------+
P1 | 0 A | 14 | 9 | 3 |
P2 | 9 | 20 | 0 A | 22 |
P3 | 23 | 0 A | 3 | 0 C |
P4 | 9 | 12 | 14 | 0 A |
----+------+------+------+-------+
A - assigned
C - can't assign
| Cost |
----------+-------
P1-J1 | 12
P2-J3 | 9
P3-J2 | 25
P4-J4 | 14
----------+-------
Total Assignment Cost: 60 /-
Q- Four professors are each capable of teaching any one of the four different subects. Class preparation time (in hrs) for different topics varies from professor to professor and is given in the table. Each professor should be assigned only one subject. Find the schedule so as to minimize the total subject preparation time for all subjects/professor.
| S1 | S2 | S3 | S4 |
----+----+----+----+----+
P1 | 2 | 10 | 9 | 7 |
P2 | 15 | 4 | 14 | 8 |
P3 | 13 | 14 | 16 | 11 |
P4 | 3 | 15 | 13 | 8 |
----+----+----+----+----+
In an unbalanced assignment problem, the number of rows (tasks) is not equal to the number of columns (jobs). This happens when the number of tasks to be assigned differs from the number of resources or workers available. To handle such cases, we convert the unbalanced problem into a balanced one by adding dummy rows or columns. These dummy rows or columns are introduced with a cost of zero for all their elements, ensuring that the problem becomes balanced while keeping the integrity of the assignment process intact. This way, each task can still be assigned to a worker, or a job can be assigned to a task, without any imbalance. For example:
Original Matrix (Unbalanced):
| J1 | J2 | J3 |
-------+----+----+----+
P1 | 15 | 20 | 35 |
P2 | 25 | 30 | 25 |
-------+----+----+----+
After adding a dummy row to balance the matrix:
| J1 | J2 | J3 |
----+----+----+----+
P1 | 15 | 20 | 35 |
P2 | 25 | 30 | 25 |
D1 | 0 | 0 | 0 |
----+----+----+----+
Now the problem is balanced, and you can apply the usual steps of row reduction, column reduction, and assignment using the Hungarian Method.
In assignment problems, the objective is usually to minimize the total cost. However, in some cases, the goal is to maximize the total profit or benefit. These are called maximization problems. The Hungarian method, which is typically used for minimization problems, can also be applied to maximization problems with a slight modification. To solve a maximization problem, we convert it into a minimization problem. This is done by subtracting each element of the given matrix from the highest element in the matrix. This transformation effectively inverts the problem, allowing us to use the same Hungarian Method steps of row reduction, column reduction, and allocation for maximization problems. For example:
Original Profit Matrix (Maximization):
| J1 | J2 | J3 |
---+----+----+----+
P1 | 50 | 60 | 40 |
P2 | 70 | 80 | 60 |
P3 | 65 | 55 | 45 |
---+----+----+----+
Step 1: Find the maximum value in the matrix (which is 80 here) and subtract each element from this value:
| J1 | J2 | J3 |
---------+----------+----------+
80-50=30 | 80-60=20 | 80-40=40 |
80-70=10 | 80-80=0 | 80-60=20 |
80-65=15 | 80-55=25 | 80-45=35 |
---------+----------+----------+
Resulting Cost Matrix (for minimization):
| J1 | J2 | J3 |
-----+----+----+----+
P1 | 30 | 20 | 40 |
P2 | 10 | 0 | 20 |
P3 | 15 | 25 | 35 |
-----+----+----+----+
Now, you can apply the usual steps of the Hungarian Method to this transformed matrix to find the optimal assignment.
Conditions:
Application of TSP:
Q- Solve the TSP given by:
| A | B | C | D | E
-----------------------------------
A | ∞ | 2 | 5 | 7 | 1
B | 6 | ∞ | 3 | 8 | 2
C | 8 | 7 | ∞ | 4 | 7
D | 12 | 4 | 6 | ∞ | 5
E | 1 | 3 | 2 | 8 | ∞
| A | B | C | D | E
-----------------------------------
A | ∞ | 1 | 4 | 6 | 0
B | 4 | ∞ | 1 | 6 | 0
C | 4 | 3 | ∞ | 0 | 3
D | 8 | 0 | 2 | ∞ | 1
E | 0 | 2 | 1 | 7 | ∞
| A | B | C | D | E
-----------------------------------
A | ∞ | 1 | 3 | 6 | 0A
B | 4 | ∞ | 0A | 6 | 0C
C | 4 | 3 | ∞ | 0A | 3
D | 8 | 0A | 1 | ∞ | 1
E | 0A | 2 | 0C | 7 | ∞
Now, we try to assign paths, but there will be no complete cycle. This means the current
solution is not optimal.
| A | B | C | D | E
-----------------------------------
A | ∞ | 1A | 3 | 6 | 0C
B | 4 | ∞ | 0C | 6 | 0A
C | 4 | 3 | ∞ | 0A | 3
D | 8 | 0C | 1A | ∞ | 1C
E | 0A | 2 | 0C | 7 | ∞
There is still no complete cycle, so we adjust the assignments.
| A | B | C | D | E
-----------------------------------
A | ∞ | 1A | 3 | 6 | 0C
B | 4 | ∞ | 0A | 6 | 0C
C | 4 | 3 | ∞ | 0A | 3
D | 8 | 0C | 1C | ∞ | 1A
E | 0A | 2 | 0C | 7 | ∞
The cycle is now complete: A - B - C - D - E - A, which forms the optimal solution.
Reference