Skip to content

Reduction: full-bin items and perfect pairs for box and rectangleguillotine - #730

Merged
fontanf merged 1 commit into
masterfrom
reduction-full-bin-items
Oct 21, 2026
Merged

fontanf merged 1 commit into
masterfrom
reduction-full-bin-items

Conversation

@fontanf

@fontanf fontanf commented Oct 21, 2026

Copy link
Copy Markdown
Owner

Ports rectangle's and onedimensional's dedicated-bin reservations (reduce_full_bin_items, reduce_perfect_pairs) to box and rectangleguillotine, for BinPacking with a single bin type. Both flags are enabled by default and exposed in the Python bindings.

How it works

  • Items are compared against the bin shrunk to the largest total length of the items along each axis, using their current (possibly lifted) dimensions.
  • Full-bin items: an item filling the shrunk bin can't share its bin with any other item, so each copy gets a dedicated bin.
  • Perfect pairs: two items spanning the shrunk bin along one axis and filling it together along the other one get a dedicated bin together. In any solution, the other items of their two bins are beside them, in slabs that fit together in a single bin.
  • Never more dedicated bins than the bin type has copies; if they take every copy while items remain, the instance is proven infeasible.
  • The dedicated items are left out of the reduced instance and the bin type has its copies reduced. optimize adds the dedicated bins back onto the bin packing bound, and unreduce_solution adds them back with the true dimensions of the items.

box

  • A pair requires a single allowed rotation for both items (otherwise they could be placed without spanning the two axes). A full-bin item may keep several rotations: if one fills the shrunk bin, every rotation fitting the bin does.
  • Not applied with a maximum weight and weighted items, nor with resources.
  • Runs in a loop with lifting, which can make an item fill the shrunk bin.

rectangleguillotine

  • Lengths are increased by the cut thickness, as for lifting.
  • Requires the cut constraints of lifting (items_can_shrink: no minimum distance between cuts, minimum waste or maximum number of cuts), no maximum distance between cuts, no trims, no resources, and items alone in their stacks.
  • The dedicated bins are built as cut trees, with a trimming cut where an item is smaller than the bin; a pair is skipped if its cut tree would need more stages than allowed.

Tests

  • New reduction tests: full-bin items and perfect pairs for both types, a pair with a cut thickness, and a weighted box instance where nothing is reserved. The tests of other operations (lifting, merging, redundant rotations) on instances these reservations would reduce entirely now disable them.
  • Full box and rectangleguillotine unit test suites pass.
  • Randomized comparison of BinPacking solves with and without reduction (instances with items filling the bin and complementary pairs; random cut types, stages, orientations and cut thicknesses for rectangleguillotine): 200 instances each for box and rectangleguillotine, with matching numbers of bins and feasible solutions.

…lotine

Port the dedicated-bin reservations of rectangle and onedimensional
('reduce_full_bin_items', 'reduce_perfect_pairs', enabled by default,
exposed in the Python bindings) to box and rectangleguillotine, for
'BinPacking' with a single bin type. They are compared against the bin
shrunk to the largest total length of the items along each axis, with the
current (possibly lifted) item dimensions. An item filling the shrunk bin
can't share its bin with any other item; two items spanning it along one
axis and filling it together along the other one get a dedicated bin
together (the other items of their bins are beside them, in slabs that fit
together in a single bin). Never more dedicated bins than the bin type
has copies; if they take every copy while items remain, the instance is
proven infeasible. The dedicated items are left out of the reduced
instance, the bin type has its copies reduced, 'optimize' adds the
dedicated bins back onto the bin packing bound, and 'unreduce_solution'
adds them back with the true dimensions of the items.

- box: a pair requires a single allowed rotation for both items; not with
  a maximum weight and weighted items, nor with resources. Runs in a loop
  with lifting, which can make an item fill the shrunk bin.
- rectangleguillotine: lengths are increased by the cut thickness; same
  cut constraints as lifting ('items_can_shrink'), no maximum distance
  between cuts, no trims, no resources, items alone in their stacks. The
  dedicated bins are built as cut trees with a trimming cut where needed;
  a pair is skipped if its cut tree would need more stages than allowed.

The tests of other operations on instances the reservations would reduce
entirely now disable them.
@fontanf
fontanf merged commit db3bd78 into master Oct 21, 2026
13 of 16 checks passed
@fontanf
fontanf deleted the reduction-full-bin-items branch October 21, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant