# Epidemics on models¶

In a temporal network model based on rates, it might happen that in a simulation there’s many events which then have to be passed to the Gillespie simulation function. This is rather heavy on memory. Instead, one can simulate directly on the model without saving the generated temporal network. So far, this is implemented for the edge activity model and the Flockwork-P model only. It works as follows.

First, you create an instance of the model, e.g. _tacoma.EdgeActivityModel as

AM = tc.EdgeActivityModel(N, # number of nodes
k/(N-1.), # network density
omega, # edge activity rate
save_temporal_network=False)


By default, save_temporal_network is False, if you want to save the generated temporal network, pass True instead.

Second, create an instance of an epidemic class, e.g. _tacoma.SIS.

SIS = tc.SIS(N, #number of nodes
tmax, # maximum time of the simulation
infection_rate,
recovery_rate,
number_of_initially_infected = int(N), # optional, default: 1
number_of_initially_vaccinated = 0, # optional, default: 0
seed = 792, # optional, default: randomly initiated
)


Note that the seed passed to _tacoma.EdgeActivityModel is overwritten with the random number generator (RNG) created in _tacoma.SIS. This RNG is also used in the corresponding Gillespie simulation, which is started and plotted as

tc.gillespie_epidemics(AM, SIS)

import matplotlib.pyplot as pl

pl.step(SIS.time, SIS.I)


The corresponding Flockwork-P model would be created as

FW = tc.FlockworkPModel(
E  # initial edge list (list of tuple of ints)
N, # number of nodes
gamma, # rate with which anything happens
P,     # probability to reconnect
save_temporal_network=False
)
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.2943654954433441, "perplexity": 5412.940769746377}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2021-43/segments/1634323586043.75/warc/CC-MAIN-20211024142824-20211024172824-00038.warc.gz"}