0% found this document useful (0 votes)
34 views11 pages

Job Scheduling1

Ads
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views11 pages

Job Scheduling1

Ads
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 11

Job Sequencing With Deadlines

The problem is stated as below.


• There are n jobs to be processed on a machine.
• Each job i has a deadline di≥ 0 and profit pi≥0 .
• Pi is earned iff the job is completed by its deadline.
• The job is completed if it is processed on a machine
for unit time.
• Only one machine is available for processing jobs.
• Only one job is processed at a time on the machine.
1
Job Sequencing With Deadlines

• A feasible solution is a subset of jobs J such that


each job is completed by its deadline.
• An optimal solution is a feasible solution with
maximum profit value.
Example : Let n = 4, (p1,p2,p3,p4) = (100,10,15,27),
(d1,d2,d3,d4) = (2,1,2,1)

2
Job Sequencing With Deadlines

Sr.No. Feasible Processing Profit value


Solution Sequence
(i) (1,2) (2,1) 110
(ii) (1,3) (1,3) or (3,1) 115
(iii) (1,4) (4,1) 127 is the optimal one
(iv) (2,3) (2,3) 25
(v) (3,4) (4,3) 42
(vi) (1) (1) 100
(vii) (2) (2) 10
(viii) (3) (3) 15
(ix) (4) (4) 27
3
Greedy Algorithm To Obtain An Optimal
Solution

• Consider the jobs in the non increasing


order of profits subject to the constraint that
the resulting job sequence J is a feasible
solution.
• In the example considered before, the non-
increasing profit vector is
(100 27 15 10) (2 1 2 1)
p1 p4 p3 p2 d1 d4 d3 d2
4
Greedy Algorithm To Obtain An Optimal
Solution

J = { 1} is a feasible one
J = { 1, 4} is a feasible one with processing
sequence
( 4,1)
J = { 1, 3, 4} is not feasible
J = { 1, 2, 4} is not feasible
J = { 1, 4} is optimal

5
Greedy Algorithm To Obtain An Optimal
Solution
Algorithm Steps:
1.Sort the jobs based on profit in descending order.
2.Initialize an array timeslot to hold jobs (initially empty). OR Draw Gantt chart
with maximum deadline
3.Use a loop to assign jobs to the latest possible timeslot based on deadlines.

for i 1 to n do // use greedy rules //


set k  min (dmax, d(i))
while k>=1 do
if timeslot[k] is empty then
timeslot[k]=job[i]
break
end if 6
Greedy Algorithm To Obtain An Optimal
Solution
EXAMPLE: let n = 5, (p1,--------p5) = (20,15,10,5,1) and (d1,--d5) =
(2,2,1,3,3). Using the above rule

Jobs 1 2 3 4 5

Profit 20 15 10 5 1
Deadline 2 2 1 3 3

7
Iteration Process

8
Iteration Process

9
Greedy Algorithm To Obtain An Optimal
Solution
EXAMPLE: let n = 5, (p1,--------p5) = (20,15,10,5,1) and (d1,--d5) =
(2,2,1,3,3). Using the above rule

The optimal solution is {1,2,4}


Total profit is 20+15+5=40

J assigned slot jobs being action or assigned to


considered
Ø none 1 [1, 2]
{1} [ 1,2] 2 [0,1]
{1,2} [0,1],[1,2] 3 cannot fit reject as
[0,1] is not free
{1,2} [0,1],[1,2] 4 assign to [2,3]

{1,2,4} [0,1],[1,2],[2,3] 5 reject

10
Solve the following
Jobs A B C D E

Profit 100 19 27 25 15
Deadline 2 1 2 1 3

Jobs 1 2 3 4 5

Profit 35 30 25 20 15
Deadline 3 4 4 2 3

11

You might also like