18 Deterministic Dynamic Programming

18 Deterministic Dynamic Programming - Match Puzzle E X A M...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Match Puzzle E X A M P L E 1 Milk E X A M P L E 2 This section covers topics that may be omitted with no loss of continuity. Deterministic Dynamic Programming Dynamic programming is a technique that can be used to solve many optimization problems. In most applications, dynamic programming obtains solutions by working backward from the end of a problem toward the beginning, thus breaking up a large, unwieldy problem into a series of smaller, more tractable problems. We introduce the idea of working backward by solving two well-known puzzles and then show how dynamic programming can be used to solve network, inventory, and resource- allocation problems. We close the chapter by showing how to use spreadsheets to solve dynamic programming problems. 18.1 Two Puzzles In this section, we show how working backward can make a seemingly difficult problem almost trivial to solve. Suppose there are 30 matches on a table. I begin by picking up 1, 2, or 3 matches. Then my opponent must pick up 1, 2, or 3 matches. We continue in this fashion until the last match is picked up. The player who picks up the last match is the loser. How can I (the first player) be sure of winning the game? Solution If I can ensure that it will be my opponents turn when 1 match remains, I will certainly win. Working backward one step, if I can ensure that it will be my opponents turn when 5 matches remain, I will win. The reason for this is that no matter what he does when 5 matches re- main, I can make sure that when he has his next turn, only 1 match will remain. For exam- ple, suppose it is my opponents turn when 5 matches remain. If my opponent picks up 2 matches, I will pick up 2 matches, leaving him with 1 match and sure defeat. Similarly, if I can force my opponent to play when 5, 9, 13, 17, 21, 25, or 29 matches remain, I am sure of victory. Thus, I cannot lose if I pick up 30 29 1 match on my first turn. Then I sim- ply make sure that my opponent will always be left with 29, 25, 21, 17, 13, 9, or 5 matches on his turn. Notice that we have solved this puzzle by working backward from the end of the problem toward the beginning. Try solving this problem without working backward! I have a 9-oz cup and a 4-oz cup. My mother has ordered me to bring home exactly 6 oz of milk. How can I accomplish this goal? 962 C H A P T E R 1 8 Deterministic Dynamic Programming Solution By starting near the end of the problem, I cleverly realize that the problem can easily be solved if I can somehow get 1 oz of milk into the 4-oz cup. Then I can fill the 9-oz cup and empty 3 oz from the 9-oz cup into the partially filled 4-oz cup. At this point, I will be left with 6 oz of milk. After I have this flash of insight, the solution to the problem may easily be described as in Table 1 (the initial situation is written last, and the final sit- uation is written first)....
View Full Document

Page1 / 56

18 Deterministic Dynamic Programming - Match Puzzle E X A M...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online