tapios / risk-networks

Code for risk networks: a blend of compartmental models, graphs, data assimilation and semi-supervised learning
Other
2 stars 2 forks source link

The EpidemicSimulator #64

Closed glwagner closed 4 years ago

glwagner commented 4 years ago

This PR introduces the EpidemicSimulator for performing simulations of epidemics with evolving contact networks.

The use of EpidemicSimulator is demonstrated in examples/super_simple_epidemic.py. It includes the ability to "cycle" contacts over a day, rather than generating new contacts for time interval of an epidemic simulation. We don't have a role for the HealthService yet, but this should be easy.

There are a few other major changes:

TransitionRates then generates dictionaries for the transition rates. A unique mapping from list elements to node IDs is used by sorting the node IDs.

It also puts the entire loop in the contact simulator into a numba function. This yields a further speed up of approx 2x, though YMMV.

On my laptop, examples/super_simple_epidemic.py --- which implements a 10,000 node, 21 day epidemic simulation --- takes ~70 s when cycling contacts, and 400 s when generating new contacts every day. It generates this plot:

image
glwagner commented 4 years ago

On my laptop it took 30 min to generate a daily cycle of contacts on a 100,000 node barabasi-albert graph with attachment parameter 2 (roughly 200,000 edges):

image

The subsequent 21-day kinetic simulation took 41 minutes.

Here's the result:

image

Needless to say if contacts were generated each time we can add roughly 11 hours to the above time.