Giter Site home page Giter Site logo

greedypacker's Introduction

Two Dimensional Bin Packing

Build Status Coverage Status

Solomon Bothwell

[email protected]

Maximal Rectangle Rendering

A 2D bin packing library based on on Jukka Jylänki's article "A Thousand Ways to Pack the Bin - A Practical Approach to Two-Dimensional Rectangle Bin Packing."

This library is intended for offline packing. All algorithms heuristics and optimizations from Jukka's article are included.

A web demo made with Flask and ReactJS is available "here" Packing performance varies drastically with different combinations of optimizations and datasets, so its important to under the settings and test a variety of them.

Example Usage:

In [1]: import greedypacker

In [2]: M = greedypacker.BinManager(8, 4, pack_algo='shelf', heuristic='best_width_fit', wastemap=True, rotation=True)

In [3]: ITEM = greedypacker.Item(4, 2)

In [4]: ITEM2 = greedypacker.Item(5, 2)

In [5]: ITEM3 = greedypacker.Item(2, 2)

In [6]: M.add_items(ITEM, ITEM2, ITEM3)

In [7]: M.execute()

In [8]: M.bins
Out[8]: [Sheet(width=8, height=4, shelves=[{'y': 2, 'x': 8, 'available_width': 0, 'area': 6, 'vertical_offset': 0, 'items': [Item(width=5, height=2, x=0, y=0)]}, {'y': 2, 'x': 8, 'available_width': 4, 'area': 8, 'vertical_offset': 2, 'items': [Item(width=4, height=2, x=0, y=2)]}])]

Algorithms

General Optional Parameters:

All optimizations are passed in as keyword arguments when the GreedyPacker instance is created:

Item Rotation

Item rotation can be disabled with the keyword argument rotation=False

Item Pre-Sort

Items can be pre-sorted according to a number of settings for the 'sorting_heuristic' keyword argument:

  • ASCA: Sort By Area Ascending
  • DESCA: Sort By Area Descending (This is the default setting)
  • ASCSS: Sort By Shorter Side Ascending
  • DESCSS: Sort By Shorter Side Descending
  • ASCLS: Sort By Longer Side Ascending
  • DESCLS: Sort By Longer Side Descending
  • ASCPERIM: Sort By Perimeter Ascending
  • DESCPERIM: Sort By Perimeter Descending
  • ASCDIFF: Sort by The ABS Difference Between Sides Ascending
  • DESCDIFF: Sort By The ABS Difference Between Sides Descending
  • ASCRATIO: Sort By The Ratio of The Sides Ascending
  • DESCRATIO: Sort By The Ratio of The Sides Descending
  • False: Pack in the order added to the binmanager
Algorithm Specific optmizations/settings:

See the algorithm specific pages linked above.

install notes

Requires Python>=3.0.

tests

python -m unittest test

greedypacker's People

Contributors

solomon-b avatar pyrige avatar ransomw avatar

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.