Presentation is loading. Please wait.

Presentation is loading. Please wait.

Allocation problems - The Hungarian Algorithm The Hungarian algorithm Step 1Reduce the array by both row and column subtractions Step 2Cover the zero elements.

Similar presentations


Presentation on theme: "Allocation problems - The Hungarian Algorithm The Hungarian algorithm Step 1Reduce the array by both row and column subtractions Step 2Cover the zero elements."— Presentation transcript:

1 Allocation problems - The Hungarian Algorithm The Hungarian algorithm Step 1Reduce the array by both row and column subtractions Step 2Cover the zero elements with the minimum number of lines. If the number of lines is the same as the size of the array, then go to Step 4. Step 3Augment the elements. To do this, identify the minimum uncovered element. Subtract this element from all uncovered elements, and add this element to all elements covered by two lines. Then return to step 2. Step 4Identify the maximal matching which uses only zero elements, and apply this matching to the original array to find the minimum cost.

2 Allocation problems - The Hungarian Algorithm Example Four workers are to be assigned to four tasks. No worker is to carry out more than one task. The expected times taken for each worker to carry out each of the tasks is shown below. Allocate the workers to the tasks so that the total time taken is as short as possible, giving the minimum time required. Task 1Task 2Task 3Task 4 Eva35241742 Fred33212335 George27201633 Holly29311938

3 Task 1Task 2Task 3Task 4 Eva35241742 Fred33212335 George27201633 Holly29311938 Allocation problems - The Hungarian Algorithm Step 1:Reduce the array by both row and column subtractions Task 1Task 2Task 3Task 4 Eva35241742 Fred33212335 George27201633 Holly29311938 To reduce by row subtractions, subtract the smallest element in each row from each element in the row. The smallest element in Eva’s row is 17, so subtract 17 from each element in the row. Task 1Task 2Task 3Task 4 Eva18241742 Fred33212335 George27201633 Holly29311938 Task 1Task 2Task 3Task 4 Eva1871742 Fred33212335 George27201633 Holly29311938 Task 1Task 2Task 3Task 4 Eva187042 Fred33212335 George27201633 Holly29311938 Task 1Task 2Task 3Task 4 Eva187025 Fred33212335 George27201633 Holly29311938

4 Allocation problems - The Hungarian Algorithm Step 1:Reduce the array by both row and column subtractions To reduce by row subtractions, subtract the smallest element in each row from each element in the row. The smallest element in Fred’s row is 21, so subtract 21 from each element in the row. Task 1Task 2Task 3Task 4 Eva187025 Fred33212335 George27201633 Holly29311938 Task 1Task 2Task 3Task 4 Eva187025 Fred12212335 George27201633 Holly29311938 Task 1Task 2Task 3Task 4 Eva187025 Fred1202335 George27201633 Holly29311938 Task 1Task 2Task 3Task 4 Eva187025 Fred120235 George27201633 Holly29311938 Task 1Task 2Task 3Task 4 Eva187025 Fred120214 George27201633 Holly29311938

5 Allocation problems - The Hungarian Algorithm Step 1:Reduce the array by both row and column subtractions To reduce by row subtractions, subtract the smallest element in each row from each element in the row. The smallest element in George’s row is 16, so subtract 16 from each element in the row. Task 1Task 2Task 3Task 4 Eva187025 Fred120214 George27201633 Holly29311938 Task 1Task 2Task 3Task 4 Eva187025 Fred120214 George11201633 Holly29311938 Task 1Task 2Task 3Task 4 Eva187025 Fred120214 George1141633 Holly29311938 Task 1Task 2Task 3Task 4 Eva187025 Fred120214 George114033 Holly29311938 Task 1Task 2Task 3Task 4 Eva187025 Fred120214 George114017 Holly29311938

6 Allocation problems - The Hungarian Algorithm Step 1:Reduce the array by both row and column subtractions To reduce by row subtractions, subtract the smallest element in each row from each element in the row. The smallest element in Holly’s row is 19, so subtract 19 from each element in the row. Task 1Task 2Task 3Task 4 Eva187025 Fred120214 George114017 Holly29311938 Task 1Task 2Task 3Task 4 Eva187025 Fred120214 George114017 Holly10311938 Task 1Task 2Task 3Task 4 Eva187025 Fred120214 George114017 Holly10121938 Task 1Task 2Task 3Task 4 Eva187025 Fred120214 George114017 Holly1012038 Task 1Task 2Task 3Task 4 Eva187025 Fred120214 George114017 Holly1012019

7 Allocation problems - The Hungarian Algorithm The minimum number of lines needed to cover all the zeros is 2, Now reduce the array by subtracting the minimum entry in each column from all the entries in the column. so the solution is not optimal. Task 1Task 2Task 3Task 4 Eva187025 Fred120214 George114017 Holly1012019 Step 1:Reduce the array by both row and column subtractions

8 Task 1Task 2Task 3Task 4 Eva187025 Fred120214 George114017 Holly1012019 Task 1Task 2Task 3Task 4 Eva187025 Fred120214 George114017 Holly1012019 Allocation problems - The Hungarian Algorithm Step 1:Reduce the array by both row and column subtractions To reduce by column subtractions, subtract the smallest element in each column from each element in the column. The smallest element in the Task 1 column is 10, so subtract 10 from each element in the column. Task 1Task 2Task 3Task 4 Eva87025 Fred120214 George114017 Holly1012019 Task 1Task 2Task 3Task 4 Eva87025 Fred20214 George114017 Holly1012019 Task 1Task 2Task 3Task 4 Eva87025 Fred20214 George14017 Holly1012019 Task 1Task 2Task 3Task 4 Eva87025 Fred20214 George14017 Holly012019

9 Allocation problems - The Hungarian Algorithm Step 1:Reduce the array by both row and column subtractions To reduce by column subtractions, subtract the smallest element in each column from each element in the column. The Task 2 and Task 3 columns both contain zeros, so no column subtraction can be done in these two columns. Task 1Task 2Task 3Task 4 Eva87025 Fred20214 George14017 Holly012019

10 Allocation problems - The Hungarian Algorithm Step 1:Reduce the array by both row and column subtractions To reduce by column subtractions, subtract the smallest element in each column from each element in the column. The smallest element in the Task 4 column is 14, so subtract 14 from each element in column 4. Task 1Task 2Task 3Task 4 Eva87025 Fred20214 George14017 Holly012019 Task 1Task 2Task 3Task 4 Eva87011 Fred20214 George14017 Holly012019 Task 1Task 2Task 3Task 4 Eva87011 Fred2020 George14017 Holly012019 Task 1Task 2Task 3Task 4 Eva87011 Fred2020 George1403 Holly012019 Task 1Task 2Task 3Task 4 Eva87011 Fred2020 George1403 Holly01205

11 Allocation problems - The Hungarian Algorithm Step 2:Cover the zero elements with the minimum number of lines Look for rows and columns containing more than one zero. In this case, the Task 3 column has three zeros and Fred’s row has two zeros, so cover these with lines. Task 1Task 2Task 3Task 4 Eva87011 Fred2020 George1403 Holly01205 The remaining zero, in square H1, can be covered by either a vertical or horizontal line. The choice of line will not affect the final result. Three lines have been used, so this array does not give the optimal allocation.

12 Allocation problems - The Hungarian Algorithm Step 3:Augment the elements The smallest uncovered element is 1 (in square G1). Task 1Task 2Task 3Task 4 Eva87011 Fred2020 George1403 Holly01205 Subtract 1 from all uncovered elements and add 1 to all elements covered by two lines Task 1Task 2Task 3Task 4 Eva77011 Fred2020 George1403 Holly01205 Task 1Task 2Task 3Task 4 Eva76011 Fred2020 George1403 Holly01205 Task 1Task 2Task 3Task 4 Eva76010 Fred2020 George1403 Holly01205 Task 1Task 2Task 3Task 4 Eva76010 Fred2020 George0403 Holly01205 Task 1Task 2Task 3Task 4 Eva76010 Fred2020 George0303 Holly01205 Task 1Task 2Task 3Task 4 Eva76010 Fred2020 George0302 Holly01205 Task 1Task 2Task 3Task 4 Eva76010 Fred2030 George0302 Holly01205 Task 1Task 2Task 3Task 4 Eva76010 Fred2030 George0302 Holly01215

13 Allocation problems - The Hungarian Algorithm Step 3:Augment the elements The smallest uncovered element is 1 (in square G1). Subtract 1 from all uncovered elements and add 1 to all elements covered by two lines Task 1Task 2Task 3Task 4 Eva76010 Fred2030 George0302 Holly01215 Now return to Step 2.

14 Allocation problems - The Hungarian Algorithm Step 2:Cover the zero elements with the minimum number of lines. Again, look for rows and columns containing more than one zero. Here, the Task 1 and Task 3 columns and Fred’s row each have two zeros. Covering these with lines covers all the zeros. Task 1Task 2Task 3Task 4 Eva76010 Fred2030 George0302 Holly01215 Three lines have been used, so this array still does not give the optimal allocation.

15 Allocation problems - The Hungarian Algorithm Step 3:Augment the elements. The smallest uncovered element is 2 (in square G4). Task 1Task 2Task 3Task 4 Eva76010 Fred2030 George0302 Holly01215 Subtract 2 from all uncovered elements and add 2 to all elements covered by two lines. Task 1Task 2Task 3Task 4 Eva74010 Fred2030 George0302 Holly01215 Task 1Task 2Task 3Task 4 Eva7408 Fred2030 George0302 Holly01215 Task 1Task 2Task 3Task 4 Eva7408 Fred2030 George0102 Holly01215 Task 1Task 2Task 3Task 4 Eva7408 Fred2030 George0100 Holly01215 Task 1Task 2Task 3Task 4 Eva7408 Fred2030 George0100 Holly01015 Task 1Task 2Task 3Task 4 Eva7408 Fred2030 George0100 Holly01013 Task 1Task 2Task 3Task 4 Eva7408 Fred4030 George0100 Holly01013 Task 1Task 2Task 3Task 4 Eva7408 Fred4050 George0100 Holly01013

16 Allocation problems - The Hungarian Algorithm Step 3:Augment the elements. The smallest uncovered element is 2 (in square G4). Subtract 2 from all uncovered elements and add 2 to all elements covered by two lines. Task 1Task 2Task 3Task 4 Eva7408 Fred4050 George0100 Holly01013 Now return to Step 2.

17 Allocation problems - The Hungarian Algorithm Step 2:Cover the zero elements with the minimum number of lines. In this case, it is not possible to cover the zero elements with less than four lines. Since four lines are required for this 4 by 4 array, the optimal allocation can now be found from this array. Now go to Step 4. Task 1Task 2Task 3Task 4 Eva7408 Fred4050 George0100 Holly01013 There are several different ways of covering them with four lines.

18 Allocation problems - The Hungarian Algorithm Step 4:Identify the maximal matching using zero elements. Look for rows and columns containing just one zero. Task 1Task 2Task 3Task 4 Eva7408 Fred4050 George0100 Holly01013 There is just one zero in Eva’s row and Holly’s row, and there is just one zero in the Task 2 column. Task 1Task 2Task 3Task 4 Eva7408 Fred4050 George0100 Holly01013 Task 1Task 2Task 3Task 4 Eva7408 Fred4050 George0100 Holly01013 Task 1Task 2Task 3Task 4 Eva7408 Fred4050 George0100 Holly01013 This means that square G4 must be the fourth zero selected.

19 Allocation problems - The Hungarian Algorithm Step 4:Identify the maximal matching using zero elements. Task 1Task 2Task 3Task 4 Eva7408 Fred4050 George0100 Holly01013 From the array, Eva is allocated Task 3, Fred is allocated Task 2, George is allocated Task 4, and Holly is allocated Task 1. Going back to the original array gives the times for each task. Task 1Task 2Task 3Task 4 Eva35241742 Fred33212335 George27201633 Holly29311938 Total time required = 17 + 21 + 33 + 29 = 100.


Download ppt "Allocation problems - The Hungarian Algorithm The Hungarian algorithm Step 1Reduce the array by both row and column subtractions Step 2Cover the zero elements."

Similar presentations


Ads by Google