 Welcome back to this NPTEL course on game theory. In the last few sessions we have introduced some cooperative concepts. In this session we will look at another class of problems called matching problems. So this matching problems these are a class of problems which involve matching the members of one group of agents with one more members of a second design group of agents all of whom have preferences over the possible reason. So what I mean to say that there is a group of people here this side there is another group of people here and then each person has preference over the other side and now you want to match the people between these two groups. Now this problem is basically introduced by David Gale and Lloyd Shapley and it has generated a huge interest in this. In fact eventually Alvin Roth and Lloyd Shapley in fact won the Nobel Prize for their work in this. In fact this subject is generally known as a market design. So now we will start looking at this problem. In fact some of the examples is that the medical internships. So once the students graduate they need to do internship in hospitals. So now the students have some preference over the hospitals which hospital they should they want to do it and similarly hospitals also have preference over the students. So this is one example. In fact Alvin Roth in fact helped devising designing such mechanisms in ES schools. In fact another example here is that there are patients who require some argon donation and there are people who would like to donate the argons. Now you need to find a match between them. This is again a big problem. And then the other interesting thing is for example in India let us say IIT's admissions. The students have choice over IIT's, IIT's also look at the students ranks, how well they scored in the joint entrance examination. Now this is again a matching and then similarly the CAT admissions. The MBA admissions in our country in India they are another thing. In fact these two follow a different algorithms. So we will come back to this again later. So let us introduce the problem. So let us say this is this problem is introduced through the marriage market where there are two set of people. One set is the men, the other set is women. Now every woman has a preference over men and similarly every man has preference over women. Now what is a matching? A matching will be pairing a man and woman. Now what is the important thing here is that if a man and woman are matched what would like to suppose if the man prefers some other woman and that some other woman also prefers this man instead of the matching that she got then what will happen is that this pair of man and woman will break their current matches and they like to be together. So whenever such a thing happen you say that such a pair is a blocking pair. Now the problem in this matching problem is that does there exist a matching where there is no blocking pair and now if such a matching exist you will call that as a stable match. So the Gail and Shapley developed an idea an algorithm which shows that a marriage market always admits a stable matching. So first of all the each man proposes to his most preferred woman. So because every man has preference over the woman so he man looks at his preferences and he proposes to the woman on the top of his list. Now every woman looks at the proposals that she received. Now remember that because there every man is proposing so therefore a woman is likely that she may receive multiple proposals or sometimes no proposal or sometimes only one proposal. So all the things are possible. Now the woman looks at all the proposals that she has received and then she looks at her preference list and then rejects all the people in this proposers who are actually in the least list. That means in this proposal among the men who proposed her he looks at all of them who is best among them except him all the others are rejected at this stage. Now that person is tentatively engaged with this woman. Now in the next step all the rejected men looks at their next preference and proposes to that man to their next preferred woman. Now this process continues and then the idea the algorithm what Gail and Shapley proved is that this algorithm eventually stops at some place. That means there is no man who would like to who can propose every man is engaged with some woman. Now at this stage the algorithm terminates and then whoever are engaged they are now paid. So what Gail and Shapley showed is that this is this algorithm gives a stable match. So we will work out this. So now look at this thing why should this algorithm terminate in a finite time? See if you really look at it this algorithm any person any man how many proposers can he do it at the most the number of women. So for example for the time being we are assuming that the men and women both are same both are n, n men and n women and every man proposes to at the most n women. So therefore whenever he is rejected he will propose to another woman that means he will propose at the most n times. So therefore the overall algorithm can run at the most n square rounds it cannot go beyond. Therefore n square rounds is the maximum therefore this algorithm is a finite time algorithm. Now let us analyze this thing. Now look at some man let us call Bharat and another woman let us call Anita. So let us say they are not matched to each other. But let us say Bharat prefers Anita to his match obtained in this algorithm let us say I am calling it as DAA what DAA means is the deferred acceptance algorithm. The idea in this algorithm is that you are not accepting until the algorithm terminates you are deferring the acceptance. So therefore it is known as a deferred acceptance algorithm. So let us say the Bharat prefers women Anita than the one she he is matched. But that means what the Bharat must have proposed to Anita earlier because she was on top of his list than the current version. Therefore she must have proposed to her and if unless she rejects he will not propose to another. So therefore this person must have been rejected by everyone else who is preferred better. So therefore this is automatically the no man can see that he will get a better match in this thing. And similarly women can the same argument goes through. In fact women because if women whomever she is matched with if there is some other man whom she prefers then there are two things can happen either that person never proposed her or she must have rejected. If she has not rejected then she surely would have received a proposal from. So therefore women is also getting the best here. So therefore no man and woman can block this match. So this algorithm the deferred acceptance algorithm always result in a stable match. So therefore this is a very simple argument and this algorithm is very useful in this. Now let us look at the another aspect here. Let us say the you reverse the roles of the two people instead of men proposing and then women rejecting. So let us start say that women proposes and men is rejecting then you get another algorithm. So therefore by reversing the roles you get two algorithms so typically these two stable matches need not be same. So in fact one is women optimal algorithm when women is proposing that means he is proposing to his best her best and hence you hope that she will always get her best when she is proposing. Similarly when men is proposing you expect that the men gets the best. So therefore the women optimal and men optimal matches that you are getting it. So in fact we can easily see that any other stable match if it if it exists that will always be in between these two things that means every man when men is proposing he is getting the best and any other stable matching there every man will get not better than the men proposal algorithm. So this is main point with this stable gale-stable-gale algorithm you are getting two stable matches and one is men optimal and other is women optimal. In fact this is where the IIT admissions for example IIT admissions look at the student optimal that means the student's preference is given the priority there therefore that is actually a student optimal whereas in the CAT admissions the institutes have a choice over the they offer to the people whom they prefer first. So these two are the other ends of the deferred acceptance algorithm. So let us look at one example. So consider this 3 by 3 matrix where the women and men preferences are given. So let us say the women w here so that means here the w1's preferences are first m1 and then m3 then m2. Similarly for w2 first m3 then m1 then m2 for w3 m1 is the first m2 is the second m3 is the this thing and similarly for men. So let us look at it in round 1 m1 will propose to look at m1 m1's best preferences w2 m1 will propose to w2 and m2 will propose to w1 m3 is also proposing to w1. The round 1 the m1 men 1 propose to w2 women 2 and whereas m2 and m3 that second and third men propose to the same women w1. Now what the women will do so w2 has received only one proposal so no not many proposals so therefore she will keep m1 engaged and w3 has received nothing so she has nothing to do in this round then w1 has received 2 proposals m2 and m3. Now look at the women w1's preference look at the w1 preference w1 prefers m1 to m3 to m2 but she received preferences for m2 and m3 among this m2 and m3 she prefers m3 therefore she will reject m2 and that means in this round the m2 is rejected and m1 and m3 are engaged. So therefore in the m2 will now offer to the next person so m2 if you look at it m2 the next choice is w2, w2 is the next choice. So therefore in the round 2 m2 proposes to w2 now what happens is that now w2 has received 2 proposals m1 and m2 and w1 is engaged with m3 so what will happen now because w2 has m1 and m2 so w2 m1 and m2 m1 is her preferred choice over m2 therefore w2 rejects m2. Once w2 rejects m2 then m2 has to go for next thing the next choice is w3 and then m2 proposes to w3 and there are no more rejections happen. So no more rounds will be required and w1 is now matched to m3 w2 is matched to m1 w3 is matched to m2. So this is basically the main optimal stable match and if you reverse the roles we will actually get this w1 m1 w2 m3 w3 m2. You can see that these 2 are different and this is the second one is the woman optimal and the first one is the man optimal. Now the most important thing here to notice is that these 2 stable matches if you take any other stable matches that match is always lies between these 2. In other words that means every person I should now say that the following thing. So let us say mu w mu m these are the matches that are obtained through deferred acceptance algorithm. So let me first write down the mu1 and mu2 there are 2 stable matches what do I mean by mu1 less than equals to mu2 for m. For a man that means what the men let us say let us take m in m mu1 m what he is obtaining in under mu1 and what he is obtaining under mu2. Suppose if the man m prefers mu2 m over this thing that means this way I will write it he prefers mu2 m to mu1 m and if this happens for every m then I will say mu1 is preferred for men by over mu2 sorry mu2 is preferred over mu1 by the man. Similarly for mu1 is least preferred compared to mu2 by woman that means what the for any w mu1 w is less than equals to mu2 w for the woman this should happen for every. So this is basically this in fact as I said mu w is most preferred by woman that means what every woman mu w this is happening that means what she is obtaining under the woman proposed this thing is always better to any stable match in fact this is not very hard to prove it if you go back to the algorithm this is obvious from there ok. So similarly we can say that for any stable match the men m whatever he obtains under the stable match is the men proposed algorithm gives him the better choice than any other stable match. In fact if this argument actually proves the following thing mu m is least preferred to woman this thing and mu w is least preferred to men compared to m. So what in the mu w the woman is getting their best whereas mu m the man is getting best and in the other things they are getting the worst. So this is also very interesting. Now this is a very important aspect of this now would like to ask you the following question. Suppose if a man or woman one of them if he makes a misrepresentation of his preferences suppose for example instead of saying that I prefer this girl over the other one. So let us say a change that preference thinking that I may get a better stable match this is a natural thing that we would like to see. Suppose if I misrepresent my true preferences am I going to get anything better. So again once again the algorithm if you go back to that if you see it because you are proposing according to your preference if you misrepresent there is a chance that you may get matched with someone who misrepresent that means you have a there is a very likely chance that you will get a least preferred match in whenever you have misrepresenting. Because everyone else are fixing their strategy no one else has deviated from their true preferences only one person has deviated then because everyone else are following the same thing. So whatever is accepted earlier the same thing there is a fairly good chance that they may be accepting and in fact they may get better because the player one players misrepresentation. So by misrepresenting preferences no person gains in this stable match. So in that sense this is a the deviation is not good. So the stable match the is actually a very the mu w and mu m for example when you are looking at the men optimal match there by misrepresenting you the no man gains. Similarly in the mu w no woman will gain by misrepresenting of course for the other stable matches there are possibilities but let us not look at. Now there are few interesting questions here when when is this these two stable matches are equal. Suppose now look at it suppose if mu w and mu m these two are same that means you have a unique stable match there cannot be any other stable match this is again coming from the same argument. Now if these two are not same then there are multiple stable matches. So here is an interesting question that one would like to ask because in this algorithm how did we do it the all the people are proposing to them and then some are rejected some are engaged and then going. Now is there a can we really come up with some decentralized algorithm for example look at the following question. Suppose you start with any pairing any match find a blocking pair and interchange then go on do repeat. So if there is a blocking pair what I will do is that I will simply interchange them. Now by doing so will this arrive at a stable match this is a very interesting question that one would like to ask in fact this question is asked by Donal Nuth in fact he found actually a counter example to this. So when you simply find a blocking pair and interchange then it need not reach a stable match. In fact in his example which of course I am not describing the example right now we can certainly find such example is that instead of finding a block pair choose a blocking pair then he obtains a stable match and then he asks the following question is this can you always find a way to reach the stable match. This is a very important question in fact this question is answered positively by Alvin Roth and one the way they the following thing. Of course we will not go into the proofs but let me mention this algorithm. So start with any match now find a block pair randomly you choose any blocking pair. Now pair the pair them and leave the their partners single and repeat. So you start with any matching and then find a blocking pair basically you randomly choose a blocking pair and then instead of interchanging them you pair the blocking pair and their part their current partners you just leave them single. Now you get another matching where some are single some are matched. Now for example if someone may prefer to be matched with someone rather than being single so therefore they form a blocking pair. So therefore they get matched in another round. So because this randomness and then they prove that with probability 1 this converges to stable match. So this is a very important development in this subject. This also provides you a distributed algorithm. Now there are other aspects to this matching problems is that what we have discussed is two sided and in fact we also have assumed the strict preferences. We can also assume the following thing instead of strict we can say that I am fine with any two of them fine with any two that means we are indifference or I can also say prefer to be single than some. So instead of matching to certain people would prefer to be single. So this so and in fact the same problem now I can ask with these questions these restrictions and in fact the Gail Shapley algorithm can be modified. So this is a two sided market. The reason why we call this as a two sided is that there are two groups which are different and we are matching them. Now there is another thing called one sided. I will not go into many details but let me give you the idea of this problem. In fact you can work out some exercises. So in the one sided market there are only single set of people. So for example students students are there we need to need to pair them. So for example an example where this pairing students come is that whenever you are allocating them to hostel rooms. So two guys have to be given one room. Now let us say we have to do this one. This is known as a one sided match. There is only one such students and they have to be paid. Now here each student has preference over the remaining students. So now how to come up with this one? How to pay them? So in fact here in this setup it is possible is non-existence of stable match. So in exercises you will see this thing. So in this setup there is it is quite possible that stable matching need not exist. So therefore this area still has lots of questions. In fact even in the two sided market there are a lot of interesting questions that are still. In fact another question that comes is that what we have seen here we have discussed in this session is that one man and one woman getting matched. But if you look at the admissions problem several students are matched to same college. That is basically many students many to one matching or many to many matching. So you can actually ask the same question with many to one and many to many. So these are all several interesting directions and in fact the good reference for this is basically a book by Alvin Roth and Sotomayor. So this provides you another aspect of the cooperative games. And in fact with this in fact we are coming to the end of this course and to recall we have touched upon few topics of game theory starting from combinatorial games and non-cooperative games and some learning and cooperative games. But there are many things that we have not discussed in this course. So in fact at this point I should say that one good reference is to look at the book by Nara Hari on game theory and mechanism design and there is a book by Meyerson and there is a book by Füdenberg and in fact there are many books. Of course this book mostly focuses only on the non-cooperative things Meyerson and Nara Hari both have on this. In fact we have followed some of the topics of this course from this thing. And Roth and Sotomayor is probably one of the best reference for this stable matching. So with this we are concluding this course and hopefully we will meet you again in some other point of time in some other course. Thank you.