Class SIR
- All Implemented Interfaces:
Runnable, LifecycleListener, Model.HasDE, Model.HasDE.ODE, Model.HasDE.PDE, Model.HasDE.SDE, Model.HasIBS, RunListener, SampleListener, Features, HasHistogram, HasHistogram.Degree, HasHistogram.StatisticsProbability, HasHistogram.StatisticsStationary, HasHistogram.StatisticsTime, HasMean, HasMean.Traits, HasPop2D, HasPop2D.Traits, HasPop3D, HasPop3D.Traits, HasS3, CLOProvider
- S → I: Susceptible individuals become infected with a certain probability/rate
- I → R: Infected individuals recover with a certain probability/rate
- I → S: Infected individuals can become susceptible again (optional)
- R → S: Recovered individuals can become susceptible again with a certain probability/rate
- Author:
- Christoph Hauert
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassPopulation for individual based simulations of the SIR module.classODE model for the SIR module.classPDE model for the SIR module.classSDE model for the SIR module.Nested classes/interfaces inherited from interface Features
Features.Groups, Features.Multispecies, Features.Pairs, Features.Payoffs, Features.StaticNested classes/interfaces inherited from interface HasHistogram
HasHistogram.Degree, HasHistogram.Fitness, HasHistogram.StatisticsProbability, HasHistogram.StatisticsStationary, HasHistogram.StatisticsTime, HasHistogram.StrategyNested classes/interfaces inherited from interface HasMean
HasMean.Fitness, HasMean.TraitsNested classes/interfaces inherited from interface HasPop2D
HasPop2D.Fitness, HasPop2D.TraitsNested classes/interfaces inherited from interface HasPop3D
HasPop3D.Fitness, HasPop3D.TraitsNested classes/interfaces inherited from interface Model.HasDE
Model.HasDE.DGroups, Model.HasDE.DPairs, Model.HasDE.DualDynamics, Model.HasDE.EM, Model.HasDE.PDEADV, Model.HasDE.PDERD, Model.HasDE.RK5Nested classes/interfaces inherited from interface Model.HasIBS
Model.HasIBS.CGroups, Model.HasIBS.CPairs, Model.HasIBS.DGroups, Model.HasIBS.DPairs, Model.HasIBS.MCGroups, Model.HasIBS.MCPairs -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal CLOptionCommand line option to set the incidence rates for S → I.final CLOptionCommand line option to set the transition probability for S → I.final CLOptionCommand line option to set the transition probability for I → R.final CLOptionCommand line option to set the transition probability for R → S.(package private) static final intThe index of the infected trait/cohort.(package private) double[]The incidence power {p, q} for infected and susceptible density, I^p S^q in S → I.(package private) doubleThe transition probability/rate for infected to recovered, I → R.(package private) doubleThe transition probability/rate for infected to susceptible, I → S.(package private) doubleThe transition probability/rate for recovered to susceptible, R → S.(package private) double[]The transition probability/rate for susceptibles to infected, S → I, including seasonal variationpSI = pSI[0] + pSI[1] cos(pSI[2] t).(package private) static final intThe index of the recovered trait/cohort.(package private) static final intThe index of the susceptible trait/cohort.private static final doubleUseful constant for converting between angular frequency and period.Fields inherited from class Discrete
cloMonoStop, monoStop, mutationFields inherited from class Module
active, cloDeathRate, cloGeometry, cloNGroup, cloNPopulation, cloPhase2DAxes, cloTraitColors, cloTraitDisable, cloTraitNames, deathRate, defaultColor, engine, ibspop, ID, logger, map2fitness, markers, model, nActive, name, nGroup, nPopulation, nTraits, opponent, playerUpdate, species, structure, traitColor, traitName, trajectoryColor, VACANT_COLOR, VACANT_NAME, vacantIdxFields inherited from interface HasS3
CORNER_LEFT, CORNER_RIGHT, CORNER_TOP, EDGE_BOTTOM, EDGE_LEFT, EDGE_RIGHT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcollectCLO(CLOParser parser) All providers of command line options must implement this method to collect their options.Opportunity to supply custom individual based simulations.createModel(ModelType type) Creates a model of typetypeformodule.intFor replicator dynamics the frequencies of all traits must sum up to one.(package private) voidgetDerivatives(double t, double[] state, double[] change, double accuracy) The SIR model is defined by the following equations:getTitle()Returns title of active module, e.g.voidload()Load new module and perform basic initializations.Methods inherited from class Discrete
getMaxMonoPayoff, getMinMonoPayoff, getMonoPayoff, getMonoStop, getMutation, setMonoStop, unloadMethods inherited from class Module
add, check, getActiveTraits, getAuthors, getDeathRate, getGeometry, getIBSPopulation, getID, getKey, getMap2Fitness, getMarkers, getMeanColors, getModelTypes, getNActive, getName, getNGroup, getNPopulation, getNRoles, getNSpecies, getNTraits, getOpponent, getPlayerUpdate, getSpecies, getSpecies, getTraitColor, getTraitColors, getTraitName, getTraitNames, getTrajectoryColor, getVacantIdx, hasVacant, init, processColorMap, reset, run, setActiveTraits, setDeathRate, setIBSPopulation, setModel, setName, setNGroup, setNPopulation, setNTraits, setNTraits, setOpponent, setTraitColors, setTraitNames, setTrajectoryColorMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface CLOProvider
adjustCLOMethods inherited from interface Features
isMultispecies, isPairwise, isStaticMethods inherited from interface HasHistogram
getCustomLevels, getNTraits, getTraitColorsMethods inherited from interface LifecycleListener
modelLoaded, modelUnloaded, moduleLoaded, moduleRestored, moduleUnloadedMethods inherited from interface Model.HasIBS
createIBSMethods inherited from interface RunListener
modelDidInit, modelDidReset, modelRelaxed, modelRunning, modelSettings, modelStoppedMethods inherited from interface SampleListener
modelSample
-
Field Details
-
S
static final int SThe index of the susceptible trait/cohort.- See Also:
-
I
static final int IThe index of the infected trait/cohort.- See Also:
-
R
static final int RThe index of the recovered trait/cohort.- See Also:
-
pSI
double[] pSIThe transition probability/rate for susceptibles to infected, S → I, including seasonal variationpSI = pSI[0] + pSI[1] cos(pSI[2] t). -
pIR
double pIRThe transition probability/rate for infected to recovered, I → R. -
pIS
double pISThe transition probability/rate for infected to susceptible, I → S. -
pRS
double pRSThe transition probability/rate for recovered to susceptible, R → S. -
incidence
double[] incidenceThe incidence power {p, q} for infected and susceptible density, I^p S^q in S → I.Note: Note available in IBS models because the incidence powers are not straightforward to implement.
-
TWOPI
private static final double TWOPIUseful constant for converting between angular frequency and period.- See Also:
-
cloInfect
Command line option to set the transition probability for S → I. -
cloRecover
Command line option to set the transition probability for I → R. -
cloSuscept
Command line option to set the transition probability for R → S. -
cloIncidence
Command line option to set the incidence rates for S → I.
-
-
Constructor Details
-
SIR
Create a new SIR module with the given pacemaker.- Parameters:
engine- the pacemaker for running the model
-
-
Method Details
-
getTitle
-
load
-
getDependent
public int getDependent()Description copied from interface:Model.HasDEFor replicator dynamics the frequencies of all traits must sum up to one. Hence, fornTraitstraits there are onlynTraits-1degrees of freedom. The index returned bygetDependent()marks the one rate of change that is derived from all the others.Notes:
- Dependent traits are used by models where the frequencies of all types must sum up to one.
- Density modules do not have dependent traits and
getDependent()should return-1. - Currently differential equations implementations are only provided for Discrete modules.
- Specified by:
getDependentin interfaceModel.HasDE- Returns:
- the index of the dependent trait (or
-1if there is none)
-
collectCLO
Description copied from interface:CLOProviderAll providers of command line options must implement this method to collect their options.Each command line option is (uniquely) identified by it's name (see
CLOption.getName()), which corresponds to the long version of the option. If an attempt is made to add an option with a name that already exists, theparserissues a warning and ignores the option. Thus, in general, implementing subclasses should first register their options and callsuper.collectCLO(CLOParser)at the end such that subclasses are able to override command line options specified in a parental class.Override this method in subclasses to add further command line options. Subclasses must make sure that they include a call to super.
- Specified by:
collectCLOin interfaceCLOProvider- Overrides:
collectCLOin classDiscrete- Parameters:
parser- the reference to parser that manages command line options- See Also:
-
getDerivatives
void getDerivatives(double t, double[] state, double[] change, double accuracy) The SIR model is defined by the following equations:\begin{align*} \frac{dS}{dt} =& R \cdot p_{RS} + I \cdot p_{IS} - S^q \cdot I^p \cdot p_{SI} \\ \frac{dI}{dt} =& S^q \cdot I^p \cdot p_{SI} - I \cdot (p_{IR} + p_{IS}) \\ \frac{dR}{dt} =& I \cdot p_{IR} - R \cdot p_{RS} \end{align*}
where \(S\), \(I\), and \(R\) are the densities of susceptible, infected, and recovered cohorts of individuals and \(p_{SI}, p_{IR}, p_{RS}\), and \(p_{IS}\) are the transition rates between the different cohorts. The parameters \(p\) and \(q\) can be used to model non-linear incidence rates.
- Parameters:
t- the current time (not used in this model)state- the current state of the system, an array containing the densities of the susceptible, infected, and recovered cohortschange- the array to store the changes in the densities of the cohortsaccuracy- the numerical accuracy
-
createModel
Description copied from class:ModuleCreates a model of typetypeformodule.Note: Override to provide custom model implementations.
Important: any custom model implementations that involve random numbers, must use the shared random number generator for reproducibility
- Overrides:
createModelin classDiscrete- Parameters:
type- the type ofModelto create- Returns:
- the model for
moduleornullif the module does not support the requested model type - See Also:
-
createIBSPopulation
Description copied from class:ModuleOpportunity to supply custom individual based simulations.- Overrides:
createIBSPopulationin classModule<Discrete>- Returns:
- the custom IBSPopulation or
nullto use default.
-