Git Product home page Git Product logo

guillotine-packer's Introduction

guillotine-packer

styled with prettier Travis Coverage Status semantic-release

What is this?

This is a bin packing implementation based off of this fantastic paper. Originally developed as part of Part Placer for the woodworking community, however it can be used for all sorts of bin packing applications! Guillotine based algorithms translate well for many real-world material use cases, as they nicely balance outputs that can easily performed on machinery with efficient material use.

Getting Started

Install

npm install guillotine-packer

Usage

import { packer } from 'guillotine-packer'

  const result = packer({
    binHeight: 30,
    binWidth: 30,
    items: [
      {
        name: 'test2',
        width: 20,
        height: 20
      } as Item,
      {
        name: 'test',
        width: 20,
        height: 20
      } as Item
    ]
  })

  /* OUTPUT:

  Array [
  Array [
    Object {
      "bin": 1,
      "height": 20,
      "item": Object {
        "name": "test2",
      },
      "width": 20,
      "x": 0,
      "y": 0,
    },
    Object {
      "bin": 1,
      "height": 20,
      "item": Object {
        "name": "test",
      },
      "width": 20,
      "x": 20,
      "y": 0,
    },
  ],
]

  */

Parameters

Inputs
Property Default Description
binHeight undefined required Height of the bin we will be packing the items into
binWidth undefined required Width of the bin we will be packing the items into
items undefined required Array of items. Each item should have a width and height property. Additional properties will be included in the item property of the results
Options
Option Default Description
kerfSize 0 The size of the blade kerf to account for when splitting rectanges
sortStrategy undefined SortStrategy to use. Undefined will try all strategies and pick which performs the best.
splitStrategy undefined SplitStrategy to use. Undefined will try all strategies and pick which performs the best.
selectionStrategy undefined SelectionStrategy to use. Undefined will try all strategies and pick which performs the best.
allowRotation true Whether items may be rotated. If true, items will be rotated if doing so maximizes the offcut size.

๐Ÿป

guillotine-packer's People

Contributors

dependabot[bot] avatar tyschroed avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

guillotine-packer's Issues

Not optimizing properly

Hi Tyler,

Thanks for creating such an awesome piece of software. I tried this out and it is something that could be very useful for us internally. However, I am facing certain issues with regards to optimization.

We have been using MaxCut optimization software so far and I tried out the data of one of our project with this library and on one of the materials I see that the optimization is not optimal and there is a wastage of one sheet.

If you see the below image:

6OK3EGN

MaxCut does this in 5 sheets whereas guillotine packer takes 6. You can clearly see that there is a lot of wastage space and the earlier sheets are not fully used.

In terms of the settings, I have only set allowRotation to true.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.