How Binacle.Net Works - ChrisMavrommatis/Binacle.Net GitHub Wiki

Contents

Binacle.Net employs specialized algorithms and techniques to address different aspects of the bin packing problem. Below are the key sections:


Algorithms

In order to solve the Bin Packing problem in real time Binacle.Net employs heuristic algorithms.

While heuristic algorithms like FFD are not guaranteed to always find the perfect solution (i.e., 100% accuracy), Binacle.Net is designed to ensure that when it identifies that a bin is suitable, it will invariably accommodate all items. However, it's worth noting that due to its heuristic nature, there are instances where items might technically fit into a bin, but the algorithm may not recognize it as the best option.

This trade-off enables faster, real-time calculations while maintaining a high success rate for practical use cases.

First Fit Decreasing (FFD)

Binacle.Net implements a hybrid variant of the First Fit Decreasing (FFD) algorithm, a widely adopted heuristic for bin packing problems. This algorithm sorts items in decreasing order of size and places each item into the first available space within a single bin that can accommodate it.

FFD strikes a balance between packing efficiency and computational performance, outperforming both WFD and BFD in speed while maintaining strong packing results. Its efficiency makes it particularly effective for real-time applications.

Worst Fit Decreasing (WFD) (Experimental)

The Worst Fit Decreasing (WFD) algorithm is a hybrid heuristic currently in the experimental stage, accessible via the v3 API endpoint. Like FFD and BFD, it sorts items in decreasing order of size but deliberately places each item in the least optimal (worst) available space within a single bin—specifically, where it leaves the most unused space after placement.

Although WFD generally underperforms compared to FFD and BFD in both packing efficiency and computational speed, it can outperform them in niche scenarios where spreading items out leads to better results, such as when minimizing dense packing is beneficial.

Best Fit Decreasing (BFD) (Experimental)

The Best Fit Decreasing (BFD) algorithm, also in the experimental stage and available via the v3 API endpoint, is another hybrid heuristic. Like FFD and WFD, it sorts items in decreasing order of size but aims to place each item in the most optimal (best) available space within a single bin—specifically, where it leaves the least remaining space after placement.

BFD often achieves superior packing efficiency compared to both FFD and WFD, though its computational performance falls between the two. However, its effectiveness can vary, and in some scenarios, it may underperform relative to the other algorithms depending on the specific arrangement of items within the bin.


Functions

Binacle.Net provides two core functions designed to meet different packing needs: Fitting and Packing.

Fitting

The Fitting function checks whether a specific set of items can fit into a predefined bin. This quick, real-time check is ideal for determining if all items in an order can be packed together before proceeding with checkout or shipping. The function returns a result that indicates which items fit and which do not, providing clear feedback on whether the bin is suitable.

Packing

The Packing function goes beyond basic fitting by not only determining which items fit, but also tracking the precise location of each item within the bin. If not all items can fit, the function will continue optimizing the arrangement to pack as many items as possible. It returns detailed information on which items were successfully packed, along with their exact positions, as well as which items could not be packed.

This is especially useful for optimizing space and providing step-by-step packing instructions, helping fulfillment teams package items more efficiently and accurately.

[!Note] Both the Fitting and Packing functions support multiple bins in a single request.

The API will return results for each bin in one response, reducing the need for multiple API calls and improving overall efficiency in your packing workflow.


Conclusion

By leveraging heuristic algorithms like First Fit Decreasing and offering both Fitting and Packing functions, Binacle.Net provides a robust, real-time solution for bin packing problems. These features enable fast and efficient packing, even if they sometimes trade off perfect accuracy for speed.

The Fitting function is ideal for quick validation, ensuring items fit in bins before proceeding with the order process, while the Packing function provides precise positioning, optimizing packing arrangements and space usage.

Both functions support handling multiple bins in one request, streamlining operations and reducing complexity. This flexibility makes Binacle.Net a practical tool for various packing and fulfillment scenarios, ensuring efficiency without sacrificing accuracy where it matters most.