CS70学习笔记(五)L4

Stable matching

这一讲主要围绕经典的稳定匹配问题展开

The premise

  • We have n candidates and n jobs
  • Each candidate can only work one job
  • Each candidate has a preference list for jobs
  • Each job(‘s hiring manager) has a preference list for candidates

The problem

How can we pair the candidates and jobs such that it is stable? Formally:

  • An instance is n candidates { C 1 , C 2 , … , C n {C_1, C_2, … , C_n} C1,C2,,Cn} and n jobs { J 1 , J 2 , … , J n J_1, J_2, … , J_n J1,J2,,Jn}
  • A pairing is a set of pairs ( C 1 C_1 C1, Jc_1), ( C 2 C_2 C2, Jc_2), … , ( C n C_n Cn, Jc_n) where each candidate and job appear exactly once
  • A rogue couple is a pair (C, J) not in the pairing where:
    J is higher on C’s preference list than C’s current job
    C is higher on J’s preference list than J’s current candidate
    Note: C and J are not matched with each other
    A rogue couple only makes sense in the context of a pairing!
  • A pairing is stable iff there are no rogue couples**

Example

CandidateJob 1Job2Job3
Alice123
Bob132
Cwop213
JobC1C2C3
1AliceCwopBob
2BobAliceCwop
3AliceBobCwop
Are these rogue couples?

(Alice, 1) 不是,job1是alice的第一顺位,alice是job1的第一顺位
(Alice, 2) 不是,job2是alice的第二顺位,alice是job2的第二顺位
(Alice, 3) 是, job3是alice的第三顺位,alice是job3的第一顺位,两者不匹配
(Bob, 1) 是, job1是bob的第一顺位,bob是job1的第三顺位,两者不匹配

Does a stable matching always exist?

在1962年,经济学家 David Gale 和 Lloyd Shapley 提出:能否针对生活中一些常见的匹配问题,设计一个能够自我执行(self-enforcing)获取最佳匹配的算法。这类问题可以称为稳定匹配问题。
根据 Gale-Shapley 算法 总是存在一个 稳定匹配:

Propose-and-reject terminates:
Morning: each candidate applies to the first job on their list that has not rejected them
Afternoon: each job looks at all applicants from the morningthey (say “maybe”) hold on to the candidate who is highest on their list, and reject the rest
Evening: each candidate crosses off any job that rejected them in the afternoon from their list

注意是每个候选人每天都要投递即便之前已经有工作了

Proof

证明过程是这样的,首先提出一个引理,让后通过归纳以及反证法证明这个引理。然后通过这个引理说明这种算法产出的结果是有效的,且稳定的。随后说明了关于这个算法的两个(一个性质)就是先手优势

A Stronger claim

claim: Propose-and-reject terminates after at most n 2 n^2 n2 days (where n is the number of candidates/jobs).
这其实是一个显而易见的命题,通过定义就可以很快得到

By definition, the algorithm terminates on the day where no one is rejected.

This means that each day (before the last), at least one job is crossed off someone’s list.

The most number of days results from one job being crossed off a day.

Therefore, since each candidate’s list is n jobs long, the most time is n 2 n^2 n2.

Improvement lemma

Claim: if a job J is holding onto some candidate C on day k, every subsequent day, they will be holding onto someone they like at least as much as C

  • In other words, the improvement lemma states that jobs can only do better over time
    这是一个引理,说明随着算法的循环进行下去,每个人和每个工作的情况都在得到改善。以下通过反证法和归纳法两种办法证明这个引理
Proof 1

Suppose J is holding on to C on day k. Let S be the set of all days > k where J is holding on to someone lower on their list than C (or no one).

Claim: S is empty.

Proof by contradiction. Assume S is non-empty. Let i be the first day after k where J is holding on to someone lower on their list than C (or no one).

This means on day i - 1, J is holding onto someone (C’) they like at least as much as C.

On day i, C’ will apply to J. This means J will have someone at least as preferable as C.

However, on day i, J has someone less preferable than C. →←

Therefore, the improvement lemma must be true.

QED

Proof 2

by induction on i, the number of days after k

Base case: i = 0. On day k, J has someone at least as good as C. //

Inductive hypothesis: suppose for some i > 0, J has someone at least as preferable as C on day k + i.

Inductive step: consider day k + i + 1.

Using our IH, we know J is holding on to someone (C’) who is at least as preferable as C on day k + i.

On day k + i + 1, C’ will apply to J (since J did not reject C’). This means J will be holding onto someone at least as preferable as C on day k + i + 1.

Therefore, we have shown the improvement lemma is true. QED

Valid Output

通过反证法来证明,得到的结果是有效的

Proof by contradiction: assume there exists some candidate C who does not have a job at the end of propose-and-reject.

This means C must have applied to every job.

Using the improvement lemma, every job has someone at least as preferable as C.

This means there are n + 1 candidates. However, there are only n candidates. →←

Therefore, propose-and-reject must terminate with everybody paired up.

Stability

这里简单的说明了得到的结果中不包含rogue couple
Proof: We will prove the claim that no rogue couples can exist.

Consider any output pair (C, J), and suppose C prefers J’ to J. Let C’ be the candidate J’ is paired with by the algorithm.

Since J’ appears before J on C’s list, C must have applied to J’ first and gotten rejected.
(at which point, J’ would be holding onto someone they prefer at least as much as C)

Therefore, C’ is not C, and J’ prefers C’ more than C, and there can be no rogue couples.

Proposer-optimal

通过第二数学归纳法说明,这样的算法总是对先手(申请者)有利,归纳过程中通过反证法来证明

Proof by (strong) induction on k, the number of days:
∀ k ∈ ℕ, no candidate is rejected by their optimal job on day k.

Base case: k = 1.
On the first day, each candidate applies to the first job on their list.

Proof by contradiction: assume some candidate C is rejected by their optimal job J on day 1 for some candidate C’. This means:

  • J prefers C’ to C (because J rejected C for C’ on day 1)
  • C’ prefers J to any other job (because C’ applied to J on day 1)

The definition of optimality tells us there must exist some stable pairing T with (C, J) as a pair. Let (C’, J’) be the pair in T that describes the match for C’.

From what we just showed, (C’, J) is a rogue couple in T.

However, T is stable. →←

Therefore, our claim holds for k = 1.

Inductive hypothesis: suppose for some k > 1, no candidate is rejected by their optimal job on any day before k.

Inductive step: consider day k.

Proof by contradiction: assume some candidate C is rejected by their optimal job J on day k for some candidate C’. This means:

  • J prefers C’ to C (because J rejected C for C’ on day k + 1)
  • C’ prefers J at least as much as their optimal job J*
    This is because C’ has not been rejected by J (IH)

Trying to reason about C’ and J
C’ prefers J at least as much as J*
The definition of optimality tells us there must exist some stable pairing T with (C, J) as a pair. Let (C’, J’) be the pair in T that describes the match for C’.
J’ is at best J* (and also by construction, J’ cannot be J).

  • recall that you cannot do better than your optimal match in any stable pairing
    Thus, C’ prefers J to J’, and so (C’, J) is a rogue couple in T.
    However, T is stable. →←

Recap of what just happened
We showed:

  • C’ prefers J at least as much as J* using our inductive hypothesis
  • J ≥ J*
  • C’ prefers J* at least as much as J’ by the definition of optimality
  • J* ≥ J’
  • J cannot be J’ because C must be paired with J in T
  • J ≠ J’
  • C’ prefers J to J’
  • J > J’
    Therefore, propose-and-reject produces a pairing that is candidate-optimal.

Job-pessimality

Claim: if a pairing is candidate-optimal, then it is job-pessimal.

Let T be the (candidate-optimal) pairing output by propose-and-reject, and let (C, J) be an arbitrary pair in T.

Proof by contradiction: assume C is not J’s pessimal candidate. That is, there exists some stable pairing S such that (C’, J) is a pair, and J prefers C’ less than C.

By definition, J prefers C to C’. And because we know T is candidate-optimal, C prefers J to whoever they’re paired with in S. Thus, (C, J) is a rogue couple.

However, S is stable. →←
Therefore, a candidate-optimal pairing must be job-pessimal. QED

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值