Handle zero-crossing coefficients in persistent updates - #1002
Draft
MaykThewessen wants to merge 3 commits into
Draft
MaykThewessen wants to merge 3 commits into
MaykThewessen wants to merge 3 commits into
Conversation
Fix PyPSA#925 by applying coefficient insertions and removals without rebuilding. Preserve the unchanged-pattern fast path and complete target snapshots. Validate with python -m pytest test -q -n 4 -o addopts= --junitxml=/tmp/linopy-priorities-full-suite.xml: 5424 passed, 80 baseline failures, 2224 skipped; all 16 new regressions fail before the fix and pass after it. Ruff passes. Mypy is unavailable in the reused environment.
for more information, see https://pre-commit.ci
Merging this PR will not alter performance
Comparing Footnotes
|
This branch has not been deployed
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.
Note
This pull request was prepared with AI assistance.
Coefficients crossing zero currently change exported CSR sparsity and force a persistent solver rebuild. This change emits positional coefficient updates instead: removed terms receive zero and inserted terms receive their target value. The unchanged-pattern fast path remains, and the adopted snapshot retains the complete target matrix.
Fixes #925.
The regressions cover both crossing directions, legacy and v1 semantics, mutable and frozen constraints, same-model updates, and an entire row becoming zero and returning. All 16 cases fail on the unchanged baseline and pass with the fix.
Validation and limitations
Test command:
python -m pytest test -q -n 4 -o addopts='' --junitxml=/tmp/linopy-priorities-full-suite.xml.The same existing BirdFlow pixi test environment was reused for baseline and fixed source, without installing packages or changing dependency pins. Full-suite comparison:
Exact failure-set comparison: 16 resolved, zero new failures, 80 unchanged failures. The unchanged failures comprise 74 OETC tests missing optional cloud dependencies and six tests requiring SOS support unavailable through HiGHS. This is not a fully passing suite. Mypy was unavailable in this environment; Ruff and whitespace checks pass.
An independent read-only review found no correctness blocker. The existing coefficient setters for HiGHS, Gurobi, Xpress and Mosek were inspected; solve-based regression validation here uses HiGHS.
Note: AI-assisted (model identity unavailable).