Bin packing problem
Encyclopedia
In computational complexity theory
Computational complexity theory
Computational complexity theory is a branch of the theory of computation in theoretical computer science and mathematics that focuses on classifying computational problems according to their inherent difficulty, and relating those classes to each other...

, the bin packing problem is a combinatorial
Combinatorics
Combinatorics is a branch of mathematics concerning the study of finite or countable discrete structures. Aspects of combinatorics include counting the structures of a given kind and size , deciding when certain criteria can be met, and constructing and analyzing objects meeting the criteria ,...

 NP-hard
NP-hard
NP-hard , in computational complexity theory, is a class of problems that are, informally, "at least as hard as the hardest problems in NP". A problem H is NP-hard if and only if there is an NP-complete problem L that is polynomial time Turing-reducible to H...

 problem. In it, objects of different volumes must be packed into a finite number of bins of capacity V in a way that minimizes the number of bins used.

There are many variations
Packing problem
Packing problems are a class of optimization problems in mathematics which involve attempting to pack objects together , as densely as possible. Many of these problems can be related to real life packaging, storage and transportation issues...

 of this problem, such as 2D packing, linear packing, packing by weight, packing by cost, and so on. They have many applications, such as filling up containers, loading trucks with weight capacity, creating file backup in removable media and technology mapping in Field-programmable gate array
Field-programmable gate array
A field-programmable gate array is an integrated circuit designed to be configured by the customer or designer after manufacturing—hence "field-programmable"...

 semiconductor chip design.

The bin packing problem can also be seen as a special case of the cutting stock problem
Cutting stock problem
The cutting-stock problem is an optimization problem, or more specifically, an integer linear programming problem. It arises from many applications in industry. Imagine that you work in a paper mill and you have a number of rolls of paper of fixed width waiting to be cut, yet different customers...

. When the number of bins is restricted to 1 and each item is characterised by both a volume and a value, the problem of maximising the value of items that can fit in the bin is known as the knapsack problem
Knapsack problem
The knapsack problem or rucksack problem is a problem in combinatorial optimization: Given a set of items, each with a weight and a value, determine the count of each item to include in a collection so that the total weight is less than or equal to a given limit and the total value is as large as...

.

Despite the fact that it is NP-hard
NP-hard
NP-hard , in computational complexity theory, is a class of problems that are, informally, "at least as hard as the hardest problems in NP". A problem H is NP-hard if and only if there is an NP-complete problem L that is polynomial time Turing-reducible to H...

, optimal solutions to very large instances can be produced with sophisticated algorithms. In addition, many heuristics have been developed: 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 Θ
Big O notation
In mathematics, big O notation is used to describe the limiting behavior of a function when the argument tends towards a particular value or infinity, usually in terms of simpler functions. It is a member of a larger family of notations that is called Landau notation, Bachmann-Landau notation, or...

(n log n) time, where n is the number of elements to be packed. The algorithm can be made much more effective by first sorting the list of elements 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 (Lewis, 2009).

Formal statement

Given a bin size and a list of sizes of the items to pack,
find an integer and a -partition
Partition of a set
In mathematics, a partition of a set X is a division of X into non-overlapping and non-empty "parts" or "blocks" or "cells" that cover all of X...

  of such that for all

A solution is optimal if it has minimal . The -value for an optimal solution is denoted OPT below.

First-fit algorithm

This is a very straightforward greedy
Greedy algorithm
A greedy algorithm is any algorithm that follows the problem solving heuristic of making the locally optimal choice at each stagewith the hope of finding the global optimum....

 approximation algorithm
Approximation algorithm
In computer science and operations research, approximation algorithms are algorithms used to find approximate solutions to optimization problems. Approximation algorithms are often associated with NP-hard problems; since it is unlikely that there can ever be efficient polynomial time exact...

. The algorithm processes the items in arbitrary order. For each item, it attempts to place the item in the first bin that can accommodate the item. If no bin is found, it opens a new bin and puts the item within the new bin.

It is rather simple to show this algorithm achieves an approximation factor
APX
In complexity theory the class APX is the set of NP optimization problems that allow polynomial-time approximation algorithms with approximation ratio bounded by a constant...

 of 2. This is due to the observation that at any given time, it is impossible for 2 bins to be at most half full. The reason is that if at some point a bin was at most half full, meaning it has at least a space of V / 2, the algorithm will not open a new bin for any item whose size is at most V / 2. Only after the bin fills with more than V / 2 or if an item with a size larger than V / 2 arrives, the algorithm may open a new bin.

Thus if we have B bins, at least B − 1 bins are more than half full. Therefore . Because is a lower bound of the optimum value OPT, we get that B − 1 < 2OPT and therefore B ≤ 2OPT. See analysis below for better approximation results.

Sample algorithm


binpackFFd(S,n,bin)
float[] used = new float[n + 1];
//used[j] is the amount of space in bin j already used up.
int i, j;
Initialize all used entries to 0.0
Sort S into descending(nonincreasing)order, giving the sequence S1 >= S2 >= ... >= Sn.
for(i = 1; i <= n; i++)
//Look for a bin in which s[i] fits.
for(j = 1; j <= n; j++)
if (used[j]+si<+1.0)
bin[i] = j;
used[j] += si;
break; //exit for(j)
//continue for(i).

http://groups.google.com/group/sci.math/browse_thread/thread/df219169f1497e6d#

Analysis of approximate algorithms

The best fit decreasing and first fit decreasing strategies are among the simplest heuristic algorithms for solving the bin packing problem. They have been shown to use no more than 11/9 OPT + 1 bins (where OPT is the number of bins given by the optimal solution). The simpler of these, the First Fit Decreasing (FFD) strategy, operates by first sorting the items to be inserted in decreasing order by volume, and then inserting each item into the first bin in the list with sufficient remaining space. Without the sorting step, we only achieve the looser bound of 17/10 OPT + 2. Sometimes, however, one does not have the option to sort the input, for example, when faced with an online
Online algorithm
In computer science, an online algorithm is one that can process its input piece-by-piece in a serial fashion, i.e., in the order that the input is fed to the algorithm, without having the entire input available from the start. In contrast, an offline algorithm is given the whole problem data from...

 bin packing problem. In 2007, it was proved that the bound 11/9 OPT + 6/9 for FFD is tight. MFFD (a variant of FFD) uses no more than 71/60 OPT + 1 bins (i.e. bounded by about 1.18×opt, compared to about 1.22×opt for FFD). In 2010, an upper bound for the asymptotic performance ratio was decreased to 17/10 OPT + 7/10 for FF and for the absolute performance ratio - to 12/7 OPT.

For all ε > 0, Bin Packing is hard to approximate within 3/2 - ε. If such approximation exists, one could partition n non-negative numbers into two sets with the same sum in polynomial time. However, this problem is also known to be NP-hard. It is therefore impossible to propose a polynomial-time approximation scheme
Polynomial-time approximation scheme
In computer science, a polynomial-time approximation scheme is a type of approximation algorithm for optimization problems ....

 (PTAS) to the bin packing problem. Alternatively, it is possible to find a solution for any 0 < ε ≤ 1/2 in polynomial time using at most (1 + 2ε)OPT + 1 bins. This approximation type is known as asymptotic PTAS.

See also

  • If the number of bins is to be fixed or constrained, and the size of the bins is to be minimised, that is a different problem which is equivalent to the Multiprocessor scheduling problem
    Multiprocessor scheduling
    In computer science, multiprocessor scheduling is an NP-complete optimization problem. The problem statement is: "Given a set J of jobs where job ji has length li and a number of processors mi, what is the minimum possible time required to schedule all jobs in J on m processors such that none...

  • Packing problem
    Packing problem
    Packing problems are a class of optimization problems in mathematics which involve attempting to pack objects together , as densely as possible. Many of these problems can be related to real life packaging, storage and transportation issues...

  • Partition problem
    Partition problem
    In computer science, the partition problem is an NP-complete problem. The problem is to decide whether a given multiset of integers can be partitioned into two "halves" that have the same sum...

  • Subset sum problem
  • Best fit
    Curve fitting
    Curve fitting is the process of constructing a curve, or mathematical function, that has the best fit to a series of data points, possibly subject to constraints. Curve fitting can involve either interpolation, where an exact fit to the data is required, or smoothing, in which a "smooth" function...


External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK