Introduction to algorithms-scheduling with the highest benefits from 15 to 7

Source: Internet
Author: User

[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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.