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