UT-Covid / episimlab

Framework for development of epidemiological models
https://ut-covid.github.io/episimlab/
BSD 3-Clause "New" or "Revised" License
3 stars 1 forks source link

Calculate FOI without for loops #11

Closed ethho closed 2 years ago

ethho commented 3 years ago

Problem

Force of infection calculation is implemented with naive for looping in the BruteForceCythonFOI process: https://github.com/eho-tacc/episimlab/blob/e888ae7d7f1d1773c271c53320a7ea8a341b40d4/episimlab/foi/bf_cython.py#L15

This wraps the lower level Cython API bf_cython_engine._brute_force_foi: https://github.com/eho-tacc/episimlab/blob/e888ae7d7f1d1773c271c53320a7ea8a341b40d4/episimlab/foi/bf_cython_engine.pyx#L69

It is relatively straightforward to perform this arithmetic on arrays directly using numpy (or xarray, which uses numpy backend): https://github.com/eho-tacc/episimlab/blob/e888ae7d7f1d1773c271c53320a7ea8a341b40d4/episimlab/foi/bf_cython_engine.pyx#L156

Objective

ethho commented 3 years ago

Prototype implementation in https://github.com/eho-tacc/episimlab-markov/

ethho commented 3 years ago

Migrated prototype notebook to markov branch on this repo: https://github.com/eho-tacc/episimlab/blob/markov/notebooks/20210731_markov_sandbox.ipynb. Process FOI in this notebook implements the above requested LooplessFOI in its foi method. foi method is confirmed to produce equivalent output to the (current) brute force method in brute_force_foi.

ethho commented 2 years ago

Fixed in v2 (#40)