Skip to content

Add agent_dispatch simulation protocol - #1593

Draft
tsmbland wants to merge 12 commits into
simulation_mode_refactor_v2from
agent_dispatch_simulation_protocol
Draft

tsmbland wants to merge 12 commits into
simulation_mode_refactor_v2from
agent_dispatch_simulation_protocol

Conversation

@tsmbland

Copy link
Copy Markdown
Collaborator

Flows and prices come directly from the activities determined by agents' own optimisations, with no system-wide dispatch. Adds Selection::commission, an AgentActivities FlowEstimator, schema/docs/release notes, and makes unmet demand in competitive appraisal an error for all protocols.

Description

Please include a summary of the change and which issue is fixed (if any). Please also
include relevant motivation and context. List any dependencies that are required for
this change.

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 11, 2026 16:30
@tsmbland
tsmbland force-pushed the agent_dispatch_simulation_protocol branch 8 times, most recently from 5d1baf8 to 9ea0958 Compare November 16, 2026 15:35
@tsmbland
tsmbland requested a balanced review from Copilot November 16, 2026 15:44

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 agent-dispatch defects can leave demand unmet despite sufficient capacity, bypass commodity limits, and accept unbalanced cyclic flows, while the protocol change also breaks regression fixtures.

4 open issues
What changed in this PR

Adds agent_dispatch as MUSE2’s default simulation protocol, deriving commodity flows and prices directly from agents’ optimisations without system-wide dispatch.

Changes:

  • Implements agent-driven dispatch, iterative investment pricing, and activity re-keying when assets are commissioned.
  • Makes agent_dispatch the default and requires dangerous-options opt-in for system_dispatch.
  • Makes unmet demand in competitive appraisal an error and updates schemas and documentation.
File Description
src/​simulation/​investment/​competitive.rs Errors when appraisal leaves demand unmet.
src/​simulation/​investment.rs Adds and tests commissioning with activity re-keying.
src/​simulation/​agent_dispatch.rs Implements the agent-dispatch simulation lifecycle and flow estimator.
src/​simulation.rs Registers agent dispatch and makes it the default.
src/​model/​parameters.rs Adds experimental-protocol validation and removes previous protocol-parsing tests.
src/​asset/​pool.rs Clarifies returned asset ordering in documentation.
schemas/​input/​model.yaml Documents both protocols, the new default, and opt-in requirements.
docs/​release_notes/​upcoming.md Announces agent dispatch and the default change.
docs/​model/​README.md Explains the new protocol and system-dispatch opt-in.
docs/​model/​prices.md Describes activity-based pricing and documents full_average.
docs/​model/​investment.md Updates flow propagation and unmet-demand behaviour.
docs/​model/​commodity_graphs.md Makes demand-update descriptions protocol-neutral.
docs/​model/​agents.md Updates price sourcing and competitive-appraisal failure behaviour.
docs/​glossary.md Revises dispatch, ironing-out, and pricing definitions.
docs/​developer_guide/​custom_highs_options.md Clarifies that dispatch solver options remain system-dispatch-specific.

Review effort: Balanced

Comment thread src/simulation.rs Resolved
Comment on lines +22 to +32
use anyhow::{Context, Result};
use log::info;

/// Run the simulation using the `agent_dispatch` protocol.
///
/// # Arguments:
///
/// * `model` - The model to run
/// * `writer` - The data writer to which results are written
#[allow(clippy::too_many_lines)]
pub fn run(model: &Model, writer: &mut DataWriter) -> Result<()> {

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.

Agree. Think we should hide commodity constraints behind the broken options guard (if not already).

Comment on lines +65 to +66
AgentRunMode::Dispatch,
&Prices::default(),

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.

I think this is a known issue and fine for now

Comment thread src/simulation/agent_dispatch.rs Resolved
@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.18421% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.45%. Comparing base (88a3311) to head (88c5022).

Files with missing lines Patch % Lines
src/simulation/agent_dispatch.rs 88.39% 0 Missing and 13 partials ⚠️
src/simulation/investment/competitive.rs 0.00% 5 Missing ⚠️
src/model/parameters.rs 80.00% 1 Missing and 1 partial ⚠️
src/simulation.rs 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@                       Coverage Diff                       @@
##           simulation_mode_refactor_v2    #1593      +/-   ##
===============================================================
- Coverage                        82.80%   75.45%   -7.36%     
===============================================================
  Files                               72       73       +1     
  Lines                            10115    10246     +131     
  Branches                         10115    10246     +131     
===============================================================
- Hits                              8376     7731     -645     
- Misses                            1465     2244     +779     
+ Partials                           274      271       -3     

☔ 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 and others added 12 commits November 17, 2026 14:31
Flows and prices come directly from the activities determined by agents'
own optimisations, with no system-wide dispatch. Adds Selection::commission,
an AgentActivities FlowEstimator, schema/docs/release notes, and makes unmet
demand in competitive appraisal an error for all protocols.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@tsmbland
tsmbland force-pushed the agent_dispatch_simulation_protocol branch from d4ccfb3 to 88c5022 Compare November 17, 2026 14:32

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