Remove warnings and refactor some code

This commit is contained in:
2022-12-16 19:46:01 +01:00
parent 912a282cd8
commit 2bdd3d9b89
3 changed files with 13 additions and 40 deletions

View File

@@ -128,12 +128,12 @@ impl History {
for j in (0..self.batches.len() - 1).rev() {
for agent in self.batches[j + 1].skills.keys() {
self.agents.get_mut(agent).unwrap().message =
self.batches[j + 1].backward_prior_out(agent, &mut self.agents);
self.batches[j + 1].backward_prior_out(agent, &self.agents);
}
let old = self.batches[j].posteriors();
self.batches[j].new_backward_info(&mut self.agents);
self.batches[j].new_backward_info(&self.agents);
let new = self.batches[j].posteriors();
@@ -152,7 +152,7 @@ impl History {
let old = self.batches[j].posteriors();
self.batches[j].new_forward_info(&mut self.agents);
self.batches[j].new_forward_info(&self.agents);
let new = self.batches[j].posteriors();
@@ -164,7 +164,7 @@ impl History {
if self.batches.len() == 1 {
let old = self.batches[0].posteriors();
self.batches[0].iteration(0, &mut self.agents);
self.batches[0].iteration(0, &self.agents);
let new = self.batches[0].posteriors();
@@ -314,7 +314,7 @@ impl History {
let b = &mut self.batches[k];
if k > 0 {
b.new_forward_info(&mut self.agents);
b.new_forward_info(&self.agents);
}
let intersect = this_agent
@@ -363,14 +363,7 @@ impl History {
agent.message = b.forward_prior_out(a);
}
} else {
let b = Batch::new(
composition,
results,
weights,
t,
self.p_draw,
&mut self.agents,
);
let b = Batch::new(composition, results, weights, t, self.p_draw, &self.agents);
self.batches.insert(k, b);
@@ -392,7 +385,7 @@ impl History {
while self.time && self.batches.len() > k {
let b = &mut self.batches[k];
b.new_forward_info(&mut self.agents);
b.new_forward_info(&self.agents);
let intersect = this_agent
.iter()
@@ -463,14 +456,14 @@ mod tests {
let observed = h.batches[1].skills[&a].forward.sigma;
let gamma: f64 = 0.15 * 25.0 / 3.0;
let expected = (gamma.powi(2) + h.batches[0].posterior(a).sigma.powi(2)).sqrt();
let expected = (gamma.powi(2) + h.batches[0].skills[&a].posterior().sigma.powi(2)).sqrt();
assert_ulps_eq!(observed, expected, epsilon = 0.000001);
let observed = h.batches[1].posterior(a);
let p = Game::new(
h.batches[1].within_priors(0, false, false, &mut h.agents),
h.batches[1].events[0].within_priors(false, false, &h.batches[1].skills, &h.agents),
vec![0.0, 1.0],
vec![],
P_DRAW,