Lecture 31
Lecture 31
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
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.