Rename variables
This commit is contained in:
@@ -325,21 +325,21 @@ impl History {
|
|||||||
while (!self.time && (self.size > k))
|
while (!self.time && (self.size > k))
|
||||||
|| (self.time && self.batches.len() > k && self.batches[k].time < t)
|
|| (self.time && self.batches.len() > k && self.batches[k].time < t)
|
||||||
{
|
{
|
||||||
let b = &mut self.batches[k];
|
let batch = &mut self.batches[k];
|
||||||
|
|
||||||
if k > 0 {
|
if k > 0 {
|
||||||
b.new_forward_info(&self.agents);
|
batch.new_forward_info(&self.agents);
|
||||||
}
|
}
|
||||||
|
|
||||||
for agent in &this_agent {
|
for agent_idx in &this_agent {
|
||||||
if let Some(skill) = b.skills.get_mut(agent) {
|
if let Some(skill) = batch.skills.get_mut(agent_idx) {
|
||||||
skill.elapsed =
|
skill.elapsed =
|
||||||
batch::compute_elapsed(self.agents[agent].last_time, b.time);
|
batch::compute_elapsed(self.agents[agent_idx].last_time, batch.time);
|
||||||
|
|
||||||
let a = self.agents.get_mut(agent).unwrap();
|
let agent = self.agents.get_mut(agent_idx).unwrap();
|
||||||
|
|
||||||
a.last_time = if self.time { b.time } else { i64::MAX };
|
agent.last_time = if self.time { batch.time } else { i64::MAX };
|
||||||
a.message = b.forward_prior_out(agent);
|
agent.message = batch.forward_prior_out(agent_idx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -364,14 +364,13 @@ impl History {
|
|||||||
|
|
||||||
if self.time && self.batches.len() > k && self.batches[k].time == t {
|
if self.time && self.batches.len() > k && self.batches[k].time == t {
|
||||||
let batch = &mut self.batches[k];
|
let batch = &mut self.batches[k];
|
||||||
|
|
||||||
batch.add_events(composition, results, weights, &self.agents);
|
batch.add_events(composition, results, weights, &self.agents);
|
||||||
|
|
||||||
for a in batch.skills.keys() {
|
for agent_idx in batch.skills.keys() {
|
||||||
let agent = self.agents.get_mut(a).unwrap();
|
let agent = self.agents.get_mut(agent_idx).unwrap();
|
||||||
|
|
||||||
agent.last_time = if self.time { t } else { i64::MAX };
|
agent.last_time = if self.time { t } else { i64::MAX };
|
||||||
agent.message = batch.forward_prior_out(a);
|
agent.message = batch.forward_prior_out(agent_idx);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let mut batch: Batch = Batch::new(t, self.p_draw);
|
let mut batch: Batch = Batch::new(t, self.p_draw);
|
||||||
@@ -381,11 +380,11 @@ impl History {
|
|||||||
|
|
||||||
let batch = &self.batches[k];
|
let batch = &self.batches[k];
|
||||||
|
|
||||||
for a in batch.skills.keys() {
|
for agent_idx in batch.skills.keys() {
|
||||||
let agent = self.agents.get_mut(a).unwrap();
|
let agent = self.agents.get_mut(agent_idx).unwrap();
|
||||||
|
|
||||||
agent.last_time = if self.time { t } else { i64::MAX };
|
agent.last_time = if self.time { t } else { i64::MAX };
|
||||||
agent.message = batch.forward_prior_out(a);
|
agent.message = batch.forward_prior_out(agent_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
k += 1;
|
k += 1;
|
||||||
@@ -395,18 +394,19 @@ impl History {
|
|||||||
}
|
}
|
||||||
|
|
||||||
while self.time && self.batches.len() > k {
|
while self.time && self.batches.len() > k {
|
||||||
let b = &mut self.batches[k];
|
let batch = &mut self.batches[k];
|
||||||
|
|
||||||
b.new_forward_info(&self.agents);
|
batch.new_forward_info(&self.agents);
|
||||||
|
|
||||||
for agent in &this_agent {
|
for agent_idx in &this_agent {
|
||||||
if let Some(skill) = b.skills.get_mut(agent) {
|
if let Some(skill) = batch.skills.get_mut(agent_idx) {
|
||||||
skill.elapsed = batch::compute_elapsed(self.agents[agent].last_time, b.time);
|
skill.elapsed =
|
||||||
|
batch::compute_elapsed(self.agents[agent_idx].last_time, batch.time);
|
||||||
|
|
||||||
let a = self.agents.get_mut(agent).unwrap();
|
let agent = self.agents.get_mut(agent_idx).unwrap();
|
||||||
|
|
||||||
a.last_time = if self.time { b.time } else { i64::MAX };
|
agent.last_time = if self.time { batch.time } else { i64::MAX };
|
||||||
a.message = b.forward_prior_out(agent);
|
agent.message = batch.forward_prior_out(agent_idx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user