Skip to content

fix: assign duals back to stochastic network#1498

Merged
lkstrp merged 2 commits intoPyPSA:masterfrom
lkstrp:fix-1472
Dec 18, 2025
Merged

fix: assign duals back to stochastic network#1498
lkstrp merged 2 commits intoPyPSA:masterfrom
lkstrp:fix-1472

Conversation

@lkstrp
Copy link
Copy Markdown
Member

@lkstrp lkstrp commented Dec 17, 2025

Closes #1472
Closes #1491

Changes proposed in this Pull Request

A simple to fix but hard to find bug. Writing back duals when stochastic dimension existed, did not work for the branch of having strongly and simply meshed buses in one network. They are assigned differently in that case. The question is if this is still needed.

Checklist

  • Code changes are sufficiently documented; i.e. new functions contain docstrings and further explanations may be given in docs.
  • Unit tests for new features were added (if applicable).
  • A note for the release notes docs/release-notes.md of the upcoming release is included.
  • I consent to the release of this PR's code under the MIT license.

@coroa
Copy link
Copy Markdown
Member

coroa commented Dec 17, 2025

The sparsity structure of linopy did not improve, since that is a fundamental xarray issue. A multidimensional constraint always needs space for the highest number of terms (ie strongly meshed buses have many terms, weakly meshed buses have considerably less terms).

Rewriting to pyoframe would help :). But that opens another bag of worms.

Copy link
Copy Markdown
Contributor

@Irieo Irieo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes the problem described in issue.

Unrelated to the issue, related to this example: assign_all_duals = True yields our own not implemented flag wrt writing duals for constraints w/o a dedicated place in data structure. This brings us back to this discussion #1474 (comment)

@lkstrp lkstrp merged commit 5031132 into PyPSA:master Dec 18, 2025
47 of 52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants