Repository navigation
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1569 +/- ##
==========================================
+ Coverage 90.88% 90.90% +0.01%
==========================================
Files 61 61
Lines 9121 9116 -5
Branches 9121 9116 -5
==========================================
- Hits 8290 8287 -3
+ Misses 509 507 -2
Partials 322 322 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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: ee7882f | Previous: 6a19604 | Ratio |
|---|---|---|---|
example_run/two_outputs example |
639063963.5 ns |
485146523.5 ns |
1.32 |
select_best_assets_parallel/01 |
13654279.702380951 ns |
9132896.765151516 ns |
1.50 |
select_best_assets_parallel/05 |
38994977.875 ns |
26819628.777777776 ns |
1.45 |
select_best_assets_parallel/10 |
66406262.33333333 ns |
45113674.75 ns |
1.47 |
select_best_assets_parallel/15 |
96065833.75 ns |
65351435.33333333 ns |
1.47 |
select_best_assets_parallel/20 |
129487808.75 ns |
85097739.5 ns |
1.52 |
select_best_assets_sequential/01 |
13742472.66025641 ns |
9107675.635526314 ns |
1.51 |
select_best_assets_sequential/05 |
65061327.5 ns |
43859325.75 ns |
1.48 |
select_best_assets_sequential/10 |
129810393.25 ns |
87553632.5 ns |
1.48 |
select_best_assets_sequential/15 |
193924851.5 ns |
131658938.5 ns |
1.47 |
select_best_assets_sequential/20 |
258691192 ns |
175652280.5 ns |
1.47 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
🟡 Changes recommended
Repeated demand-map and graph-node scans introduce validation scaling regressions as model size increases.
2 open issues
What changed in this PR
Combines regional commodity graphs into one graph per year, simplifying graph handling and preparing MUSE2 for future inter-region trade.
Changes:
- Adds region identities to commodity nodes and process edges.
- Adapts validation and investment ordering to year-keyed graphs.
- Saves one DOT file per year and updates affected tests.
| File | Description |
|---|---|
tests/cli.rs |
Expects the year-only DOT filename. |
src/input.rs |
Returns commodity graphs keyed by year. |
src/graph/validate.rs |
Uses regional edge availability and demand in combined graphs. |
src/graph/investment.rs |
Derives investment order from a single yearly graph. |
src/graph.rs |
Builds region-qualified yearly graphs and updates DOT output. |
Review effort: Balanced
| for ((region_id, dem_year, dem_ts_sel), &flow) in &commodity.demand { | ||
| if *dem_year != year || dem_ts_sel != time_slice_selection || flow <= Flow(0.0) { |
| let commodity_node_index = filtered_graph | ||
| .node_indices() | ||
| .find(|&idx| filtered_graph.node_weight(idx) == Some(&commodity_node)) | ||
| .unwrap_or_else(|| { | ||
| filtered_graph.add_node(GraphNode::Commodity(commodity_id.clone())) | ||
| }); | ||
| .unwrap_or_else(|| filtered_graph.add_node(commodity_node)); |
35a8154 to
5e22b4a
Compare

Description
We currently build separate commodity graphs for each region, which we then combine into a single investment graph to get the investment order. This works ok for now, as there aren't any edges between regions (that would imply trade), but this is surely something that we'll want. The way I see it, there's no reason to have multi-region models if we don't have trade, so either way building separate graphs for different regions is a bit dumb. Not a high priority, but I think there will be some changes incoming to the graph code, and I wanted to get this out of the way. I think it's also a bit more consistent with how the rest of the code works.
I first tried this when we were discussing trade (https://github.com/EnergySystemsModellingLab/MUSE2/tree/rough_trade_implementation), and I've mostly just copied over some of the changes from that. There are some other changes in that branch about allowing flows between regions, and prettifying the graph, which I haven't copied over, but these can come later.
Copilot has flagged some performance issues, which I think I agree with, although they're probably minor.
Fixes # (issue)
Type of change
Key checklist
$ cargo test$ cargo docpresent in the previous release
Further checks