[Switch]
Problem:
Suppose there is a machine and a set of n jobs A1, A2,... an processed on this machine. Every job AJ has a processing time TJ, benefit PJ, and end date DJ. Machine in
Only one job can be processed at a time, and the job AJ must run continuously within the TJ continuous time unit. Benefits PJ are obtained if job AJ is completed before the deadline DJ, but if it is completed after the deadline
Is not effective. Please provide a dynamic planning algorithm to find the most efficient scheduling, assuming that all processing time is an integer between 1 and N.
----------
Analysis:
In fact, this problem is similar to the 01 backpack problem.
1. Set A1, A2 ,..., An is sorted by DJ value, from small to large. Assume that in the following analysis, di <DJ is guaranteed when I <j. Add D0 = 0.
2. Construct the array s [N] [d [N], s [I] [J] to Schedule I jobs within J time, and obtain the most efficient benefit value. In the initial state, make s [I] [0] = 0 (I = 0-> N ), s [0] [J] = 0 (j = 0-> d [N]).
3. Calculate the value of S [I] [J]. Select [I] [J] is used to record whether to select I. Recursion involves the idea that if the I-th job is scheduled, it is best to end the job in a period, this ensures that jobs before I can be scheduled in more time.
For I = 1-> N
For j = 1-> d [I]
// Do not schedule I
S [I] [J] = s [I-1] [min (J, d [I-1])]
Select [I] [J] = false
// Schedule I
If j> T [I]
If s [I] [J] <s [I-1] [min (J-T [I], d [I-1])] + P [I]
S [I] [J] = s [I-1] [min (J-T [I], d [I-1])] + P [I]
Select [I] [J] = true
4. The final s [N] [d [N] is the most efficient benefit value. If the sequence of the scheduled job is required, it can be obtained through select.
Note that J in D [I-1] [J] can reach d [I-1] at most, so min (J-T [I], d [I-1]) is required!