Hungarian method (Hungarian algorithm)----solve assignment problems

Source: Internet
Author: User

<title>Hungarian method (Hungarian algorithm)----solve assignment problems (GO)</title> ---Hungarian solution is a novel and simple solution to the assignment problem.
The optimal solution of the---assignment problem has such a property that if the smallest element of the row (column) is subtracted from each element of the coefficient matrix, the new matrix is obtained, and the optimal solution obtained by the new matrix is the same as that of the original matrix. By using this property, the original coefficient matrix can be transformed into a new matrix containing many 0 elements, and the optimal solution remains unchanged.

---The first step: the coefficient matrix of the assignment problem is transformed, and 0 elements appear in each column of the row. (1) Subtract the smallest element of the row from each line element of the coefficient matrix, and (2) subtract the smallest element of the column from each column element of the resulting coefficient matrix. The second step: the trial assignment. If you get the MPN at this point, you should go back to the first step and re-transform the coefficient matrix. But to change the process of the first step to (1) subtract the smallest element of the column from each column element of the coefficient matrix, and (2) subtract the smallest element of the row from each row element of the resulting coefficient matrix. This makes the 0 elements of the new matrix more. The optimal solution can be obtained by entering the second step and assigning the test.
Examples of---Hungarian solution
  

Step one: Transform this coefficient matrix so that each row column appears with 0 elements. Subtracting the smallest element of the row from each line element of the coefficient matrix is the coefficient matrix with 0 elements per row per column.

--------------------------------

Step two: Perform a pilot assignment to find the independent 0 elements. The independent 0 element is expressed in Θ , and the other 0 is indicated by Φ

...... (1)

Here the number of Θ m=4, and n=5; the problem is not solved, using step three to continue to solve.

Step three: Cover all 0 elements in a minimal line to determine the maximum number of independent elements that can be found in the coefficient matrix. To do this, follow these steps.

(1) to the line without Θ to hit the √ number:;

(2) Tick the number of 0 elements contained in the line that has been hit √;

(3) The line that contains the @ element in the column of the √ number is then hit the √ number;

(4) Repeat 2, 3 until you can not get the new number of √.

(5) to a line without a √ number, there is a row in the √ number of the line, which gets the minimum number of straight lines covering all 0 elements.

Make the line number L. If l < n, it is necessary to change the current coefficient matrix to find n independent 0 elements, for this conversion step four, if l = n, and m < n, should go back to step two for further testing.

In this example, the matrix (1) is performed in the following order:

Next to the fifth line to hit √, and then you can judge in the first column to play √, and then on the 3rd line next to the √, after inspection can not play √. Do not hit √ line to draw a straight line to cover 0 elements, the row of a √ to draw a straight line to cover 0 elements, it is:

...... (2)

This shows l = 4 < n. Therefore, you should continue to transform the (2) matrix to step four.

  Step four: The Transformation of the (2) matrix is to increase the 0 elements.

To do this, find the smallest element in a section that is not covered by a line. The smallest element is subtracted from each element of the √ line, and the smallest element is added to each element of the √ column to ensure that the original 0 element is unchanged. This gets the new coefficient matrix (which is the same as the optimal solution and the original problem). If we get n independent 0 elements, the optimal solution is obtained, otherwise we return to step three to repeat.

In The Matrix (2), the smallest element is found to be 2 in the non-covered portion (3rd, 5 rows), and the elements in the 3rd and 5 lines are subtracted by 2 respectively. Add 2 to each element of column l to get a new matrix (3)

...... (3)

Follow step two to find out all the independent 0 elements. Get Matrix (4)

...... (4)

It has n independent 0 elements. The optimal solution is obtained, and the corresponding solution matrix is

  

Optimal assignment scheme by solution matrix:

A--b, b--d, C--e, Ding--c, e--a

The total time required is minz=32.



From for notes (Wiz)

Hungarian method (Hungarian algorithm)----solve assignment problems (GO)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.