Skip to content

irregular: tree search with maximal spaces on the actual geometry - #754

Merged
fontanf merged 8 commits into
masterfrom
irregular-tree-search-maximal-spaces
Oct 29, 2026
Merged

fontanf merged 8 commits into
masterfrom
irregular-tree-search-maximal-spaces

Conversation

@fontanf

@fontanf fontanf commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Add a tree search with maximal spaces for irregular, between the tree search and the tree search with periodic packings:

  • like the tree search with periodic packings, a node stores the maximal empty spaces of the bin, a block (a single item or a periodic block) is packed at each stage in the empty space closest to the bottom-left corner, and the nodes are evaluated by a greedy completion;
  • like the tree search, the blocks are described by their trapezoids: they rest on a supporting part of the bin or of the blocks already packed and slide until they don't overlap them. The empty spaces, computed from rectangles covering the items, are only used to select where to insert a block, so a block may stick out of its empty space, e.g. to fit in a concavity.

It only handles instances with a single bin (knapsack and feasibility directly, the other objectives through sequential feasibility), and it is never selected automatically: --use-tree-search-maximal-spaces 1 / use_tree_search_maximal_spaces.

Refactoring

  • The directions, the trapezoid sets, the supports and the construction of the bin types are moved out of the branching scheme of the tree search (trapezoid_set.hpp), and the slide of a trapezoid set along a supporting part into a TrapezoidSetSlider class (trapezoid_slider.hpp), replacing five copies of the same loop. The results of the tree search are unchanged (identical solution files on the literature instances, queue sizes 16 and 128).
  • The maximal empty spaces of the tree search with periodic packings are moved to empty_spaces.hpp, with a new function cutting them by several rectangles at once.

Results

Literature strip packing instances (13 instances, not-anytime sequential):

Algorithm Mean density Total time
Tree search, queue size 16 0.753 21 s
Tree search, queue size 128 0.764 195 s
Tree search with maximal spaces, queue size 4 0.767 23 s

CG:SHOP 2024 knapsack instances with 100 to 1379 items (anytime, 30 s): the new algorithm beats the tree search with periodic packings on all 14 instances, and the tree search on the 3 instances with more than 1000 items (e.g. jigsaw 1338: 147183 vs 34965 for the tree search and 106152 for the periodic packings). The tree search remains better between 100 and 700 items, where the greedy completions of the new algorithm are expensive.

Tests

  • New tree_search_maximal_spaces_test: checks that the solutions found on the 35 small instances of data/irregular/tests (including a new knapsack_l_shapes_triangles.json) have no overlaps and no item outside the bin.
  • Existing tree search and periodic packing tests pass.

The algorithm is documented in doc/internals/irregular/tree_search_maximal_spaces.rst.

Move the directions, the trapezoid sets, the supports and the
construction of the bin types out of the branching scheme of the tree
search, and the slide of a trapezoid set along a supporting part into a
TrapezoidSetSlider class, so that other branching schemes can use them.
Add a tree search between the tree search and the tree search with
periodic packings: like the latter, a node stores the maximal empty
spaces of the bin, an insertion packs a block (a single item or a
periodic block) in the empty space closest to the bottom-left corner,
and a node is evaluated by a greedy completion; like the former, the
blocks are described by their trapezoids, rest on the supporting parts
of the bin or of the blocks already packed and slide until they don't
overlap them.

It is only run when requested (--use-tree-search-maximal-spaces 1).
Cover each item by at most 8 rectangles, and cut the empty spaces by all
the rectangles of a block at once, discarding the parts too small for
the remaining blocks.
Also expose its parameters in the Python bindings, and score the
insertions by the profit of the blocks only.
… tests

The literature instances are not available in the CI and are too large
for unit tests. Use instances from data/irregular/tests instead and add
a small knapsack instance with L-shapes and triangles.
@fontanf
fontanf merged commit 0c74629 into master Oct 29, 2026
16 checks passed
@fontanf
fontanf deleted the irregular-tree-search-maximal-spaces branch October 29, 2026 07:42
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