• This repository has been archived on 20/Sep/2021
  • Stars
    star
    179
  • Rank 214,039 (Top 5 %)
  • Language
    Python
  • License
    Other
  • Created over 7 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

2D Bin Packing Algorithms

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

"Shelf"
"Guillotine"
"Maximal Rectangles"
"Skyline"

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

More Repositories

1

lambda-calculus-hs

Single file Lambda Calculus implementations demonstrating various type system features and interpretation techniques
Haskell
42
star
2

nixos-config

Homelab managed wtih Nix Flakes
Nix
20
star
3

HowardLang

An interpreted lambda calculus with Algebraic and Recursive Types.
Haskell
18
star
4

monoidal-functors

A library encoding monoidal functors and related structures in Haskell.
Haskell
16
star
5

kindly-functors

A category polymorphic `Functor` typeclass.
Haskell
11
star
6

hmud

A mud server written in haskell
Haskell
8
star
7

hcatlab

An exploration of the category Hask
Haskell
7
star
8

titan

A Gemini Protocol Server
Haskell
6
star
9

blog.cofree.coffee

My Blog
HTML
4
star
10

metric-trees

Haskell
4
star
11

lambda-calculus-rs

Learning Rust via implementing the lambda cube
Rust
4
star
12

SimpleLisp

A small Lisp implementation based on John McCarthy's 1960 paper "Recursive Functions of Symbolic Expressions and Their Computation by Machine, Part I"
Haskell
4
star
13

profunctor-optics

An implementation of profunctor optics :)
Haskell
3
star
14

fudgets

A copy of Fudgets so that I can more easily include it as a dependency in a cabal.project file
Haskell
3
star
15

graded-monads

Graded Monads with a QualifiedDo interface
Haskell
2
star
16

jwt-config-generator

A small script for generating signed JWT Tokens and JWTConfig Objects for Hasura.
Nix
2
star
17

Algebra

Proving algebraic properties with Idris
Idris
1
star
18

web-server

Common web service stub for various projects.
Haskell
1
star
19

Cellular

Cellular Automata experiments in Idris
Idris
1
star
20

yampy-cube-clone

A reimplementation of Konstantin Zudov's Yampy Cube
Haskell
1
star
21

text-editor-prototype

PureScript
1
star
22

Dont-Worry-Be-Happy

Example projects for Happy and Alex
Haskell
1
star
23

graphql-parser

A Happy little GraphQL Parser
Haskell
1
star
24

IdrisBookExercises

Exercises for Type Driven Development With Idris
Idris
1
star