Skip to content

rectangleguillotine: fix column_generation_strips maximum_distance_2_cuts handling#430

Merged
fontanf merged 2 commits into
masterfrom
rectangleguillotine-column-generation-strips-max2cut
Jul 4, 2026
Merged

rectangleguillotine: fix column_generation_strips maximum_distance_2_cuts handling#430
fontanf merged 2 commits into
masterfrom
rectangleguillotine-column-generation-strips-max2cut

Conversation

@fontanf

@fontanf fontanf commented Jul 4, 2026

Copy link
Copy Markdown
Owner

No description provided.

fontanf added 2 commits July 4, 2026 01:03
…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.
@fontanf fontanf merged commit 71ee321 into master Jul 4, 2026
3 checks passed
@fontanf fontanf deleted the rectangleguillotine-column-generation-strips-max2cut branch July 4, 2026 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant