Move stuff around

This commit is contained in:
Anders Olsson
2023-10-26 11:01:14 +02:00
parent 72e06eb536
commit 755a5ea668
2 changed files with 10 additions and 15 deletions

View File

@@ -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));
```

View File

@@ -247,7 +247,7 @@ impl History {
results: Vec<Vec<f64>>,
times: Vec<i64>,
weights: Vec<Vec<Vec<f64>>>,
priors: HashMap<Index, Player>,
mut priors: HashMap<Index, Player>,
) {
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(&times, 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 =