Advanced Algorithms – COMS31900
Approximation algorithms part four
Asymptotic Polynomial Time Approximation Schemes
Benjamin Sach
Approximation Algorithms Recap
A polynomial time algorithm A is an α-approximation for problem P if,
it always outputs a solution s with
Opt
α s Opt (for a maximisation problem)
Opt s α · Opt (for a minimisation problem)
A poly-time approximation scheme (PTAS) is a family of algorithms:
For any constant > 0, A is a (1 + )-approximation for P
It is a (fully) FPTAS if A takes time polynomial in both n and 1/
A PTAS is allowed to have A which takes O(n1/ ) time
- which is polynomial in n (for any constant )
i.e. O((n/ )c)
Approximation Algorithms Recap
A polynomial time algorithm A is an α-approximation for problem P if,
it always outputs a solution s with
Opt
α s Opt (for a maximisation problem)
Opt s α · Opt (for a minimisation problem)
We have seen various c-approximations with constant c
A poly-time approximation scheme (PTAS) is a family of algorithms:
For any constant > 0, A is a (1 + )-approximation for P
Last lecture we saw an FPTAS for SUBSETSUM
It is a (fully) FPTAS if A takes time polynomial in both n and 1/
A PTAS is allowed to have A which takes O(n1/ ) time
- which is polynomial in n (for any constant )
i.e. O((n/ )c)
The SUBSETSUM problem
4 4
7
322
t = 12
The SUBSETSUM problem
4 4
7
322
t = 12
• Let S be a (multi) set of integers and t be a positive integer
here S = {4, 2, 4, 7, 2, 3} and t = 12
The SUBSETSUM problem
4 4
7
322
t = 12
• Let S be a (multi) set of integers and t be a positive integer
here S = {4, 2, 4, 7, 2, 3} and t = 12
Decision Problem Is there a subset, S ⊆ S with SIZE(S ) = t?
The SUBSETSUM problem
4 4
7
322
t = 12
• Let S be a (multi) set of integers and t be a positive integer
here S = {4, 2, 4, 7, 2, 3} and t = 12
Decision Problem Is there a subset, S ⊆ S with SIZE(S ) = t?
where SIZE(S ) = a∈S a
The SUBSETSUM problem
t = 12
4
4
2
7
32
• Let S be a (multi) set of integers and t be a positive integer
here S = {4, 2, 4, 7, 2, 3} and t = 12
Decision Problem Is there a subset, S ⊆ S with SIZE(S ) = t?
where SIZE(S ) = a∈S a
The SUBSETSUM problem
t = 12
7
3
2
4 42
• Let S be a (multi) set of integers and t be a positive integer
here S = {4, 2, 4, 7, 2, 3} and t = 12
Decision Problem Is there a subset, S ⊆ S with SIZE(S ) = t?
where SIZE(S ) = a∈S a
The SUBSETSUM problem
4 4
7
322
t = 12
• Let S be a (multi) set of integers and t be a positive integer
here S = {4, 2, 4, 7, 2, 3} and t = 12
Decision Problem Is there a subset, S ⊆ S with SIZE(S ) = t?
where SIZE(S ) = a∈S a
(last lecture we discussed the NP-hard optimisation version)
The decision version is NP-complete
The PARTITION problem
4 4
7
322
The PARTITION problem is a special case of SUBSETSUM
The PARTITION problem
4 4
7
322
The input S is a multi-set of integers
The PARTITION problem is a special case of SUBSETSUM
The PARTITION problem
4 4
7
322
The input S is a multi-set of integers
but t is always half the sum of item sizes
The PARTITION problem is a special case of SUBSETSUM
The PARTITION problem
4 4
7
322
t = 11
The input S is a multi-set of integers
but t is always half the sum of item sizes
The PARTITION problem is a special case of SUBSETSUM
The PARTITION problem
4 4
7
322
t = 11
The input S is a multi-set of integers
but t is always half the sum of item sizes
t = SIZE(S)/2 = a∈S
a
2
The PARTITION problem is a special case of SUBSETSUM
The PARTITION problem
4 4
7
322
t = 11
The input S is a multi-set of integers
but t is always half the sum of item sizes
Decision Problem Is there a subset, S ⊆ S with SIZE(S ) = SIZE(S)/2?
t = SIZE(S)/2 = a∈S
a
2
The PARTITION problem is a special case of SUBSETSUM
The PARTITION problem
t = 11
4
4
2
7
32
The input S is a multi-set of integers
but t is always half the sum of item sizes
Decision Problem Is there a subset, S ⊆ S with SIZE(S ) = SIZE(S)/2?
t = SIZE(S)/2 = a∈S
a
2
The PARTITION problem is a special case of SUBSETSUM
The PARTITION problem
7
22
t = 11
The input S is a multi-set of integers
but t is always half the sum of item sizes
Decision Problem Is there a subset, S ⊆ S with SIZE(S ) = SIZE(S)/2?
t = SIZE(S)/2 = a∈S
a
2
4
4
3
The PARTITION problem is a special case of SUBSETSUM
The PARTITION problem
4 4
7
322
t = 11
The input S is a multi-set of integers
but t is always half the sum of item sizes
Decision Problem Is there a subset, S ⊆ S with SIZE(S ) = SIZE(S)/2?
t = SIZE(S)/2 = a∈S
a
2
The PARTITION problem is a special case of SUBSETSUM
The PARTITION problem
4 4
7
322
t = 11
The input S is a multi-set of integers
but t is always half the sum of item sizes
Decision Problem Is there a subset, S ⊆ S with SIZE(S ) = SIZE(S)/2?
t = SIZE(S)/2 = a∈S
a
2
The PARTITION problem is a special case of SUBSETSUM
The PARTITION problem
4 4
7
322
t = 11
The input S is a multi-set of integers
but t is always half the sum of item sizes
Decision Problem Is there a subset, S ⊆ S with SIZE(S ) = SIZE(S)/2?
t = SIZE(S)/2 = a∈S
a
2
The PARTITION problem is a special case of SUBSETSUM
Alternatively... Can we pack S into two bins of size SIZE(S)/2?
The PARTITION problem
The input S is a multi-set of integers
but t is always half the sum of item sizes
Decision Problem Is there a subset, S ⊆ S with SIZE(S ) = SIZE(S)/2?
t = SIZE(S)/2 = a∈S
a
2
The PARTITION problem is a special case of SUBSETSUM
Alternatively... Can we pack S into two bins of size SIZE(S)/2?
4 4
7
322
t = 11
The PARTITION problem
The input S is a multi-set of integers
but t is always half the sum of item sizes
Decision Problem Is there a subset, S ⊆ S with SIZE(S ) = SIZE(S)/2?
t = SIZE(S)/2 = a∈S
a
2
The PARTITION problem is a special case of SUBSETSUM
Alternatively... Can we pack S into two bins of size SIZE(S)/2?
4
4
3
7
2
2
t = 11
The PARTITION problem
The input S is a multi-set of integers
but t is always half the sum of item sizes
Decision Problem Is there a subset, S ⊆ S with SIZE(S ) = SIZE(S)/2?
t = SIZE(S)/2 = a∈S
a
2
The PARTITION problem is a special case of SUBSETSUM
Alternatively... Can we pack S into two bins of size SIZE(S)/2?
4
4
3
7
2
2
t = 11
The PARTITION problem is also NP-complete
PARTITION and BINPACKING
Key Idea Solve the PARTITION problem by approximating BINPACKING
PARTITION and BINPACKING
Key Idea Solve the PARTITION problem by approximating BINPACKING
4 4
7
322
t = 11
PARTITION and BINPACKING
Key Idea Solve the PARTITION problem by approximating BINPACKING
4 4
7
322
t = 11
• Convert the PARTITION instance into a BINPACKING problem
by dividing all item and bin sizes by t = SIZE(S)/2
PARTITION and BINPACKING
Key Idea Solve the PARTITION problem by approximating BINPACKING
• Convert the PARTITION instance into a BINPACKING problem
by dividing all item and bin sizes by t = SIZE(S)/2
4
11
4
11
7
11 3
112
11
2
11
1
PARTITION and BINPACKING
Key Idea Solve the PARTITION problem by approximating BINPACKING
• Convert the PARTITION instance into a BINPACKING problem
by dividing all item and bin sizes by t = SIZE(S)/2
• Now all items are have size at most 1 and the bins have size 1
4
11
4
11
7
11 3
112
11
2
11
1
PARTITION and BINPACKING
Key Idea Solve the PARTITION problem by approximating BINPACKING
• Convert the PARTITION instance into a BINPACKING problem
by dividing all item and bin sizes by t = SIZE(S)/2
• Now all items are have size at most 1 and the bins have size 1
• The optimal number of bins Optb is 2 iff
the answer to the PARTITION instance is ‘yes’
4
11
4
11
7
11 3
112
11
2
11
1
PARTITION and BINPACKING
Key Idea Solve the PARTITION problem by approximating BINPACKING
• Convert the PARTITION instance into a BINPACKING problem
by dividing all item and bin sizes by t = SIZE(S)/2
• Now all items are have size at most 1 and the bins have size 1
• The optimal number of bins Optb is 2 iff
the answer to the PARTITION instance is ‘yes’
4
11
4
11
7
11 3
112
11
2
11
1
• What does this tell us about approximating BINPACKING?
PARTITION and BINPACKING
Key Idea Solve the PARTITION problem by approximating BINPACKING
4
11
4
11
7
11 3
112
11
2
11
1
• Assume A is an α-approximation for BINPACKING with α < 3/2
PARTITION and BINPACKING
Key Idea Solve the PARTITION problem by approximating BINPACKING
4
11
4
11
7
11 3
112
11
2
11
1
• Assume A is an α-approximation for BINPACKING with α < 3/2
A outputs a solution using s bins with Optb s α · Optb
PARTITION and BINPACKING
Key Idea Solve the PARTITION problem by approximating BINPACKING
4
11
4
11
7
11 3
112
11
2
11
1
• Assume A is an α-approximation for BINPACKING with α < 3/2
A outputs a solution using s bins with Optb s α · Optb
• If Optb > 2 then s > 2
PARTITION and BINPACKING
Key Idea Solve the PARTITION problem by approximating BINPACKING
4
11
4
11
7
11 3
112
11
2
11
1
• Assume A is an α-approximation for BINPACKING with α < 3/2
A outputs a solution using s bins with Optb s α · Optb
• If Optb > 2 then s > 2
• If Optb = 2 then 2 s α · Optb < (3/2) · Optb = 3
PARTITION and BINPACKING
Key Idea Solve the PARTITION problem by approximating BINPACKING
4
11
4
11
7
11 3
112
11
2
11
1
• Assume A is an α-approximation for BINPACKING with α < 3/2
A outputs a solution using s bins with Optb s α · Optb
• If Optb > 2 then s > 2
• If Optb = 2 then 2 s α · Optb < (3/2) · Optb = 3
PARTITION and BINPACKING
Key Idea Solve the PARTITION problem by approximating BINPACKING
4
11
4
11
7
11 3
112
11
2
11
1
• Assume A is an α-approximation for BINPACKING with α < 3/2
A outputs a solution using s bins with Optb s α · Optb
• If Optb > 2 then s > 2
so s = 2• If Optb = 2 then 2 s α · Optb < (3/2) · Optb = 3
PARTITION and BINPACKING
Key Idea Solve the PARTITION problem by approximating BINPACKING
4
11
4
11
7
11 3
112
11
2
11
1
• Assume A is an α-approximation for BINPACKING with α < 3/2
A outputs a solution using s bins with Optb s α · Optb
• If Optb > 2 then s > 2
so s = 2
• So A can solve the NP-complete PARTITION problem in polynomial time!
• If Optb = 2 then 2 s α · Optb < (3/2) · Optb = 3
PARTITION and BINPACKING
Key Idea Solve the PARTITION problem by approximating BINPACKING
4
11
4
11
7
11 3
112
11
2
11
1
• Assume A is an α-approximation for BINPACKING with α < 3/2
A outputs a solution using s bins with Optb s α · Optb
• If Optb > 2 then s > 2
so s = 2
• So A can solve the NP-complete PARTITION problem in polynomial time!
which implies that P = NP
• If Optb = 2 then 2 s α · Optb < (3/2) · Optb = 3
PARTITION and BINPACKING
Key Idea Solve the PARTITION problem by approximating BINPACKING
4
11
4
11
7
11 3
112
11
2
11
1
Lemma There is no α-approximation for BINPACKING with α < 3/2
unless P = NP
PARTITION and BINPACKING
Key Idea Solve the PARTITION problem by approximating BINPACKING
4
11
4
11
7
11 3
112
11
2
11
1
Lemma There is no α-approximation for BINPACKING with α < 3/2
unless P = NP
We saw that First Fit Decreasing (FFD) is a 3/2-approximation
PARTITION and BINPACKING
Key Idea Solve the PARTITION problem by approximating BINPACKING
4
11
4
11
7
11 3
112
11
2
11
1
Lemma There is no α-approximation for BINPACKING with α < 3/2
unless P = NP
We saw that First Fit Decreasing (FFD) is a 3/2-approximation
so this is the best we can do?
PARTITION and BINPACKING
Key Idea Solve the PARTITION problem by approximating BINPACKING
4
11
4
11
7
11 3
112
11
2
11
1
Lemma There is no α-approximation for BINPACKING with α < 3/2
unless P = NP
We saw that First Fit Decreasing (FFD) is a 3/2-approximation
so this is the best we can do?
In fact, FFD gives a solution using s bins with
Optb s
11
9
· Optb + 1
Asymptotic Polynomial time approximation schemes
An asymptotic polynomial time approximation scheme (APTAS)
for problem P is a family of algorithms:
For any constant > 0, A runs in polynomial time (poly-time)
There is a constant c > 0 such that
and outputs a solution s with Opt s (1 + ) · Opt + c
Asymptotic Polynomial time approximation schemes
An asymptotic polynomial time approximation scheme (APTAS)
for problem P is a family of algorithms:
For any constant > 0, A runs in polynomial time (poly-time)
There is a constant c > 0 such that
and outputs a solution s with Opt s (1 + ) · Opt + c
(this is the minimisation version of the definition)
Asymptotic Polynomial time approximation schemes
An asymptotic polynomial time approximation scheme (APTAS)
for problem P is a family of algorithms:
For any constant > 0, A runs in polynomial time (poly-time)
An APTAS does not have to have running time polynomial in 1/
There is a constant c > 0 such that
and outputs a solution s with Opt s (1 + ) · Opt + c
(this is the minimisation version of the definition)
Asymptotic Polynomial time approximation schemes
An asymptotic polynomial time approximation scheme (APTAS)
for problem P is a family of algorithms:
For any constant > 0, A runs in polynomial time (poly-time)
An APTAS does not have to have running time polynomial in 1/
An asymptotic fully PTAS (AFPTAS) is also polynomial in 1/
There is a constant c > 0 such that
and outputs a solution s with Opt s (1 + ) · Opt + c
(this is the minimisation version of the definition)
Asymptotic Polynomial time approximation schemes
An asymptotic polynomial time approximation scheme (APTAS)
for problem P is a family of algorithms:
For any constant > 0, A runs in polynomial time (poly-time)
An APTAS does not have to have running time polynomial in 1/
An asymptotic fully PTAS (AFPTAS) is also polynomial in 1/
There is a constant c > 0 such that
and outputs a solution s with Opt s (1 + ) · Opt + c
(this is the minimisation version of the definition)
We will see an APTAS for BINPACKING
which uses at most (1 + ) · Opt + 1 bins
A special case of BINPACKING
We will now see a special case of BINPACKING which we can solve optimally in polynomial time
4
8
7
8
3
8
1
4
8
4
8 7
8
7
8
4
8
3
8
A special case of BINPACKING
We will now see a special case of BINPACKING which we can solve optimally in polynomial time
4
8
7
8
3
8
1
4
8
4
8 7
8
7
8
4
8
3
8
We have n items but
A special case of BINPACKING
We will now see a special case of BINPACKING which we can solve optimally in polynomial time
4
8
7
8
3
8
1
4
8
4
8 7
8
7
8
4
8
3
8
We have n items but
◦ There are cs (a constant) number of different item sizes
A special case of BINPACKING
We will now see a special case of BINPACKING which we can solve optimally in polynomial time
4
8
7
8
3
8
1
4
8
4
8 7
8
7
8
4
8
3
8
We have n items but
◦ There are cs (a constant) number of different item sizes
◦ At most cb (another constant) items fit in each bin
A special case of BINPACKING
We will now see a special case of BINPACKING which we can solve optimally in polynomial time
4
8
7
8
3
8
1
4
8
4
8 7
8
7
8
4
8
3
8
We have n items but
◦ There are cs (a constant) number of different item sizes
◦ At most cb (another constant) items fit in each bin
Here cs = 3 and cb = 2
A special case of BINPACKING
We will now see a special case of BINPACKING which we can solve optimally in polynomial time
4
8
7
8
3
8
1
4
8
4
8 7
8
7
8
4
8
3
8
We have n items but
◦ There are cs (a constant) number of different item sizes
◦ At most cb (another constant) items fit in each bin
Here cs = 3 and cb = 2
How many different ways are there to fill a single bin?
A special case of BINPACKING
4
8
3
8
3
8
3
8
4
8
7
8 3
8
4
8
4
8
1 2 3 4 5 6 7
Type:
• We can describe any packing of items into a single bin by its type
cs diff. item sizes
cb items fit in each bin
A special case of BINPACKING
4
8
3
8
3
8
3
8
4
8
7
8 3
8
4
8
4
8
1 2 3 4 5 6 7
Type:
• We can describe any packing of items into a single bin by its type
• The type of a packed bin determines how many of each item is packed
cs diff. item sizes
cb items fit in each bin
A special case of BINPACKING
4
8
3
8
3
8
3
8
4
8
7
8 3
8
4
8
4
8
1 2 3 4 5 6 7
Type:
• We can describe any packing of items into a single bin by its type
• The type of a packed bin determines how many of each item is packed
we ignore rearrangement of items
cs diff. item sizes
cb items fit in each bin
A special case of BINPACKING
4
8
3
8
3
8
3
8
4
8
7
8 3
8
4
8
4
8
1 2 3 4 5 6 7
Type:
• We can describe any packing of items into a single bin by its type
• The type of a packed bin determines how many of each item is packed
we ignore rearrangement of items
3
8
4
8
cs diff. item sizes
cb items fit in each bin
A special case of BINPACKING
4
8
3
8
3
8
3
8
4
8
7
8 3
8
4
8
4
8
1 2 3 4 5 6 7
Type:
• We can describe any packing of items into a single bin by its type
• The type of a packed bin determines how many of each item is packed
we ignore rearrangement of items
cs diff. item sizes
cb items fit in each bin
A special case of BINPACKING
4
8
3
8
3
8
3
8
4
8
7
8 3
8
4
8
4
8
1 2 3 4 5 6 7
Type:
• We can describe any packing of items into a single bin by its type
• The type of a packed bin determines how many of each item is packed
we ignore rearrangement of items
• How many types can there be?
cs diff. item sizes
cb items fit in each bin
A special case of BINPACKING
4
8
3
8
3
8
3
8
4
8
7
8 3
8
4
8
4
8
1 2 3 4 5 6 7
Type:
• We can describe any packing of items into a single bin by its type
• The type of a packed bin determines how many of each item is packed
we ignore rearrangement of items
• How many types can there be?
There are between 0 and cb items of any one size
cs diff. item sizes
cb items fit in each bin
A special case of BINPACKING
4
8
3
8
3
8
3
8
4
8
7
8 3
8
4
8
4
8
1 2 3 4 5 6 7
Type:
• We can describe any packing of items into a single bin by its type
• The type of a packed bin determines how many of each item is packed
we ignore rearrangement of items
• How many types can there be?
There are between 0 and cb items of any one size
There are cs different sizes
cs diff. item sizes
cb items fit in each bin
A special case of BINPACKING
4
8
3
8
3
8
3
8
4
8
7
8 3
8
4
8
4
8
1 2 3 4 5 6 7
Type:
• We can describe any packing of items into a single bin by its type
• The type of a packed bin determines how many of each item is packed
we ignore rearrangement of items
• How many types can there be?
There are between 0 and cb items of any one size
There are cs different sizes
The number of types
cs diff. item sizes
cb items fit in each bin
A special case of BINPACKING
4
8
3
8
3
8
3
8
4
8
7
8 3
8
4
8
4
8
1 2 3 4 5 6 7
Type:
• We can describe any packing of items into a single bin by its type
• The type of a packed bin determines how many of each item is packed
we ignore rearrangement of items
• How many types can there be?
There are between 0 and cb items of any one size
There are cs different sizes
(cb + 1) × (cb + 1) × . . . × (cb + 1)
cs
The number of types
cs diff. item sizes
cb items fit in each bin
A special case of BINPACKING
4
8
3
8
3
8
3
8
4
8
7
8 3
8
4
8
4
8
1 2 3 4 5 6 7
Type:
• We can describe any packing of items into a single bin by its type
• The type of a packed bin determines how many of each item is packed
we ignore rearrangement of items
• How many types can there be?
There are between 0 and cb items of any one size
There are cs different sizes
(cb + 1) × (cb + 1) × . . . × (cb + 1)
cs
= (cb + 1)csThe number of types
cs diff. item sizes
cb items fit in each bin
A special case of BINPACKING
4
8
3
8
3
87
8 3
8
4
8
3 4 5 6
• We can completely describe any packing of S into b n bins
by the number of bins of each type used
7
8
4
3
8
3
8
5
3
8
3
8
5
cb items fit in each bin
cs diff. item sizes
A special case of BINPACKING
4
8
3
8
3
87
8 3
8
4
8
3 4 5 6
• We can completely describe any packing of S into b n bins
by the number of bins of each type used
7
8
4
3
8
3
8
5
3
8
3
8
5
1× Type 3
2× Type 4
3× Type 5
1× Type 6
0× Type 1
0× Type 2
0× Type 7
cb items fit in each bin
cs diff. item sizes
A special case of BINPACKING
4
8
3
8
3
87
8 3
8
4
8
3 4 5 6
• We can completely describe any packing of S into b n bins
we ignore rearrangement of bins
by the number of bins of each type used
7
8
4
3
8
3
8
5
3
8
3
8
5
1× Type 3
2× Type 4
3× Type 5
1× Type 6
0× Type 1
0× Type 2
0× Type 7
cb items fit in each bin
cs diff. item sizes
A special case of BINPACKING
• We can completely describe any packing of S into b n bins
we ignore rearrangement of bins
by the number of bins of each type used
4
8
3
8
3
87
8 3
8
4
8
3 4 5 6
7
8
4
3
8
3
8
5
3
8
3
8
5
1× Type 3
2× Type 4
3× Type 5
1× Type 6
0× Type 1
0× Type 2
0× Type 7
cb items fit in each bin
cs diff. item sizes
A special case of BINPACKING
4
8
3
8
3
87
8 3
8
4
8
3 4 5 6
• We can completely describe any packing of S into b n bins
we ignore rearrangement of bins
by the number of bins of each type used
7
8
4
3
8
3
8
5
3
8
3
8
5
1× Type 3
2× Type 4
3× Type 5
1× Type 6
0× Type 1
0× Type 2
0× Type 7
cb items fit in each bin
cs diff. item sizes
A special case of BINPACKING
4
8
3
8
3
87
8 3
8
4
8
3 4 5 6
• We can completely describe any packing of S into b n bins
we ignore rearrangement of bins
• How different packings can there be?
by the number of bins of each type used
7
8
4
3
8
3
8
5
3
8
3
8
5
1× Type 3
2× Type 4
3× Type 5
1× Type 6
0× Type 1
0× Type 2
0× Type 7
cb items fit in each bin
cs diff. item sizes
A special case of BINPACKING
4
8
3
8
3
87
8 3
8
4
8
3 4 5 6
• We can completely describe any packing of S into b n bins
we ignore rearrangement of bins
• How different packings can there be?
There are between 0 and n bins of any type
by the number of bins of each type used
7
8
4
3
8
3
8
5
3
8
3
8
5
1× Type 3
2× Type 4
3× Type 5
1× Type 6
0× Type 1
0× Type 2
0× Type 7
cb items fit in each bin
cs diff. item sizes
A special case of BINPACKING
4
8
3
8
3
87
8 3
8
4
8
3 4 5 6
• We can completely describe any packing of S into b n bins
we ignore rearrangement of bins
• How different packings can there be?
There are between 0 and n bins of any type
There are at most (cb + 1)cs different types
by the number of bins of each type used
7
8
4
3
8
3
8
5
3
8
3
8
5
1× Type 3
2× Type 4
3× Type 5
1× Type 6
0× Type 1
0× Type 2
0× Type 7
cb items fit in each bin
cs diff. item sizes
A special case of BINPACKING
4
8
3
8
3
87
8 3
8
4
8
3 4 5 6
• We can completely describe any packing of S into b n bins
we ignore rearrangement of bins
• How different packings can there be?
There are between 0 and n bins of any type
There are at most (cb + 1)cs different types
by the number of bins of each type used
7
8
4
3
8
3
8
5
3
8
3
8
5
number of packings
1× Type 3
2× Type 4
3× Type 5
1× Type 6
0× Type 1
0× Type 2
0× Type 7
cb items fit in each bin
cs diff. item sizes
A special case of BINPACKING
4
8
3
8
3
87
8 3
8
4
8
3 4 5 6
• We can completely describe any packing of S into b n bins
we ignore rearrangement of bins
• How different packings can there be?
There are between 0 and n bins of any type
There are at most (cb + 1)cs different types
(n + 1) × (n + 1) × . . . × (n + 1)
(cb + 1)cs
by the number of bins of each type used
7
8
4
3
8
3
8
5
3
8
3
8
5
number of packings
1× Type 3
2× Type 4
3× Type 5
1× Type 6
0× Type 1
0× Type 2
0× Type 7
cb items fit in each bin
cs diff. item sizes
A special case of BINPACKING
4
8
3
8
3
87
8 3
8
4
8
3 4 5 6
• We can completely describe any packing of S into b n bins
we ignore rearrangement of bins
• How different packings can there be?
There are between 0 and n bins of any type
There are at most (cb + 1)cs different types
(n + 1) × (n + 1) × . . . × (n + 1)
(cb + 1)cs
= (n+1)(cb+1)cs
by the number of bins of each type used
7
8
4
3
8
3
8
5
3
8
3
8
5
number of packings
1× Type 3
2× Type 4
3× Type 5
1× Type 6
0× Type 1
0× Type 2
0× Type 7
cb items fit in each bin
cs diff. item sizes
A special case of BINPACKING
4
8
3
8
3
87
8 3
8
4
8
3 4 5 6
• We can completely describe any packing of S into b n bins
by the number of bins of each type used
7
8
4
3
8
3
8
5
3
8
3
8
5
1× Type 3
2× Type 4
3× Type 5
1× Type 6
0× Type 1
0× Type 2
0× Type 7
cb items fit in each bin
cs diff. item sizes
A special case of BINPACKING
4
8
3
8
3
87
8 3
8
4
8
3 4 5 6
• We can completely describe any packing of S into b n bins
by the number of bins of each type used
7
8
4
3
8
3
8
5
3
8
3
8
5
• However, not all these different packings are valid
1× Type 3
2× Type 4
3× Type 5
1× Type 6
0× Type 1
0× Type 2
0× Type 7
cb items fit in each bin
cs diff. item sizes
A special case of BINPACKING
4
8
3
8
3
87
8 3
8
4
8
3 4 5 6
• We can completely describe any packing of S into b n bins
by the number of bins of each type used
7
8
4
3
8
3
8
5
3
8
3
8
5
• However, not all these different packings are valid
Many of them use too few or many items of a particular size
1× Type 3
2× Type 4
3× Type 5
1× Type 6
0× Type 1
0× Type 2
0× Type 7
cb items fit in each bin
cs diff. item sizes
(in particular the example packing uses too many items of size 3/8)
A special case of BINPACKING
4
8
3
8
3
87
8 3
8
4
8
3 4 5 6
• We can completely describe any packing of S into b n bins
by the number of bins of each type used
7
8
4
3
8
3
8
5
3
8
3
8
5
• However, not all these different packings are valid
Many of them use too few or many items of a particular size
• We check each of the different packings to see if it is valid
1× Type 3
2× Type 4
3× Type 5
1× Type 6
0× Type 1
0× Type 2
0× Type 7
cb items fit in each bin
cs diff. item sizes
(in particular the example packing uses too many items of size 3/8)
A special case of BINPACKING
4
8
3
8
3
87
8 3
8
4
8
3 4 5 6
• We can completely describe any packing of S into b n bins
by the number of bins of each type used
7
8
4
3
8
3
8
5
3
8
3
8
5
• However, not all these different packings are valid
Many of them use too few or many items of a particular size
• We check each of the different packings to see if it is valid
and output the valid one which uses the fewest bins
1× Type 3
2× Type 4
3× Type 5
1× Type 6
0× Type 1
0× Type 2
0× Type 7
cb items fit in each bin
cs diff. item sizes
(in particular the example packing uses too many items of size 3/8)
A special case of BINPACKING
4
8
3
8
3
87
8 3
8
4
8
3 4 5 6
• We can completely describe any packing of S into b n bins
by the number of bins of each type used
7
8
4
3
8
3
8
5
3
8
3
8
5
• However, not all these different packings are valid
Many of them use too few or many items of a particular size
• We check each of the different packings to see if it is valid
and output the valid one which uses the fewest bins
• This takes O(n · (n + 1)(cb+1)cs
) time and exactly solves BINPACKING
1× Type 3
2× Type 4
3× Type 5
1× Type 6
0× Type 1
0× Type 2
0× Type 7
(i.e. it outputs an optimal packing)
cb items fit in each bin
cs diff. item sizes
(in particular the example packing uses too many items of size 3/8)
Towards an APTAS
The APTAS for BINPACKING will use a four step process:
Step 1 Remove all the small items
Step 2 Divide the items into a constant number of groups
Only cb of the remaining large items will fit into a single bin
Sizes of items in each group are then rounded up
to match the size of the largest member
This will leave only cs different item sizes
Step 3 Use the poly-time algorithm to optimally pack the remaining special case
the constants cb and cs will depend on
Step 4 Reverse the grouping from Step 2 and then
Remember that the goal is to use b bins where Opt b (1 + ) · Opt + c (for some c)
greedily pack all the small items removed in Step 1
(and the largest group is removed)
Removing the small items
Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins,
in polynomial time we can find a packing of all items in S which either uses:
b bins or (1 + )Opt + 1 bins
Removing the small items
Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins,
in polynomial time we can find a packing of all items in S which either uses:
b bins or (1 + )Opt + 1 bins
After packing of large items (> /2)
Removing the small items
we pack the small items ( /2) on top of the large items greedily
Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins,
in polynomial time we can find a packing of all items in S which either uses:
b bins or (1 + )Opt + 1 bins
After packing of large items (> /2)
Removing the small items
we pack the small items ( /2) on top of the large items greedily
Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins,
in polynomial time we can find a packing of all items in S which either uses:
b bins or (1 + )Opt + 1 bins
After packing of large items (> /2)
Removing the small items
we pack the small items ( /2) on top of the large items greedily
Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins,
in polynomial time we can find a packing of all items in S which either uses:
b bins or (1 + )Opt + 1 bins
After packing of large items (> /2)
pack the small items anywhere you like - just but don’t use an extra bin unless you have to
Removing the small items
we pack the small items ( /2) on top of the large items greedily
Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins,
in polynomial time we can find a packing of all items in S which either uses:
b bins or (1 + )Opt + 1 bins
After packing of large items (> /2)
Removing the small items
we pack the small items ( /2) on top of the large items greedily
Either: We don’t use any extra bins
or every bin (except possibly the last) is 1 − ( /2) full
Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins,
in polynomial time we can find a packing of all items in S which either uses:
b bins or (1 + )Opt + 1 bins
After packing of large items (> /2)
Removing the small items
we pack the small items ( /2) on top of the large items greedily
Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins,
in polynomial time we can find a packing of all items in S which either uses:
After packing of large items (> /2)
b bins or (1 + )Opt + 1 bins
Either: We don’t use any extra bins
or every bin (except possibly the last) is 1 − ( /2) full
Removing the small items
we pack the small items ( /2) on top of the large items greedily
Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins,
in polynomial time we can find a packing of all items in S which either uses:
After packing of large items (> /2)
Either: We don’t use any extra bins
or every bin (except possibly the last) is 1 − ( /2) full
b bins or (1 + )Opt + 1 bins
Removing the small items
we pack the small items ( /2) on top of the large items greedily
Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins,
in polynomial time we can find a packing of all items in S which either uses:
After packing of large items (> /2)
Either: We don’t use any extra bins
or every bin (except possibly the last) is 1 − ( /2) full
b bins or (1 + )Opt + 1 bins
Removing the small items
we pack the small items ( /2) on top of the large items greedily
Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins,
in polynomial time we can find a packing of all items in S which either uses:
After packing of large items (> /2)
Either: We don’t use any extra bins
or every bin (except possibly the last) is 1 − ( /2) full
b bins or (1 + )Opt + 1 bins
small items don’t fit in here (so they are very well packed)
1 − 2
Removing the small items
we pack the small items ( /2) on top of the large items greedily
Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins,
in polynomial time we can find a packing of all items in S which either uses:
After packing of large items (> /2)
Either: We don’t use any extra bins
or every bin (except possibly the last) is 1 − ( /2) full
b bins or (1 + )Opt + 1 bins
small items don’t fit in here (so they are very well packed)
1 − 2
this is the +1
Removing the small items
Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins,
in polynomial time we can find a packing of all items in S which either uses:
b bins or (1 + )Opt + 1 bins
We can now ignore all the small items
and focus on finding a good packing of the large items
Removing the small items
Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins,
in polynomial time we can find a packing of all items in S which either uses:
b bins or (1 + )Opt + 1 bins
We can now ignore all the small items
and focus on finding a good packing of the large items
How many large items fit in a single bin?
Removing the small items
Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins,
in polynomial time we can find a packing of all items in S which either uses:
b bins or (1 + )Opt + 1 bins
We can now ignore all the small items
and focus on finding a good packing of the large items
How many large items fit in a single bin?
Each large item is larger than /2. . .
Removing the small items
Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins,
in polynomial time we can find a packing of all items in S which either uses:
b bins or (1 + )Opt + 1 bins
We can now ignore all the small items
and focus on finding a good packing of the large items
How many large items fit in a single bin?
Each large item is larger than /2. . .
so at most 2/
Removing the small items
Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins,
in polynomial time we can find a packing of all items in S which either uses:
b bins or (1 + )Opt + 1 bins
We can now ignore all the small items
and focus on finding a good packing of the large items
How many large items fit in a single bin?
Each large item is larger than /2. . .
so at most 2/ which is a constant :)
Reducing the number of item sizes
• We divide the items by size, into groups of size k
k k k
1
the smallest group might contain fewer than k items
Reducing the number of item sizes
• We divide the items by size, into groups of size k
k k k
1
the smallest group might contain fewer than k items
• We define a new set of items S where each item is rounded up
so each item in a group has the same size
Reducing the number of item sizes
• We divide the items by size, into groups of size k
k k k
1
the smallest group might contain fewer than k items
• We define a new set of items S where each item is rounded up
so each item in a group has the same size
Reducing the number of item sizes
• We divide the items by size, into groups of size k
k k k
1
the smallest group might contain fewer than k items
• We define a new set of items S where each item is rounded up
so each item in a group has the same size
and the largest group is removed
Reducing the number of item sizes
• We divide the items by size, into groups of size k
k k k
1
the smallest group might contain fewer than k items
• We define a new set of items S where each item is rounded up
so each item in a group has the same size
• Notice that S contains only n/k distinct item sizes
and the largest group is removed
Reducing the number of item sizes
• We divide the items by size, into groups of size k
k k k
1
the smallest group might contain fewer than k items
• We define a new set of items S where each item is rounded up
so each item in a group has the same size
• Notice that S contains only n/k distinct item sizes
and the largest group is removed
(k will be big enough so that n/k 4/ 2 - which is a constant)
Reducing the number of item sizes
Lemma Let S be S after linear grouping (with groups of size k).
Opt(S ) Opt(S) Opt(S ) + k .
. Further, any packing of S can be converted into a packing of S in polynomial time
using at most k extra bins
Reducing the number of item sizes
Lemma Let S be S after linear grouping (with groups of size k).
Opt(S ) Opt(S) Opt(S ) + k .
.
Here Opt(S) is the optimal number of bins required to pack S
Similarly Opt(S ) is the optimal number of bins required to pack S
Further, any packing of S can be converted into a packing of S in polynomial time
using at most k extra bins
Reducing the number of item sizes
Lemma Let S be S after linear grouping (with groups of size k).
Opt(S ) Opt(S) Opt(S ) + k .
. Further, any packing of S can be converted into a packing of S in polynomial time
using at most k extra bins
Reducing the number of item sizes
Lemma Let S be S after linear grouping (with groups of size k).
Opt(S ) Opt(S) Opt(S ) + k .
S
S
Reducing the number of item sizes
Proof
Lemma Let S be S after linear grouping (with groups of size k).
Opt(S ) Opt(S) Opt(S ) + k .
S
S
Reducing the number of item sizes
Proof
Lemma Let S be S after linear grouping (with groups of size k).
Opt(S ) Opt(S) Opt(S ) + k .
S
S
If you can pack S into b bins,
you can pack S into b bins
Reducing the number of item sizes
Proof
Lemma Let S be S after linear grouping (with groups of size k).
Opt(S ) Opt(S) Opt(S ) + k .
S
S
If you can pack S into b bins,
you can pack S into b bins
Take the packing of S
and replace each item as shown
unpack
these
Reducing the number of item sizes
Proof
Lemma Let S be S after linear grouping (with groups of size k).
Opt(S ) Opt(S) Opt(S ) + k .
S
S
If you can pack S into b bins,
you can pack S into b bins
Take the packing of S
and replace each item as shown
Each item from S is replaced
with one no larger from S
unpack
these
Reducing the number of item sizes
Proof
Lemma Let S be S after linear grouping (with groups of size k).
Opt(S ) Opt(S) Opt(S ) + k .
S
S
If you can pack S into b bins,
you can pack S into b bins
Take the packing of S
and replace each item as shown
Each item from S is replaced
with one no larger from S
So the packing is valid and hence
Opt(S ) Opt(S)
unpack
these
Reducing the number of item sizes
Proof
Lemma Let S be S after linear grouping (with groups of size k).
Opt(S ) Opt(S) Opt(S ) + k .
S
S
If you can pack S into b bins,
you can pack S into b + k bins
Reducing the number of item sizes
Proof
Lemma Let S be S after linear grouping (with groups of size k).
Opt(S ) Opt(S) Opt(S ) + k .
S
S
If you can pack S into b bins,
you can pack S into b + k bins
Take the packing of S
and replace each item as shown
Reducing the number of item sizes
Proof
Lemma Let S be S after linear grouping (with groups of size k).
Opt(S ) Opt(S) Opt(S ) + k .
S
S
If you can pack S into b bins,
you can pack S into b + k bins
Take the packing of S
and replace each item as shown
Reducing the number of item sizes
Proof
Lemma Let S be S after linear grouping (with groups of size k).
Opt(S ) Opt(S) Opt(S ) + k .
S
S
If you can pack S into b bins,
you can pack S into b + k bins
Take the packing of S
and replace each item as shown
Each item from S is replaced
with one no larger from S
Reducing the number of item sizes
Proof
Lemma Let S be S after linear grouping (with groups of size k).
Opt(S ) Opt(S) Opt(S ) + k .
S
S
If you can pack S into b bins,
you can pack S into b + k bins
Take the packing of S
and replace each item as shown
Each item from S is replaced
with one no larger from S
The k largest items are
given their own extra bins
give these k items a bin each
Reducing the number of item sizes
Proof
Lemma Let S be S after linear grouping (with groups of size k).
Opt(S ) Opt(S) Opt(S ) + k .
S
S
If you can pack S into b bins,
you can pack S into b + k bins
Reducing the number of item sizes
Proof
Lemma Let S be S after linear grouping (with groups of size k).
Opt(S ) Opt(S) Opt(S ) + k .
S
S
If you can pack S into b bins,
you can pack S into b + k bins
This gives a valid packing of S
Reducing the number of item sizes
Proof
Lemma Let S be S after linear grouping (with groups of size k).
Opt(S ) Opt(S) Opt(S ) + k .
S
S
If you can pack S into b bins,
you can pack S into b + k bins
Opt(S) Opt(S ) + k
This gives a valid packing of S
Hence,
Reducing the number of item sizes
Proof
Lemma Let S be S after linear grouping (with groups of size k).
Opt(S ) Opt(S) Opt(S ) + k .
S
S
If you can pack S into b bins,
you can pack S into b + k bins
Opt(S) Opt(S ) + k
This gives a valid packing of S
Hence,
Note that both transformations
take polynomial time
Reducing the number of item sizes
Lemma Let S be S after linear grouping (with groups of size k).
Opt(S ) Opt(S) Opt(S ) + k .
. Further, any packing of S can be converted into a packing of S in polynomial time
using at most k extra bins
Reducing the number of item sizes
Lemma Let S be S after linear grouping (with groups of size k).
Opt(S ) Opt(S) Opt(S ) + k .
.
We set k = n · ( 2/2) and let S be the set of large items which implies that. . .
n = |S|
Further, any packing of S can be converted into a packing of S in polynomial time
using at most k extra bins
Reducing the number of item sizes
Lemma Let S be S after linear grouping (with groups of size k).
Opt(S ) Opt(S) Opt(S ) + k .
.
We set k = n · ( 2/2) and let S be the set of large items which implies that. . .
k · Opt(S)
n = |S|
Further, any packing of S can be converted into a packing of S in polynomial time
using at most k extra bins
Reducing the number of item sizes
Lemma Let S be S after linear grouping (with groups of size k).
Opt(S ) Opt(S) Opt(S ) + k .
.
We set k = n · ( 2/2) and let S be the set of large items which implies that. . .
k · Opt(S) (because each of the n items in S has size at least /2)
n = |S|
Further, any packing of S can be converted into a packing of S in polynomial time
using at most k extra bins
Reducing the number of item sizes
Lemma Let S be S after linear grouping (with groups of size k).
Opt(S ) Opt(S) Opt(S ) + k .
.
We set k = n · ( 2/2) and let S be the set of large items which implies that. . .
k · Opt(S) (because each of the n items in S has size at least /2)
If we can find the optimal packing of S , which uses Opt(S ) bins
we can convert it into a packing of S which uses
Opt(S ) + k (1 + )Opt(S) bins
n = |S|
Further, any packing of S can be converted into a packing of S in polynomial time
using at most k extra bins
Reducing the number of item sizes
Lemma Let S be S after linear grouping (with groups of size k).
Opt(S ) Opt(S) Opt(S ) + k .
.
We set k = n · ( 2/2) and let S be the set of large items which implies that. . .
k · Opt(S) (because each of the n items in S has size at least /2)
If we can find the optimal packing of S , which uses Opt(S ) bins
we can convert it into a packing of S which uses
Opt(S ) + k (1 + )Opt(S) bins
S contains 4/ 2 distinct item sizes
and only 2/ items fit in each bin. . .
n = |S|
Further, any packing of S can be converted into a packing of S in polynomial time
using at most k extra bins
Reducing the number of item sizes
Lemma Let S be S after linear grouping (with groups of size k).
Opt(S ) Opt(S) Opt(S ) + k .
.
We set k = n · ( 2/2) and let S be the set of large items which implies that. . .
k · Opt(S) (because each of the n items in S has size at least /2)
I.e. we can optimally pack S in polynomial time. . .
If we can find the optimal packing of S , which uses Opt(S ) bins
we can convert it into a packing of S which uses
Opt(S ) + k (1 + )Opt(S) bins
S contains 4/ 2 distinct item sizes
and only 2/ items fit in each bin. . .
n = |S|
Further, any packing of S can be converted into a packing of S in polynomial time
using at most k extra bins
The overall APTAS
Step 1 Remove all the small items
Step 2 Divide the items into k = n · ( 2/2) different groups
Only cb = 2/ of the remaining large items will fit into a single bin
Sizes of items in each group are then rounded up
to match the size of the largest member
This will leave only cs = 4/ 2 different item sizes
Step 3 Use the poly-time algorithm to optimally pack the remaining special case
Step 4 Reverse the grouping from Step 2 and then
greedily pack all the small items removed in Step 1
(and the largest group is removed)
This takes O n · (n + 1)(4/ 2
+1)
2/
time
Theorem For any 0 < < 1, the algorithm presented runs in polynomial time and returns a packing
of any set of items using at most (1 + )Opt + 1 bins
3 4 5 64 5 5
Conclusions
• There is no α-approximation for BINPACKING with α < 3/2
• We saw an APTAS for BINPACKING. (which uses at most (1 + ) · Opt + 1 bins)
• There is a poly-time algorithm which outputs a solution using at most,
unless P = NP
• This in turn implies that there is no PTAS for BINPACKING
unless P = NP
• The First Fit Decreasing algorithm uses at most,
11
9
· Opt + 1 bins
there is also an AFPTAS for bin packing
Opt+O(log2 Opt) = 1 +
O(log2 Opt)
Opt
·Opt bins
Conclusions
• There is no α-approximation for BINPACKING with α < 3/2
• We saw an APTAS for BINPACKING. (which uses at most (1 + ) · Opt + 1 bins)
• There is a poly-time algorithm which outputs a solution using at most,
unless P = NP
• This in turn implies that there is no PTAS for BINPACKING
unless P = NP
• The First Fit Decreasing algorithm uses at most,
11
9
· Opt + 1 bins
there is also an AFPTAS for bin packing
Opt+O(log2 Opt) = 1 +
O(log2 Opt)
Opt
·Opt bins
Whether there is a poly-time algorithm which uses at most Opt + 1 bins is an open problem

Approximation Algorithms Part Four: APTAS

  • 1.
    Advanced Algorithms –COMS31900 Approximation algorithms part four Asymptotic Polynomial Time Approximation Schemes Benjamin Sach
  • 2.
    Approximation Algorithms Recap Apolynomial time algorithm A is an α-approximation for problem P if, it always outputs a solution s with Opt α s Opt (for a maximisation problem) Opt s α · Opt (for a minimisation problem) A poly-time approximation scheme (PTAS) is a family of algorithms: For any constant > 0, A is a (1 + )-approximation for P It is a (fully) FPTAS if A takes time polynomial in both n and 1/ A PTAS is allowed to have A which takes O(n1/ ) time - which is polynomial in n (for any constant ) i.e. O((n/ )c)
  • 3.
    Approximation Algorithms Recap Apolynomial time algorithm A is an α-approximation for problem P if, it always outputs a solution s with Opt α s Opt (for a maximisation problem) Opt s α · Opt (for a minimisation problem) We have seen various c-approximations with constant c A poly-time approximation scheme (PTAS) is a family of algorithms: For any constant > 0, A is a (1 + )-approximation for P Last lecture we saw an FPTAS for SUBSETSUM It is a (fully) FPTAS if A takes time polynomial in both n and 1/ A PTAS is allowed to have A which takes O(n1/ ) time - which is polynomial in n (for any constant ) i.e. O((n/ )c)
  • 4.
  • 5.
    The SUBSETSUM problem 44 7 322 t = 12 • Let S be a (multi) set of integers and t be a positive integer here S = {4, 2, 4, 7, 2, 3} and t = 12
  • 6.
    The SUBSETSUM problem 44 7 322 t = 12 • Let S be a (multi) set of integers and t be a positive integer here S = {4, 2, 4, 7, 2, 3} and t = 12 Decision Problem Is there a subset, S ⊆ S with SIZE(S ) = t?
  • 7.
    The SUBSETSUM problem 44 7 322 t = 12 • Let S be a (multi) set of integers and t be a positive integer here S = {4, 2, 4, 7, 2, 3} and t = 12 Decision Problem Is there a subset, S ⊆ S with SIZE(S ) = t? where SIZE(S ) = a∈S a
  • 8.
    The SUBSETSUM problem t= 12 4 4 2 7 32 • Let S be a (multi) set of integers and t be a positive integer here S = {4, 2, 4, 7, 2, 3} and t = 12 Decision Problem Is there a subset, S ⊆ S with SIZE(S ) = t? where SIZE(S ) = a∈S a
  • 9.
    The SUBSETSUM problem t= 12 7 3 2 4 42 • Let S be a (multi) set of integers and t be a positive integer here S = {4, 2, 4, 7, 2, 3} and t = 12 Decision Problem Is there a subset, S ⊆ S with SIZE(S ) = t? where SIZE(S ) = a∈S a
  • 10.
    The SUBSETSUM problem 44 7 322 t = 12 • Let S be a (multi) set of integers and t be a positive integer here S = {4, 2, 4, 7, 2, 3} and t = 12 Decision Problem Is there a subset, S ⊆ S with SIZE(S ) = t? where SIZE(S ) = a∈S a (last lecture we discussed the NP-hard optimisation version) The decision version is NP-complete
  • 11.
    The PARTITION problem 44 7 322 The PARTITION problem is a special case of SUBSETSUM
  • 12.
    The PARTITION problem 44 7 322 The input S is a multi-set of integers The PARTITION problem is a special case of SUBSETSUM
  • 13.
    The PARTITION problem 44 7 322 The input S is a multi-set of integers but t is always half the sum of item sizes The PARTITION problem is a special case of SUBSETSUM
  • 14.
    The PARTITION problem 44 7 322 t = 11 The input S is a multi-set of integers but t is always half the sum of item sizes The PARTITION problem is a special case of SUBSETSUM
  • 15.
    The PARTITION problem 44 7 322 t = 11 The input S is a multi-set of integers but t is always half the sum of item sizes t = SIZE(S)/2 = a∈S a 2 The PARTITION problem is a special case of SUBSETSUM
  • 16.
    The PARTITION problem 44 7 322 t = 11 The input S is a multi-set of integers but t is always half the sum of item sizes Decision Problem Is there a subset, S ⊆ S with SIZE(S ) = SIZE(S)/2? t = SIZE(S)/2 = a∈S a 2 The PARTITION problem is a special case of SUBSETSUM
  • 17.
    The PARTITION problem t= 11 4 4 2 7 32 The input S is a multi-set of integers but t is always half the sum of item sizes Decision Problem Is there a subset, S ⊆ S with SIZE(S ) = SIZE(S)/2? t = SIZE(S)/2 = a∈S a 2 The PARTITION problem is a special case of SUBSETSUM
  • 18.
    The PARTITION problem 7 22 t= 11 The input S is a multi-set of integers but t is always half the sum of item sizes Decision Problem Is there a subset, S ⊆ S with SIZE(S ) = SIZE(S)/2? t = SIZE(S)/2 = a∈S a 2 4 4 3 The PARTITION problem is a special case of SUBSETSUM
  • 19.
    The PARTITION problem 44 7 322 t = 11 The input S is a multi-set of integers but t is always half the sum of item sizes Decision Problem Is there a subset, S ⊆ S with SIZE(S ) = SIZE(S)/2? t = SIZE(S)/2 = a∈S a 2 The PARTITION problem is a special case of SUBSETSUM
  • 20.
    The PARTITION problem 44 7 322 t = 11 The input S is a multi-set of integers but t is always half the sum of item sizes Decision Problem Is there a subset, S ⊆ S with SIZE(S ) = SIZE(S)/2? t = SIZE(S)/2 = a∈S a 2 The PARTITION problem is a special case of SUBSETSUM
  • 21.
    The PARTITION problem 44 7 322 t = 11 The input S is a multi-set of integers but t is always half the sum of item sizes Decision Problem Is there a subset, S ⊆ S with SIZE(S ) = SIZE(S)/2? t = SIZE(S)/2 = a∈S a 2 The PARTITION problem is a special case of SUBSETSUM Alternatively... Can we pack S into two bins of size SIZE(S)/2?
  • 22.
    The PARTITION problem Theinput S is a multi-set of integers but t is always half the sum of item sizes Decision Problem Is there a subset, S ⊆ S with SIZE(S ) = SIZE(S)/2? t = SIZE(S)/2 = a∈S a 2 The PARTITION problem is a special case of SUBSETSUM Alternatively... Can we pack S into two bins of size SIZE(S)/2? 4 4 7 322 t = 11
  • 23.
    The PARTITION problem Theinput S is a multi-set of integers but t is always half the sum of item sizes Decision Problem Is there a subset, S ⊆ S with SIZE(S ) = SIZE(S)/2? t = SIZE(S)/2 = a∈S a 2 The PARTITION problem is a special case of SUBSETSUM Alternatively... Can we pack S into two bins of size SIZE(S)/2? 4 4 3 7 2 2 t = 11
  • 24.
    The PARTITION problem Theinput S is a multi-set of integers but t is always half the sum of item sizes Decision Problem Is there a subset, S ⊆ S with SIZE(S ) = SIZE(S)/2? t = SIZE(S)/2 = a∈S a 2 The PARTITION problem is a special case of SUBSETSUM Alternatively... Can we pack S into two bins of size SIZE(S)/2? 4 4 3 7 2 2 t = 11 The PARTITION problem is also NP-complete
  • 25.
    PARTITION and BINPACKING KeyIdea Solve the PARTITION problem by approximating BINPACKING
  • 26.
    PARTITION and BINPACKING KeyIdea Solve the PARTITION problem by approximating BINPACKING 4 4 7 322 t = 11
  • 27.
    PARTITION and BINPACKING KeyIdea Solve the PARTITION problem by approximating BINPACKING 4 4 7 322 t = 11 • Convert the PARTITION instance into a BINPACKING problem by dividing all item and bin sizes by t = SIZE(S)/2
  • 28.
    PARTITION and BINPACKING KeyIdea Solve the PARTITION problem by approximating BINPACKING • Convert the PARTITION instance into a BINPACKING problem by dividing all item and bin sizes by t = SIZE(S)/2 4 11 4 11 7 11 3 112 11 2 11 1
  • 29.
    PARTITION and BINPACKING KeyIdea Solve the PARTITION problem by approximating BINPACKING • Convert the PARTITION instance into a BINPACKING problem by dividing all item and bin sizes by t = SIZE(S)/2 • Now all items are have size at most 1 and the bins have size 1 4 11 4 11 7 11 3 112 11 2 11 1
  • 30.
    PARTITION and BINPACKING KeyIdea Solve the PARTITION problem by approximating BINPACKING • Convert the PARTITION instance into a BINPACKING problem by dividing all item and bin sizes by t = SIZE(S)/2 • Now all items are have size at most 1 and the bins have size 1 • The optimal number of bins Optb is 2 iff the answer to the PARTITION instance is ‘yes’ 4 11 4 11 7 11 3 112 11 2 11 1
  • 31.
    PARTITION and BINPACKING KeyIdea Solve the PARTITION problem by approximating BINPACKING • Convert the PARTITION instance into a BINPACKING problem by dividing all item and bin sizes by t = SIZE(S)/2 • Now all items are have size at most 1 and the bins have size 1 • The optimal number of bins Optb is 2 iff the answer to the PARTITION instance is ‘yes’ 4 11 4 11 7 11 3 112 11 2 11 1 • What does this tell us about approximating BINPACKING?
  • 32.
    PARTITION and BINPACKING KeyIdea Solve the PARTITION problem by approximating BINPACKING 4 11 4 11 7 11 3 112 11 2 11 1 • Assume A is an α-approximation for BINPACKING with α < 3/2
  • 33.
    PARTITION and BINPACKING KeyIdea Solve the PARTITION problem by approximating BINPACKING 4 11 4 11 7 11 3 112 11 2 11 1 • Assume A is an α-approximation for BINPACKING with α < 3/2 A outputs a solution using s bins with Optb s α · Optb
  • 34.
    PARTITION and BINPACKING KeyIdea Solve the PARTITION problem by approximating BINPACKING 4 11 4 11 7 11 3 112 11 2 11 1 • Assume A is an α-approximation for BINPACKING with α < 3/2 A outputs a solution using s bins with Optb s α · Optb • If Optb > 2 then s > 2
  • 35.
    PARTITION and BINPACKING KeyIdea Solve the PARTITION problem by approximating BINPACKING 4 11 4 11 7 11 3 112 11 2 11 1 • Assume A is an α-approximation for BINPACKING with α < 3/2 A outputs a solution using s bins with Optb s α · Optb • If Optb > 2 then s > 2 • If Optb = 2 then 2 s α · Optb < (3/2) · Optb = 3
  • 36.
    PARTITION and BINPACKING KeyIdea Solve the PARTITION problem by approximating BINPACKING 4 11 4 11 7 11 3 112 11 2 11 1 • Assume A is an α-approximation for BINPACKING with α < 3/2 A outputs a solution using s bins with Optb s α · Optb • If Optb > 2 then s > 2 • If Optb = 2 then 2 s α · Optb < (3/2) · Optb = 3
  • 37.
    PARTITION and BINPACKING KeyIdea Solve the PARTITION problem by approximating BINPACKING 4 11 4 11 7 11 3 112 11 2 11 1 • Assume A is an α-approximation for BINPACKING with α < 3/2 A outputs a solution using s bins with Optb s α · Optb • If Optb > 2 then s > 2 so s = 2• If Optb = 2 then 2 s α · Optb < (3/2) · Optb = 3
  • 38.
    PARTITION and BINPACKING KeyIdea Solve the PARTITION problem by approximating BINPACKING 4 11 4 11 7 11 3 112 11 2 11 1 • Assume A is an α-approximation for BINPACKING with α < 3/2 A outputs a solution using s bins with Optb s α · Optb • If Optb > 2 then s > 2 so s = 2 • So A can solve the NP-complete PARTITION problem in polynomial time! • If Optb = 2 then 2 s α · Optb < (3/2) · Optb = 3
  • 39.
    PARTITION and BINPACKING KeyIdea Solve the PARTITION problem by approximating BINPACKING 4 11 4 11 7 11 3 112 11 2 11 1 • Assume A is an α-approximation for BINPACKING with α < 3/2 A outputs a solution using s bins with Optb s α · Optb • If Optb > 2 then s > 2 so s = 2 • So A can solve the NP-complete PARTITION problem in polynomial time! which implies that P = NP • If Optb = 2 then 2 s α · Optb < (3/2) · Optb = 3
  • 40.
    PARTITION and BINPACKING KeyIdea Solve the PARTITION problem by approximating BINPACKING 4 11 4 11 7 11 3 112 11 2 11 1 Lemma There is no α-approximation for BINPACKING with α < 3/2 unless P = NP
  • 41.
    PARTITION and BINPACKING KeyIdea Solve the PARTITION problem by approximating BINPACKING 4 11 4 11 7 11 3 112 11 2 11 1 Lemma There is no α-approximation for BINPACKING with α < 3/2 unless P = NP We saw that First Fit Decreasing (FFD) is a 3/2-approximation
  • 42.
    PARTITION and BINPACKING KeyIdea Solve the PARTITION problem by approximating BINPACKING 4 11 4 11 7 11 3 112 11 2 11 1 Lemma There is no α-approximation for BINPACKING with α < 3/2 unless P = NP We saw that First Fit Decreasing (FFD) is a 3/2-approximation so this is the best we can do?
  • 43.
    PARTITION and BINPACKING KeyIdea Solve the PARTITION problem by approximating BINPACKING 4 11 4 11 7 11 3 112 11 2 11 1 Lemma There is no α-approximation for BINPACKING with α < 3/2 unless P = NP We saw that First Fit Decreasing (FFD) is a 3/2-approximation so this is the best we can do? In fact, FFD gives a solution using s bins with Optb s 11 9 · Optb + 1
  • 44.
    Asymptotic Polynomial timeapproximation schemes An asymptotic polynomial time approximation scheme (APTAS) for problem P is a family of algorithms: For any constant > 0, A runs in polynomial time (poly-time) There is a constant c > 0 such that and outputs a solution s with Opt s (1 + ) · Opt + c
  • 45.
    Asymptotic Polynomial timeapproximation schemes An asymptotic polynomial time approximation scheme (APTAS) for problem P is a family of algorithms: For any constant > 0, A runs in polynomial time (poly-time) There is a constant c > 0 such that and outputs a solution s with Opt s (1 + ) · Opt + c (this is the minimisation version of the definition)
  • 46.
    Asymptotic Polynomial timeapproximation schemes An asymptotic polynomial time approximation scheme (APTAS) for problem P is a family of algorithms: For any constant > 0, A runs in polynomial time (poly-time) An APTAS does not have to have running time polynomial in 1/ There is a constant c > 0 such that and outputs a solution s with Opt s (1 + ) · Opt + c (this is the minimisation version of the definition)
  • 47.
    Asymptotic Polynomial timeapproximation schemes An asymptotic polynomial time approximation scheme (APTAS) for problem P is a family of algorithms: For any constant > 0, A runs in polynomial time (poly-time) An APTAS does not have to have running time polynomial in 1/ An asymptotic fully PTAS (AFPTAS) is also polynomial in 1/ There is a constant c > 0 such that and outputs a solution s with Opt s (1 + ) · Opt + c (this is the minimisation version of the definition)
  • 48.
    Asymptotic Polynomial timeapproximation schemes An asymptotic polynomial time approximation scheme (APTAS) for problem P is a family of algorithms: For any constant > 0, A runs in polynomial time (poly-time) An APTAS does not have to have running time polynomial in 1/ An asymptotic fully PTAS (AFPTAS) is also polynomial in 1/ There is a constant c > 0 such that and outputs a solution s with Opt s (1 + ) · Opt + c (this is the minimisation version of the definition) We will see an APTAS for BINPACKING which uses at most (1 + ) · Opt + 1 bins
  • 49.
    A special caseof BINPACKING We will now see a special case of BINPACKING which we can solve optimally in polynomial time 4 8 7 8 3 8 1 4 8 4 8 7 8 7 8 4 8 3 8
  • 50.
    A special caseof BINPACKING We will now see a special case of BINPACKING which we can solve optimally in polynomial time 4 8 7 8 3 8 1 4 8 4 8 7 8 7 8 4 8 3 8 We have n items but
  • 51.
    A special caseof BINPACKING We will now see a special case of BINPACKING which we can solve optimally in polynomial time 4 8 7 8 3 8 1 4 8 4 8 7 8 7 8 4 8 3 8 We have n items but ◦ There are cs (a constant) number of different item sizes
  • 52.
    A special caseof BINPACKING We will now see a special case of BINPACKING which we can solve optimally in polynomial time 4 8 7 8 3 8 1 4 8 4 8 7 8 7 8 4 8 3 8 We have n items but ◦ There are cs (a constant) number of different item sizes ◦ At most cb (another constant) items fit in each bin
  • 53.
    A special caseof BINPACKING We will now see a special case of BINPACKING which we can solve optimally in polynomial time 4 8 7 8 3 8 1 4 8 4 8 7 8 7 8 4 8 3 8 We have n items but ◦ There are cs (a constant) number of different item sizes ◦ At most cb (another constant) items fit in each bin Here cs = 3 and cb = 2
  • 54.
    A special caseof BINPACKING We will now see a special case of BINPACKING which we can solve optimally in polynomial time 4 8 7 8 3 8 1 4 8 4 8 7 8 7 8 4 8 3 8 We have n items but ◦ There are cs (a constant) number of different item sizes ◦ At most cb (another constant) items fit in each bin Here cs = 3 and cb = 2 How many different ways are there to fill a single bin?
  • 55.
    A special caseof BINPACKING 4 8 3 8 3 8 3 8 4 8 7 8 3 8 4 8 4 8 1 2 3 4 5 6 7 Type: • We can describe any packing of items into a single bin by its type cs diff. item sizes cb items fit in each bin
  • 56.
    A special caseof BINPACKING 4 8 3 8 3 8 3 8 4 8 7 8 3 8 4 8 4 8 1 2 3 4 5 6 7 Type: • We can describe any packing of items into a single bin by its type • The type of a packed bin determines how many of each item is packed cs diff. item sizes cb items fit in each bin
  • 57.
    A special caseof BINPACKING 4 8 3 8 3 8 3 8 4 8 7 8 3 8 4 8 4 8 1 2 3 4 5 6 7 Type: • We can describe any packing of items into a single bin by its type • The type of a packed bin determines how many of each item is packed we ignore rearrangement of items cs diff. item sizes cb items fit in each bin
  • 58.
    A special caseof BINPACKING 4 8 3 8 3 8 3 8 4 8 7 8 3 8 4 8 4 8 1 2 3 4 5 6 7 Type: • We can describe any packing of items into a single bin by its type • The type of a packed bin determines how many of each item is packed we ignore rearrangement of items 3 8 4 8 cs diff. item sizes cb items fit in each bin
  • 59.
    A special caseof BINPACKING 4 8 3 8 3 8 3 8 4 8 7 8 3 8 4 8 4 8 1 2 3 4 5 6 7 Type: • We can describe any packing of items into a single bin by its type • The type of a packed bin determines how many of each item is packed we ignore rearrangement of items cs diff. item sizes cb items fit in each bin
  • 60.
    A special caseof BINPACKING 4 8 3 8 3 8 3 8 4 8 7 8 3 8 4 8 4 8 1 2 3 4 5 6 7 Type: • We can describe any packing of items into a single bin by its type • The type of a packed bin determines how many of each item is packed we ignore rearrangement of items • How many types can there be? cs diff. item sizes cb items fit in each bin
  • 61.
    A special caseof BINPACKING 4 8 3 8 3 8 3 8 4 8 7 8 3 8 4 8 4 8 1 2 3 4 5 6 7 Type: • We can describe any packing of items into a single bin by its type • The type of a packed bin determines how many of each item is packed we ignore rearrangement of items • How many types can there be? There are between 0 and cb items of any one size cs diff. item sizes cb items fit in each bin
  • 62.
    A special caseof BINPACKING 4 8 3 8 3 8 3 8 4 8 7 8 3 8 4 8 4 8 1 2 3 4 5 6 7 Type: • We can describe any packing of items into a single bin by its type • The type of a packed bin determines how many of each item is packed we ignore rearrangement of items • How many types can there be? There are between 0 and cb items of any one size There are cs different sizes cs diff. item sizes cb items fit in each bin
  • 63.
    A special caseof BINPACKING 4 8 3 8 3 8 3 8 4 8 7 8 3 8 4 8 4 8 1 2 3 4 5 6 7 Type: • We can describe any packing of items into a single bin by its type • The type of a packed bin determines how many of each item is packed we ignore rearrangement of items • How many types can there be? There are between 0 and cb items of any one size There are cs different sizes The number of types cs diff. item sizes cb items fit in each bin
  • 64.
    A special caseof BINPACKING 4 8 3 8 3 8 3 8 4 8 7 8 3 8 4 8 4 8 1 2 3 4 5 6 7 Type: • We can describe any packing of items into a single bin by its type • The type of a packed bin determines how many of each item is packed we ignore rearrangement of items • How many types can there be? There are between 0 and cb items of any one size There are cs different sizes (cb + 1) × (cb + 1) × . . . × (cb + 1) cs The number of types cs diff. item sizes cb items fit in each bin
  • 65.
    A special caseof BINPACKING 4 8 3 8 3 8 3 8 4 8 7 8 3 8 4 8 4 8 1 2 3 4 5 6 7 Type: • We can describe any packing of items into a single bin by its type • The type of a packed bin determines how many of each item is packed we ignore rearrangement of items • How many types can there be? There are between 0 and cb items of any one size There are cs different sizes (cb + 1) × (cb + 1) × . . . × (cb + 1) cs = (cb + 1)csThe number of types cs diff. item sizes cb items fit in each bin
  • 66.
    A special caseof BINPACKING 4 8 3 8 3 87 8 3 8 4 8 3 4 5 6 • We can completely describe any packing of S into b n bins by the number of bins of each type used 7 8 4 3 8 3 8 5 3 8 3 8 5 cb items fit in each bin cs diff. item sizes
  • 67.
    A special caseof BINPACKING 4 8 3 8 3 87 8 3 8 4 8 3 4 5 6 • We can completely describe any packing of S into b n bins by the number of bins of each type used 7 8 4 3 8 3 8 5 3 8 3 8 5 1× Type 3 2× Type 4 3× Type 5 1× Type 6 0× Type 1 0× Type 2 0× Type 7 cb items fit in each bin cs diff. item sizes
  • 68.
    A special caseof BINPACKING 4 8 3 8 3 87 8 3 8 4 8 3 4 5 6 • We can completely describe any packing of S into b n bins we ignore rearrangement of bins by the number of bins of each type used 7 8 4 3 8 3 8 5 3 8 3 8 5 1× Type 3 2× Type 4 3× Type 5 1× Type 6 0× Type 1 0× Type 2 0× Type 7 cb items fit in each bin cs diff. item sizes
  • 69.
    A special caseof BINPACKING • We can completely describe any packing of S into b n bins we ignore rearrangement of bins by the number of bins of each type used 4 8 3 8 3 87 8 3 8 4 8 3 4 5 6 7 8 4 3 8 3 8 5 3 8 3 8 5 1× Type 3 2× Type 4 3× Type 5 1× Type 6 0× Type 1 0× Type 2 0× Type 7 cb items fit in each bin cs diff. item sizes
  • 70.
    A special caseof BINPACKING 4 8 3 8 3 87 8 3 8 4 8 3 4 5 6 • We can completely describe any packing of S into b n bins we ignore rearrangement of bins by the number of bins of each type used 7 8 4 3 8 3 8 5 3 8 3 8 5 1× Type 3 2× Type 4 3× Type 5 1× Type 6 0× Type 1 0× Type 2 0× Type 7 cb items fit in each bin cs diff. item sizes
  • 71.
    A special caseof BINPACKING 4 8 3 8 3 87 8 3 8 4 8 3 4 5 6 • We can completely describe any packing of S into b n bins we ignore rearrangement of bins • How different packings can there be? by the number of bins of each type used 7 8 4 3 8 3 8 5 3 8 3 8 5 1× Type 3 2× Type 4 3× Type 5 1× Type 6 0× Type 1 0× Type 2 0× Type 7 cb items fit in each bin cs diff. item sizes
  • 72.
    A special caseof BINPACKING 4 8 3 8 3 87 8 3 8 4 8 3 4 5 6 • We can completely describe any packing of S into b n bins we ignore rearrangement of bins • How different packings can there be? There are between 0 and n bins of any type by the number of bins of each type used 7 8 4 3 8 3 8 5 3 8 3 8 5 1× Type 3 2× Type 4 3× Type 5 1× Type 6 0× Type 1 0× Type 2 0× Type 7 cb items fit in each bin cs diff. item sizes
  • 73.
    A special caseof BINPACKING 4 8 3 8 3 87 8 3 8 4 8 3 4 5 6 • We can completely describe any packing of S into b n bins we ignore rearrangement of bins • How different packings can there be? There are between 0 and n bins of any type There are at most (cb + 1)cs different types by the number of bins of each type used 7 8 4 3 8 3 8 5 3 8 3 8 5 1× Type 3 2× Type 4 3× Type 5 1× Type 6 0× Type 1 0× Type 2 0× Type 7 cb items fit in each bin cs diff. item sizes
  • 74.
    A special caseof BINPACKING 4 8 3 8 3 87 8 3 8 4 8 3 4 5 6 • We can completely describe any packing of S into b n bins we ignore rearrangement of bins • How different packings can there be? There are between 0 and n bins of any type There are at most (cb + 1)cs different types by the number of bins of each type used 7 8 4 3 8 3 8 5 3 8 3 8 5 number of packings 1× Type 3 2× Type 4 3× Type 5 1× Type 6 0× Type 1 0× Type 2 0× Type 7 cb items fit in each bin cs diff. item sizes
  • 75.
    A special caseof BINPACKING 4 8 3 8 3 87 8 3 8 4 8 3 4 5 6 • We can completely describe any packing of S into b n bins we ignore rearrangement of bins • How different packings can there be? There are between 0 and n bins of any type There are at most (cb + 1)cs different types (n + 1) × (n + 1) × . . . × (n + 1) (cb + 1)cs by the number of bins of each type used 7 8 4 3 8 3 8 5 3 8 3 8 5 number of packings 1× Type 3 2× Type 4 3× Type 5 1× Type 6 0× Type 1 0× Type 2 0× Type 7 cb items fit in each bin cs diff. item sizes
  • 76.
    A special caseof BINPACKING 4 8 3 8 3 87 8 3 8 4 8 3 4 5 6 • We can completely describe any packing of S into b n bins we ignore rearrangement of bins • How different packings can there be? There are between 0 and n bins of any type There are at most (cb + 1)cs different types (n + 1) × (n + 1) × . . . × (n + 1) (cb + 1)cs = (n+1)(cb+1)cs by the number of bins of each type used 7 8 4 3 8 3 8 5 3 8 3 8 5 number of packings 1× Type 3 2× Type 4 3× Type 5 1× Type 6 0× Type 1 0× Type 2 0× Type 7 cb items fit in each bin cs diff. item sizes
  • 77.
    A special caseof BINPACKING 4 8 3 8 3 87 8 3 8 4 8 3 4 5 6 • We can completely describe any packing of S into b n bins by the number of bins of each type used 7 8 4 3 8 3 8 5 3 8 3 8 5 1× Type 3 2× Type 4 3× Type 5 1× Type 6 0× Type 1 0× Type 2 0× Type 7 cb items fit in each bin cs diff. item sizes
  • 78.
    A special caseof BINPACKING 4 8 3 8 3 87 8 3 8 4 8 3 4 5 6 • We can completely describe any packing of S into b n bins by the number of bins of each type used 7 8 4 3 8 3 8 5 3 8 3 8 5 • However, not all these different packings are valid 1× Type 3 2× Type 4 3× Type 5 1× Type 6 0× Type 1 0× Type 2 0× Type 7 cb items fit in each bin cs diff. item sizes
  • 79.
    A special caseof BINPACKING 4 8 3 8 3 87 8 3 8 4 8 3 4 5 6 • We can completely describe any packing of S into b n bins by the number of bins of each type used 7 8 4 3 8 3 8 5 3 8 3 8 5 • However, not all these different packings are valid Many of them use too few or many items of a particular size 1× Type 3 2× Type 4 3× Type 5 1× Type 6 0× Type 1 0× Type 2 0× Type 7 cb items fit in each bin cs diff. item sizes (in particular the example packing uses too many items of size 3/8)
  • 80.
    A special caseof BINPACKING 4 8 3 8 3 87 8 3 8 4 8 3 4 5 6 • We can completely describe any packing of S into b n bins by the number of bins of each type used 7 8 4 3 8 3 8 5 3 8 3 8 5 • However, not all these different packings are valid Many of them use too few or many items of a particular size • We check each of the different packings to see if it is valid 1× Type 3 2× Type 4 3× Type 5 1× Type 6 0× Type 1 0× Type 2 0× Type 7 cb items fit in each bin cs diff. item sizes (in particular the example packing uses too many items of size 3/8)
  • 81.
    A special caseof BINPACKING 4 8 3 8 3 87 8 3 8 4 8 3 4 5 6 • We can completely describe any packing of S into b n bins by the number of bins of each type used 7 8 4 3 8 3 8 5 3 8 3 8 5 • However, not all these different packings are valid Many of them use too few or many items of a particular size • We check each of the different packings to see if it is valid and output the valid one which uses the fewest bins 1× Type 3 2× Type 4 3× Type 5 1× Type 6 0× Type 1 0× Type 2 0× Type 7 cb items fit in each bin cs diff. item sizes (in particular the example packing uses too many items of size 3/8)
  • 82.
    A special caseof BINPACKING 4 8 3 8 3 87 8 3 8 4 8 3 4 5 6 • We can completely describe any packing of S into b n bins by the number of bins of each type used 7 8 4 3 8 3 8 5 3 8 3 8 5 • However, not all these different packings are valid Many of them use too few or many items of a particular size • We check each of the different packings to see if it is valid and output the valid one which uses the fewest bins • This takes O(n · (n + 1)(cb+1)cs ) time and exactly solves BINPACKING 1× Type 3 2× Type 4 3× Type 5 1× Type 6 0× Type 1 0× Type 2 0× Type 7 (i.e. it outputs an optimal packing) cb items fit in each bin cs diff. item sizes (in particular the example packing uses too many items of size 3/8)
  • 83.
    Towards an APTAS TheAPTAS for BINPACKING will use a four step process: Step 1 Remove all the small items Step 2 Divide the items into a constant number of groups Only cb of the remaining large items will fit into a single bin Sizes of items in each group are then rounded up to match the size of the largest member This will leave only cs different item sizes Step 3 Use the poly-time algorithm to optimally pack the remaining special case the constants cb and cs will depend on Step 4 Reverse the grouping from Step 2 and then Remember that the goal is to use b bins where Opt b (1 + ) · Opt + c (for some c) greedily pack all the small items removed in Step 1 (and the largest group is removed)
  • 84.
    Removing the smallitems Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins, in polynomial time we can find a packing of all items in S which either uses: b bins or (1 + )Opt + 1 bins
  • 85.
    Removing the smallitems Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins, in polynomial time we can find a packing of all items in S which either uses: b bins or (1 + )Opt + 1 bins After packing of large items (> /2)
  • 86.
    Removing the smallitems we pack the small items ( /2) on top of the large items greedily Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins, in polynomial time we can find a packing of all items in S which either uses: b bins or (1 + )Opt + 1 bins After packing of large items (> /2)
  • 87.
    Removing the smallitems we pack the small items ( /2) on top of the large items greedily Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins, in polynomial time we can find a packing of all items in S which either uses: b bins or (1 + )Opt + 1 bins After packing of large items (> /2)
  • 88.
    Removing the smallitems we pack the small items ( /2) on top of the large items greedily Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins, in polynomial time we can find a packing of all items in S which either uses: b bins or (1 + )Opt + 1 bins After packing of large items (> /2) pack the small items anywhere you like - just but don’t use an extra bin unless you have to
  • 89.
    Removing the smallitems we pack the small items ( /2) on top of the large items greedily Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins, in polynomial time we can find a packing of all items in S which either uses: b bins or (1 + )Opt + 1 bins After packing of large items (> /2)
  • 90.
    Removing the smallitems we pack the small items ( /2) on top of the large items greedily Either: We don’t use any extra bins or every bin (except possibly the last) is 1 − ( /2) full Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins, in polynomial time we can find a packing of all items in S which either uses: b bins or (1 + )Opt + 1 bins After packing of large items (> /2)
  • 91.
    Removing the smallitems we pack the small items ( /2) on top of the large items greedily Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins, in polynomial time we can find a packing of all items in S which either uses: After packing of large items (> /2) b bins or (1 + )Opt + 1 bins Either: We don’t use any extra bins or every bin (except possibly the last) is 1 − ( /2) full
  • 92.
    Removing the smallitems we pack the small items ( /2) on top of the large items greedily Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins, in polynomial time we can find a packing of all items in S which either uses: After packing of large items (> /2) Either: We don’t use any extra bins or every bin (except possibly the last) is 1 − ( /2) full b bins or (1 + )Opt + 1 bins
  • 93.
    Removing the smallitems we pack the small items ( /2) on top of the large items greedily Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins, in polynomial time we can find a packing of all items in S which either uses: After packing of large items (> /2) Either: We don’t use any extra bins or every bin (except possibly the last) is 1 − ( /2) full b bins or (1 + )Opt + 1 bins
  • 94.
    Removing the smallitems we pack the small items ( /2) on top of the large items greedily Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins, in polynomial time we can find a packing of all items in S which either uses: After packing of large items (> /2) Either: We don’t use any extra bins or every bin (except possibly the last) is 1 − ( /2) full b bins or (1 + )Opt + 1 bins small items don’t fit in here (so they are very well packed) 1 − 2
  • 95.
    Removing the smallitems we pack the small items ( /2) on top of the large items greedily Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins, in polynomial time we can find a packing of all items in S which either uses: After packing of large items (> /2) Either: We don’t use any extra bins or every bin (except possibly the last) is 1 − ( /2) full b bins or (1 + )Opt + 1 bins small items don’t fit in here (so they are very well packed) 1 − 2 this is the +1
  • 96.
    Removing the smallitems Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins, in polynomial time we can find a packing of all items in S which either uses: b bins or (1 + )Opt + 1 bins We can now ignore all the small items and focus on finding a good packing of the large items
  • 97.
    Removing the smallitems Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins, in polynomial time we can find a packing of all items in S which either uses: b bins or (1 + )Opt + 1 bins We can now ignore all the small items and focus on finding a good packing of the large items How many large items fit in a single bin?
  • 98.
    Removing the smallitems Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins, in polynomial time we can find a packing of all items in S which either uses: b bins or (1 + )Opt + 1 bins We can now ignore all the small items and focus on finding a good packing of the large items How many large items fit in a single bin? Each large item is larger than /2. . .
  • 99.
    Removing the smallitems Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins, in polynomial time we can find a packing of all items in S which either uses: b bins or (1 + )Opt + 1 bins We can now ignore all the small items and focus on finding a good packing of the large items How many large items fit in a single bin? Each large item is larger than /2. . . so at most 2/
  • 100.
    Removing the smallitems Lemma Let 0 < < 1. Given a packing of the items a ∈ S with size a > /2 into b bins, in polynomial time we can find a packing of all items in S which either uses: b bins or (1 + )Opt + 1 bins We can now ignore all the small items and focus on finding a good packing of the large items How many large items fit in a single bin? Each large item is larger than /2. . . so at most 2/ which is a constant :)
  • 101.
    Reducing the numberof item sizes • We divide the items by size, into groups of size k k k k 1 the smallest group might contain fewer than k items
  • 102.
    Reducing the numberof item sizes • We divide the items by size, into groups of size k k k k 1 the smallest group might contain fewer than k items • We define a new set of items S where each item is rounded up so each item in a group has the same size
  • 103.
    Reducing the numberof item sizes • We divide the items by size, into groups of size k k k k 1 the smallest group might contain fewer than k items • We define a new set of items S where each item is rounded up so each item in a group has the same size
  • 104.
    Reducing the numberof item sizes • We divide the items by size, into groups of size k k k k 1 the smallest group might contain fewer than k items • We define a new set of items S where each item is rounded up so each item in a group has the same size and the largest group is removed
  • 105.
    Reducing the numberof item sizes • We divide the items by size, into groups of size k k k k 1 the smallest group might contain fewer than k items • We define a new set of items S where each item is rounded up so each item in a group has the same size • Notice that S contains only n/k distinct item sizes and the largest group is removed
  • 106.
    Reducing the numberof item sizes • We divide the items by size, into groups of size k k k k 1 the smallest group might contain fewer than k items • We define a new set of items S where each item is rounded up so each item in a group has the same size • Notice that S contains only n/k distinct item sizes and the largest group is removed (k will be big enough so that n/k 4/ 2 - which is a constant)
  • 107.
    Reducing the numberof item sizes Lemma Let S be S after linear grouping (with groups of size k). Opt(S ) Opt(S) Opt(S ) + k . . Further, any packing of S can be converted into a packing of S in polynomial time using at most k extra bins
  • 108.
    Reducing the numberof item sizes Lemma Let S be S after linear grouping (with groups of size k). Opt(S ) Opt(S) Opt(S ) + k . . Here Opt(S) is the optimal number of bins required to pack S Similarly Opt(S ) is the optimal number of bins required to pack S Further, any packing of S can be converted into a packing of S in polynomial time using at most k extra bins
  • 109.
    Reducing the numberof item sizes Lemma Let S be S after linear grouping (with groups of size k). Opt(S ) Opt(S) Opt(S ) + k . . Further, any packing of S can be converted into a packing of S in polynomial time using at most k extra bins
  • 110.
    Reducing the numberof item sizes Lemma Let S be S after linear grouping (with groups of size k). Opt(S ) Opt(S) Opt(S ) + k . S S
  • 111.
    Reducing the numberof item sizes Proof Lemma Let S be S after linear grouping (with groups of size k). Opt(S ) Opt(S) Opt(S ) + k . S S
  • 112.
    Reducing the numberof item sizes Proof Lemma Let S be S after linear grouping (with groups of size k). Opt(S ) Opt(S) Opt(S ) + k . S S If you can pack S into b bins, you can pack S into b bins
  • 113.
    Reducing the numberof item sizes Proof Lemma Let S be S after linear grouping (with groups of size k). Opt(S ) Opt(S) Opt(S ) + k . S S If you can pack S into b bins, you can pack S into b bins Take the packing of S and replace each item as shown unpack these
  • 114.
    Reducing the numberof item sizes Proof Lemma Let S be S after linear grouping (with groups of size k). Opt(S ) Opt(S) Opt(S ) + k . S S If you can pack S into b bins, you can pack S into b bins Take the packing of S and replace each item as shown Each item from S is replaced with one no larger from S unpack these
  • 115.
    Reducing the numberof item sizes Proof Lemma Let S be S after linear grouping (with groups of size k). Opt(S ) Opt(S) Opt(S ) + k . S S If you can pack S into b bins, you can pack S into b bins Take the packing of S and replace each item as shown Each item from S is replaced with one no larger from S So the packing is valid and hence Opt(S ) Opt(S) unpack these
  • 116.
    Reducing the numberof item sizes Proof Lemma Let S be S after linear grouping (with groups of size k). Opt(S ) Opt(S) Opt(S ) + k . S S If you can pack S into b bins, you can pack S into b + k bins
  • 117.
    Reducing the numberof item sizes Proof Lemma Let S be S after linear grouping (with groups of size k). Opt(S ) Opt(S) Opt(S ) + k . S S If you can pack S into b bins, you can pack S into b + k bins Take the packing of S and replace each item as shown
  • 118.
    Reducing the numberof item sizes Proof Lemma Let S be S after linear grouping (with groups of size k). Opt(S ) Opt(S) Opt(S ) + k . S S If you can pack S into b bins, you can pack S into b + k bins Take the packing of S and replace each item as shown
  • 119.
    Reducing the numberof item sizes Proof Lemma Let S be S after linear grouping (with groups of size k). Opt(S ) Opt(S) Opt(S ) + k . S S If you can pack S into b bins, you can pack S into b + k bins Take the packing of S and replace each item as shown Each item from S is replaced with one no larger from S
  • 120.
    Reducing the numberof item sizes Proof Lemma Let S be S after linear grouping (with groups of size k). Opt(S ) Opt(S) Opt(S ) + k . S S If you can pack S into b bins, you can pack S into b + k bins Take the packing of S and replace each item as shown Each item from S is replaced with one no larger from S The k largest items are given their own extra bins give these k items a bin each
  • 121.
    Reducing the numberof item sizes Proof Lemma Let S be S after linear grouping (with groups of size k). Opt(S ) Opt(S) Opt(S ) + k . S S If you can pack S into b bins, you can pack S into b + k bins
  • 122.
    Reducing the numberof item sizes Proof Lemma Let S be S after linear grouping (with groups of size k). Opt(S ) Opt(S) Opt(S ) + k . S S If you can pack S into b bins, you can pack S into b + k bins This gives a valid packing of S
  • 123.
    Reducing the numberof item sizes Proof Lemma Let S be S after linear grouping (with groups of size k). Opt(S ) Opt(S) Opt(S ) + k . S S If you can pack S into b bins, you can pack S into b + k bins Opt(S) Opt(S ) + k This gives a valid packing of S Hence,
  • 124.
    Reducing the numberof item sizes Proof Lemma Let S be S after linear grouping (with groups of size k). Opt(S ) Opt(S) Opt(S ) + k . S S If you can pack S into b bins, you can pack S into b + k bins Opt(S) Opt(S ) + k This gives a valid packing of S Hence, Note that both transformations take polynomial time
  • 125.
    Reducing the numberof item sizes Lemma Let S be S after linear grouping (with groups of size k). Opt(S ) Opt(S) Opt(S ) + k . . Further, any packing of S can be converted into a packing of S in polynomial time using at most k extra bins
  • 126.
    Reducing the numberof item sizes Lemma Let S be S after linear grouping (with groups of size k). Opt(S ) Opt(S) Opt(S ) + k . . We set k = n · ( 2/2) and let S be the set of large items which implies that. . . n = |S| Further, any packing of S can be converted into a packing of S in polynomial time using at most k extra bins
  • 127.
    Reducing the numberof item sizes Lemma Let S be S after linear grouping (with groups of size k). Opt(S ) Opt(S) Opt(S ) + k . . We set k = n · ( 2/2) and let S be the set of large items which implies that. . . k · Opt(S) n = |S| Further, any packing of S can be converted into a packing of S in polynomial time using at most k extra bins
  • 128.
    Reducing the numberof item sizes Lemma Let S be S after linear grouping (with groups of size k). Opt(S ) Opt(S) Opt(S ) + k . . We set k = n · ( 2/2) and let S be the set of large items which implies that. . . k · Opt(S) (because each of the n items in S has size at least /2) n = |S| Further, any packing of S can be converted into a packing of S in polynomial time using at most k extra bins
  • 129.
    Reducing the numberof item sizes Lemma Let S be S after linear grouping (with groups of size k). Opt(S ) Opt(S) Opt(S ) + k . . We set k = n · ( 2/2) and let S be the set of large items which implies that. . . k · Opt(S) (because each of the n items in S has size at least /2) If we can find the optimal packing of S , which uses Opt(S ) bins we can convert it into a packing of S which uses Opt(S ) + k (1 + )Opt(S) bins n = |S| Further, any packing of S can be converted into a packing of S in polynomial time using at most k extra bins
  • 130.
    Reducing the numberof item sizes Lemma Let S be S after linear grouping (with groups of size k). Opt(S ) Opt(S) Opt(S ) + k . . We set k = n · ( 2/2) and let S be the set of large items which implies that. . . k · Opt(S) (because each of the n items in S has size at least /2) If we can find the optimal packing of S , which uses Opt(S ) bins we can convert it into a packing of S which uses Opt(S ) + k (1 + )Opt(S) bins S contains 4/ 2 distinct item sizes and only 2/ items fit in each bin. . . n = |S| Further, any packing of S can be converted into a packing of S in polynomial time using at most k extra bins
  • 131.
    Reducing the numberof item sizes Lemma Let S be S after linear grouping (with groups of size k). Opt(S ) Opt(S) Opt(S ) + k . . We set k = n · ( 2/2) and let S be the set of large items which implies that. . . k · Opt(S) (because each of the n items in S has size at least /2) I.e. we can optimally pack S in polynomial time. . . If we can find the optimal packing of S , which uses Opt(S ) bins we can convert it into a packing of S which uses Opt(S ) + k (1 + )Opt(S) bins S contains 4/ 2 distinct item sizes and only 2/ items fit in each bin. . . n = |S| Further, any packing of S can be converted into a packing of S in polynomial time using at most k extra bins
  • 132.
    The overall APTAS Step1 Remove all the small items Step 2 Divide the items into k = n · ( 2/2) different groups Only cb = 2/ of the remaining large items will fit into a single bin Sizes of items in each group are then rounded up to match the size of the largest member This will leave only cs = 4/ 2 different item sizes Step 3 Use the poly-time algorithm to optimally pack the remaining special case Step 4 Reverse the grouping from Step 2 and then greedily pack all the small items removed in Step 1 (and the largest group is removed) This takes O n · (n + 1)(4/ 2 +1) 2/ time Theorem For any 0 < < 1, the algorithm presented runs in polynomial time and returns a packing of any set of items using at most (1 + )Opt + 1 bins 3 4 5 64 5 5
  • 133.
    Conclusions • There isno α-approximation for BINPACKING with α < 3/2 • We saw an APTAS for BINPACKING. (which uses at most (1 + ) · Opt + 1 bins) • There is a poly-time algorithm which outputs a solution using at most, unless P = NP • This in turn implies that there is no PTAS for BINPACKING unless P = NP • The First Fit Decreasing algorithm uses at most, 11 9 · Opt + 1 bins there is also an AFPTAS for bin packing Opt+O(log2 Opt) = 1 + O(log2 Opt) Opt ·Opt bins
  • 134.
    Conclusions • There isno α-approximation for BINPACKING with α < 3/2 • We saw an APTAS for BINPACKING. (which uses at most (1 + ) · Opt + 1 bins) • There is a poly-time algorithm which outputs a solution using at most, unless P = NP • This in turn implies that there is no PTAS for BINPACKING unless P = NP • The First Fit Decreasing algorithm uses at most, 11 9 · Opt + 1 bins there is also an AFPTAS for bin packing Opt+O(log2 Opt) = 1 + O(log2 Opt) Opt ·Opt bins Whether there is a poly-time algorithm which uses at most Opt + 1 bins is an open problem