Proving correctness of Stable Matching algorithm Analyzing algorithms Asymptotic running times

Similar documents
Analyzing proofs Introduction to problem solving. Wiki: Everyone log in okay? Decide on either using a blog or wiki-style journal?

CSCI211: Intro Objectives

Minimum Spanning Tree Union-Find Data Structure. Feb 28, 2018 CSCI211 - Sprenkle. Comcast wants to lay cable in a neighborhood. Neighborhood Layout

Midterm Review. EECS 2011 Prof. J. Elder - 1 -

Text UI. Data Store Ø Example of a backend to a real Could add a different user interface. Good judgment comes from experience

Comparison Sorts. EECS 2011 Prof. J. Elder - 1 -

Coalitional Game Theory

Estimating the Margin of Victory for Instant-Runoff Voting

TAFTW (Take Aways for the Week) APT Quiz and Markov Overview. Comparing objects and tradeoffs. From Comparable to TreeMap/Sort

Local differential privacy

Notes for Session 7 Basic Voting Theory and Arrow s Theorem

Midterm Review. EECS 2011 Prof. J. Elder - 1 -

Chapter 11. Weighted Voting Systems. For All Practical Purposes: Effective Teaching

CHAPTER 1 PROLOGUE: VALUES AND PERSPECTIVES

Overview. Ø Neural Networks are considered black-box models Ø They are complex and do not provide much insight into variable relationships

Maps and Hash Tables. EECS 2011 Prof. J. Elder - 1 -

Voting Criteria April

Random Forests. Gradient Boosting. and. Bagging and Boosting

Chapter 8: Recursion

Appendix to Non-Parametric Unfolding of Binary Choice Data Keith T. Poole Graduate School of Industrial Administration Carnegie-Mellon University

Hoboken Public Schools. Algebra II Honors Curriculum

CHAPTER 1 PROLOGUE: VALUES AND PERSPECTIVES

11/15/13. Objectives. Review. Our Screen Saver Dependencies. Our Screen Saver Dependencies. Project Deliverables Timeline TEAM FINAL PROJECT

Essential Questions Content Skills Assessments Standards/PIs. Identify prime and composite numbers, GCF, and prime factorization.

Year 1 Mental mathematics and fluency in rapid recall of number facts are one of the main aims of the new Mathematics Curriculum.

Illegal Migration and Policy Enforcement

Advanced Placement Calculus Assignment Log

EXAMINATION 3 VERSION B "Wage Structure, Mobility, and Discrimination" April 19, 2018

Lab 11: Pair Programming. Review: Pair Programming Roles

Hoboken Public Schools. College Algebra Curriculum

Modeling Voting Machines

Support Vector Machines

Complexity of Manipulating Elections with Few Candidates

Designing a Social Network Prep for Lab 10. March 26, 2018 Sprenkle - CSCI Why classes and objects? How do we create new data types?

Super-Simple Simultaneous Single-Ballot Risk-Limiting Audits

Influence in Social Networks

Tengyu Ma Facebook AI Research. Based on joint work with Rong Ge (Duke) and Jason D. Lee (USC)

THE ARITHMETIC OF VOTING

Many Social Choice Rules

Mr. Rarrick. John Locke

Tengyu Ma Facebook AI Research. Based on joint work with Yuanzhi Li (Princeton) and Hongyang Zhang (Stanford)

Hoboken Public Schools. AP Calculus Curriculum

Learning and Belief Based Trade 1

SOCIAL STUDIES LIFEWORK. The Three Branches of Government 6 th Grade

arxiv: v2 [math.ho] 12 Oct 2018

Check off these skills when you feel that you have mastered them. Identify if a dictator exists in a given weighted voting system.

John Locke. Source: John Locke, The Second Treatise of Government published 1689

In Elections, Irrelevant Alternatives Provide Relevant Data

Survey Research (Polling)

Managing migration from the traditional to modern sector in developing countries

David R. M. Thompson, Omer Lev, Kevin Leyton-Brown & Jeffrey S. Rosenschein COMSOC 2012 Kraków, Poland

Maps, Hash Tables and Dictionaries

Math of Election APPORTIONMENT

Latin American Immigration in the United States: Is There Wage Assimilation Across the Wage Distribution?

International Cooperation, Parties and. Ideology - Very preliminary and incomplete

Democratic Rules in Context

Civic Participation II: Voter Fraud

Hoboken Public Schools. Project Lead The Way Curriculum Grade 8

WUSC Student Refugee Program

Social Choice Theory. Denis Bouyssou CNRS LAMSADE

Reconciling Educational Adequacy and Equity Arguments Through a Rawlsian Lens

PPIC Statewide Survey Methodology

Enriqueta Aragones Harvard University and Universitat Pompeu Fabra Andrew Postlewaite University of Pennsylvania. March 9, 2000

Computational Inelasticity FHLN05. Assignment A non-linear elasto-plastic problem

Games With Incomplete Information A Nobel Lecture by John Harsanyi

Sequential Voting with Externalities: Herding in Social Networks

NP-Hard Manipulations of Voting Schemes

THE LOUISIANA SURVEY 2017

Special Majorities Rationalized

CONTRACT LAW Part II * Spring 2018 Course Number Location: F. J. JACKSON Office Hours Course Books / Material Course Description Course Objectives

Philosophische Winterakademie 07. bis 10. Februar 2017 Wettbewerb Philosophischer Essay. 2. Platz

The ten years since the start of the Great Recession have done little to address

PSC : American Politics 106 Graham Building MWF, 11:00-11:50 Fall 2012

Part 1: Focus on Income. Inequality. EMBARGOED until 5/28/14. indicator definitions and Rankings

CSC304 Lecture 16. Voting 3: Axiomatic, Statistical, and Utilitarian Approaches to Voting. CSC304 - Nisarg Shah 1

Event Based Sequential Program Development: Application to Constructing a Pointer Program

2015 Remember Bracero Foundation Scholarship

BY Amy Mitchell, Tom Rosenstiel and Leah Christian

Review of Lab 9. Review Lab 9. Social Network Classes/Driver Data. Lab 10 Design

MATH 1340 Mathematics & Politics

For All Your Staffing Solutions

Title: Adverserial Search AIMA: Chapter 5 (Sections 5.1, 5.2 and 5.3)

Unemployment and the Immigration Surplus

Jens Hainmueller Massachusetts Institute of Technology Michael J. Hiscox Harvard University. First version: July 2008 This version: December 2009

Liberalism and Neoliberalism

ONLINE APPENDIX: Why Do Voters Dismantle Checks and Balances? Extensions and Robustness

Voting and preference aggregation

Extended Abstract: The Swing Voter s Curse in Social Networks

Objec&ves. Review. So-ware Quality Metrics Sta&c Analysis Tools Refactoring for Extensibility

Computational Social Processes. Lirong Xia

Name: Class: Date: ID: A

STUDY GUIDE FOR TEST 2

arxiv: v1 [cs.gt] 11 Jul 2018

Two-dimensional voting bodies: The case of European Parliament

Tilburg University. Can a brain drain be good for growth? Mountford, A.W. Publication date: Link to publication

Priority Queues & Heaps

North Carolina Races Tighten as Election Day Approaches

POLS 385: Comparative Political Institutions

How to Change a Group s Collective Decision?

Minnesota Public Radio News and Humphrey Institute Poll. Dayton Starts with Edge in Democratic Primary and Fall Election

Transcription:

Objectives Proving correctness of Stable Matching algorithm Analyzing algorithms Asymptotic running times Wiki notes: Read after class; I am giving loose guidelines the point is to review and synthesize Monday midnight deadline If you re interested, join the W&L Computer Science Facebook Group! Jan 11, 2019 Sprenkle - CSCI211 1 Review What is the stable matching problem? Ø What is given? Ø What is our goal? Provide a sketch of the algorithm What observations do you have about the algorithm and how it progresses? Ø What can we say about any woman s partner during the execution of the algorithm? Ø How does a woman s state change over the execution of the algorithm? Ø What can we say about a man s partner? Jan 11, 2019 Sprenkle - CSCI211 2 1

Propose-And-Reject Algorithm [Gale-Shapley 1962] Initialize each person to be free while (some man is free and hasn't proposed to every woman) Choose such a man m w = 1 st woman on m's list to whom m has not yet proposed if w is free assign m and w to be engaged else if w prefers m to her fiancé m' assign m and w to be engaged and m' to be free else w rejects m Jan 11, 2019 Sprenkle - CSCI211 3 Observations about the Algorithm What can we say about any woman s partner during the execution of the algorithm? Ø Observation 1. He gets better à she prefers him over her last partner How does a woman s state change over the execution of the algorithm? Ø Observation 2. Once a woman is matched, she never becomes unmatched; she only "trades up What can we say about a man s partner? Ø Observation 3. She gets worse Jan 11, 2019 Sprenkle - CSCI211 4 2

Proving Correctness Need to show Ø Algorithm terminates Ø Result is a perfect matching Ø Result is a stable matching Jan 11, 2019 Sprenkle - CSCI211 5 1) Algorithm Termination [Gale-Shapley 1962] Does algorithm terminate? Initialize each person to be free while (some man is free and hasn't proposed to every woman) Choose such a man m w = 1 st woman on m's list to whom m has not yet proposed if w is free assign m and w to be engaged else if w prefers m to her fiancé m' assign m and w to be engaged and m' to be free else w rejects m Jan 11, 2019 Sprenkle - CSCI211 6 3

Proof of Correctness: Termination Claim. Algorithm terminates after at most n 2 iterations of while loop. Ø Hint: How wouldn t the algorithm terminate? Jan 11, 2019 Sprenkle - CSCI211 7 Proof of Correctness: Termination Claim. Algorithm terminates after at most n 2 iterations of while loop. Pf. Each time through the while loop, a man proposes to a new woman. There are only n 2 possible proposals. Number of proposals is a good measure for termination à strictly increases; limited Jan 11, 2019 Sprenkle - CSCI211 8 4

Proof of Correctness: Termination Claim. Algorithm terminates after at most n 2 iterations of while loop. Pf. Each time through the while loop, a man proposes to a new woman. There are only n 2 possible proposals. Note: not yet discussing the cost in the body of the while loop Jan 11, 2019 Sprenkle - CSCI211 9 2) Algorithm Analysis: Perfect Matching Prove that final matching is a perfect matching Perfect matching: everyone is matched monogamously Hint: in algorithm, we know if m is free at some point in the execution of the algorithm, then there is a woman to whom he has not yet proposed. Jan 11, 2019 Sprenkle - CSCI211 10 5

Proof of Correctness: Perfection Claim. All men and women get matched. Pf. (by contradiction) Ø Where should we start? Suppose that some man m is not matched upon termination of algorithm Jan 11, 2019 Sprenkle - CSCI211 11 Proof of Correctness: Perfection Claim. All men and women get matched. Pf. (by contradiction) Ø Suppose that m is not matched upon termination of algorithm Ø Then some woman, say w, is not matched upon termination. Ø By Observation 2, w was never proposed to. Ø But, last man proposed to everyone, since he ends up unmatched (by the while loop s condition) Ø Contradiction Jan 11, 2019 Sprenkle - CSCI211 12 6

Proof of Correctness: Stability Claim. No unstable pairs. What does it mean for a given matching S* to be unstable? S* Amy-Yancey Bertha-Zeus... How do you think we should approach this proof? Jan 11, 2019 Sprenkle - CSCI211 13 Proof of Correctness: Stability Claim. No unstable pairs. Pf. (by contradiction) Ø Suppose m-w is an unstable pair: m, w prefers each other to partner in Gale-Shapley matching S*. S* Amy-Yancey Bertha-Zeus... What are the possibilities that lead to this? Jan 11, 2019 Sprenkle - CSCI211 14 7

Proof of Correctness: Stability Claim. No unstable pairs. Pf. (by contradiction) Ø Suppose m-w is an unstable pair: m, w prefers each other to partner in Gale-Shapley matching S*. Ø Case 1: m never proposed to w Þ m prefers his GS partner to w. Þ m-w is stable. Ø Case 2: m proposed to w Þ w rejected m (right away or later) Þ w prefers her GS partner to m. Þ m-w is stable. Ø In either case m-w is stable, a contradiction. S* Amy-Yancey Bertha-Zeus... men propose in decreasing order of preference women only trade up Jan 11, 2019 Sprenkle - CSCI211 15 Summary So Far Stable matching problem. Given n men and n women and their preferences, find a stable matching if one exists. Gale-Shapley algorithm. Guarantees to find a stable matching for any input Remaining Questions: If there are multiple stable matchings, which one does GS find? (see book) How to implement GS algorithm efficiently? (next week) What is our goal running time? Jan 11, 2019 Sprenkle - CSCI211 16 8

Review: Our Process 1. Understand/identify problem Ø Simplify as appropriate 2. Design a solution 3. Analyze Ø Correctness, efficiency Ø May need to go back to step 2 and try again 4. Implement Ø Within bounds shown in analysis Jan 11, 2019 Sprenkle - CSCI211 17 Lloyd Shapley 2012 1980 2012 Nobel Memorial Prize in Economic Sciences for the theory of stable allocations and the practice of market design. Jan 11, 2019 Sprenkle - CSCI211 18 9

Stable Matching Summary Stable matching problem. Given preference profiles of n men and n women, find a stable matching. no man and woman prefer to be with each other than assigned partner Gale-Shapley algorithm. Finds a stable matching in O(n 2 ) time. Ø Claim: can implement algorithm efficiently Jan 11, 2019 Sprenkle - CSCI211 19 TODAY S GOAL: DEFINE ALGORITHM EFFICIENCY Jan 11, 2019 Sprenkle - CSCI211 20 10

Our Process 1. Understand/identify problem Ø Simplify as appropriate 2. Design a solution 3. Analyze Ø Correctness, efficiency Ø May need to go back to step 2 and try again 4. Implement (On Wednesday) Ø Within bounds shown in analysis Jan 11, 2019 Sprenkle - CSCI211 21 Computational Tractability As soon as an Analytic Engine exists, it will necessarily guide the future course of the science. Whenever any result is sought by its aid, the question will arise - By what course of calculation can these results be arrived at by the machine in the shortest time? -- Charles Babbage Charles Babbage (1864) Analytic Engine (schematic) Jan 11, 2019 Sprenkle - CSCI211 22 http://plan28.org/ 11

Brute Force For many non-trivial problems, there is a natural brute force search algorithm that checks every possible solution Exponential Ø Typically takes 2 N time or worse for inputs of size N Ø Unacceptable in practice Example: How many possible solutions are there in the stable matching problem? In other words, how many possible perfect matchings are there? For each perfect match, we ll check if it s stable. Jan 11, 2019 Sprenkle - CSCI211 23 Brute Force For many non-trivial problems, there is a natural brute force search algorithm that checks every possible solution Exponential Ø Typically takes 2 N time or worse for inputs of size N Ø Unacceptable in practice Example: Stable matching: n! with n men and n women Ø If n increases by 1, what happens to the running time? Jan 11, 2019 Sprenkle - CSCI211 24 12

How Do We Measure Runtime? Jan 11, 2019 Sprenkle - CSCI211 25 Worst-Case Running Time Obtain bound on largest possible running time of algorithm on input of a given size N Ø Generally captures efficiency in practice Ø Draconian view but hard to find effective alternative What are alternatives to worst-case analysis? Jan 11, 2019 Sprenkle - CSCI211 26 13

Average Case Running Time Obtain bound on running time of algorithm on random input as a function of input size N Ø Hard (or impossible) to accurately model real instances by random distributions Ø Algorithm tuned for a certain distribution may perform poorly on other inputs Jan 11, 2019 Sprenkle - CSCI211 27 Towards a Definition of Efficient Desirable scaling property: When input size doubles, algorithm should only slow down by some constant factor C Ø Doesn t grow multiplicatively Jan 11, 2019 Sprenkle - CSCI211 28 14

Polynomial-Time Defn. There exists constants c > 0 and d > 0 such that on every input of size N, its running time is bounded by c N d steps. üdesirable scaling property: When input size doubles, algorithm should only slow down by some constant factor C Ø What happens if we double N? Defn. An algorithm is polynomial time (or polytime) if the above scaling property holds. Jan 11, 2019 Sprenkle - CSCI211 29 Algorithm Efficiency Defn. An algorithm is efficient if its running time is polynomial Justification: It really works in practice! Ø In practice, poly-time algorithms that people develop almost always have low constants and low exponents Ø Breaking through the exponential barrier of brute force typically exposes some crucial structure of the problem Exceptions Ø Some poly-time algorithms do have high constants and/or exponents (6.02 10 23 N 20 ) and are useless in practice Ø Some exponential-time (or worse) algorithms are widely used because the worst-case instances seem to be rare Jan 11, 2019 Sprenkle - CSCI211 30 15

Visualizing Running Times Running Time 1E+282 1E+266 1E+250 1E+234 1E+218 1E+202 1E+186 1E+170 1E+154 1E+138 1E+122 1E+106 1E+90 1E+74 1E+58 1E+42 1E+26 1E+10 0.000001 2 n 1.5 n 1 10 100 1000 Input Size n 10 n 3 n 2 n Polynomial Huge difference from polynomial to not polynomial Differences in runtime matter more as input size increases Jan 11, 2019 Sprenkle - CSCI211 32 Comparing 10000 n 2 and n 3 Running Time 1E+24 1E+22 1E+20 1E+18 1E+16 1E+14 1E+12 1E+10 100000000 1000000 10000 100 1 0.01 0.0001 0.000001 n 3 10000 n 2 1 10 100 1000 10000 1000000 10000000 100000000 Input Size As input size increases, n 3 dominates large constant * n 2 ècare about running time as input size approaches infinity èonly care about highest-order term Jan 11, 2019 Sprenkle - CSCI211 33 16

Asymptotic Order of Growth: Upper Bounds T(n) is the worst case running time of an algorithm We say that T(n) is O(f(n)) if there exist constants c cannot depend on n order f(n) sufficiently large n c > 0 and n 0 ³ 0 such that for all n ³ n 0, we have T(n) c f(n) T(n) is bounded above by a constant multiple of f(n) T is asymptotically upperbounded by f Jan 11, 2019 Sprenkle - CSCI211 34 Asymptotic Order of Growth: Upper Bounds f(n) T(n) n 0 Point at which f(n) > T(n) Jan 11, 2019 Sprenkle - CSCI211 35 17

Upper Bounds Example Find an upperbound for T(n) = pn 2 + qn + r Ø p, q, r are positive constants Motivation: Why can we simplify to just the largest term? Jan 11, 2019 Sprenkle - CSCI211 36 Upper Bounds Example Find an upperbound for T(n) = pn 2 + qn + r Ø p, q, r are positive constants Idea: Let s inflate the terms in the equation so that all terms are n 2 Jan 11, 2019 Sprenkle - CSCI211 37 18

Upper Bounds Example T(n) = pn 2 + qn + r Ø p, q, r are positive constants For all n 1, T(n) = pn 2 + qn + r pn 2 + qn 2 + rn 2 = (p+q+r) n 2 = c n 2 èt(n) cn 2, where c = p+q+r èt(n) = O(n 2 ) Also correct to say that T(n) = O(n 3 ) Jan 11, 2019 Sprenkle - CSCI211 38 Notation T(n) = O(f(n)) is a slight abuse of notation Ø Asymmetric: f(n) = 5n 3 ; g(n) = 3n 2 f(n) = O(n 3 ) = g(n) But f(n) ¹ g(n). Ø Better notation: T(n) Î O(f(n)) Meaningless statement. Any comparison-based sorting algorithm requires at least O(n log n) comparisons Ø Use W for lower bounds Jan 11, 2019 Sprenkle - CSCI211 39 19

Asymptotic Order of Growth: Lower Bounds Complementary to upper bound T(n) is Ω(f(n)) if there exist constants ε > 0 and sufficiently large n ε cannot depend on n n 0 ³ 0 such that for all n ³ n 0, we have T(n) ε f(n) T(n) is bounded below by a constant multiple of f(n) èt is asymptotically lowerbounded by f Jan 11, 2019 Sprenkle - CSCI211 40 Example: Lower Bound T(n) = pn 2 + qn + r Ø p, q, r are positive constants Idea: Deflate terms rather than inflate Jan 14, 2019 Sprenkle - CSCI211 41 20

Example: Lower Bound T(n) = pn 2 + qn + r Ø p, q, r are positive constants Idea: Deflate terms rather than inflate For all n 0, T(n) = pn 2 + qn + r pn 2 èt(n) εn 2, where ε = p > 0 èt(n) Î Ω(n 2 ) Also correct to say that T(n) Î Ω(n) Jan 14, 2019 Sprenkle - CSCI211 42 Tight bounds T(n) is Q(f(n)) if T(n) is both O(f(n)) and W(f(n)) ØThe right bound Jan 11, 2019 Sprenkle - CSCI211 43 21

A Fashion Analogy O == Hammer pants Ø Loose and baggy with plenty of room for the pants to shrink or the body to grow Ω == The pants you plan to fit in this summer after working off the snacks from Christmas Θ == Katy Perry's skin tight jeans in a teenage dream Ø Can't make them any smaller, and no extra room to even fit a cell phone in the pocket Courtesy Andy Danner, Swarthmore Jan 11, 2019 Sprenkle - CSCI211 44 Looking Ahead Continue reading Chapter 2 Ø Covering later sections on Wednesday Journal for 2 pages of Preface, 1.1, Chapter 2, 2.1, 2.2 due Monday at midnight Ø No journal for Chapter 1.2 Ø Wrapping up 2.2 in class on Monday; first part is helpful for problem set Problem Set 1 due next Friday before class Ø Proof, stable matching, asymptotic bound Ø Start early! Read problems and let your brain start thinking about them Solved exercises in book Ø Honor Code Jan 11, 2019 Sprenkle - CSCI211 45 22