Skip to content

[DNM] Adds Plasmo.jl interface in contrib folder for benders algorithms on linopy models - #821

Draft
coroa wants to merge 3 commits into
masterfrom
feat/plasmo-jl-benders
Draft

coroa wants to merge 3 commits into
masterfrom
feat/plasmo-jl-benders

Conversation

@coroa

@coroa coroa commented Jul 8, 2026 •

Copy link
Copy Markdown
Member

Changes proposed in this Pull Request

Adds a new sub-packge linopy.contrib.plasmo to run Benders or nested benders decompositions on linopy models.

A partitioning algebra that is available through linopy.contrib.plasmo.Partition and a few small helpers allows splitting up a linopy model into named nodes based on its dimensions. Each nodes is subset of variables and constraints. Variable sets are typically overlapping, while constraint sets are disjunct. Within Python CSR matrices and variable bounds for each node are constructed, passed to helpers in a small julia module and constructed as individual subgraphs in a Plasmo.jl OptiGraph. A Benders or NestedBendersAlgorithm can then be used to solve the OptiGraph in Julia/JuMP.

The result is retrieved as a Result object that can be assigned to the original Linopy model.

The contrib.plasmo code probably will eventually not live in linopy, but instead a small adjacent package. The experiment folder is a small example which should move to the docs (but without the dependencies).

Look at the experiment/run_benders.py file or the commented experiment/plasmo-benders-decomposition.nb notebook, both run benders decomposition on the small testProblem that was provided by @leonardgoeke through https://github.com/leonardgoeke/Linopy2Plasmo.jl , see also discussion in PyPSA/PyPSA#1712 .

Dependencies

The interface depends on juliacall and juliapkg to set up a julia installation and an environment with the required Julia packages. They are set up automatically within the pixi environment in the experiment folder.

Open issues

  • Lacks implementation for non-continuous variables and special constraint types.
  • Experiment should not be part of the repository
  • Unit tests

Checklist

  • AI-generated content is marked (see AGENTS.md).
  • 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).
  • 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.

@coroa coroa changed the title [DNM] Adds Plasmo.jl interface in contrib folder for running on linopy models [DNM] Adds Plasmo.jl interface in contrib folder for benders algorithms on linopy models Jul 8, 2026
@coroa

coroa commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

@odow Promised ping, please have a look.

@codspeed

codspeed Bot commented Jul 8, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 14.68%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
❌ 3 regressed benchmarks
✅ 177 untouched benchmarks
⏩ 181 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ test_to_lp[qp-n=1000] 1.9 MB 2.6 MB -24.96%
❌ test_to_lp[nodal_balance_sparse-severity=50] 2.8 MB 3.7 MB -24.08%
❌ test_to_lp[merge_balance-severity=0] 2.7 MB 3.3 MB -18.24%
⚡ test_to_lp[nodal_balance-severity=0] 3.7 MB 3.3 MB +13.77%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing feat/plasmo-jl-benders (8ccbdbd) with master (718c0c1)

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

@odow

odow commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Yeah we should chat about this.

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

enhancement New feature or request solver interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants