Repository navigation
Allow assets to have continuous (non-tranched) capacities - #1573
Conversation
f8a04d9 to
bf2a63f
Compare
8ce12fb to
a9d1198
Compare
a9d1198 to
ed42637
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Partial continuous mothballing and decommissioning lack lifecycle test coverage, and the output schema does not document that tranche counters are empty for continuous capacities.
2 open issues
What changed in this PR
Restores continuous asset capacities in MUSE2, preparing for the non-tranched asset-selection algorithm in #1574 while preserving discrete-capacity support.
Changes:
- Adds continuous capacity representation and capacity-based mothballing and decommissioning.
- Treats input assets without tranche settings as continuous and leaves their output tranche counts blank.
- Updates input documentation, unit tests and regression expectations.
| File | Description |
|---|---|
| tests/data/two_regions/asset_capacities.csv | Expects blank continuous-asset tranche counts. |
| tests/data/two_outputs/asset_capacities.csv | Updates tranche-count expectations. |
| tests/data/simple/asset_capacities.csv | Updates baseline tranche-count expectations. |
| tests/data/simple_tranche_size/asset_capacities.csv | Preserves explicit tranches alongside continuous assets. |
| tests/data/simple_shadow/asset_capacities.csv | Updates shadow-pricing output expectations. |
| tests/data/simple_npv/asset_capacities.csv | Updates net-present-value output expectations. |
| tests/data/simple_mothball/asset_capacities.csv | Updates continuous mothballing output expectations. |
| tests/data/simple_marginal/asset_capacities.csv | Updates marginal-pricing output expectations. |
| tests/data/simple_marginal_average/asset_capacities.csv | Updates average marginal-pricing expectations. |
| tests/data/simple_ironing_out/asset_capacities.csv | Updates ironing-out scenario expectations. |
| tests/data/simple_full/asset_capacities.csv | Updates full-output scenario expectations. |
| tests/data/muse1_default/asset_capacities.csv | Updates default-example tranche counts. |
| tests/data/missing_commodity/asset_capacities.csv | Updates missing-commodity scenario expectations. |
| tests/data/circularity/asset_capacities.csv | Updates circularity scenario expectations. |
| tests/data/circularity_npv/asset_capacities.csv | Updates circularity valuation expectations. |
| src/simulation/investment/competitive.rs | Adapts selection to capacity-based unmothballing. |
| src/output.rs | Serialises optional tranche counts. |
| src/input/asset.rs | Loads assets without tranche settings as continuous. |
| src/fixture.rs | Uses the discrete-capacity constructor. |
| src/asset/pool.rs | Tracks unretained capacity rather than tranche counts. |
| src/asset/capacity.rs | Adds continuous and discrete capacity variants. |
| src/asset.rs | Converts lifecycle bookkeeping to capacity amounts. |
| schemas/input/processes.yaml | Documents the continuous-capacity fallback. |
| schemas/input/assets.yaml | Explains omitted tranche settings. |
| docs/model/investment.md | Describes continuous assets and current selection behaviour. |
Review effort: Balanced
b2a4f17 to
d850ace
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1573 +/- ##
==========================================
- Coverage 89.26% 89.18% -0.09%
==========================================
Files 63 63
Lines 9244 9294 +50
Branches 9244 9294 +50
==========================================
+ Hits 8252 8289 +37
- Misses 675 685 +10
- Partials 317 320 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
d850ace to
3544e4c
Compare
alexdewar
left a comment
There was a problem hiding this comment.
Always a bit galling to have to undo refactoring like this, but it all seems fine to me.
| /// Returns the number of tranches if this capacity is discrete, or `None` if continuous. | ||
| pub fn num_tranches(&self) -> Option<u32> { | ||
| match self { | ||
| AssetCapacity::Continuous(_) => None, | ||
| AssetCapacity::Discrete { num_tranches, .. } => Some(*num_tranches), | ||
| } | ||
| } |
There was a problem hiding this comment.
Could we just return 1 instead of None for the Continuous case? For the mothballing stuff, I treated Continuous capacities as if they had one tranche and it made things a bit simpler, but I don't know whether it might break things if we did the same thing everywhere.
| /// Whether this capacity is zero. | ||
| /// | ||
| /// Continuous capacities are treated as zero if they are within a small tolerance of zero, to | ||
| /// allow for floating-point error (e.g. after subtracting almost-equal capacities). | ||
| pub fn is_zero(&self) -> bool { | ||
| match self { | ||
| AssetCapacity::Continuous(capacity) => capacity.abs() <= Capacity(1e-9), | ||
| AssetCapacity::Discrete { num_tranches, .. } => *num_tranches == 0, | ||
| } | ||
| } |
There was a problem hiding this comment.
I feel like it might be clearer to call this is_approx_zero. Would it be worth using the approx_eq! macro for this?
It seems a little wrong that you could have a Discrete capacity with one tranche of size <1e-9 that isn't treated in the same way as a Continuous capacity with the same total capacity. Should we make it consistent?
|
Oops, accidentally reviewed this before #1577. I'll review that one now. |
3544e4c to
9769290
Compare
9769290 to
e59f57c
Compare
e59f57c to
1c7d608
Compare


Description
This one was frustrating. Adam wants the new asset selection algorithm (#1574) to not use tranching, which means adding back the ability for assets to have continuous capacities, after we recently removed this ability.
Fortunately a lot of this was just reverting previous commits and fixing up conflicts. I needed a way for mothballing to work with continuous capacities, so rather than storing tranche counts it now stores
AssetCapacitys. The output files have a few columns representing tranche counts, so I've made it so these are blank for assets with continuous capacities.Fixes # (issue)
Type of change
Key checklist
$ cargo test$ cargo docpresent in the previous release
Further checks