SIR_VariableInfection
: SIR with per-edge infectivity
- class epydemic.SIR_VariableInfection
A version of the SIR compartmented model of disease where each edge can have a different infectivity. This is the basic machinery for supporting models with different populations of individuals, different environments, or different levels of contact.
Different parameters and additional node attributes
There is no use for the SIR.P_INFECT
parameter: instead the
infection probability of each edge is set by
SIR_VariableInfection.initialInfectivities()
. The value assigned
to each edge is stored in an edge property
-
SIR_VariableInfection.INFECTIVITY:
str
= None State variable holding an edge’s infectivity.
Building the model
- SIR_VariableInfection.build(params)
Build the model. This adds a tracker for SI edges, but with no associated stochastic event.
- Parameters:
params (
Dict
[str
,Any
]) – the simulation parameters
- SIR_VariableInfection.setUp(params)
Set up compartments and infectivites. Initial compartments are saet according to the usual approach for SIR using the parameter
SIR.P_INFECTED
. Per-edge infectivities are set using a call toinitialInfectivities()
.- Parameters:
params (
Dict
[str
,Any
]) – the simulation parameters
- SIR_VariableInfection.initialInfectivities()
Assign an infectivity to an edge. The default takes infectivities uniformly on the range \([0.0, 1.0]\). Sub-classes may override this to provide different distributions.
The event distribution
To allow the Dynamics
to access the infection events defined
per-edge we construct an event distribution at each time point. This
takes any events associated directly with loci (such as those
for removal) and adds an event per edge with the given probability.
- SIR_VariableInfection.perElementEventDistribution(t)
Construct the event distribution from the contents of the SI locus, combining each edge with its infection probability.
- Parameters:
t (
float
) – the simulation time- Return type:
List
[Tuple
[Locus
,float
,Callable
[[float
,Union
[Any
,Tuple
[Any
,Any
]]],None
],str
]]- Returns:
an event rate distribution