cp-algorithms icon indicating copy to clipboard operation
cp-algorithms copied to clipboard

add alternate approach to schedule-with-completion-duration.md

Open Aaryan-Dadu opened this issue 8 months ago • 6 comments

  • add alternate approach for the article on optimal schedule of jobs given their deadlines and durations
  • article is based upon this approach https://github.com/cp-algorithms/cp-algorithms/issues/1593#issuecomment-3910189197
  • add proof of correctness for both approach
  • Closes #1593

Aaryan-Dadu avatar Mar 30 '26 19:03 Aaryan-Dadu

I am closing https://github.com/cp-algorithms/cp-algorithms/pull/1608 as that PR got little messy.

Aaryan-Dadu avatar Mar 30 '26 19:03 Aaryan-Dadu

What is the source for your proof and code?

spike1236 avatar Apr 26 '26 21:04 spike1236

What is the source for your proof and code?

I am little unsure what you mean by source for my proof, considering you are asking me my thoughts on how I got the proof, Firstly for the new approach I proposed my code here https://github.com/cp-algorithms/cp-algorithms/issues/1593#issuecomment-3910189197 For the proof part, Proof of present approach was straightforward, we move from right to left so for the last deadline only the last job matters as the deadline of all the rest of the jobs had already been met, so we have duration from dn-1 to dn we can completely dedicate to the last job, then dn-2 to dn-1 can be given to either complete last job if its not completed in dn-1 to dn duration or complete Jn-1 job, we can choose the job that has minimum duration left for completion and so on we can move, but while writing this proof it sounds like we are preempting the jobs so for that I proved a lemma which basically proves that if k jobs can be completed before their deadlines even with preemption then executing the jobs in order of their deadline can complete those jobs before their deadline without the need of preempting any of them.

For the alternate approach, We look from left to right, considering from the i-1 jobs maximum jobs that can be completed are in a set and total duartion to complete is T, for the Ji we add it to the set and the T can be updated to T+ti (total duration of all the jobs in set and the duration to complete Ji), if the T is now less that di then it means all the jobs in the set can be completed without exceeding the deadline else we remove the job with highest duration from the set as it reduces T the most. We did this as 1 job must be removed as all jobs in the set can't be completed if T is greater so we chose that job and we have to remove only 1 job as before adding Ji the set had jobs that can be completed before deadline so we can remove Ji or any other job with duration greater than equal to di so we choose the job with maximum duration.

I referred this proof and tried to keep my writing style similar to it.

Aaryan-Dadu avatar Apr 27 '26 08:04 Aaryan-Dadu

I'm asking because the proof looks suspiciously too polished (and likely AI-generated) so I wanted to know if there's some source for this proof. Also, I suggest to add !!! note "Lemma" for lemma styling. Refer to https://squidfunk.github.io/mkdocs-material/reference/admonitions .

spike1236 avatar Apr 30 '26 00:04 spike1236

I'm asking because the proof looks suspiciously too polished (and likely AI-generated) so I wanted to know if there's some source for this proof. Also, I suggest to add !!! note "Lemma" for lemma styling. Refer to https://squidfunk.github.io/mkdocs-material/reference/admonitions .

Sorry but I didn't referred to any source, I have course of Discrete Maths so in that we were taught about ways and flow to prove a theorem and I got the idea to add a lemma from there only so that is all. And I have made the suggested changes. (I have used info one because it looks more accurate for the lemma from here)

Aaryan-Dadu avatar Apr 30 '26 02:04 Aaryan-Dadu

You can refer to Knuth optimization article for lemma styling.

spike1236 avatar Apr 30 '26 05:04 spike1236

Just commenting to specify that the PR is not stale and I am working on this, just due to some commitments and the suggested changes are near to a re-write its taking a while to do so.

Aaryan-Dadu avatar Jul 10 '26 08:07 Aaryan-Dadu