Repository navigation
irregular: approximate the obstacles of periodic packing by rectangles - #726
Merged
Merged
Conversation
tree_search_periodic_packing approximated the defects, borders and fixed items by their bounding boxes: a fixed item with a hole covered its hole, so no item could be placed in it (#720). The obstacles are now approximated by rectangles with shape's outer_approximation_by_rectangles, within the same maximum waste as the shape simplification: maximum_approximation_ratio times the smallest of the bin area and of the total item area, the ratio being the not_anytime_maximum_approximation_ratio of the tree search. A rectangular frame is covered exactly by 4 rectangles. Also give back one item-item spacing on the left and bottom sides of the obstacles: the extent of a block already ends one spacing past its items, so a block which fitted exactly in front of an obstacle was rejected. Update shape to a4efbe93 for outer_approximation_by_rectangles.
This was referenced Oct 20, 2026
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.
Follow-up of #721 for the last comment of #720:
tree_search_periodic_packingapproximated the defects, borders and fixed items by their bounding boxes, so a fixed part with a hole covered its hole and no item could be placed in it.Changes
outer_approximation_by_rectangles(Add outer_approximation_by_rectangles shape#149), computed once when the branching scheme is built. The maximum waste follows the same rule as the shape simplification:maximum_approximation_ratio × min(bin area, total item area). The ratio is a new parameter ofTreeSearchPeriodicPackingParameters, set byoptimizeto the tree search'snot_anytime_maximum_approximation_ratio(0.05). A rectangular frame is covered exactly by 4 rectangles, leaving its hole free.usable_bin_bx()), but the obstacles didn't, so a block which fitted exactly in front of an obstacle was rejected. The left and bottom sides of the obstacle rectangles are now moved by one item-item spacing (at most to their middle). This also affected defects and borders with a non-zero item spacing.a4efbe93.Results
The instance of the last comment of #720 (a 400 × 300 frame with a 320 × 220 hole, fixed, and 200 rectangles of 30 × 28), solutions checked with shapely (fixed item present, no overlap, minimum distance, inside the bin):
With the default selection, periodic packing is selected and gives these results.
With slanted fixed items, the tree search can still place a few more items, by nesting them partly next to the slanted edges, which periodic packing sees as a staircase of rectangles.
Tests
Two new periodic packing tests:
knapsack_fixed_item_with_hole: a 100 × 60 frame with an 80 × 40 hole; 32 squares fit in the hole, none before.knapsack_fixed_item_with_hole_spacing: the same with an 80 × 38 hole and a spacing of 2, sized so that 3 rows of squares fit only with the spacing fix (it fails without it).The irregular tests pass (15 + 16 + 4 + 24 + 74), built against the merged shape commit.