Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/internals/irregular/tree_search_maximal_spaces.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ The insertions of a node are computed as follows.

**2. Candidate blocks.** The candidate blocks are the valid blocks which may fit in the selected empty space.

**3. Candidate supporting parts.** The candidate supporting parts are the ones which touch the bottom side of the empty space: they overlap it horizontally, and their lowest point is at or below it while their highest point is at or above it. They are searched among the supporting parts of the bin and of the blocks already packed (only for the blocks whose bounding box crosses the bottom side of the empty space). The bottom side of an empty space is usually the top of a rectangle covering an item, which is also the top of the item, so the supporting part of the item at the top of this rectangle touches it.
**3. Candidate supporting parts.** The candidate supporting parts are the ones which touch the bottom side of the empty space: they overlap it horizontally, and their lowest point is at or below it while their highest point is at or above it. They are searched among the supporting parts of the bin and of the blocks already packed (only for the blocks for which the bounding box of their supporting parts crosses the bottom side of the empty space; the supporting parts are computed on the inflated shapes, so with an item-item spacing, this bounding box goes above the bounding box of the items). The bottom side of an empty space is usually the top of a rectangle covering an item, which is also the top of the item inflated by the item-item spacing, so the supporting part of the item at the top of this rectangle touches it.

**4. Obstacles.** For each candidate supporting part, the trapezoids which a block resting on it may overlap are selected among the trapezoids of the node: the ones whose right is to the right of the left side of the empty space minus the width of the widest candidate block, and which overlap vertically the supporting part extended, above and below, by the height of the highest candidate block. The other trapezoids can't be reached by the slides below.

Expand Down
8 changes: 3 additions & 5 deletions src/irregular/tree_search_maximal_spaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ BranchingSchemeMaximalSpaces::Block BranchingSchemeMaximalSpaces::build_block(
if (covered(item_pos, support.aabb, true))
continue;
block_trapezoid_set.supporting_parts.push_back(block.supporting_parts.size());
block.supporting_parts_aabb = shape::merge(block.supporting_parts_aabb, support.aabb);
block.supporting_parts.push_back(support);
}
}
Expand Down Expand Up @@ -545,11 +546,8 @@ void BranchingSchemeMaximalSpaces::select_empty_space(
}
for (const Node::PlacedBlock& placed_block: node.placed_blocks) {
const Block& block = blocks_[placed_block.block_id];
AxisAlignedBoundingBox block_aabb;
block_aabb.x_min = placed_block.x + block.trapezoid_set.x_min;
block_aabb.x_max = placed_block.x + block.trapezoid_set.x_max;
block_aabb.y_min = placed_block.y + block.trapezoid_set.y_min;
block_aabb.y_max = placed_block.y + block.trapezoid_set.y_max;
AxisAlignedBoundingBox block_aabb = block.supporting_parts_aabb;
block_aabb.shift(placed_block.x, placed_block.y);
if (!touches_bottom(block_aabb))
continue;
for (const Support& support: block.supporting_parts) {
Expand Down
6 changes: 6 additions & 0 deletions src/irregular/tree_search_maximal_spaces.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ class BranchingSchemeMaximalSpaces
*/
std::vector<Support> supporting_parts;

/**
* Bounding box of the supporting parts, which are computed on the
* inflated shapes of the items, relative to the block.
*/
AxisAlignedBoundingBox supporting_parts_aabb;

/**
* Supported parts with which the block rests on a supporting part,
* relative to the block.
Expand Down
7 changes: 7 additions & 0 deletions test/irregular/tree_search_maximal_spaces_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,11 @@ INSTANTIATE_TEST_SUITE_P(
// worse than packing item types 0 and 2 (150).
fs::path("data") / "irregular" / "tests" / "knapsack_penalized_resource.json",
fs::path("data") / "irregular" / "tests" / "knapsack_penalized_resource_solution.json"
}, {
// With the item-item spacing, the empty spaces above the items
// start above the bounding boxes of their non-inflated shapes,
// at the top of their inflated shapes, where their supporting
// parts are: the second row of items rests on them.
fs::path("data") / "irregular" / "tests" / "knapsack_item_item_minimum_spacing.json",
fs::path("data") / "irregular" / "tests" / "knapsack_item_item_minimum_spacing_solution.json"
}}));
Loading