connectors
Define connectors, which are used to mediate interactions between modules when the sim is run.
While most of the
Classes
| Name | Description |
|---|---|
| Connector | Base class for Connectors, which mediate interactions between disease (or other) modules |
| seasonality | Example connector – apply sine-wave seasonality of transmission to one or more diseases |
Connector
connectors.Connector(name=None, label=None, **kwargs)Base class for Connectors, which mediate interactions between disease (or other) modules
Because connectors can do anything, they have no specified structure: it is up to the user to define how they behave.
seasonality
connectors.seasonality(**kwargs)Example connector – apply sine-wave seasonality of transmission to one or more diseases
This works by modifying the disease’s rel_trans state; note that it replaces it with the seasonality variable, and will overwrite any existing values. (Note: this function would work more or less identically as an intervention, but it is closer in spirit to a connector.)
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| diseases | str / list | disease or list of diseases to apply seasonality to | required |
| scale | float | how strong of a seasonality effect to apply (0.1 = 90-110% relative transmission rate depending on time of year) | required |
| shift | float | offset by time of year (0.5 = 6 month offset) | required |
Example:
import starsim as ss
pars = dict(
n_agents = 10_000,
start = '2020-01-01',
stop = '2023-01-01',
dt = ss.weeks(1.0),
diseases = dict(
type = 'sis',
beta = ss.perweek(0.05),
dur_inf = ss.weeks(5),
waning = ss.perweek(0.1),
dt = ss.weeks(1),
),
networks = 'random',
)
s1 = ss.Sim(pars, connectors=None, label='Random network')
s2 = ss.Sim(pars, connectors=ss.seasonality(), label='Seasonality')
s3 = ss.Sim(pars, connectors=ss.seasonality(scale=0.5, shift=0.2), label='Extreme seasonality')
msim = ss.parallel(s1, s2, s3)
msim.plot('sis')
s3.connectors[0].plot()
Methods
| Name | Description |
|---|---|
| step | Apply seasonality |
step
connectors.seasonality.step(*args, **kwargs)Apply seasonality