Simulation
alles aus setup folder configuration des sim objects
Overview Structs
GEMS.InfectedFraction
GEMS.NoneInfected
GEMS.Simulation
GEMS.Simulation
GEMS.Simulation
GEMS.Simulation
GEMS.StartCondition
GEMS.StopCriterion
GEMS.TimesUp
Overview Functions
GEMS.add_hospitalization_trigger!
GEMS.add_strategy!
GEMS.add_symptom_trigger!
GEMS.add_testtype!
GEMS.add_tick_trigger!
GEMS.ags
GEMS.configfile
GEMS.customlogger
GEMS.customlogger!
GEMS.customlogs
GEMS.deathlogger
GEMS.deaths
GEMS.evaluate
GEMS.event_queue
GEMS.fire_custom_loggers!
GEMS.fraction
GEMS.hospitalization_triggers
GEMS.incidence
GEMS.increment!
GEMS.infections
GEMS.info
GEMS.interval
GEMS.label
GEMS.limit
GEMS.parameters
GEMS.pathogen
GEMS.pathogen!
GEMS.pooltestlogger
GEMS.pooltests
GEMS.population
GEMS.populationDF
GEMS.populationfile
GEMS.quarantinelogger
GEMS.quarantines
GEMS.region_info
GEMS.remove_empty_settings!
GEMS.reset!
GEMS.run!
GEMS.settings
GEMS.settings
GEMS.should_fire
GEMS.start_condition
GEMS.step!
GEMS.stepmod
GEMS.stop_criterion
GEMS.strategies
GEMS.symptom_triggers
GEMS.testlogger
GEMS.tests
GEMS.testtypes
GEMS.tick
GEMS.tick_triggers
GEMS.tickunit
Structs
GEMS.InfectedFraction
— TypeInfectedFraction <: StartCondition
A StartCondition
that specifies a fraction of infected individuals (drawn at random).
Fields
fraction::Float64
: A fraction of the whole population that has ot be infectedpathogen::Pathogen
: The pathogen with which the fraction has to be infected
GEMS.NoneInfected
— TypeNoneInfected <: StopCriterion
A StopCriterion
that stops the simulation once no individual is infected.
GEMS.Simulation
— TypeSimulation
A struct for the management of a single run, holding all necessary informations.
Fields
- Data Sources
configfile::String
: Path to config file
- General
tick::Int16
: Current tick/timesteptickunit::Char
: Time unit of one simulation step (tick)startdate::Date
: Start date of the simulationenddate::Date
: End date of the simulationstart_condition::StartCondition
: Starting condition that sets the initial situationstop_criterion::StopCriterion
: Criterion that terminates a simulation runlabel::String
: Label for plot visualizations
- Model
population::Population
: Container to hold all present individualssettings::SettingsContainer
: All settings present in the simulationpathogen::Pathogen
: The pathogen of which infections are simulated
- Logger
infectionlogger::InfectionLogger
: A logger tracking all infectionsdeathlogger::DeathLogger
: A logger specifically for the deaths of individualstestlogger::TestLogger
: A logger tracking all individual testspooltestlogger::PoolTestLogger
: A logger tracking all pool testsquarantinelogger::QuarantineLogger
: A tracking cumulative quarantines per tickcustomlogger::CustomLogger
: A logger running custom methods on theSimulation
object in each tick
- Interventions
symptom_triggers::Vector{ITrigger}
: List of allSymptomTriggers
tick_triggers::Vector{TickTrigger}
: List of allTickTriggers
hospitalization_triggers::Vector{ITrigger}
: List of allHospitalizationTriggers
event_queue::EventQueue
: Event Queue to apply intervention measuresstrategies::Vector{Strategy}
: List of all registered intervention strategiestesttypes::Vector{AbstractTestType}
: List of allTestTypes
(e.g. Antigen- or PCR-Test)
- Runtime Modifiers
stepmod::Function
: Single-argment function that runs custom code on the simulation object in each tick
GEMS.StartCondition
— Typesupertype for all start conditions
GEMS.StopCriterion
— Typesupertype for all stop criteria
GEMS.TimesUp
— TypeTimesUp <: StopCriterion
A StopCriterion
that specifies a time limit.
Fields
limit::Int16
: A time limit. When reached, the simulation should be terminated.
Constructors
GEMS.Simulation
— MethodSimulation(; simargs...)
Constructor that creates and initializes a Simulation
object based on various parameters.
It uses the default configuration for the created run which is saved in data/DefaultConf.toml
but should not be edited. See Usage and Examples on how to edit the simulation configuration.
- The constructor can be called without any parameters which will create a default simulation.
- A population can be provided. This can either be the path to a population file (.csv or .jdl2) or a
Population
object created. Either way the poulation will overwrite any population configurations in the config file. - Arguments can be provided overwriting just certain parameters. For all possible arguments see the table below. These arguments can be used in combination with a custom config file and will overwrite it where possible. Arguments can be combined.
- All arguments can alse be put into Dictionary and provided to function. This dictionary must have Symbols as keys. The keys must be the same as the argument names.
- All possibilities above can also be combined. Providing arguments will overwrite custom config file where possible. Custom populations will override custom arguments.
The optional stepmod
argument allows to pass a custom single-argument function that takes the simulation object as its argument and allows to do custom operations on the simulation object in each step.
Note: Be careful with the stepmod
option as there's no option to check whether your custom code invalidates simulation outputs or causes internal model inconsistencies. Please only use this option if you are sure you know what you're doing :-)
Examples
sim = Simulation() # returns a default simulation
sim = Simulation(population = "data/TestPop.csv") # returns a Simulation using the assigned population file.
sim = Simulation(population = Population()) # returns a Simulation using the created Population.
my_population = Population(n=1_000);
sim = Simulation(population = my_population) # returns a Simulation using the created Population that has its own parameters.
sim = Simulation(label = "My First Simulation") # returns a Simulation with a custom label
sim = Simulation(startdate = "2020.1.1", n = 100_000, transmission_rate = 0.2) # returns a Simulation starting at the 1.1.2020, having 100,000 individuals and a transmission rate of 0.2
my_arguments = Dict(
:transmission_rate => 0.3,
:pop_size => 10_000_000
)
sim = Simulation(my_arguments) # returns a `Simulation` the arguments provided in the dictionary.
sim = Simulation(population = Population(n=100_000), label = "My First Simulation") # returns a Simulation with a custom label and a population partly overwriting the default configuration.
Parameters
Name | Type | Description |
---|---|---|
population | String , Population | Path to a CSV or JLD2 file containing popultion data or a Population object |
settingsfile | String | Path to a setting-file |
label | String | Label used to name simulation runs during analysis |
stepmod | Function | One-agument function which will be executed each simulation step, called on the Simulation object |
seed | Int64 | Random seed |
global_setting | Bool | Enable or disable a global setting that contains every individual |
startdate | Date , String | Simulation start date (format: YYYY.MM.DD ) |
enddate | Date , String | Simulation end date (format: YYYY.MM.DD ) |
infected_fraction | Float64 | Fraction of the initially infected agents for the InfectedFraction start condition |
transmission_rate | Float64 | Infection probability (0-1) during a contact where one individual is infectious |
onset_of_symptoms | Float64 | Average time from exposure to onset of symptoms (Poisson-distributed) |
onset_of_severeness | Float64 | Average time from onset of symptoms to onset of severeness (Poisson-distributed) |
infectious_offset | Float64 | Average time from onset of infectiousness to onset of symptoms (Poisson-distributed); cannot be before exposure, obviously. |
mild_death_rate | Float64 | Probability of dying (0-1) with a mild disease progression |
severe_death_rate | Float64 | Probability of dying (0-1) with a severe disease progression |
critical_death_rate | Float64 | Probability of dying (0-1) with a critical disease progression |
hospitalization_rate | Float64 | Probability of being hospitalized (0-1) with a severe disease progression |
ventilation_rate | Float64 | Probability of being ventilated (0-1) with a critical disease progression |
icu_rate | Float64 | Probability of being admitted to ICU (0-1) with a critical disease progression |
time_to_recovery | Float64 | Average time from onset of symptoms to recovery (Poisson-distributed) |
time_to_hospitalization | Float64 | Average time from onset of symptoms to hospitalization (Poisson-distributed) |
time_to_icu | Float64 | Average time from hospitalization to ICU-addmitance (Poisson-distributed) |
length_of_stay | Float64 | Average duration of hospitalization (Poisson-distributed) |
progression_categories | Vector{Float64} | Four-value vector indicating the fraction of individuals with an asymptomatic, mild, severe, and critical progression (must sum to 1) |
office_contact_rate | Float64 | Average number of office contacts per timestep (Poisson-distributed) |
household_contact_rate | Float64 | Average number of household contacts per timestep (Poisson-distributed) |
school_contact_rate | Float64 | Average number of school contacts per timestep (Poisson-distributed) |
school_class_contact_rate | Float64 | Average number of school-class contacts per timestep (Poisson-distributed) |
school_year_contact_rate | Float64 | Average number of school-year contacts per timestep (Poisson-distributed) |
school_complex_contact_rate | Float64 | Average number of school-complex contacts per timestep (Poisson-distributed) |
workplace_site_contact_rate | Float64 | Average number of workplace-site contacts per timestep (Poisson-distributed) |
workplace_contact_rate | Float64 | Average number of workplace contacts per timestep (Poisson-distributed) |
department_contact_rate | Float64 | Average number of department contacts per timestep (Poisson-distributed) |
municipality_contact_rate | Float64 | Average number of municipality contacts per timestep (Poisson-distributed) |
global_contact_rate | Float64 | Average number of contacts in the global per timestep (Poisson-distributed) |
Population Parameters | ||
pop_size | Int64 | Number of individuals in the population |
avg_household_size | Int64 | Average size of households |
avg_office_size | Int64 | Average size of offices |
avg_school_size | Int64 | Average size of schools |
GEMS.Simulation
— MethodSimulation(argsdict::Dict{Symbol, <:Any})
Takes a dict as input.
The dict contains the custom parameters of the other constructors but combined as Dict
with Symbols as keys.
Example
my_arguments = Dict(
:transmission_rate = 0.3,
:configfile = "Data/ChangedConfig.toml",
:n = 10_000_000
)
sim = Simulation(my_arguments) # returns a `Simulation` the arguments provided in the dictionary.
GEMS.Simulation
— MethodSimulation(file::String; simargs...)
Takes a path to a file as input and checks if it is a population or config file. Creates a simulation with that population or configuration. Further parameters can be defined.
Calls a deeper constructor
Functions
GEMS.add_hospitalization_trigger!
— Functionadd_hospitalization_trigger!(simulation, trigger)
Adds a HospitalizationTrigger
to the simulation.
GEMS.add_strategy!
— Functionadd_strategy!(simulation, strategy)
Adds an intervention Strategy
to the simulation object. A strategy must be added to the simulation object to make it appear in the report. In order to execute a strategy during the simulation run, you must define a Trigger
and link this strategy. Just adding it here will not execute the strategy.
GEMS.add_symptom_trigger!
— Functionadd_symptom_trigger!(simulation, trigger)
Adds a SymptomTrigger
to the simulation.
GEMS.add_testtype!
— Functionadd_testtype!(simulation, testtype)
Adds a test type to the simulation.
GEMS.add_tick_trigger!
— Functionadd_tick_trigger!(simulation, trigger)
Adds a TickTrigger
to the simulation.
GEMS.ags
— Methodags(patientZeros)
Returns the vector of ags where intial seeds should be planted.
GEMS.configfile
— Methodconfigfile(simulation)
Returns configfile that was used to initialize simulation.
GEMS.customlogger!
— Methodcustomlogger!(simulation, customlogger)
Sets the Simulation's CustomLogger
.
GEMS.customlogger
— Methodcustomlogger(simulation)
Returns the CustomLogger
of the simulation.
GEMS.customlogs
— Functioncustomlogs(simulation::Simulation)
Calls the dataframe()
function on the internal simulation's CustomLogger
.
GEMS.deaths
— Methoddeaths(simulation::Simulation)
Calls the dataframe()
function on the internal simulation's DeathLogger
.
GEMS.deathlogger
— Methoddeathlogger(simulation)
Returns the DeathLogger
of the simulation.
GEMS.evaluate
— Functionevaluate(simulation, criterion)
Evaluates whether the specified stop criterion is met for the simulation model. Return True
if criterion was met. This is an 'abstract' function that must be implemented for concrete criterion types.
evaluate(simulation, criterion)
Returns true if specified termination tick has been met.
evaluate(simulation, criterion)
Returns true if none of the individuals are infected.
GEMS.event_queue
— Methodevent_queue(simulation)
Returns the simulation's intervention event queue.
GEMS.fire_custom_loggers!
— Methodfire_custom_loggers!(sim::Simulation)
Executes all custom functions that are stored in the CustomLogger
on the Simulation
object and stores them in the internal dataframe.
GEMS.fraction
— Methodfraction(infectedFraction)
Returns fraction of individuals that shall be infected at the beginning in this start condition.
GEMS.hospitalization_triggers
— Methodhospitalization_triggers(simulation)
Returns the list of HospitalizationTrigger
s registered in the simulation.
GEMS.incidence
— Functionincidence(simulation::Simulation, pathogen::Pathogen, base_size::Int = 100_000, duration::Int16 = Int16(7))
Returns the incidence at a particular pathogen and a point in time (current simulation tick). The duration
defines a time-span for which the incidence is measured (default: 7 ticks). The base_size
provides the population size reference (default: 100_000 individuals)
Parameters
simulation::Simulation
: Simulation objectpathogen::Pathogen
: Pathogen for which the incidence shall be calculatedbase_size::Int = 100_000
(optional): Reference popuation size for incidence calculationduration::Int16 = Int16(7)
(optional): Reference duration (in ticks) for the incidence calculation
Returns
Float64
: Incidence
incidence(simulation::Simulation, base_size::Int = 100_000, duration::Int16 = Int16(7))
Returns the incidence at a particular point in time (current simulation tick). NOTE: This will only work for the single-pathogen version. The duration
defines a time-span for which the incidence is measured (default: 7 ticks). The base_size
provides the population size reference (default: 100_000 individuals)
Parameters
simulation::Simulation
: Simulation objectbase_size::Int = 100_000
(optional): Reference popuation size for incidence calculationduration::Int16 = Int16(7)
(optional): Reference duration (in ticks) for the incidence calculation
Returns
Float64
: Incidence
GEMS.increment!
— Methodincrement!(simulation)
Increments the current simulation's tick counter by 1.
GEMS.infections
— Methodinfections(simulation::Simulation)
Calls the dataframe()
function on the internal simulation's InfectionLogger
.
GEMS.info
— Methodinfo(sim::Simulation)
Summary output for Simulation
object configuration.
GEMS.interval
— Functioninterval(trigger::TickTrigger)
Returns the interval
associated with a TickTrigger
.
GEMS.label
— Methodlabel(simulation::Simulation)
Returns simulation object's string label.
GEMS.limit
— Functionlimit(timesUp)
Returns time limit of a timesUp stop criterion.
GEMS.parameters
— Functionparameters(d::Distribution)
Returns a dictionary containing the string() of the distribution, the mean and the std.
parameters(dps::DiseaseProgressionStrat)::Dict
Obtains a dictionary containing the parameters of the DiseaseProgressionStrat.
parameters(transfunc::TransmissionFunction)
Fallback function for transmission functions that returns the type of the transmission function as an entry in a dictionary
parameters(transfunc::AgeDependentTransmissionRate)
Returns the parameters of the AgeDependentTransmissionRate
as a dictionary.
parameters(transfunc::ConstantTransmissionRate)
Returns the parameters of the ConstantTransmissionRate
as a dictionary.
parameters(pathogen::Pathogen):::Dict
Obtains a dictionary containing the parameters of the Pathogen. Distributions and the disease progression are formatted using their parameters function.
parameters(v::Vaccine)::Dict
Returns a dictionary containing the parameters of the vaccine.
parameters(s::StartCondition)
Returns an empty dictionary.
parameters(inffrac::InfectedFraction)
Returns a dictionary containing the parameters of the infected fraction start condition.
parameters(p0::PatientZero)
Returns a dictionary containing the parameters of the patient zero start condition.
parameters(p0::PatientZero)
Returns a dictionary containing the parameters of the patient zero start condition.
parameters(criterion::NoneInfected)
Fallback parameters function for the StopCriterion
.
parameters(criterion::TimesUp)
Returns a dictionary with the type and limit of the criterion
.
parameters(criterion::NoneInfected)
Returns a dictionary with the type of the NoneInfected
stop criterion.
GEMS.pathogen!
— Methodpathogen!(simulation, pathogen)
Sets the pathogen of the simulation.
GEMS.pathogen
— Functionpathogen(simulation)
Retursn the pathogen of the simulation.
pathogen(patientZero)
Returns pathogen used to infect individuals at the beginning in this start condition.
pathogen(patientZeros)
Returns pathogen used to infect individuals at the beginning in this start condition.
pathogen(infectedFraction)
Returns pathogen used to infect individuals at the beginning in this start condition.
pathogen(tt::TestType)
Returns the TestType's associated pathogen.
GEMS.pooltests
— Functionpooltests(simulation::Simulation)
Calls the dataframe()
function on the internal simulation's PoolTestLogger
.
GEMS.pooltestlogger
— Functionpooltestlogger(simulation)
Returns the PoolTestLogger
of the simulation.
GEMS.population
— Methodpopulation(simulation)
Returns the population associated with the simulation run.
GEMS.populationDF
— MethodpopulationDF(simulation::Simulation)
Calls the dataframe()
function on the simulation's Population object
.
GEMS.populationfile
— Methodpopulationfile(simulation)
Returns populationfile that was used to initialize simulation.
GEMS.quarantinelogger
— Methodquarantinelogger(simulation)
Returns the QuarantineLogger
of the simulation.
GEMS.quarantines
— Functionquarantines(simulation::Simulation)
Calls the dataframe()
function on the internal simulation's QuarantineLogger
.
GEMS.remove_empty_settings!
— Methodremove_empty_settings!(sim::Simulation)
Removes all settings that have no individuals associated with them. In the end update all ids to ensure that they are still correspond to the entry in the settings container.
GEMS.reset!
— Methodreset!(simulation)
Resets the current simulation's tick counter to 0.
GEMS.region_info
— Methodregion_info(sim::Simulation)
Returns a DataFrame
containing information about the Municipality
s in the model with the following columns:
Name | Type | Description |
---|---|---|
ags | AGS | Amtlicher Gemeindeschlüssel (Community Identification Code) |
pop_size | Int64 | Number of individuals in that municipality |
area | Float64 | Area size of this municipality in km² |
Note: This function will download the Germany shapefile, if it's not available locally, and return missing
values for pop_size
and area
if the download cannot be completed.
GEMS.run!
— Methodrun!(simulation::Simulation; with_progressbar::Bool = true)
Takes and initializes Simulation object and calls the stepping function (step!) until the stop criterion is met.
Returns
Simulation
: Simulation object
GEMS.settings
— Methodsettings(simulation::Simulation)
Returns a dictionary containing all settings, separated by setting type (key).
GEMS.settings
— Methodsettings(simulation::Simulation, settingtype::DataType)
Returns all settings of settingtype
of the simulation.
GEMS.should_fire
— Functionshould_fire(trigger::TickTrigger, tick::Int16)
Evaluates whether a trigger should be fired at a given tick. Considers switch_tick
and interval
.
Returns
Bool
: True, if the trigger should fire at this tick. False otherwise.
GEMS.start_condition
— Functionstart_condition(simulation)
Returns start condition associated with the simulation run.
start_condition(rd::ResultData)
Returns the StartCondition
object the simulation was initialized with. Returns an empty dictionary if the data is not available in the input ResultData
object.
GEMS.step!
— Functionstep!(simulation::Simulation)
Increments the simulation status by one tick and executes all events that shall be handled during this tick.
GEMS.stepmod
— Functionstepmod(simulation::Simulation)
Returns the defined step mod.
GEMS.stop_criterion
— Methodstop_criterion(simulation)
Returns stop criterion associated with the simulation run.
GEMS.strategies
— Methodstrategy(simulation)
Returns the intervention Strategy
s registered in the simulation.
GEMS.symptom_triggers
— Methodsymptom_triggers(simulation)
Returns the list of SymptomTrigger
s registered in the simulation.
GEMS.testlogger
— Methodtestlogger(simulation)
Returns the TestLogger
of the simulation.
GEMS.tests
— Methodtests(simulation::Simulation)
Calls the dataframe()
function on the internal simulation's TestLogger
.
GEMS.testtypes
— Methodtesttypes(simulation)
Returns the test types registered in the simulation.
GEMS.tick
— Methodtick(simulation)
Returns current tick of the simulation run.
GEMS.tick_triggers
— Methodtick_triggers(simulation)
Returns the list of TickTrigger
s registered in the simulation.
GEMS.tickunit
— Methodtickunit(simulation)
Returns the unit of the ticks as a char like in date formats, i.e. 'd' means days, 'h' mean hours, etc.