Assnmt 1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 42

August 26, 2009

ASSIGNMENT PROBLEM
• It is a matching problem
• Can be used for allocation

Warehouses to Markets
Factories to Markets
Factories to Warehouses
Operator to machines
Machines to Jobs
Salesmen to market territories
Etc.,
Example
• Time matrix is given below.
• Each market should be supplied by one
warehouse only.
MKT1 MKT2 MKT3 MKT4
Warehouse 1 14 5 8 10
Warehouse 2 2 12 6 5
Warehouse 3 7 8 3 9
Warehouse 4 2 4 6 7

We must determine which warehouse to supply


which market to
minimize the total time.
• We may try all possible combinations
There are 4 ! Number of solutions. Find the total time for each solution
and choose the best ???
MKT1 MKT2 MKT3 MKT4

Warehouse 1 14 5 8 10

Warehouse 2 2 12 6 5
Warehouse 3 7 8 3 9
Warehouse 4 2 4 6 7

•We may apply common sense – but may not be consistent and may not guarantee
optimality

• We need smarter ways of solving this problem – optimizing algorithm


Algorithm
Step 1:
• (a) Find the minimum element in each row
of the time matrix. Form a new matrix by
subtracting this time element from the
respective row.
• (b) Find the minimum time in each column
of the new matrix, and subtract this from
each column.
• This is the reduced time matrix.
Example: Step 1(a)
MKT1 MKT2 MKT3 MKT4

Warehouse 1 14 5 8 10
Warehouse 2 2 12 6 5
Warehouse 3 7 8 3 9
Warehouse 4 2 4 6 7

MKT1 MKT2 MKT3 MKT4

Warehouse 1 9 0 3 5
Row Reduction Warehouse 2 0 10 4 3
Warehouse 3 4 5 0 6
Warehouse 4 0 2 4 5
Example: Step 1(b)
MKT1 MKT2 MKT3 MKT4

Warehouse 1 9 0 3 5
Warehouse 2 0 10 4 3
Warehouse 3 4 5 0 6
Warehouse 4 0 2 4 5

MKT1 MKT2 MKT3 MKT4

Warehouse 1 9 0 3 2
Column Reduction Warehouse 2 0 10 4 0
Warehouse 3 4 5 0 3
Warehouse 4 0 2 4 2
Example: Final Solution

MKT1 MKT2 MKT3 MKT4

Warehouse 1 9 0 3 2
Warehouse 2 0 10 4 0
Warehouse 3 4 5 0 3
Warehouse 4 0 2 4 2

Optimal assignment
x12 = 1, x24 = 1, x33 = 1, x41 = 1,
How did we
know which 0’s
to choose?!
FINAL ALLOCATION AND THE
EFFECT
MKT1 MKT2 MKT3 MKT4
Warehouse 1 5
Warehouse 2 5
Warehouse 3 3
Warehouse 4 2

What is the effect ?

Find the value of the solution in terms of total time


WHAT IS THE VALUE OF THE
SOLUTION
• X 12 = 5
• X 24 = 5
• X 33 = 3
• X41 = 2

• TOTAL TIME = 15
• Can you find a solution better than this ?
PRACTICE PROBLEM
• A DEPARTMENT HAS 4 JOBS AND 4
MEN.
• ROWS REPRESENT JOBS 1 To 4
• COLUMNS REPRESENT MEN A TO D
• THE TIME MATRIX IS GIVEN.
• CHOOSE THE BEST JOB-MAN
COBINATIONS.
M/C1 M/C2 M/C3 M/C 4
8 26 17 11
Job 1

13 28 4 26
Job 2

38 19 18 15

Job 3

19 26 24 10

Job4
THE PROBLEM
• AIM : TO MINIMIZE THE TOTAL TIME
TAKEN TO COMPLETE ALL JOBS.
• THERE ARE 4! NUMBER OF POSSIBLE
ALLOCATIONS.
• REQUIREMENT :
A SYSTEMATIC METHOD.
HUNGARIAN METHOD
PHASE 1
STEPS
• Row operation
Find the smallest number in each row and Subtract
it from the remaining elements in that row.

• Column operation
Find the minimum element in each column and
subtract it from the other elements in the
respective column

• Check if allocation is possible


See if we have the number of independent zeros
equal to number of rows or columns.
8 26 17 11
13 27 4 26
38 19 18 15
19 26 24 10

0 18 9 3
9 23 0 22
23 4 3 0
9 16 14 0

0 14 9 3
9 19 0 22
23 0 3 0
9 12 14 0
COMMENTS
HERE
THE INDEPENDENT ASSINGNMENTS ARE:
A-1 (8)
B-3 (19)
C-2 (4)
D-4 (10)

CHECK THE ORIGINAL MATRIX AND CHECK THE


EFFECTIVENESS (41)

IF THE INDEPENDENT ASSINGNMENTS ARE < n, WHERE n IS


EQUAL TO THE NUMBER OF ALLOCATIONS REQUIRED

GO TO PHASE 2
WILL IT BE THIS SIMPLE ALWAYS ?
Consider an example

• Same situation, but the numbers are


slightly different
Example
• We must determine which warehouse to supply
which market minimize the total time. Time
matrix is given below.
• Each market should be supplied by one
warehouse only.

MKT1 MKT2 MKT3 MKT4


Warehouse 1 14 5 8 7
Warehouse 2 2 12 6 5
Warehouse 3 7 8 3 9
Warehouse 4 2 4 6 10
Hungarian Algorithm Phase1
Step 1:
• (a) Find the minimum element in each row
of the time matrix. Form a new matrix by
subtracting this time from each row.
• (b) Find the minimum time in each column
of the new matrix, and subtract this from
each column.
• This is the reduced time matrix.
Example: Step 1(a)
MKT1 MKT2 MKT3 MKT4

Warehouse 1 14 5 8 7
Warehouse 2 2 12 6 5
Warehouse 3 7 8 3 9
Warehouse 4 2 4 6 10

MKT1 MKT2 MKT3 MKT4

Warehouse 1 9 0 3 2
Row Reduction Warehouse 2 0 10 4 3
Warehouse 3 4 5 0 6
Warehouse 4 0 2 4 8
Example: Step 1(b)
MKT1 MKT2 MKT3 MKT4

Warehouse 1 9 0 3 2
Warehouse 2 0 10 4 3
Warehouse 3 4 5 0 6
Warehouse 4 0 2 4 8

MKT1 MKT2 MKT3 MKT4

Warehouse 1 9 0 3 0
Column Reduction Warehouse 2 0 10 4 1
Warehouse 3 4 5 0 4
Warehouse 4 0 2 4 6
THE PROBLEM ?
• Only 3 allocations are possible
• We need 4 allocations

Go to Phase 2
Hungarian Algorithm Phase 2
• Step 2: Draw the minimum number of
lines that are needed to cover all the zeros
in the reduced cost matrix.
• If m (number of assignments required)
lines are available, then an optimal
solution is available among the covered
zeros in the matrix.
• Otherwise, continue to Step 3. How do we
find the
minimum
number of
lines?
Example: Step 2

MKT1 MKT2 MKT3 MKT4

Warehouse 1 9 0 3 0
Warehouse 2 0 10 4 1
Warehouse 3 4 5 0 4
Warehouse 4 0 2 4 6

We have 3 lines, but


we need 4 lines.
Now continue with Step 3
Hungarian Algorithm
• Step 3: Find the smallest nonzero element
(say, k) in the reduced time matrix that is
uncovered by the lines.
• Subtract k from each uncovered element,
and add k to each element that is covered
by two lines.
• Return to Step 2.
Example: Step 3

MKT1 MKT2 MKT3 MKT4

Warehouse 9 0 3 0
Warehouse 0 10 4 1
Warehouse 4 5 0 4
Warehouse 0 2 4 6

MKT1 MKT2 MKT3 MKT4

Warehouse 10 0 3 0
Warehouse 0 9 3 0
Warehouse 5 5 0 4
Warehouse 0 1 3 5
Example: Step 2 (again)

Zero Assignment

MKT1 MKT2 MKT3 MKT4

Warehouse 1 10 0 3 0
Warehouse 2 0 9 3 0
Warehouse 3 5 5 0 4
Warehouse 4 0 1 3 5

There are 4 lines.


We can get the optimal assignment.
We stop
Example: Final Solution

MKT1 MKT2 MKT3 MKT4

Warehouse 1 10 0 3 0
Warehouse 2 0 9 3 0
Warehouse 3 5 5 0 4
Warehouse 4 0 1 3 5

Optimal assignment
x12 = 1, x33 = 1, x41 = 1, x24 = 1
How did we
know which 0’s
to choose?!
HOW TO DRAW THE LINES
SYSTEMATICALLY ?
• CONSIDER ONE MORE EXAMPLE
CONSIDER THE FOLLOWING
EXAMPLE
• There are 5 operators and 5 jobs

• Time required by each operator to


complete each job is given
Job1 Job2 Job3 Job 4 JOb5

11 17 8 16 20
M1

9 7 12 6 15
M2

13 16 15 12 16
M3

21 24 17 28 26
M4

14 10 12 11 15

M5
3 9 0 8 12
3 1 6 0 9
1 4 3 0 4
4 7 0 11 9
4 0 2 1 5

2 9 0 8 8
2 1 6 0 5
0 4 3 0 0
3 7 0 11 5
3 0 2 1 1
PHASE 2 0F ASSIGNMENTS

STEPS
• MARK ALL ROWS HAVING NO
ASSINGNMENT
• MARK COLUMNS WITH ZEROS IN MARKED
ROWS.
• MARK ROWS THAT HAVE ASSIGNMENTS IN
MARKED COLUMN.
• REPEAT STEPS 1 TO 3 TILL THE CHAIN OF
MARKING ENDS.
• DRAW LINES THROUGH UNMARKED ROWS
AND MARKED COLUMNS.
2 9 0 8 8
2 1 6 0 5
0 4 3 0 0
3 7 0 11 5
3 0 2 1 1
CHECK
IF THE PROCEDURE HAS BEEN CARRIED OUT CORRECTLY:

THERE SHOULD BE AS MANY LINES AS THERE


ARE ASSIGNMENTS IN THE MAXIMAL ASSIGNMENT

EVERY ZERO WILL HAVE AT LEAST ONE LINE


THROUGH IT.

THIS METHOD YIELDS THE MINIMUM NUMBER OF LINES THAT


WILL PASS THROUGH ALL ZEROS.

HAVING DRAWN THE SET OF LINES IN STEPS 1 TO 4, DO THE


FOLLOWING.
0 7 0 6 6
2 1 8 0 5
0 4 5 0 0
1 5 0 9 3
3 0 4 1 1
IMPORTANT STEP TO FIND
ADDITIONAL ALLOCATION
• EXAMINE ELEMENTS THAT DO NOT
HAVE A LINE THROUGH THEM.
• SELECT THE SMALLEST OF THESE
AND SUBTRACT IT FROM ALL THE
ELEMNTS THAT DO NOT HAVE A LINE
THROUGH THEM.
• ADD THIS SMALLEST ELEMENT TO
EVERY ELEMENT THAT LIES AT THE
INTERSECTION OF TWO LINES.
• LEAVE THE REMAINING ELEMENTS OF
THE MATRIX UNCHANGED.
0 7 0 6 6
2 1 8 0 5
0 4 5 0 0
1 5 0 9 3
3 0 4 1 1
FINAL SOLUTION

• X11 = 1 ( 11)
• X24 = 1 (6)
• X35 = 1 (16)
• X43 = 1 (17 )
• X52 = 1 (10)

• Total Value = 60
PRACTICE PROBLEMS
MAN 1 2 3 4 5
JOBS
A 10 5 13 15 16
B 3 9 18 13 6
C 10 7 2 2 2
D 7 11 9 7 12
E 7 9 10 4 12
ANSWER : A-2, B-1, C-5, D-3, E-4 ( CHECK)
> A, B, C, D, E ARE THE TOWNS REACHING WHICH CARS ARE TO
BE HIRED.
> a, b, c, d, e ARE CAR DEPOTS FROM WHERE CARS CAN BE HIRED.
EACH DEPOT CAN ONLY GIVE CAR TO REACH ONE TOWN.

MATRIX- DISTANCE BETWEEN DEPOT AND TOWN


LINK THE DEPOT AND THE TOWN TO MINIMISE TOTAL DISTENCE

DEPOTS

a b c d e
A 160 130 175 190 200
TOWNS
B 135 120 130 160 175

C 140 110 155 170 185

D 50 50 90 80 110

E 55 35 70 80 105

ANS : A-e, B-c, C-b, D-a, E-d


( CHECK)

You might also like