Vous êtes sur la page 1sur 15

An assignment algorithm

HUNGARIAN METHOD
(THIS IS AN EXACT ALGORITHM.)

EIN4365

Chapter 6 - Layout Planning Models and Design Algorithms

Assignment Model

Example: Due to an increase in the volume of sales, the production capacity will be expanded. A new wing is being added to the plant that will house (1) a punch press, (2) a grinder, (3) a lathe and (4) a welding machine. There are only four possible locations for these machines, say A, B, C, and D. The welding machine will not fit in location B.

EIN4365

Chapter 6 - Layout Planning Models and Design Algorithms

Example

The estimated cost of locating each machine to each possible location ;


A 1 2 3 4 94 62 75 11 B 13 19 88 M C 62 84 18 81 D 71 96 80 21

Chapter 6 - Layout Planning Models and Design Algorithms

Find the minimum cost assignment.


EIN4365 3

Observation

If a constant is added to, or subtracted from, all entries in a row or column of an assignment cost matrix, the optimal assignment is unchanged. Note that the following algorithm always gives the optimal. If the number of locations is larger than the number of machines: Add dummy machines (those locations will remain empty) If the number of machines is larger than the number of machines: Add dummy machines (those machines will not be placed)

EIN4365

Chapter 6 - Layout Planning Models and Design Algorithms

The Hungarian Algorithm


Locate the smallest number in row 1 and subtract it from all entries in row 1. Repeat for all rows. Locate the smallest number in column 1 and subtract it from all entries in column 1. Repeat for all columns. If its possible to make a zero cost assignment, then do it. That will be the optimal solution. If not go to Step 4. Determine the maximum number of zero cost assignments. This will equal the smallest number of lines required to cover all zeros. Choose the smallest number uncovered and Subtract it from all other uncovered numbers. Add it to the numbers where the lines cross. Return to Step 3.

Chapter 6 - Layout Planning Models and Design Algorithms

EIN4365

1. Locate the smallest number in row 1 and subtract it from all entries in row 1.

1 94 13 62 71 2 62 19 84 96 3 75 88 18 80 4 11 M 81 21

1 94-13=81 13-13=0 62-13=49 71-13=58 2 3 4 62 75 11 19 88 M 84 18 81 96 80 21

Repeat for all rows.

EIN4365

Chapter 6 - Layout Planning Models and Design Algorithms

1. Locate the smallest number in row 1 and subtract it from all entries in row 1.

A 1 2 3 4 81 62 75 11

B 0 19 88 M

C 49 84 18 81

D 58 96 80 21 1 2 3 4

A 81 43 57 0

B 0 0 70 M

C 49 65 0 70

D 58 77 62 10

Repeat for all rows.

EIN4365

Chapter 6 - Layout Planning Models and Design Algorithms

2. Locate the smallest number in column 1 and subtract it from all entries in column 1.

A 1 2 3 4 81 43 57 0

B 0 0 70 M

C 49 65 0 70

D 58 77 62 10 1 2 3 4

A 81 43 57 0

B 0 0 70 M

C 49 65 0 70

D 48 67 52 0

Repeat for all columns.

EIN4365

Chapter 6 - Layout Planning Models and Design Algorithms

3. If its possible to make a zero cost assignment, then do it.


That will be the optimal solution.

Chapter 6 - Layout Planning Models and Design Algorithms

A 1 2 3 4 81 43 57 0

B 0 0 70 M

C 49 65 0 70

D 48 67 52 0

If not go to Step 4.

EIN4365

4. Determine the maximum number of zero cost assignments.


This will equal the smallest number of lines required to cover all zeros.

Chapter 6 - Layout Planning Models and Design Algorithms

A 1 2 3 4 81 43 57 0

B 0 0 70 M

C 49 65 0 70

D 48 67 52 0 1 2 3 4

A 81 43 57 0

B 0 0 70 M

C 49 65 0 70

D 48 67 52 0

The number of lines: 3

EIN4365

10

5. Choose the smallest number uncovered and


i. ii. iii. Subtract it from all other uncovered numbers. Add it to the numbers where the lines cross. Return to Step 3.

Chapter 6 - Layout Planning Models and Design Algorithms

A 1 2 3 4 81 43 57 0

B 0 0 70 M

C 49 65 0 70

D 48 67 52 0 1 2 3 4

A 38 0 57 0

B 0 0

C 6 22 0 70

D 5 24 52 0

113
M

The number of lines: 3

EIN4365

11

3. If its possible to make a zero cost assignment, then do it.


This will equal the smallest number of lines required to cover all zeros.

Chapter 6 - Layout Planning Models and Design Algorithms

A 1 2 3 4 38 0 57 0

B 0 0
113

C 6 22 0 70

D 5 24 52 0
1 2 3 A 94 62 75 11 B 13 19 88 M C 62 84 18 81 D 71 96 80 21

If not go to Step 4.

Optimal solution: (A,2), (B,1), (C,3), (D,4) with cost 114.


EIN4365 12

Modeling assignment problem

Assume we have 4 machines (A, B, C, and D)and 4 possible locations (1, 2, 3, and 4). Decision variables:
xij equals 1 iff (i.e, if and only if) machine i is assigned to location j

Objective function:

minimize total assignment cost i 1 j 1 where cij is the cost of assigning i to j

ij

xij

Constraints
Introduction to modeling 13

EIN4365

Modeling assignment problem (contd)

Constraints
Cannot put more than one machine in a location All machines must be assigned to some location Decision variables must be binary (logical)

x
i 1
4

ij

1
1

j {1,...,4}
i {1,...,4}
i, j {1,...,4}

At most one machine to a location

x
j1

ij

All machines should be assigned

x ij {0,1}

Logical contraints

EIN4365

Introduction to modeling

14

Mathematical model of the assignment problem


min
s.t.

c x
i 1 j1
4

ij

ij

x
i 1
4

ij

1
1

j {1,...,4}
i {1,...,4}

x
j1

ij

x ij {0,1}

i, j {1,...,4}

EIN4365

Introduction to modeling

15

Vous aimerez peut-être aussi