INF421 - Amphi 1 Stable Mariage

0. 课程介绍:

课程:

  • Short Amphi (必须去): Monday at 15:15,课程简介+Q&A,declare this in Moodle
  • 2nd Q&A (Optional): Monday at 21:30 所有的问题都可以问
  • Regular PC (Mandatory): 周二早上,建议周一下午就开始思考

Progamming Project (PI)

  • ~ 20h ~ 500行的代码,Report,Defense (10min pre + 10min Q&A)
  • 在12月6日之前和Binome选择题目,在2021年2月7日停止上传Code。

Exam:

  1. 双语考试,回答甚至可以混合在一起。

课程目标:

  • 经典算法
  • 算法设计技巧:Devide-and-conquer, dynamic programming, greedy algorithms
  • algs paradigms: Algorithmic game theory, approximation algorithms, randomized algorithms, heuristics

1. The Stable Marriage Problem

问题描述:

  • n men, n women
  • 每个人都有自己心中的对n个异性的偏好顺序
  • 目的:找到Stable Marriage,即没有一个男人或者女人可以通过和其他人再形成新的couple来改进他们处境。

【例子】

Formal Definition:

记号:

  • 一个集合G(n man),一个集合F(n women)
  • 每一个男人g都有一个对于女人的ordre of preference (linear order),我们记 f 1 > g f 2 f_1 >_g f_2 f1>gf2表示男人g更喜欢女人 f 1 f_1 f1
  • 同理,每一个女人f都对于G有一个linear order,记为 > f >_f >f

目的:

  • Matching:找到 M M M使得每一个g和f都最多在M中出现一次,即没有重婚(bigamy)。
  • Perfect Matching:每个男人和女人都只在Pair中恰好出现1次。
  • Stable Matching:找到一个Perfect matching M使得
    ∀ ( g , f ) ∈ M ∀ ( g ′ , f ′ ) ∈ M : ¬ ( ( f ′ > g f ) ∧ ( g > f ′ g ′ ) ) \forall (g,f) \in M \forall (g',f') \in M : \neg ((f'>_gf) \wedge (g >_{f'} g')) (g,f)M(g,f)M:¬((f>gf)(g>fg))
    即,不可能出现g更喜欢跟f’在一起,f’更喜欢跟g再一起。
g
f
g'
f'

2.找到一个算法的步骤:

待解决问题是一个已知问题(Known Problem)的另一种表述(Reformulation)

例子:

  • Selection Problem: 给定一个int a[n],寻找a中第k大的数字。
    • Sol: 这个问题可以看作是一个排序问题的子问题,即,将a从大到小排,a[k-1]即可。

利用Generic Algorithm Design Principles

  • Devide and conquer
  • Dynamic Programming
  • Greedy Algorithms

看看简单的例子

例如,在Stable Marraige中,我们可以考虑所有的男人和女人都有相同的Prefereces。
此时,第k个最受欢迎的人相互结婚。
此时我们注意到,我们研究的问题有Unique Solution。

Deeper Understanding of the Problem

  • 是否一直存在一个Unique Solution?
  • 并不,在n=2的时候:
    【Amphi1 n=2.jpeg】

只要有一方不同意,且为另一方最优,则就是最优Match

🌟 Ordered Iterative Improvement: Deferred Acceptance Algorithm

Deferred Acceptance Algorithm (Gale, Shapley, 1962):

  • 开始:所有的人都是Single
  • while 还有一个single的男人 g:
    • 令f是对g来说最优美丽的女人,f要是single或者她与另外一个不如g有魅力的男人订婚了
    • 如果f和g‘结婚了,则他们需要分手
    • 让f和g结婚

Rq:

  1. Greedy Approach: g得到了最优吸引力的女人
  2. Ordered Progress: 每次都为一个Single的男人找到他的一个伴侣
    • 希望能避免Cycles

3. 对于算法的描述

定义:

An algorithm is not a computer program. It’s a sufficiently precise description how to compute a desired object.

我们有很多种描述算法的方法:

  1. Plain Text
  2. Pseudo Code
  3. Code in some programming language
  4. diagrams, flow charts (现在不太用了)

Textual Description

例如,对于Stable Mariage问题:

Starting with all people being single, we repeat marrying unmarried men to the most attractive woman willing to marry them, until everyone is married.

Rough Pseudocode

  • 开始:所有的人都是Single
  • while 还有一个single的男人 g:
    • 令f是对g来说最优美丽的女人,f要是single或者她与另外一个不如g有魅力的男人订婚了
    • 如果f和g‘结婚了,则他们需要分手
    • 让f和g结婚

有while和if

4. 分析Deffered Acceptance Algorithms

要考虑的问题:

  1. Algorithm是否可以结束?
  2. Algorithm是否正确?
  3. Complexity
  4. Can we say more about its output than just being stable ?

是否所有的操作都会被执行?

是的。这里我们主要考虑两点:

  1. The choice of g is ambiguous, but we agreed that unspecified details can be specified arbitrarily
  2. 是否存在一个f满足我们第三行的条件:(如果不存在,就无法执行了)
    • 是的,因为我们每次都是一对夫妇进行结婚,而且进入while循环的时候,我们就已经知道有一个单身男士了,所以一定存在一个单身女士,所以第三行可以被执行。

🌟 怎么分析算法?-> Invariants

方法一:
M t M_t Mt记为算法进行t次之后的值。
方法二:
证明存在一个性质它一直成立,与时间t无关。

证明算法会结束

Invariant 1: Women Improve Overtime

证明每一个女人的情况会随着时间而改善。
即: single -> some guy -> better guy -> … -> final partner

Dem:

  • 首先,女人的情况只在有新的男人g问她的情况下才改变(第三行),而她要改变伴侣只可能处于(1)她没有伴侣(2)她的现任伴侣g’要比g对她来说更没吸引力。
  • 因此,我们证明了一个女人的情况会随着时间而改善。

Invariant 2: Each man asks each women at most once

证明:每一个男人最多只会问同一个女人一次。[这里的问就是有把握他自己更优]

Dem:

  • 当男人g第一次问f的时候,他们将会结婚(engage)
  • 男人g要第二次问f,则他们(g和f)一定要先分手,则此时f一定和一个比g更优秀的男人g’在一起。
  • 此时,如果g是single进入循环的话,g不会再找f,因为f现任伴侣g’比g更优秀(Invariant 1)。

Lemma 1:The GS-Algorithm terminates after at most n 2 n^2 n2 iterations of the while-loop.

证明了算法会在最多 n 2 n^2 n2次循环后结束(Terminate)。

Dem:
由Invariant 2知道,n个男人中的每一个男人g,最多问n个女人中每一个女人1次,因此最多需要 n 2 n^2 n2次iterations才会停止。

算法正确:

Invariant 3: 对于任何一个Pair存在一个Matching [🌟Classic Loop Invariant]

Dem:

  1. 进入循环的时候,Invariant 3成立,因为每个人都是single的
  2. 假设进入循环后的第一行,Invariant 3 成立。
  3. Invariant在循环结束的时候依旧成立,因为(1)新的couple(g,f)新形成了,(2)g现在是单身,(3)f将之前的partners都踢掉了。因此在循环结束的时候,Invariant 3依旧成立。

再结合Lemma 1,我们就可以知道,存在一个Perfect Matching

Invariant 4: 如果f和g结婚了,则对于g更有吸引力的女生f’都跟相对于她们比g更有吸引力的男生g’结婚了

If g and f are engaged, then all women f’ more attractive for g than f are engaged to a man they find more attractive than g.

Dem:

  1. 考虑 f ′ ∈ F , f ′ > g f f' \in F, f' >_g f fF,f>gf
  2. 如果f和g结婚了,则g’一定和f’结婚了,f’满足 f ′ > g f f'>_gf f>gf。否则,根据算法,g一定会和f’结婚。
  3. 根据Invariant 1,f‘之后的伴侣一定质量越来越高,因此不可能给g再有机会。

证明算法terminates with a stable matching

Dem:

  1. 鉴于我们证明了Perfect Matching,所以只要证Stable即可。
  2. 假设(g,f),(g’,f’)已经engaged,如果g更喜欢f’,则 f ′ > g ′ f f' >_g' f f>gf(Invariant 4),因此形成(g,f’)不好,因为f’不愿意。

改进

Invariant 2+: The women asked by a man g over time are sorted in decreasing order of preference

否则为了寻找g的伴侣,需要循环所有列表F,找到一个单身或者伴侣质量没有g好的女人f。

Dem:

  1. 设f1,f2两个被g 按此顺序asked女人。要么是f1更吸引g,要么是f2已经和一个比g更好的人结婚了。此外,由Invariant 1知道,f2的伴侣只可能越来越好,所以排除了g还会找f2的可能。

Pseudocode

【Amphi 1 Gale-Shapley Algorithm改进后】

Rq:
这个算法会给所有的男人最优的女人,而给女人最差的男人。

🌟 Invariants vs. Temporal Properties

True Invariants: Static assertion valid throughout the execution of the algorithm

  • 因为是static,所以可以在任意时刻来检查。
  • 证明技巧:(Loop Invariant)
    • Show: Assertion true when the loop is first entered
    • Show: if the assertion is true at the beginning of the loop, then also at the end.
    • Gives: Assertion always true.

Temporal Properties: “dynamic” assertion on the whole process

  • 例如:“Each women’s situation only improves over time”
  • 因为是Dynamic的,所以必须在整个过程的意义下考虑
  • 可以变成一个Static的Assertion(见Poly❓)

5. Algorithmic Game Theory

Algorithmic Game Theory = Problems that have both an algorithmic and a game theoretic flavor.

Game 定义:

  • n players:
  • Each player has differernt ways to act (“strategies”):
  • The Players simultaneously choose a strategy.
  • Depending on all strategies chosen, each player receives a pay-off.
  • Selfish behavoir: players try to optimize their pay-off.

Nash-equilibrium:

一系列Strategies: 单个Player无法单方面改变策略提高他的pay-off Stable Situation.

Maximum Matchings: Classic Algorithmics v.s. Game Theory

在这里插入图片描述
如果使用传统意义上使得权重和最大,我们得到的解的和是200,但这个解并不是Stable的,所以Game Theory改变了什么是Good Solution的定义。

1. Price of Anarchy

Price of Anarchy:
最优的值处以最差的nash均衡的值。

例如,在上面的例子中,我们最优的值为100+100=200。但是Nash均衡的时候,值为101+1=102。 Price of Anarchy ∼ 2 \text{Price of Anarchy} \sim 2 Price of Anarchy2

2. Truthfulness

An algorithm is truthful if no player has an incentive to lie. [lie之后有可能会让一个解变成Social Optmum]

例子1:Classic sealed-bid auction: 出价最高的人赢

Classic sealed-bid auction: 出价最高的人赢,他付他出的钱。
此时并不是Truthful

如果你按照你估计值的原价拍卖(truthful),无论你是否赢,你都不会得到Payoff。
因此,你会采取另一种对你更优的策略:比心中价格出得更低一些。(not truthful)。

例子2:Vickrey Auctions
出价最高的人赢,他付第二高bid的人出的钱。
此时是一个truthful的auction。

3. Braess’s Paradox

证明一个selfish behavoir leads to unexpecred results.
这里的x意味着,如果只有50个人选这条路,则他们所需要用的时间就是50。

【Braess‘s Paradox】

总结:

我们如果单纯的运用数学上对于最优的定义,我们的解可能会在实际上因为人们的自私行为等因素导致Price of Anarchy, Truthfulness和Braess’s Paradox。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值