Repository navigation
Circularity MILP - #1557
Draft
tsmbland wants to merge 10 commits into
Draft
Circularity MILP#1557tsmbland wants to merge 10 commits into
tsmbland wants to merge 10 commits into
Conversation
tsmbland
force-pushed
the
circularity_milp
branch
2 times, most recently
from
October 27, 2026 14:04
19f051d to
b798205
Compare
Contributor
There was a problem hiding this comment.
⚠️ Performance Alert ⚠️
Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.30.
| Benchmark suite | Current: 948f1b7 | Previous: 6a19604 | Ratio |
|---|---|---|---|
select_best_assets_parallel/01 |
13564670.46875 ns |
9132896.765151516 ns |
1.49 |
select_best_assets_parallel/05 |
38101280.5 ns |
26819628.777777776 ns |
1.42 |
select_best_assets_parallel/10 |
64754173 ns |
45113674.75 ns |
1.44 |
select_best_assets_parallel/15 |
94518125.75 ns |
65351435.33333333 ns |
1.45 |
select_best_assets_parallel/20 |
124836132.25 ns |
85097739.5 ns |
1.47 |
select_best_assets_sequential/01 |
13319748.961538462 ns |
9107675.635526314 ns |
1.46 |
select_best_assets_sequential/05 |
64110279.33333333 ns |
43859325.75 ns |
1.46 |
select_best_assets_sequential/10 |
127960637.5 ns |
87553632.5 ns |
1.46 |
select_best_assets_sequential/15 |
192535830.5 ns |
131658938.5 ns |
1.46 |
select_best_assets_sequential/20 |
259066737 ns |
175652280.5 ns |
1.47 |
This comment was automatically generated by workflow using github-action-benchmark.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved feedback-ordering, demand-accounting and input-handling bugs can cause infeasible portfolios, unnecessary investment and model-loading panics.
5 open issues
What changed in this PR
This PR replaces MUSE2’s flexible-capacity cycle balancing with a two-pass investment algorithm that detects feedback processes automatically, unlike the manual configuration approach in #1547.
Changes:
- Adds supply-preservation constraints to cycle ordering and automatic feedback exclusion during the second investment pass.
- Passes explicit demand maps into dispatch and removes
capacity_margin. - Combines regional commodity graphs into yearly graphs and updates circularity regression expectations.
| File | Description |
|---|---|
tests/data/circularity/commodity_prices.csv |
Updates expected circularity prices. |
tests/data/circularity/assets.csv |
Updates expected selected assets. |
tests/data/circularity/asset_capacities.csv |
Updates expected capacities and tranche counts. |
tests/data/circularity_npv/commodity_prices.csv |
Updates expected NPV scenario prices. |
tests/data/circularity_npv/assets.csv |
Updates NPV scenario asset selections. |
tests/data/circularity_npv/asset_capacities.csv |
Updates NPV scenario capacities. |
tests/cli.rs |
Checks the yearly graph filename. |
src/simulation/optimisation/constraints.rs |
Uses explicit demands and removes flexible-capacity constraints. |
src/simulation/optimisation.rs |
Accepts demand maps and removes capacity decision variables. |
src/simulation/market.rs |
Implements feedback detection and two-pass investment. |
src/simulation/investment.rs |
Supplies dispatch demands and introduces demand flooring. |
src/simulation.rs |
Passes preset demands to final dispatch. |
src/model/parameters.rs |
Removes capacity_margin. |
src/input.rs |
Loads yearly graphs and propagates ordering errors. |
src/graph/validate.rs |
Validates region-aware nodes and edges. |
src/graph/investment.rs |
Adds external-supply tracking and cycle-order constraints. |
src/graph.rs |
Builds and exports one region-aware graph per year. |
schemas/input/model.yaml |
Removes the capacity-margin schema entry. |
benches/assets.rs |
Adapts benchmark dispatch to explicit demands. |
Review effort: Balanced
| fn find_sourced_markets(graph: &CommoditiesGraph) -> HashSet<MarketSet> { | ||
| graph | ||
| .edge_references() | ||
| .filter(|e| matches!(graph[e.source()], GraphNode::Source)) |
Comment on lines
+337
to
+342
| // Make sure the SCC has at least one external incoming edge - panic if not as this should | ||
| // not happen | ||
| assert!( | ||
| has_external_incoming.contains(&true), | ||
| "SCC {scc_display} has no inputs" | ||
| ); |
Comment on lines
+424
to
+425
| let required = if has_external_incoming[i] { 0.0 } else { 1.0 }; | ||
| problem.add_row(required.., incoming_terms); |
Comment on lines
+188
to
+190
| if *value < Flow(0.0) { | ||
| *value = Flow(0.0); | ||
| } |
Comment on lines
+267
to
+269
| if !process.active_for_year(year) { | ||
| continue; | ||
| } |
tsmbland
force-pushed
the
graph_multi_region
branch
from
November 2, 2026 09:55
35a8154 to
5e22b4a
Compare
tsmbland
force-pushed
the
circularity_milp
branch
from
November 2, 2026 09:58
948f1b7 to
11a4689
Compare
Fix MILP error Comments to order_scc
Fix doc build
Fix for select_assets_for_cycle
tsmbland
force-pushed
the
circularity_milp
branch
from
November 2, 2026 15:51
11a4689 to
87919cc
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Similar to #1547, but doesn't require/allow users to manually mark feedback processes. These are detected based on which commodities end up out of order in the MILP result, with an added constraint to make sure that the system remains valid once feedback processes are removed (necessary for the second investment pass). I imagine this PR is the one we'll merge over #1547, if this two-pass approach proves useful, but that other PR is useful for testing different
feedback_processconfigurations.Fixes # (issue)
Type of change
Key checklist
$ cargo test$ cargo docpresent in the previous release
Further checks