Download presentation
Presentation is loading. Please wait.
Published byErick Nicholson Modified over 8 years ago
1
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 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
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. High jumpLong jumpDiscus100 m Abby120155159113 Beth175133184152 Claire134141132104 Donna176174182168 The Hungarian Algorithm – Maximisation problems
3
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 High jumpLong jumpDiscus100 m Abby120155159113 Beth175133184152 Claire134141132104 Donna176174182168 High jumpLong jumpDiscus100 m Abby64155159113 Beth175133184152 Claire134141132104 Donna176174182168 High jumpLong jumpDiscus100 m Abby6429159113 Beth175133184152 Claire134141132104 Donna176174182168 High jumpLong jumpDiscus100 m Abby642925113 Beth175133184152 Claire134141132104 Donna176174182168 High jumpLong jumpDiscus100 m Abby64292571 Beth175133184152 Claire134141132104 Donna176174182168 High jumpLong jumpDiscus100 m Abby64292571 Beth9133184152 Claire134141132104 Donna176174182168 High jumpLong jumpDiscus100 m Abby64292571 Beth951184152 Claire134141132104 Donna176174182168 High jumpLong jumpDiscus100 m Abby64292571 Beth9510152 Claire134141132104 Donna176174182168 High jumpLong jumpDiscus100 m Abby64292571 Beth951032 Claire134141132104 Donna176174182168 High jumpLong jumpDiscus100 m Abby64292571 Beth951032 Claire50141132104 Donna176174182168 High jumpLong jumpDiscus100 m Abby64292571 Beth951032 Claire5043132104 Donna176174182168 High jumpLong jumpDiscus100 m Abby64292571 Beth951032 Claire504352104 Donna176174182168 High jumpLong jumpDiscus100 m Abby64292571 Beth951032 Claire50435280 Donna176174182168 High jumpLong jumpDiscus100 m Abby64292571 Beth951032 Claire50435280 Donna8174182168 High jumpLong jumpDiscus100 m Abby64292571 Beth951032 Claire50435280 Donna810182168 High jumpLong jumpDiscus100 m Abby64292571 Beth951032 Claire50435280 Donna8102168 High jumpLong jumpDiscus100 m Abby64292571 Beth951032 Claire50435280 Donna810216
4
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 High jumpLong jumpDiscus100 m Abby64292571 Beth951032 Claire50435280 Donna810216 High jumpLong jumpDiscus100 m Abby64292571 Beth951032 Claire50435280 Donna810216 High jumpLong jumpDiscus100 m Abby394046 Beth951032 Claire50435280 Donna810216
5
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 High jumpLong jumpDiscus100 m Abby394046 Beth951032 Claire50435280 Donna810216 High jumpLong jumpDiscus100 m Abby394046 Beth951032 Claire50435280 Donna810216
6
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 High jumpLong jumpDiscus100 m Abby394046 Beth951032 Claire50435280 Donna810216 High jumpLong jumpDiscus100 m Abby394046 Beth951032 Claire50435280 Donna810216 High jumpLong jumpDiscus100 m Abby394046 Beth951032 Claire70937 Donna810216
7
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. The Hungarian Algorithm – Maximisation problems High jumpLong jumpDiscus100 m Abby394046 Beth951032 Claire70937 Donna810216 High jumpLong jumpDiscus100 m Abby394046 Beth951032 Claire70937 Donna810216 High jumpLong jumpDiscus100 m Abby394046 Beth951032 Claire70937 Donna68014
8
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. Step 1:Reduce the array by both row and column subtractions High jumpLong jumpDiscus100 m Abby394046 Beth951032 Claire70937 Donna68014
9
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 High jumpLong jumpDiscus100 m Abby394046 Beth951032 Claire70937 Donna68014 High jumpLong jumpDiscus100 m Abby394046 Beth951032 Claire70937 Donna68014 High jumpLong jumpDiscus100 m Abby334046 Beth351032 Claire10937 Donna08014
10
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 High jumpLong jumpDiscus100 m Abby334046 Beth351032 Claire10937 Donna08014 High jumpLong jumpDiscus100 m Abby334046 Beth351032 Claire10937 Donna08014
11
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 High jumpLong jumpDiscus100 m Abby334046 Beth351032 Claire10937 Donna08014 High jumpLong jumpDiscus100 m Abby334046 Beth351032 Claire10937 Donna08014 High jumpLong jumpDiscus100 m Abby334032 Beth351018 Claire10923 Donna0800
12
High jumpLong jumpDiscus100 m Abby334032 Beth351018 Claire10923 Donna0800 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
13
High jumpLong jumpDiscus100 m Abby334032 Beth351018 Claire10923 Donna0800 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 High jumpLong jumpDiscus100 m Abby301029 Beth048015 Claire10923 Donna0800 High jumpLong jumpDiscus100 m Abby301029 Beth048015 Claire101223 Donna0830
14
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 High jumpLong jumpDiscus100 m Abby301029 Beth048015 Claire101223 Donna0830 Now return to Step 2.
15
High jumpLong jumpDiscus100 m Abby301029 Beth048015 Claire101223 Donna0830 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. There are several different ways of covering them with four lines. The Hungarian Algorithm – Maximisation problems
16
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 High jumpLong jumpDiscus100 m Abby301029 Beth048015 Claire101223 Donna0830 High jumpLong jumpDiscus100 m Abby301029 Beth048015 Claire101223 Donna0830 High jumpLong jumpDiscus100 m Abby301029 Beth048015 Claire101223 Donna0830 High jumpLong jumpDiscus100 m Abby301029 Beth048015 Claire101223 Donna0830
17
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. The Hungarian Algorithm – Maximisation problems High jumpLong jumpDiscus100 m Abby301029 Beth048015 Claire101223 Donna0830 High jumpLong jumpDiscus100 m Abby120155159113 Beth175133184152 Claire134141132104 Donna176174182168
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.