Tranching refactor#1391
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1391 +/- ##
==========================================
- Coverage 89.60% 89.47% -0.14%
==========================================
Files 58 58
Lines 8338 8329 -9
Branches 8338 8329 -9
==========================================
- Hits 7471 7452 -19
- Misses 550 560 +10
Partials 317 317 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR refactors the investment “tranching” flow to appraise assets based on their pre-set capacities (rather than passing a separate max_capacity through appraisal/optimisation), tightens capacity_to_activity validation, and updates regression/example outputs to match the new behaviour.
Changes:
- Simplifies appraisal/optimisation by removing the
max_capacityparameter and usingasset.capacity()directly throughout. - Updates investment candidate handling and investment-limit collection so annual addition limits are no longer capped by the original demand-limiting capacity (DLC), while still capping per-round capacity by current DLC and remaining addition limits.
- Disallows
capacity_to_activity = 0and propagates the validation change through schema + release notes, updating regression datasets accordingly.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/data/two_regions/commodity_prices.csv | Updated regression output values for prices under the new investment/appraisal behaviour. |
| tests/data/two_regions/commodity_flows.csv | Updated regression output values for flows under the new investment/appraisal behaviour. |
| tests/data/two_regions/asset_capacities.csv | Updated regression output values for installed capacities under the new selection logic. |
| tests/data/muse1_default/commodity_prices.csv | Updated example/regression output values for prices. |
| tests/data/muse1_default/commodity_flows.csv | Updated example/regression output values for flows. |
| tests/data/muse1_default/asset_capacities.csv | Updated example/regression output values for capacities. |
| src/simulation/investment/appraisal/optimisation.rs | Removes max_capacity plumbing and constrains activities based on asset.capacity(). |
| src/simulation/investment/appraisal/constraints.rs | Updates activity constraints to derive bounds from the asset’s capacity. |
| src/simulation/investment/appraisal.rs | Removes hypothetical capacity from AppraisalOutput and appraises strictly using the asset’s capacity. |
| src/simulation/investment.rs | Refactors candidate generation + limit collection and adjusts selection/update logic accordingly. |
| src/output.rs | Writes appraisal result capacity from the asset’s capacity (since AppraisalOutput.capacity is removed). |
| src/input/process.rs | Tightens validation to require capacity_to_activity > 0. |
| src/fixture.rs | Updates fixtures to reflect AppraisalOutput no longer carrying a separate capacity field. |
| schemas/input/processes.yaml | Updates schema notes to require capacity_to_activity > 0. |
| docs/release_notes/upcoming.md | Adds release note entry for the capacity_to_activity > 0 validation change. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Description
I've taken some of the main refactoring/small improvements from #1358 and made this a standalone PR.
max_capacityargument. Also,compare_metricno longer needs to check if capacities are zero, as we can do this beforehandcapacity_to_activityvalidation to disallow 0calculate_investment_limits_for_candidates(nowcollect_investment_limits_for_candidates) no longer caps capacities based on the original demand limiting capacity (DLC). Effectively, this means that we can now install more than DLC capacity each year. This helps with Problem treating tranches as separate assets #1383 and simplifies the code/model.Fixes # (issue)
Type of change
Key checklist
$ cargo test$ cargo docpresent in the previous release
Further checks