Map addition limits by ProcessID rather than AssetRef - #1495
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1495 +/- ##
==========================================
+ Coverage 90.26% 90.29% +0.03%
==========================================
Files 60 60
Lines 8614 8645 +31
Branches 8614 8645 +31
==========================================
+ Hits 7775 7806 +31
Misses 525 525
Partials 314 314 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ProcessID rather than AssetRef
There was a problem hiding this comment.
Pull request overview
This PR refactors how investment/addition limits are tracked during asset selection by mapping limits per ProcessID instead of per AssetRef, aligning the selection logic with process-level constraints and simplifying downstream usage.
Changes:
- Replace candidate investment limit tracking (
HashMap<AssetRef, Capacity>) with agent-scaled process addition limits (HashMap<ProcessID, Capacity>). - Add
Process::agent_addition_limit(...)and update market/investment selection flows to use it. - Rename selection-state variables/functions to reflect “retention” and “addition limits” semantics more clearly.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/simulation/market.rs | Computes agent-scaled process addition limits from agent search space; updates cycle logic to use Process::agent_addition_limit; updates tests. |
| src/simulation/investment.rs | Threads HashMap<ProcessID, Capacity> through selection; updates limit enforcement and selection-state bookkeeping names. |
| src/process.rs | Introduces agent_addition_limit helper on Process to compute portion-scaled addition limits. |
| src/asset.rs | Removes asset-level max_installable_capacity in favour of process-level limit calculation; removes related unit test. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
AdrianDAlessandro
left a comment
There was a problem hiding this comment.
This all makes sense. I'll have to change what I've done is #1496 to match it, but this approach is better, so I'll build from here.
Description
I think it's a bit clearer to make the addition limits map
HashMap<ProcessID, Capacity>rather thanHashMap<AssetRef, Capacity>, and this will also be more consistent with the eventual implementation for total capacity limits.Also changed some function/argument/variable names for clarity
Fixes # (issue)
Type of change
Key checklist
$ cargo test$ cargo docpresent in the previous release
Further checks