190 likes | 475 Views
The Hungarian Algorithm – Maximisation problems. The Hungarian algorithm for maximisation problems To solve a maximisation problem using the Hungarian algorithm, first subtract all elements in the array from the largest number in the array. Then apply the standard Hungarian algorithm:
E N D
The Hungarian Algorithm – Maximisation problems The Hungarian algorithm for maximisation problems To solve a maximisation problem using the Hungarian algorithm, first subtract all elements in the array from the largest number in the array. Then apply the standard Hungarian algorithm: Step 1 Reduce the array by both row and column subtractions Step 2 Cover 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 3 Augment 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 4 Identify the maximal matching which uses only zero elements, and apply this matching to the original array to find the minimum cost.
The Hungarian Algorithm – Maximisation problems Example A team of four athletes are taking part in a competition involving four events: high jump, long jump, discus and 100 m sprint. One athlete must be chosen for each event, and no athlete can take part in more than one event. In each event, the athlete’s result is converted into points. These points are added together to give the total score for the team. The points which each athlete can expect to achieve in each event, based on their personal best, are shown in the table below. Allocate the athletes to the events so that the total team score is as large as possible.
The Hungarian Algorithm – Maximisation problems First convert the problem into a minimisation problem. The largest element in the array is 184, so subtract each element from 184.
The Hungarian Algorithm – Maximisation problems 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 Abby’s row is 25, so subtract 25 from each element in the row.
The Hungarian Algorithm – Maximisation problems 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. Beth’s row already contains a zero, so this row cannot be reduced.
The Hungarian Algorithm – Maximisation problems 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 Claire’s row is 43, so subtract 43 from each element in this row.
The Hungarian Algorithm – Maximisation problems 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 Donna’s row is 2, so subtract 2 from each element in this row.
Allocation problems - The Hungarian Algorithm Step 1: Reduce the array by both row and column subtractions The minimum number of lines needed to cover all the zeros is 2, so the solution is not optimal. Now reduce the array by subtracting the minimum entry in each column from all the entries in the column.
The Hungarian Algorithm – Maximisation problems 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 High jump column is 6, so subtract 6 from each element in the column.
The Hungarian Algorithm – Maximisation problems 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 Long jump and Discus columns already contain zeros, so no column reduction is possible.
The Hungarian Algorithm – Maximisation problems 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 number in the 100 m column is 14, so subtract 14 from each element in this column.
The Hungarian Algorithm – Maximisation problems 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 Discus column has three zeros and Donna’s row has two zeros, so cover these with lines. The remaining zero 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.
The Hungarian Algorithm – Maximisation problems Step 3: Augment the elements The smallest uncovered element is 3 (in square B1). Subtract 3 from all uncovered elements and add 3 to all elements covered by two lines
The Hungarian Algorithm – Maximisation problems Step 3: Augment the elements The smallest uncovered element is 3 (in square B1). Subtract 3 from all uncovered elements and add 3 to all elements covered by two lines Now return to Step 2.
The Hungarian Algorithm – Maximisation problems 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. There are several different ways of covering them with 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.
The Hungarian Algorithm – Maximisation problems Step 4: Identify the maximal matching using zero elements. Look for rows and columns containing just one zero. There is just one zero in Abby’s row and Claire’s row, and there is just one zero in the 100 m column. This means that square B1 must be the fourth zero selected.
The Hungarian Algorithm – Maximisation problems Step 4: Identify the maximal matching using zero elements. From the array, Abby is allocated Discus, Beth is allocated High jump, Claire is allocated Long jump, and Donna is allocated 100 m. Going back to the original array gives the points for each event. Total points = 159 + 175 + 141 + 168 = 643.