0% found this document useful (0 votes)
12 views

Lecture 31

Uploaded by

f20212599
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Lecture 31

Uploaded by

f20212599
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

BITS, PILANI – K. K.

BIRLA GOA CAMPUS

Design & Analysis of Algorithms


(CS F364)

Lecture No. 31

1
Bin Packing
You are given n items, of sizes s1, s2,…..,sn . All sizes are
such that 0 < si ≤ 1. There is infinite supply of unit size bins.
Goal: To pack the items in as few bins as possible
Theorem: The approximation ratio for Next Fit is 2 & 2 is a
tight bound.
Theorem: First Fit algorithm returns a solution h such that
h ≤ 1.7h* + 2
Theorem: First Fit Decreasing algorithm is a 3/2-
approximation for Bin Packing.
Theorem: If P ≠ NP, there can not exist a ρ-approximation
algorithm for the bin packing problem for any ρ < 3/2
FFD Proof - Idea
Let k be the number of non-empty bins found by First Fit
Decreasing and let k* be the optimal number.
Consider bin number j = ⌈2/3k⌉.
Suppose it contains an item i with si > 1/2,
then each bin j′ < j did not have space for item i.
Thus j′ was assigned an item i′ with i′ < i.
Since the items are considered in non-increasing order of size we
have si’ ≥ si > 1/2.
Therefore, there are at least j items of size larger than 1/2.
And these items need to be placed in individual bins.
This implies k* ≥ j ≥ 2/3 k.
Proof
Otherwise, bin j and any bin j′ > j does not contain an item
with size larger than 1/2.
Hence the bins j, j + 1, . . . , k contain at least 2(k − j) + 1
items, none of which fits into the bins 1, . . . , j − 1.
Thus we have
s(I) > min{j − 1, 2(k − j) + 1}, where 𝒔 𝑰 = σ𝒊 ∈𝑰 𝒔𝒊
≥ ⌈2/3k⌉ − 1
Also, k* ≥ s(I)
Therefore, k* ≥ ⌈2/3k⌉ ≥ 2/3k
Load Balancing
Input. identical m machines and n jobs with processing
times t1 ,t2 ,…., tn
• Job j must run contiguously on one machine.
• A machine can process at most one job at a time.
Let S[i] be the subset of jobs assigned to machine i

The makespan of an algorithm is the maximum load on


any machine 𝐿 = max 𝐿[𝑖]
𝑖
Load Balancing Problem: Find an assignment of jobs to
machines so as to minimize the makespan.
Load Balancing
Claim:
Load Balancing problem is NP Complete even for m = 2
Proof: Exercise (Reduce Subset Sum to Load Balancing)
Approximation Algorithm: List-scheduling algorithm
• Consider n jobs in some fixed order.
• Assign job j to machine whose load is smallest so far.
Theorem:
List-scheduling algorithm is a 2-approximation.
Proof: Let OPT denote the optimal makespan
Lemma 1: The optimal makespan OPT  maxj tj
Lemma 2: The optimal makespan OPT  1/m j tj
Load Balancing
Consider load L[i] of bottleneck machine i.
Let j be last job scheduled on machine i.
Observe:
When job j assigned to machine i, i had smallest load.

Exercise:
Prove that 2 is a tight bound for the
algorithm.
Load Balancing
Observe
Our greedy algorithm is an online algorithm
• Assigns jobs to machines in the order they arrive
• Does not depend on future jobs
• Can we do better, if we assume all jobs are available
at start time?
• Slight modification of greedy gets better approximation
What is worst case for greedy?
• Spreading jobs out evenly and a big job at the end
Load Balancing
What can we do to avoid this?
Idea: Deal with larger jobs first
Longest processing time (LPT) first algorithm:
• Sort n jobs in descending order of processing time
• Then run list scheduling algorithm.
Theorem:
LPT first algorithm is a 3/2 approximation algorithm.

You might also like