The UFZ services GitLab and Mattermost will be unavailable on Monday, July 4 from 06:00 AM to 08:00 AM due to maintenance work.

Commit b56d49a0 authored by Adam Reichold's avatar Adam Reichold Committed by Adam Reichold
Browse files

Trace the temporal network of potential contaminations by sampling the...

Trace the temporal network of potential contaminations by sampling the relevant time scale from the same distribution.
parent a49af6a9
Pipeline #54501 passed with stage
in 6 minutes and 11 seconds
......@@ -27,7 +27,7 @@ use crate::{
params::Params,
space::Vector,
units::{Area, Mass, Tick},
FlowerContaminators, Rng, TaggedIndex,
Rng, TaggedIndex,
};
\end{hiddencode}
......@@ -149,7 +149,6 @@ impl Event {
tick: Tick,
flower_patches: &mut [FlowerPatch],
flowers: &mut [u64],
flower_contaminators: &mut FlowerContaminators,
) {
loop {
match events.peek() {
......@@ -177,8 +176,6 @@ impl Event {
false,
);
flower_contaminators.remove(&(*flower_patch, *flower));
events.pop();
}
_ => break,
......
......@@ -118,7 +118,7 @@ It also contains several auxiliary data structures which are used during the sim
Furthermore, the \inlinecode{visited_flowers} buffers are used to store the trajectories each insect takes along the flowers within a patch which are stored independently of the state of the insects as they are never relocated to another subworld as a relocation implies not being within a flower patch.
Finally, the \inlinecode{flower_contaminators} hash table is used to determine which individual is responsible for contaminating a flower wihtin a patch and is used to trace the temporal structure of epidemiologically relevant contacts.
Finally, the \inlinecode{flower_contaminators} hash table is used to determine which individual is responsible for contaminating a flower wihtin a patch and is used to trace the temporal structure of potentially epidemiologically relevant contacts.
\begin{code}
pub struct Model {
......@@ -138,7 +138,7 @@ pub struct Model {
relocations: MailBoxes<Relocation>,
}
pub type FlowerContaminators = HashMap<(TaggedIndex, u16), u32>;
pub type FlowerContaminators = HashMap<(TaggedIndex, u16), HashMap<u32, Tick>>;
\end{code}
The subworld state itself consists of the current time step \inlinecode{tick}, the state associated with the various entities resp. their driving submodels, a PCG pseudo-random number generator (PRNG) \inlinecode{rng} \autocite{pcg_family_algorithms_random_number_generation} and the measurements of several micro-observables.
......@@ -332,7 +332,6 @@ impl World {
self.tick,
&mut self.flower_patches,
&mut self.flowers,
flower_contaminators,
);
ClutchEvent::process(clutch_events, self.tick, &mut self.clutches);
......@@ -550,7 +549,7 @@ unsafe impl Message for Relocation {}
For a mobile entity to properly identify a stationary entity, e.g. for memorisation of depleted flower patches, both the process rank as well as the index of the entity need to be stored. To avoid the loss of memory density due to alignment and padding, these two values are packed into a single four byte integer using a single byte for the rank and three bytes for the index, i.e. at most $2^8 = 256$ processes handling fewer than $2^{24} = 16\,777\,216$ entities of a given type are assumed.
\begin{code}
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct TaggedIndex(u32);
......
......@@ -113,14 +113,26 @@ pub fn infection_contamination(
vectors: &mut Vectors,
temporal_network: &mut TemporalNetwork,
) {
let flower_patch_params = &params.flower_patches[flower_patch.species.0 as usize];
\end{code}
The \inlinecode{flower_contaminators} hash table is used to track which individuals have contaminated a given flower within a patch. This is used to derive a temporal network for these epidemiologically relevant contacts by collecting the edges between contaminator and visitor. This tracking is tied to contamination events instead of infection events or just visits as the decontamination time provides the relevant time scale for the temporal network.
\begin{code}
if let Some(contaminator) = flower_contaminators.get(&(index, flower)) {
temporal_network.push((tick, *contaminator, id));
}
let flower_contaminators = flower_contaminators.entry((index, flower)).or_default();
flower_contaminators.retain(|contaminator, decontaminates_at| {
if *decontaminates_at > tick {
temporal_network.push((tick, *contaminator, id));
true
} else {
false
}
});
flower_contaminators.insert(id, tick + flower_patch_params.decontamination(params, rng));
let is_susceptible = matches!(status, Status::Susceptible);
let is_infected = status.is_infected();
......@@ -145,12 +157,8 @@ The \inlinecode{flower_contaminators} hash table is used to track which individu
}
if is_infected && !is_contaminated && insect_params.contamination.sample(rng) {
let flower_patch_params = &params.flower_patches[flower_patch.species.0 as usize];
let decontaminates_at = tick + flower_patch_params.decontamination(params, rng);
flower_patch_events.push(FlowerPatchEvent::Decontamination {
happens_at: decontaminates_at,
happens_at: tick + flower_patch_params.decontamination(params, rng),
flower_patch: index,
flower,
});
......@@ -160,8 +168,6 @@ The \inlinecode{flower_contaminators} hash table is used to track which individu
.set(flowers, flower as usize, true);
flower_patch.contaminated_by_species = MaybeUninit::new(species);
flower_contaminators.insert((index, flower), id);
}
}
\end{code}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment