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
225 questions
0
votes
0 answers

C++ Bin Packing Implementation using First Fit

I'm doing a project for university but I encountered an exception which I don't understand. I'm using S.Sahni algorithms, so mostly I've got the code from his book. What I'm trying to do is to implement the Bin Packing problem with First Fit while…
0
votes
2 answers

Bin packing bruteforce without duplicates and empty bins

I want to find all ways to distribute n elements to b bins but without "duplicates" and empty bins. Example If I have n = 3 elements and b = 2 bins and apply the bruteforce method from this stackoverflow thread Bin packing bruteforce method I get…
conscho
  • 165
  • 1
  • 8
0
votes
0 answers

Sorting Boxes for optimal bin packing

I am currently working on a Bin Packing program and need to know what would be the most efficient way of getting boxes (arbitrary width, length, and height) to be sorted in the manner below? Biggest (Cube-like) shaped boxes then Tallest (Thin-like)…
Kay
  • 77
  • 1
  • 8
0
votes
2 answers

How to determine Boundary Cut Utilization MATLAB?

Working on 2D Rectangular Nesting. Need to find the utilization percentage of the material. Assuming i have the length, breadth, left-bottom position of each rectangle. What is the best way to determine the Boundary-Cut Utilization? Objective:- To…
Santhan Salai
  • 3,848
  • 17
  • 29
0
votes
1 answer

Gurobi C# optimization of box packing

I have three products and five boxes: var products = new string[] { "A", "B", "C"}; var boxes = new string[] { "1", "2", "3" ,"4","5"}; and dimensions are : double[,] boxDimensions = new double[,] {{8}, …
Adem Aygun
  • 408
  • 2
  • 6
  • 17
0
votes
1 answer

How to distribute a list of rectangles of varying width and height, maximizing distance between items, inside a rectangular container?

I need a function that takes in two inputs: a bounding box with a width and height an array of rectangular items with varying width and height (all smaller than the bounding box) It would output an array of the same items with an additional…
CheapSteaks
  • 4,091
  • 3
  • 28
  • 46
0
votes
0 answers

bin packing boolean if bin is full

I'm trying to implement a bin packing algorithm using Next Fit online. So I don't know the size of the boxes before hand. Anyway I had a Box class with height and width. A column class which represents and stack of boxes and a Truck class which…
0
votes
1 answer

Looking for an algorithm that will show how to fit the most boxes in a container

I've been interested in writing an application that will show how to fit boxes (of random dimensions) in a container so there is as little space as possible left. A real life example would be something that would tell you how to use the most space…
Abe Miessler
  • 75,910
  • 89
  • 276
  • 451
0
votes
2 answers

Does this bin-packing variant have a name?

I have what sounds like a typical bin-packing problem: x products of differing sizes need to be packed into y containers of differing capacities, minimizing the number of containers used, as well as minimizing the wasted space. I can simplify the…
John
  • 168
  • 9
0
votes
1 answer

First-Fit Bin Packing Algorithm Skipping Numbers

I'm trying to do First-Fit bin packing. This is the code I've written with explanations for each line as comments: private void runFirstFit(ActionEvent event) { // The counters int i; int j = 0; // The boolean packingComplete =…
user3063257
  • 119
  • 1
  • 4
  • 11
0
votes
0 answers

given a random set of boxes and a set of spaces, how can you find the optimal combination?

I have kind of an interesting assignment and I'm not sure where to begin. Imagine you have a set of spaces (all same size) and a set of boxes (variable integer size, 1 or 2 or 3 units of volume). Each space can hold 4 units of volume. Given a…
metinoheat
  • 108
  • 10
0
votes
0 answers

Algorithm for arranging patients; simpler version of bin packing

I am currently working on a scheduling tool where I have multiple locations (bins) each with differing seating capacities where I need to place patients. The patients are either positive or negative. I cannot mix positive and negative patients in…
Copers
  • 35
  • 5
0
votes
1 answer

Finding multiple solutions to bin packing

I have 3 boxes of variable size: A: 5, B: 3, C: 6 I have items of size a: 1, b: 2, c: 2, d: 3, e: 5 I could obviously fit them in the following pattern: A: a, b, c B: d C: e but you could also do it like this: A: e B: a, b C: c, d Is there a way…
Pete Hamilton
  • 7,102
  • 6
  • 31
  • 57
0
votes
1 answer

Simplified rectangle packing algorithm. Being able to pick from bigger pool of shapes.

I have a rectangle with 200 width and 100 height. I have a mix pool of 50 rectangles and boxes. The rectangles comes in shapes like 20x40, and 40x20. The boxes will come in shapes of 20x20 and 40x40. So lets say If I want to fit the highest number…
Alex Coner
  • 15
  • 4
0
votes
1 answer

Bin packing - exact np-hard exponential algorithm

I wrote a heuristic algorithm for the bin packing problem using best-fit aproach, itens S=(i1,...,in), bins size T, and a want to create a real exact exponential algorithm witch calculates the optimal solution(minimum numbers of bins to pack all the…
MeatPuppet
  • 13
  • 4
1 2 3
14
15