escape-abm 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- escape_abm-0.0.1/.clang-format +6 -0
- escape_abm-0.0.1/.cpush.json5 +7 -0
- escape_abm-0.0.1/.gitignore +160 -0
- escape_abm-0.0.1/LICENSE +19 -0
- escape_abm-0.0.1/PKG-INFO +56 -0
- escape_abm-0.0.1/README.md +27 -0
- escape_abm-0.0.1/TODO.rst +27 -0
- escape_abm-0.0.1/docs/escape-banner.webp +0 -0
- escape_abm-0.0.1/docs/howto-setup-jupyterlab-locally.rst +98 -0
- escape_abm-0.0.1/docs/logo.png +0 -0
- escape_abm-0.0.1/examples/edges.parquet +0 -0
- escape_abm-0.0.1/examples/example1.esl +160 -0
- escape_abm-0.0.1/examples/nodes.parquet +0 -0
- escape_abm-0.0.1/examples/run-example1.ipynb +1028 -0
- escape_abm-0.0.1/pyproject.toml +46 -0
- escape_abm-0.0.1/setup.cfg +4 -0
- escape_abm-0.0.1/src/escape_abm/__init__.py +0 -0
- escape_abm-0.0.1/src/escape_abm/alias_table.py +64 -0
- escape_abm-0.0.1/src/escape_abm/ast.py +1646 -0
- escape_abm-0.0.1/src/escape_abm/check_ast.py +441 -0
- escape_abm-0.0.1/src/escape_abm/cli.py +34 -0
- escape_abm-0.0.1/src/escape_abm/click_helpers.py +146 -0
- escape_abm-0.0.1/src/escape_abm/codegen_openmp.py +759 -0
- escape_abm-0.0.1/src/escape_abm/input_helpers.py +360 -0
- escape_abm-0.0.1/src/escape_abm/language_server.py +243 -0
- escape_abm-0.0.1/src/escape_abm/misc.py +92 -0
- escape_abm-0.0.1/src/escape_abm/output_helpers.py +322 -0
- escape_abm-0.0.1/src/escape_abm/parse_tree.py +165 -0
- escape_abm-0.0.1/src/escape_abm/static/simulation_common_openmp.h +857 -0
- escape_abm-0.0.1/src/escape_abm/templates/apply_statement_defn_openmp.jinja2 +20 -0
- escape_abm-0.0.1/src/escape_abm/templates/apply_statement_launch_openmp.jinja2 +5 -0
- escape_abm-0.0.1/src/escape_abm/templates/call_statement.jinja2 +2 -0
- escape_abm-0.0.1/src/escape_abm/templates/cmakelists_txt_openmp.jinja2 +48 -0
- escape_abm-0.0.1/src/escape_abm/templates/contagion_methods.jinja2 +233 -0
- escape_abm-0.0.1/src/escape_abm/templates/discrete_dist_defn.jinja2 +23 -0
- escape_abm-0.0.1/src/escape_abm/templates/edge_table_defn.jinja2 +43 -0
- escape_abm-0.0.1/src/escape_abm/templates/enum_defn.jinja2 +4 -0
- escape_abm-0.0.1/src/escape_abm/templates/function_decl.jinja2 +2 -0
- escape_abm-0.0.1/src/escape_abm/templates/function_defn.jinja2 +15 -0
- escape_abm-0.0.1/src/escape_abm/templates/global_defn.jinja2 +1 -0
- escape_abm-0.0.1/src/escape_abm/templates/if_statement.jinja2 +20 -0
- escape_abm-0.0.1/src/escape_abm/templates/node_table_defn.jinja2 +44 -0
- escape_abm-0.0.1/src/escape_abm/templates/normal_dist_defn.jinja2 +12 -0
- escape_abm-0.0.1/src/escape_abm/templates/pass_statement.jinja2 +2 -0
- escape_abm-0.0.1/src/escape_abm/templates/print_statement.jinja2 +2 -0
- escape_abm-0.0.1/src/escape_abm/templates/reduce_statement_defn_openmp.jinja2 +52 -0
- escape_abm-0.0.1/src/escape_abm/templates/reduce_statement_launch_openmp.jinja2 +2 -0
- escape_abm-0.0.1/src/escape_abm/templates/return_statement.jinja2 +2 -0
- escape_abm-0.0.1/src/escape_abm/templates/sample_statement_launch_openmp.jinja2 +13 -0
- escape_abm-0.0.1/src/escape_abm/templates/select_statement_defn_openmp.jinja2 +15 -0
- escape_abm-0.0.1/src/escape_abm/templates/select_statement_launch_openmp.jinja2 +5 -0
- escape_abm-0.0.1/src/escape_abm/templates/simulator_openmp.jinja2 +295 -0
- escape_abm-0.0.1/src/escape_abm/templates/switch_statement.jinja2 +16 -0
- escape_abm-0.0.1/src/escape_abm/templates/uniform_dist_defn.jinja2 +10 -0
- escape_abm-0.0.1/src/escape_abm/templates/update_statement.jinja2 +2 -0
- escape_abm-0.0.1/src/escape_abm/templates/variable.jinja2 +2 -0
- escape_abm-0.0.1/src/escape_abm/templates/while_loop.jinja2 +6 -0
- escape_abm-0.0.1/src/escape_abm/tree_sitter_bindings.py +29 -0
- escape_abm-0.0.1/src/escape_abm/utils.py +271 -0
- escape_abm-0.0.1/src/escape_abm.egg-info/PKG-INFO +56 -0
- escape_abm-0.0.1/src/escape_abm.egg-info/SOURCES.txt +63 -0
- escape_abm-0.0.1/src/escape_abm.egg-info/dependency_links.txt +1 -0
- escape_abm-0.0.1/src/escape_abm.egg-info/entry_points.txt +2 -0
- escape_abm-0.0.1/src/escape_abm.egg-info/requires.txt +16 -0
- escape_abm-0.0.1/src/escape_abm.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# poetry
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
102
|
+
#poetry.lock
|
|
103
|
+
|
|
104
|
+
# pdm
|
|
105
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
106
|
+
#pdm.lock
|
|
107
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
108
|
+
# in version control.
|
|
109
|
+
# https://pdm.fming.dev/#use-with-ide
|
|
110
|
+
.pdm.toml
|
|
111
|
+
|
|
112
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
113
|
+
__pypackages__/
|
|
114
|
+
|
|
115
|
+
# Celery stuff
|
|
116
|
+
celerybeat-schedule
|
|
117
|
+
celerybeat.pid
|
|
118
|
+
|
|
119
|
+
# SageMath parsed files
|
|
120
|
+
*.sage.py
|
|
121
|
+
|
|
122
|
+
# Environments
|
|
123
|
+
.env
|
|
124
|
+
.venv
|
|
125
|
+
env/
|
|
126
|
+
venv/
|
|
127
|
+
ENV/
|
|
128
|
+
env.bak/
|
|
129
|
+
venv.bak/
|
|
130
|
+
|
|
131
|
+
# Spyder project settings
|
|
132
|
+
.spyderproject
|
|
133
|
+
.spyproject
|
|
134
|
+
|
|
135
|
+
# Rope project settings
|
|
136
|
+
.ropeproject
|
|
137
|
+
|
|
138
|
+
# mkdocs documentation
|
|
139
|
+
/site
|
|
140
|
+
|
|
141
|
+
# mypy
|
|
142
|
+
.mypy_cache/
|
|
143
|
+
.dmypy.json
|
|
144
|
+
dmypy.json
|
|
145
|
+
|
|
146
|
+
# Pyre type checker
|
|
147
|
+
.pyre/
|
|
148
|
+
|
|
149
|
+
# pytype static type analyzer
|
|
150
|
+
.pytype/
|
|
151
|
+
|
|
152
|
+
# Cython debug symbols
|
|
153
|
+
cython_debug/
|
|
154
|
+
|
|
155
|
+
# PyCharm
|
|
156
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
157
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
158
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
159
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
160
|
+
#.idea/
|
escape_abm-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (C) 2023 Rector and Visitors of the University of Virginia
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: escape-abm
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Epidemic Simulator Compiler and Programming Environment
|
|
5
|
+
Author-email: Parantapa Bhattacharya <parantapa@virginia.edu>
|
|
6
|
+
Project-URL: Homepage, http://github.com/nssac/escape-abm
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.11
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: click
|
|
14
|
+
Requires-Dist: platformdirs
|
|
15
|
+
Requires-Dist: rich
|
|
16
|
+
Requires-Dist: tree-sitter
|
|
17
|
+
Requires-Dist: tree-sitter-esl
|
|
18
|
+
Requires-Dist: jinja2
|
|
19
|
+
Requires-Dist: pygls
|
|
20
|
+
Requires-Dist: platformdirs
|
|
21
|
+
Requires-Dist: numpy
|
|
22
|
+
Requires-Dist: scipy
|
|
23
|
+
Requires-Dist: pandas
|
|
24
|
+
Requires-Dist: pyarrow
|
|
25
|
+
Requires-Dist: polars
|
|
26
|
+
Requires-Dist: h5py
|
|
27
|
+
Requires-Dist: typeguard
|
|
28
|
+
Requires-Dist: pydantic
|
|
29
|
+
|
|
30
|
+
# ESCAPE: Epidemic Simulator Compiler and Programming Environment
|
|
31
|
+
|
|
32
|
+

|
|
33
|
+
|
|
34
|
+
The *Epidemic Simulator Compiler and Programming Environment* or ESCAPE
|
|
35
|
+
is a framework for efficiently developing
|
|
36
|
+
high-performance agent based epidemic simulators.
|
|
37
|
+
|
|
38
|
+
ESCAPE uses a domain specific language
|
|
39
|
+
called the *Epidemic Simulator Language* or ESL,
|
|
40
|
+
which users have to use to define the epidemic simulations.
|
|
41
|
+
The ESL language provides domain specific constructs
|
|
42
|
+
to define compartmental disease models
|
|
43
|
+
and the structure of the contact networks
|
|
44
|
+
on top of which the disease propagate.
|
|
45
|
+
Additionally, ESL also includes general purpose programming constructs
|
|
46
|
+
— conditionals, loops, functions, variables, etc. —
|
|
47
|
+
and parallel constructs
|
|
48
|
+
— select, sample, apply, and reduce —
|
|
49
|
+
for describing interventions.
|
|
50
|
+
|
|
51
|
+
ESCAPE provides a compiler that converts
|
|
52
|
+
the epidemic simulators written in ESL into C++ or CUDA programs.
|
|
53
|
+
Simulators created with ESCAPE are high performance
|
|
54
|
+
parallel programs that run on multi-core CPU systems
|
|
55
|
+
or GPU based systems.
|
|
56
|
+
The ESCAPE compiler itself is written in Python.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# ESCAPE: Epidemic Simulator Compiler and Programming Environment
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
The *Epidemic Simulator Compiler and Programming Environment* or ESCAPE
|
|
6
|
+
is a framework for efficiently developing
|
|
7
|
+
high-performance agent based epidemic simulators.
|
|
8
|
+
|
|
9
|
+
ESCAPE uses a domain specific language
|
|
10
|
+
called the *Epidemic Simulator Language* or ESL,
|
|
11
|
+
which users have to use to define the epidemic simulations.
|
|
12
|
+
The ESL language provides domain specific constructs
|
|
13
|
+
to define compartmental disease models
|
|
14
|
+
and the structure of the contact networks
|
|
15
|
+
on top of which the disease propagate.
|
|
16
|
+
Additionally, ESL also includes general purpose programming constructs
|
|
17
|
+
— conditionals, loops, functions, variables, etc. —
|
|
18
|
+
and parallel constructs
|
|
19
|
+
— select, sample, apply, and reduce —
|
|
20
|
+
for describing interventions.
|
|
21
|
+
|
|
22
|
+
ESCAPE provides a compiler that converts
|
|
23
|
+
the epidemic simulators written in ESL into C++ or CUDA programs.
|
|
24
|
+
Simulators created with ESCAPE are high performance
|
|
25
|
+
parallel programs that run on multi-core CPU systems
|
|
26
|
+
or GPU based systems.
|
|
27
|
+
The ESCAPE compiler itself is written in Python.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
TODOs
|
|
2
|
+
=====
|
|
3
|
+
|
|
4
|
+
Bugfix
|
|
5
|
+
......
|
|
6
|
+
|
|
7
|
+
* Upgrade to latest tree-sitter parser
|
|
8
|
+
* Allow negative constants for config and globals
|
|
9
|
+
* Add support to save specific global/config values each tick
|
|
10
|
+
* Add more support for templated identifier and expressions
|
|
11
|
+
|
|
12
|
+
Base features
|
|
13
|
+
..............
|
|
14
|
+
|
|
15
|
+
* Support grouped reductions
|
|
16
|
+
* Support codegen for Kokkos / CUDA
|
|
17
|
+
* Support distributed memory implementation using MPI / UPCXX
|
|
18
|
+
|
|
19
|
+
Performance improvement
|
|
20
|
+
.......................
|
|
21
|
+
|
|
22
|
+
* Use bitset/succinct datastructure instead of array of bytes
|
|
23
|
+
* Profile cpu code with vtune/advisor
|
|
24
|
+
|
|
25
|
+
* Merge back to back parallel calls
|
|
26
|
+
* Use differnt / faster random number generator
|
|
27
|
+
|
|
Binary file
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
Howto setup Jupyter Lab for local EpiSim37 development
|
|
2
|
+
======================================================
|
|
3
|
+
|
|
4
|
+
For this setup we shall use the Conda package manager.
|
|
5
|
+
|
|
6
|
+
Installation instructions for Miniconda can be found
|
|
7
|
+
`here <https://docs.conda.io/en/latest/miniconda.html>`_.
|
|
8
|
+
|
|
9
|
+
Once setup is done, please ensure that your conda config contains the following:
|
|
10
|
+
|
|
11
|
+
.. code::
|
|
12
|
+
|
|
13
|
+
# ~/.condarc
|
|
14
|
+
|
|
15
|
+
channels:
|
|
16
|
+
- conda-forge
|
|
17
|
+
- defaults
|
|
18
|
+
anaconda_upload: false
|
|
19
|
+
auto_activate_base: false
|
|
20
|
+
|
|
21
|
+
Create and activate a conda environment.
|
|
22
|
+
|
|
23
|
+
.. code::
|
|
24
|
+
|
|
25
|
+
$ conda create -n episim37 python=3.11 nodejs=20 jupyterlab=4.1.8 gxx_impl_linux-64 cmake ninja hdf5
|
|
26
|
+
$ conda activate episim37
|
|
27
|
+
|
|
28
|
+
Install jupyterlab_esl37 (for ESL37 file type support),
|
|
29
|
+
episim37 (for ESL37 language server),
|
|
30
|
+
and jupyterlab-lsp (for allowing Jupyter Lab to use the language server).
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
.. code::
|
|
34
|
+
|
|
35
|
+
$ pip install jupyterlab_esl37 episim37 jupyterlab-lsp
|
|
36
|
+
|
|
37
|
+
Configure jupyterlab-lsp.
|
|
38
|
+
|
|
39
|
+
.. code::
|
|
40
|
+
|
|
41
|
+
# Locate episim37 executable
|
|
42
|
+
$ which episim37
|
|
43
|
+
/path/to/miniconda3/envs/episim37/bin/episim37
|
|
44
|
+
|
|
45
|
+
# Ensure config directory exits
|
|
46
|
+
$ mkdir -p $HOME/.jupyter/jupyter_server_config.d
|
|
47
|
+
|
|
48
|
+
Create the jupyterlab-lsp config file with the following contents:
|
|
49
|
+
|
|
50
|
+
.. code::
|
|
51
|
+
|
|
52
|
+
# $HOME/.jupyter/jupyter_server_config.d/esl37-ls.json
|
|
53
|
+
|
|
54
|
+
{
|
|
55
|
+
"LanguageServerManager": {
|
|
56
|
+
"language_servers": {
|
|
57
|
+
"episim37": {
|
|
58
|
+
"version": 2,
|
|
59
|
+
"argv": [
|
|
60
|
+
"/path/to/miniconda3/envs/episim37/bin/episim37",
|
|
61
|
+
"language-server",
|
|
62
|
+
"io-server"
|
|
63
|
+
],
|
|
64
|
+
"languages": [
|
|
65
|
+
"esl37"
|
|
66
|
+
],
|
|
67
|
+
"mime_types": [
|
|
68
|
+
"text/esl37"
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
Replace `/path/to/miniconda3/envs/episim37/bin/episim37` with
|
|
76
|
+
the real path of the episim37 executable.
|
|
77
|
+
|
|
78
|
+
Jupyter Lab should now be configured for opening ESL37 files.
|
|
79
|
+
Start Jupyter Lab using the following command:
|
|
80
|
+
|
|
81
|
+
.. code::
|
|
82
|
+
|
|
83
|
+
$ cd $HOME
|
|
84
|
+
$ jupyter lab
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
Known Issues
|
|
88
|
+
------------
|
|
89
|
+
|
|
90
|
+
If your Jupyter kernel keeps crashing on a Apple Mac
|
|
91
|
+
it maybe due to incompatibility with `polars'.
|
|
92
|
+
You can try using the long term release version of polars.
|
|
93
|
+
|
|
94
|
+
.. code::
|
|
95
|
+
|
|
96
|
+
$ pip uninstall polars
|
|
97
|
+
$ pip install polars-lts-cpu
|
|
98
|
+
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# Example 1: In-school NPIs
|
|
2
|
+
|
|
3
|
+
config enable_hybrid_learning: bool = True
|
|
4
|
+
config enable_day_30_antigen_test: bool = True
|
|
5
|
+
config enable_day_30_pcr_test: bool = False
|
|
6
|
+
config transmissibility_scale: float = 0.3
|
|
7
|
+
|
|
8
|
+
node
|
|
9
|
+
pid: int node key
|
|
10
|
+
is_in_school: bool static
|
|
11
|
+
home_isolation_start: int
|
|
12
|
+
home_isolation_end: int
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
edge
|
|
16
|
+
target_pid: int target node key
|
|
17
|
+
source_pid: int source node key
|
|
18
|
+
duration: int static
|
|
19
|
+
is_school_edge: bool static
|
|
20
|
+
is_non_home_edge: bool static
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
enum c1_state_t
|
|
24
|
+
S, E, Ipresymp, Isymp, Iasymp, R
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
contagion c1
|
|
28
|
+
state type c1_state_t
|
|
29
|
+
|
|
30
|
+
transition
|
|
31
|
+
E -> Ipresymp, p = 0.65, dwell = 3.0
|
|
32
|
+
E -> Iasymp, p = 0.35, dwell = normal5
|
|
33
|
+
Ipresymp -> Isymp, dwell = 2.0
|
|
34
|
+
Isymp -> R, dwell = isymp_r_dwell
|
|
35
|
+
Iasymp -> R, dwell = normal5
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
transmission
|
|
39
|
+
Ipresymp => S -> E
|
|
40
|
+
Isymp => S -> E
|
|
41
|
+
Iasymp => S -> E
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
susceptibility c1_susceptibility
|
|
45
|
+
infectivity c1_infectivity
|
|
46
|
+
transmissibility c1_transmissibility
|
|
47
|
+
enabled c1_enabled
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def c1_susceptibility(v: node) -> float:
|
|
51
|
+
if v.c1.state == S:
|
|
52
|
+
return 1.0
|
|
53
|
+
else:
|
|
54
|
+
return 0.0
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def c1_infectivity(v: node) -> float:
|
|
59
|
+
if v.c1.state == Ipresymp:
|
|
60
|
+
return 0.8
|
|
61
|
+
elif v.c1.state == Isymp or v.c1.state == Iasymp:
|
|
62
|
+
return 1.0
|
|
63
|
+
else:
|
|
64
|
+
return 0.0
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def c1_transmissibility(e: edge) -> float:
|
|
69
|
+
return transmissibility_scale * e.duration / 86400
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def c1_enabled(e: edge) -> bool:
|
|
73
|
+
if e.is_non_home_edge and (is_isolating(e.source_node) or is_isolating(e.target_node)):
|
|
74
|
+
return False
|
|
75
|
+
elif e.is_school_edge and not is_school_day():
|
|
76
|
+
return False
|
|
77
|
+
else:
|
|
78
|
+
return True
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def is_isolating(n: node) -> bool:
|
|
83
|
+
if CUR_TICK <= n.home_isolation_start and n.home_isolation_end < CUR_TICK:
|
|
84
|
+
return True
|
|
85
|
+
else:
|
|
86
|
+
return False
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# Sunday = 0, Monday = 1, Tuesday = 2, Wednesday = 3
|
|
91
|
+
# Thursday = 4, Friday = 5
|
|
92
|
+
def is_school_day() -> bool:
|
|
93
|
+
var day_of_week : int = CUR_TICK % 7
|
|
94
|
+
|
|
95
|
+
if enable_hybrid_learning and 1 <= day_of_week and day_of_week <= 3:
|
|
96
|
+
return True
|
|
97
|
+
elif 1 <= day_of_week and day_of_week <= 5:
|
|
98
|
+
return True
|
|
99
|
+
else:
|
|
100
|
+
return False
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
distribution
|
|
105
|
+
discrete isymp_r_dwell
|
|
106
|
+
p = 0.175, v = 1
|
|
107
|
+
p = 0.175, v = 2
|
|
108
|
+
p = 0.1, v = 3
|
|
109
|
+
p = 0.1, v = 4
|
|
110
|
+
p = 0.1, v = 5
|
|
111
|
+
p = 0.1, v = 6
|
|
112
|
+
p = 0.1, v = 7
|
|
113
|
+
p = 0.05, v = 8
|
|
114
|
+
p = 0.05, v = 9
|
|
115
|
+
p = 0.05, v = 10
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
normal normal5
|
|
119
|
+
mean = 5.0, std = 1.0, min = 0.0
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
nodeset susceptibles
|
|
124
|
+
nodeset seed_nodes
|
|
125
|
+
nodeset positive_inschool_nodes
|
|
126
|
+
nodeset will_start_isolation
|
|
127
|
+
|
|
128
|
+
def intervene():
|
|
129
|
+
if CUR_TICK < 10:
|
|
130
|
+
select(susceptibles, [n: node -> bool](n.c1.state == S))
|
|
131
|
+
sample(seed_nodes, susceptibles, 5, ABSOLUTE)
|
|
132
|
+
apply(seed_nodes, [n: node]{ n.c1.state = E ; })
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
select(susceptibles, [n: node -> bool](n.c1.state == S))
|
|
136
|
+
|
|
137
|
+
if (enable_day_30_antigen_test or enable_day_30_pcr_test) and CUR_TICK >= 30:
|
|
138
|
+
select(positive_inschool_nodes, [n: node -> bool](
|
|
139
|
+
(n.c1.state == Ipresymp or n.c1.state == Isymp or n.c1.state == Iasymp)
|
|
140
|
+
and n.is_in_school
|
|
141
|
+
and not is_isolating(n)
|
|
142
|
+
))
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
if enable_day_30_antigen_test and CUR_TICK >= 30:
|
|
146
|
+
sample(will_start_isolation, positive_inschool_nodes, 0.8, RELATIVE)
|
|
147
|
+
apply(will_start_isolation, [n: node]{
|
|
148
|
+
n.home_isolation_start = CUR_TICK+1
|
|
149
|
+
n.home_isolation_end = CUR_TICK+15
|
|
150
|
+
})
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
if enable_day_30_pcr_test and CUR_TICK >= 30:
|
|
154
|
+
sample(will_start_isolation, positive_inschool_nodes, 0.95, RELATIVE)
|
|
155
|
+
apply(will_start_isolation, [n: node]{
|
|
156
|
+
n.home_isolation_start = CUR_TICK+2
|
|
157
|
+
n.home_isolation_end = CUR_TICK+16
|
|
158
|
+
})
|
|
159
|
+
end
|
|
160
|
+
end
|
|
Binary file
|