(Latest Revision:
March 19, 2021)
Weighted Intervals Problem
EXAMPLE:
Suppose we have the following weighted intervals.
start finish weight
11 14 4
10 13 5
9 11 5
11 14 3
8 9 2
To solve the problem, we start out by sorting the intervals by finish time. This gives us the following.
start finish weight
8 9 2
9 11 5
10 13 5
11 14 4
11 14 3
Next we calculate the p-values. P(j) = k, where, in the list below,
interval #k is the last interval prior to interval #j that
does not conflict with interval #j. (P(j) = 0 if all intervals
prior to interval #j conflict with it.)
# start finish weight P
1 8 9 2 0
2 9 11 5 1
3 10 13 5 1
4 11 14 3 2
5 11 14 4 2
Finally, we use the formula OPT(j) = max{OPT(j-1), weight(j)+ OPT(P(j))} to fill in the OPT value for each j. (The base case where j=1 is that OPT(1)=weight(1)).
# start finish weight P OPT
1 8 9 2 0 2
2 9 11 5 1 7
3 10 13 5 1 7
4 11 14 3 2 10
5 11 14 4 2 11
BACKTRACKING:
Since OPT(5)=11>10=OPT(4), we know that interval 5 is part of an optimal solution. Since the P value for 5 is 2, we know that the rest of the intervals are chosen from among intervals 1 and 2.
Since OPT(2)=7>2=Opt(1), we know that interval 2 is part of an optimal solution that uses interval 5. Since the P value for 2 is 1, we know that the rest of the intervals are chosen from "among" interval 1.
As a base case of the backtracking, we see that we can either take interval 1, and get its weight 2, or not take it, and get nothing, so we conclude that interval 1 is a part of the solution.
Thus, by backtracking, we have found that intervals 5, 2, and 1 form an optimal solution, with total weight 11.
The example above shows how to work this kind of problem. Your assignment is to work the following problem, and to produce the corresponding table and backtracking results, according to the technique illustrated in the example.
YOUR ASSIGNED PROBLEM:
start finish weight
11 15 7
16 21 10
12 14 4
20 23 6
10 13 5
18 24 8
14 19 8
22 25 5
Let me know if you have questions about how such problems are solved. The algorithm is covered in sections 6.1 and 6.2.
Directions For Submitting Solution:
You will e-mail me your homework solution.
Below is a sample of the information I want in your e-mail. It shows what the information would be for the example problem at the beginning of this document.
You must give me the same kind of information, in the same format,
for your assigned problem.
# start finish weight P OPT
1 8 9 2 0 2
2 9 11 5 1 7
3 10 13 5 1 7
4 11 14 3 2 10
5 11 14 4 2 11
Backtracking finds that intervals 5, 2,
and 1 form an optimal solution,
with total weight 11.
When you create your e-mail, copy and paste the text of your solution into the e-mail.
Do not attach any files to your e-mail.
Copy and paste the text into the message window of the e-mail.
Send the e-mail to
tester2@cs.csustan.edu
with this subject line:
CS 4440 Weighted Intervals Problem
(Copy & Paste that exact subject line. Get it right, or get no credit.)