- We are given n jobs. Associated with each job i there is an integer deadline di and a profit pi where di>0 & pi>0.
- For any job i, the corresponding profit is earned if the job is completely by its deadline. To complete the job one has to process a job on a machine and only one machine is available for processing jobs.
- Each jobs requires only one unit of time for its processing.
- A feasible solution for this problem is a subset j of jobs such that each job in this subset can be completed by its deadline. The value of this feasible solution j is the sum of profits of jobs in j or ⅀pi. An optimal solution is a feasible solution with maximum value. Hence again, since the problem involves the identification of a subset, it fits the subset paradigm.
Job sequencing with deadlines algorithm:
- Initially all slots are free
- We have b+1 sets corresponding ponding to b+1 time slots i, 0 ≤ i ≤ b
- Slot 0 is a sentinel
- Initially F (i) = i for all i
- We will use parent p[i] to link slot i into its set
- Initially p[i] = -1 for all i
- Parent of root is negative of number of nodes in set
- To schedule job i with deadline di :
- “Find” root of tree containing slot min (n, di)
- Usually this is just slot di
- If root of i’s set is j, then F (j) is latest free slot, provided F (j) ≠ 0
- After using slot F(j), we combine (“set union”) set having root j with set having slot F(j) -1
Problem:
Feasible solution and there values are:
Sr. No |
Feasible solution |
Frequenting,sequence |
Values |
1 |
(1,2) |
1,2 or 2,1 |
110 |
2 |
(1,3) |
1,3 |
115 |
3 |
(1,4) |
1,4 |
127 |
5 |
(1,2,4) |
1,2,4 or 2,1,4 |
137 |
6 |
(1,3,4) |
3,1,4 |
142 |
7 |
(2,3,4) |
3,2,4 |
52 |
11 |
(2,3) |
3,2 |
25 |
12 |
(2,4) |
2,4 |
37 |
- Solution 6 is optimal. In this solution, job 1, 3, 4 are processed and the value is 142.
- These jobs can be processed in order 1, 3 and then 4 or 3, 1 and then 4.
- The processing of job 1 or 3 begins at time zero and is completed at time 3 and that of job 4 is completed at time 3.