Online Algorithms and Competitive Analysis. Spring 2018

Similar documents
The Market Economy. The Economy. Consumers, Producers, and the Market. Are You Motivated Yet? Name:

Why Do So Many Online Businesses Fail?

100 Classified Ad Examples & Resources

The slightest perception of something negative happening can affect an employee s emotional state.

THE HR GUIDE TO IDENTIFYING HIGH-POTENTIALS

Operations and Supply Chain Management Prof. G. Srinivasan Department of Management Studies Indian Institute of Technology, Madras

8 ways to make your survey useless if you are making any of these mistakes with your surveys, you might as well throw away the data and start all over

Be the COMPLIMENTS OF INTUIT PAYROLL BEST BOSS. Your Employees Ever Had By Ken Darrow

Online Book Arbitrage

Workshop #2: Evolution

Innovative Marketing Ideas That Work

The Lazy Man s Cash Formula

Social Media Marketing Navigating the Maze

MORE PARKING FOR LESS. Preliminary round assignment 22 st Mathematics A-lympiad

Payback & Return Analysis for Solar in Mueller - Revision 1

Introduction to e-commerce website optimization

NHRMA Conference - September 27, 2017

The Beginners Guide to Setting Up an Adwords Account

Anytime Adviser New Car Buying Coach

SOFTWARE DEVELOPMENT. Process, Models, Methods, Diagrams Software Development Life Cyles. Part - V

Recruiting Leader Data Toolkit

HOW TO KEEP EMPLOYEES MOTIVATED, EVERY SINGLE DAY

Economics 102 Summer 2015 Answers to Homework #2 Due Tuesday, June 30, 2015

Millennials are crowdsourcingyouhow companies and brands have the chance to do

THE ULTIMATE CAREER FAIR CHECKLIST FOR EMPLOYERS

My Top 19 Customer Service Tips

Exam #2 (100 Points Total) Answer Key

Tips for Employer Relationship Building: A Guide for IPS Supported Employment Specialists

TOP 5 CHALLENGES OF GROWING COMPANIES

Shaping fundraising s future, part two

What Is Coaching? Overview Guiding Church Leaders

Basics of Social Media. The why, the what, and the how for your small business or nonprofit

10 COMMON DIRECT MAIL FAILS

Selected brief answers for review questions for first exam, Fall 2006 AGEC 350 Don't forget, you may bring a 3x5" notecard to the exam.

Multiple Regression. Dr. Tom Pierce Department of Psychology Radford University

Information and Practice Leaflet

PERCENTS - Teacher Notes Unit 6-7 th grade

HOW BEST-IN-CLASS DEALERS ARE MAKING MORE CUSTOMER CONNECTIONS

Make the Jump from Business User to Data Analyst in SAS Visual Analytics

How to Begin Preparing Your Business For Sale

Health & Safety at Work

Starting Your Own Business

Five Marketing Mistakes Every Manager Makes (and how to avoid making them)

The Challenger TM Customer: THE NEW REALITY OF SALES

Top 10 Marketing Mistakes Even the Smartest Companies Make And How You Can Avoid Them

Negotiation and Selling Against Lower-Priced Competition

Shape and Velocity Management. Stu Schmidt

Most organizations spend

MANAGEMENT ACCOUNTING PERFORMANCE EVALUATION John Joyce addresses the problem areas of overhead variances and planning variances.

Econ 3120 Fall 2016 Xi Wang

Mobile Marketing. This means you need to change your strategy for marketing to those people, or risk losing them to your competition.

Unit 6 Good Choice. What is the most important thing to consider when you buy a product? Rank them 1 4. (1 = most important) Answer the question.

Realizing. Issue 17 LEADERSHIP. Everyday Leaders Changing Our World. Linda Fisher Thornton in Conversation ETHICAL LEADERSHIP

Health & Safety at Work

developer.* The Independent Magazine for Software Professionals Automating Software Development Processes by Tim Kitchens

How to Use a Weird "Trade- In" Loophole to Bank $300 to $500 PER DAY

Thoughts and Guidance on Addressing the Current Economic Environment: Fundraising in a Difficult Economy

Differentiation. The SunTrust Guide to Competitive Strategy 1

BBC LEARNING ENGLISH 6 Minute English How would you like to pay?

Appendix A Tools to Prioritize Requirements

What Every Business Owner or General Manager should Know

Why The Best Product Fails

Scope Creep: need strong change control to prevent or mitigate. Must establish the change control system early in the project.

Role of the Business Development Center (BDC)

E-J Electric Company

Creating Kick-Ass Engagement Plans for Your Key Accounts

How a Revolutionary New Marketing System can Double or Triple Your Real Estate Commissions This Year.

Lesson 1) PPC Strategy Development

Marginal Costing Q.8

Discover Prepaid Jeff Lewis Interview

#1 Misalignment of internal and external resources

Facebook Friendly Marketing

A Generational Snapshot of Digital Communication and Gifting:

Measuring Your ROI On Social Media

Thinking about competence (this is you)

CRUSHING THE MANGANESE MYTH. Choosing the right alloy for your wear parts

Marketing Automation: One Step at a Time

HOW YOUR CAREER BACKGROUND CAN HELP YOU BECOME A BUSINESS ANALYST

Start Making Money: Make Money Helping Local Businesses! Page 1

USING FACEBOOK FOR RECRUITING

JUNE 18, 2008 $3.50. A SIMPLE System to WIN the New York Numbers Games! Red gave YOU another $2,500 payday with a STRAIGHT HIT on 2691!

a list of ready, willing, and able buyers that will pay you cash and close as quick as you need them to do so.

Sawtooth Software. Sample Size Issues for Conjoint Analysis Studies RESEARCH PAPER SERIES. Bryan Orme, Sawtooth Software, Inc.

Linda Carrington, Wessex Commercial Solutions

P.O. Box 12135, Costa Mesa, CA Phone: Fax:

Getting started with BPMe - FAQ

3 Ways for B2B Companies TO CASH IN, NOT CRASH IN. the Big Data Boom

How to Run a Successful B2B Content Syndication Campaign

Written Paper. Global Perspectives. Written Paper

Scottish Rugby Marketing Guide for Clubs

What Marketing DNA Tells You About Managing Google AdWords

The Ultimate Online Reputation Management Guide

Starting Your Own Business

CALCULATING THE ROI OF LEAD NURTURING

reasons to invest in a CMMS

ADWORDS IS AN AUTOMATED ONLINE AUCTION. WITHIN A CAMPAIGN, YOU IDENTIFY KEYWORDS THAT TRIGGER YOUR ADS TO APPEAR IN SPECIFIC SEARCH RESULTS.!

UIC Orientation Example Investments Intro (Finance 310) and Advice for Success

The 7C Social PR Framework Blueprint for Success

Where do workers find jobs in good times and bad times?

Best Practices for Trust in the Wireless Emergency Alerts System, page 1

Transcription:

Online Algorithms and Competitive Analysis CS16: Introduction to Data Structures & Algorithms CS16: Introduction to Data Structures & Algorithms Spring 2018

Outline 1. Motivation 2. The Ski-Rental Problem 3. Experts Problem 4. Dating Problem 3

Motivation We don t always start off with all the data we want at once We want the best algorithms to answer questions about such data 4

Offline Algorithms An offline algorithm has access to all of its data at the start it knows all of its data in advance Most of what you have done in this class has been offline (or at least given offline) 5

Online Algorithms An online algorithm does not have access to all of the data at the start Data is received serially, with no knowledge of what comes next How do you make a good algorithm when you don t know the future? 6

Ski-Rental Problem You like skiing You re going to go skiing for n days You need to decide: Do you rent skis or buy skis? Renting: $50 per day Buy: $500 once Goal: Minimize cost 7

Ski-Rental Problem (Offline) Offline solution: If n < 10, rent! Else, buy! Tough luck. You don t know what n is You love skiing so much, you ll ski as long as you don t get injured 8

Ski-Rental Problem Rent vs. Buy Total $ Rent $500 Buy 10 9 Days Time

Ski-Rental Problem (Offline) Total $ Offline solution is somewhere on the blue line $500 10 Days 10 Time

Ski-Rental Problem (Online) We don t know the future, so what can we do? Try to get within some constant multiplicative factor of the offline solution! I want to spend at most X times the amount the offline solution would spend Strategy: Rent until total spending equals the cost of buying Then buy if we want to ski some more 11

Ski-Rental Problem (Online) Total $ $1000 Online solution is somewhere on the purple line $500 10 12 Days

Ski-Rental Problem Analysis How good is this? If we ski 10 days or less, we match the optimal solution! If we ski more than 10 days, we never spend more than twice the offline solution This is not the only online solution! 13

Comparing Solutions Total $ Online solution $500 Offline solution 10 Days 14

How good is this? How do we know that our algorithms are good, i.e. close to optimal? What can we do if we don t even know what the most optimal algorithm is? 15

Competitive Analysis Analyzing an online algorithm by comparing it to an offline counterpart Competitive ratio: Ratio of performance of an online algorithm to performance of an optimal offline algorithm perf online apple c perf o ine + Our ski-rental solution has a competitive ratio of 2, since we are never more than 2 times as bad as the offline solution Our online algorithm is 2-competitive with the offline solution 16

More than just skis Refactoring versus working with a poor design Unrequited love? 17

The Experts Problem Dating is hard You know nothing about dating (oops) Dating can be reformulated as a series of binary decisions Not What should I wear?, but Do I wear these shoes? (yes) Should we go at 7? Should we go at 8? (7) Do I wait 15 minutes to text them back? Or 3 hours? (3) Should I buy them flowers? (no) 18

The Experts Problem: The Scenario You know nothing, so you should ask for help You know n experts who can give you advice before you make each decision (but you don t know if it s good) 19

The Experts Problem Rules If you make the right decision, you gain nothing If you make the wrong decision, you get 1 unit of embarrassment Total embarrassment = number of mistakes Goal: Minimize total embarrassment (relative to what the best expert would ve gotten) 20

The Experts Problem (Offline) Offline: We know the best expert We only listen to them Whatever successes and mistakes they have, we have Online: We don t know the best expert 21

The Experts Problem (Online) Assign every expert a weight of 1, for total weight of W = n across all experts Repeat for every decision: Ask every expert for their advice Weight their advice and decide by majority vote After the outcome is known, take every expert who gave bad advice and cut their weight in half, regardless of whether your bet was good or bad How good is this? 22

Multiplicative Weights Algorithm - Analysis To analyze how good this is, we need to relate the number of mistakes we make (m) to the number of mistakes the best expert makes (b) How can we do that? Use the weights! Let W represent the sum of the weights across the n experts at an arbitrary point in the algorithm 23

Experts Algorithm - Analysis Look at the total weight assigned to the experts When the best expert makes the wrong decision We cut their weight in half They started out with a weight of 1 1 b apple W 2 24

Experts Algorithm - Analysis Look at the total weight assigned to the experts When we made the wrong decision At least ½ weight was placed on the wrong decision We will cut at least ¼ of W, so we will reduce the total weight to at most ¾ of W Since we gave the experts n total weight at the start: 3 m W apple n 4 25

Experts Algorithm - Analysis 3 m W apple n 4 1 b apple W 2 1 b apple W apple n 3 m 2 4 26

Experts Algorithm - Analysis 1 3 m b log 2 n apple m log 2 3 4 2 1 2 b b apple W apple n apple W apple n 1 4 3 4 3 m m b + log 2 n m log 2 4 3 (b + log 2 n) log 2 4 3 m 2 b apple n b apple log 2 n + m log 2 3 4 4 So the number of mistakes we make, m, is at most 2.41 times the number of mistakes the best expert makes, b, plus some change 27

We want THE BEST How to find the best apartment? deal for a ticket? class to take? partner? How can we know that they re the best? How much effort are we willing to spend to find the best one? 28

The {Secretary, Dating} Problem Also known as the secretary problem There are n people we are interested in, and we want to end up dating the best one Assumptions: People are consistently comparable, and score(a)!= score(b) for arbitrary people a and b You don t know anyone s score until you ve gone on at least one date with them Can only date one person at a time (serial monogamy) Anyone you ask to stay with you will agree to do so 29

Dating Problem What s the offline solution? If you already know everyone s score, just pick the best person A naïve online solution? Try going out with everyone to assign them scores, and ask the best person to take you back Problems: Takes a lot of time / money, depending on n Assumes that they will take you back 30

Dating Problem Two main constraints: You can t look ahead into the future There s no undo if you let someone go, chances are they ll be taken by the time you ask for them back In other words, the problem is: Do I reject the current possibility in hopes of landing something better if I keep looking, or do I stick with what I have? 31

Dating Problem Solution: Pick a random ordering of the n people Go out with the first k people. No matter how the dates go, reject them (calibration of expectations) After these k dates, pick the first person that s better than everyone we ve seen so far, and stick with them they re probably the best candidate 32

Dating Problem - Analysis What value of k maximizes our chances of ending up with the best person? 3 Cases to consider: What if the best person is in the first k? We end up alone. Oops. What if the person that we pick isn t actually the best? Oh well, we live in blissful ignorance Otherwise, we successfully pick the best person! 33

Dating Problem - Analysis Consider the candidate at position j Let s first consider the probability that the algorithm pairs us with this candidate, given a value of k P choose (k, j) = 8 < 0 if j apple k, k : j 1 otherwise 34

Dating Problem - Analysis Consider the candidate at position j Case 1 0 j k n P choose (k, j) = 8 < 0 if j apple k, k : j 1 otherwise 35

Dating Problem - Analysis Case 2: There exists some person at position i who has the highest score we ve seen so far by the time we re considering the jth person 0 i k j n 0 k i j P choose (k, j) = 8 < 0 if j apple k, k : j 1 otherwise 36 n

Dating Problem - Analysis The probability that the jth person actually is the best is 1 / n) For a given k, the probability that we end up with the best person, P best, is the sum of the conditional probabilities for each valid value of j nx 1 k P best (k) = j 1 n j=k+1 37

Dating Problem - Analysis P best (k) = = lim n!1 nx k 1 j=k+1 j 1 n n k X 1 n j 1 j=k+1 k k ln n n In the above graph, what s the k/n value that maximizes p best? And what s the maximum value? 38

Dating Problem - Analysis 1/e, for both the maximum value of P best and the maximizing input for k/n 1 e = k n =) k = n e So, with 1/e = 36.79% probability, if your strategy is to date the first person better than everyone in the first 36.79% of dates, you ll end up with the best person! 39

Dating Problem - Improvements 1/e probability of not ending up with anyone :( Strategy: Be desperate Pick the last person, if you get that far With probability 1/e, we pick the last person who will have, on average, rank n/2, so we ll probably be ok Strategy: Gradually lower expectations Pick a series of timesteps, t 0, t 1, t 2, t k Reject the first t0 dates as before Look for the best person we ve seen so far between dates t 0 and t 1 If we find them, great! Otherwise, between dating the (t 1 +1)th and t 2 th people, look for either the first or the second best we haven t yet dated Repeat the above, gradually accepting a larger pool We ll probably do better than the be desperate strategy, though by how much is hard to say without hardcore math 40

Dating Problem - Extensions Why don t really know what n is Instead, we can use time as an approximation Michael Trick http://nymag.com/thecut/2013/03/princeton-mom-to-allstudents-find-a-husband.html Some numbers 18-40 -> 26.1 18-30 -> 22.44 22-30 -> 25 22-40 -> 28.66 41

Recap An online algorithm is an algorithm where input is fed to you piece by piece, which makes writing a fast and optimal algorithm much more difficult Competitive analysis frames an online algorithm s efficiency in terms of an offline solution 42

CS Applications CPUs and memory caches (CS33, CS157) Intel pays major $$$ for good caching strategies Artificial intelligence (CS141) Heuristics, search, genetic algorithms Machine learning (CS142) Statistics 43

More Applications (continued) Economics Stocks and trading Game theory Gambling Biology (featuring 2 authors of our textbook, Papadimitriou and Varizani) https://www.quantamagazine.org/20140618-the-gametheory-of-life/ Our textbook: Dasgupta, Papadimitriou, and Varizani Evolution as a balance between fitness and diversity, given an unknown future 44