Skip to content

Get activities from agent-level optimisations - #1585

Open
tsmbland wants to merge 11 commits into
competitive_algorithm_market_pricesfrom
activities_from_investment
Open

tsmbland wants to merge 11 commits into
competitive_algorithm_market_pricesfrom
activities_from_investment

Conversation

@tsmbland

@tsmbland tsmbland commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Description

This adds infrastructure to allow us to extract activities from agent-level optimisations. We don't actually use these yet, but we will.

In the base year things will be different: we need to work out how agents will dispatch their existing assets, without investing in new ones. I've added the concept of "committed" assets (i.e. assets that have to be kept and used), and two different agent run modes: dispatch (just dispatch committed assets) and invest (invest/retain assets and dispatch them), the former applying to the base year and the latter to all other years. This will be wired up properly in a future PR.

Probably should have broken this into two PRs, but too fiddly now.

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 cumulative_appraisal November 10, 2026 14:51
@tsmbland
tsmbland added this pull request to stack #1584 November 10, 2026 15:25
@tsmbland
tsmbland force-pushed the activities_from_investment branch from 02eb149 to 7c3ebb8 Compare November 10, 2026 15:54
@tsmbland
tsmbland removed this pull request from stack #1584 November 10, 2026 15:58
@tsmbland
tsmbland changed the base branch from cumulative_appraisal to competitive_algorithm_market_prices November 10, 2026 15:59
@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 activities_from_investment branch 5 times, most recently from 76d0e13 to d231c0b Compare November 16, 2026 10:54
@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 59.09091% with 171 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.15%. Comparing base (3d79213) to head (e17110e).

Files with missing lines Patch % Lines
src/simulation/investment/competitive.rs 0.00% 85 Missing ⚠️
src/simulation/market.rs 51.92% 47 Missing and 3 partials ⚠️
.../simulation/investment/competitive/optimisation.rs 0.00% 22 Missing ⚠️
src/simulation/investment/portfolio.rs 91.66% 9 Missing ⚠️
src/simulation/investment/competitive/metrics.rs 0.00% 3 Missing ⚠️
src/simulation.rs 88.88% 0 Missing and 1 partial ⚠️
src/simulation/investment.rs 98.36% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@                           Coverage Diff                           @@
##           competitive_algorithm_market_prices    #1585      +/-   ##
=======================================================================
- Coverage                                82.31%   82.15%   -0.17%     
=======================================================================
  Files                                       68       69       +1     
  Lines                                     9812     9998     +186     
  Branches                                  9812     9998     +186     
=======================================================================
+ Hits                                      8077     8214     +137     
- Misses                                    1456     1507      +51     
+ Partials                                   279      277       -2     

☔ 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 force-pushed the activities_from_investment branch 3 times, most recently from cacabfc to 312a17a Compare November 16, 2026 13:32
@tsmbland
tsmbland requested a balanced review from Copilot November 16, 2026 13:40

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

Critical dispatch issues can leave demand unmet despite sufficient committed capacity and allow mothballed capacity to support activities beyond an asset’s active availability.

2 open issues
What changed in this PR

Adds infrastructure to return asset activities alongside agent selections in MUSE2, with committed assets and separate dispatch and investment modes. The simulation still uses investment mode and does not yet consume the returned activities.

Changes:

  • Introduces shared activity/flow maps and a Selection container.
  • Updates competitive and portfolio algorithms to return activities and support committed assets.
  • Propagates selections through market orchestration and updates tests and benchmarks.
File Description
src/​simulation/​optimisation.rs Reuses the shared flow-map conversion.
src/​simulation/​market.rs Propagates run modes and selections through markets and cycles.
src/​simulation/​investment/​portfolio/​optimisation.rs Adds fixed capacity variables for committed assets.
src/​simulation/​investment/​portfolio.rs Returns selections with activities and adds committed-asset tests.
src/​simulation/​investment/​competitive/​optimisation.rs Extracts a reusable fixed-asset solver.
src/​simulation/​investment/​competitive/​metrics.rs Uses the shared activity-map type.
src/​simulation/​investment/​competitive.rs Dispatches committed assets and returns final activities.
src/​simulation/​investment.rs Defines run modes and asset options; aggregates selections.
src/​simulation/​activity.rs Adds activity/flow types, selection helpers and tests.
src/​simulation.rs Adapts the investment caller to the new result type.
src/​output.rs Imports the relocated flow-map type.
src/​graph/​investment.rs Updates a function name in a documentation comment.
benches/​assets.rs Adapts benchmark setup to the revised competitive API.

Review effort: Balanced

Comment on lines +258 to +260
if !committed_assets.is_empty() {
(previous_solution, unmet_demand) =
solve_for_assets(model, &selected_assets, commodity, &coefficients, demand)?;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

No I think this is fine and consistent with the approach

Some(upper) => problem.add_column(cost, 0.0..=upper.value()),
None => problem.add_column(cost, 0.0..),
let var = if i < num_committed {
let capacity = asset.total_capacity().value();

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Technically true so I'll change it, but in practice committed assets (i.e. existing assets in the base year) will never be mothballed.

@tsmbland
tsmbland marked this pull request as ready for review November 16, 2026 14:11
@tsmbland tsmbland changed the title Get activities from asset-level optimisations Get activities from agent-level optimisations Nov 16, 2026
@tsmbland
tsmbland marked this pull request as draft November 16, 2026 14:11
@tsmbland
tsmbland force-pushed the activities_from_investment branch from 3527155 to e17110e Compare November 16, 2026 15:00
@tsmbland
tsmbland marked this pull request as ready for review November 16, 2026 15:03
@tsmbland
tsmbland requested a review from alexdewar November 16, 2026 15:03

This branch has not been deployed

No deployments
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.

2 participants