Exclude mothballed assets from main dispatch - #1458
Conversation
We don't want mothballed assets contributing to either flows or prices.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1458 +/- ##
==========================================
- Coverage 89.66% 89.52% -0.15%
==========================================
Files 60 60
Lines 8523 8542 +19
Branches 8523 8542 +19
==========================================
+ Hits 7642 7647 +5
- Misses 560 573 +13
- Partials 321 322 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This pull request fixes dispatch correctness when the mothballing feature is enabled by ensuring mothballed (inactive) assets do not contribute to the main annual dispatch run, while still allowing assets revived via investment selection to participate.
Changes:
- Unmothball commissioned assets at the point they are selected during investment so they are treated as active immediately.
- Filter mothballed assets out of
run_dispatch_for_yearso the main dispatch run uses only active assets for flows/prices. - Add a new patched regression scenario (
simple_mothball) and expected outputs to exercise mothballing behaviour.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/regression.rs | Registers the new patched regression test case. |
| tests/data/simple_mothball/commodity_prices.csv | Expected prices for the new mothball regression scenario. |
| tests/data/simple_mothball/commodity_flows.csv | Expected flows for the new mothball regression scenario. |
| tests/data/simple_mothball/assets.csv | Expected asset list for the new mothball regression scenario. |
| tests/data/simple_mothball/asset_capacities.csv | Expected capacities for the new mothball regression scenario. |
| src/simulation/investment.rs | Unmothballs commissioned assets immediately when selected for retention. |
| src/simulation.rs | Excludes mothballed assets from the main dispatch run and documents the behaviour. |
| src/example/patches.rs | Adds the simple_mothball patched example (sets mothball_years = 10). |
| src/asset/pool.rs | Adjusts mothballing/extension behaviour to align with unmothball-at-selection. |
| src/asset.rs | Makes mothball state queryable via is_mothballed() and makes get_mothballed_year() non-panicking. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tsmbland
left a comment
There was a problem hiding this comment.
Looks good. Good idea adding a patch test. Looks like most mothballed assets weren't being used anyway, apart from one which has some knock on consequences when excluded.
Do you think it might still be worth including mothballed assets in commodity_flows.csv (showing zero activity?).
Also, beyond the scope of this PR, but some way of representing mothballing decisions in the output data so it's clear to users (maybe splitting mothballed/non-mothballed capacity in asset_capacities.csv, although there's probably a nicer way)?
Good point.
These are both good ideas, but I think I'll open issues rather than trying to tackle them now. I'm just finishing up a bigger refactor of the mothballing code to support partially mothballed assets, which we (unfortunately) need for #1123. |
Description
MUSE2 has a feature where assets can be mothballed instead of being decommissioned immediately, with the assets eventually decommissioned after a period indicated by
mothball_yearsif they remain unused. In the interim, they can be revived if selected for investment.During investment, we include mothballed assets during dispatch runs as we want them to contribute to prices and flows. For the main dispatch run in
run_dispatch_for_year, however, we shouldn't be including them, as they are technically inactive and so should not contribute to flows and prices. Of course, if they have been mothballed, the model has deemed them superfluous, so we wouldn't expect them to contribute much, but it would be better to exclude them explicitly. With local testing, I found that mothballed assets were contributing a non-negligible amount to flows and prices.The way the code is currently written, selected assets remain in a mothballed state until they are added back to the
AssetPool, at which point they are unmothballed. However, by virtue of having been selected, they are effectively no longer mothballed and so should be included in the dispatch run. I decided the cleanest way to implement this was to instead unmothball assets at the point they are selected and then unconditionally exclude mothballed assets inrun_dispatch_for_year.By default, the mothballing feature is disabled (
mothball_yearsdefaults to zero) and none of the existing regression tests exercise this part of the code, so I've added a new regression test to cover this case. If you want to see how excluding mothballed assets from dispatch affects results, see 6ec71bd. A regression test is also useful for all the refactoring I'll be doing for #1123, which involves a lot of fiddling with the mothballing-related code.Type of change
Key checklist
$ cargo test$ cargo docpresent in the previous release
Further checks