• Stars
    star
    132
  • Rank 267,751 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 7 years ago
  • Updated over 1 year ago

Reviews

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

Repository Details

2D, 3D, 4D Bin Packing JS Library

binpackingjs

Build Status npm version MIT license

binpackingjs is 2D, 3D, 4D well tested JavaScript Bin Packing library.

  • 3D Bin Packing Code is porting from golang package bp3d which is based on this paper.
  • 2D Bin Packing Code is porting from ruby package bin_packing which is based on this paper.

Install

yarn add binpackingjs

2D Bin Packing

2D Bin Packing Demo

2D Bin Packing

const BinPacking2D = require('binpackingjs').BP2D;
const { Bin, Box, Packer } = BinPacking2D;

let bin_1 = new Bin(100, 50);
let bin_2 = new Bin(50, 50);
let boxes = [
  new Box(15, 10), // Should be added last (smaller)
  new Box(50, 45), // Fits in bin_2 better than in bin_1
  new Box(40, 40),
  new Box(200, 200), // Too large to fit
];
let packer = new Packer([bin_1, bin_2]);
let packed_boxes = packer.pack(boxes);

packed_boxes.length
=> 3
bin_1.boxes.length
=> 2
bin_1.boxes[0].label
=> '40x40 at [0x0]'
bin_1.boxes[0].label
=> '40x40 at [0x0]'
bin_1.boxes[1].label
=> '15x10 at [0x40]'
bin_2.boxes.length
=> 1
bin_2.boxes[0].label
=> '50x45 at [0x0]'
boxes[3].packed
=> false

3D Bin Packing

const BinPacking3D = require('binpackingjs').BP3D;

const { Item, Bin, Packer } = BinPacking3D;

let bin1 = new Bin("Le petite box", 296, 296, 8, 1000);
let item1 = new Item("Item 1", 250, 250, 2, 200);
let item2 = new Item("Item 2", 250, 250, 2, 200);
let item3 = new Item("Item 3", 250, 250, 2, 200);
let packer = new Packer();

packer.addBin(bin1);
packer.addItem(item1);
packer.addItem(item2);
packer.addItem(item3);

// pack items into bin1
packer.pack();

// item1, item2, item3
console.log(bin1.items);

// items will be empty, all items was packed
console.log(packer.items);

// unfitItems will be empty, all items fit into bin1
console.log(packer.unfitItems)

License

MIT

More Repositories

1

gtts.js

gTTS.js (Google Text to Speech)
JavaScript
15
star
2

meteor-handsontable

Handsontable repackaged for Meteor
JavaScript
14
star
3

graphql_api

GraphQL for Drupal 7
PHP
13
star
4

bp3d.js

JS 3D Bin Packing library
JavaScript
8
star
5

drupalmirror

Quick and duty python script to build local Drupal.org/project git repositories.
XML
5
star
6

learn-slim-doctrine-react

This project is used to learn Slim framework, Doctrine and React by clone Hacker News (http://news.ycombinator.com)
PHP
5
star
7

meteorchat

Simple chat room based on Meteor.
JavaScript
4
star
8

JageDown

JageDown = PageDown + jQuery
JavaScript
4
star
9

darkoon

Realtime web app for SQL Injection detector and data takeover build with sqlmap, node.js, socket.io, Bootstrap 3, Heroku
JavaScript
4
star
10

meteor-uri-js

URI.js repackaged for Meteor
JavaScript
3
star
11

DC_bench

Simple benchmark using ping test and file download test.
Python
3
star
12

Image_Graphviz

Some patch ...
PHP
2
star
13

skypeweb

A Skype client built on top of Electron
JavaScript
2
star
14

flag_entity

Drupal's module, extend module flag to flag any entity.
PHP
2
star
15

date-holidays-data

date-holidays's data extracted to bite-sized JSON files
JavaScript
1
star
16

adjacency-matrix-diagram

Adjacency matrix diagram editor for Interior Design https://adjacency-matrix-diagram.now.sh/
Vue
1
star
17

silex-starter

Silex starter project
PHP
1
star
18

sevabot-modules

Sevabot contrib modules
Python
1
star
19

VNMK

Work in progress. API server for https://github.com/nguyenvanhaokhtn/VietNamMusicKiller
JavaScript
1
star
20

heroku-buildpack-nodejs-sqlmap

Shell
1
star
21

nhac.meteor.com

Source code of download link getter app nhac.meteor.com
JavaScript
1
star
22

meteor-filemanager

File manager for intranet.
JavaScript
1
star