Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement downscaling for the almost-infinite scenarios #278

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

juntyr
Copy link
Owner

@juntyr juntyr commented Jun 5, 2024

  • implement self-dispersal probability
    • how do we get this efficiently and accurately?
    • can start with numerical approximation
  • implement merged args serialising and deserialising
  • fix downscale factor deserialising - must deserialise with any
  • where does the downscaling take place?
    • external script would be quick and dirty, but wouldn't know the scale parameters
    • maybe a very hacky habitat-dependent pre-processing and post-processing hook?
      • could only downscale internally and then remap to fake upscaled coords before and after
      • default impl for habitats would do nothing
    • other ideas @NicoFirbas
  • code review and cleanup
  • testing

@codecov-commenter
Copy link

codecov-commenter commented Jun 5, 2024

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

Codecov Report

Attention: Patch coverage is 2.50482% with 506 lines in your changes missing coverage. Please review.

Project coverage is 15.39%. Comparing base (c8c3023) to head (3a961bd).

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

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #278      +/-   ##
==========================================
- Coverage   15.59%   15.39%   -0.20%     
==========================================
  Files         296      299       +3     
  Lines       21469    21454      -15     
==========================================
- Hits         3348     3303      -45     
- Misses      18121    18151      +30     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@juntyr
Copy link
Owner Author

juntyr commented Jun 6, 2024

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

  • ensure that the lineage file format is modifiable outside Rust
  • write a Python helper script
    • initialise model
    • compute pause times based on speciation percentiles
    • apply 2x2 downscale on every pause
    • run with pinky-promise no event log but only allow the resumable lineage reporters for now
    • test with event log and only speciation reporter

@juntyr
Copy link
Owner Author

juntyr commented Jun 7, 2024

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

@juntyr
Copy link
Owner Author

juntyr commented Jun 7, 2024

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

@juntyr
Copy link
Owner Author

juntyr commented Jun 7, 2024

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
Copy link
Owner Author

juntyr commented Jun 8, 2024

Improvement ideas

  • allow customising the dispersal precomputing sample count
  • give a rejection sampling threshold to still use it when the self dispersal probability isn't too small yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants