Lec-16 Assignment Problem - Hungarian Algorithm

nptelhrd · 436K views · 2009 · 1:00:16

Open on YouTube

Algorithms & data structuresUniversity lectures & courseslecture

Why Stack Overflow recommends it

Stack Overflow users link it as a walkthrough of the Hungarian algorithm, both when recommending a way to learn it and when asking about the tricky dead-end cases it shows.

Recommended by 3 people across 3 different months, 2010 to 2016.

What it is

A one-hour NPTEL lecture from IIT Madras in Prof. G. Srinivasan's Fundamentals of Operations Research series, covering the assignment problem and the Hungarian algorithm. It works through the steps on cost matrices, including the harder cases where zeros must be chosen arbitrarily.

Cited in 1 Wikipedia article, including Hungarian algorithm.

What people said

Recommends mohi666 · 2010-10 · Stack Overflow · on “Finding The Max of sum of elements in matrix in distinct rows and columns”

The solution is to use Hungarian Algorithm. It's a complicated algorithm. There's a very good lecture on that on youtube: [this video]

Recommends rroowwllaanndd · 2013-07 · Stack Overflow · on “Given a matrix, how to find the best cell for each row, without repetition”

This is an example of the Linear Assignment [LINK] problem. An optimal solution can be found in O(N^3) time using the Hungarian Algorithm [LINK] , for which there is a decent Python implementation with further information here [LINK] . If you want to get a feel for how the Hungarian Algorithm works - this lecture [this video] is definitely worth watching. If speed is important, a method which can return optimal solutions quickly (although - as far as I can tell - is not guaranteed to do so) is the so-called Softassign algorithm [LINK] , which related to Simulated Annealing [LINK] , and involves iterative row and column normalisation of the cost matrix. Finally, it is of course possible to solve t

Recommends Yay295 · 2016-06 · Stack Overflow · on “Hungarian algorithm dead end”

In this particular example, we can just arbitrarily select a 0. Selecting the top left one gives us 2 1 0(se) 0(su) 0(su) 3 3 0(se) 4 5 2 7 0(su) 7 0(su) 0? 0(su) 5 3 2 3 1 2 0(se) 0(se) 0(su) 6 3 3 5 3 4 5 2 0(se) 3 We can then select the final free 0 and be done. This doesn't always work though. Consider 0 0 0 0 0 0 0 0 0 0 1 2 0 0 3 4 (If you'd prefer a video, I'm using the same problem as here [this video] , though I'll actually solve it.) We can't select anything from the start, so we arbitrarily select the first 0. 0(se) 0(su) 0(su) 0(su) 0(su) 0 0 0 0(su) 0 1 2 0(su) 0 3 4 Now we can select (1,3) because it's the only free 0 in its row. 0(se) 0(su) 0(su) 0(su) 0(su) 0(su) 0 0 0(su) 0(se) 1

Cites jan1 · 2012-03 · Stack Overflow · on “Assignment algorithm: how can I overcome this situation?”

[LINK] The situation I'm about to describe is from the following lecture: [this video] at 32:00 the professor explains this problem, however he doesn't present any solution to it Suppose we are having the following table. The rows represent the workers, the columns the assignments and the values the amount of time a worker needs to complete an assignment 3 1 1 4 4 2 2 5 5 3 4 8 4 2 5 9 Initially I find the min value of each row, and subtract it from all the other values of the same row. I do the same for the columns and I get the following result 0 0 0 0 0 0 0 0 0 0 1 2 0 0 3 4 now, an obvious solution is worker 1 takes the task 4, worker 2 the task 3, worker 3 the task 2, worker 1 the task 1 how

Cites ksm001 · 2013-03 · Stack Overflow · on “Hungarian algorithm: I'm having trouble with assigning as many jobs to workers as possible”

I have created an implementation of the Hungarian algorithm in C++. This implementation works very well for many cases. However there are some cases that my algorithm does not work at all because I believe(and it's true) that my implementation of one step of the algorithm is wrong. My implementation takes as an input the array X , runs the steps of the algorithm and produces the final assignment. The steps of the algorithm can be found on wiki: Hungarian Algorithm [LINK] In step 3 it has the following array of costs(workers are represented by rows and jobs by columns) and then it says Initially assign as many tasks as possible then do the following However I don't understand what a correct i

Cites Iraklis · 2016-06 · Stack Overflow · on “Hungarian algorithm dead end”

I am following the tutorial on [this video] . I stack in the point where he decides which rows and columns are going to be selected for the next step. His example do not have the problem I am facing. Here is the table of my example: 2 1 0 0 0 3 2 0 4 5 2 7 0 7 0 0 0 5 3 2 3 1 2 0 0 0 6 3 3 5 3 4 5 2 0 3 So let's start the rows and columns selection step by step: first row contains >1 zeros => go to next row select (2,1) zero and add (5,1) to suspended zeros third row contains >1 zeros => go to next row select (4,6) zero select (5,1) zero and add (3,1) to suspended zeros select (6,5) zero and add (3,5), (1,5) to suspended zeros Now, the zeros that are left are (1,3), (1,4), (3,3), (3,4) I cannot f

Cites Yay295 · 2016-06 · Stack Overflow · on “Assignment Problem when jobs are available more than once”

This is actually called the Transportation Problem. The Transportation Problem is similar to the Assignment Problem in that they both have sources and destinations, but the Transportation Problem has two more values: each source has a supply, and each destination has a demand. The Assignment Problem is a simplification of the Transportation Problem in which the supply of each source and the demand of each destination is 1. In your case, you have 50,000 sources (your workers) each with a supply of 1 (each worker can only work one job). You also have 10 destinations (the job types) each with some amount of demand (the number of openings for that type). The Transportation Problem is traditional

Cites Tom Baxter · 2016-08 · Stack Overflow · on “Hungarian Algorithm - Arbitrary Choices”

I've looked at several explanations of the Hungarian Algorithm for solving the Assignment Problem and the vast majority of these cover very simplistic cases. The most understandable explanation I've found is a [this video] . I can code the algorithm but I'm concerned about one special case. If you watch the video, the relevant case is explained from 31:55 [this video] to 37:42, but I’ll explain it below. I should first mention that I will be dealing with a 300 x 300 matrix, so visual inspection is out of the question. Additionally, I need to find all minimum assignments. In other words, if there are multiple assignments that produce the same minimum value, I need to find them all. Here's the particula