Harmonic bin packing explained

Harmonic bin-packing is a family of online algorithms for bin packing. The input to such an algorithm is a list of items of different sizes. The output is a packing - a partition of the items into bins of fixed capacity, such that the sum of sizes of items in each bin is at most the capacity. Ideally, we would like to use as few bins as possible, but minimizing the number of bins is an NP-hard problem.

The harmonic bin-packing algorithms rely on partitioning the items into categories based on their sizes, following a Harmonic progression. There are several variants of this idea.

Harmonic-k

The Harmonic-k algorithm partitions the interval of sizes

(0,1]

harmonically into

k-1

pieces

Ij:=(1/(j+1),1/j]

for

1\leqj<k

and

Ik:=(0,1/k]

such that
k
cup
j=1

Ij=(0,1]

. An item

i\inL

is called an

Ij

-item, if

s(i)\inIj

.

The algorithm divides the set of empty bins into

k

infinite classes

Bj

for

1\leqj\leqk

, one bin type for each item type. A bin of type

Bj

is only used for bins to pack items of type

j

. Each bin of type

Bj

for

1\leqj<k

can contain exactly

j

Ij

-items. The algorithm now acts as follows:

i\inL

is an

Ij

-item for

1\leqj<k

, the item is placed in the first (only open)

Bj

bin that contains fewer than

j

pieces or opens a new one if no such bin exists.

i\inL

is an

Ik

-item, the algorithm places it into the bins of type

Bk

using Next-Fit.

This algorithm was first described by Lee and Lee.[1] It has a time complexity of

l{O}(nlog(n))

where n is the number of input items. At each step, there are at most

k

open bins that can be potentially used to place items, i.e., it is a k-bounded space algorithm.

Lee and Lee also studied the asymptotic approximation ratio. They defined a sequence

\sigma1:=1

,

\sigmai+1:=\sigmai(\sigmai+1)

for

i\geq1

and proved that for

\sigmal<k<\sigmal+1

it holds that
infty
R
Hk

\leq

l
\sum
i=1

1/\sigmai+k/(\sigmal+1(k-1))

. For

kinfty

it holds that
infty
R
Hk

1.6910

. Additionally, they presented a family of worst-case examples for that
infty
R
Hk

=

l
\sum
i=1

1/\sigmai+k/(\sigmal+1(k-1))

Refined-Harmonic (RH)

The Refined-Harmonic combines ideas from the Harmonic-k algorithm with ideas from Refined-First-Fit. It places the items larger than

1/3

similar as in Refined-First-Fit, while the smaller items are placed using Harmonic-k. The intuition for this strategy is to reduce the huge waste for bins containing pieces that are just larger than

1/2

.

The algorithm classifies the items with regard to the following intervals:

I1:=(59/96,1]

,

Ia:=(1/2,59/96]

,

I2:=(37/96,1/2]

,

Ib:=(1/3,37/96]

,

Ij:=(1/(j+1),1/j]

, for

j\in\{3,...,k-1\}

, and

Ik:=(0,1/k]

. The algorithm places the

Ij

-items as in Harmonic-k, while it follows a different strategy for the items in

Ia

and

Ib

. There are four possibilities to pack

Ia

-items and

Ib

-items into bins.

Ia

-bin contains only one

Ia

-item.

Ib

-bin contains only one

Ib

-item.

Iab

-bin contains one

Ia

-item and one

Ib

-item.

Ibb

-bin contains two

Ib

-items.

An

Ib'

-bin denotes a bin that is designated to contain a second

Ib

-item. The algorithm uses the numbers N_a, N_b, N_ab, N_bb, and N_b' to count the numbers of corresponding bins in the solution. Furthermore, N_c= N_b+N_ab Algorithm Refined-Harmonic-k for a list L = (i_1, \dots i_n): 1. N_a = N_b = N_ab = N_bb = N_b' = N_c = 0 2. If i_j is an I_k-piece then use algorithm Harmonic-k to pack it 3. else if i_j is an I_a-item then if N_b != 1, then pack i_j into any J_b-bin; N_b--; N_ab++; else place i_j in a new (empty) bin; N_a++; 4. else if i_j is an I_b-item then if N_b' = 1 then place i_j into the I_b'-bin; N_b' = 0; N_bb++; 5. else if N_bb <= 3N_c then place i_j in a new bin and designate it as an I_b'-bin; N_b' = 1 else if N_a != 0 then place i_j into any I_a-bin; N_a--; N_ab++;N_c++ else place i_j in a new bin; N_b++;N_c++This algorithm was first described by Lee and Lee. They proved that for

k=20

it holds that
infty
R
RH

\leq373/228

.

Other variants

Modified Harmonic (MH) has asymptotic ratio

infty
R
MH

\leq538/331.61562

.[2]

Modified Harmonic 2 (MH2) has asymptotic ratio

infty
R
MH2

\leq239091/1483041.61217

.

Harmonic + 1 (H+1) has asymptotic ratio

infty
R
H+1

\geq1.59217

.[3]

Harmonic ++ (H++) has asymptotic ratio

infty
R
H++

\leq1.58889

and
infty
R
H++

\geq1.58333

.

References

  1. Lee. C. C.. Lee. D. T.. July 1985. A simple on-line bin-packing algorithm. Journal of the ACM. 32. 3. 562–572. 10.1145/3828.3833. 15441740. free.
  2. Ramanan. Prakash. Brown. Donna J. Lee. C.C. Lee. D.T. September 1989. On-line bin packing in linear time. Journal of Algorithms. 10. 3. 305–326. 10.1016/0196-6774(89)90031-X. free. 2142/74206.
  3. Seiden. Steven S.. 2002. On the online bin packing problem. Journal of the ACM. 49. 5. 640–671. 10.1145/585265.585269. 14164016.