Skip to content

irregular: prune the slides of the tree search with maximal spaces with score bounds - #831

Merged
fontanf merged 2 commits into
masterfrom
irregular-tsms-score-bound
Nov 9, 2026
Merged

fontanf merged 2 commits into
masterfrom
irregular-tsms-score-bound

Conversation

@fontanf

@fontanf fontanf commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

Most of the time of the tree search with maximal spaces is spent sliding every candidate block, at each stage of each greedy completion. This PR skips the slides which can't change the result.

Bound. The rectangle of the density of an insertion contains the bounding box of the block, so the density is at most the area of the items of the block divided by the area of its bounding box. This gives an upper bound of the score of each block, profit × min(1, item_area / bbox_area)^β × N^(−γ), without any slide (0 for a negative profit, infinite for β < 0).

Lazy insertions. The candidate blocks of the selected empty space are sorted by decreasing bound. The insertion of rank k is known once k + 1 insertions are found and the bound of the next block is below the score of the insertion of rank k. The greedy completions only request rank 0, and the children request their insertions one by one, so the blocks which can't be ranked among them are not slid. The ties are still broken by the order of the blocks, so the insertions are exactly the same as before.

Empty spaces without supporting part. A second commit computes the supporting parts of the selected empty space first, and skips its candidate blocks when it has none: no block can be inserted there. On the instances of #829, these empty spaces were most of the empty spaces selected, and evaluating all the candidate blocks in them took most of the time; the search is about 4 times faster, with the same results.

Results

On the instances of #829 (60 s, --use-tree-search-maximal-spaces 1), the same solutions are found earlier, and the search goes further:

Instance Bin used, before → after Queue size 2 reached at
1000 item types 45.8% → 48.3% 7.4 s → 1.8 s
2000 item types 29.2% → 30.5% 26.9 s → 7.2 s

Checks of exactness, old vs new binary:

  • 77 instances (literature, user2025, opencutlist, users), 10 s: identical final statistics on 68; the 9 others only differ because the new version goes further within the time limit.
  • These 9 in not-anytime-deterministic mode: identical results on 8, 1.2× to 2× faster on the longer ones; the 9th (opencutlist knight_armor) reaches the 900 s timeout with both.

Doc: the score bounds are described in doc/internals/irregular/tree_search_maximal_spaces.rst.

…th score bounds

The density of an insertion is at most the area of the items of the block
divided by the area of its bounding box, which gives an upper bound of the
score of each block without any slide. The insertions of a node are now
computed lazily: the candidate blocks are slid by decreasing bound, until
the bound of the next one is below the score of the insertion requested. The
greedy completions only request the best insertion, and the children request
their insertions one by one, so the blocks which can't be ranked among them
are not slid. The insertions are the same as before, ties included.
…orting part in the tree search with maximal spaces

No block can be inserted in an empty space without supporting part touching
its bottom: compute the supporting parts first, and don't compute the
candidate blocks and their score bounds in this case. On the instances of
#829, these empty spaces are most of the empty spaces selected, and the
search is about 4 times faster.
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