rectangleguillotine: fix column_generation_strips maximum_distance_2_cuts handling#430
Merged
fontanf merged 2 commits intoJul 4, 2026
Merged
Conversation
…cuts handling column_generation_strips never enforced maximum_distance_2_cuts: the auto algorithm selection guard in optimize() had been relaxed to allow it, but none of generate_1e_patterns, generate_1n_patterns, and generate_2ho_patterns (which stack items into a strip via a 1D knapsack over height, one item/row per 2-cut) checked a row's height against the limit, and generate_lower_stage_patterns's sub-instance mapping dropped the outer's maximum_distance_2_cuts entirely instead of passing it down as the sub-instance's maximum_distance_1_cuts (and failed to reset the sub-instance's own maximum_distance_2_cuts, which could otherwise leak the outer's value onto unrelated cuts or crash InstanceBuilder::build() on a now-2-staged sub-instance). Since a homogeneous row's height can't be shrunk (unlike minimum_distance_2_cuts, which can be satisfied by padding), rows taller than the limit are now excluded outright. Added knapsack_3hvo_max2cut and knapsack_3hvr_max2cut regression tests (oriented and rotatable items, exercising the 2ho and recursive lower-stage paths respectively) to both the tree_search and column_generation_strips test suites, each confirmed to fail without the fix.
…e constraints it supports
Each algorithm now validates its final solution against exactly the subset of
instance constraints it actually implements, throwing a std::logic_error
otherwise (matching the existing pattern in tree_search.cpp's to_solution()):
- tree_search.cpp: was missing maximum_distance_2_cuts, number_of_stages and
item_copies checks even though it supports all of them.
- tree_search_maximal_spaces.cpp: only item_copies, since its auto-selection
guard requires every other constraint to be trivial.
- column_generation_strips.cpp: number_of_stages, distance between 1-cuts and
2-cuts (min/max), and item_copies, at all 4 points a solution is reported.
- labeling.cpp and sequential_feasibility.cpp: only item_copies, per
labeling.hpp's documented limitations and sequential_feasibility.cpp's role
of stitching sub-solver solutions together.
- dynamic_programming_infinite_copies_array.cpp: left unchanged, since it
genuinely ignores item copy limits by design ("infinite copies").
Adding the item_copies check to column_generation_strips.cpp's
generate_all_columns_2h_patterns immediately caught a real bug: strip copy
counts were bounded only by how many physically fit in the bin height, never
by the item type's actual copies, so a homogeneous strip could be reported as
a candidate solution using more copies of an item than the instance provides.
Fixed by capping copies_max with the item type's copies in both the oriented
and rotated branches.
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.
No description provided.