Repository navigation
irregular: tree search option to expand only the K biggest item types per node - #829
HamzaYslmn wants to merge 2 commits into
Conversation
… per node On a knapsack instance with many distinct item types (~1000), every node tries every remaining item type x rotation x supporting part and children() builds a node for every insertion before the beam keeps the best ones, so time and memory per level grow with the number of types and the search stalls after the biggest few dozen items. tree_search_maximum_number_of_item_types (CLI --tree-search-maximum-number-of-item-types, default -1: unchanged) expands only the K biggest item types that have at least one insertion at each node; an item type without one does not count, so smaller ones are tried instead.
Synthetic sheet-metal parts (plates and brackets with holes, irregular blobs, letter-like strokes), every item a distinct type with one copy: 1000 types on a 2000x1000 bin and 2000 types on a 3000x1500 bin, item-item spacing 2, rotations 0/90/180/270, profit = area. The solutions are the ones found with --tree-search-maximum-number-of-item-types 25 and a 60 s time limit.
…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.
…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.
|
Thanks a lot for this PR and for the very clear analysis and instances. I'm closing it in favor of another approach. Limiting the expanded item types doesn't fit the tree search well, since it relies on a skyline-like structure and on dominances between the nodes. These instances, where many items fit in each section of the bin, are a better fit for the tree search with maximal spaces. It had a few issues, which are fixed in:
With the default parameters and a 60 s time limit, the solver now uses 83.4% of the bin (790 items) on the 1000-item-types instance and 85.8% (1501 items) on the 2000-item-types one. The time limit is respected. I also tried a "K item types per node" limit in the tree search with maximal spaces, with K = 5, 10, 25, 50 and 100. It made no measurable difference there, so I didn't keep it. Your two instances are added in About the |
Summary
On irregular knapsack instances with many distinct item types (a few hundred and up), the tree search stops making progress: it places the largest few dozen items, then each further step takes several seconds, and memory grows to several GB. This PR adds an opt-in parameter that bounds the work per node. With it, the same instances reach 74-80% bin utilization in 60 s instead of 35-47% in 300 s, with about 10-20x less memory.
Default behaviour is unchanged.
Cause
In
BranchingScheme::insertions, every node tries every remaining item type × rotation × supporting part, andchildren()builds a node for each resulting insertion before the beam keeps the best ones. Both the time per level and the memory therefore grow with the number of item types. With ~1000 types a single level takes seconds, so within a normal time limit the search only gets through a few dozen items.Change
New parameter
OptimizeParameters::tree_search_maximum_number_of_item_types(CLI--tree-search-maximum-number-of-item-types), default-1(no limit, original code path).With a value
K >= 0, each node expands item types in decreasing order of area and stops onceKof them have produced at least one insertion. Item types that do not fit anywhere are skipped and do not count towardK, so smaller items are considered once the large ones no longer fit, and the search does not dead-end. Work and memory per node become bounded byK × rotations × supportsrather than by the number of item types.Results
Two instances are added in
data/irregular/users/(synthetic, generated to resemble sheet-metal jobs: plates and brackets with bolt holes and cut-outs, irregular blobs, thin letter-like parts). Every item is a distinct type with one copy; rotations 0/90/180/270; item-item spacing 2; profit = area. The solutions found withK = 25are included.--time-limit 60--time-limit 300K = 10,--time-limit 60K = 25,--time-limit 60--time-limit 60--time-limit 300K = 10,--time-limit 60K = 25,--time-limit 60Utilization = placed item area / bin area. Measured on Windows, 4 threads per run, master at d4b0082. Note that master also exceeds its time limit on these instances (77 s for a 60 s limit, 417 s for 300 s), since a single node expansion outlasts it.
1000 item types:
2000 item types:
Reproduce
Notes
shape::trapezoidation('open_trapezoid_pos' must be != -1). That is unrelated to this change; I can open a separate issue with the shape.