JamesBremner / knapsack

3D Bin packing code direct from psuedocode
3 stars 1 forks source link

Optimizing Inventory Returns #7

Closed JamesBremner closed 4 years ago

JamesBremner commented 4 years ago

Optimizing what is returned to inventory is also a huge factor. Wood is too expensive to let any of it go unused.

The timber allocation algorithm we have been discussing in #6 arranges the ordered timber into levels of the same height. It first does a number of G-cuts ( guillotine ) to produce sheets that are passed on to to a 2D allocation algorithm. Lets call these cuts L-cuts.

I propose:

At startup, the contents of the specified inventory are ordered by their smallest dimension. The timbers that are smaller than a specified limit are considered too "thin" to be considered worth L-cutting. They are moved to a section of inventory called sheet inventory. The larger timbers are moved to the stock inventory.

The timbers in the sheet inventory are ordered by their second smallest dimension. The timbers that are smaller than a specified limit are considered too "narrow" to be considered worth splitting in the long dimension. They are moved to a section of inventory called scrap inventory.

Each timber in the order is checked to see if it can be allocated to a timber in the scrap inventory with just one or zero cuts. The order timbers that qualify are allocated to scrap using a 1D algorithm.

Each remaining order timber is checked to see if it can be allocated to a timber in the sheet without using an L-cut The order timbers that qualify are allocated to sheet using a 2D algorithm.

The remaining order timbers are allocated from stock by the full 3D algorithm discussed in #6.

When the cutting pattern is complete, the remaining bits of timber are filtered by their second smallest dimension. Those that are below a specified limit are discarded. The remainder are returned to inventory, scrap, sheet or stock as they qualify.

As an example:

image

red indicates discard

yellow indicates to scrasp inventory

blue indicates to sheet inventory

Cashewfly commented 4 years ago

I can see the logic of doing it this way. It's vaguely reminiscent of a 1d allocation system I'd looked at that could guarantee some performance bounds by calculating the specified limit used to determine whether to allocate on a primary or secondary pass.

JamesBremner commented 4 years ago

There will be a performance improvement if there are a lot of returns in the inventory, but the motivation is not to waste returns by ensuring they are used before large inventory items are chopped into little pieces.