Lec-16 Assignment Problem - Hungarian Algorithm

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
In the last lecture we introduced the assignment problem. The assignment problem is one where we have an equal number of jobs that have to be given to equal number of people. In this example there are 4 jobs and 4 people, the problem is one of assigning jobs to people such that the total cost is minimized subject to the condition that each job goes to exactly 1 person and each person gets exactly 1 job. So for a 4 into 4 assignments problem represented this way. The 5 represents the cost of assigning job 1 to person 1 and so on. The assignment matrix is always a square matrix. Assignment problems are shown as a special case of the transportation problem where we have an equal number of supply points and demand points and all supplies and requirements is = 1. So assignment problem is also formulated considering decision variables Xij = 1, if job i goes to person j0 otherwise. It has a minimization function. So minimize Cij Xij subject to the condition, sigma Xij = 1 for every j and sigma Xij = 1 for every i, Xij = 0, 1. Now for every j this is for j = 1 summed over all, i which means this person gets exactly 1 job and the other constraint would mean that this job goes exactly to 1 person. We also looked at 2 important properties of the assignment problem. We said it is very reasonable to assume that Cij is greater than or equal to 0. Cost of person doing a job is non negative or strictly positive and if Cij is greater than or equal to 0, then a feasible solution with Z = 0 is optimal. So what is a feasible solution? For example job 1 to person 1, job 2 to person 2, 3 to person 3, 4 to person 4 is feasible, so 5 + 7 = 12 + 12 = 24 + 6 = 30. A solution is feasible if we have exactly 4 assignments for this problem and 1 assignment for every row and 1 assignment for every column. We also saw that if you consider a row like this with 5, 9, 3 and 6 which means, to do job 1, person 1 charges Rs 5, person 2 charges Rs 9 and so on. We also said if each of them decides to increase the cost by 1, example this becomes 6, 10, 4 and 7 then we said the solution will not change because anyway this job has to go to 1 person. It will go to the same person because all of them have increased the cost by 1. So the same will hold if all of them reduce the cost by 1 which motivates us to subtract the row minimum from each row and get a new table which is like this. So we subtract the row minimum from this to get a new table which is like this. So row minimum is 3 and I have 2, 6, 0, and 3. Row minimum is 2, 6, 5, 6, and 0. Row minimum is 6, 0, 4, 6, and 1. Row minimum is 3, 0, 7, 5 and 3. Once again if this person decides to increase the cost by 1 rupee, for all the jobs and becomes 6, 9, 7 and 4 respectively then once again the solution will not change. Only the objective function value will change because this person has to get 1 job. Now the same rule holds when this person reduces the cost for each and makes this 4, 7, 5 and 2 respectively. The solution will not change. This motivates us to do column minimum subtraction. Now that we have already reduced from this matrix we have gone to this matrix. Now we look at column minimum subtraction for the reduced matrix and then write a new assignment matrix. Column minimum is 0, so we retain the same thing therefore, 2, 6, 0, and 0. Here the column minimum is 4 so 2, 1, 0, and 3. Here the column minimum is 0, 6, 6, and 5 and we have 3, 0, 1, and 3. After performing 1 iteration of row minimum and 1 iteration of column minimum, we are sure about the fact that this matrix has at least 1, 0 in every row and 1, 0 in every column. Now we start making assignments and allocations only on the 0s because of the first rule which says if I have a feasible solution with Z = 0 then it is optimal. We also know that the optimal solution to this matrix is the same as the optimal solution to this matrix though the value of the objective function will change. Let us try to get an arbitrary feasible solution with Z = 0. For example if we make assignments like this, we have made 4 assignments, 1 in each row and 1 in each column so this is a feasible solution with Z = 0 because we have made our assignments only in 0 positions. This is optimal because of this property and therefore the optimal solution to this will have an allocation here. Job 1 goes to person 3, job 2 goes to person 4, job 3 goes to person 2, job 4 goes to person 1 with Z = 3 + 2 = 5 + 10 = 15 + 3 = 18. So the optimal solution has Z = 18. So now from this result, this solution is feasible solution with Z = 0 is optimal. Now there are 2 questions. From the matrix that we had here, after the O column reduction, i.e., the matrix that we had, this is a small example so by looking at the matrix, we will be able to get a feasible solution with Z = 0, if we had decided to get our feasible solution in a different way, for example we started with this and then we realized we started with this. If we had allocated this 0, then we cannot allocate here. We also cannot allocate here because the constraints would mean that every job goes to exactly 1 person and every person gets exactly 1 job. If we decide on an arbitrary order, in which we start allocating then we may get into a situation where we have 3 assignments as against the possible 4.There is something called a maximal assignment given a matrix with 0s and there are some rules that help us get the get as many assignments as possible in a given matrix with 0s and positive numbers. Let us look at that. Now the rule is like this, if any row or any column has exactly one 0, we will make an assignment. So this row has one 0. We make an assignment once. This assignment is made. Other 0s in this column cannot be assigned and there are no 0s. So we will leave it like that. Now this row has exactly one 0. Make an assignment. There are no other 0s in the column. So leave it. This row has two 0s so when we have two 0s, leave that row or column temporarily and proceed further. Now the 4th row has exactly one 0, so make an assignment and once we make an assignment here this cannot be assigned. Now go back to the column. 1st column already has an assignment. 2nd column has exactly one assignable, 0 so we can make an assignment 3rd and 4th are already assigned. If we go back to the rows we see that this row has only one assignable 0 therefore we make an assignment. So we follow this rule consistently, the rule is if there is an assignable 0, only 1 assignable 0, in any row or any column assign it. If there are more than 1, leave it and proceed. Now this rule would try to give us as many assignments as possible. Now the next question is this example, with 1 iteration of 1 row minimum subtraction and column minimum subtraction by using the rule to assign we have got the optimal solution. Can we get into a situation where we may not get the optimal solution? Can something like that also happen? We look at that with another example. The second example has 5 jobs and 5 people. It is a 5/5 assignment problem, so as usual we find out the row minimum and subtract the row minimum from every element of that row. So for the first row the row minimum is 7, so we get 4, 0, 3, 10, and 3. Here the row minimum is 7 so 6, 7 + 7 = 14, 0, 4, and 6. Here the row minimum is 13 we get 0, 0, 2, 0, 1. Here the row minimum is 10, so we get 8, 0, 3, 6 and 4 Here the row minimum is 8 so 12 - 8 = 4, 0, 8, 11 and 2 We realize that these 4 columns have a 0 and the 5th column does not have a 0, so we subtract the column minimum from the 5th to get a new reduced matrix which is 4, 6, 0, 8, 4, 0, 14, 0, 0, 0, 3, 0, 2, 3, 8, 10, 4, 0, 6, 11, 2, 5, 0, 3, and 1. So we have subtracted the row minimum and column minimum to get this reduced matrix. The optimal solution to this will be the same as optimal solution to this. We try to identify if we can get a basic feasible solution or a feasible solution with Z = 0. Now we start making our allocations. This row has only one assignable 0 so we make an allocation here because we have made an allocation here. Now these 0s cannot be allocated. The second row has only 1, 0, so make an assignment. Now there are no additional 0s in that column and we leave it. The third row has more than 1, 0, so we leave it. The 4th and the 5th do not have any assignable 0s. We do this column wise. The first column has only one assignable 0. So we make an assignment, therefore the other two 0s are not assignable anymore. Now we are unable to proceed because all the 0s have either been assigned or crossed. This cross indicates that it is not fit for assignment because assignments are already made. Since all 0s are covered either with a box which represents an assignment or a cross, we stop the assigning process. Now we realize that we have 3 assignments for this 5/5 matrix. We did not have 5. In the earlier example we were able to get 4 assignments for a 4/4. Now we have got only 3 for a 5/5 problem. Now how do we get the remaining 2? Now we follow another procedure to proceed from these 3 assignments to 5 assignments and let us do that procedure as follows. Tick an unassigned row. So this is an unassigned row. So we put a tick mark. This is an unassigned row. We put a tick mark; tick the corresponding column if there is a 0 so there is a 0 earlier so we tick the corresponding column. This row is already ticked, so come back. There is a 0, so put a tick mark in the corresponding column. Similarly put a tick mark in the corresponding column. It is already ticked so leave it. Now look at all the columns that have a tick mark. If there is an assignment in that column, put a tick mark in the corresponding row so there is an assignment here we put it. Now come back. There is only 1, 0, it is already ticked. There are no other 0s, so the algorithm stops when no more ticking is possible. Now draw lines through unticked rows, unticked columns 1, 2 and 3. Now this will cover all the 0s. Once again let us write this procedure as follows. 1. Either tick an unassigned row or tick all unassigned rows. 2. If a ticked row has a 0, then tick the corresponding column. 3. If a ticked column has an assignment, then tick the corresponding row. Now this is assuming that the row is already not ticked, if it is already ticked then leave it. Repeat steps 2 and 3 which mean tick all unassigned rows, till no more ticking is possible. 4. Draw lines through unticked rows and ticked columns. Now that is shown here, Tick all unassigned rows. If a row is ticked and has a 0, then tick the corresponding column if the column is not ticked yet. If a column is ticked and has an assignment then tick the corresponding row if the row is not ticked yet. Repeat steps 2 and 3, till no more ticking is possible. Draw lines through unticked rows and ticked columns. The number of lines represents the maximum number of assignments possible. We have 3 lines here, so 3 assignments are possible. We have the 3 assignments here, now the next thing that we need to do is to reconstruct this matrix. Find out the smallest number which does not have any line passing through it so that is this number 1 and we call this as theta. Now theta = 1. Theta is the smallest number which has no line passing through it. In fact the lines will now cover all the 0s. So we will have only the non zero numbers appearing. So find out the smallest one which is this. Now do this. Now subtract theta from all the numbers that do not have any line passing through them, add theta to all those numbers that have 2 lines passing through them and keep the rest of them the same. For example a number like this which has 1 line passing through will not change. For example this 4 will become 3, 0 remains as 0, 3 becomes 2, 10 becomes 9, 2 becomes 1, 6 remains as 6, 14 becomes 15 because we add 1 here, because it has 2 lines passing through it, it becomes 15. 0 remains as 0, 4 remains as 4, 5 remains as 5, 0 remains as 0, this 0 becomes 1, because 2 lines pass through, 2 remains as 2, and 0 and 0. 8 becomes 7, 0 remains as 0, 3 becomes 2, 6 becomes 5, 3 becomes 2, 4 becomes 3, 0 is 0, 8 becomes 7, 11 becomes 10 and 1 becomes 0. This is what we get after we make these changes. The changes are, Add theta if 2 lines pass through, and subtract theta if no lines passes through. Identify the minimum number, theta, that have no lines passing through. Update the Cij matrix using the changes Cij = Cij - theta, if the number has no lines passing through it. Cij remains as Cij, if the number has one line passing through it there is no change and Cij = Cij + theta, if the number has 2 lines passing through it. So we use this and get the new table.Now we start making assignments in this. Now this row has only one 0, so make an assignment. Now these two 0s cannot be assigned further. This row has one 0 so make an assignment and there are no other 0s in this column. This has three 0s so leave it. This has no assignable 0. Leave it you cannot do anything.Now this has one assignable 0. Make the assignment. In fact this is the new 0 that has been created as a result of this. The only thing we ensure is, when we convert this matrix into this matrix, we ensure that at least there is a new 0 created. We may get into situation where an existing 0 here has become 1, but it does not matter to us, we have created at least one new 0. We are not saying we have created an extra 0, we are saying that we have created one new 0 so this 1 has become 0. Because of this assignment we cannot make assignments here so this goes. We do column wise first, column has only one 0, so make an assignment. This goes now. All 0s are either assigned or crossed. There is an assignment cross that indicates they are unfit. They are not ready for assignment because of other assignments made in the corresponding row or column. We have 4 assignments against the required 5 and we now check the maximum. Tick an unassigned row, if there is a 0 in that row, tick the column. If there is an assignment, tick the corresponding row. Now there are no more ticks possible. Draw lines through unticked rows 1, 2, 3 and ticked columns. We have exactly 4 lines representing the 4 assignments. Go back, identify the minimum theta, minimum theta is 1 here. So construct this matrix again by making these changes. 3 becomes 2, 2 remains as 0, 0 remains as 0, 2 becomes 1, 9 becomes 8, 1 becomes 0, 6 remains as 6, 15 becomes 16 because we have to add, 0 remains as 0, 4 remains as 4, 5 remains as 5, 0 remains as 0, 1 becomes 2, 2 remains as 2, 0, 0, 7 becomes 6, 0, 1, 4, 1, 3. This 0 becomes 1, 7, 10, and 0. So this is a new 0 that we have created. Now once again make assignments. In this matrix there are two 0s, so you cannot make an assignment. Leave it as it is. There is only one 0, make an assignment here. There are no crosses coming in now, three 0s, leave it as it is. There is one 0 so make an assignment here now. Because of this, this goes now. There is only one 0. Make an assignment here because of this. This as well as this goes. This column has only one assignment or 1 0. So make an assignment here. This goes now. All 0s are either assigned or have a cross. Once again there are 4 assignments only as against the required 5. This also makes us understand that there is no guarantee that with every iteration we will have one more assignment that does not happen all the time. We started with 3, it became 4, does not mean here it will become 5. It can remain at 4 and then we need to proceed further once again by using the line, drawing and ticking procedure. Tick an unassigned row. If there is a 0 in that row, tick that column. So this column gets ticked. If there is an assignment, tick the corresponding row. So this gets ticked and because of this assignment this gets ticked. If there are other 0s, tick that column. There are no 0s, so the procedure stops. Draw lines through unticked rows and tick columns 1, 2, 3 and 4. There is a 1 here. Now all 0s are covered with the line. Now let us go back and compute the theta and redo the matrix again.Now the minimum theta in this case happens to be 1. There is a 1 here, there is a 1 here, so theta = 1, so we rewrite the matrix once again. 2 becomes 1, 0 remains as 0, 1 becomes 0, 8 becomes 7, 0 remains as 0, 6 remains as 6, 16 becomes 17, 0, 4, 5, 0, 2 becomes 3, other 2 remains as 2, 0, 0, 6 becomes 5, subtracting theta, 0 remains as 0, 1 becomes 0, 4 becomes 3, 1 remains as 1, 3 becomes 2, 1 remains as 1, 7 becomes 6, 10 becomes 9, 0 becomes 0. Now we start making assignments. Once again in this matrix, there are three 0s, so leave it. There is only one assignable 0. Make an assignment now. This goes. There are three 0s. Leave it. There is only one assignable 0. Make an assignment here. This goes; there is only one assignable 0 here. So make an assignment here. This as well as this goes. Look at this column, there is only one 0. This goes. So we now realize that we still have not got the 5 assignments that we wanted. There are 4 assignments only. So once again, use the ticking procedure. Tick an unassigned row. If there is a 0 in that row, tick that column. If there is an assignment, tick the corresponding row. There is an assignment here. There is an assignment here. Go back and see no new ticks are possible, draw lines through unticked rows and ticked columns. The minimum theta is 1 make the changes. 1 becomes 0, 0 remains as 0, 0, 6, 0, 6 becomes 5, 17, 0, 3, 4 becomes 3, 5 becomes 5 remains as 5, 0. 3 becomes 4, 2, 2 becomes 3, 0, 0, 5 becomes 4, 0 remains 0 remains, 3 becomes 2, 1 remains as 1, 2 becomes 1, 1 becomes 1, 1 remains as 1, 6 remains as 6, 9 becomes 8, have a 0. Now once again start making assignments. There are four 0s, so leave it. There is only one assignable 0, make and assignment here, this goes, this goes, there are three 0s. Leave it, there is one assignable 0. So make an assignment here, this goes, there is one assignable 0, make an assignment here. This goes, this goes. Now this column has two 0s, so leave it. Already assignments are made. This column has only 1. Make an assignment here, this goes now comes back to the row, this row has only 1. Make an assignment, so now we have got 5 assignments for this and we have got the optimal solution. Now the assignments are X1 1, , 2, 3, 3, 4, 4, 2 and 5, which means first job goes to the 1st person, 2nd job goes to the 3rd , 3rd job goes to the 4th, 4th job goes to the 2nd and the 5th goes to the 5th. The value of the objective function is 11 + 7 = 18; 18 + 13 is 31 + 10 = 41 + 10 = 51. So this is how we solve a general assignment problem. It is not necessary that the first time we subtract, do the row minimum and column minimum. We will get a feasible solution or we may not, but then we need to do this procedure. We need to first understand and then do this line drawing procedure and then the theta identification and then the rule to add subtract and retain theta. So this how we solve. Let us take a 3rd example to see one more peculiar situation that can happen. We solve an assignment problem and that is given by this example. 3, 1, 1, 4, 4, 2, 2, 5, 5, 3, 4, 8, 4, 2, 5, 9, Let us consider a 4/4 assignment problem. First let us do the row minimum subtraction to get, 2, 0, 0, 3, 2, 0, 0, 3, 2, 0, 1, 5, 2, 0, 3, 7. Now this column does not have a 0, so do a column subtraction to get 2, so this will all become 0. So 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 0, 0, 2, 4, now let us apply our assignment method so this has 4 0s 4 0s 2 0s 2 0s so we do not make an assignment. Similarly column wise there are four 0s, four 0s, 2 and 2. We do not make any assignment. When we blindly follow our assignment rule, we can get into a situation where we do not make assignments at all or we may get into a situation where some of the 0s may still be open. So whenever we get into a situation where we are not able to make an assignment or when still some of the 0s are open, it means that row and corresponding columns have more than one, more than two 0s, 2 or more 0s. So we start making arbitrary assignments. If we look at this matrix carefully, there is more than 1 optimal solution and there is a very obvious optimal solution where this, for example 1, 4, 2, 3, 3, 2, 2, 1, 1, 4, 2, 3, 3, 2, 4, 1 is optimal with all 0s. Here we could for example look at this 2 and then this 2 or this 2 and so on there are many. Now let us now when we get into a situation where we cannot make an assignment at all or if there are still some 0s which are neither put in a box that is assigned or crossed. Then we start making arbitrary assignments. So let us consider making arbitrary assignments in this case and let us assume, we start with the top left hand corner. Now we start with the top left hand corner and make this assignment now. Once we make this assignment, all these will go as well as these will go. Now look at this row. There are three 0s, so do not make an assignment. This row has only one assignable 0, make an assignment. This goes, this goes now. Come back to the 4th row. We cannot make an assignment. Go to the 3rd column. Third column has only one assignable 0. Make an assignment. This goes. So an arbitrary choice or an arbitrary tie breaking can get us into a situation where we may have fewer than the maximum number of assignments possible. For example when we had a very obvious solution here, obvious feasible solution, in fact more than one, the assignment procedure is unable to detect it. Now let us proceed further and let us try to draw the ticks and lines. Tick an unassigned row, if there is 0, tick that column. If there is an assignment, tick that row. If there is a 0, tick that column, if there is an assignment tick that. Now all rows and all columns are ticked. Draw lines through unticked rows and ticked columns. There is no minimum theta, so we can get into situations like this. Right now we are not going into this. In these fundamentals of operations research course, we may not give you the solution as to how to overcome this but there are more sophisticated methods available using which we can come out of this situation. But the solution that we are going to propose here is if you get into a situation where you have all 4 vertical lines indicating that 4 assignments are possible, then this is a 4/4 problem. Right now we will have to say this has happened because of the arbitrary assignment here and one needs to do this careful assignment not simply randomly or arbitrarily but carefully so that we are able to get the optimal solution which is either this or this, or these two and these two or any other combinations to get. Right now we are going to stop saying that if we get into a situation, where now all the lines become vertical and we are unable to get the theta. It means we have reached a stage where the optimum solution is readable from this matrix. It is just that our arbitrary choice has prevented us from getting the optimal. Now we should go back and try to read the optimal from this. For larger size problems where such things may be difficult there are more sophisticated methods that are there. Now the motivation, for example, when we started making these assignments, for example if we did this, but this row now has one assignable 0, we make it the motivation behind assigning, when we have one 0 which is the idea of the penalty. We are used to computing a penalty function in the Vogels approximation method. So when there is only one 0, it means that there is an opportunity loss of not assigning it. There we get a positive penalty, the other number should be positive whereas if there are more than one 0 then the penalty is actually 0.Very similar to the idea of the Vogels approximation, except that we do not explicitly compute the penalty but we use the ideas of the penalty. When there is only one 0 in a row or column, it means by not assigning there, we will incur a positive penalty therefore does not incur the penalty and assign it. That is the motivation based on which we start making assignments if there is exactly one assignable 0 in a row or in a column. The optimality so far that we have seen is based on the fact that we reduce the original problem to a new problem which has at least one 0 in every row or every column. Then we make assignments only on the 0s and then we said that a feasible solution with Z = 0 is optimal which is a very obvious result. Let us try to see where the similarity between the linear programming theory that we have learnt or the simplex algorithm that we have seen and the algorithm exists and how we got the optimal solution to this problem. Let us learn that using the first example first; we go to the second example. For example 1, now let us revisit the first example and let us see what we tried to do there. Now first thing we did was we did the row minimum subtraction to write 2, 6, 0, 3 so effectively we subtracted 3 from this. Let us write like we did in transportation. Say u1 = 3, now here the row minimum was 2 to give a 6, 5, 6, 0. Let us write u2 = 2. The row minimum is 6, so we got 0, 4, 6 and 1. To get u3 = 6 and 0, 7, 5, 3 to get u4 = 3. Now let us move to the matrix. After we do the column minimum we have here u1 = 3; u2 = 2; u3 = 6; u4 = 3, now there is already a 0 here so 2, 6, 0, 0, we say v1 = 0. Now the column minimum is 4 so we put v2 = 4 and write 2, 1, 0, 3. Here there is a 0 already so v3 = 0, 0, 6, 6, 5, v4 = 0, 3, 0, 1, 3. What are these u's and v's? In the transportation problem when we wrote the u's and v's, we said the u's and v's are actually the solution to the dual of the transportation problem. Let us now go back to the assignment problem, write it is dual and see whether these u's and v's represent the solution to the dual of the assignment problem. The primal is to minimize Cij Xij for every j, now Xij = 0, 1. Right now we write it as greater than or equal to 0 and treat it as a linear programming problem. We also later showed the assignment problem, when solved as a linear programming problem it would give 0s and 1. This is the primal, so dual will be, let us introduce dual variables u1 to um, or un, considering there is a n/n assignment problem. In this case it is a 4/4, so there are 4 u's dual variables corresponding to these constraints and 4 v's v1 to vn corresponding to these 4 constraints. What we have done here is we have actually evaluated the u's and the v's which are feasible or which are solutions to the dual. How did we evaluate the u's and the v's at the end of the evaluation of the u's and the v's. We now have a matrix which is nothing but if we call it C dash ij = Cij - ui + vj, this is what we have done if we take every element here, if we take this element 6, this is C dash ij, so what is Cij? Cij is 8 here, Cij - ui + vj would give us 6 so we have now written or reconstructed this matrix as C dash ij = Cij - ui + vj. We have also made sure that this C dash ij is greater than or equal to 0 by making the u's and v's correspond to row minimum and column minimum respectively. We make sure that this is 0. If we write the dual carefully the dual will be maximize sigma ui + sigma vj because all these are ones subject to the condition ui + vj is less than or equal to Cij, because every Xij will appear once here and once here. You will have it. It will appear in the i'th constraint here so ui and the j'th constraint here, vj so with the coefficient of 1 you will have ui + vj is less than or equal to Cij. Now ui vj are unrestricted in sign. Why that is because these are equations in the primal. Now when we have ui and vj such that C dash ij greater than or equal to 0 simply Cij - ui + vj greater than or equal to 0 would imply ui + vj less than or = Cij. This can be rewritten as Cij - ui + vj greater than = 0 can be rewritten as ui + vj less than = Cij. The dual variables that we have found out is u1 to u4 and v1 to v4 which is dual feasible. Number 1, it is feasible to the dual of the assignment problem. Number 2, we always make assignments only in the 0 positions. What does that mean? We look at positions where ui + vj is exactly = Cij which means we look at positions where if you write a slack hij then this hij is 0. We want to make 0 positions basic. We want to make Xij = 1, only when there is a 0 here, which implies when the dual is satisfied as an equation, which implies that the dual slack is 0. We are looking at primal basic variables where the dual slack is 0 which means we are satisfying the complimentary slackness conditions. Whenever we make an assignment, whenever we reduce the matrix we are getting a feasible solution to the dual, whenever we are making an assignment from this reduced matrix, we are satisfying complimentary slackness conditions. The moment the primal is feasible, we have exactly 4 here or 5 in the other example. It is optimal. So we are using principles from linear programming to solve this even though it is not very obvious. Now this algorithm is called the Hungarian algorithm and a very popular algorithm to solve. The assignment problem and this is an example of what are called dual algorithms. This is a dual algorithm like your dual simplex. Dual simplex does something very similar to what the Hungarian does or the Hungarian does something very similar compared to what the dual simplex does. It starts with a dual feasible solution that it starts with a solution to the dual of the problem which is feasible. It maintains its complimentary slackness conditions and terminates when the primal becomes feasible. That is exactly what the Hungarian algorithm does. That is exactly what the simplex algorithm does and dual simplex algorithm does. The Hungarian and dual simplex are examples of what are called dual algorithms. While the regular simplex and transportation algorithm are examples of what are called primal algorithms. If we look at this matrix and if you are able to get a feasible solution to the primal which means there are exactly 4 assignments, 1 in every row and 1 in every column then it is optimal. For example that would be an assignment here, assignment here, assignment here and an assignment here would mean we have got the optimal solution. This is a situation where the reduced matrix represents the feasible solution to the dual, allocating in 0s represents complimentary slackness and the moment we get the feasible solution to the primal, we have optimal solution to both primal and dual. What happens to the situation where we do not get 4 assignments? This is a situation where the reduced matrix gives us 4 assignments and has the optimal solution hidden. When we looked at our second example we realized that we had only 3 assignments that were there against the required file and then we made a lot of changes. There are some places where we added something. There are some places where we subtracted something; there are some places where we kept the numbers as it is. Now how are we justified? We are justified simply by saying that the new table that we get is optimal. Solution to the new table is the same as the optimal solution to the original problem. How are we justified in doing that? Let us explain that by going back to the second example. 7, 11, 13, 13, 13, 15, 13, 14, 18, 10, 13, 16, 14, 12, 8, 16, 19, 10 Now let us do the row minimum subtraction to get the u's and then the column minimum subtraction to get the v's. This would mean u1 = 7, would give us 4, 0, 3, 10, 3. u2 = 0 would give us u2 = 7 would give us 6, 14, 0, 4, 6. u3 = 13 would give us 0, 0, 2, 0, 1. u4 = 10 would give us 8, 0, 3, 6, 4. u5 = 8 would give us 4, 0, 8, 11, 2. We do the column subtractions to get, v1 = 0, 4, 6, 0, 8, 4. v2 = 0, 0, 14, 0, 0, 0. v3 = 0, 3, 0, 2, 3, 8. v4 = 0, 10, 4, 0, 6, 11. v5 = 1 to give us 2, 5, 0, 3, 1. Now u1 = 7, 7, 13, 10 and 8. This is a reduced matrix C dash ij = Cij. This is a reduced matrix, C dash ij = Cij - ui + vj. Take anything, 4 + 7 = 11 + 0 is 11 or this is 0 + 13 + 1 would give us 14, so C dash ¬ij = Cij - ui + vj. Let us make the assignments. We make an assignment here. This has an assignment. All these 3 goes. There is one assignable 0. This is okay. Three 0s leave it, first column we make an assignment, these 2 goes. Now we go back and draw the lines and the tick marks, tick an unassigned row. There is a 0 tick, that column assignment tick that row draw lines through unticked rows and ticked columns. Now what do we do? We now redo this matrix. The minimum theta was 1. So the matrix now becomes 3, 0, 2, 9, 1, 6, 15, 0, 4, 5, 0, 1, 2, 0, 0, 0 2, 5, 2, 3, 0, 7, 10, 0. Now we converted this matrix to this matrix and then we solved this. Now the question is how are we justified in saying that the optimal solution to this will be optimal to this? We have consistently subtracted and added or subtracted a constant. So we know from the earlier rule that if we consistently subtract the constant then whether we solve this or solve this, the solution is the same. Here apparently we have not subtracted. We have subtracted in some places we have added in some places and so on. But let us see what we actually have done. What we have done is this. u1 = u1 - theta, u1 + theta. This is a ticked row. So we keep it as it is. Here u2 = u2. Here it is u3 = u3 + theta, here u4 is same as u4; u5 is the same as u5. Now we go to v1 here. This is the column that is ticked, so this will give v1, v2 = v2 - theta, v1 remains as v1, v3, v4, v5. So what are the values? Original u1 was 7, now u1 will be 8, u2 remains as 7, u3 remains as 13 because of the line u4 becomes 11 u5 becomes 9v1 remains as v1 v2 v1 remains as 0 now v2 is v2 - theta so this becomes - 1 this is 0 this is 0 this is + 1. So we now redefine the u's and the v's and go back and check now Cij C dash ij = Cij - ui + vj, so 8 + 0 + 9 would give us 17. Take something else. This is 8 - 1 = 7 + 0 is = 7. Now take this 13 + 0 + 0 is = 13. Now this is exactly nothing but this with the new u's and the v's suitably defined. Even though here when we said you subtract, if there are no lines you add, if there are 2 lines and keep it if there is only 1 line. what we are effectively doing is we are redefining the duals by making them take different values and then saying this matrix is obtained by subtracting u1, u2, u3, u4, u5 respectively first and then v1, v2, v3, v4, v5. second retaining the greater than or equal to 0 characteristic. So now whether we solve this or whether we solve this, the optimal solution will be the same. Therefore we are justified in converting this into this. There are as I said 2 ways of doing it. One is identify the theta, redefine the u's and v's and then subtract them to get this reduced matrix or if you want to take it from this one now, follow the rule that if there are 2 lines, then add theta. If there is only 1 line keep it as it is and if there are no lines subtract it. Either way what we are trying to do is we are reducing it into a new matrix so solving this and solving this are the same. Any subsequent matrix drawn from this has the same interpretation with the new u's and v's updated therefore the Hungarian algorithm is optimal.Now with this we come to the end of the assignment problem. There are still a couple of small things to be done which we will deal in the next lecture and then we start dynamic programming in the next lecture.
Info
Channel: nptelhrd
Views: 404,900
Rating: undefined out of 5
Keywords: Lec-16, Assignment, Problem, Hungarian, Algorithm
Id: BUGIhEecipE
Channel Id: undefined
Length: 60min 15sec (3615 seconds)
Published: Mon Aug 31 2009
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.