refactor(history): replace HashMap<Index, Agent<D>> with dense AgentStore<D>
AgentStore<D> is a Vec<Option<Agent<D>>>-backed store indexed directly by Index.0, eliminating per-iteration hashing in the cross-history forward/backward sweep. Implements Index<Index>/IndexMut<Index> for ergonomic agent access. AgentStore is public (so benches/batch.rs can use it). SkillStore remains pub(crate) since Skill is pub(crate) in batch.rs. HashMap<Index, _> is now only used for the posteriors() return value (temporary; will be replaced in T2 with a proper typed return) and for the add_events_with_prior(priors: HashMap<Index, Player<D>>) API (also T2 target). Part of T0 engine redesign.
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use criterion::{Criterion, criterion_group, criterion_main};
|
||||
use trueskill_tt::{
|
||||
BETA, GAMMA, IndexMap, MU, P_DRAW, SIGMA, agent::Agent, batch::Batch, drift::ConstantDrift,
|
||||
gaussian::Gaussian, player::Player,
|
||||
gaussian::Gaussian, player::Player, storage::AgentStore,
|
||||
};
|
||||
|
||||
fn criterion_benchmark(criterion: &mut Criterion) {
|
||||
@@ -13,33 +11,17 @@ fn criterion_benchmark(criterion: &mut Criterion) {
|
||||
let b = index.get_or_create("b");
|
||||
let c = index.get_or_create("c");
|
||||
|
||||
let agents = {
|
||||
let mut map = HashMap::new();
|
||||
let mut agents: AgentStore<ConstantDrift> = AgentStore::new();
|
||||
|
||||
map.insert(
|
||||
a,
|
||||
for agent in [a, b, c] {
|
||||
agents.insert(
|
||||
agent,
|
||||
Agent {
|
||||
player: Player::new(Gaussian::from_ms(MU, SIGMA), BETA, ConstantDrift(GAMMA)),
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
map.insert(
|
||||
b,
|
||||
Agent {
|
||||
player: Player::new(Gaussian::from_ms(MU, SIGMA), BETA, ConstantDrift(GAMMA)),
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
map.insert(
|
||||
c,
|
||||
Agent {
|
||||
player: Player::new(Gaussian::from_ms(MU, SIGMA), BETA, ConstantDrift(GAMMA)),
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
|
||||
map
|
||||
};
|
||||
}
|
||||
|
||||
let mut composition = Vec::new();
|
||||
let mut results = Vec::new();
|
||||
|
||||
Reference in New Issue
Block a user