diff --git a/NOTEPAD.md b/NOTEPAD.md index 0d45245..f0e91f2 100644 --- a/NOTEPAD.md +++ b/NOTEPAD.md @@ -1,15 +1,8 @@ # History -```shell -teams: [[player]] -weights: [[f64]] -results: [f64] +```rust +let mut history = History::new(); -player: (gaussian, f64, f64) - -players: [player] -weights: [f64] - - -teams: [([(player, weight)], result)] +let agent_a = history.new_agent(); +let agent_b = history.new_agent_with_prior(Prior::new(Gaussian::default(), BETA, GAMMA)); ``` diff --git a/src/history.rs b/src/history.rs index 37829df..4a09dc4 100644 --- a/src/history.rs +++ b/src/history.rs @@ -247,7 +247,7 @@ impl History { results: Vec>, times: Vec, weights: Vec>>, - priors: HashMap, + mut priors: HashMap, ) { assert!(times.is_empty() || self.time, "length(times)>0 but !h.time"); assert!( @@ -267,6 +267,8 @@ impl History { "(length(weights) > 0) & (length(composition) != length(weights))" ); + agent::clean(self.agents.values_mut(), true); + let mut unique = Vec::with_capacity(100); let this_agent = composition @@ -289,7 +291,7 @@ impl History { self.agents.insert( **agent, Agent { - player: priors.get(agent).cloned().unwrap_or_else(|| { + player: priors.remove(agent).unwrap_or_else(|| { Player::new( Gaussian::from_ms(self.mu, self.sigma), self.beta, @@ -302,8 +304,6 @@ impl History { } } - agent::clean(self.agents.values_mut(), true); - let n = composition.len(); let o = if self.time { sort_time(×, false) @@ -331,6 +331,7 @@ impl History { batch.new_forward_info(&self.agents); } + // TODO: Is it faster to iterate over agents in batch instead? for agent_idx in &this_agent { if let Some(skill) = batch.skills.get_mut(agent_idx) { skill.elapsed = @@ -398,6 +399,7 @@ impl History { batch.new_forward_info(&self.agents); + // TODO: Is it faster to iterate over agents in batch instead? for agent_idx in &this_agent { if let Some(skill) = batch.skills.get_mut(agent_idx) { skill.elapsed =