Repository navigation
irregular: prune the slides of the tree search with maximal spaces with score bounds - #831
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:Checks of exactness, old vs new binary:
not-anytime-deterministicmode: identical results on 8, 1.2× to 2× faster on the longer ones; the 9th (opencutlistknight_armor) reaches the 900 s timeout with both.Doc: the score bounds are described in
doc/internals/irregular/tree_search_maximal_spaces.rst.