Skip to content

Handle zero-crossing coefficients in persistent updates - #1002

Draft
MaykThewessen wants to merge 2 commits into
PyPSA:masterfrom
MaykThewessen:codex/fix-zero-crossing-persistent-updates
Draft

MaykThewessen wants to merge 2 commits into
PyPSA:masterfrom
MaykThewessen:codex/fix-zero-crossing-persistent-updates

Conversation

@MaykThewessen

Copy link
Copy Markdown
Contributor

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:

Source Passed Failed Skipped
Baseline with the new regressions 5408 96 2224
Fix 5424 80 2224

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).

MaykThewessen and others added 2 commits October 4, 2026 21:12
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.
@codspeed

codspeed Bot commented Oct 4, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 181 untouched benchmarks
⏩ 181 skipped benchmarks1


Comparing MaykThewessen:codex/fix-zero-crossing-persistent-updates (98a4d08) with master (1b2ea76)

Open in CodSpeed

Footnotes

  1. 181 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

This branch has not been deployed

No deployments
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.

Zero culling forces model rebuilding

1 participant