-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Ideally, we would want something like this in infection_attempt
and infect_person
but it results in an context immutability/mutability error
pub fn infection_attempt(context: &mut Context, person_id: PersonId) -> Option<PersonId> {
if let Some(setting) = context.sample_setting(person_id) {
let next_contact = context.get_contact(person_id, setting, ()).unwrap()?;
match context.get_person_property(next_contact, InfectionStatus) {
InfectionStatusValue::Susceptible => {
if context.sample_bool(
ForecastRng,
context.get_relative_total_transmission(next_contact),
) {
context.infect_person(
next_contact,
Some(person_id),
Some(setting),
);
Some(next_contact)
} else {
None
}
}
_ => None,
}
} else {
None
}
}
fn infect_person(
&mut self,
target_id: PersonId,
source_id: Option<PersonId>,
setting: Option<&dyn AnySettingId>
) {
let infection_time = self.get_current_time();
trace!("Person {target_id}: Infected at {infection_time}");
self.set_person_property(
target_id,
InfectionData,
InfectionDataValue::Infectious {
infection_time,
infected_by: source_id,
infection_setting_type: setting
.and_then(|s| Some(s.get_category_id())),
infection_setting_id: setting.and_then(|s| Some(s.id()))
},
);
}
Metadata
Metadata
Assignees
Labels
No labels