| Learn | Algorithm - Applications of Greedy technique - Minimizing lateness | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Minimizing Lateness There are numerous problems minimizing lateness, here we have a single resource which can only process one job at a time. Job
The solution
Its easy to see that shortest processing time first is not optimal a good counter example is
the smallest stack solution has simillar problems
the last strategy looks valid so we start with some pseudo code:
And as implementation in C++: And the output for this program is: The runtime of the algorithm is obviously Θ(n log n) because sorting is the dominating operation of this algorithm. Now we need to show that it is optimal. Clearly an optimal schedule has no idle time. the earliest deadline first schedule has also no idle time. Lets assume the jobs are numbered so that Proposition: Swapping two adjacent, inverted jobs reduces the number of inversions by one and does not increase the maximal lateness. Proof: Let Clearly it is That means the lateness after swap is less or equal than before. This concludes the proof. Proposition: The earliest deadline first schedule Proof:****(by contradiction) Lets assume The minimizing lateness problem and its near related minimum makespan problem, where the question for a minimal schedule is asked have lots of applications in the real world. But usually you don't have only one machine but many and they handle the same task at different rates. These problems get NP-complete really fast. Another interesting question arises if we don't look at the offline problem, where we have all tasks and data at hand but at the online variant, where tasks appear during execution. |
Read Article
https://develop.horje.com/learn/1434/reference