Skip to content

Refactor price calculation to take activities directly - #1586

Open
tsmbland wants to merge 1 commit into
activities_from_investmentfrom
prices_refactor
Open

tsmbland wants to merge 1 commit into
activities_from_investmentfrom
prices_refactor

Conversation

@tsmbland

@tsmbland tsmbland commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Description

This uncouples price calculation from full-system dispatch, so we can eventually calculate prices using agent-level activities

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 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 prices_refactor branch 5 times, most recently from dbbad15 to 24ff79a Compare November 16, 2026 10:54
@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.29412% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.02%. Comparing base (e17110e) to head (704bdb8).

Files with missing lines Patch % Lines
src/simulation/prices.rs 82.35% 12 Missing ⚠️
src/simulation.rs 0.00% 7 Missing and 2 partials ⚠️
Additional details and impacted files
@@                      Coverage Diff                       @@
##           activities_from_investment    #1586      +/-   ##
==============================================================
- Coverage                       82.15%   82.02%   -0.13%     
==============================================================
  Files                              69       69              
  Lines                            9998    10037      +39     
  Branches                         9998    10037      +39     
==============================================================
+ Hits                             8214     8233      +19     
- Misses                           1507     1527      +20     
  Partials                          277      277              

☔ 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 prices_refactor branch 3 times, most recently from fd9df9b to 240054f Compare November 16, 2026 13:32
@tsmbland
tsmbland requested a balanced review from Copilot November 16, 2026 13:41

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.

🟢 Approval recommended

The pricing-input refactor has no active review issues.

No open issues 🎉

What changed in this PR

Decouples commodity price calculation from dispatch solutions, preparing the simulation to calculate prices from agent-level activities.

Changes:

  • Makes the core pricing function accept activities, candidates, shadow prices, and activity duals directly.
  • Adds solution-to-map helpers and a wrapper for dispatch-based pricing.
  • Updates simulation and benchmark callers to use the wrapper.
File Description
src/​simulation/​prices.rs Refactors pricing inputs and adds the dispatch-solution wrapper.
src/​simulation/​optimisation.rs Adds activity and dual map extraction helpers.
src/​simulation/​activity.rs Defines the activity-dual map type.
src/​simulation.rs Updates dispatch pricing calls to use the wrapper.
benches/​assets.rs Updates benchmark seed-price calculation to use the wrapper.

Review effort: Balanced

@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