Skip to content

Tidy mothballing - #1538

Merged
tsmbland merged 5 commits into
mainfrom
tidy_mothballing
Sep 9, 2026
Merged

tsmbland merged 5 commits into
mainfrom
tidy_mothballing

Conversation

@tsmbland

@tsmbland tsmbland commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Description

Rather than representing a mothballed asset as a new asset with a reduced capacity, this changes the key methods in Asset to take mothballed capacity into account. This allows with_subset_of_tranches to be removed.

Fixes #1460

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

@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.84%. Comparing base (e467309) to head (145d87c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1538      +/-   ##
==========================================
- Coverage   90.85%   90.84%   -0.02%     
==========================================
  Files          61       61              
  Lines        9042     9019      -23     
  Branches     9042     9019      -23     
==========================================
- Hits         8215     8193      -22     
+ Misses        508      507       -1     
  Partials      319      319              

☔ 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.

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

A now-incorrect dispatch doc comment and a brittle hard-coded tranche size in a test should be fixed to prevent confusion/regressions.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR changes how mothballed capacity is represented in dispatch by making core Asset activity/capacity logic account for mothballed tranches directly, allowing mothballed assets to remain in dispatch/output with zero activity/flows instead of being filtered out or represented as separate reduced-capacity assets.

Changes:

  • Update Asset activity limit calculations to use active (non-mothballed) capacity.
  • Remove dispatch-time filtering/subsetting of mothballed tranches so mothballed assets can still appear in flow outputs.
  • Update golden test data for simple_mothball to include zero flows for mothballed assets.
File summaries
File Description
tests/data/simple_mothball/commodity_flows.csv Updates expected output to include (zero) flows for mothballed assets.
src/simulation/investment/appraisal/constraints.rs Switches appraisal activity constraints to use absolute activity limits from Asset.
src/simulation.rs Removes the dispatch-time filtering that previously excluded mothballed tranches/assets.
src/asset/pool.rs Updates a pool test to avoid with_subset_of_tranches by directly adjusting capacity.
src/asset.rs Introduces active_capacity() and applies it to activity limit/max activity calculations; removes with_subset_of_tranches.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/asset/pool.rs
Comment on lines +632 to +635
let mut retained = full.clone();
retained
.make_mut()
.set_capacity(AssetCapacity::new(2, Capacity(4.0)));
Comment thread src/simulation.rs
@tsmbland
tsmbland marked this pull request as ready for review September 9, 2026 15:12
@tsmbland
tsmbland merged commit 07b0372 into main Sep 9, 2026
10 checks passed
@tsmbland
tsmbland deleted the tidy_mothballing branch September 9, 2026 15:14
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.

Include flows for mothballed assets in commodity_flows.csv

2 participants