Closed glwagner closed 4 years ago
Very nice. Thanks for adding the plotting function!
Ok, the llvmlite and numba causes some trouble on my computer. After installing the most recent llvmlite and numba versions, I get the following error:
This seems to be a general problem: https://github.com/numba/numba/issues/2428
Can you provide a version without numba/llvmlite? This would be helpful to run some test simulations.
damn. I didn't anticipate that.
Ok, the numba stuff is now isolated in a module called fast_contact_simulator
. We may have to refactor / revert a few more changes in the non-numba version to make it more performant (since it added some python functions that are inevitably slow).
On my Mac, the difference is:
(risknet) $ python3 contact_simulation_example.py
Simulated 5000 contacts in 8.810 seconds
Simulated 10000 contacts in 23.712 seconds
Simulated 20000 contacts in 63.544 seconds
I guess the slow version sped up a bit too during this PR...
(risknet) $ python3 fast_contact_simulation_example.py
Simulated 5000 contacts in 3.817 seconds
Simulated 10000 contacts in 7.176 seconds
Simulated 20000 contacts in 26.726 seconds
The output of the above scripts is
This PR removes placeholders from
KineticModel
. This is a first step toward resolving #53. We can now run a simple simulation of an epidemic with no accounting for hospitalization and the corresponding changes to the contact network.It also uses
numba
to speed up the Gillespie simulation of the contact durations. By isolating and@jit
-ing a few expensive functions, we get 5x speed up or so. There is probably more to be had, but we'll see if its needed.EDIT: not everyone is able to install numba, so the
numba
-ized contract simulator is isolated infast_contact_simulator.py
.It adds an example
simulate_simple_epidemic.py
that simulates an epidemic. The example produces this plot: