gabrielrocket
gabrielrocket

Reputation: 13

2d bin packing Java?

I need to solve a 2d bin packing problem using best fit on line in Java. I don't know how exactly should I find the correct location to put the next box.

I was thinking. Should I store all the top box positions of each 2d bin somewhere? Should I keep something like an array and a 2d array in each bin with how empty they are in an array and the position of each top box in the 2d array?

Upvotes: 1

Views: 1018

Answers (1)

Cybercartel
Cybercartel

Reputation: 12592

You can try a treemap. Sort the boxes store the first into a tree and split the tree on both axis. Find the best fit for the next box and rinse and repeat.

Upvotes: 1

Related Questions