Creating new worlds inside the computer. COS 116: 2/10/2011 Sanjeev Arora

Similar documents
Algorithm Design and Analysis

Analysis of Algorithms Fall Some Representative Problems Stable Matching

1. REPRESENTATIVE PROBLEMS

Algorithm Design and Analysis

1. REPRESENTATIVE PROBLEMS

Approximation and Randomized Algorithms (ARA) Lecture 1, September 3, 2012

CS320 Algorithms: Theory and Practice. Course Introduction

Algorithms. [Knuth, TAOCP] An algorithm is a finite, definite, effective procedure, with some input and some output.

CSC2556. Lecture 5. Matching - Stable Matching - Kidney Exchange [Slides : Ariel D. Procaccia]

Game Theory: Lecture #5

The key is that there are two disjoint populations, and everyone in the market is on either one side or the other

Matching Residents to Hospitals

1. REPRESENTATIVE PROBLEMS

What do you do when you can t use money to solve your problems?

Matching Theory and the Allocation of Kidney Transplantations

CS 6901 (Applied Algorithms) Lecture 2

Stable matching. Carlos Hurtado. July 5th, Department of Economics University of Illinois at Urbana-Champaign

Matching. Terence Johnson. April 17, University of Notre Dame. Terence Johnson (ND) Matching April 17, / 41

PROBLEMS OF MARRIAGE Eugene Mukhin

Two-Sided Matching. Terence Johnson. December 1, University of Notre Dame. Terence Johnson (ND) Two-Sided Matching December 1, / 47

We set up the basic model of two-sided, one-to-one matching

1. STABLE MATCHING. stable matching problem Gale Shapley algorithm hospital optimality context

Review Asympto&c Bounds

CPSC 320 Sample Solution, Reductions and Resident Matching: A Residentectomy

Consider a complete bipartite graph with sets A and B, each with n vertices.

Omega notation. Transitivity etc.

1 Definitions and Things You Know

Ma/CS 6b Class 3: Stable Matchings

It ain t no good if it ain t snappy enough. (Efficient Computations) COS 116, Spring 2011 Sanjeev Arora

1.1 First Problem: Stable Matching. Six medical students and four hospitals. Student Preferences. s6 h3 h1 h4 h2. Stable Matching Problem

Ma/CS 6b Class 3: Stable Matchings

Science Fiction, Bad Science, and Pseudoscience

Matchings in Graphs. Definition 3 A matching N in G is said to be stable if it does not contain a blocking pair.

Matching Problems. Roberto Lucchetti. Politecnico di Milano

CHAPTER 2 ATOMS, MOLECULES,

CS711008Z Algorithm Design and Analysis

Science Fiction, Bad Science, and Pseudoscience

Subramanian s stable matching algorithm

CSE 417, Winter Introduc6on, Examples, and Analysis. Ben Birnbaum Widad Machmouchi

Midterm 1. Your Exam Room: Name of Person Sitting on Your Left: Name of Person Sitting on Your Right: Name of Person Sitting in Front of You:

COOPERATIVE GAME THEORY: CORE AND SHAPLEY VALUE

CHAPTER 2 ATOMS, MOLECULES,

CS 598RM: Algorithmic Game Theory, Spring Practice Exam Solutions

COMP251: Bipartite graphs

Matching Problems. Roberto Lucchetti. Politecnico di Milano

Matching Theory. Mihai Manea. Based on slides by Fuhito Kojima. MIT

Bipartite Matchings and Stable Marriage

Assignment 3 Logic and Reasoning KEY

CPSC 320 Sample Solution, The Stable Marriage Problem

Advanced Algorithms. Lecture Notes for April 5, 2016 Dynamic programming, continued (HMMs); Iterative improvement Bernard Moret

Two Algorithms for the Student-Project Allocation Problem

Algorithms: COMP3121/3821/9101/9801

COMP251: Bipartite graphs

cs.washington.edu/417

Clouds & Mission for NASA

Big Bang, Black Holes, No Math

Discrete Mathematics and Probability Theory Fall 2014 Anant Sahai Midterm 1

Discrete Mathematics and Probability Theory Fall 2014 Anant Sahai Homework 3. This homework is due September 22, 2014, at 12:00 noon.

Spotlight On Saylesville Elementary Science Investigations

Cheating to Get Better Roommates in a Random Stable Matching

An improved approximation algorithm for the stable marriage problem with one-sided ties

Balancing Chemical Equations

Lecture 5: The Principle of Deferred Decisions. Chernoff Bounds

Matching: The Theory. Muriel Niederle Stanford and NBER. September 26, 2011

From Greek philosophers to circuits: An introduction to boolean logic. COS 116, Spring 2011 Sanjeev Arora

Chapter 2: Atoms, Molecules, and Life

Stable Marriage with Ties and Bounded Length Preference Lists

CSEP 521 Applied Algorithms. Richard Anderson Winter 2013 Lecture 1

Stable Matching Existence, Computation, Convergence Correlated Preferences. Stable Matching. Algorithmic Game Theory.

Cell Alive Homeostasis Plants Animals Fungi Bacteria. Loose DNA DNA Nucleus Membrane-Bound Organelles Humans

CPSC W1: Midterm #1 Sample Solution

General Chemistry I Chemistry 101B Fall 2002 Department of Chemistry Colgate University

Grade 6 Lesson 1. Lesson Plan Page 2. Student Activity Handout 1 Page 5

CSE 421 Algorithms. Richard Anderson Autumn 2015 Lecture 1

Weather and the Atmosphere. RAP Short Course

Prob. 1 Prob. 2 Prob. 3 Total

Lecture 2: Just married

Two-Sided Matching. Terence Johnson. September 1, University of Notre Dame. Terence Johnson (ND) Two-Sided Matching September 1, / 37

Designing Information Devices and Systems I Fall 2017 Homework 3

Strategic Behavior and Manipulation in Gender- Neutral Matching Algorithms

HOMEWORK IS WHERE THE REAL LEARNING HAPPENS!

Lesson Adaptation Activity: Analyzing and Interpreting Data

Astronomy 1010: Survey of Astronomy. University of Toledo Department of Physics and Astronomy

Algorithmics of Two-Sided Matching Problems

5E Lesson Plan Template

CSE 21 Practice Exam for Midterm 2 Fall 2017

Welcome to Physics 212

Copyright 2000, Kevin Wayne 1

CS 301. Lecture 18 Decidable languages. Stephen Checkoway. April 2, 2018

Practice problems from chapters 2 and 3

Weights in stable marriage problems increase manipulation opportunities

Weather. science centers. created by: The Curriculum Corner.

PS 101: Introductory Astronomy Fall 2014

Recent Advances in Generalized Matching Theory

February 11, Weather and Water Investigation 6 Day 6

Structures and Functions of Plant and Animal Cells

Cellular Automata. Jason Frank Mathematical Institute

First Midterm Examination

6.2b Homework: Fit a Linear Model to Bivariate Data

Linear Programming Test Review. Day 6

Transcription:

Creating new worlds inside the computer COS 116: 2/10/2011 Sanjeev Arora

Pseudocode Simple instructions: involve +, -,, Compound instructions Conditionals Loops No need to sweat over exact wording during exams (unless it changes meaning!)

Algorithm defn; revisited Pseudocode for turning a set of inputs into outputs in a finite amount of time Questions to think about: What class of computational tasks can be solved by algorithms? How dependent is this class on the exact definition of pseudocode?

Today s topic: Creating new worlds inside the computer. simulation

Conway s Game of life Rules: At each step, in each cell Survival: Critter survives if it has 2 or 3 neighbors. Death: Critter dies if it has 1 or fewer neighbors, or more than 3. Birth: New critter is born if cell is currently empty and 3 neighboring cells have critters.

Discussion Time How would you write pseudocode that simulates Game of Life? Should use: n x n array A (for desired n) A[i, j] = 1 means critter lives in square, 0 means empty square

Pseudocode for each step Do for i = 1 to n { Do for j = 1 to n { neighbors A[i 1, j - 1] + A[i 1, j] + A[i 1,j + 1] + A[i, j 1] + A[i, j + 1] + A[i + 1, j 1] + A[i + 1, j] + A[i + 1, j + 1] if ( neighbors = 2 OR neighbors = 3 ) then { B[i, j] 1 } else if ( neighbors = 1 ) etc. //see handout; Example 3// } } Do for i = 1 to n { Do for j = 1 to n { A[i,j] B[i,j] } }

Moral of the Game of Life? Simple local behavior can lead to complex global behavior (cf. Brian Hayes article on blackboard)

Physics of snow crystals Water vapor cooling Water further cooling Snow crystals Cooling reduce amount of molecular motion Crystal growth: capture of nearby floating molecules

Next..

Discussion Time How does weather prediction happen? Why can t we predict the weather a month from today?

Twister simulation Divide region into 3D grid Identify laws of physics for air Navier Stokes equations: How does a block of air move when certain pressure, temperature and velocity differentials exist on its boundary?

Simulator pseudocode Initialize Grid using data from observations: surface and aircraft measurements, radar (NEXRAD) readings, etc. Do for i = 1 to n { Do for j = 1 to n { Do for k = 1 to n { Update state of Grid[i, j, k] } } } 10ºC, 15 psi, 20% humidity 11ºC, 15 psi, 23% humidity etc.

Other examples of simulation [Turk 91] following: Weather forecasting Protein folding How patterns arise in plants and animals Animation

Display Q: How to display result of simulation? A: Computer graphics (later in course) [Enright and Fedkiw 02]

Bigger questions Alan Turing Albert Einstein Can computer simulation be replaced by a theory of weather? A theory of tornadoes? Is there a theory that answers this type of problem: Given: A starting configuration in the game of life Output: Yes if the cell at position (100, 100) is ever occupied, No otherwise

Actually, reverse trend: theory of matter (particle physics) is becoming computational. 1670 F = ma Today Hayes (reading this week): The universe as a cellular automaton

Peeking ahead: A computer can simulate another computer (e.g., a Classic Mac simulator on a PC). Will explore the implications of this in a future lecture. Game of life is actually a computer.

What does this pseudocode do? Write on a piece of paper and hand it in. n items, stored in array A Variables are i, S. S 0 Do for i = 1 to [n/2] { S S + A[2*i]; }

Stable Matching Problem Problem: Given N men & N women, find suitable matching Everyone lists their preferences from best to worst. Men s Preference List Man 1 st 2 nd 3 rd 4 th 5 th Victor Bertha Amy Diane Erika Clare Wyatt Diane Bertha Amy Clare Erika Xavier Bertha Erika Clare Diane Amy Yancey Amy Diane Clare Bertha Erika Zeus Bertha Diane Amy Erika Clare best worst

Stable Matching Problem Problem: Given N men & N women, find suitable matching Everyone lists their preferences from best to worst. Women s Preference List Woman 1 st 2 nd 3 rd 4 th 5 th Amy Zeus Victor Wyatt Yancey Xavier Bertha Xavier Wyatt Yancey Victor Zeus Clare Wyatt Xavier Yancey Zeus Victor Diane Victor Zeus Yancey Xavier Wyatt Erika Yancey Wyatt Zeus Xavier Victor best worst

Stable matching: definition There is no pair such that they prefer each other more than their current partners.

A man & woman are currently unstable if they prefer each other more than their current partner Man Xavier Yancey Zeus Men s Preference List 1 st A B A 2 nd B A B 3 rd C C C Woman Amy Bertha Clare Women s Preference List Lavender assignment is a possible matching. Are there any unstable pairs? 1 st Y X X 2 nd X Y Y 3 rd Z Z Z Yes. Bertha and Xavier form an unstable pair. They would prefer each other to current partners.

Example Men s Preference List Man 1 st 2 nd Xavier A B C Yancey B A C Zeus A B C 3 rd Women s Preference List Woman 1 st 2 nd 3 rd Amy Y X Z Bertha X Y Z Clare X Y Z Green assignment is a stable matching.

Example Man Xavier Yancey Men s Preference List 1 st A B 2 nd B C 3 rd A C Zeus A B C Women s Preference List Woman 1 st 2 nd 3 rd Amy Bertha Clare Y X X X Y Y Z Z Z Gray assignment is also a stable matching.

Propose-And-Reject Algorithm Guarantees a stable matching. Gale-Shapley Algorithm (men propose) Initialize each person to be free. while (some man m is free and hasn't proposed to every woman) { w = first woman on m's list to whom he has not yet proposed if (w is free) assign m and w to be engaged else if (w prefers m to her fiancé f) assign m and w to be engaged, and f to be free else w rejects m }

Extensions Unacceptable partners Every woman is not willing to marry every man, and vice versa. Some participants declare others as unacceptable. Sets of unequal size Unequal numbers of men and women, e.g. 100 men & 90 women Limited Polygamy e.g., Bill wants to be matched with 3 women.

Matching Residents to Hospitals Hospitals ~ Men (limited polygamy allowed). Residents ~ Women (more than hospitals) Started just after WWII (before computer usage). Ides of March, 13,000+ residents are matched. Rural hospital dilemma. Certain hospitals (mainly in rural areas) were unpopular and declared unacceptable by many residents. How to find stable matching that benefits rural hospitals?

Assignment for Valentine s day (write on piece of paper and bring to class on Tues; participation grade) Try Gale-Shapley algorithm for previously-shown Amy-Erica / Victor-Zeuss preference lists, but vary the order of choosing man m. Does this affect the outcome? Try the version where women propose. Does this affect the outcome? Bonus question: Try to justify this statement The Gale-Shapley algorithm finishes at some point, and when it finishes, there are no unstable pairs.

Other homework Readings for this week (on blackboard): (i) Brian Hayes article; first 5 pages (ii) Brooks 99-126. HW 1: Will be on website and has to be submitted in Class next Thurs