FIBERALLOC-63: Fix collision in science-target constraint names - #30
Merged
Conversation
makeName("ST", key[0], key[1]) indexed the first two characters of the
target-class string rather than elements of a tuple, so every class sharing
a two-character prefix produced one name: sci_P1 through sci_P7 all became
ST_s_c.
The constraints themselves still reached the solver, but HiGHS received
duplicate row names, and _constraintdict kept only the last constraint per
colliding name, so constraintByName could not retrieve them.
FIBERALLOC-63
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CsehUfGABWV8uBhVQWUBet
There was a problem hiding this comment.
Pull request overview
Fixes a constraint-naming bug in buildProblem() where science-target class names were accidentally indexed as strings (taking only the first two characters), causing multiple constraints to collide under the same name and making constraint lookup / model dumps ambiguous.
Changes:
- Update the science-target constraint naming to use the full class key (e.g.,
ST_sci_P1) instead ofST_s_c.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
mreineck
approved these changes
Aug 25, 2026
mreineck
left a comment
Contributor
There was a problem hiding this comment.
Looks great, thank you for spotting this!
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.
Summary
makeName("ST", key[0], key[1])indexed the first two characters of the target-class string rather than elements of a tuple, so every class sharing a two-character prefix produced a single constraint name:sci_P1throughsci_P7all becameST_s_c.Impact
The constraints themselves still reached the solver on the supported backends —
GurobiProblem.add_constraintdoes not pass the name to gurobipy, and the HiGHS backend adds every row — so observation counts were not affected. What broke was naming:ST_s_c, making LP/MPS dumps ambiguous and hard to debug.LPProblem._constraintdictkeeps only the last constraint per colliding name, soconstraintByName()cannot retrieve them. This part is latent:constraintByNamehas no callers today.Risk
No change to any solution. Row names in dumped models change, so any external tooling that matches on
ST_names should be checked.Testing
python -m py_compilepasses. Naming was checked directly: for['sci_P1','sci_P2','sci_P7','cal','sky']the old expression yields 3 unique names out of 5, the new one yields 5 of 5. The solver was not run end to end.Refs FIBERALLOC-63
🤖 Generated with Claude Code
https://claude.ai/code/session_01CsehUfGABWV8uBhVQWUBet