/3D-Bin-Packing-Algorithm

This algoritham can Use for box packing process, to determine how to pack the box without wasting space.

Primary LanguageTypeScript

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Coverage Discord Backers on Open Collective Sponsors on Open Collective Support us

3D Bin PackingAlgorithm

The 3D Bin Packing Algorithm is a powerful solution designed to optimize the efficient packing of objects within three-dimensional containers. This algorithm is particularly useful in scenarios where maximizing space utilization is crucial, such as in logistics, manufacturing, or resource allocation.

NPM Version

Sample Request

{
  "maxBin": {
      "width":100,
      "height" : 100,
      "length" : 100,
      "weight" : 22
  },
  "box": {
      "width":10,
      "height" : 15,
      "length" : 20,
      "weight" : 5
  },
  "numBoxes": 10
}

Sample Response

{
    "result": [
        {
            "width": 100,
            "length": 100,
            "height": 100,
            "weight": 20,
            "totalWidth": 10,
            "totalHeight": 60,
            "totalLength": 20,
            "boxes": [
                {
                    "index": 0,
                    "position": {
                        "x": 0,
                        "y": 0,
                        "z": 0
                    }
                },
                {
                    "index": 1,
                    "position": {
                        "x": 0,
                        "y": 0,
                        "z": 15
                    }
                },
                {
                    "index": 2,
                    "position": {
                        "x": 0,
                        "y": 0,
                        "z": 30
                    }
                },
                {
                    "index": 3,
                    "position": {
                        "x": 0,
                        "y": 0,
                        "z": 45
                    }
                }
            ]
        },
        {
            "width": 100,
            "length": 100,
            "height": 100,
            "weight": 20,
            "totalWidth": 10,
            "totalHeight": 60,
            "totalLength": 20,
            "boxes": [
                {
                    "index": 4,
                    "position": {
                        "x": 0,
                        "y": 0,
                        "z": 0
                    }
                },
                {
                    "index": 5,
                    "position": {
                        "x": 0,
                        "y": 0,
                        "z": 15
                    }
                },
                {
                    "index": 6,
                    "position": {
                        "x": 0,
                        "y": 0,
                        "z": 30
                    }
                },
                {
                    "index": 7,
                    "position": {
                        "x": 0,
                        "y": 0,
                        "z": 45
                    }
                }
            ]
        },
        {
            "width": 100,
            "length": 100,
            "height": 100,
            "weight": 10,
            "totalWidth": 10,
            "totalHeight": 30,
            "totalLength": 20,
            "boxes": [
                {
                    "index": 8,
                    "position": {
                        "x": 0,
                        "y": 0,
                        "z": 0
                    }
                },
                {
                    "index": 9,
                    "position": {
                        "x": 0,
                        "y": 0,
                        "z": 15
                    }
                }
            ]
        }
    ]
}

Installation

$ npm install

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod