RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Solving the 2D Packing Problem

In 2D packing the goal is to fit as many items as possible into a specified area, without overlapping. Discover some packing problem variants, and explore some approaches you can use to solve one variation.

t's easy to list applications where computers leave humans in the dust. When it comes to complex mathematics, repetitive calculations, and tedious searches, even the most astute mathematician can't beat a good computer program.

However, there are also many applications where humans can easily surpass computers. For example, some classic problems that have only recently yielded to high-powered hardware and sophisticated algorithms are pattern matching applications such as face recognition, speaker-independent speech recognition, and chess.

Another problem that's usually easier to solve for people than computers is two-dimensional bin packing (2BP). The idea is that you have some sort of area or stock that you need to fill with as many items of given sizes and shapes as possible.

Figure 1. Rotated Arrangement: You can see that the only way to fit these five squares on the stock without an overlap is to rotate the center square.
For example, suppose you have several sheets of plywood from which you want to cut a set of shapes. The goal is to cut out the pieces using as few sheets as possible. If you were cutting 1x8 ft. strips from a 4x8 sheet of plywood, the problem would be easy, but when the shapes aren't regular, or the substrate isn't a multiple of the shape size, the problem becomes deceptively difficult, and has a huge number of variations. Some of the variations include:

  • You are allowed to rotate the pieces arbitrarily, allowing an infinite number of possible positions and orientations. Figure 1 shows five squares positioned on a larger square. The center square will not fit unless it's rotated as shown.
  • You are allowed to rotate the pieces—but only in certain restricted ways, such as in multiples of 90 degrees.
  • The pieces must have fixed orientations. For example, pieces might need to be oriented along the wood grain. If the stock is cloth, you might need to orient pieces along the cloth's pattern or weave. As an example, in one M*A*S*H episode Trapper John buys a pinstriped suit, but the tailor makes it with the stripes sideways. In such cases, you may be able to rotate the pieces by 180 degrees but not to other angles.
  • Rather than having fixed-size sheets of stock, you have a long continuous sheet such as a bolt of cloth. In this case, the goal isn't to use as few sheets as possible, but to use as little length as possible.
  • Pieces may be concave. For example, a series of crescent shapes could be nested inside each other to take up less room.
  • You are allowed to cut up the stock using only "guillotine cuts" that go from one side of the stock to the other. For example, suppose you need to cut up a piece of wood using a table saw that cannot cut corners.
  • You are loading objects into a truck. In addition to fitting as many objects in the truck as possible, you may also need to distribute their weight evenly. You may need to place heavier objects as close to the center as possible, or you may need to place heavy items near tie-down points.
The problem is difficult enough in two dimensions, but the problem gets even trickier in three-dimensional variations. Imagine trying to pack several hundred experiments inside the space shuttle. Or imagine trying to arrange hundreds of thousands of items on a cargo ship. With so many possible arrangements, it's no wonder shipping companies simplify the problem. For example, container ships carry thousands of huge metal containers that all have the same size and shape, regardless of their contents. You may still need to worry about weight distribution, but having fixed-size regular shapes, makes the packing problem much more manageable.

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date