Skip to content

Allow assets to have continuous (non-tranched) capacities - #1573

Merged
tsmbland merged 6 commits into
mainfrom
continuous_capacities
Nov 13, 2026
Merged

tsmbland merged 6 commits into
mainfrom
continuous_capacities

Conversation

@tsmbland

@tsmbland tsmbland commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

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

  • Bug fix (non-breaking change to fix an issue)
  • New feature (non-breaking change to add functionality)
  • Refactoring (non-breaking, non-functional change to improve maintainability)
  • Optimization (non-breaking change to speed up the code)
  • Breaking change (whatever its nature)
  • Documentation (improve or add documentation)

Key checklist

  • All tests pass: $ cargo test
  • The documentation builds and looks OK: $ cargo doc
  • Update release notes for the latest release if this PR adds a new feature or fixes a bug
    present in the previous release

Further checks

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

@tsmbland
tsmbland changed the base branch from main to circularity_milp October 29, 2026 11:14
@tsmbland
tsmbland force-pushed the continuous_capacities branch from f8a04d9 to bf2a63f Compare October 29, 2026 13:38
github-actions[bot]

This comment was marked as outdated.

@tsmbland
tsmbland force-pushed the continuous_capacities branch 2 times, most recently from 8ce12fb to a9d1198 Compare November 4, 2026 13:48
@tsmbland
tsmbland changed the base branch from circularity_milp to multi_investment_algorithms_prep November 4, 2026 13:49
@tsmbland tsmbland changed the title Restore continuous capacities Allow assets to have continuous (non-tranched) capacities Nov 4, 2026
@tsmbland
tsmbland force-pushed the continuous_capacities branch from a9d1198 to ed42637 Compare November 9, 2026 15:50
@tsmbland
tsmbland marked this pull request as ready for review November 9, 2026 16:06
@tsmbland
tsmbland requested a balanced review from Copilot November 9, 2026 16:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment thread src/asset.rs Resolved
Comment thread src/output.rs Resolved
@tsmbland
tsmbland requested a review from alexdewar November 9, 2026 16:16
@tsmbland
tsmbland added this pull request to stack #1584 November 10, 2026 11:27
@tsmbland
tsmbland force-pushed the continuous_capacities branch from b2a4f17 to d850ace Compare November 10, 2026 11:53
@codecov

codecov Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.02454% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.18%. Comparing base (bd37615) to head (1c7d608).

Files with missing lines Patch % Lines
src/asset.rs 85.33% 8 Missing and 3 partials ⚠️
src/asset/capacity.rs 97.22% 2 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tsmbland
tsmbland removed this pull request from stack #1584 November 10, 2026 15:58
@tsmbland
tsmbland added this pull request to stack #1588 November 10, 2026 16:00
@tsmbland
tsmbland removed this pull request from stack #1588 November 11, 2026 16:29
@tsmbland
tsmbland added this pull request to stack #1594 November 11, 2026 16:29
@tsmbland
tsmbland force-pushed the continuous_capacities branch from d850ace to 3544e4c Compare November 12, 2026 16:13

@alexdewar alexdewar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always a bit galling to have to undo refactoring like this, but it all seems fine to me.

Comment thread src/asset/capacity.rs
Comment on lines +62 to 68
/// 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),
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/asset/capacity.rs
Comment on lines +92 to +101
/// 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,
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@alexdewar

Copy link
Copy Markdown
Member

Oops, accidentally reviewed this before #1577. I'll review that one now.

@tsmbland
tsmbland force-pushed the continuous_capacities branch from 3544e4c to 9769290 Compare November 13, 2026 14:02
Base automatically changed from multi_investment_algorithms_prep to main November 13, 2026 16:10
@tsmbland
tsmbland force-pushed the continuous_capacities branch from 9769290 to e59f57c Compare November 13, 2026 16:10
@tsmbland
tsmbland force-pushed the continuous_capacities branch from e59f57c to 1c7d608 Compare November 13, 2026 16:13
@tsmbland
tsmbland enabled stacked auto-merge November 13, 2026 16:13
@tsmbland
tsmbland merged commit 6bd113c into main Nov 13, 2026
@tsmbland
tsmbland deleted the continuous_capacities branch November 13, 2026 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants