Questions tagged [bin-packing]

In the bin packing problem, objects of different volumes must be packed into a finite number of bins or containers each of volume V in a way that minimizes the number of bins used. In computational complexity theory, it is a combinatorial NP-hard problem.

From wikipedia

In the bin packing problem, objects of different volumes must be packed into a finite number of bins or containers each of volume V in a way that minimizes the number of bins used. In computational complexity theory, it is a combinatorial NP-hard problem.

There are many variations 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 constraints, creating file backups in removable media and technology mapping in Field-programmable gate array semiconductor chip design. 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 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.

Despite the fact that the bin packing problem has an NP-hard computational complexity, optimal solutions to very large instances of the problem 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 Θ(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.1

An interesting 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[2] 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 the space sharing fits into a hierarchy, as is the case with memory sharing in virtual machines, the bin packing problem can be efficiently approximated.

  1. Lewis, R. (2009), "A General-Purpose Hill-Climbing Method for Order Independent Minimum Grouping Problems: A Case Study in Graph Colouring and Bin Packing", Computers and Operations Research 36 (7): 2295–2310, doi:10.1016/j.cor.2008.09.004
  2. Sindelar, Michael; Sitaraman, Ramesh; Shenoy, Prashant (2011), "Sharing-Aware Algorithms for Virtual Machine Colocation", Proceedings of 23rd ACM Symposium on Parallelism in Algorithms and Architectures (SPAA), San Jose, CA, June 2011: 367–378
280 questions
7
votes
3 answers

2D bin packing on a grid

I have an n × m grid and a collection of polyominos. I would like to know if it is possible to pack them into the grid: no overlapping or rotation is allowed. I expect that like most packing problems this version is NP-hard and difficult to…
7
votes
2 answers

Extreme point based-packing algorithm (3D)

I am trying to implement a 3D packing algorithm using the extreme point-based approach. The paper which introduced this approach can be seen here: Extreme Point-Based Heuristics for Three-Dimensional Bin Packing At the end of the paper there is also…
Thomas D.
  • 1,031
  • 6
  • 17
7
votes
3 answers

Solving task scheduling or bin-packing optimizations in R

I have an optimisation issue. It's about a product that contains 20 parts (the order of producing doesn't matter). I've got 3 similar machine that can produce all 20 parts. I've got the 20 parts represented in minutes (ie. it takes 3min to produce…
S12000
  • 3,345
  • 12
  • 35
  • 51
6
votes
4 answers

Fair product distribution algorithm

Here is my problem: There are n companies distributing products. All products should be distributed in k days Distributing products of company Ci should be consecutive - it means that it can be distributed on days 2,3,4,5 but not 2,3,6,7 number of…
dfens
  • 5,413
  • 4
  • 35
  • 50
5
votes
2 answers

Algorithm needed for distributing rectangles evenly within another rectangle

I am looking for an algorithm that can help distribute different sized rectangles within a larger rectangle while minimizing overlapping. I have looked at bin packing algorithms, but they seem to minimize the amount of space between rectangles (in…
howardr
  • 323
  • 1
  • 6
5
votes
2 answers

Bin Packing: Set amount on bins, want to minimize the max bin weight

Given n bins of infinite capacity, I want to pack m items into them (each with a specific weight), whilst minimizing the weight of the heaviest bin. This isn't a traditional bin packing / knapsack problem where a bin has a finite capacity and you…
user593062
  • 1,593
  • 4
  • 15
  • 24
5
votes
3 answers

Dividing a list of numbers into roughtly equal totals

I'm aware that there probably isn't a "perfect" solution to my question (this sounds like a variation of the knapsack or the bin packing problem), but here's my scenario: I want to divide a list of SQL database tables into n (let's say 7) roughly…
BradC
  • 39,306
  • 13
  • 73
  • 89
5
votes
3 answers

What kind of algorithm? (Knapsack, Bin Packing!?)

The Problem is the following: You have n trip lengths in km which should be divided among m number of days such that the maximum sum of lengths per day is minimized. E.g. The Trip lengths [1,5,2,6,8,3,2] divided among 3 days result in [1,5,2] [6]…
Igl3
  • 4,900
  • 5
  • 35
  • 69
4
votes
1 answer

Distribute large quantities over multiple rows

I have a simple Order table and one order can have different products with Quantity and it's Product's weight as…
JackFrost
  • 200
  • 1
  • 2
  • 16
4
votes
2 answers

Python: How to get all possible bin combinations from a set of data with a weight limit?

I have a list of numbers which all correspond to items of different weight: weights = [50, 40, 30, 100, 150, 12, 150, 10, 5, 4] I need to split the values into two bins with the caveat that the bin sum total cannot exceed 300. e.g. The simplest one…
Stuchfield
  • 53
  • 4
4
votes
3 answers

Allocation optimization problem using python

I have a list of sectors each with certain capacity. For instance: Sectors = { "1A": 80, "1B": 20, "2A": 10, "3A": 50, "3B": 20, "3C": 110 } I have also a list of teams each with certain amount of…
4
votes
2 answers

Measurement for intersection of 2 irregular shaped 3d object

I am trying to implement an objective function that minimize the overlap of 2 irregular shaped 3d objects. While the most accurate measurement of the overlap is the intersection volume, it's too computationally expensive as I am dealing with complex…
Susie
  • 287
  • 1
  • 13
4
votes
1 answer

Algorithm that is a combination of the continuous knapsack problem and the variable size bin packing problem

I'm trying to solve a problem (in php, but programming language doesn't matter). I'm having a n number of persons that have paid money, and I have got a m number of persons that are going to pay the same amount as the sum of what the n number of…
jonepatr
  • 7,769
  • 7
  • 30
  • 53
4
votes
4 answers

A new Bin-packing?

I'm looking in to a kind-of bin-packing problem, but not quite the same. The problem asks to put n items into minimum number of bins without total weight exceeding capacity of bins. (classical definition) The difference is: Each item has a weight…
4
votes
1 answer

Packing regular polygons into square

I am trying to figure out whether given those constraints regular 2D packing problem can be simplified. You have n regular s-sided polygons for s between 3 and 12. All of them have the same side length. We need to minimise the area of bounding…
1
2
3
18 19