Move stuff around
This commit is contained in:
15
NOTEPAD.md
15
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));
|
||||
```
|
||||
|
||||
@@ -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(×, 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 =
|
||||
|
||||
Reference in New Issue
Block a user