YouTube2Text

Lecture 02 : The Stable Matching Algorithm — Transcript

by NPTEL IIT Kharagpur · 4,819 words · 772 segments · language en · Watch on YouTube

Full transcript

  1. 0:01[Music]
  2. 0:22[Music]
  3. 0:27welcome to lecture two of artificial
  4. 0:29intelligence for economics in lecture
  5. 0:31one we looked at two examples of network
  6. 0:34data of interpreting network data in
  7. 0:37today's lecture we'll look at something
  8. 0:39completely different we look at what's
  9. 0:41called the stable matching
  10. 0:44algorithm now what is
  11. 0:47that it's basically a matching problem
  12. 0:51uh as the name suggests but what exactly
  13. 0:54do we mean by
  14. 0:55that uh let's say we have two
  15. 0:57heterogeneous populations X and Y
  16. 1:01okay uh it could be a set of boys and a
  17. 1:04set of
  18. 1:05girls every element in X or every member
  19. 1:08of set
  20. 1:09X has a preference ordering over the
  21. 1:12elements of set
  22. 1:15y similarly every element of set y has a
  23. 1:20preference ordering over the elements of
  24. 1:22set
  25. 1:23X if that's the case who should be
  26. 1:26matched with whom that's the kind of
  27. 1:29question
  28. 1:30which we want to answer in this
  29. 1:32lecture where do we see situations like
  30. 1:36this well in the in the marriage or
  31. 1:38dating Market let's say there are a
  32. 1:40bunch of men and a bunch of women Every
  33. 1:43Man Has a preference ordering over the
  34. 1:46set of women and every woman has a
  35. 1:48preference ordering over the set of
  36. 1:50men labor market let's say there are ex
  37. 1:53CEOs and X firms or Y
  38. 1:55firms and the CEOs have a preference
  39. 1:59ordering over the set of firms and every
  40. 2:01firm has a preference ordering over the
  41. 2:03set of individuals or
  42. 2:06CEOs credits and Banks right so there
  43. 2:10are firms and Banks the firms have a a
  44. 2:13preference ordering over which bank they
  45. 2:15want to borrow
  46. 2:17from and uh the banks also have a
  47. 2:19preference ordering over the set of
  48. 2:22firms similarly have we have buyers and
  49. 2:25sellers so on and so forth so these are
  50. 2:28typical examples of where we uh
  51. 2:32encounter a matching the need for
  52. 2:38matching there could be many to One
  53. 2:40problems too for example campus
  54. 2:43placements there are students and then
  55. 2:45there are firms who visit the
  56. 2:48campus the the students uh definitely
  57. 2:51have a preference ordering over the set
  58. 2:54of firms who have come to
  59. 2:57recruit the firms also have a preference
  60. 3:00ordering over the set of students based
  61. 3:02on their GPA or or other
  62. 3:06credentials
  63. 3:08great so let's think of a particular
  64. 3:13context let's think of marriage or the
  65. 3:15dating Market which is the first example
  66. 3:17I
  67. 3:19cited so we are going to make a
  68. 3:20simplifying assumption we'll make an
  69. 3:22assumption of monogamy that is one to
  70. 3:24one matching one boy for one girl one
  71. 3:27girl for one
  72. 3:28boy we also assume equal sized
  73. 3:31population that is the set of boys and
  74. 3:34the set of girls are they have same
  75. 3:38cardinality if that's the situation the
  76. 3:41question is how to optimally
  77. 3:44match right but when am I when I'm using
  78. 3:47the word optimal what exactly do I mean
  79. 3:50by that what do I mean by Optimal let's
  80. 3:54look at an
  81. 3:58example consider
  82. 4:01a set of two boys and two girls the two
  83. 4:04boys are named Rahul and Aman and the
  84. 4:07two girls are let's say Angeli and
  85. 4:10Tina now every boy remember has a
  86. 4:13preference ordering over the set of
  87. 4:15girls so Rahul prefers uh Tina the most
  88. 4:20and then anjeli Amon also prefers Tina
  89. 4:24the most and then
  90. 4:25aneli Tina prefers Rahul and then Amon
  91. 4:28aneli prefers Rahul and then then number
  92. 4:30okay and this can be uh represented by
  93. 4:33this uh easy graph or network whatever
  94. 4:37you might call
  95. 4:39it now the question of this if this is
  96. 4:42the preference orders of the different
  97. 4:45individuals how to optimally
  98. 4:48match what are the possible
  99. 4:51matchings well these are my two possible
  100. 4:54matchings Rahul matched with aneli Aman
  101. 4:57matched with Tina or Rahul matched with
  102. 5:00Tina and Ammon matched with aneli
  103. 5:03correct
  104. 5:04F let's look at matching one the first
  105. 5:09matching Rahul analii and am amantina
  106. 5:13let's look at this
  107. 5:15matching is there any problem with this
  108. 5:17matching let's understand let's look at
  109. 5:20the preference
  110. 5:23relationships preference
  111. 5:25orderings Rahul and aneli and Amon and
  112. 5:28Tina these are my two pairs
  113. 5:31who does Rahul prefer the most Rahul
  114. 5:34prefers Tina the
  115. 5:35most who does Tina prefer the most Tina
  116. 5:38prefers Rahul the most so in matching
  117. 5:42one Rahul is paired with anjeli but
  118. 5:46Rahul likes Tina more Tina is paired
  119. 5:49with Ammon and Tina likes Rahul more
  120. 5:51than
  121. 5:52Ammon so in this case both Rahul and
  122. 5:58Tina uh uh prefer each other over their
  123. 6:03current mates or current
  124. 6:06Partners which means they will break out
  125. 6:09of their current
  126. 6:10Partnerships right Rahul is paired with
  127. 6:13anjeli Rahul has all the incentive to
  128. 6:16break out from that Partnership if Tina
  129. 6:19says
  130. 6:20yes because why because Rahul prefers
  131. 6:22Tina more than
  132. 6:23anjeli Tina on the other hand uh has an
  133. 6:27incentive to break out of her her
  134. 6:30partnership with Amon because Tina
  135. 6:32prefers Rahul more than Amon so Tina
  136. 6:36would be more than eager to break out if
  137. 6:37Rahul says yes now both Rahul and Tina
  138. 6:40are eager to break out so both of them
  139. 6:42will say yes and they will break out of
  140. 6:44their current Partnerships so matching
  141. 6:47one is
  142. 6:50unstable
  143. 6:53okay we
  144. 6:56say that uh given a matching M two
  145. 7:01individuals X and Y form a rogue couple
  146. 7:05if they prefer each other over their
  147. 7:08mates so in this case Rahul and Tina in
  148. 7:12matching one Rahul and Tina former Rog
  149. 7:18couple okay matching two by the way has
  150. 7:21no Rog
  151. 7:25couples great now that we know what a
  152. 7:28Rog couple means here's the definition
  153. 7:31so what is a stable
  154. 7:34matching a stable a perfect matching is
  155. 7:36where all individuals are paired
  156. 7:39okay a stable matching is a perfect
  157. 7:42matching such that there are no row
  158. 7:46couples so matching one is not a stable
  159. 7:50matching matching two on the other hand
  160. 7:53is a stable
  161. 7:56matching great let's move on
  162. 8:01let's look at one more
  163. 8:03example let's take a let's take a movie
  164. 8:06example let's say we have these four
  165. 8:08movie stars Akshay Salman amitab and
  166. 8:12John and uh let's say there are two
  167. 8:16movies which are being
  168. 8:17made and in each movie there will be two
  169. 8:20stars okay now who will be paired with
  170. 8:25whom now what is their preference
  171. 8:27relation preference ordering
  172. 8:30well akshai prefers amitab the most then
  173. 8:32Salman then John as you can see from
  174. 8:35here right Akshay prefers amitab the
  175. 8:38most this is one I'm sorry
  176. 8:44uh so AKA prefers amitab the most then
  177. 8:48Salman and then
  178. 8:50John right similarly uh Salman prefers
  179. 8:57Akay then amitab then John am prefers
  180. 9:00Salman then AK then John well John's
  181. 9:03preferences are inconsequential because
  182. 9:04he's everybody's last
  183. 9:07choice I mean no no offenses against uh
  184. 9:10John but then
  185. 9:11yeah uh this is just
  186. 9:15hypothetical okay let's move
  187. 9:19on the theorem is there does not exist a
  188. 9:22stable
  189. 9:23match if this is the preference
  190. 9:26ordering and if we want to pair if we
  191. 9:28want to form two
  192. 9:30pairs there we can't we can't do it we
  193. 9:33can't form a stable
  194. 9:35match okay let's
  195. 9:40see assume that there exists a stable
  196. 9:42match n so we are going to prove by
  197. 9:44contradiction
  198. 9:46here assume that there exists a stable
  199. 9:50match so without loss of generality JN
  200. 9:54will be matched with somebody in that
  201. 9:56stable matching let us say John has been
  202. 9:59matched with AA without loss of
  203. 10:02generality wlog is without loss of
  204. 10:06generality now if Jon is matched with
  205. 10:11AKA then by default Salman is matched
  206. 10:14with
  207. 10:16amitab
  208. 10:21great but then look at the look at the
  209. 10:23preference relations preference
  210. 10:26orderings so Salman is matched with
  211. 10:28amitab AKA is is matched with John let's
  212. 10:30go back to our preference
  213. 10:37ordering uh Salman is matched with
  214. 10:39amitab and aksha is matched with John
  215. 10:42but aksha prefers amitab
  216. 10:46more uh Salman
  217. 10:50prefers uh sorry AA is matched with John
  218. 10:54so AKA prefers John the least so AKA
  219. 10:57will definitely want to move out
  220. 11:00right Salman on the other hand prefers
  221. 11:03aka the
  222. 11:05most okay so aksha and Salman will form
  223. 11:10a rogue
  224. 11:13couple
  225. 11:15right AKA has been matched with JN let's
  226. 11:18say without loss of generality then aka
  227. 11:20prefers John the least so aksha wants to
  228. 11:22break
  229. 11:23out and Salman prefers a aka the most so
  230. 11:28Salman and Akay will form a Rog couple
  231. 11:31Salman also would want to break out
  232. 11:34because he prefers Akshay more than
  233. 11:37amitab
  234. 11:38great so this is not there can't be a
  235. 11:41stable match so m is not
  236. 11:44stable and we can prove
  237. 11:46this uh for if I if I match John with
  238. 11:51this is an exercise for all of
  239. 11:52you if you match John with Salman and
  240. 11:56then see if you can find a rogue couple
  241. 11:58you will be able to find one
  242. 12:00no matter whom you match John with there
  243. 12:03will be a Rog
  244. 12:05couple great so the this was my
  245. 12:07preference
  246. 12:09orderings I can't find a stable
  247. 12:12match well this just gives you an
  248. 12:15inkling towards a more General result
  249. 12:17which I'm going to talk about
  250. 12:20now this is the more important theorem
  251. 12:22this theorem states
  252. 12:25that a stable match will necessarily
  253. 12:28exist
  254. 12:29if the preference list can be
  255. 12:31represented by a bipartite graph what is
  256. 12:33a bipartite
  257. 12:35graph that is if we have two mutually
  258. 12:38exclusive sets
  259. 12:41and any member of set one has a
  260. 12:45preference ordering over the individuals
  261. 12:47of set two and any individual of set two
  262. 12:51has a preference ordering over the
  263. 12:52individuals of set one in such a
  264. 12:55setting a stable match necessarily
  265. 12:58exists
  266. 13:01okay if this case which we just talked
  267. 13:05about it was not a bipartite scenario
  268. 13:09right we can't find two distinct two
  269. 13:12mutually exclusive sets such that every
  270. 13:15individual in that set has a preference
  271. 13:17ordering over others it's not the case
  272. 13:19here this is not a bipartite
  273. 13:23graph okay so now this is theorem two
  274. 13:29now we have seen that if it if it is not
  275. 13:32bipartite we have found an example where
  276. 13:35a stable match does not exist but does
  277. 13:39it tell us for sure that if the if the
  278. 13:43if there is a bipartite graph
  279. 13:44representing the preference
  280. 13:47orderings uh then we will necessarily
  281. 13:51have a stable
  282. 13:52match the answer is yes and we are going
  283. 13:54to prove
  284. 13:55that okay so in the next part of the
  285. 13:59lecture what we'll do is the following
  286. 14:01we'll try to prove that in such a
  287. 14:04scenario a stable match necessarily
  288. 14:07exists and we'll also propose an
  289. 14:10algorithm to find that stable
  290. 14:14match okay but we'll go the other way
  291. 14:17around we'll first propose the
  292. 14:20algorithm and then claim that the
  293. 14:23algorithm works we'll first propose an
  294. 14:26algorithm to find the stable match and
  295. 14:29then prove the existence of the stable
  296. 14:31match by proving that the algorithm
  297. 14:33necessarily Works under all
  298. 14:36scenarios okay great so first uh I'll
  299. 14:41try to propose an algorithm for
  300. 14:43finding a stable
  301. 14:46matching but while proposing the
  302. 14:48algorithm I will take help of an
  303. 14:51example so let's say we have five girls
  304. 14:54and five boys the girls are named a b c
  305. 14:57d e and the boys are named 1 2 3 4
  306. 15:035 these are my preference
  307. 15:07orderings every boy has a preference
  308. 15:09ordering over the girls so this is boy
  309. 15:12one's preference ordering let's say so
  310. 15:14boy one prefers girl C the most and then
  311. 15:19B and then e and then a and then D okay
  312. 15:22similarly every boy has a preference
  313. 15:23ordering similarly girl every girl also
  314. 15:26has a preference ordering over the set
  315. 15:29of
  316. 15:30boys girl a for example
  317. 15:33prefers boy three the most and boy four
  318. 15:37the
  319. 15:38least
  320. 15:41okay fine let's move on so if this is
  321. 15:44the
  322. 15:45situation can we find a stable matching
  323. 15:49that is a matching where there will be
  324. 15:52no Rog
  325. 15:55couples so
  326. 15:57first which is what usually uh we try to
  327. 16:01do we'll try to propose a greedy
  328. 16:03algorithm a greedy algorithm is the most
  329. 16:05intuitively obvious algorithm what is a
  330. 16:08greedy algorithm a greedy algorithm is
  331. 16:10where we optimize stepwise and we don't
  332. 16:13go
  333. 16:14back okay so we'll propose a greedy
  334. 16:17algorithm and we'll we'll try to guess
  335. 16:19or we'll try to see if this greedy
  336. 16:21algorithm works or
  337. 16:23not great let's begin start with boy one
  338. 16:27so this is the algorithm we start with
  339. 16:29boy one and allocate the best possible
  340. 16:33girl that is what is best possible girl
  341. 16:36the highest in his preference
  342. 16:38list allocate him that
  343. 16:42girl
  344. 16:45next look at boy two and match him with
  345. 16:48the best available girl again what what
  346. 16:51do what do I mean by best according to
  347. 16:54his preference list remember these are
  348. 16:56the preference lists so what's going to
  349. 16:59happen so who does boy one
  350. 17:04prefer by the way and we are going to
  351. 17:06carry on like this so let's see what the
  352. 17:09what outcome the greedy algorithm gives
  353. 17:12us so who does boy one prefer the most C
  354. 17:16so I'm going to match one with C that's
  355. 17:19what I do one likes C the most one with
  356. 17:22C then I'll come to boy two who does boy
  357. 17:27two like the most a a is a available
  358. 17:30that is is a already matched no a is
  359. 17:33available so I'm going to
  360. 17:35match two with
  361. 17:39a okay so C and A have been taken now I
  362. 17:43come to three boy 3 who does boy 3 whom
  363. 17:47does boy 3 like the most D girl
  364. 17:51D is girl D
  365. 17:53available yes only C and A have been
  366. 17:56already matched girl D is available so
  367. 17:59I'm going to match three with
  368. 18:01d great so c a d have been
  369. 18:04taken now I come to boy
  370. 18:07four who does boy four like the most a
  371. 18:10but a has already been matched with two
  372. 18:13so I can't do
  373. 18:14that next C well C has already been
  374. 18:17matched with one so I can't do that then
  375. 18:20comes D well D has already been matched
  376. 18:22with three I can't do that either so
  377. 18:25four will be matched with the best
  378. 18:27available girl which is
  379. 18:31B right and coming to five five will be
  380. 18:35matched with the only girl who is left
  381. 18:37which is
  382. 18:40e okay so that's it that's the match
  383. 18:44which we
  384. 18:45get uh by using the greedy
  385. 18:48algorithm but now the question is is
  386. 18:51this matching which we have got is this
  387. 18:53a stable
  388. 18:55match how do we inspect that we try to
  389. 18:58look at these couples and see if any of
  390. 19:01these
  391. 19:03couples form or is a rogue
  392. 19:08couple okay so let's let's
  393. 19:12inspect and it turns
  394. 19:15out that boy four and girl C form a
  395. 19:19rogue
  396. 19:20couple let's understand
  397. 19:23why let's look at boy four and girl C
  398. 19:27who four matched with four is matched
  399. 19:30with b and one is matched with
  400. 19:34C
  401. 19:36fine
  402. 19:38now who does four prefer the
  403. 19:42most four prefers four is now hitched
  404. 19:46with
  405. 19:48B right but four prefers C more than
  406. 19:53b four prefers C more than
  407. 19:56b c right now
  408. 20:00is matched with
  409. 20:04one but C prefers four the most see look
  410. 20:09at C's preference ordering C prefers
  411. 20:12four the
  412. 20:14most and four prefers C more than his
  413. 20:18own partner which is
  414. 20:21B so c will definitely want to break out
  415. 20:24because C prefers four the most and four
  416. 20:26will also break out because four refers
  417. 20:28C more than the current partner which
  418. 20:31four has which is
  419. 20:32B so which means boy four and girl c
  420. 20:36will form a Rog couple so we see that
  421. 20:39the greedy algorithm gives us a a
  422. 20:43matching which is not
  423. 20:46stable okay so the greedy algorithm has
  424. 20:49failed so what do we do we naturally
  425. 20:53we'll have to propose an alternative
  426. 20:56algorithm so here we are proposing
  427. 20:59are stable matching
  428. 21:02algorithm please understand this
  429. 21:04algorithm carefully you can pause the
  430. 21:06video and read the slide or listen to
  431. 21:08this uh once more so this is how the
  432. 21:12algorithm
  433. 21:14goes every day a boy will go and stand
  434. 21:17in front of the balcony of the
  435. 21:19girl he likes the
  436. 21:22most okay every day the boy every boy
  437. 21:27any boy will go and stand in front of
  438. 21:30the balcony of the girl he likes the
  439. 21:32most
  440. 21:34okay the girl the each day a
  441. 21:38girl can
  442. 21:40either uh tell a boy standing in front
  443. 21:43of the balcony there could be more than
  444. 21:44one boy standing in front of a girl's
  445. 21:46balcony the girl can tell the boy come
  446. 21:50back next day or
  447. 21:53reject okay once the girl says reject to
  448. 21:57a boy the boy crosses that girl off from
  449. 22:01his list of
  450. 22:02possibilities and never goes back to
  451. 22:05that balcony ever okay this
  452. 22:09continues until every girl has exactly
  453. 22:13one boy standing in front of the
  454. 22:17balcony
  455. 22:19okay when there is exactly one boy
  456. 22:22standing in front of each girl's balcony
  457. 22:25then the algorithm terminates
  458. 22:28this is the stable matching
  459. 22:31algorithm and let's see if this
  460. 22:34works and initially all girls are in the
  461. 22:37boy's
  462. 22:38list he'll keep the boy will keep
  463. 22:41crossing a girl out once the girl says
  464. 22:44reject okay fine let's look at the
  465. 22:47iterations now let's apply this
  466. 22:49algorithm on the example which we have
  467. 22:53got so this is our preference lists
  468. 22:56remember so let's see this is day one
  469. 22:59what's going to
  470. 23:02happen uh every boy will go and stand in
  471. 23:05front
  472. 23:06of uh the balcony of the girl he likes
  473. 23:09the most
  474. 23:11okay
  475. 23:13so one whom does one like the most boy
  476. 23:17one boy one likes C so boy one goes and
  477. 23:21stands in front of C's
  478. 23:23balcony whom does two like the most a so
  479. 23:27two goes and stands in front of A's
  480. 23:29balcony whom does three like the most
  481. 23:32D where does d go d goes and stand in
  482. 23:36front
  483. 23:37of uh sorry three goes and stand in
  484. 23:39stands in front of D's
  485. 23:41balcony what about boy four boy four
  486. 23:45likes a the most and boy five also likes
  487. 23:48a the most so both of them again go and
  488. 23:50stand in front of A's
  489. 23:53balcony okay so this is how it's
  490. 23:56operating great
  491. 23:59now two knows that both two four and
  492. 24:03five prefer her the
  493. 24:06most right girl girl a knows that boys 2
  494. 24:114 and five prefer her the
  495. 24:15most okay now look at girl A's
  496. 24:18preference preference ordering whom does
  497. 24:21girl a prefer the most amongst these
  498. 24:23boys 2 4 and five well clearly girl a
  499. 24:28prefers five the
  500. 24:30most
  501. 24:32okay so girl a knows that five is
  502. 24:35available to her then why should she
  503. 24:38bother about boys 2 and four so what
  504. 24:42will she say she will say reject to 2
  505. 24:44and
  506. 24:45four okay she will say reject to 2 and
  507. 24:50four so two and four will now what will
  508. 24:54what will two and four do boys two and
  509. 24:56four what will they do
  510. 24:58well two and four will cross a out of
  511. 25:01their list so like this a is out of
  512. 25:04their list now Mark Mark a
  513. 25:07red
  514. 25:08h fine now day two comes in day two
  515. 25:12again every boy goes and stands in front
  516. 25:15of the balcony of the girl he likes the
  517. 25:18most in his
  518. 25:20list in his
  519. 25:22list so again one goes in front of C's
  520. 25:26balcony right two will now go in front
  521. 25:29of B's balcony three will now go in
  522. 25:32front of C's balcony four will now go in
  523. 25:35front of C's balcony right five in front
  524. 25:38of a so this is what happens
  525. 25:43now
  526. 25:46right now C is having two two boys
  527. 25:51standing in front of her balcony one and
  528. 25:54four now whom does she like more well C
  529. 25:58like four the most so she she and she
  530. 26:02knows that
  531. 26:05uh right now she is the most preferred
  532. 26:09girl in boy Four's list so why should C
  533. 26:13bother about boy one why should girl C
  534. 26:17bother about boy one so girl C rejects
  535. 26:21boy
  536. 26:22one
  537. 26:24okay so boy one now crosses out see from
  538. 26:29his list so these are my cross outs
  539. 26:33now
  540. 26:35right
  541. 26:37fine now again now day three comes
  542. 26:40everybody goes every boy goes and stands
  543. 26:43in front of the balcony of the girl he
  544. 26:45likes the most in his
  545. 26:48list okay remember if you look at boy
  546. 26:52one's list C is not there anymore so
  547. 26:55where will he go he will go and stand in
  548. 26:57front of B B's balcony two again will go
  549. 27:00and stand in front of B's balcony
  550. 27:04right so 1 and two both go and stand in
  551. 27:07front of B's
  552. 27:08balcony right you can you can see that
  553. 27:11three will go in front of D's balcony
  554. 27:13four will go and stand in front of C's
  555. 27:15balcony because a is not there in Four's
  556. 27:18list
  557. 27:19anymore five again will go and stand in
  558. 27:21front of A's balcony so this is how the
  559. 27:24balconies look like
  560. 27:26now now B has two men standing in front
  561. 27:29of her balcony one and
  562. 27:32two look at B's ordering B's preference
  563. 27:35ordering between 1 and two who does B
  564. 27:39prefer well B clearly prefers two more
  565. 27:42than
  566. 27:43one right and B knows that right now she
  567. 27:48is she tops in the preference list of
  568. 27:53two if that's the case why should she
  569. 27:56bother about boy one so she rejects boy
  570. 28:01one so B will reject boy one and boy one
  571. 28:05in turn will cross out B from his
  572. 28:09list this is the updated list
  573. 28:12now great what happens next day where
  574. 28:14will boy one go in front of the most
  575. 28:17preferred girl of his list these have
  576. 28:19been crossed out so boy one goes in goes
  577. 28:23and stands in front of E's balcony two
  578. 28:25goes and stands in front of B's balcony
  579. 28:28three in front of D's balcony four in
  580. 28:30front of C's balcony five in front of
  581. 28:32A's
  582. 28:33balcony this is what we
  583. 28:36have okay now we have the terminating
  584. 28:39condition right we have one boy standing
  585. 28:43in front
  586. 28:44of uh or every balcony has exactly one
  587. 28:48boy standing in
  588. 28:50front and remember this was my condition
  589. 28:53for termination of the stable matching
  590. 28:55algorithm so this is where the algorithm
  591. 28:57terminates
  592. 29:00fine now is this a stable match is this
  593. 29:03match which we have got now is this
  594. 29:05stable remember we had got a similar
  595. 29:07match using the greedy algorithm which
  596. 29:08turned out to be unstable because we
  597. 29:10could find a rogue
  598. 29:12couple but this match which we have got
  599. 29:15let's see if this is
  600. 29:17stable and the answer
  601. 29:19is if you take a look at the preference
  602. 29:23of the boys and the preference of the
  603. 29:24girls and if you take a look at this
  604. 29:26matching it indeed turns out to be
  605. 29:29stable you will not be able to find any
  606. 29:32Rogue couple in this
  607. 29:35matching I will urge all of you to take
  608. 29:38a little pause and work it out to
  609. 29:40yourself try to find a rogue couple and
  610. 29:43you will see that you
  611. 29:44can't
  612. 29:48okay now the question is fine we have
  613. 29:50proposed an
  614. 29:52algorithm now uh let's look at some
  615. 29:54desirable properties of the stable
  616. 29:56matching algorithm and this in turn will
  617. 30:00U kind of make it clear that this
  618. 30:04algorithm Works generally under any
  619. 30:07situation for any preference orderings
  620. 30:10if the preference orderings can be uh if
  621. 30:13if it's a bipartite
  622. 30:16structure okay so the first first result
  623. 30:20the stable matching algorithm
  624. 30:21necessarily terminates it will terminate
  625. 30:23at some
  626. 30:24point what is the proof for that
  627. 30:28it's very
  628. 30:30simple in fact it terminates in less
  629. 30:33than equal to n² + 1 days that's the
  630. 30:35upper
  631. 30:36bound why what is the logic what is
  632. 30:40happening in this algorithm every day at
  633. 30:43least one boy is being crossed
  634. 30:47out or or in other words one boy crosses
  635. 30:50out a girl from his list when every day
  636. 30:54one girl is crossed
  637. 30:56out from some boys
  638. 30:59list so every day there is a cross out
  639. 31:03now there are n boys and N girls and so
  640. 31:07every boy has a list which which has a
  641. 31:09cardinality n of size n so how many
  642. 31:13total cross outs are possible at
  643. 31:16Max well at Max n Square cross outs are
  644. 31:20possible Right which means on the n² + 1
  645. 31:24at day the algorithm will necessarily
  646. 31:26terminate
  647. 31:29okay so this is the proof that the
  648. 31:31stable matching algorithm will
  649. 31:33necessarily terminate if we uh have a
  650. 31:36bunch of boys and girls and the
  651. 31:38preference orderings and if we apply the
  652. 31:40algorithm it will necessarily terminate
  653. 31:42at some point after a finite amount of
  654. 31:45time and the upper upper bound is n sare
  655. 31:48+
  656. 31:491 upper bound of
  657. 31:53time what is the next one everybody gets
  658. 31:56married or paired so this is the
  659. 31:58definition of a perfect matching
  660. 31:59remember in perfect matching everybody
  661. 32:01gets
  662. 32:03paired uh in our example or we have made
  663. 32:07a simplifying assumption at the start of
  664. 32:08the lecture that uh the set of the the
  665. 32:11the cardinality of the two sets which
  666. 32:13are being matched are
  667. 32:15equal so let's prove this let's say boy
  668. 32:19B has not been uh is not married at the
  669. 32:24end okay any boy I I'm naming him me
  670. 32:29which means B has been rejected by every
  671. 32:32girl
  672. 32:34right which means every girl is already
  673. 32:38married but if every girl is married
  674. 32:40every boy is
  675. 32:41married because the cardinality of the
  676. 32:44two sets are equal so if every girl is
  677. 32:47married every girl is married to one boy
  678. 32:49at least which means every boy is
  679. 32:51married which means B is also married so
  680. 32:54which which leads to a contradiction
  681. 32:56that b is not married okay so if the
  682. 32:58cardinality of the two sets are equal
  683. 33:00this is not
  684. 33:03possible and finally the last
  685. 33:06one which is that uh it this algorithm
  686. 33:10necessarily produces a stable match we
  687. 33:13have seen it does right we have seen it
  688. 33:16does in the example which we worked
  689. 33:20out but what is the intuitive uh
  690. 33:22explanation that it always does it's the
  691. 33:26following right it's it's a pretty
  692. 33:28intuitively easy proof to think about
  693. 33:31let us say it does not let us say we
  694. 33:33have applied stable matching and we
  695. 33:35actually end up getting a rogue couple
  696. 33:37let's say the Rog couple is called
  697. 33:38Johnny and
  698. 33:39Amber okay now if it is a rogue couple
  699. 33:42it means it is not a couple in the
  700. 33:44matching right now
  701. 33:46right okay now how come Johnny and Amber
  702. 33:50are not couple right now in the St in
  703. 33:53this in the match which we have got
  704. 33:55either case one is either Amber rejected
  705. 33:59Johnny right if Amber rejected Johnny it
  706. 34:03means Amber must have
  707. 34:06had a boy more preferred than Johnny
  708. 34:11standing in front of her balcony only
  709. 34:13then Amber would have rejected
  710. 34:17journy and the final Choice which Amber
  711. 34:20got was definitely
  712. 34:23somebody who was preferred to
  713. 34:26Journey which which means Johnny and
  714. 34:29Amber cannot be a rogue couple so it's a
  715. 34:33contradiction what is case two case 2 is
  716. 34:35Johnny never went and serated Amber that
  717. 34:38is Johnny never went and stood in front
  718. 34:39of Amber's balcony what does this
  719. 34:43mean now when is a boy going to a
  720. 34:46balcony of a
  721. 34:49girl when is a boy not going in front of
  722. 34:52balcony of a
  723. 34:53girl when he's not being rejected by a
  724. 34:56girl
  725. 34:58whom she whom he prefers more than the
  726. 35:01girl uh under whose balcony he has not
  727. 35:04been to right so which means if Johnny
  728. 35:07has not been under the balcony of Amber
  729. 35:10it simply means that Johnny has not been
  730. 35:12rejected by some girl whom he prefers
  731. 35:16more than
  732. 35:18Amber if he has not been rejected by a
  733. 35:20girl whom he prefers more than
  734. 35:23amember which means Johnny's current
  735. 35:25partner whom he has been matched with by
  736. 35:28the
  737. 35:30algorithm he prefers that person more
  738. 35:32than
  739. 35:33am which means Johnny does not prefer
  740. 35:36Amber over his current
  741. 35:38partner which means Johnny and Amber
  742. 35:40again does not form a rogue couple right
  743. 35:45so we see again we prove it by
  744. 35:47contradiction that uh formation of a
  745. 35:50rogue couple or occurrence of a rogue
  746. 35:52couple is impossible once we apply
  747. 35:55stable matching algorithm
  748. 35:59okay
  749. 36:00great so we have learned uh
  750. 36:04uh the stable matching algorithm in in
  751. 36:07this lecture so we have learned two
  752. 36:09different kinds of things we have had
  753. 36:10two different uh uh exposures in the
  754. 36:13first two lectures in the first lecture
  755. 36:16we talked about network data and we
  756. 36:18tried to interpret two different
  757. 36:20situations one in history one in
  758. 36:23finance in this lecture we have looked
  759. 36:26at something else we have looked at
  760. 36:27stable matching algorithm in the next
  761. 36:30two or three lectures I will deal with
  762. 36:33something completely
  763. 36:35different I will talk about modeling of
  764. 36:39uncertainty in artificial intelligence
  765. 36:41training an agent to behave optimally in
  766. 36:45uncertain situations is a key
  767. 36:48thing so is true in
  768. 36:51finance so in the next two lectures I
  769. 36:54will delve a little more in in finance
  770. 36:58and talk about the idea of hedging and
  771. 37:01risk
  772. 37:02management see you in the next lecture

About this transcript

This page contains the full transcript of Lecture 02 : The Stable Matching Algorithm by NPTEL IIT Kharagpur, generated from the public captions YouTube serves with the video. The transcript has 4,819 words across 772 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.

Free YouTube transcript tool

YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.