Skip to content

gedex/bp3d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bp3d

3D Bin Packing implementation based on this paper. The code is based on binpacking by bom-d-van but modified to allow flexible bins and use float64 instead of int.

Install

go get github.com/gedex/bp3d

Usage

p := bp3d.NewPacker()

// Add bins.
p.AddBin(bp3d.NewBin("Small Bin", 10, 15, 20, 100))
p.AddBin(bp3d.NewBin("Medium Bin", 100, 150, 200, 1000))

// Add items.
p.AddItem(bp3d.NewItem("Item 1", 2, 2, 1, 2))
p.AddItem(bp3d.NewItem("Item 2", 3, 3, 2, 3))

// Pack items to bins.
if err := p.Pack(); err != nil {
	log.Fatal(err)
}

// Each bin, b, in p.Bins might have packed items in b.Items

See example/example.go

Credit

License

MIT