Discrete Optimization

Slides:



Advertisements
Similar presentations
CS Section 600 CS Section 002 Dr. Angela Guercio Spring 2010.
Advertisements

Dynamic Programming.
Dynamic Programming In this handout A shortest path example
Part 3: The Minimax Theorem
Lecture 10. Simplified roulette European roulette has numbers 0,1,…36. xD0s
Dealer Comm Hand Player makes Ante bet and optional Bonus bet. Five cards are dealt to each player from the shuffler. Five cards are dealt from the shuffler.
Computer Science 313 – Advanced Programming Topics.
Lecture 33 CSE 331 Nov 20, Homeworks Submit HW 9 by 1:10PM HW 8 solutions at the end of the lecture.
Pertemuan 23 : Penerapan Dinamik Programming (DP) Mata kuliah : K0164-Pemrograman vers 01.
Chapter 5 Black Jack. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 5-2 Chapter Objectives Provide a case study example from problem statement.
Dynamic Programming 0-1 Knapsack These notes are taken from the notes by Dr. Steve Goddard at
Blackjack: Myths vs. Reality Group K Andrew KerrAndrew Phillips Sven SkoogWoj Wrona.
Please open your laptops, log in to the MyMathLab course web site, and open Quiz 2.6/7. You will have access to the online calculator on your laptop during.
April 2009 BEATING BLACKJACK CARD COUNTING FEASIBILITY ANALYSIS THROUGH SIMULATION.
Learning to Play Blackjack Thomas Boyett Presentation for CAP 4630 Teacher: Dr. Eggen.
Learning BlackJack with ANN (Aritificial Neural Network) Ip Kei Sam ID:
Fundamentals of Algorithms MCS - 2 Lecture # 7
Blackjack: A Beatable Game Amber Guo Adapted from: David Parker Advisor: Dr. Wyels California Lutheran University ‘05.
LECTURE 14: USE CASE BASICS CSC 212 – Data Structures.
COSC 3101A - Design and Analysis of Algorithms 7 Dynamic Programming Assembly-Line Scheduling Matrix-Chain Multiplication Elements of DP Many of these.
CS 312: Algorithm Design & Analysis Lecture #23: Making Optimal Change with Dynamic Programming Slides by: Eric Ringger, with contributions from Mike Jones,
Week 11 - Wednesday.  What did we talk about last time?  Exam 2 post-mortem  Combinations.
Dynamic Programming. Many problem can be solved by D&C – (in fact, D&C is a very powerful approach if you generalize it since MOST problems can be solved.
Do Now 9/17/09  Take out HW from last night. Textbook page 32 #14-40 even, #48-58 even Textbook page 32 #14-40 even, #48-58 even  Copy HW in your planner.
Thursday, May 2 Dynamic Programming – Review – More examples Handouts: Lecture Notes.
Week 8 : User-Defined Objects (Simple Blackjack Game)
Backtracking & Brute Force Optimization Intro2CS – weeks
Introduction to State Space Search
Discrete Optimization MA2827 Fondements de l’optimisation discrète Dynamic programming (Part 2) Material based on.
Discrete Optimization MA2827 Fondements de l’optimisation discrète Material from P. Van Hentenryck’s course.
Game playing Types of games Deterministic vs. chance
Data Structures Lab Algorithm Animation.
Game Theory Just last week:
Discrete Optimization
Intro to Computer Science II
Lecture 11.
Lecture 5 Dynamic Programming
Discrete Optimization
Chapter 5 Black Jack.
Lecture 10.
Pre-Algebra Q3W8: Square and Cube Roots
Advanced Design and Analysis Techniques
Use Combinations and the Binomial Theorem
Types of Algorithms.
Lecture 5 Dynamic Programming
Probability of casino games
Lecture 12.
Data Structures and Algorithms
1.1.3 Analysing competitor strengths and weaknesses
Kevin Mason Michael Suggs
CS 188: Artificial Intelligence Fall 2007
CS 188: Artificial Intelligence Fall 2008
Pasa números Divide students in to teams and have each team sit in a row. Give each student a dry erase marker and something to erase with. Each team gets.
Blackjack: Counting Hands and Counting Cards
Analysis of Algorithms CS 477/677
Task 2 Implementation help
Trevor Brown DC 2338, Office hour M3-4pm
Team Dont Block Me, National Taiwan University
DYNAMIC PROGRAMMING.
Dynamic Programming 動態規劃
Writing Expressions.
Do Now 9/24/10 Take out HW from last night. Copy HW in your planner.
Backtracking, Search, Heuristics
Dynamic Programming.
BY: Cesar, Jennifer, Adrianne & Allen
Announcements Assignment #4 is due tonight. Last lab program is going to be assigned this Wednesday. ◦ A backtracking problem.
CMSC201 Computer Science I for Majors Lecture 12 – Program Design
Analysis of Algorithms CS 477/677
Backtracking, Search, Heuristics
Unit II Game Playing.
Presentation transcript:

Discrete Optimization MA2827 Fondements de l’optimisation discrète Dynamic programming (Part 2) https://project.inria.fr/2015ma2827/ Material based on the lectures of Erik Demaine at MIT and Pascal Van Hentenryck at Coursera

Outline Dynamic programming More dynamic programming Guitar fingering More dynamic programming Tetris Blackjack Quiz: bracket sequences

Dynamic programming DP ≈ “careful brute force” DP ≈ recursion + memoization + guessing Divide the problem into subproblems that are connected to the original problem Graph of subproblems has to be acyclic (DAG) Time = #subproblems · time/subproblem

5 easy steps of DP Analysis: #subproblems #choices Define subproblems time/subproblem time extra time Define subproblems Guess part of solution Relate subproblems (recursion) Recurse + memoize OR build DP table bottom-up - check subprobs be acyclic / topological order Solve original problem

Guitar fingering Task: find the best way to play a melody

Guitar fingering Task: find the best way to play a melody Input: sequence of notes to play with right hand One note at a time! Which finger to use? 1, 2, …, F = 5 for humans Measure d( f, p, g, q ) of difficulty to go from note p with finger f to note q with finger g Examples of rules: crossing fingers: 1 < f < g and p > q => uncomfortable stretching: p << q => uncomfortable legato (smooth): ∞ if f = g

Guitar fingering Task: find the best way to play a melody Goal: minimize overall difficulty Subproblems: min. difficulty for suffix note[ i : ] #subproblems = O( n ) where n = #notes Guesses: finger f for the first note[ i ] #choices = F Recurrence: DP[ i ] = min{ DP[ i + 1 ] + d( note[ i ], f, note[ i +1 ], next finger ) }

Guitar fingering Task: find the best way to play a melody Goal: minimize overall difficulty Subproblems: min. difficulty for suffix note[ i : ] #subproblems = O( n ) where n = #notes Guesses: finger f for the first note[ i ] #choices = F Recurrence: DP[ i ] = min{ DP[ i + 1 ] + d( note[ i ], f, note[ i +1 ], next finger ) } Not enough information!

Guitar fingering Task: find the best way to play a melody Goal: minimize overall difficulty Subproblems: min. difficulty for suffix note[ i : ] when finger f is on note[ i ] #subproblems = O( n F ) Guesses: finger f for the next note, note[ i + 1 ] #choices = F Recurrence: DP[ i, f ] = min{ DP[ i + 1, g ] + d( note[ i ], f, note[ i +1 ], g ) | all g } Base-case: DP[ n, f ] = 0 time/subproblem = O( F )

Guitar fingering Task: find the best way to play a melody Topological order: for i = n-1, n-2, …, 0: for f = 1, …, F: total time = O( n F2 ) Final problem: find minimal DP[ 0, f ] for f = 1, …, F guessing the first finger notes fingers

Tetris Task: win in the game of Tetris!

Tetris Task: win in the game of Tetris! Input: a sequence of n Tetris pieces and an empty board of small width w Choose orientation and position for each piece Must drop piece till it hits something Full rows do not clear Goal: survive i.e., stay within height h

Tetris Task: stay within height h Subproblem: survival? in suffix [ i : ] given a particular column profile #subproblems = O( n (h+1)w ) Guesses: where to drop piece i? #choices = O( w ) Recurrence: DP[ i, p ] = max { DP[ i + 1, q ] | q is a valid move from p } Base-case: DP[ n+1, p ] = true for all profiles p time/subproblem = O( w )

Tetris Task: stay within height h Topological order: for i = n – 1, n – 2, …, 0: for p = 0, …, (h+1)w – 1: total time O( n w (h+1)w ) Final problem: DP[ 0, empty ] pieces profiles

Blackjack Task: beat the blackjack (twenty-one)!

Blackjack Task: beat the blackjack! Rules of Blackjack (simplified): The player and the dealer are initially given 2 cards each Each card gives points: Cards 2-10 are valued at the face value of the card Face cards (King, Queen, Jack) are valued at 10 The Ace card can be valued either at 11 or 1 The goal of the player is to get more points than the dealer, but less than 21, if more than 21 than he looses (busts) Player can take any number of cards (hits) After that the dealer hits deterministically: until ≥ 17 points

Perfect-information Blackjack Task: beat the blackjack with a marked deck! Input: a deck of cards c0, …, cn-1 Player vs. dealer one-on-one Goal: maximize winning for a fixed bet $1 Might benefit from loosing to get a better deck

Quiz (as homework) Write the DP for perfect-information blackjack Derive the number of subproblems for the tetris problem