Symbolic MatrixBased Models¶
Provides an API to define epidemiological models in terms of sympy symbolic expressions based on a matrix description.

class
epipack.symbolic_matrix_epi_models.
SymbolicMatrixEpiModel
(compartments, initial_population_size=1, correct_for_dynamical_population_size=False)[source]¶ Bases:
epipack.symbolic_epi_models.SymbolicMixin
,epipack.numeric_matrix_epi_models.MatrixEpiModel
A general class to define standard meanfield compartmental epidemiological model.

compartments
¶ A list containing strings that describe each compartment, (e.g. "S", "I", etc.).

linear_rates
¶ Matrix containing transition rates of the linear processes.
 Type
sympy.Matrix

quadratic_rates
¶ List of matrices that contain transition rates of the quadratic processes for each compartment.
 Type
list of sympy.Matrix

affected_by_quadratic_process
¶ List of integer compartment IDs, collecting compartments that are affected by the quadratic processes
Example
>>> epi = SymbolicMatrixEpiModel(symbols("S I R")) >>> print(epi.compartments) [ S, I, R ]

set_linear_rates
(rate_list, reset_rates=True, allow_nonzero_column_sums=True)[source]¶ Define the linear transition rates between compartments.
 Parameters
A list of tuples that contains transitions rates in the following format:
[ ( acting_compartment, affected_compartment, rate ), ... ]
allow_nonzero_column_sums (
bool
, default : False)  This keyword has no function in this classreset_rates (bool, default : True)  Whether to reset all linear rates to zero before setting the new ones.

set_quadratic_rates
(rate_list, reset_rates=True, allow_nonzero_column_sums=False)[source]¶ Define the quadratic transition processes between compartments.
 Parameters
A list of tuples that contains transitions rates in the following format:
[ ("coupling_compartment_0", "coupling_compartment_1", "affected_compartment", rate ), ... ]
allow_nonzero_column_sums (
bool
, default : False)  This keyword has no function in this classreset_rates (bool, default : True)  Whether to reset all quadratic rates to zero before setting the new ones.
Example
For an SEIR model.
epi.set_quadratic_rates([ ("S", "I", "S", 1 ), ("S", "I", "E", +1 ) ])
Read as
"Coupling of S and I leads to a reduction in "S" proportional to \(S\times I\) and rate 1/time_unit. Furthermore, coupling of S and I leads to an increase in "E" proportional to \(S\times I\) and rate +1/time_unit."


class
epipack.symbolic_matrix_epi_models.
SymbolicMatrixSIModel
(infection_rate, initial_population_size=1)[source]¶ Bases:
epipack.symbolic_matrix_epi_models.SymbolicMatrixEpiModel
An SI model derived from
epipack.symbolic_epi_models.SymbolicMatrixEpiModel
.

class
epipack.symbolic_matrix_epi_models.
SymbolicMatrixSIRModel
(infection_rate, recovery_rate, initial_population_size=1)[source]¶ Bases:
epipack.symbolic_matrix_epi_models.SymbolicMatrixEpiModel
An SIR model derived from
epipack.symbolic_epi_models.SymbolicMatrixEpiModel
.

class
epipack.symbolic_matrix_epi_models.
SymbolicMatrixSIRSModel
(infection_rate, recovery_rate, waning_immunity_rate, initial_population_size=1)[source]¶ Bases:
epipack.symbolic_matrix_epi_models.SymbolicMatrixEpiModel
An SIRS model derived from
epipack.symbolic_epi_models.SymbolicMatrixEpiModel
.

class
epipack.symbolic_matrix_epi_models.
SymbolicMatrixSISModel
(infection_rate, recovery_rate, initial_population_size=1)[source]¶ Bases:
epipack.symbolic_matrix_epi_models.SymbolicMatrixEpiModel
An SIS model derived from
epipack.symbolic_epi_models.SymbolicMatrixEpiModel
.