Skip to content

Commit

Permalink
Merge pull request #14 from benmaier/dev
Browse files Browse the repository at this point in the history
updates
  • Loading branch information
benmaier authored May 18, 2021
2 parents 2a576c0 + 048ae80 commit 2bc4a2b
Show file tree
Hide file tree
Showing 23 changed files with 1,190 additions and 146 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## [v0.1.4] - 2020-05-18

### Added

- A new small-world network styling method based on 1d lattice distance (in epipack.networks)
- methods to compute Jacobian and next generation matrices (NGMs) in `MatrixEpiModel`, as well as R0 from said NGMs (TODO: add docs)
- tests for these methods
- `epipack.distributions` module, which deals with fitting empirical distributions to sums of exponentially distributed random variables (still in dev mode, also TODO: add docs)
- tests for this module
- methods to `EpiModel` that save events that have been set. This will be used to generate model flowcharts with graphviz at some point
- the possibility to pass a function to ``StochasticEpiModel.simulate`` that checks for a custom stop condition

## [v0.1.3] - 2020-04-07

### Fixed
Expand Down Expand Up @@ -88,7 +100,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- initialized

[Unreleased]: https://github.com/benmaier/epipack/compare/v0.1.3...HEAD
[Unreleased]: https://github.com/benmaier/epipack/compare/v0.1.4...HEAD
[v0.1.4]: https://github.com/benmaier/epipack/compare/v0.1.2...v0.1.4]
[v0.1.3]: https://github.com/benmaier/epipack/compare/v0.1.2...v0.1.3]
[v0.1.2]: https://github.com/benmaier/epipack/compare/v0.1.1...v0.1.2]
[v0.1.1]: https://github.com/benmaier/epipack/compare/v0.1.0...v0.1.1]
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ So far, the package's functionality was tested on Mac OS X and CentOS only.
* `sympy==1.6`
* `pyglet<1.6`
* `matplotlib>=3.0.0`
* `bfmplot>=0.0.7`
* `ipython>=7.14.0`
* `ipywidgets>=7.5.1`

Expand Down
1 change: 0 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ installed by ``pip`` during the installation process
- ``sympy==1.6``
- ``pyglet<1.6``
- ``matplotlib>=3.0.0``
- ``bfmplot>=0.0.7``
- ``ipython>=7.14.0``
- ``ipywidgets>=7.5.1``

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
from epipack import MatrixEpiModel, get_2D_lattice_links
from epipack.vis import visualize_reaction_diffusion, get_grid_layout
import numpy as np
import networkx as nx
import cMHRN
from time import time
from epipack.networks import get_small_world_layout

# load edges from txt file and construct Graph object
N, edges = cMHRN.fast_mhrn(8,3,7,0.18,True)



start = time()

# get the network properties
links = [ ( u, v, 1.0 ) for u, v in edges ]

network = get_small_world_layout(N,links)






base_compartments = "SIR"

compartments = [ (node, C) for node in range(N) for C in base_compartments ]
model = MatrixEpiModel(compartments)

infection_rate = 3
recovery_rate = 1
mobility_rate = 0.05

quadratic_processes = []
linear_processes = []

print("defining processes")

for node in range(N):
quadratic_processes.append(
( (node, "S"), (node, "I"), infection_rate, (node, "I"), (node, "I") ),
)

linear_processes.append(
( (node, "I"), recovery_rate, (node, "R") )
)

for u, v, w in links:
for C in base_compartments:

linear_processes.extend([
( (u, C), w*mobility_rate, (v, C) ),
( (v, C), w*mobility_rate, (u, C) ),
])

print("set processes")

model.set_processes(quadratic_processes+linear_processes,allow_nonzero_column_sums=True)

initial_conditions = { ( node, "S" ): 1.0 for node in range(N) }
initial_conditions[(0, "S")] = 0.8
initial_conditions[(0, "I")] = 0.2
model.set_initial_conditions(initial_conditions,allow_nonzero_column_sums=True)

t = np.linspace(0,20,100)

node_compartments = [ (node, "I" ) for node in range(N) ]

dt = 0.04
visualize_reaction_diffusion(model, network, dt, node_compartments, value_extent=[0,0.3])

1 change: 0 additions & 1 deletion docs/about.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ installed by ``pip`` during the installation process
- ``sympy==1.6``
- ``pyglet<1.6``
- ``matplotlib>=3.0.0``
- ``bfmplot>=0.0.7``
- ``ipython>=7.14.0``
- ``ipywidgets>=7.5.1``

Expand Down
8 changes: 8 additions & 0 deletions docs/api/distributions.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Distributions
-------------

.. automodule:: epipack.distributions
:members:
:undoc-members:
:show-inheritance:

2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def __getattr__(cls, name):

# General information about the project.
project = u'epipack'
copyright = u'2020, Benjamin F. Maier'
copyright = u'2020-2021, Benjamin F. Maier'
author = u' Benjamin F. Maier'

# The version info for the project you're documenting, acts as replacement for
Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ epipack
api/numeric_matrix_epi_models
api/symbolic_matrix_epi_models
api/plottools
api/distributions

.. .. toctree::
.. :maxdepth: 2
Expand Down
Loading

0 comments on commit 2bc4a2b

Please sign in to comment.