bin packing algorithm

A Comprehensive List of Bin Packing Algorithms for Better Packing

Packing is kind of an integral part of shipping. But to get you packing right, you need to have a right, bin packing algorithm in place. With an algorithm, it becomes easy to work on the packing when advance technology helps to ease the management of numerous goods. With these baselines bin packing algorithms, the packaging problem in today’s world is minimized. Several tools come handy which explains the 3 D model demonstration of how bin packing can be executed.

What is Bin packing algorithm?

A bin packing algorithm refers to the algorithm dealing with the packing of different items with varied sizes into finite shipping boxes or bins. Using the algorithm, the packaging is simplified. Using the algorithm, the best possible solutions are arrived by :

1. Packing one of the containers as densely as possible ., and

2. By packing all the items into the least number of packages.

With these two possible methods, the overall shipping cost is reduced and also leads to cost-saving. As you know that efficient packing methods are the key to successful shipping and overall cost-saving option. Moreover, with inefficient packaging, it will cost you higher packaging material cost and also the shipping cost.

So, Why do we need to work on an algorithm for packing?

Most of the shippers are going to randomly pack the items in the box and then ship it. Most of them choose the bigger one first and then place the ones on the go. In this way, at times, some of the packages that could have saved some space and cost you less will be missed. To avoid the surcharging costs, it is ideal to go with an algorithm, which in turn reduces the overall cost in packaging and also ensures that the items are delivered sooner and without incurring much cost.

So how does the bin packing algorithm helps?

In the case of bin packing algorithm, the boxes are rotated in all the three ways ( length, breadth and height) to determine which way fitting is economical. Indeed manually this is quite slow and consumes lots of time and effort. Well, this can be efficiently done with the help of  Stamps.com Shipping Plugin with USPS Postage for WooCommerce plugin, which helps to pack items individually. The shipping plugin works with the packaging algorithm to simplify the packing and shipping methods automatically.

Let us look into various algorithms to understand how packing can efficiently be done.

Stack first packing

By stack-first algorithm, it means that the items are stacked one above the other, basically based on the length, breadth or width and the height of the boxes as well as the one into which they are being packed. In this algorithm, the dimensions of the item are compared with the box dimensions. Suppose, if you take the length into account, the length of the item is compared with the length of the box into which the item is packed. Then, if the length of the former is less, the item is placed in the box. Remaining items are stacked upon in the same way, side by side

Generally, when you consider a box dimension, there are three sides to consider length, width and heigh. Whenever a box is to be packed, the length is first considered, to the length of the box into which it should be packed.

Take a look at how Stack first algorithm works here :

Consider we have three items Item1, Item2 and Item3  with the following dimensions 5L x 4W x 3H, 4L x 3W x 3H and 3L x  3W x 3H respectively that need to be packed in a box.

Suppose if the box dimension is 14L x 8W x 10H.

WooCommerce Stamps.com | Step1 | Sample Box

If we consider stacking items based on length then ;

  • The length of Item1(5in) is compared with the length of the box which is 14in. Since the former is lesser in size, the item is placed in the box and the remaining length is calculated, which in this case is 9in(14in-5in).
  • In the same way, Item2(4in) and Item3(3in) can also be placed, since their length fits in the remaining length of the box.
  • Now the remaining space is 2in

WooCommerce Stamps.com | Step1 | Case1 - Taking Length

As you see, if there any item with length more than 2 in, then you cannot add the same in the box, but if it is less, then you can fit it into the box.

Let us consider stack first based on the width of the box

Consider the width of the items and the box to be packed in. The width of Item1(4in) is compared with the width of the box which is 8in. Since the former is lesser, the item is placed in the box and the remaining width is calculated, which is 4in(8in-4in). Next, the width of Item2(3in) is compared with the remaining width of the box(4in). Since there’s space available, the item is placed in the box.
The width of the Item3 is then compared with the remaining width(1in). Since there is no space for Item3, it will be packed in a different box, or packed individually. Hence the item needs to be packed in two different boxes for shipping.
WooCommerce Stamps.com | Step1 | Case2 - Taking Width

Stacking based on the height of the items

WooCommerce Stamps.com | Step1 | Case3 - Taking Height

As you can see, when item 1 is packed first, into the box, which is 3in, there enough space left (10-3=7 in). Next Item 2 is placed which is again 3 inches. Also, Item 3  is placed in the remaining 4 in. Now we are left with 1 in in the box. The remaining 1in has to go empty unless there is something that can be fit in.

Now the next way is flipping the box.

Flip the Box with Box dimension 14L x 10W x 8H

WooCommerce Stamps.com | Step2 | Sample Box

When flipped. The longest will be considered the length of the box and the rest will be with and height.

Now firstly stacking based on the length of the box: The length of Item1(5in) is compared with the length of the box(14in). Since the length of the box is lesser, the item is placed in the box and the remaining length is calculated, which in this case is 9in.
In the same way, Item2(4in) and Item3(3in) can also be placed, since their length fits in the remaining length of the box.
Now the remaining space is 2in as shown in the image :

WooCommerce Stamps.com | Step2 | Case1 - Taking Length

Stacking based on width with Box dimension 14L x 10W x 8H

The width of Item1(4in) is compared with the width of the box which is 10in. Since the width of Item 1 is lesser, the item is placed in the box and the remaining width is calculated, which is 6in. In the same way, Item2(3in) and Item3(3in) can also be placed, since their length fits in the remaining length of the box.
Finally, the box has now reached its limit and there is no remaining space left for other items.

WooCommerce Stamps.com | Step2 | Case2 - Taking Width

Stacking based on the Height of the box with Box dimension 14L x 10W x 8H

Here the height of Item1 is 3in which is then compared with the height of the box which is 8in. Since the height of the item is lesser, it is placed in the box and the remaining height is calculated, which is 5in. Next, we place the Item2 whose height is 3in. Since there’s space available, the item is placed in the box which is 2in, we cannot accommodate the third box whose height is 3 in. Hence, the item is packed in a different box or packed individually. The remaining space is 2in in the packing box.

Similarly, when again flipped, the box height is considered as the dimension for the stack-based filling.

Stacking based on Box dimension 8L x 10W x 14H

Upon flipping, the box looks like

WooCommerce Stamps.com | Step3 | Sample Box

Now When we try to fill the box using the stack-based algorithm :

Based on the length of Item1(5in), compared with the length of the box(8in). Since the length of the box is lesser, the item is placed in the box and the remaining length is calculated, which is 3in. Next, the length of Item2(4in) is compared with the remaining length of the box(3in). Since the item cannot fit, it is packed in a different box or packed individually.

Stacking items based on the width of Item1(4in), compared with the width of the box(10in). The item is placed in the box and the remaining width is calculated, which is 6in. In the same way, Item2(3in) and Item3(3in) can also be placed, since their length fits in the remaining length of the box. The box has now reached its limit and there is no remaining space left for other items.

Stacking items based on Height of Item1(3in) is compared with the height of the box(14in). Since the height of the item is lesser, it is placed in the box and the remaining height is calculated, which is 11in. Next, the height of Item2(3in) is compared with the remaining height of the box(11in). Since there’s space available, the item is placed in the box. Likewise, Item3(3in) is placed in the remaining space(8in). The remaining space in the box is 5in.

 Volume-based packing

When you consider volume-based packing, then you need to consider volume as the factor in whole. If you have a box with dimension (volume) then it will be used to pack the products (product dimensional volume) into the containers. Most products are packed in together for a single shipment.

Volume is calculated using the container dimensions. Products will be packed into the containers based on their volume and the containers maximum weight.

How do you work out a container’s volume?

This is done by Multiplying the dimensional units together.

Container: L 10 x W 10 x H 10= 1000

Product: 4 x 4 x 4 =64

Remaining volume of the container is= 936

Note : Products require dimensions and weight.

Box Packing in Volume-based packing

In here the items are packed concerning the volume of each product into the container depending on the container volume. If the items are not fitting in then the container is changed. Mostly the products are packed together. Here the volume that is the cubic weight is taken into consideration.

Weight-based – Volume-based packing

Weight Based- Regular sized items are grouped. The Container dimensions and the total weight of the shipment will be used for the packing and will determine the shipping quote altogether.

Weight-based packing

In here the products are packed in the box based on their weight only. Which means that this method is completely independent of the product dimensions. As soon as the total weight is under the defined Max Weight, all the products will be packed in one box. Once the weight exceeds the maximum weight limit, another box will be selected for packing additional products.

For example, suppose if your item weighs around 20kg, and you have three boxes with capacity 30, 20 and 18 kgs then you can either pack your item in the boxes with capacity 30 and 20kgs, but not in the one with 18kgs.

Volumetric weight-based packing

An ideal way to reduce your transportation cost is using the volumetric weight-based packing. In here, the charge is based on the volume rather than the weight. So totally it checks the space it occupies rather than the weight of the items.Volumetric weight-based is calculated as (length × width × height) / (dimensional factor).

How to implement the same using the Stamps Plugin in your WooCommerce store?

When you consider Stamps plugin for shipping on your eCommerce store, you can opt for three kinds of packing options.

Stamps parcel Packing || Bin packing algorithm

You can either pack into boxes with weights and dimensions, or pack item individually or even on a weight-based packing method.

For example, consider the use case :

Case 1: “Black Box ” single quantity. Product dimension 7x 11x .75 weight 20. and Case 2: “Black Box” quantity 20.

In the first case, the best fit found is this predefined box (d29).
“length” => “12.5”,
“width” => “9.5”,
“height” => “1”,
“weight” => “70”,
“online price” => “5.70”
In second case, it will getting packed to two predefined boxes (d22a, d17b)

Box 1:
“length” => “23.69”,
“width” => “11.75”,
“height” => “3”,
“weight” => “70”,
“online price” => “15.80”
Box 2:
“length” => “11”,
“width” => “8.5”,
“height” => “5.5”,
“weight” => “70”,
“online price” => “11.30”

So, 15.80 + 11.30 = 27.10

When you consider packing algorithm , Stamps plugin has a default volume-based packing algorithm and a stack base algorithm. You can chose which suits you the best.

If you choose weight-based: calculate shipping based on weight, then you few options that are explained above.bin packing algorithm

For example, you are considering to buy two items, one weighing 15 and the other 10. In here you select the parcel packing as weight-based and the maximum box limit is set to 10. If you want to choose the packing process as pack heavier items first, then you can see that, upon purchasing, the stamps will generate two packages for a single order.

bin packing algorithm

Suppose you want to pack items individually, irrespective of weight and any other dimension. If you are purchasing three items, then stamps plugin will generate three different packages.

bin pakcing

To Conclude :

So you can see, how ELEX Stamps.com Shipping Plugin with USPS Postage for WooCommerce can easily execute all kinds of bin packing algorithm done rightly. You can try various combinations to work out your packaging requirements and also ship your WooCommerce store products using the Stamps.

Further Reading

    Leave a Reply

    WordPress Image Lightbox Plugin