Skip to content

irregular: add the fixed items to the solutions with SolutionBuilder::add_fixed_item - #836

Merged
fontanf merged 1 commit into
masterfrom
solution-builder-add-fixed-item
Nov 9, 2026
Merged

fontanf merged 1 commit into
masterfrom
solution-builder-add-fixed-item

Conversation

@fontanf

@fontanf fontanf commented Nov 9, 2026

Copy link
Copy Markdown
Owner

Follow-up of #835: the fixed items of a certificate were read as packed items, so writing then reading a solution lost them.

Instead of matching the items of a certificate with the fixed items of the bin types, the solutions now know which fixed item each of their fixed items is:

  • SolutionItem::is_fixed is replaced by SolutionItem::fixed_item_pos, the position of the item in the fixed items of the bin type, or -1 (is_fixed() is kept as an accessor, and as a read-only property in Python).
  • The is_fixed argument of SolutionBuilder::add_item is removed. The new SolutionBuilder::add_fixed_item(bin_pos, fixed_item_pos) takes the item type, position, angle and mirror from the bin type; it throws for an invalid position or a fixed item already added to the bin.
  • The certificates store fixed_item_pos for the fixed items, and SolutionBuilder::read adds them with add_fixed_item. The solution files of the tests with fixed items are updated (only the new key is added), and the certificate format is documented.

Changes in the algorithms:

  • All the algorithms add the fixed items with add_fixed_item. The direct trigonometry separator no longer keeps a copy of the fixed items, and the items of the separation models store fixed_item_pos instead of a boolean.
  • In the reduction, the fixed items keep the item type of the fixed item of the bin type, instead of the one of the run of the merged item types.
  • The post-processing no longer shifts the bins with fixed items, since it moved the fixed items with the other items.

Tests: Irregular.SolutionBuilderAddFixedItem and Irregular.SolutionWriteReadFixedItems. All the irregular tests pass.

The other problem types have a BinType::fixed_items field, but nothing fills it yet, so they are unchanged.

…:add_fixed_item

Replace the 'is_fixed' argument of SolutionBuilder::add_item by an
'add_fixed_item' method which takes the position of the fixed item in the
bin type, and store this position in the solution items. The certificates
store it as 'fixed_item_pos', so that the fixed items of a certificate are
still fixed once it is read.
@fontanf
fontanf merged commit d982595 into master Nov 9, 2026
16 checks passed
@fontanf
fontanf deleted the solution-builder-add-fixed-item branch November 9, 2026 22:53
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