Skip to content

Add population agent type - #1603

Draft
tsmbland wants to merge 5 commits into
agent_dispatch_simulation_protocolfrom
population_agents
Draft

tsmbland wants to merge 5 commits into
agent_dispatch_simulation_protocolfrom
population_agents

Conversation

@tsmbland

@tsmbland tsmbland commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Adds a new agent type, as described in the docs

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 #1594 November 17, 2026 13:58
@codecov

codecov Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.38596% with 141 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.69%. Comparing base (d4ccfb3) to head (eacafe3).

Files with missing lines Patch % Lines
src/simulation/investment/population.rs 73.46% 101 Missing and 3 partials ⚠️
src/simulation/investment/population/metrics.rs 55.00% 18 Missing ⚠️
src/simulation/investment/population/costs.rs 62.50% 6 Missing ⚠️
src/simulation/investment/population/output.rs 87.23% 2 Missing and 4 partials ⚠️
...rc/simulation/investment/population/constraints.rs 97.24% 2 Missing and 1 partial ⚠️
...c/simulation/investment/population/optimisation.rs 96.20% 2 Missing and 1 partial ⚠️
src/simulation/market.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                          Coverage Diff                           @@
##           agent_dispatch_simulation_protocol    #1603      +/-   ##
======================================================================
+ Coverage                               75.45%   75.69%   +0.24%     
======================================================================
  Files                                      73       79       +6     
  Lines                                   10246    10930     +684     
  Branches                                10246    10930     +684     
======================================================================
+ Hits                                     7731     8274     +543     
- Misses                                   2244     2376     +132     
- Partials                                  271      280       +9     

☔ 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

Critical capacity-handling errors can violate committed assets’ minimum activity bounds and round selected capacity twice, allowing dispatch beyond the returned asset’s capacity.

2 open issues
What changed in this PR

Adds a population agent type to MUSE2’s investment simulation. It represents entities with identical needs by appraising each asset against the full demand profile, then selecting assets in merit order.

Changes:

  • Registers population agents in model input and market execution.
  • Implements profile optimisation, cost ranking, capacity selection and debug output, with initial tests.
  • Documents the new agent’s behaviour and adds a release note.
File Description
src/​simulation/​market.rs Routes population agents to their selection algorithm.
src/​simulation/​investment/​population/​output.rs Adds appraisal debug output and a serialisation test.
src/​simulation/​investment/​population/​optimisation.rs Optimises each option against the full demand profile.
src/​simulation/​investment/​population/​metrics.rs Ranks appraisals by cost and asset tie-break rules.
src/​simulation/​investment/​population/​costs.rs Calculates annual fixed costs for appraisal.
src/​simulation/​investment/​population/​constraints.rs Defines availability, demand and utilisation constraints.
src/​simulation/​investment/​population.rs Implements asset selection, capacity limits and initial tests.
src/​simulation/​investment.rs Exposes the population module.
src/​input/​agent.rs Tests parsing the population agent type.
src/​agent.rs Adds the Population enum variant.
schemas/​input/​agents.yaml Allows and describes population agents in input.
docs/​release_notes/​upcoming.md Announces the new agent type.
docs/​model/​investment.md Documents population capacity and retention behaviour.
docs/​model/​agents.md Explains population appraisal and asset selection.

Review effort: Balanced

Comment on lines +224 to +228
let selected_capacity = capacity_for_remaining_demand(
appraisal.capacity,
remaining_demand_fraction(demand, &remaining_demand),
)
.min(appraisal.asset.active_capacity());
continue;
}

let selected_asset = selected_asset(&appraisal.asset, selected_capacity, agent);

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