Skip to content

Make extendability and committability compatible, when modularity is on#1007

Merged
FabianHofmann merged 89 commits intoPyPSA:masterfrom
enricogiglio:AdvancedModularity
Feb 17, 2026
Merged

Make extendability and committability compatible, when modularity is on#1007
FabianHofmann merged 89 commits intoPyPSA:masterfrom
enricogiglio:AdvancedModularity

Conversation

@enricogiglio
Copy link
Copy Markdown
Contributor

@enricogiglio enricogiglio commented Aug 21, 2024

Closes #1000

@davide-f and I would like to propose a MILP formulation for extendability and committability, only when modularity is on, to make these two features compatible. We have also added a test for the feature we have implemented, and believe that the proposed changes are consistent with the rest of the codebase. In particular, the goal is to keep everything compatible with the previous version without introducing breaking changes.

At the moment we'd like to continue working on improving the proposed code changes, but perhaps we'll also propose a new test that's more accurate with respect to the changes introduced.

image

Checklist

  • Code changes are sufficiently documented; i.e. new functions contain docstrings and further explanations may be given in doc.
  • Unit tests for new features were added (if applicable).
  • Newly introduced dependencies are added to environment.yaml, environment_docs.yaml and setup.py (if applicable).
  • A note for the release notes doc/release_notes.rst of the upcoming release is included.
  • I consent to the release of this PR's code under the MIT license.

Copy link
Copy Markdown
Collaborator

@davide-f davide-f left a comment

Choose a reason for hiding this comment

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

Thanks @enricogiglio :D
I've gone through the PR and added some preliminary comments.

Please, see that the pre-commit has added edits.
Do:
git fetch
git pull
to have them locally.

Afterwards, ensure to install the pre-commit locally using:
pre-commit install

This should prevent future online commits related to the precommit

@enricogiglio
Copy link
Copy Markdown
Contributor Author

@davide-f I integrated the changes you suggested as discussed, but 1) we also added more tests and 2) now we have passed all the checks. Any other suggestions?

@davide-f
Copy link
Copy Markdown
Collaborator

davide-f commented Sep 7, 2024

@davide-f I integrated the changes you suggested as discussed, but 1) we also added more tests and 2) now we have passed all the checks. Any other suggestions?

To me the PR looks ready to be revised by the maintainers.
You can convert it to ready

@enricogiglio enricogiglio marked this pull request as ready for review September 8, 2024 07:49
FabianHofmann and others added 6 commits February 2, 2026 10:50
- Add fixtures for common network setups
- Add helper functions for generator/link creation
- Reduce snapshot counts for faster execution
- Consolidate similar tests via parametrization
- Reduce test code by 62% (1731 → 662 lines)
Copy link
Copy Markdown
Member

@lkstrp lkstrp left a comment

Choose a reason for hiding this comment

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

This will make a couple of people happy if finally merged ! There are some formatting things in the docs left, which are otherwise lovely. And then I have some pain with all the validation/ consistency stuff, but I think this needs a bigger clean up in a follow up PR and not in here. Just waiting for the formulation review of @Irieo

@lkstrp lkstrp requested a review from Irieo February 2, 2026 14:46
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 is a really neat addition (and generalisation) of PyPSA UC & investment logic functionality, h/t @enricogiglio and @FabianHofmann. Implementation makes good sense, the notebooks illustrate new functionality neatly. The inference of M for Big-M is 🍒 (one can argue if the implementation is enough tight, but the very fact it is automatically found and not hardcoded is great).

Below is the review, here is brief summary:

  • I suppose some math in docs is wrong, but code implementation is actually correct.
  • note that ramp_limit_start_up/down are not working here (reason/fix is in #1540). More, compatibility with ramp_limit_start_up/down is not mentioned in summary table in docs and not tested (I left dedicated comment for it)
  • The fact that in modular expansion case the status variable is NOT a binary on/off variable anymore, but instead becomes an integer representing the number of committed modules inside the component & the fact that status defaults to "1" -> creates a super unintuitive result, also observed in the notebook here. Say we invest into 5 blocks x 100 MW to cover 500 MWh/h load. The reported status and dispatch variables are 5 & 500 MW, but there are 4 startups (since first one is already started up), which also means we pay in objective for 4 UC events and the first one PyPSA gives for free 🎁. User can control it by adjusting default status obv, and I don't think this is something worth fixing, but it is worth documenting.
  • There are no tests for multi-period invesment logic and considering the madness that can be created by transition of all status variables across periods across modular units correctly, I'd recommend covering this with tests.

lkstrp added a commit to PyPSA/redirect-service that referenced this pull request Feb 11, 2026
@davide-f
Copy link
Copy Markdown
Collaborator

@Irieo Adding a comment on

The reported status and dispatch variables are 5 & 500 MW, but there are 4 startups (since first one is already started up), which also means we pay in objective for 4 UC events and the first one PyPSA gives for free 🎁. User can control it by adjusting default status obv, and I don't think this is something worth fixing, but it is worth documenting.

That phenomenon is intended, though agree worth documenting. With modularity options, a single PyPSA object simulates the dispatch of N independent units, which saves lots of variables (continuous and binary ones). As such, if any of the unit is dispatched, then the startup cost is paid.
Savings can be significant [factor 10x], see https://ieeexplore.ieee.org/abstract/document/11050131

FabianHofmann and others added 7 commits February 16, 2026 13:30
Avoid LinearExpression * LinearExpression in ramp constraints when
both extendable and committable components coexist. For modular+
committable+extendable use p_nom_mod as constant capacity per module.
Document all four big-M ramp constraints (run/start-up/shut-down) with
correct constraint names and startup/shutdown ramp limit parameters.
Add test for modular+committable ramp limits.
@FabianHofmann FabianHofmann enabled auto-merge (squash) February 17, 2026 12:40
@FabianHofmann FabianHofmann merged commit e128724 into PyPSA:master Feb 17, 2026
26 checks passed
@lkstrp
Copy link
Copy Markdown
Member

lkstrp commented Feb 17, 2026

🚀

@Irieo Irieo mentioned this pull request Feb 27, 2026
5 tasks
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.

Make extendable components committable when modularity is used

7 participants