03-Dynamic Programming
03-Dynamic Programming
Question 1
Solve the shortest path problem with dynamic programming (Forward
strategy)
7
B E 1
4
6 H
2 4
3
3 6
4 2
A C F J
3
4 4
3
3 I
4
1 3
D G
5
We have 5 stages
Stage 1:
Stage 2:
Stage 3:
Stage 4:
Question 2
• I am an avid hiker. Last summer, I went with my friend G. Don on a 5-day hike-
and-camp trip in the beautiful White Mountains in New Hampshire. We
decided to limit our hiking to an area comprising three well-known peaks:
Mounts Washington, Jefferson, and Adams. Mount Washington has a 6-mile
base-to-peak trail. The corresponding base-to-peak trails for Mounts Jefferson
and Adams are 4 and 5 miles, respectively.
• The trails joining the bases of the three mountains are 3 miles between
Mounts Washington and Jefferson, 2 miles between Mounts Jefferson and
Adams, and 5 miles between Mounts Adams and Washington. We started on
the first day at the base of Mount Washington and returned to the same spot
at the end of 5 days. Our goal was to hike as many miles as we could. We also
decided to climb exactly one mountain each day and to camp at the base of
the mountain we would be climbing the next day. Additionally, we decided
that the same mountain could not be visited in any two consecutive days.
• Use DP to schedule the 5-day hike.
Question 3
A wilderness hiker must pack three items: food, first-aid kits, and
clothes.
The backpack has a capacity of 3 ft3 Each unit of food takes 1 ft3. A first-
aid kit occupies ¼ ft3 and each piece of cloth takes about ½ ft3.
The hiker assigns the priority weights 3, 4, and 5 to food, first aid, and
clothes, which means that clothes are the most valuable of the three
items.
From experience, the hiker must take at least one unit of each item and
no more than two first-aid kits.
How many of each item should the hiker take?
Let,
Objective
Subject to,
Recursive Equations:
Stage 3:
Optimum Solution
Optimum Solution
Optimum Solution
12 3 + 23 = 26 6 + 13 = 19 9 + ---- 26 1
Optimum Solution:
Z = 26
m1 = 1, m2 = 2, m3 = 3