Hi all! i know this is a bit hard and far fetch. But i was wondering if there is a way to implement this algorithm into vba to pick a job for process
1. enumerate jobs such that d1 ≤ . . . ≤ dn;
2. S1 := ∅; t := 0;
3. FOR j:=1 TO n DO
4. S1 := S1 ∪ {j}; t := t + pj;
5. IF t > dj THEN
6. Find job k with largest pk value in S1;
7. S1 := S1 \ {k}; t := t − pk;
8. END
9. END
The main idea is we have 4 columns with the number of jobs
[TABLE="width: 500"]
<tbody>[TR]
[TD]Job number[/TD]
[TD]Processing time [/TD]
[TD]Due Date[/TD]
[TD]Completion date[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]2[/TD]
[TD]8[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]1[/TD]
[TD]4[/TD]
[TD]3 = (2+1)[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]3[/TD]
[TD]6[/TD]
[TD]6 = (3+3)[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]4[/TD]
[TD]7[/TD]
[TD]10= (6+4)[/TD]
[/TR]
</tbody>[/TABLE]
The jobs are first sorted by due date in ascending order and checked if the job is late (completion date < due date)
[TABLE="width: 500"]
<tbody>[TR]
[TD]Job number[/TD]
[TD]Processing time [/TD]
[TD]Due Date[/TD]
[TD]Completion Date[/TD]
[TD]Late?[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]1[/TD]
[TD]4[/TD]
[TD]1[/TD]
[TD]No[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]3[/TD]
[TD]6[/TD]
[TD]4 (1+3)[/TD]
[TD]No[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]4[/TD]
[TD]7[/TD]
[TD]8 (4+4)[/TD]
[TD]Yes[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]2[/TD]
[TD]8[/TD]
[TD]10 (2+8)[/TD]
[TD]Yes[/TD]
[/TR]
</tbody>[/TABLE]
From the first 3 jobs (earliest late job to the top), remove the longest duration job, keeping it seperate
[TABLE="width: 500"]
<tbody>[TR]
[TD]Job number[/TD]
[TD]Processing time [/TD]
[TD]Due Date[/TD]
[TD]Completion Date[/TD]
[TD]Late?[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]1[/TD]
[TD]4[/TD]
[TD]3[/TD]
[TD]No[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]3[/TD]
[TD]6[/TD]
[TD]6[/TD]
[TD]No[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]2[/TD]
[TD]8[/TD]
[TD]2[/TD]
[TD]Yes
[/TD]
[/TR]
</tbody>[/TABLE]
Repeat steps to see if last job is late.
[TABLE="width: 500"]
<tbody>[TR]
[TD]Job number[/TD]
[TD]Processing time [/TD]
[TD]Due Date[/TD]
[TD]Completion Date[/TD]
[TD]Late?[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]1[/TD]
[TD]4[/TD]
[TD]1[/TD]
[TD]No[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]3[/TD]
[TD]6[/TD]
[TD]4(1+3)[/TD]
[TD]No[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]2[/TD]
[TD]8[/TD]
[TD]6(4+2)[/TD]
[TD]No[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]
[/TD]
[/TR]
</tbody>[/TABLE]
Once all jobs are not late, add the seperated jobs back
[TABLE="width: 500"]
<tbody>[TR]
[TD]Job number[/TD]
[TD]Processing time [/TD]
[TD]Due Date[/TD]
[TD]Completion Date[/TD]
[TD]Late?[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]1[/TD]
[TD]4[/TD]
[TD]1[/TD]
[TD]No[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]3[/TD]
[TD]6[/TD]
[TD]4(1+3)[/TD]
[TD]No[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]2[/TD]
[TD]8[/TD]
[TD]6(4+2)[/TD]
[TD]No[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]4[/TD]
[TD]7[/TD]
[TD]10 (6+4)[/TD]
[TD]Yes
[/TD]
[/TR]
</tbody>[/TABLE]
This would be the sequence the jobs would be process 2-3-1-4.
help greatly appreciated
1. enumerate jobs such that d1 ≤ . . . ≤ dn;
2. S1 := ∅; t := 0;
3. FOR j:=1 TO n DO
4. S1 := S1 ∪ {j}; t := t + pj;
5. IF t > dj THEN
6. Find job k with largest pk value in S1;
7. S1 := S1 \ {k}; t := t − pk;
8. END
9. END
The main idea is we have 4 columns with the number of jobs
[TABLE="width: 500"]
<tbody>[TR]
[TD]Job number[/TD]
[TD]Processing time [/TD]
[TD]Due Date[/TD]
[TD]Completion date[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]2[/TD]
[TD]8[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]1[/TD]
[TD]4[/TD]
[TD]3 = (2+1)[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]3[/TD]
[TD]6[/TD]
[TD]6 = (3+3)[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]4[/TD]
[TD]7[/TD]
[TD]10= (6+4)[/TD]
[/TR]
</tbody>[/TABLE]
The jobs are first sorted by due date in ascending order and checked if the job is late (completion date < due date)
[TABLE="width: 500"]
<tbody>[TR]
[TD]Job number[/TD]
[TD]Processing time [/TD]
[TD]Due Date[/TD]
[TD]Completion Date[/TD]
[TD]Late?[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]1[/TD]
[TD]4[/TD]
[TD]1[/TD]
[TD]No[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]3[/TD]
[TD]6[/TD]
[TD]4 (1+3)[/TD]
[TD]No[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]4[/TD]
[TD]7[/TD]
[TD]8 (4+4)[/TD]
[TD]Yes[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]2[/TD]
[TD]8[/TD]
[TD]10 (2+8)[/TD]
[TD]Yes[/TD]
[/TR]
</tbody>[/TABLE]
From the first 3 jobs (earliest late job to the top), remove the longest duration job, keeping it seperate
[TABLE="width: 500"]
<tbody>[TR]
[TD]Job number[/TD]
[TD]Processing time [/TD]
[TD]Due Date[/TD]
[TD]Completion Date[/TD]
[TD]Late?[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]1[/TD]
[TD]4[/TD]
[TD]3[/TD]
[TD]No[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]3[/TD]
[TD]6[/TD]
[TD]6[/TD]
[TD]No[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]2[/TD]
[TD]8[/TD]
[TD]2[/TD]
[TD]Yes
[/TD]
[/TR]
</tbody>[/TABLE]
Repeat steps to see if last job is late.
[TABLE="width: 500"]
<tbody>[TR]
[TD]Job number[/TD]
[TD]Processing time [/TD]
[TD]Due Date[/TD]
[TD]Completion Date[/TD]
[TD]Late?[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]1[/TD]
[TD]4[/TD]
[TD]1[/TD]
[TD]No[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]3[/TD]
[TD]6[/TD]
[TD]4(1+3)[/TD]
[TD]No[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]2[/TD]
[TD]8[/TD]
[TD]6(4+2)[/TD]
[TD]No[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]
[/TD]
[/TR]
</tbody>[/TABLE]
Once all jobs are not late, add the seperated jobs back
[TABLE="width: 500"]
<tbody>[TR]
[TD]Job number[/TD]
[TD]Processing time [/TD]
[TD]Due Date[/TD]
[TD]Completion Date[/TD]
[TD]Late?[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]1[/TD]
[TD]4[/TD]
[TD]1[/TD]
[TD]No[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]3[/TD]
[TD]6[/TD]
[TD]4(1+3)[/TD]
[TD]No[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]2[/TD]
[TD]8[/TD]
[TD]6(4+2)[/TD]
[TD]No[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]4[/TD]
[TD]7[/TD]
[TD]10 (6+4)[/TD]
[TD]Yes
[/TD]
[/TR]
</tbody>[/TABLE]
This would be the sequence the jobs would be process 2-3-1-4.
help greatly appreciated