/3D-Bin-Packing-Text-Based-Python-Script

Simple python script that simulates the packaging of rectangular boxes of any size.

Primary LanguagePythonThe UnlicenseUnlicense

3D bin-packing - text based python script

Simple python script that simulates the packaging of rectangular boxes of any size.

Table of contents

General info

This simple and intuitive script allows you to use the 3D bin-packing simulation in an easier way. By writing the right keyword you can launch a certain action (like create bin, add item, pack items,..).
You can find the algorithm and objects (Bin, Item, Item_List) in _3dbp.py, run text_based_script.py for a simple terminal UI and check examples directory if you want to see some examples about how can you use the code in your projects.
The algorithm doesn't offer the optimal solution sometimes but the average wasted space is below 5% which is pretty good for my needs (given that it's a NP hard problem).

Graphical version

Also, I developed a graphic version of 3D bin-packing that uses the algorithm mentioned above.
3D Bin Packing Graphic Version

Technologies

  • Python 3.8.3
  • Modules:
    • copy
    • math

Setup

Bin and Items dimensions need to be positive integers.
python text_based_script.py - to run the terminal UI

Purpose

This open source project is meant to provide an approximately optimal solution for the 3D bin packing problem.
It can be used for various things:

  • deposit space management
  • cargo vehicle space management (keep in mind that this algorithm doesn't take into account the boxes weight)
  • others (Example: I needed it for a game feature)

Examples of use

You can see some example code in example scripts from examples directory.
As I mentioned I already developed a graphic version of 3D bin-packing (check here 3D Bin Packing Graphic Version).
But if you don't want to install the packages or to use the executable, you can represent the output data by yourself:

  • Use pen and paper (kind of weird and not environmentally friendly:), I don't recommend)
  • Use a 3D modeling web application (Example: SketchUp)
  • Use some unusual ways (lego pieces, cubic shapes)

Sources

The strategy is based on Erick Dube and Leon Reeves Kanavathy research Optimizing Three-Dimensional Bin Packing Through Simulation

Other information

Contact