Repository navigation
Conversation
7e8fd94 to
40e4737
Compare
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are identified for the agent-selection refactor.
No open issues 🎉
What changed in this PR
Refactors asset selection to support multiple agent algorithms, isolating the existing behaviour as competitive and preparing for the portfolio algorithm described in #1574.
Changes:
- Adds an optional
agent_typeinput, defaulting tocompetitive, and routes market selection accordingly. - Moves competitive selection, appraisal and debug output into a dedicated module.
- Adds reusable custom debug writers and updates tests, fixtures and benchmark imports.
| File | Description |
|---|---|
tests/data/simple/debug_asset_selection_competitive.csv |
Adds expected competitive-selection debug output. |
src/simulation/market.rs |
Routes asset selection by agent type. |
src/simulation/investment/competitive/optimisation.rs |
Updates imports for the relocated optimisation code. |
src/simulation/investment/competitive/metrics.rs |
Relocates appraisal metrics and narrows visibility. |
src/simulation/investment/competitive/debug.rs |
Owns competitive debug CSV output and its tests. |
src/simulation/investment/competitive/costs.rs |
Houses competitive appraisal cost calculations. |
src/simulation/investment/competitive/constraints.rs |
Updates imports for relocated appraisal constraints. |
src/simulation/investment/competitive/coefficients.rs |
Adjusts coefficient interfaces and helper visibility. |
src/simulation/investment/competitive.rs |
Encapsulates competitive selection and related tests. |
src/simulation/investment.rs |
Retains shared utilities and exposes the competitive module. |
src/output.rs |
Adds lazily created custom debug writers and tests. |
src/input/agent/search_space.rs |
Updates test agents with the default agent type. |
src/input/agent.rs |
Parses optional agent types and tests defaults and validation. |
src/fixture.rs |
Updates agent fixtures and removes the shared appraisal fixture. |
src/agent.rs |
Defines AgentType and adds it to agents. |
schemas/input/agents.yaml |
Documents the optional agent_type field. |
benches/assets.rs |
Updates imports to the competitive module. |
Review effort: Balanced
|
@alexdewar Again, you missed all the conversations I had with Adam about this (mostly on Teams and not captured in issues). Happy to discuss further if you need more explanation. |
Pure move: appraisal.rs becomes competitive/metrics.rs and the appraisal submodules move alongside it, in preparation for supporting multiple asset selection algorithms. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…module select_best_assets, its helpers and the candidate/tranche logic move from investment.rs and market.rs into investment/competitive.rs. No behaviour change. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Option building and process exclusion move inside the algorithm, so select_assets_for_single_market only computes demand portions and limits. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Allows modules such as asset selection algorithms to own their debug files, which are created lazily on first write. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove appraisal-specific code from the output module. The competitive algorithm now writes debug_asset_selection_competitive.csv and debug_asset_selection_competitive_time_slices.csv via DataWriter::write_debug_rows. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The optional agent_type column selects the asset selection algorithm for each agent. Currently the only option is `competitive` (the default), so existing models are unaffected. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
3db7b64 to
c241bd6
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## circularity_milp #1577 +/- ##
===================================================
Coverage ? 89.21%
===================================================
Files ? 63
Lines ? 9209
Branches ? 9209
===================================================
Hits ? 8216
Misses ? 676
Partials ? 317 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Description
We want to support multiple different asset selection algorithms. The idea is that we will have different agent "types" which select assets in different ways (this is different to objectives which are used within each algorithm as a way of assessing asset options).
This is just a refactor of the current algorithm to make it possible to easily slot in new algorithms, introducing the concept of an agent type. I've called the current type "competitive", as I believe the algorithm was designed to try to simulate a competitive market. This is in contrast to the "portfolio" type introduced in #1574, in which agents are meant to be a single decision maker in change of a portfolio of assets.
The design decision is to make
select_assetsthe front-end for each algorithm, with any implementation details up to the algorithm (these should be private, although currently some need to be public for the benchmark, unfortunately). This includes making the algorithm in charge of its own debug files. To allow this I had to modify theoutputmodule to acceptcustom_writers.Fixes # (issue)
Type of change
Key checklist
$ cargo test$ cargo docpresent in the previous release
Further checks