Bin packing problem
Bin packing problem
Main page

Bin packing problem

logo
Community Hub0 subscribers
Read side by side
from Wikipedia

The bin packing problem[1][2][3][4] is an optimization problem, in which items of different sizes must be packed into a finite number of bins or containers, each of a fixed given capacity, in a way that minimizes the number of bins used. The problem has many applications, such as filling up containers, loading trucks with weight capacity constraints, creating file backups in media, splitting a network prefix into multiple subnets,[5] and technology mapping in FPGA semiconductor chip design.

Computationally, the problem is NP-hard, and the corresponding decision problem, deciding if items can fit into a specified number of bins, is NP-complete. Despite its worst-case hardness, optimal solutions to very large instances of the problem can be produced with sophisticated algorithms. In addition, many approximation algorithms exist. For example, the first fit algorithm provides a fast but often non-optimal solution, involving placing each item into the first bin in which it will fit. It requires Θ(n log n) time, where n is the number of items to be packed. The algorithm can be made much more effective by first sorting the list of items into decreasing order (sometimes known as the first-fit decreasing algorithm), although this still does not guarantee an optimal solution and for longer lists may increase the running time of the algorithm. It is known, however, that there always exists at least one ordering of items that allows first-fit to produce an optimal solution.[6]

There are many variations of this problem, such as 2D packing, linear packing, packing by weight, packing by cost, and so on. The bin packing problem can also be seen as a special case of the cutting stock problem. When the number of bins is restricted to 1 and each item is characterized by both a volume and a value, the problem of maximizing the value of items that can fit in the bin is known as the knapsack problem.

A variant of bin packing that occurs in practice is when items can share space when packed into a bin. Specifically, a set of items could occupy less space when packed together than the sum of their individual sizes. This variant is known as VM packing[7] since when virtual machines (VMs) are packed in a server, their total memory requirement could decrease due to pages shared by the VMs that need only be stored once. If items can share space in arbitrary ways, the bin packing problem is hard to even approximate. However, if space sharing fits into a hierarchy, as is the case with memory sharing in virtual machines, the bin packing problem can be efficiently approximated.

Another variant of bin packing of interest in practice is the so-called online bin packing. Here the items of different volume are supposed to arrive sequentially, and the decision maker has to decide whether to select and pack the currently observed item, or else to let it pass. Each decision is without recall. In contrast, offline bin packing allows rearranging the items in the hope of achieving a better packing once additional items arrive. This of course requires additional storage for holding the items to be rearranged.

Formal statement

[edit]

In Computers and Intractability[8]: 226  Garey and Johnson list the bin packing problem under the reference [SR1]. They define its decision variant as follows.

Instance: Finite set of items, a size for each , a positive integer bin capacity , and a positive integer .

Question: Is there a partition of into disjoint sets such that the sum of the sizes of the items in each is or less?

Note that in the literature often an alternate, but not equivalent, notation is used, where and for each . Furthermore, research is mostly interested in the optimization variant, which asks for the smallest possible value of . A solution is optimal if it has minimal . The -value for an optimal solution for a set of items is denoted by or just if the set of items is clear from the context.

A possible integer linear programming formulation of the problem is:

minimize
subject to

where if bin is used and if item is put into bin .[9]

Hardness of bin packing

[edit]

The bin packing problem is strongly NP-complete. This can be proven by reducing the strongly NP-complete 3-partition problem to bin packing.[8]

Furthermore, there can be no approximation algorithm with absolute approximation ratio smaller than unless . This can be proven by a reduction from the partition problem:[10] given an instance of Partition where the sum of all input numbers is , construct an instance of bin-packing in which the bin size is T. If there exists an equal partition of the inputs, then the optimal packing needs 2 bins; therefore, every algorithm with an approximation ratio smaller than 3/2 must return less than 3 bins, which must be 2 bins. In contrast, if there is no equal partition of the inputs, then the optimal packing needs at least 3 bins.

On the other hand, bin packing is solvable in pseudo-polynomial time for any fixed number of bins K, and solvable in polynomial time for any fixed bin capacity B.[8]

Approximation algorithms for bin packing

[edit]

To measure the performance of an approximation algorithm there are two approximation ratios considered in the literature. For a given list of items the number denotes the number of bins used when algorithm is applied to list , while denotes the optimum number for this list. The absolute worst-case performance ratio for an algorithm is defined as

On the other hand, the asymptotic worst-case ratio is defined as

Equivalently, is the smallest number such that there exists some constant K, such that for all lists L:[4]

.

Additionally, one can restrict the lists to those for which all items have a size of at most . For such lists, the bounded size performance ratios are denoted as and .

Approximation algorithms for bin packing can be classified into two categories:

  1. Online heuristics, that consider the items in a given order and place them one by one inside the bins. These heuristics are also applicable to the offline version of this problem.
  2. Offline heuristics, that modify the given list of items e.g. by sorting the items by size. These algorithms are no longer applicable to the online variant of this problem. However, they have an improved approximation guarantee while maintaining the advantage of their small time-complexity. A sub-category of offline heuristics is asymptotic approximation schemes. These algorithms have an approximation guarantee of the form for some constant that may depend on . For an arbitrarily large these algorithms get arbitrarily close to . However, this comes at the cost of a (drastically) increased time complexity compared to the heuristical approaches.

Online heuristics

[edit]

In the online version of the bin packing problem, the items arrive one after another and the (irreversible) decision where to place an item has to be made before knowing the next item or even if there will be another one. A diverse set of offline and online heuristics for bin-packing have been studied by David S. Johnson on his Ph.D. thesis.[11]

Single-class algorithms

[edit]

There are many simple algorithms that use the following general scheme:

  • For each item in the input list:
    1. If the item fits into one of the currently open bins, then put it in one of these bins;
    2. Otherwise, open a new bin and put the new item in it.

The algorithms differ in the criterion by which they choose the open bin for the new item in step 1 (see the linked pages for more information):

  • Next Fit (NF) always keeps a single open bin. When the new item does not fit into it, it closes the current bin and opens a new bin. Its advantage is that it is a bounded-space algorithm since it only needs to keep a single open bin in memory. Its disadvantage is that its asymptotic approximation ratio is 2. In particular, , and for each there exists a list L such that and .[11] Its asymptotic approximation ratio can be somewhat improved based on the item sizes: for all and for all . For each algorithm A that is an AnyFit-algorithm it holds that .
  • Next-k-Fit (NkF) is a variant of Next-Fit, but instead of keeping only one bin open, the algorithm keeps the last k bins open and chooses the first bin in which the item fits. Therefore, it is called a k-bounded space algorithm.[12] For the NkF delivers results that are improved compared to the results of NF, however, increasing k to constant values larger than 2 improves the algorithm no further in its worst-case behavior. If algorithm A is an AlmostAnyFit-algorithm and then .[11]
  • First-Fit (FF) keeps all bins open, in the order in which they were opened. It attempts to place each new item into the first bin in which it fits. Its approximation ratio is , and there is a family of input lists L for which matches this bound.[13]
  • Best-Fit (BF), too, keeps all bins open, but attempts to place each new item into the bin with the maximum load in which it fits. Its approximation ratio is identical to that of FF, that is: , and there is a family of input lists L for which matches this bound.[14]
  • Worst-Fit (WF) attempts to place each new item into the bin with the minimum load. It can behave as badly as Next-Fit, and will do so on the worst-case list for that . Furthermore, it holds that . Since WF is an AnyFit-algorithm, there exists an AnyFit-algorithm such that .[11]
  • Almost Worst-Fit (AWF) attempts to place each new item inside the second most empty open bin (or emptiest bin if there are two such bins). If it does not fit, it tries the most empty one. It has an asymptotic worst-case ratio of .[11]

In order to generalize these results, Johnson introduced two classes of online heuristics called any-fit algorithm and almost-any-fit algorithm:[4]: 470 

  • In an AnyFit (AF) algorithm, if the current nonempty bins are B1,...,Bj, then the current item will not be packed into Bj+1 unless it does not fit in any of B1,...,Bj. The FF, WF, BF and AWF algorithms satisfy this condition. Johnson proved that, for any AnyFit algorithm A and any :
    .
  • In an AlmostAnyFit (AAF) algorithm, if the current nonempty bins are B1,...,Bj, and of these bins, Bk is the unique bin with the smallest load, then the current item will not be packed into Bk, unless it does not fit into any of the bins to its left. The FF, BF and AWF algorithms satisfy this condition, but WF does not. Johnson proved that, for any AAF algorithm A and any α:
    In particular: .

Refined algorithms

[edit]

Better approximation ratios are possible with heuristics that are not AnyFit. These heuristics usually keep several classes of open bins, devoted to items of different size ranges (see the linked pages for more information):

  • Refined-first-fit bin packing (RFF) partitions the item sizes into four ranges: , , , and . Similarly, the bins are categorized into four classes. The next item is first assigned to its corresponding class. Inside that class, it is assigned to a bin using first-fit. Note that this algorithm is not an Any-Fit algorithm since it may open a new bin despite the fact that the current item fits inside an open bin. This algorithm was first presented by Andrew Chi-Chih Yao,[15] who proved that it has an approximation guarantee of and presented a family of lists with for .
  • Harmonic-k partitions the interval of sizes based on a Harmonic progression into pieces for and such that . This algorithm was first described by Lee and Lee.[16] It has a time complexity of and 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. For , its approximation ratio satisfies , and it is asymptotically tight.
  • Refined-harmonic combines ideas from Harmonic-k with ideas from Refined-First-Fit. It places the items larger than 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 . This algorithm was first described by Lee and Lee.[16] They proved that for it holds that .

General lower bounds for online algorithms

[edit]

Yao[15] proved in 1980 that there can be no online algorithm with an asymptotic competitive ratio smaller than . Brown[17] and Liang[18] improved this bound to 1.53635. Afterward, this bound was improved to 1.54014 by Vliet.[19] In 2012, this lower bound was again improved by Békési and Galambos[20] to .

Comparison table

[edit]
Algorithm Approximation guarantee Worst case list Time-complexity
Next-fit (NF) [11] [11]
First-fit (FF) [13] [13] [11]
Best-fit (BF) [14] [14] [11]
Worst-Fit (WF) [11] [11] [11]
Almost-Worst-Fit (AWF) [11] [11] [11]
Refined-First-Fit (RFF) [15] (for )[15] [15]
Harmonic-k (Hk) for [16] [16] [16]
Refined Harmonic (RH) [16] [16]
Modified Harmonic (MH) [21]
Modified Harmonic 2 (MH2) [21]
Harmonic + 1 (H+1) [22]
Harmonic ++ (H++) [22] [22]

Offline algorithms

[edit]

In the offline version of bin packing, the algorithm can see all the items before starting to place them into bins. This allows to attain improved approximation ratios.

Multiplicative approximation

[edit]

The simplest technique used by offline approximation schemes is the following:

  • Ordering the input list by descending size;
  • Run an online algorithm on the ordered list.

Johnson[11] proved that any AnyFit scheme A that runs on a list ordered by descending size has an asymptotic approximation ratio of

.

Some methods in this family are (see the linked pages for more information):

  • First-fit-decreasing (FFD) orders the items by descending size, then calls First-Fit. Its approximation ratio is , and this is tight.[23]
  • Next-fit-decreasing (NFD) orders the items by descending size, then calls Next-Fit. Its approximate ratio is slightly less than 1.7 in the worst case.[24] It has also been analyzed probabilistically.[25] Next-Fit packs a list and its inverse into the same number of bins. Therefore, Next-Fit-Increasing has the same performance as Next-Fit-Decreasing.[26]
  • Modified first-fit-decreasing (MFFD)[27], improves on FFD for items larger than half a bin by classifying items by size into four size classes large, medium, small, and tiny, corresponding to items with size > 1/2 bin, > 1/3 bin, > 1/6 bin, and smaller items respectively. Its approximation guarantee is .[28]

Fernandez de la Vega and Lueker[29] presented a PTAS for bin packing. For every , their algorithm finds a solution with size at most and runs in time , where denotes a function only dependent on . For this algorithm, they invented the method of adaptive input rounding: the input numbers are grouped and rounded up to the value of the maximum in each group. This yields an instance with a small number of different sizes, which can be solved exactly using the configuration linear program.[30]

Additive approximation

[edit]

The Karmarkar-Karp bin packing algorithm finds a solution with size at most , and runs in time polynomial in n (the polynomial has a high degree, at least 8).

Rothvoss[31] presented an algorithm that generates a solution with at most bins.

Hoberg and Rothvoss[32] improved this algorithm to generate a solution with at most bins. The algorithm is randomized, and its running-time is polynomial in n.

Comparison table

[edit]
Algorithm Approximation guarantee Worst case instance
First-fit-decreasing (FFD) [23] [23]
Modified-first-fit-decreasing (MFFD) [28] [27]
Karmarkar and Karp [33]
Rothvoss [31]
Hoberg and Rothvoss [32]

Exact algorithms

[edit]

Martello and Toth[34] developed an exact algorithm for the 1-dimensional bin-packing problem, called MTP. A faster alternative is the Bin Completion algorithm proposed by Richard E. Korf in 2002[35] and later improved.[36]

A further improvement was presented by Schreiber and Korf in 2013.[37] The new Improved Bin Completion algorithm is shown to be up to five orders of magnitude faster than Bin Completion on non-trivial problems with 100 items, and outperforms the BCP (branch-and-cut-and-price) algorithm by Belov and Scheithauer on problems that have fewer than 20 bins as the optimal solution. Which algorithm performs best depends on problem properties like the number of items, the optimal number of bins, unused space in the optimal solution and value precision.

Small number of different sizes

[edit]

A special case of bin packing is when there is a small number d of different item sizes. There can be many different items of each size. This case is also called high-multiplicity bin packing, and It admits more efficient algorithms than the general problem.

Bin-packing with fragmentation

[edit]

Bin-packing with fragmentation or fragmentable object bin-packing is a variant of the bin packing problem in which it is allowed to break items into parts and put each part separately on a different bin. Breaking items into parts may allow for improving the overall performance, for example, minimizing the number of total bin. Moreover, the computational problem of finding an optimal schedule may become easier, as some of the optimization variables become continuous. On the other hand, breaking items apart might be costly. The problem was first introduced by Mandal, Chakrabary and Ghose.[38]

Variants

[edit]

The problem has two main variants.

  1. In the first variant, called bin-packing with size-increasing fragmentation (BP-SIF), each item may be fragmented; overhead units are added to the size of every fragment.
  2. In the second variant, called bin-packing with size-preserving fragmentation (BP-SPF) each item has a size and a cost; fragmenting an item increases its cost but does not change its size.

Computational complexity

[edit]

Mandal, Chakrabary and Ghose[38] proved that BP-SPF is NP-hard.

Menakerman and Rom[39] showed that BP-SIF and BP-SPF are both strongly NP-hard. Despite the hardness, they present several algorithms and investigate their performance. Their algorithms use classic algorithms for bin-packing, like next-fit and first-fit decreasing, as a basis for their algorithms.

Bertazzi, Golden and Wang[40] introduced a variant of BP-SIF with split rule: an item is allowed to be split in only one way according to its size. It is useful for the vehicle routing problem for example. In their paper, they provide the worst-case performance bound of the variant.

Shachnai, Tamir and Yehezkeli[41] developed approximation schemes for BP-SIF and BP-SPF; a dual PTAS (a PTAS for the dual version of the problem), an asymptotic PTAS called APTAS, and a dual asymptotic FPTAS called AFPTAS for both versions.

Ekici[42] introduced a variant of BP-SPF in which some items are in conflict, and it is forbidden to pack fragments of conflicted items into the same bin. They proved that this variant, too, is NP-hard.

Cassazza and Ceselli[43] introduced a variant with no cost and no overhead, and the number of bins is fixed. However, the number of fragmentations should be minimized. They present mathematical programming algorithms for both exact and approximate solutions.

[edit]

The problem of fractional knapsack with penalties was introduced by Malaguti, Monaci, Paronuzzi and Pferschy.[44] They developed an FPTAS and a dynamic program for the problem, and they showed an extensive computational study comparing the performance of their models. See also: Fractional job scheduling.

Performance with divisible item sizes

[edit]

An important special case of bin packing is that the item sizes form a divisible sequence (also called factored). A special case of divisible item sizes occurs in memory allocation in computer systems, where the item sizes are all powers of 2. If the item sizes are divisible, then some of the heuristic algorithms for bin packing find an optimal solution.[45]

Cardinality constraints on the bins

[edit]

There is a variant of bin packing in which there are cardinality constraints on the bins: each bin can contain at most k items, for some fixed integer k.

  • Krause, Shen and Schwetman[46] introduce this problem as a variant of optimal job scheduling: a computer has some k processors. There are some n jobs that take unit time (1), but have different memory requirements. Each time-unit is considered a single bin. The goal is to use as few bins (=time units) as possible, while ensuring that in each bin, at most k jobs run. They present several heuristic algorithms that find a solution with at most bins.
  • Kellerer and Pferschy[47] present an algorithm with run-time , that finds a solution with at most bins. Their algorithm performs a binary search for OPT. For every searched value m, it tries to pack the items into 3m/2 bins.

Non-additive functions

[edit]

There are various ways to extend the bin-packing model to more general cost and load functions:

  • Anily, Bramel and Simchi-Levi[48] study a setting where the cost of a bin is a concave function of the number of items in the bin. The objective is to minimize the total cost rather than the number of bins. They show that next-fit-increasing bin packing attains an absolute worst-case approximation ratio of at most 7/4, and an asymptotic worst-case ratio of 1.691 for any concave and monotone cost function.
  • Cohen, Keller, Mirrokni and Zadimoghaddam[49] study a setting where the size of the items is not known in advance, but it is a random variable. This is particularly common in cloud computing environments. While there is an upper bound on the amount of resources a certain user needs, most users use much less than the capacity. Therefore, the cloud manager may gain a lot by slight overcommitment. This induces a variant of bin packing with chance constraints: the probability that the sum of sizes in each bin is at most B should be at least p, where p is a fixed constant (standard bin packing corresponds to p=1). They show that, under mild assumptions, this problem is equivalent to a submodular bin packing problem, in which the "load" in each bin is not equal to the sum of items, but to a certain submodular function of it.
[edit]

In the bin packing problem, the size of the bins is fixed and their number can be enlarged (but should be as small as possible).

In contrast, in the multiway number partitioning problem, the number of bins is fixed and their size can be enlarged. The objective is to find a partition in which the bin sizes are as nearly equal is possible (in the variant called multiprocessor scheduling problem or minimum makespan problem, the goal is specifically to minimize the size of the largest bin).

In the vector bin packing problem, each item is a vector, and the size of each bin is also a vector. Let a bin has size , and the sum of vectors in the bin be , then the requirement is that .[50]

In the inverse bin packing problem,[51] both the number of bins and their sizes are fixed, but the item sizes can be changed. The objective is to achieve the minimum perturbation to the item size vector so that all the items can be packed into the prescribed number of bins.

In the maximum resource bin packing problem,[52] the goal is to maximize the number of bins used, such that, for some ordering of the bins, no item in a later bin fits in an earlier bin. In a dual problem, the number of bins is fixed, and the goal is to minimize the total number or the total size of items placed into the bins, such that no remaining item fits into an unfilled bin.

In the bin covering problem, the bin size is bounded from below: the goal is to maximize the number of bins used such that the total size in each bin is at least a given threshold.

In the fair indivisible chore allocation problem (a variant of fair item allocation), the items represent chores, and there are different people each of whom attributes a different difficulty-value to each chore. The goal is to allocate to each person a set of chores with an upper bound on its total difficulty-value (thus, each person corresponds to a bin). Many techniques from bin packing are used in this problem too.[53]

In the guillotine cutting problem, both the items and the "bins" are two-dimensional rectangles rather than one-dimensional numbers, and the items have to be cut from the bin using end-to-end cuts.

In the selfish bin packing problem, each item is a player who wants to minimize its cost.[54]

There is also a variant of bin packing in which the cost that should be minimized is not the number of bins, but rather a certain concave function of the number of items in each bin.[48]

Other variants are two-dimensional bin packing,[55] three-dimensional bin packing,[56] bin packing with delivery,[57]

Resources

[edit]
  • BPPLIB - a library of surveys, codes, benchmarks, generators, solvers, and bibliography.

References

[edit]
Revisions and contributorsEdit on WikipediaRead on Wikipedia
from Grokipedia
The bin packing problem is a fundamental combinatorial optimization challenge in computer science and operations research, consisting of packing a given set of items—each with a specified positive size—into the minimum number of fixed-capacity bins such that the sum of the sizes of items assigned to any single bin does not exceed its capacity, typically normalized to unit size 1 with item sizes in (0,1].[1] Formally, for a list L=(a1,a2,,an)L = (a_1, a_2, \dots, a_n) of items with sizes s(ai)s(a_i), the objective is to partition LL into the fewest subsets B1,B2,,BmB_1, B_2, \dots, B_m where aiBjs(ai)1\sum_{a_i \in B_j} s(a_i) \leq 1 for each j=1,,mj = 1, \dots, m, thereby minimizing mm.[1] This problem is NP-hard in the strong sense, as proven by reduction from the 3-PARTITION problem, implying no exact polynomial-time algorithm exists unless P=NP, and the decision variant—determining if all items fit into at most kk bins—is NP-complete.[2] Due to its computational intractability, extensive research focuses on approximation algorithms, which provide near-optimal solutions efficiently; notable examples include the offline First Fit Decreasing (FFD) heuristic, which sorts items in decreasing size order before packing and achieves at most 11/9OPT+111/9 \cdot OPT + 1 bins where OPTOPT is the optimal number (with the asymptotic ratio RFFD1=11/91.222R^1_{FFD} = 11/9 \approx 1.222), and online variants like First Fit (FF) with worst-case ratio approaching 1.7.[1] Fully polynomial-time approximation schemes (FPTAS) also exist, guaranteeing solutions within 1+ϵ1 + \epsilon of optimal for any ϵ>0\epsilon > 0 in time polynomial in nn and 1/ϵ1/\epsilon.[1] The bin packing problem has broad practical applications, including efficient loading of shipping containers or trucks to minimize transportation costs, allocating fixed-size memory blocks to files or processes in computing systems, and scheduling tasks on identical machines to reduce resource usage.[3] Originating in the early 1970s as a model for resource allocation, it has served as a key testbed for developing and analyzing approximation techniques in optimization, influencing fields like logistics, manufacturing, and cloud computing.[1] Extensions, such as multidimensional or variable-sized bin variants, address more complex real-world scenarios like 3D packing in warehouses.[4]

Formal Statement

Basic Definition

The bin packing problem originated as a fundamental optimization challenge in operations research, with its formal analysis emerging in the 1970s through early studies of heuristic methods and performance guarantees. The landmark paper by Johnson et al. (1974) provided the first comprehensive examination of simple packing algorithms, establishing worst-case bounds and highlighting the problem's relevance to resource allocation scenarios.[5] At its core, the bin packing problem entails assigning a collection of items, each characterized by a specific size, to a minimal number of fixed-capacity bins without exceeding any bin's limit. This mirrors practical tasks such as fitting diverse rectangular goods into uniform shipping containers to reduce the volume of transport needed, thereby cutting costs and improving efficiency in logistics.[1] The problem has broad real-world implications across industries, including cargo loading in manufacturing and transportation to optimize space utilization in containers and vehicles.[6] In computing, it underpins load balancing strategies that distribute workloads across processors or servers to prevent bottlenecks and enhance system performance.[7] Similarly, in operating systems, bin packing principles guide memory allocation by partitioning available storage into blocks for processes while minimizing waste and fragmentation.[8] In the standard formulation, the bin packing problem assumes one-dimensional packing, treating item sizes as lengths along a single axis to simplify analysis and approximation, with extensions to higher dimensions addressed separately when required.[1] Despite its intuitive appeal and practical utility, the problem is strongly NP-hard, rendering exact solutions infeasible for large instances without prohibitive computational effort.[1]

Mathematical Formulation

The bin packing problem is formally defined as follows. Given a set of $ n $ items, each with a positive size $ s_i $ satisfying $ 0 < s_i \leq 1 $ for $ i = 1, 2, \dots, n $, and bins each of unit capacity 1, the goal is to assign the items to the minimum number of bins such that the total size of items in any bin does not exceed 1.[1] Let $ m $ denote the number of bins used in a feasible packing, where each bin $ j $ (for $ j = 1, 2, \dots, m $) contains a subset of items with $ \sum_{i \in B_j} s_i \leq 1 $ and the subsets $ B_j $ partition the set of all items. The objective is to minimize $ m $, and the minimum value over all feasible packings is denoted by $ OPT $, the optimal number of bins.[1] A fundamental lower bound on $ OPT $ arises from the total size of the items: since each bin holds at most 1 unit of size, at least the total size $ \sum_{i=1}^n s_i $ bins are needed in the fractional relaxation, so
OPTi=1nsi. OPT \geq \sum_{i=1}^n s_i.
Another lower bound comes from the largest item: no bin can hold more than one item of size greater than $ 1/2 $, but more directly, $ OPT \geq \max_i s_i $ (with the ceiling implied for integrality, as $ m $ must be integer). These bounds together give $ OPT \geq \max\left{ \sum_{i=1}^n s_i, \max_i s_i \right} $.[1][9]

Hardness Results

NP-Hardness

The decision version of the bin packing problem determines whether a given instance—consisting of item sizes s1,s2,,sns_1, s_2, \dots, s_n where each 0<si10 < s_i \leq 1 and an integer k1k \geq 1—admits a packing into at most kk bins of unit capacity. This problem belongs to NP, since a proposed packing serves as a polynomial-time verifiable certificate.[10] To establish NP-hardness, a polynomial-time reduction from the NP-complete Partition problem is employed. In Partition, given a multiset S={a1,a2,,an}S = \{a_1, a_2, \dots, a_n\} of positive integers summing to 2B2B, the question is whether SS can be divided into two subsets each summing to BB. The corresponding bin packing instance sets item sizes to si=ai/Bs_i = a_i / B (ensuring they sum to 2), bin capacity to 1, and target bins k=2k = 2. A valid partition exists if and only if the items fit into two bins, as the total sum is 2 and any overflow in one bin (summing to more than 1) would exceed its capacity. This reduction, detailed by Garey and Johnson, confirms NP-completeness.[10][11] The bin packing problem exhibits strong NP-hardness, remaining NP-hard even when item sizes are polynomially bounded in the input length (i.e., no exponential dependence on nn). This follows from a straightforward reduction from the strongly NP-complete 3-Partition problem, proven NP-complete by Garey and Johnson. In 3-Partition, given 3m3m positive integers a1,,a3ma_1, \dots, a_{3m} with B/4<ai<B/2B/4 < a_i < B/2 for all ii and total sum mBmB, the task is to partition them into mm triples each summing to BB. Scale the instance to bin packing by setting item sizes si=ai/Bs_i = a_i / B (now bounded between 1/41/4 and 1/21/2), unit bin capacity, and target k=mk = m; the size constraints ensure exactly three items per bin in any feasible packing, yielding equivalence.[12][2] These results imply that no polynomial-time algorithm exists for solving the bin packing problem exactly, unless P = NP.[12]

Inapproximability

The bin packing problem cannot be approximated to within a factor strictly better than $ \frac{3}{2} $ by any polynomial-time algorithm unless P = NP. This fundamental inapproximability result follows from a straightforward reduction from the NP-complete Partition problem: given positive integers $ a_1, \dots, a_n $ summing to $ 2S $, create bin packing items of sizes $ s_i = a_i / S $; the optimal number of unit bins is 2 if the $ a_i $ admit a partition into two sets of equal sum, and 3 otherwise, so distinguishing these cases requires an approximation ratio better than $ \frac{3}{2} $.[1] The bound is tight in the sense that no polynomial-time $ \left( \frac{3}{2} - \epsilon \right) $-approximation exists for any fixed $ \epsilon > 0 $ unless P = NP, as the same reduction implies that improving beyond $ \frac{3}{2} $ by any positive margin solves Partition.[1] Harder variants of bin packing, such as multidimensional or vector bin packing, exhibit stronger inapproximability ties to problems like set cover; for instance, reductions from set cover hardness yield inapproximability factors of $ \frac{5}{4} + \epsilon $ for any $ \epsilon > 0 $ in the two-dimensional case unless P = NP.

Online Algorithms

Heuristic Strategies

In the online bin packing problem, items arrive one by one, and the algorithm must assign each item to a bin immediately upon its arrival, without any information about future items. This setting requires heuristics that make greedy, irrevocable decisions based solely on the current state of open bins and the incoming item size. These strategies prioritize simplicity and low computational overhead, making them suitable for real-time applications despite their suboptimal performance guarantees.[5] The First-Fit (FF) heuristic scans the sequence of existing bins from the first opened to the last and places the item in the earliest bin with sufficient remaining capacity. If no such bin exists, a new bin is opened to hold the item. FF maintains all bins as potentially available for future assignments. Analysis shows that FF uses at most (17/10) * OPT + O(1) bins asymptotically, where OPT is the minimum number of bins needed by an optimal offline solution, yielding an asymptotic approximation ratio of 17/10. This bound is tight, as there exist input sequences where FF performs arbitrarily close to this factor.[5][1] The Best-Fit (BF) heuristic examines all open bins and selects the one with the smallest remaining capacity that can still accommodate the item, with the goal of leaving as little unused space as possible in the chosen bin. A new bin is opened only if no existing bin fits the item. Like FF, BF achieves an asymptotic approximation ratio of 17/10, though it often performs better in practice by reducing fragmentation in individual bins. The bound is similarly tight for worst-case inputs.[5][1] Worst-Fit (WF) operates by placing the item in the bin with the largest remaining capacity among those that can fit it, potentially spreading items more evenly but often leading to inefficient overall packing due to increased empty space in multiple bins. If no bin fits, a new one is opened. WF has a weaker asymptotic approximation ratio of 2, meaning it can use up to twice as many bins as OPT in the worst case, making it less effective than FF or BF for adversarial inputs.[1] The Next-Fit (NF) heuristic is a streamlined variant of FF that uses less memory by considering only the most recently opened bin (the "current" bin) for placement. The item is placed there if it fits; otherwise, the current bin is closed (no longer considered), and a new bin becomes the current one to hold the item. This "sliding window" approach simplifies implementation but results in an asymptotic approximation ratio of 2, comparable to WF and worse than FF or BF in the worst case.[1]

Advanced Online Algorithms

Advanced online algorithms for the bin packing problem build upon basic heuristics by employing classification schemes or partitioning techniques to achieve better competitive ratios, particularly through size-based categorization of items and tailored packing rules for each category. These methods address the limitations of simple strategies like First Fit by dynamically grouping items and applying specialized procedures, leading to more efficient space utilization in an online setting where items arrive sequentially without knowledge of future inputs. One prominent example is the Harmonic-k (H_k) algorithm, which classifies items into k size classes based on their normalized sizes s, where the i-th class contains items satisfying 1/(i+1) < s ≤ 1/i for i = 1 to k, with a separate class for items s ≤ 1/k. For each class, the algorithm uses distinct packing rules: large items (class 1, s > 1/2) are placed in dedicated bins if possible, while smaller classes employ variants of First Fit or Next Fit to avoid fragmentation. This classification ensures that bins are filled more evenly across similar-sized items, yielding an asymptotic competitive ratio of 1 + 1/(k+1) - 1/(k(k+1)), which approaches approximately 1.691 as k tends to infinity. The approach was introduced as a refinement over earlier heuristics, demonstrating improved performance on instances with diverse item sizes.[1] Refined compaction techniques further enhance these classification-based methods by incorporating a post-processing step to merge underfilled bins after initial placement, effectively reducing waste from suboptimal early decisions. In particular, applying compaction to First Fit outputs can consolidate partially filled bins, achieving an asymptotic competitive ratio of approximately 1.588 times the optimal packing. This improvement stems from analyzing bin fill levels post-heuristic and reassigning items to eliminate excess bins, as detailed in advanced harmonic variants that integrate such merging. More recent advancements, such as the Advanced Harmonic algorithm, achieve an improved asymptotic competitive ratio of approximately 1.578 as of 2018.[1][13] While the focus remains on one-dimensional variants, dual approaches like shelf packing extend these ideas to two-dimensional extensions by partitioning the bin height into shelves based on item heights and packing widths online within each shelf, achieving competitive ratios around 2 for strip packing scenarios.

Lower Bounds

Lower bounds for online bin packing algorithms establish fundamental limits on their asymptotic competitive ratios, demonstrating that no algorithm can guarantee performance better than certain thresholds relative to the optimal offline solution. These bounds are derived primarily through adversarial constructions and Yao's minimax principle, which provides a method to prove limits for randomized algorithms by considering the worst-case performance of deterministic algorithms over a fixed distribution of inputs. More refined adversarial constructions push this limit higher. For instance, sequences alternating large items (e.g., sizes slightly above 2/3) with small items (e.g., sizes slightly above 1/3) can force any online algorithm to open new bins for each large item while leaving space unused, resulting in at least 1.5 times the optimal number of bins asymptotically.[1] The strongest general lower bound for any online bin packing algorithm, deterministic or randomized, is approximately 1.54037, established via Yao's principle applied to an optimal distribution of item sizes solved using linear programming. This bound shows that, over the worst-case input distribution, the expected number of bins used by the best deterministic algorithm exceeds 1.54037 times the optimal.[14] For algorithms restricted to constant space, a tighter lower bound of approximately 1.691 applies, derived using Yao's principle with a harmonic distribution of item sizes (proportions following 1/k for k = 1, 2, ...). This value, known as $ H_\infty = \sum_{k=1}^\infty \frac{1}{k} $, matches the asymptotic upper bound achieved by the Harmonic algorithm, indicating it is tight for this class.[15]

Offline Algorithms

Multiplicative Approximations

In the offline variant of the bin packing problem, the complete list of item sizes is available in advance, enabling algorithms to preprocess the input—such as by sorting items—and optimize the packing configuration globally to minimize the number of bins used. This setting contrasts with online algorithms, which process items sequentially without future knowledge, often leading to superior approximation guarantees for offline approaches. Seminal heuristics in this category include sorting-based methods that achieve bounded multiplicative factors relative to the optimal solution OPT. The First-Fit Decreasing (FFD) algorithm sorts the items in non-increasing order of size and then applies the First-Fit heuristic, placing each item into the lowest-indexed bin that has sufficient remaining capacity or opening a new bin if none exists. Johnson et al. proved that FFD uses at most 119OPT+69\frac{11}{9} \mathrm{OPT} + \frac{6}{9} bins, which is at most approximately 1.22 OPT + 1.[16] The Best-Fit Decreasing (BFD) algorithm follows a similar preprocessing step but places each item into the bin with the smallest remaining capacity that can accommodate it. The same analysis shows that BFD also achieves the approximation ratio of 119OPT+69\frac{11}{9} \mathrm{OPT} + \frac{6}{9}.[16] A significant advancement is the asymptotic polynomial-time approximation scheme (APTAS) introduced by de la Vega and Lueker, which, for any fixed ϵ>0\epsilon > 0, produces a packing using at most (1+ϵ)OPT(1 + \epsilon) \mathrm{OPT} bins in polynomial time (specifically, linear in the input size for fixed ϵ\epsilon). This scheme groups small items and solves an integer program for large items, ensuring the multiplicative factor approaches 1 as ϵ\epsilon decreases.[17] Subsequent refinements have yielded improved APTAS variants with tighter constants for practical ϵ\epsilon values; for instance, setting ϵ=0.05\epsilon = 0.05 yields a 1.05 OPT + O(1) guarantee while maintaining polynomial runtime, as explored in robust extensions of the original scheme.[18]

Additive Approximations

Additive approximations for the bin packing problem focus on offline algorithms that guarantee a solution using at most OPT + c bins, where OPT is the minimum number of bins needed and c is a small constant. This type of guarantee is particularly useful when OPT is bounded, as it provides near-optimal performance without the scaling issues of multiplicative approximations. A key hardness result is that there is no polynomial-time algorithm achieving OPT + c for any constant c < 1 unless P = NP, since such an algorithm would solve the NP-complete decision version of determining whether the items can be packed into k bins. One seminal approach is the in-out algorithm, which classifies items into large and small based on a threshold (typically > 1/2 for large items). Large items are packed optimally using exhaustive enumeration or dynamic programming, as their limited types allow efficient exact packing into at most OPT bins. Small items are then packed greedily using a heuristic like First Fit: each small item is placed into an existing bin with sufficient remaining capacity ("in") if possible, or a new bin ("out") otherwise. This method achieves a guarantee of OPT + O(1) bins in the worst case. Bin completion algorithms extend this idea by first fixing a packing of large items and then solving a subproblem to "complete" each bin to near-full capacity with small items. After optimally packing large items, the remaining space in those bins is treated as multiple knapsack instances, solved approximately for small items using dynamic programming or greedy methods. This yields an additive guarantee of OPT + O(1), with the constant depending on the classification threshold; for example, using a threshold of 1/3 results in OPT + 2. The approach leverages the fact that small items can fill gaps efficiently, bounding the waste per bin. Recent advancements include FPT-time algorithms achieving OPT + 1 for general instances, running in time 2^{O(OPT \log^2 OPT)} \cdot n by classifying items into large, medium, and small categories, rounding medium items geometrically, and greedily packing small ones after enumerating feasible configurations for large items. For certain size distributions, such as when item sizes are multiples of 1/poly(n) or from a small number of types, OPT + 1 can be achieved in linear time O(n) using tailored dynamic programming that exploits the restricted variety. These results, from the 2010s, highlight progress in practical near-optimality for restricted inputs.

Exact Algorithms

Exact algorithms for the bin packing problem seek to determine the minimum number of bins required to pack all items without exceeding bin capacity, providing optimal solutions despite the problem's NP-hardness that restricts their use to small instances, typically with up to 100 items. These methods rely on exhaustive enumeration strategies enhanced by pruning techniques to manage computational complexity. Seminal approaches include branch-and-bound, dynamic programming, integer linear programming formulations, and improvements to naive exponential-time algorithms. The branch-and-bound framework, particularly the Martello-Toth Procedure (MTP), represents a cornerstone for exact solutions. Developed by Martello and Toth, the MTP systematically enumerates partial packings by assigning items to bins in a depth-first manner, branching on possible assignments for each item while maintaining feasibility. To accelerate the search, it employs tight lower bounds derived from linear relaxations and continuous approximations of the remaining items, as well as reduction procedures that eliminate dominated partial solutions—such as configurations where one partial packing cannot outperform another based on unpacked item profiles. Dominance is assessed via criteria like the Martello-Toth dominance rule, which compares the filled space and potential for the remaining items across branches. The procedure also integrates upper bounds from heuristic packings to fathom branches early. Implemented in their software, MTP solves instances with up to 100 items in seconds on standard hardware and larger ones up to 500 items in reasonable time for many cases. Dynamic programming methods for exact bin packing often model the problem using states that capture subsets of packed items or profiles of bin configurations. A typical approach considers the decision version—whether all items fit into k bins—via a state representing the subset of items assigned to the first few bins and the residual capacities of those bins, computing the minimum k recursively. For the general case, this leads to an exponential number of states, on the order of O(2^n poly(n)), but optimizations like bounding the number of open bins or using item ordering reduce the effective size. Such techniques are practical for instances with n ≤ 100, especially when combined with symmetry breaking or memoization, achieving solutions in polynomial time relative to the state space. Martello and Toth describe DP-based lower bounds integrated into branch-and-bound for efficiency, while extensions in knapsack-related DP handle the multiple-subset-sum nature of bin packing. The bin packing problem admits a straightforward integer linear programming (ILP) formulation that enables solution via off-the-shelf solvers. Define binary variables $ x_{ij} $ for $ i = 1, \dots, n $ and $ j = 1, \dots, n $, where $ x_{ij} = 1 $ if item $ j $ (of size $ s_j $) is placed in bin $ i $, and binary variables $ y_i = 1 $ if bin $ i $ is used (assuming at most n bins suffice). The model minimizes the number of used bins subject to assignment and capacity constraints:
mini=1nyis.t.i=1nxij=1j=1,,n,j=1nsjxijyii=1,,n,xij,yi{0,1}i,j. \begin{align*} \min &\quad \sum_{i=1}^n y_i \\ \text{s.t.} &\quad \sum_{i=1}^n x_{ij} = 1 \quad \forall j = 1, \dots, n, \\ &\quad \sum_{j=1}^n s_j x_{ij} \leq y_i \quad \forall i = 1, \dots, n, \\ &\quad x_{ij}, y_i \in \{0,1\} \quad \forall i,j. \end{align*}
This set partitioning-style formulation has an exponential number of implicit constraints but is effectively solved by modern branch-and-cut solvers like CPLEX or Gurobi, which generate violated inequalities (e.g., cover or clique constraints) dynamically and exploit the problem's structure for fast root-node relaxations. For n ≤ 100, instances solve near-instantaneously, with larger cases benefiting from preprocessing reductions. The formulation originates in early optimization literature and is refined in works addressing symmetry via aggregated variables or lazy constraints. In terms of worst-case time complexity, a naive exact algorithm enumerates all possible assignments, achieving O(2^n n) time via dynamic programming over item subsets to solve the decision problem for increasing k (with binary search on k up to n).

Special Cases for Few Item Types

When the number of distinct item sizes is bounded by a small constant kk, the bin packing problem admits exact polynomial-time algorithms. A standard dynamic programming approach tracks the vector of remaining multiplicities for each item type across partially packed bins. The state space consists of all possible multiplicity vectors up to the total counts, yielding O(nk)O(n^k) states, where nn is the total number of items; from each state, transitions correspond to filling a new bin with a feasible combination of items, and the number of such combinations is constant for fixed kk since item sizes are fixed. This computes the minimum number of bins required.[19] The case of exactly two item sizes is a special instance with k=2k=2, solvable in polynomial time via the above dynamic programming in O(n2)O(n^2) time, or alternatively using network flow formulations that model item assignments to bin configurations as a minimum-cost flow problem.[19][20] For items whose sizes are unit fractions 1/m1/m with fixed integer m2m \geq 2, the distinct sizes are at most m1m-1 (namely 1/2,1/3,,1/m1/2, 1/3, \dots, 1/m), so the problem reduces to the bounded-kk case above and is solvable in polynomial time. Specific structural results further enable optimal packing in H(a)H(a) bins (where H(a)=1/miH(a) = \lceil \sum 1/m_i \rceil) when the total size satisfies certain thresholds, such as 1/miH(a)3/7\sum 1/m_i \leq H(a) - 3/7, via polynomial-time algorithms that reduce to minimal counterexamples and apply first-fit decreasing.[19][21] These techniques find applications in scenarios where item sizes conform to a limited set of standard dimensions, such as in manufacturing processes for cutting stock from rolls or sheets of material.[22]

Performance Comparison

Offline algorithms for the bin packing problem vary significantly in their approximation guarantees, computational complexity, and practical applicability, allowing practitioners to select based on instance size and required precision. First Fit Decreasing (FFD) provides a strong balance of efficiency and quality, achieving at most 119\frac{11}{9} OPT + 1 bins, where OPT is the optimal number, with a runtime of O(nlogn)O(n \log n).[23] Asymptotic Polynomial Time Approximation Schemes (APTAS) offer near-optimal solutions of (1 + ε) OPT + c for any ε > 0, but at higher cost with runtime O(n2/ε3)O(n^2 / \varepsilon^3).[1] Exact algorithms guarantee OPT bins, though their exponential runtime limits them to smaller instances.[1]
AlgorithmApproximation RatioRuntime Complexity
FFD119\frac{11}{9} OPT + 1 (≈1.22 OPT + 1)O(nlogn)O(n \log n)
APTAS(1 + ε) OPT + cO(n2/ε3)O(n^2 / \varepsilon^3)
ExactOPTExponential
Empirical evaluations demonstrate that heuristics like FFD perform close to optimal on instances with uniform item size distributions, often achieving waste bounded by Θ(n)\Theta(\sqrt{n}) relative to OPT, making them suitable for large-scale problems where exact optimality is unnecessary.[1] Exact methods, such as branch-and-bound variants, remain feasible for instances up to n ≈ 500, solving them in seconds on modern hardware.[24] Key trade-offs among these approaches include the speed and looseness of multiplicative approximations like FFD, which scale well but may overuse bins by up to 22%; the tunable tightness of additive approximations in APTAS, which excel when OPT is large but demand more computation for small ε; and the precision of exact methods, ideal for small n but impractical beyond moderate sizes due to exponential growth.[1]

Variants

Fragmentation

In the fragmentation variant of the bin packing problem, items are permitted to be divided into a limited number of fragments, with the total number of fragments per item constrained by a parameter ff (for example, f=2f=2). Each fragment is packed independently into bins, while ensuring that the sizes of all fragments from an original item sum exactly to its original size, and the bin capacity remains fixed (typically normalized to 1). Unlike the standard problem, this allows for more flexible packing by distributing portions of large items across multiple bins, but the bound on ff prevents arbitrary subdivision to maintain computational challenge and model real-world limits on splitting. The objective is to minimize the number of bins required to accommodate all fragments, where the cost of splitting is implicitly captured through the fragmentation limit rather than explicit overhead in capacity usage.[25] This variant remains NP-hard even for f=2f=2, as the case reduces to the classical bin packing problem when no splitting occurs. Seminal work establishes that allowing a single split per item (corresponding to at most two fragments) admits an asymptotic fully polynomial-time approximation scheme (AFPTAS) for the problem, while asymptotic approximation schemes achieve performance arbitrarily close to optimal for larger instances. For unrestricted fragmentation (where ff is unbounded), the problem reduces to the divisible case, where approximation algorithms attain the optimal ratio of 1 without size-increasing overhead, though practical implementations often incorporate bounds to avoid trivial solutions.[25] The fragmentation model finds applications in cloud computing, particularly in scenarios involving data partitioning or task distribution across servers, such as scheduling jobs with data locality constraints where computational workloads can be split into fragments to meet deadlines while optimizing resource utilization. For instance, in cloud data processing frameworks, large datasets may be fragmented to fit available memory across multiple nodes without violating capacity limits.

Divisible Item Sizes

In the divisible item sizes variant of the bin packing problem, items may be split into any number of portions whose sizes sum to the original item size, similar to packing divisible resources such as fluids. This model assumes no restrictions on the number of fragments per item or bin, allowing portions to be distributed freely across bins to achieve exact fills. The optimal number of bins required equals the ceiling of the total item size divided by the bin capacity; for unit-capacity bins, this is i=1nsi\lceil \sum_{i=1}^n s_i \rceil, where sis_i denotes the size of item ii. A simple greedy algorithm, such as Next Fit, achieves this optimum by sequentially assigning portions of each item to fill current bins completely before opening new ones, with a runtime of O(n)O(n) where nn is the number of items. Thus, the problem is solvable in polynomial time, in contrast to the NP-hard standard bin packing where items cannot be split. This variant eliminates wasted space entirely, as bins can always be packed to full capacity, differing fundamentally from the indivisible case where fragmentation due to fixed item sizes often leads to underutilized bins.

Cardinality Constraints

In the bin packing problem with cardinality constraints, items of given sizes must be packed into bins of unit capacity such that the total size in each bin does not exceed 1 and, additionally, no bin contains more than cc items, where c2c \geq 2 is a fixed integer parameter. The objective remains to minimize the number of bins used, with items being indivisible. This constraint introduces a combinatorial limit alongside the classical size restriction, effectively modeling scenarios where both volume and item count matter.[26] The decision version of the problem is NP-complete, and the optimization problem is NP-hard in the strong sense, even when cc is fixed at any value 2\geq 2; this follows from a reduction from the 3-partition problem, which remains hard under bounded item counts per subset. A fundamental lower bound on the minimum number of bins required, denoted OPT, is
OPTmax(i=1nsi,nc), \mathrm{OPT} \geq \max\left( \left\lceil \sum_{i=1}^n s_i \right\rceil, \left\lceil \frac{n}{c} \right\rceil \right),
where nn is the number of items and si>0s_i > 0 are their sizes; the first term accounts for total size, while the second enforces the cardinality limit. For fixed cc, the problem admits a polynomial-time approximation scheme (PTAS) achieving an approximation ratio of (1+[ϵ](/page/Epsilon))(1 + [\epsilon](/page/Epsilon)) OPT for any [ϵ](/page/Epsilon)>0[\epsilon](/page/Epsilon) > 0, by enumerating feasible bin configurations (polynomial in number for bounded cc) and applying dynamic programming on grouped item types after scaling small items.[26] This variant arises in practical settings such as vehicle loading, where bins represent cargo holds or trucks limited not only by weight or volume but also by the maximum number of passengers or discrete items (e.g., packages) they can accommodate, and in computing resource allocation, such as assigning tasks to CPU cores with caps on the number of processes per core to manage overhead or fairness. These applications highlight the need for balanced packing under dual constraints, often requiring tailored heuristics beyond classical size-only methods.[26]

Non-Additive Functions

In the non-additive variant of the bin packing problem, the objective shifts from minimizing the number of bins to minimizing the total cost, where the cost of each bin is a non-linear function ff of its load, defined as the sum of item sizes assigned to it. Formally, given items with sizes si(0,1]s_i \in (0,1] and bins of unit capacity, the goal is to partition the items into subsets BjB_j such that iBjsi1\sum_{i \in B_j} s_i \leq 1 for each jj, minimizing jf(iBjsi)\sum_j f\left( \sum_{i \in B_j} s_i \right), where f:[0,1]R0f: [0,1] \to \mathbb{R}_{\geq 0} is typically non-decreasing and satisfies f(0)=0f(0) = 0. This generalizes the standard additive objective, which corresponds to f(x)=1f(x) = 1 for x>0x > 0, reducing to minimizing the number of non-empty bins. The problem is NP-hard, as it encompasses the classical bin packing problem as a special case. Approximation algorithms exploit properties of ff; for monotone non-decreasing ff, heuristics such as constructive and local search methods achieve a worst-case performance ratio of 2, meaning the algorithm's cost is at most twice the optimal cost.[27] When ff is additionally concave—reflecting economies of scale where marginal costs decrease with higher utilization—an asymptotic polynomial-time approximation scheme (APTAS) exists, yielding a solution cost of at most (1+ϵ)(1 + \epsilon) times the optimal plus a constant term depending on ϵ>0\epsilon > 0, in polynomial time.[28] Practical examples include scenarios with concave ff, such as shipping or logistics where bin costs decrease sublinearly with load due to fixed overheads dominating at low utilization; for instance, a piecewise-linear concave ff might model pallet transport costs from higher to lower rates as load increases. Quadratic costs arise in energy-related applications, where power consumption grows nonlinearly with load (e.g., f(x)x2f(x) \propto x^2), incentivizing fuller bins to minimize total energy in data centers or manufacturing. Variable effective bin costs can also emerge if ff encodes setup fees scaled by utilization, though bins remain fixed-capacity.

Knapsack and Multiple Knapsack

The bin packing problem exhibits a strong duality with the knapsack problem, where the single knapsack variant serves as a foundational counterpart. In the single knapsack problem, given a set of items with sizes and values, the objective is to select a subset that maximizes the total value without exceeding a fixed bin capacity, typically normalized to 1. When values are set equal to sizes, this reduces to maximizing the packed weight in one bin, providing insight into the maximum utilization possible per bin in packing scenarios. This maximization contrasts with bin packing's goal of minimizing the number of bins needed to accommodate all items, effectively framing bin packing as the problem of covering the item set with the fewest such maximal knapsack solutions.[29] The multiple knapsack problem extends this duality by considering a fixed number kk of bins, each of capacity 1, and seeking to assign items to these bins to maximize the total packed value (or weight, when values equal sizes). In this setting, bin packing for a given kk corresponds to determining whether the multiple knapsack solution can pack the entire instance, i.e., if the maximum packed weight equals the total item size. Approximation algorithms for the multiple knapsack problem leverage techniques such as linear programming (LP) rounding to achieve performance guarantees; for instance, LP-based methods yield constant-factor approximations, with schemes achieving (1 + \epsilon)-approximation for any \epsilon > 0 in polynomial time via a PTAS.[30][31][32] These approaches often relax the assignment to fractional solutions and round them while preserving feasibility and value bounds. A key connection between bin packing variants and knapsack problems arises in the Gilmore-Gomory approach for the cutting stock problem, which treats cutting patterns as columns in an LP formulation. Here, column generation iteratively solves a pricing subproblem formulated as a 0-1 knapsack problem to identify beneficial patterns that improve the current solution, linking the minimization of stock usage (akin to bin packing) directly to knapsack optimizations for pattern efficiency. This method, introduced in the early 1960s, remains influential for large-scale instances where enumerating all possible patterns is infeasible.[33] To bound the optimal bin count in bin packing, a standard lower bound utilizes the knapsack maximum fill: let SS denote the total size of all items, and let ff be the maximum weight packable into a single bin of capacity 1, computed via the 0-1 knapsack problem with item values equal to their sizes. Then, the minimum number of bins satisfies
OPTSf, \text{OPT} \geq \frac{S}{f},
since no bin can exceed fill ff, providing a tight relaxation-based estimate especially when item sizes limit dense packings. This bound is routinely evaluated alongside others like LP relaxations for assessing algorithm performance.[34]

Cutting Stock Problem

The cutting stock problem represents a practical application of bin packing principles in manufacturing, particularly in industries such as paper production, metal fabrication, and textiles, where raw stock material of fixed dimensions must be cut into smaller pieces to meet specific demands while minimizing waste.[22] In the one-dimensional case, the problem involves cutting rolls or sheets of standard width WW into items of various widths wiw_i to satisfy demands bib_i for each item type i=1,,mi = 1, \dots, m, with the goal of using the fewest stock rolls possible or equivalently minimizing total trim loss (unused material).[35] Unlike the classical bin packing problem, which treats items as unique and focuses solely on packing feasibility, the cutting stock problem accounts for multiplicities in demands, allowing multiple identical items per pattern, and optimizes for trim loss as the primary objective. The problem was first formally modeled as an integer programming problem by Leonid Kantorovich in 1939, with the English translation published in 1960.[36] In this formulation, let ajia_{ji} denote the number of pieces of item ii cut from pattern jj, where each pattern jj satisfies iajiwiW\sum_i a_{ji} w_i \leq W, and xjx_j is the integer number of times pattern jj is used. The model minimizes the total number of stock rolls jxj\sum_j x_j subject to jajixj=bi\sum_j a_{ji} x_j = b_i for each ii, with xj0x_j \geq 0 integer.[36] This set partitioning structure captures the exact demands but leads to an exponential number of possible patterns, making direct solution impractical for large instances.[22] To address the large number of variables, the problem is efficiently solved using column generation, as introduced by Gilmore and Gomory in their seminal 1961 work.[35] This technique starts with a restricted master problem—a linear programming relaxation over a subset of patterns—and iteratively generates new columns (cutting patterns) by solving a knapsack subproblem to maximize the reduced cost: maxiπiai\max \sum_i \pi_i a_i subject to iwiaiW\sum_i w_i a_i \leq W and ai0a_i \geq 0 integer, where πi\pi_i are dual prices from the master.[35] The process converges to the optimal LP solution, after which integer rounding or branch-and-price extensions yield near-optimal integer solutions.[22] For instances with large demands bib_i, the Gilmore-Gomory procedure provides a (1 + \epsilon)-approximation to the optimal integer solution for any fixed \epsilon > 0, leveraging the fact that the LP relaxation becomes nearly integral and rounding introduces negligible relative waste. This guarantee arises because high demand multiplicities ensure that the additional stock rolls needed for integrality are a small fraction of the total, distinguishing the problem from bin packing where demands are typically unit-sized.

Scheduling and Resource Allocation

The bin packing problem arises naturally in parallel machine scheduling, where the objective is to assign jobs to identical processors to minimize the makespan, defined as the completion time of the last job. In the standard notation P||C_max, n jobs each with processing time p_i must be non-preemptively scheduled on m identical machines, and the problem is equivalent to determining the minimum capacity T such that the jobs can be packed into at most m bins of size T. This connection allows bin packing techniques to provide lower bounds and approximation algorithms for scheduling; for instance, the NP-hardness of deciding whether all jobs fit within a given makespan T directly implies the NP-hardness of P||C_max when m is part of the input. A prominent approximation algorithm for P||C_max is the Longest Processing Time (LPT) rule, which sorts jobs in non-increasing order of processing times and assigns each job to the machine with the current smallest total load—mirroring the First Fit Decreasing (FFD) heuristic in bin packing. Graham showed that LPT guarantees a makespan at most \frac{4}{3} - \frac{1}{3m} times the optimal, establishing it as a (4/3 - 1/(3m))-approximation algorithm. This bound remains tight for certain instances, such as when job sizes lead to suboptimal packing similar to the classic bin packing example with items of size 1/2 + \epsilon and 1/3. In resource allocation contexts, such as distributing computational tasks across processors, LPT and related bin packing heuristics minimize makespan by efficiently balancing loads, ensuring no single processor is overburdened beyond necessary.[37] The optimal makespan C_{\max}^* satisfies the lower bound
Cmaxmax(i=1npim,maxipi), C_{\max}^* \geq \max\left( \frac{\sum_{i=1}^n p_i}{m}, \max_{i} p_i \right),
which parallels the fundamental bounds in bin packing: the total item size divided by bin capacity and the largest item size. This bound is computable in linear time and serves as a quick estimate for practical scheduling. In cloud computing, bin packing formulations address virtual machine (VM) placement, where VMs with resource demands (e.g., CPU, memory) are allocated to physical hosts to minimize active servers or balance loads across a data center. Online variants of bin packing, such as First Fit or Best Fit, are commonly applied for dynamic VM provisioning, reducing energy consumption by consolidating workloads onto fewer hosts while respecting capacity constraints.[38] For example, in large-scale environments like Amazon EC2, these heuristics approximate solutions to the multidimensional bin packing problem inherent in multi-resource allocation.

References

User Avatar
No comments yet.