Skip to content

Commit 7fe0ff5

Browse files
committed
(ml5717) Added far too simple location+time hashing
1 parent bb42eae commit 7fe0ff5

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

necsim-impls-no-std/src/cogs/active_lineage_sampler/independent/sampler.rs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ impl<
6969
return None;
7070
}
7171

72+
// TODO: Should be returned upon extraction as well
73+
let lineage_index_at_location = simulation.lineage_store[chosen_lineage_reference.clone()]
74+
.index_at_location()
75+
.unwrap();
76+
7277
let lineage_location = simulation
7378
.lineage_store
7479
.extract_lineage_from_its_location(chosen_lineage_reference.clone());
@@ -85,17 +90,21 @@ impl<
8590
loop {
8691
let location_bytes_x = lineage_location.x().to_le_bytes();
8792
let location_bytes_y = lineage_location.y().to_le_bytes();
93+
let location_bytes_i = lineage_index_at_location.to_le_bytes();
8894
let time_step_bytes = time_step.to_le_bytes();
8995

96+
// TODO: This should be more automatic, similar to Hash -> it should also NOT use simple xor
97+
// TODO: It would be much better if we could get a location index here, i.e. bijection from
98+
// u64 to Location & index_at_location (this would require a cumulative habitat)
9099
rng.prime_with([
91-
location_bytes_x[0],
92-
location_bytes_x[1],
93-
location_bytes_x[2],
94-
location_bytes_x[3],
95-
location_bytes_y[0],
96-
location_bytes_y[1],
97-
location_bytes_y[2],
98-
location_bytes_y[3],
100+
location_bytes_x[0] ^ location_bytes_i[7],
101+
location_bytes_x[1] ^ location_bytes_i[6],
102+
location_bytes_x[2] ^ location_bytes_i[5],
103+
location_bytes_x[3] ^ location_bytes_i[4],
104+
location_bytes_y[0] ^ location_bytes_i[3],
105+
location_bytes_y[1] ^ location_bytes_i[2],
106+
location_bytes_y[2] ^ location_bytes_i[1],
107+
location_bytes_y[3] ^ location_bytes_i[0],
99108
time_step_bytes[0],
100109
time_step_bytes[1],
101110
time_step_bytes[2],

necsim-impls-no-std/src/cogs/event_sampler/gillespie/conditional/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ impl<
5151
{
5252
#[must_use]
5353
#[allow(clippy::double_parens)]
54+
#[allow(clippy::type_complexity)]
5455
#[debug_ensures(match &ret.r#type() {
5556
EventType::Speciation => true,
5657
EventType::Dispersal {
@@ -130,6 +131,7 @@ impl<
130131
for ConditionalGillespieEventSampler<H, G, D, R, S>
131132
{
132133
#[must_use]
134+
#[allow(clippy::type_complexity)]
133135
fn get_event_rate_at_location(
134136
&self,
135137
location: &Location,

necsim-impls-no-std/src/cogs/event_sampler/gillespie/conditional/probability.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub struct ProbabilityAtLocation {
1414
}
1515

1616
impl ProbabilityAtLocation {
17+
#[allow(clippy::type_complexity)]
1718
pub fn new<
1819
H: Habitat,
1920
G: RngCore,

necsim-impls-no-std/src/cogs/event_sampler/independent.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ impl<
5050
for IndependentEventSampler<H, G, D, R, S>
5151
{
5252
#[must_use]
53+
#[allow(clippy::type_complexity)]
5354
fn sample_event_for_lineage_at_location_time(
5455
&self,
5556
lineage_reference: R,

0 commit comments

Comments
 (0)