Skip to content

Support multidimensional slope-to-breakpoint conversion - #1013

Open
MaykThewessen wants to merge 2 commits into
PyPSA:masterfrom
MaykThewessen:codex/snapshot-piecewise-slopes
Open

MaykThewessen wants to merge 2 commits into
PyPSA:masterfrom
MaykThewessen:codex/snapshot-piecewise-slopes

Conversation

@MaykThewessen

@MaykThewessen MaykThewessen commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Note

AI-assisted implementation and factual description, written with GPT-6.

Slopes.to_breakpoints() currently rejects a DataArray with both snapshot and component dimensions, although piecewise formulations already accept those dimensions. This adds a vectorized conversion for multiple entity dimensions, with scalar or DataArray initial values, exact entity-coordinate alignment and trailing NaN padding. Existing single-entity conversion stays unchanged.

The change supports the snapshot-dependent cost proposal in PyPSA #1914. Breakpoint coordinates remain positional, as in the existing API.

Validation: 136 slope/conversion tests passed, including 28 new cases for broadcasting, initial values, coordinate mismatch, ragged inputs and empty inputs. Ruff lint and formatting passed. Tests ran against this branch's source; no solver calls were needed for this mathematical conversion.

python -m pytest test/test_piecewise_constraints.py test/test_piecewise_snapshot_slopes.py -q -k 'SlopesToPointsPrivate or SlopesToBreakpoints or SlopesValueType or SlopesValidationErrors or snapshot_slopes' -o addopts=

Downstream validation with the paired patches passed 7244 tests and a representative 1008-hour solve with six accepted 168-hour chunks. The integration removed 246 to 282 eligible LP Generator rows per chunk while retaining physical tranche outputs. Reloaded results had no thermal violations or slack, and snapshot-weighted generator operating costs exactly matched the original tranche accounting. This compatible scenario explicitly disabled ramp penalties; positive per-tranche ramp costs remain an aggregation exclusion by default. The Linux downstream locked environment installation and quick suite also passed. These results do not establish annual behaviour or a performance gain.

@codspeed

codspeed Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 181 untouched benchmarks
⏩ 181 skipped benchmarks1


Comparing MaykThewessen:codex/snapshot-piecewise-slopes (98496ec) with master (f665a26)

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

@MaykThewessen
MaykThewessen marked this pull request as ready for review October 6, 2026 15:55

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.

1 participant