juntyr / necsim-rust

Spatially explicit biodiversity simulations using a parallel library written in Rust
https://juntyr.github.io/necsim-rust-docs/
Apache License 2.0
2 stars 2 forks source link

Implement downscaling for the almost-infinite scenarios #278

Open juntyr opened 3 months ago

juntyr commented 3 months ago
codecov-commenter commented 3 months ago

:warning: Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 2.51451% with 504 lines in your changes missing coverage. Please review.

Project coverage is 15.37%. Comparing base (c8c3023) to head (6f0bc53).

Files Patch % Lines
...std/src/cogs/habitat/almost_infinite/downscaled.rs 0.00% 190 Missing :warning:
...gs/dispersal_sampler/almost_infinite/downscaled.rs 0.00% 147 Missing :warning:
.../cogs/origin_sampler/singleton_demes/downscaled.rs 0.00% 34 Missing :warning:
rustcoalescence/src/args/config/scenario.rs 0.00% 19 Missing :warning:
necsim/core/src/cogs/rng.rs 29.41% 12 Missing :warning:
necsim/core/bond/src/off_by_one_u32.rs 0.00% 7 Missing :warning:
necsim/core/bond/src/off_by_one_u64.rs 0.00% 7 Missing :warning:
rustcoalescence/src/args/utils/ser/impl.rs 0.00% 7 Missing :warning:
necsim/core/src/landscape/extent.rs 0.00% 6 Missing :warning:
necsim/impls/no-std/src/alias/mod.rs 0.00% 6 Missing :warning:
... and 43 more

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #278 +/- ## ========================================== - Coverage 15.59% 15.37% -0.22% ========================================== Files 296 299 +3 Lines 21469 21476 +7 ========================================== - Hits 3348 3303 -45 - Misses 18121 18173 +52 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

juntyr commented 3 months ago

Let's follow the path of least resistance / easiest implementation for now

juntyr commented 3 months ago

@NicoFirbas I've now got a minimal prototype that ... sort of works

juntyr commented 3 months ago

Here's the Python script to orchestrate the gradual downscaling of the habitat https://gist.github.com/juntyr/4e98b3cb7e30e30c8a20ef27ad0c0ba1

juntyr commented 3 months ago

The issue is that even though the event-skipping algorithm is fast and can speed up the simulation tail, it also needs a fast dispersal sampler. In particular, it needs fast non-self-dispersal. A version based on rejection sampling was just far too slow, so this current code just cheats and switches to nearest-neighbour dispersal when in downsampled mode ... yeah.

What could be done is to precompute the non-self-dispersal target distribution and to then just use that. However, that would be not fully accurate (but then again we're already simplifying in major ways) but most importantly probably not target all possible locations, since a finite pre-computation might only learn about a few.

juntyr commented 3 months ago

Improvement ideas