Reprint: Task assignment problem---Hungarian algorithm

Source: Internet
Author: User

Transferred from: http://www.cnblogs.com/dwdxdy/p/3261742.html

First, the problem description

Problem Description: N individual assignment n tasks, a person can only assign a task, a task can only be assigned to one person, assigning a task to a person is the need to pay remuneration, how to assign a task, to ensure that the total amount of compensation paid is minimal.

Problem Mathematical Description:

  

Second, case analysis---poor lifting method

Before talking about the Hungarian algorithm to solve the task problem, first analyze several concrete examples.

Take 3 workers and 3 tasks as an example, for the compensation chart and the cost matrix based on the compensation chart.

  

The simplest method (exhaustive method) is used to solve the total compensation cost of all allocations and then the minimum value is calculated.

Total_cost1 = 250 + 600 + 250 = 1100; x00 = 1,x11 = 1,x22 = 1;

Total_cost2 = 250 + 350 + 400 = 1000; x00 = 1,x12 = 1,x21 = 1;

TOTAL_COST3 = 400 + 400 + 250 = 1050; x01 = 1,x10 = 1,x22 = 1;

TOTAL_COST4 = 400 + 350 + 200 = 950;  x01 = 1,x12 = 1,x20 = 1; Optimal allocation

TOTAL_COST5 = 350 + 400 + 400 = 1150; x02 = 1,x10 = 1,x21 = 1;

TOTAL_COST6 = 350 + 600 + 250 = 1150; x02 = 1,x11 = 1,x22 = 1;

For a small number of tasks and personnel, the results can be calculated using the exhaustive method.

if the n task is assigned to n people, it contains all of the assigned number of n!, When n increases, the poor lifting method will be difficult to complete the task.

Third, Hungarian algorithm

The Hungarian algorithm is briefly described below.

The basic theoretical basis is to calculate the cost matrix by adding or subtracting one row or one column of data from the cost matrix, and the optimal task assignment solves the problem.

  

The basic steps of the algorithm are as follows:

  

IV. Example Analysis---Hungarian algorithm

The following is a concrete example of how the Hungarian algorithm solves the task assignment problem.

An instance of n = 4 is the cost list and cost matrix.

  

Step1. Subtract 75 from line 1th, line 2nd minus 35, 3rd line minus 90, 4th line minus 45.

  

Step2. Subtract 0 from column 1th, 2nd column minus 0, 3rd column minus 0, 4th column minus 5.

  

Step3. Cover all 0 with a minimum of horizontal or vertical lines.

  

Step4. Since the total number of horizontal and vertical lines is 3, less than 4, enter STEP5.

Step5. The minimum value that is not overwritten is 5, minus the minimum value of 5 for each row that is overwritten, plus the minimum value of 5 for each column that is overwritten, and then jumps to step 3.

  

Step3. Cover all 0 with a minimum of horizontal or vertical lines.

  

Step4. Since the total number of horizontal and vertical lines is 3, less than 4, enter STEP5.

Step5. The minimum value that is not overwritten is 20, minus the minimum value of 20 for each row that is overwritten, plus the minimum value of 20 for each column that is overwritten, and then jumps to step 3.

  

Step3. Cover all 0 with a minimum of horizontal or vertical lines.

  

Step4. Because the total number of horizontal and vertical lines is 4, the algorithm ends and the allocation results are as shown.

  

The yellow box indicates the allocation result, and the optimal allocation of the left matrix is equivalent to the optimal allocation of the left matrix.

Reprint: Task assignment problem---Hungarian algorithm

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.