20
Instructor Neelima Gupta [email protected]

Instructor Neelima Gupta [email protected]. Table of Contents Factor 2 algorithm for Bin Packing Factor 2 algorithm for Minimum Makespan Scheduling Reference:

Embed Size (px)

Citation preview

Page 1: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Factor 2 algorithm for Bin Packing Factor 2 algorithm for Minimum Makespan Scheduling Reference:

InstructorNeelima Gupta

[email protected]

Page 2: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Factor 2 algorithm for Bin Packing Factor 2 algorithm for Minimum Makespan Scheduling Reference:

Table of Contents

Factor 2 algorithm for Bin PackingFactor 2 algorithm for Minimum Makespan Scheduling

Reference: Vazirani.

Page 3: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Factor 2 algorithm for Bin Packing Factor 2 algorithm for Minimum Makespan Scheduling Reference:

Bin Packing Problem: DefinitionGiven n items of sizes x1 , … xn between 0 and 1, excluding 0, but including 1. Find a packing in unit-sized bins that minimizes the number of bins used.

Page 4: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Factor 2 algorithm for Bin Packing Factor 2 algorithm for Minimum Makespan Scheduling Reference:

Greedy Approach: factor 2Consider items in any arbitrary order.At any iteration I, we have a set of partially

filled bins B1 …. Bk

To insert the next element xi , we check if it can be put in any of the already used bin. If not then we open another bin Bk=1

Page 5: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Factor 2 algorithm for Bin Packing Factor 2 algorithm for Minimum Makespan Scheduling Reference:

Analysis : 2 factor approximationProve by induction that if at any iteration we have

m bins then at least m-1 of them are at least half full.

Thus (m-1)/2 < Sum_{i,n} xi

Since bins are of unit length, sum of item sizes is a lower bound on OPT. i.e Sum_{i,n} xi <= OPT

Thus m – 1 < 2 OPT i.e m <= 2OPT

Page 6: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Factor 2 algorithm for Bin Packing Factor 2 algorithm for Minimum Makespan Scheduling Reference:

Minimum Makespan SchedulingGiven n jobs with processing times p1 ……. Pn

and an integer m , find an assignment of the jobs to m identical machines so that the completion time, called the makespan is minimized.

Page 7: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Factor 2 algorithm for Bin Packing Factor 2 algorithm for Minimum Makespan Scheduling Reference:

Greedy Approach: factor 2Consider jobs in any arbitrary order.Schedule the next job on the machine with

the minimum makespan so far.

Page 8: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Factor 2 algorithm for Bin Packing Factor 2 algorithm for Minimum Makespan Scheduling Reference:

M1

M2

M3

t=0

MachinesJobs Processing time

J1 2J2 3J3 8J4 5J5 1J6 7

Thanks to: Isha Jaiswal (12 ) (MCS ‘ 12)

Page 9: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Factor 2 algorithm for Bin Packing Factor 2 algorithm for Minimum Makespan Scheduling Reference:

M1

M2

M3

t=0

MachinesJobs Processing time

J1 2J2 3J3 8J4 5J5 1J6 7

2

J1

Thanks to: Isha Jaiswal (12 ) (MCS ‘ 12)

Page 10: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Factor 2 algorithm for Bin Packing Factor 2 algorithm for Minimum Makespan Scheduling Reference:

M1

M2

M3

t=0

MachinesJobs Processing time

J1 2J2 3J3 8J4 5J5 1J6 7

2

J1

J2

3

Thanks to: Isha Jaiswal (12 ) (MCS ‘ 12)

Page 11: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Factor 2 algorithm for Bin Packing Factor 2 algorithm for Minimum Makespan Scheduling Reference:

M1

M2

M3

t=0

MachinesJobs Processing time

J1 2J2 3J3 8J4 5J5 1J6 7

2

J1

J2

3

J3

8

Thanks to: Isha Jaiswal (12 ) (MCS ‘ 12)

Page 12: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Factor 2 algorithm for Bin Packing Factor 2 algorithm for Minimum Makespan Scheduling Reference:

M1

M2

M3

t=0

MachinesJobs Processing time

J1 2J2 3J3 8J4 5J5 1J6 7

2

J1

J2

3

J3

8

J4

5

Thanks to: Isha Jaiswal (12 ) (MCS ‘ 12)

Page 13: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Factor 2 algorithm for Bin Packing Factor 2 algorithm for Minimum Makespan Scheduling Reference:

M1

M2

M3

t=0

MachinesJobs Processing time

J1 2J2 3J3 8J4 5J5 1J6 7

2

J1

J2

3

J3

8

J4

5

1

J5

Thanks to: Isha Jaiswal (12 ) (MCS ‘ 12)

Page 14: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Factor 2 algorithm for Bin Packing Factor 2 algorithm for Minimum Makespan Scheduling Reference:

M1

M2

M3

t=0

MachinesJobs Processing time

J1 2J2 3J3 8J4 5J5 1J6 7

2

J1

J2

3

J3

8

J4

5

1

J6

7

J5

Thanks to: Isha Jaiswal (12 ) (MCS ‘ 12)

Page 15: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Factor 2 algorithm for Bin Packing Factor 2 algorithm for Minimum Makespan Scheduling Reference:

M1

M2

M3

t=0

MachinesJobs Processing time

J1 2J2 3J3 8J4 5J5 1J6 7

2

J1

J2

3

J3

8

J4

5

1

J6

7

J5

Thanks to: Isha Jaiswal (12 )(MCS ‘ 12)

Page 16: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Factor 2 algorithm for Bin Packing Factor 2 algorithm for Minimum Makespan Scheduling Reference:

M1

M2

M3

t=0

MachinesJobs Processing time

J1 2J2 3J3 8J4 5J5 1J6 7

2

J1

J2

3

J3

8

J4

5

1

J6

7

J5

Thanks to: Isha Jaiswal (12 )(MCS ‘ 12)

Page 17: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Factor 2 algorithm for Bin Packing Factor 2 algorithm for Minimum Makespan Scheduling Reference:

M1

M2

M3

t=0

MachinesJobs Processing time

J1 2J2 3J3 8J4 5J5 1J6 7

2

J1

J2

3

J3

8

J4

5 1

J6

7

J5

Thanks to: Isha Jaiswal (12 )(MCS ‘ 12)

Page 18: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Factor 2 algorithm for Bin Packing Factor 2 algorithm for Minimum Makespan Scheduling Reference:

Analysis : 2 factor approximationAverage mount of time for which a machine runs

is (sum_{i} pi ) /m

Clearly OPT >= (sum_{i} pi ) /m

Proof: Suppose ti denotes the completion time of the ith machine in OPT. Then

(sum_{i} pi ) /m is nothing but (sum_{i} ti ) /m

Thus, OPT = max{ti } >= (sum_{i} ti ) /m = (sum_{i} pi ) /m

Also, OPT >= max{pi}

Page 19: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Factor 2 algorithm for Bin Packing Factor 2 algorithm for Minimum Makespan Scheduling Reference:

Contd..Consider the machine M whose makespan is

maximum in our solution. Let pl be the processing time of the last job jl scheduled on M. Let sl be the start time of jl on M.

Then, makespan of our solution = sl + pl

Let j1 ….jr be the jobs scheduled just before jl.

Then sl = min{Ti} <= (sum_{i = j1 ….jr Ti} )/m

= (sum_{i = j1 ….jr pi} )/m

<= (sum_{i} pi ) /m

Thus sl + pl <= (sum_{i} pi ) /m + max{pi}

<= 2 OPT.

Page 20: Instructor Neelima Gupta ngupta@cs.du.ac.in. Table of Contents Factor 2 algorithm for Bin Packing Factor 2 algorithm for Minimum Makespan Scheduling Reference:

Consolidated by: Sumedha Upadhyaya( 42), Prachi Nagpal(41) (MCS '09)