Epidemiology
Epidemiology: compartmental, network, metapopulation, and agent-based models of infection and recovery.
ActiveHostElement(label, visual=None, *, i=0.0, a=0.1, lam=0.3, mu=0.1)
Bases: Element
Node of an activity-driven network, susceptible at i = 0 or infected at i = 1, in discrete time.
A TransitionInteraction recovers an infected node with probability mu in a step, and another infects a
susceptible node with probability lam by every infected neighbour along the edges of the previous step. A
TopologyInteraction joins the node to other nodes with the probability a, its activity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the node or of the group of nodes. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
None
|
i
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
Whether the node is infected. |
0.0
|
a
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The activity, the probability of firing at a step. |
0.1
|
lam
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The probability of infection along one edge. |
0.3
|
mu
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The probability of recovery at a step. |
0.1
|
Examples:
>>> from skcomplex.models.biology.epidemiology import ActiveHostElement
>>> ActiveHostElement('node').mu
0.1
Source code in src/skcomplex/models/biology/epidemiology/_active_host.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
CarrierElement(label, visual=None, *, p=0.05, lam=0.2)
Bases: Element
Node of a network whose state is the probability that it is infected, in quenched mean field.
The node recovers at rate 1 and every infected neighbour infects it at rate lam, with the probabilities of the
neighbours taken as independent, so dp_i / dt = -p_i + lam (1 - p_i) sum_j A_ij p_j over the neighbours j.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the node or of the group of nodes. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
None
|
p
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The initial probability of being infected. |
0.05
|
lam
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The spreading rate, the ratio of the infection rate per edge and the recovery rate. |
0.2
|
Examples:
>>> from skcomplex.models.biology.epidemiology import CarrierElement
>>> CarrierElement('node').lam
0.2
Source code in src/skcomplex/models/biology/epidemiology/_carrier.py
43 44 45 46 47 48 49 50 51 52 53 | |
DegreeClassElement(label, visual=None, *, rho=0.01, lam=0.2, k=1.0, P=1.0)
Bases: Element
Infected density of the nodes of one degree of a network, in heterogeneous mean field.
A node of degree k recovers at rate 1 and is infected at rate lam k Theta, where
Theta = sum_k k P(k) rho_k / <k> is the probability that an edge points to an infected node, a total over the
degree classes, so d rho_k / dt = -rho_k + lam k (1 - rho_k) Theta. The classes are the members of a group, and
the recovery and the infection are interactions of the group, which heterogeneous_mean_field_sis adds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the class or the group of classes. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
None
|
rho
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The initial infected density. |
0.01
|
lam
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The spreading rate, the ratio of the infection and recovery rates. |
0.2
|
k
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The degree of the class. |
1.0
|
P
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The probability |
1.0
|
Examples:
>>> from skcomplex.core.elements import GroupElement
>>> from skcomplex.models.biology.epidemiology import DegreeClassElement
>>> GroupElement(
... 'network', element=DegreeClassElement, size=2, values={'k': [1.0, 2.0], 'P': [0.5, 0.5]}
... ).check().prepare().size_
2
Source code in src/skcomplex/models/biology/epidemiology/_degree_class.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
EpidemicCenterElement(label, visual=None, *, x=0.0, a=2.2, recovery=6, e=0.005)
Bases: Element
City in a discrete-time SIRS epidemic, where an infection lasts one step and immunity recovery steps.
The state keeps the infected fractions of the last 12 steps, so the recovery time is at most 12.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the center. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
None
|
x
|
Annotated[float, StateSpec(domain=closed_open(0, oo), lags=MAX_RECOVERY, initial=(0.0,) * MAX_RECOVERY)]
|
The initial fraction of infected individuals. |
0.0
|
a
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The rate of transmission per contact. |
2.2
|
recovery
|
Annotated[int, ParameterSpec(domain=NN)]
|
The number of steps a recovered individual stays immune, at most 12. |
6
|
e
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The fraction of the infected of the center who visit another center. |
0.005
|
Examples:
>>> from skcomplex.models.biology.epidemiology import EpidemicCenterElement
>>> EpidemicCenterElement('city', x=0.01).recovery
6
Source code in src/skcomplex/models/biology/epidemiology/_recurrent.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
HostElement(label, visual=None, *, i=0.0, w=1.0)
Bases: Element
Node of a network that is susceptible at i = 0 or infected at i = 1, in continuous time.
A SpreadingInteraction infects and recovers it, and a TopologyInteraction rewires its edges at its rate w.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the node or of the group of nodes. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
None
|
i
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
Whether the node is infected. |
0.0
|
w
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The rate at which the node, while susceptible, rewires an edge to an infected neighbour. |
1.0
|
Examples:
>>> from skcomplex.models.biology.epidemiology import HostElement
>>> HostElement('node').w
1.0
Source code in src/skcomplex/models/biology/epidemiology/_host.py
39 40 41 42 43 44 45 46 47 48 49 | |
ImmunityLossInteraction(label, *, recovered, susceptible, xi=0.05, stochastic=False)
Bases: ReactionInteraction
Loss of immunity, the reaction R -> S at the rate xi R from recovered back to susceptible.
It is a ReactionInteraction between the states n of the two compartments its roles bind, a rate equation, or
in stochastic mode a random event that moves one individual.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
recovered
|
Annotated[str, RoleSpec()]
|
The path of the recovered compartment. |
required |
susceptible
|
Annotated[str, RoleSpec()]
|
The path of the susceptible compartment. |
required |
xi
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The rate at which immunity wanes. |
0.05
|
stochastic
|
bool
|
Whether losses of immunity are random events. |
False
|
Examples:
>>> from skcomplex.models.biology.epidemiology import ImmunityLossInteraction
>>> ImmunityLossInteraction('waning', recovered='R', susceptible='S', xi=0.05).check().xi
0.05
Source code in src/skcomplex/models/biology/epidemiology/_immunity_loss.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
ImmunizingDegreeClassElement(label, visual=None, *, s=0.999, i=0.001, r=0.0, beta=0.1, mu=1.0, k=1.0, P=1.0)
Bases: Element
Susceptible, infected, and recovered densities of the nodes of one degree, in heterogeneous mean field.
A susceptible node of degree k is infected at rate beta k theta and an infected node recovers at rate mu, so
d i_k / dt = -mu i_k + beta k s_k theta and d r_k / dt = mu i_k. On an uncorrelated network, the probability
that a contact of a susceptible node is infected is theta = sum_k (k - 1) P(k) i_k / <k>, a total over the
degree classes, since an infected neighbour of degree k has at most k - 1 other contacts. The classes are the
members of a group, and the infections and the recoveries are interactions of the group, which
heterogeneous_mean_field_sir adds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the class or the group of classes. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
None
|
s
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The initial susceptible density. |
0.999
|
i
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The initial infected density. |
0.001
|
r
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The initial recovered density. |
0.0
|
beta
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The rate of transmission along one contact. |
0.1
|
mu
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The recovery rate. |
1.0
|
k
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The degree of the class. |
1.0
|
P
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The probability |
1.0
|
Examples:
>>> from skcomplex.models.biology.epidemiology import ImmunizingDegreeClassElement
>>> GroupElement(
... 'network',
... element=ImmunizingDegreeClassElement,
... size=3,
... values={'k': [1.0, 2.0, 3.0], 'P': [0.5, 0.3, 0.2]},
... ).size
3
Source code in src/skcomplex/models/biology/epidemiology/_outbreaks.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
InfectionInteraction(label, *, susceptible, infected, beta=0.001, stochastic=False)
Bases: ReactionInteraction
Mass-action infection, the reaction S + I -> 2 I at the rate beta S I from susceptible to infected.
It is a ReactionInteraction between the states n of the two compartments its roles bind, a rate equation, or
in stochastic mode a random event that moves one individual.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
susceptible
|
Annotated[str, RoleSpec()]
|
The path of the susceptible compartment. |
required |
infected
|
Annotated[str, RoleSpec()]
|
The path of the infected compartment. |
required |
beta
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The transmission rate. |
0.001
|
stochastic
|
bool
|
Whether infections are random events. |
False
|
Examples:
>>> from skcomplex.core.elements import CompartmentElement
>>> from skcomplex.core.system import System
>>> from skcomplex.engine.runtime import Simulation
>>> from skcomplex.models.biology.epidemiology import InfectionInteraction
>>> system = System(
... elements=[CompartmentElement('S', n=99.0), CompartmentElement('I', n=1.0)],
... interactions=[InfectionInteraction('infection', susceptible='S', infected='I', beta=0.01)],
... )
>>> trajectory = Simulation(system, dt=0.1).check().prepare().run(until=5.0).trajectory_
>>> round(float(trajectory.values('S.n')[-1] + trajectory.values('I.n')[-1]), 6)
100.0
Source code in src/skcomplex/models/biology/epidemiology/_infection.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
PersonElement(label, visual=VisualSpec('agents', {'color_by': 'health', 'color_range': (0.0, 4.0)}), *, health=SUSCEPTIBLE, d=0.8, beta=0.6, gamma=0.01, mu=0.0, alpha=0.0, lockdown_start=0.0, lockdown_length=0.0, lockdown_d=0.1)
Bases: Element
Person of the agent-based SIR model, with incubation, mortality, waning immunity, and lockdown.
A MovementInteraction walks a living person to a neighbouring cell with probability d, or lockdown_d during
the lockdown, which lasts lockdown_length steps from lockdown_start. Transitions of the agent form, which
agent_based_sir adds, move the health of the person. An infectious person infects, with probability beta,
every susceptible person in its cell, who becomes exposed. An infectious person recovers with probability gamma
or dies with probability mu, and a recovered person loses immunity with probability alpha. Health is 0
susceptible, 1 exposed, 2 infected, 3 recovered, or 4 dead.
The incubation follows the convention of the residence time after of TransitionInteraction: the step of the
exposure counts as the first step in the exposed state, so a person exposed in step n becomes infectious at the
end of step n + incubation - 1. The clock that the person kept before counted the step of the exposure only when
the person acted after its infector in that step, so the onset now comes half a step earlier on average.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the agent or group. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
VisualSpec('agents', {'color_by': 'health', 'color_range': (0.0, 4.0)})
|
health
|
Annotated[float, StateSpec(domain=NN)]
|
The health state. |
SUSCEPTIBLE
|
d
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The probability of moving at every step. |
0.8
|
beta
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The probability that an infectious person infects the susceptible persons of its cell. |
0.6
|
gamma
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The probability of recovering at every step. |
0.01
|
mu
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The probability of dying at every step of the infection. |
0.0
|
alpha
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The probability of losing immunity at every step. |
0.0
|
lockdown_start
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The step at which the lockdown starts. |
0.0
|
lockdown_length
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The number of steps of the lockdown, 0 for none. |
0.0
|
lockdown_d
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The probability of moving during the lockdown. |
0.1
|
Examples:
>>> from skcomplex.core.elements import GroupElement
>>> from skcomplex.models.biology.epidemiology import PersonElement
>>> GroupElement('people', element=PersonElement, size=100).size
100
Source code in src/skcomplex/models/biology/epidemiology/_person.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
RecoveryInteraction(label, *, infected, recovered, gamma=0.1, stochastic=False)
Bases: ReactionInteraction
Recovery, the reaction I -> R at the rate gamma I from infected to recovered.
It is a ReactionInteraction between the states n of the two compartments its roles bind, a rate equation, or
in stochastic mode a random event that moves one individual.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
infected
|
Annotated[str, RoleSpec()]
|
The path of the infected compartment. |
required |
recovered
|
Annotated[str, RoleSpec()]
|
The path of the recovered compartment. |
required |
gamma
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The recovery rate. |
0.1
|
stochastic
|
bool
|
Whether recoveries are random events. |
False
|
Examples:
>>> from skcomplex.core.elements import CompartmentElement
>>> from skcomplex.core.system import System
>>> from skcomplex.engine.runtime import Simulation
>>> from skcomplex.models.biology.epidemiology import RecoveryInteraction
>>> system = System(
... elements=[CompartmentElement('I', n=10.0), CompartmentElement('R')],
... interactions=[RecoveryInteraction('recovery', infected='I', recovered='R', gamma=0.5)],
... )
>>> trajectory = Simulation(system, dt=0.01).check().prepare().run(until=2.0).trajectory_
>>> round(float(trajectory.values('I.n')[-1]), 3)
3.679
Source code in src/skcomplex/models/biology/epidemiology/_recovery.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
SpreadingInteraction(label, *, target, state='state', beta=1.0, gamma=0.0, omega=0.0, inactive=0.0, active=1.0, removed=None, form='number', layer=None)
Bases: TransitionInteraction
Spreading of the active value of a discrete state along the edges of a network or the bonds of a lattice.
An inactive member becomes active at the rate beta times the number of its active neighbours, or times their
fraction of its neighbours. An active member recovers at the rate gamma, to the inactive value, or to the removed
value when there is one, and a removed member returns to the inactive value at the rate omega. Every move is a
transition at a rate, so the state changes by random events in continuous time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction, unique among the parts of its system. |
required |
target
|
Annotated[str, RoleSpec()]
|
The path of the group on the nodes or sites. |
required |
state
|
str
|
The name of the discrete state of the members. |
'state'
|
beta
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The rate of spreading from one active neighbour, or from all neighbours when they are all active. |
1.0
|
gamma
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The rate of recovery of an active member. |
0.0
|
omega
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The rate at which a removed member returns to the inactive value. |
0.0
|
inactive
|
float
|
The value of the state of an inactive member. |
0.0
|
active
|
float
|
The value of the state of an active member. |
1.0
|
removed
|
float | None
|
The value of the state of a recovered member, or |
None
|
form
|
str
|
|
'number'
|
layer
|
str | None
|
The layer of the network whose edges the spreading runs on, or |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
The form is unknown, or the values of the state are not distinct. |
Examples:
>>> from skcomplex.models.biology.epidemiology import SpreadingInteraction
>>> spreading = SpreadingInteraction('spreading', target='sites', beta=2.0, gamma=1.0, form='fraction')
>>> spreading.check().form
'fraction'
Source code in src/skcomplex/models/biology/epidemiology/_spreading.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
SubpopulationElement(label, visual=None, *, S=1000.0, I=0.0, R=0.0, beta=0.3, gamma=0.1, D=0.01)
Bases: Element
Well-mixed SIR population at a node of a network, whose individuals hop along each edge at the rate D.
Inside the node, beta S I / N individuals are infected and gamma I recover per unit time, with
N = S + I + R. Hopping along every edge adds D times the graph Laplacian to every compartment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the subpopulation or the field. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
None
|
S
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The initial number of susceptible individuals. |
1000.0
|
I
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The initial number of infected individuals. |
0.0
|
R
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The initial number of recovered individuals. |
0.0
|
beta
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The infection rate. |
0.3
|
gamma
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The recovery rate. |
0.1
|
D
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The rate at which an individual hops along one edge. |
0.01
|
Examples:
>>> from skcomplex.models.biology.epidemiology import SubpopulationElement
>>> SubpopulationElement('city', S=1000.0).beta
0.3
Source code in src/skcomplex/models/biology/epidemiology/_subpopulation.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
TravellerElement(label, visual=VisualSpec('agents', {'color_by': 'health', 'color_range': (0.0, 3.0)}), *, health=SUSCEPTIBLE, tau=0.05, m=0.05)
Bases: Element
Resident of a city at a network node, who infects fellow residents and travels to neighbouring cities.
In its own activation, an infected traveller infects every susceptible traveller of its node with probability
tau, by a TransitionInteraction whose members act on their cell, and another transition makes it recover after
a residence of a number of steps. A MovementInteraction moves it to a random neighbouring node with probability
m. Health is 0 susceptible, 2 infected, or 3 recovered.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the agent or group. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
VisualSpec('agents', {'color_by': 'health', 'color_range': (0.0, 3.0)})
|
health
|
Annotated[float, StateSpec(domain=NN)]
|
The health state. |
SUSCEPTIBLE
|
tau
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The probability of infecting a susceptible traveller of the same node at every step. |
0.05
|
m
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The probability of moving to a neighbouring node at every step. |
0.05
|
Examples:
>>> from skcomplex.core.elements import GroupElement
>>> from skcomplex.models.biology.epidemiology import TravellerElement
>>> GroupElement('travellers', element=TravellerElement, size=10).size
10
Source code in src/skcomplex/models/biology/epidemiology/_traveller.py
48 49 50 51 52 53 54 55 56 57 58 59 60 | |
VaccinatedPopulationElement(label, visual=None, *, S=0.99, I=0.01, R=0.0, u=0.0, beta=0.5, gamma=0.1, a=1.0, b=1.0)
Bases: Element
Susceptible, infected, and recovered fractions of a population vaccinated at a bounded rate.
The fractions follow S' = -beta S I - u S, I' = beta S I - gamma I, and R' = gamma I + u S, where the
vaccination rate u is a control input between 0 and its largest value. The planner minimises the burden of the
infections and the cost of the vaccines, ∫ (a I + b u^2 / 2) dt, after Lenhart and Workman.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the population. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
None
|
S
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The initial susceptible fraction. |
0.99
|
I
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The initial infected fraction. |
0.01
|
R
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The initial recovered fraction. |
0.0
|
u
|
Annotated[float, ParameterSpec(adaptive=True, bounds=(0.0, MAX_RATE))]
|
The vaccination rate, the control input. |
0.0
|
beta
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The transmission rate. |
0.5
|
gamma
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The recovery rate. |
0.1
|
a
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The weight of the infected fraction in the cost. |
1.0
|
b
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The weight of the squared vaccination rate in the cost. |
1.0
|
Examples:
>>> from skcomplex.models.biology.epidemiology import VaccinatedPopulationElement
>>> VaccinatedPopulationElement('population', I=0.01).I
0.01
Source code in src/skcomplex/models/biology/epidemiology/_vaccination.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
WalkerElement(label, visual=VisualSpec('agents', {'color_by': 'health', 'color_range': (0.0, 2.0)}), *, health=HEALTHY, infection=1.0, travel=1.0)
Bases: Element
Random walker that carries a deadly disease, of Charbonneau's epidemic model.
In its own activation, a living walker moves to a neighbouring cell or node with probability travel by a
MovementInteraction, and a TransitionInteraction whose members act on their cell makes a sick walker infect
every healthy walker of its cell with probability infection. Another transition kills a sick walker after a
residence of a number of steps. Health is 0 healthy, 1 sick, or 2 dead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the agent or group. |
required |
visual
|
VisualSpec | None
|
How the element is drawn, or |
VisualSpec('agents', {'color_by': 'health', 'color_range': (0.0, 2.0)})
|
health
|
Annotated[float, StateSpec(domain=NN)]
|
The health state. |
HEALTHY
|
infection
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The probability that a sick walker infects a healthy walker of its cell at every step. |
1.0
|
travel
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The probability of moving at every step. |
1.0
|
Examples:
>>> from skcomplex.core.elements import GroupElement
>>> from skcomplex.models.biology.epidemiology import WalkerElement
>>> GroupElement('walkers', element=WalkerElement, size=10).size
10
Source code in src/skcomplex/models/biology/epidemiology/_walker.py
49 50 51 52 53 54 55 56 57 58 59 60 61 | |
activity_driven_epidemics(n=500, *, m=2, exponent=2.2, least=0.01, lam=0.9, mu=0.1, infected=0.05, seed=1)
Return SIS spreading on an activity-driven temporal network, whose edges last one step.
At every step every node fires with probability its activity, drawn from a^-exponent above least, and joins
m random nodes. The infection travels along the edges of a step, which disappear at the next step, so it spreads
only when lam / mu exceeds a threshold set by the moments of the activity, 2 <a> / (m (<a> + sqrt(<a^2>))) in
the limit of small probabilities, and not by the degrees of the network aggregated over time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
The number of nodes. |
500
|
m
|
int
|
The number of edges an active node creates. |
2
|
exponent
|
float
|
The exponent of the power-law distribution of activities. |
2.2
|
least
|
float
|
The smallest activity. |
0.01
|
lam
|
float
|
The probability of infection along one edge. |
0.9
|
mu
|
float
|
The probability of recovery at a step. |
0.1
|
infected
|
float
|
The initial share of infected nodes. |
0.05
|
seed
|
int | None
|
The seed of the activities and the initial infections. |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The model, with the states |
Examples:
>>> from skcomplex.models.biology.epidemiology import activity_driven_epidemics
>>> float(activity_driven_epidemics(n=10, seed=0).elements[0].values['a'].min()) >= 0.01
True
Source code in src/skcomplex/models/biology/epidemiology/_adaptive.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | |
adaptive_sis(n=200, k=6.0, *, beta=0.4, gamma=1.0, w=1.0, infected=0.2, seed=1)
Return the SIS epidemic on a network whose susceptible nodes cut their edges to infected neighbours.
Every edge between a susceptible and an infected node is rewired at rate w: the susceptible end keeps it and
joins it to another susceptible node. Rewiring isolates the infected nodes and raises the epidemic threshold above
its value on the fixed network, while the susceptible nodes cluster.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
The number of nodes. |
200
|
k
|
float
|
The mean degree of the initial Erdős-Rényi network. |
6.0
|
beta
|
float
|
The infection rate per edge to an infected neighbour. |
0.4
|
gamma
|
float
|
The recovery rate. |
1.0
|
w
|
float
|
The rewiring rate of an edge between a susceptible and an infected node. |
1.0
|
infected
|
float
|
The initial share of infected nodes. |
0.2
|
seed
|
int | None
|
The seed of the network and of the initial infections. |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The model, with the states |
Examples:
>>> from skcomplex.models.biology.epidemiology import adaptive_sis
>>> [component.label for component in adaptive_sis(n=20).elements]
['hosts', 'contacts']
Source code in src/skcomplex/models/biology/epidemiology/_adaptive.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | |
agent_based_sir(width=50, height=50, *, people=500, infected=5, d=0.8, beta=0.6, gamma=0.02, mu=0.0, alpha=0.0, incubation=0.0, lockdown_start=0.0, lockdown_length=0.0, lockdown_d=0.1, random_state=0)
Return people who walk on a grid and infect those in their cell, with optional extensions of the SIR model.
The basic model infects with probability beta and recovers with probability gamma. Its final size depends on
beta and gamma separately, not only on their ratio, because walking limits the contacts. Mortality mu, waning
immunity alpha, an incubation of incubation steps, and a lockdown that lowers the probability of moving to
lockdown_d extend it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
width
|
int
|
The number of columns of the grid. |
50
|
height
|
int
|
The number of rows of the grid. |
50
|
people
|
int
|
The number of people. |
500
|
infected
|
int
|
The initial number of infected people. |
5
|
d
|
float
|
The probability of moving at every step. |
0.8
|
beta
|
float
|
The probability that an infectious person infects the susceptible persons of its cell. |
0.6
|
gamma
|
float
|
The probability of recovering at every step. |
0.02
|
mu
|
float
|
The probability of dying at every step of the infection. |
0.0
|
alpha
|
float
|
The probability of losing immunity at every step. |
0.0
|
incubation
|
float
|
The number of steps an infected person stays exposed before it becomes infectious, counting the step of
the exposure, as the residence time of |
0.0
|
lockdown_start
|
float
|
The step at which the lockdown starts. |
0.0
|
lockdown_length
|
float
|
The number of steps of the lockdown, 0 for none. |
0.0
|
lockdown_d
|
float
|
The probability of moving during the lockdown. |
0.1
|
random_state
|
int | Generator | None
|
The seed or generator of the initial cells and infections. |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The model, with the group |
Examples:
>>> from skcomplex.models.biology.epidemiology import agent_based_sir
>>> int(agent_based_sir(people=100, infected=3, random_state=0).elements[0].values['health'].sum())
6
Source code in src/skcomplex/models/biology/epidemiology/_agents.py
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | |
delayed_sirs(first=0.01, second=0.0, *, a=2.0, recovery=6, e=0.005)
Return two cities with recurrent outbreaks of a disease of fixed infection and immunity periods.
With one infected step and recovery immune steps, each city follows x' = a x (1 - x - x(t-1) - ... -
x(t-recovery)), which reduces to the logistic map without immunity. Outbreaks recur like relaxation oscillations,
and the visits of a fraction e of the infected couple the two cities, whose outbreaks lock in or out of phase.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
first
|
float
|
The initial infected fraction of the first city. |
0.01
|
second
|
float
|
The initial infected fraction of the second city. |
0.0
|
a
|
float
|
The rate of transmission per contact. |
2.0
|
recovery
|
int
|
The number of steps a recovered individual stays immune, at most 12. |
6
|
e
|
float
|
The fraction of the infected who visit the other city. |
0.005
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The model, with the centers |
Examples:
>>> from skcomplex.models.biology.epidemiology import delayed_sirs
>>> delayed_sirs().elements[0].x
0.01
Source code in src/skcomplex/models/biology/epidemiology/_recurrent.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |
heterogeneous_mean_field_sir(exponent=2.5, k_min=3, k_max=100, *, beta=0.1, mu=1.0, infected=0.0001)
Return the SIR epidemic on an uncorrelated network of power-law degrees, in heterogeneous mean field.
The degrees run from k_min to k_max with P(k) ~ k^-exponent. An outbreak grows when
beta / mu > <k> / (<k^2> - <k>), a threshold close to <k> / <k^2> on heterogeneous networks, which vanishes on
scale-free networks as k_max grows. Below it the epidemic dies out after infecting a share of the order of the
initial one, and above it a finite share of the population ends recovered. The hubs are infected first.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exponent
|
float
|
The exponent of the degree distribution. |
2.5
|
k_min
|
int
|
The smallest degree. |
3
|
k_max
|
int
|
The largest degree. |
100
|
beta
|
float
|
The rate of transmission along one contact. |
0.1
|
mu
|
float
|
The recovery rate. |
1.0
|
infected
|
float
|
The initial infected density of every class. |
0.0001
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The model, with the densities |
Examples:
>>> from skcomplex.models.biology.epidemiology import heterogeneous_mean_field_sir
>>> heterogeneous_mean_field_sir(k_min=2, k_max=5).elements[0].check().prepare().size_
4
Source code in src/skcomplex/models/biology/epidemiology/_outbreaks.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
heterogeneous_mean_field_sis(exponent=2.5, k_min=3, k_max=30, *, lam=0.2, rho=0.01)
Return the SIS epidemic on a network with a power-law degree distribution, in heterogeneous mean field.
The degrees run from k_min to k_max with P(k) ~ k^-exponent. The infection persists above the epidemic
threshold lam_c = <k> / <k^2>, which vanishes on scale-free networks as k_max grows, and dies out below it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exponent
|
float
|
The exponent of the degree distribution. |
2.5
|
k_min
|
int
|
The smallest degree. |
3
|
k_max
|
int
|
The largest degree. |
30
|
lam
|
float
|
The spreading rate, the ratio of the infection and recovery rates. |
0.2
|
rho
|
float
|
The initial infected density of every class. |
0.01
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The model, with the densities |
Examples:
>>> from skcomplex.models.biology.epidemiology import heterogeneous_mean_field_sis
>>> heterogeneous_mean_field_sis(k_min=2, k_max=5).elements[0].check().prepare().size_
4
Source code in src/skcomplex/models/biology/epidemiology/_networks.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
metapopulation(graph=None, *, population=1000.0, infected=10.0, beta=0.3, gamma=0.1, D=0.01)
Return SIR epidemics in subpopulations at the nodes of a network, linked by individuals who travel.
The infection starts in the first node and spreads to the others with the travellers. The total number of individuals stays constant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
object
|
The NetworkX graph, or |
None
|
population
|
float
|
The initial number of individuals of every node. |
1000.0
|
infected
|
float
|
The initial number of infected individuals in the first node. |
10.0
|
beta
|
float
|
The infection rate. |
0.3
|
gamma
|
float
|
The recovery rate. |
0.1
|
D
|
float
|
The rate at which an individual hops along one edge. |
0.01
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The model, with the compartments |
Examples:
>>> import networkx as nx
>>> from skcomplex.models.biology.epidemiology import metapopulation
>>> metapopulation(nx.path_graph(4)).elements[0].check().prepare().size_
4
Source code in src/skcomplex/models/biology/epidemiology/_networks.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
network_sir(graph=None, *, residents=20, tau=0.05, days=14.0, m=0.05, random_state=0)
Return SIR epidemics in cities at the nodes of a network, carried between cities by travellers.
Every node starts with the same number of susceptible residents, and one resident of a random node is infected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
object
|
The NetworkX graph of the cities, or |
None
|
residents
|
int
|
The initial number of travellers per node. |
20
|
tau
|
float
|
The probability of infecting a susceptible traveller of the same node at every step. |
0.05
|
days
|
float
|
The number of steps an infection lasts. |
14.0
|
m
|
float
|
The probability of moving to a neighbouring node at every step. |
0.05
|
random_state
|
int | Generator | None
|
The seed or generator of the first infection. |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The model, with the group |
Examples:
>>> import networkx as nx
>>> from skcomplex.models.biology.epidemiology import network_sir
>>> network_sir(nx.cycle_graph(5), residents=3).elements[0].check().prepare().size_
15
Source code in src/skcomplex/models/biology/epidemiology/_agents.py
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 | |
quenched_mean_field_sis(graph=None, *, n=300, m=3, lam=0.2, p=0.05, seed=1)
Return the SIS epidemic on a fixed network in quenched mean field, one infection probability per node.
The infection persists above the threshold lam_c = 1 / Lambda, the inverse of the largest eigenvalue of the
adjacency matrix, and dies out below it. On scale-free networks the hubs keep it alive at small lam.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
Graph | None
|
The network, or |
None
|
n
|
int
|
The number of nodes of the default network. |
300
|
m
|
int
|
The number of edges of every new node of the default network. |
3
|
lam
|
float
|
The spreading rate, the ratio of the infection rate per edge and the recovery rate. |
0.2
|
p
|
float
|
The initial probability that every node is infected. |
0.05
|
seed
|
int | None
|
The seed of the default network. |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The model, with the probabilities |
Examples:
>>> import networkx as nx
>>> from skcomplex.models.biology.epidemiology import quenched_mean_field_sis
>>> quenched_mean_field_sis(nx.cycle_graph(10)).elements[0].check().prepare().size_
10
Source code in src/skcomplex/models/biology/epidemiology/_adaptive.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
random_walker_epidemics(width=64, height=64, *, walkers=1000, lifetime=20.0, infection=1.0, travel=1.0, graph=None, random_state=0)
Return random walkers among whom one sick walker starts a deadly epidemic, on a grid or on a network.
Sick walkers infect the walkers they meet in a cell and die lifetime steps later, so the epidemic spreads as a
front like a forest fire and burns out. Above a critical density of walkers it percolates across the grid. On a
network, such as a small world of cities, walkers travel along edges and long links carry the disease far.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
width
|
int
|
The number of columns of the grid, whose edges walkers cannot cross. |
64
|
height
|
int
|
The number of rows of the grid. |
64
|
walkers
|
int
|
The number of walkers. |
1000
|
lifetime
|
float
|
The number of steps a walker lives after its infection. |
20.0
|
infection
|
float
|
The probability that a sick walker infects a healthy walker of its cell at every step. |
1.0
|
travel
|
float
|
The probability of moving at every step. |
1.0
|
graph
|
object
|
A NetworkX graph whose nodes the walkers occupy instead of the grid, or |
None
|
random_state
|
int | Generator | None
|
The seed or generator of the initial places and the first sick walker. |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The model, with the group |
Examples:
>>> from skcomplex.models.biology.epidemiology import random_walker_epidemics
>>> float(random_walker_epidemics(walkers=50).elements[0].values['health'].sum())
1.0
Source code in src/skcomplex/models/biology/epidemiology/_agents.py
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 | |
sir(susceptible=990.0, infected=10.0, recovered=0.0, *, beta=0.0003, gamma=0.1, stochastic=False)
Return an epidemic that moves individuals from susceptible to infected to recovered.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
susceptible
|
float
|
The initial number of susceptible individuals. |
990.0
|
infected
|
float
|
The initial number of infected individuals. |
10.0
|
recovered
|
float
|
The initial number of recovered individuals. |
0.0
|
beta
|
float
|
The infection rate per susceptible-infected pair. |
0.0003
|
gamma
|
float
|
The recovery rate. |
0.1
|
stochastic
|
bool
|
Whether infections and recoveries are random events of single individuals. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The model, with the compartments |
Examples:
>>> from skcomplex.models.biology.epidemiology import sir
>>> [element.label for element in sir().elements]
['S', 'I', 'R']
Source code in src/skcomplex/models/biology/epidemiology/_factories.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
sir_vaccination(S=0.99, I=0.01, *, beta=0.5, gamma=0.1, a=1.0, b=1.0)
Return an SIR epidemic with the vaccination rate that minimises the burden of infections and vaccines.
Run with an optimal control solver, vaccination is strongest early, while many are susceptible, and the epidemic
peaks lower than without vaccination. With no weight a on the infections the optimal rate is 0, the epidemic
without control.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
S
|
float
|
The initial susceptible fraction. |
0.99
|
I
|
float
|
The initial infected fraction. |
0.01
|
beta
|
float
|
The transmission rate. |
0.5
|
gamma
|
float
|
The recovery rate. |
0.1
|
a
|
float
|
The weight of the infected fraction in the cost. |
1.0
|
b
|
float
|
The weight of the squared vaccination rate in the cost. |
1.0
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The model, with the fractions |
Examples:
>>> from skcomplex.models.biology.epidemiology import sir_vaccination
>>> sir_vaccination(beta=0.3).elements[0].beta
0.3
Source code in src/skcomplex/models/biology/epidemiology/_vaccination.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
sirs(susceptible=990.0, infected=10.0, recovered=0.0, *, beta=0.0003, gamma=0.1, xi=0.02, stochastic=False)
Return an epidemic whose immunity wanes, which returns in damped waves to an endemic equilibrium.
The equilibrium has S = gamma / beta susceptible and I = xi (N - S) / (gamma + xi) infected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
susceptible
|
float
|
The initial number of susceptible individuals. |
990.0
|
infected
|
float
|
The initial number of infected individuals. |
10.0
|
recovered
|
float
|
The initial number of recovered individuals. |
0.0
|
beta
|
float
|
The infection rate per susceptible-infected pair. |
0.0003
|
gamma
|
float
|
The recovery rate. |
0.1
|
xi
|
float
|
The rate at which immunity wanes. |
0.02
|
stochastic
|
bool
|
Whether infections, recoveries, and losses of immunity are random events of single individuals. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The model, with the compartments |
Examples:
>>> from skcomplex.models.biology.epidemiology import sirs
>>> sirs(xi=0.1).interactions[-1].xi
0.1
Source code in src/skcomplex/models/biology/epidemiology/_factories.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | |
sis(susceptible=990.0, infected=10.0, *, beta=0.0003, gamma=0.1, stochastic=False)
Return an infection without immunity, where the recovered become susceptible again and the disease is endemic.
Above the threshold beta N > gamma, the infected settle at I = N - gamma / beta, and below it they die out.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
susceptible
|
float
|
The initial number of susceptible individuals. |
990.0
|
infected
|
float
|
The initial number of infected individuals. |
10.0
|
beta
|
float
|
The infection rate per susceptible-infected pair. |
0.0003
|
gamma
|
float
|
The recovery rate. |
0.1
|
stochastic
|
bool
|
Whether infections and recoveries are random events of single individuals. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The model, with the compartments |
Examples:
>>> from skcomplex.models.biology.epidemiology import sis
>>> [element.label for element in sis().elements]
['S', 'I']
Source code in src/skcomplex/models/biology/epidemiology/_factories.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |