Skip to content

irregular: use the free area of the bin in the algorithm selection - #728

Merged
fontanf merged 1 commit into
masterfrom
irregular-selection-free-area
Oct 20, 2026
Merged

fontanf merged 1 commit into
masterfrom
irregular-selection-free-area

Conversation

@fontanf

@fontanf fontanf commented Oct 20, 2026

Copy link
Copy Markdown
Owner

Follow-up of #720 and #726.

The automatic selection of the single-bin algorithms uses two estimates:

  • whether periodic packing is worth running: the item types with many copies cover more than 80% of the bin area (or of the total item area);
  • whether the tree search is run alongside it: max_number_of_items_in_bin, which fills the bin area with the smallest items, is below periodic_packing_max_items_threshold (64).

Both used the whole bin area, and counted the fixed items as items to place. With large fixed items, an instance whose solutions hold few items could look like it held many, so only periodic packing was run.

Change

  • New bin_free_area(instance): the bin area minus the areas of its fixed items and of its defects (approximate if defects overlap or go out of the bin).
  • Both estimates use it, and only count the copies which are not fixed (copies - copies_fixed).

Results

The four instances of the reporter of #720, default selection, --time-limit 10, items placed excluding the fixed item, spacing 0 / 3:

Instance Estimate (whole bin → free area) Before Now Algorithms run now --use-tree-search 1 (reporter)
frame_rect (frame with hole, 200 rectangles) 143 → 84 77 / 63 77 / 63 periodic packing 77 / 63
frame_l (frame with hole, 120 L shapes) 89 → 53 38 / 32 45 / 34 periodic packing + tree search 45 / 35
solid_rect (solid fixed rectangle, 300 rectangles) 286 → 143 135 / 117 135 / 117 periodic packing 135 / 117
solid_l (solid fixed rectangle, 200 L shapes) 178 → 89 66 / 58 66 / 58 periodic packing 76 / 61

The solutions were checked with shapely (fixed item kept, no overlap, spacing, inside the bin). On solid_l, the free area still holds more than 64 items, so the gap with the tree search remains: it comes from periodic packing on non-rectangular items, not from the fixed items.

The irregular tests pass (15 + 16 + 4 + 24 + 112).

The automatic selection of the single-bin algorithms estimated the
number of items fitting in the bin, and the area to fill with the item
types with many copies, from the whole bin area, and it counted the
fixed items as items to place. With large fixed items, an instance whose
solutions hold few items could look like it held many, and the tree
search wasn't run alongside the periodic packing.

The bin area is now its free area: its area minus the areas of its fixed
items and of its defects; and only the copies which are not fixed are
counted.
@fontanf
fontanf merged commit b4e6859 into master Oct 20, 2026
7 of 8 checks passed
@fontanf
fontanf deleted the irregular-selection-free-area branch October 20, 2026 20: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