Simulation

alles aus setup folder configuration des sim objects

Overview Structs

Overview Functions

Structs

GEMS.InfectedFractionType
InfectedFraction <: 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 infected
  • pathogen::Pathogen: The pathogen with which the fraction has to be infected
GEMS.NoneInfectedType
NoneInfected <: StopCriterion

A StopCriterion that stops the simulation once no individual is infected.

GEMS.SimulationType
Simulation

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/timestep
    • tickunit::Char: Time unit of one simulation step (tick)
    • startdate::Date: Start date of the simulation
    • enddate::Date: End date of the simulation
    • start_condition::StartCondition: Starting condition that sets the initial situation
    • stop_criterion::StopCriterion: Criterion that terminates a simulation run
    • label::String: Label for plot visualizations
  • Model
    • population::Population: Container to hold all present individuals
    • settings::SettingsContainer: All settings present in the simulation
    • pathogen::Pathogen: The pathogen of which infections are simulated
  • Logger
    • infectionlogger::InfectionLogger: A logger tracking all infections
    • deathlogger::DeathLogger: A logger specifically for the deaths of individuals
    • testlogger::TestLogger: A logger tracking all individual tests
    • pooltestlogger::PoolTestLogger: A logger tracking all pool tests
    • quarantinelogger::QuarantineLogger: A tracking cumulative quarantines per tick
    • customlogger::CustomLogger: A logger running custom methods on the Simulation object in each tick
  • Interventions
    • symptom_triggers::Vector{ITrigger}: List of all SymptomTriggers
    • tick_triggers::Vector{TickTrigger}: List of all TickTriggers
    • hospitalization_triggers::Vector{ITrigger}: List of all HospitalizationTriggers
    • event_queue::EventQueue: Event Queue to apply intervention measures
    • strategies::Vector{Strategy}: List of all registered intervention strategies
    • testtypes::Vector{AbstractTestType}: List of all TestTypes (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.TimesUpType
TimesUp <: StopCriterion

A StopCriterion that specifies a time limit.

Fields

  • limit::Int16: A time limit. When reached, the simulation should be terminated.

Constructors

GEMS.SimulationMethod
Simulation(; 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

NameTypeDescription
populationString, PopulationPath to a CSV or JLD2 file containing popultion data or a Population object
settingsfileStringPath to a setting-file
labelStringLabel used to name simulation runs during analysis
stepmodFunctionOne-agument function which will be executed each simulation step, called on the Simulation object
seedInt64Random seed
global_settingBoolEnable or disable a global setting that contains every individual
startdateDate, StringSimulation start date (format: YYYY.MM.DD)
enddateDate, StringSimulation end date (format: YYYY.MM.DD)
infected_fractionFloat64Fraction of the initially infected agents for the InfectedFraction start condition
transmission_rateFloat64Infection probability (0-1) during a contact where one individual is infectious
onset_of_symptomsFloat64Average time from exposure to onset of symptoms (Poisson-distributed)
onset_of_severenessFloat64Average time from onset of symptoms to onset of severeness (Poisson-distributed)
infectious_offsetFloat64Average time from onset of infectiousness to onset of symptoms (Poisson-distributed); cannot be before exposure, obviously.
mild_death_rateFloat64Probability of dying (0-1) with a mild disease progression
severe_death_rateFloat64Probability of dying (0-1) with a severe disease progression
critical_death_rateFloat64Probability of dying (0-1) with a critical disease progression
hospitalization_rateFloat64Probability of being hospitalized (0-1) with a severe disease progression
ventilation_rateFloat64Probability of being ventilated (0-1) with a critical disease progression
icu_rateFloat64Probability of being admitted to ICU (0-1) with a critical disease progression
time_to_recoveryFloat64Average time from onset of symptoms to recovery (Poisson-distributed)
time_to_hospitalizationFloat64Average time from onset of symptoms to hospitalization (Poisson-distributed)
time_to_icuFloat64Average time from hospitalization to ICU-addmitance (Poisson-distributed)
length_of_stayFloat64Average duration of hospitalization (Poisson-distributed)
progression_categoriesVector{Float64}Four-value vector indicating the fraction of individuals with an asymptomatic, mild, severe, and critical progression (must sum to 1)
office_contact_rateFloat64Average number of office contacts per timestep (Poisson-distributed)
household_contact_rateFloat64Average number of household contacts per timestep (Poisson-distributed)
school_contact_rateFloat64Average number of school contacts per timestep (Poisson-distributed)
school_class_contact_rateFloat64Average number of school-class contacts per timestep (Poisson-distributed)
school_year_contact_rateFloat64Average number of school-year contacts per timestep (Poisson-distributed)
school_complex_contact_rateFloat64Average number of school-complex contacts per timestep (Poisson-distributed)
workplace_site_contact_rateFloat64Average number of workplace-site contacts per timestep (Poisson-distributed)
workplace_contact_rateFloat64Average number of workplace contacts per timestep (Poisson-distributed)
department_contact_rateFloat64Average number of department contacts per timestep (Poisson-distributed)
municipality_contact_rateFloat64Average number of municipality contacts per timestep (Poisson-distributed)
global_contact_rateFloat64Average number of contacts in the global per timestep (Poisson-distributed)
Population Parameters
pop_sizeInt64Number of individuals in the population
avg_household_sizeInt64Average size of households
avg_office_sizeInt64Average size of offices
avg_school_sizeInt64Average size of schools
GEMS.SimulationMethod
Simulation(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.SimulationMethod
Simulation(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_strategy!Function
add_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_testtype!Function
add_testtype!(simulation, testtype)

Adds a test type to the simulation.

GEMS.add_tick_trigger!Function
add_tick_trigger!(simulation, trigger)

Adds a TickTrigger to the simulation.

GEMS.agsMethod
ags(patientZeros)

Returns the vector of ags where intial seeds should be planted.

GEMS.configfileMethod
configfile(simulation)

Returns configfile that was used to initialize simulation.

GEMS.customlogger!Method
customlogger!(simulation, customlogger)

Sets the Simulation's CustomLogger.

GEMS.customloggerMethod
customlogger(simulation)

Returns the CustomLogger of the simulation.

GEMS.customlogsFunction
customlogs(simulation::Simulation)

Calls the dataframe() function on the internal simulation's CustomLogger.

GEMS.deathsMethod
deaths(simulation::Simulation)

Calls the dataframe() function on the internal simulation's DeathLogger.

GEMS.deathloggerMethod
deathlogger(simulation)

Returns the DeathLogger of the simulation.

GEMS.evaluateFunction
evaluate(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_queueMethod
event_queue(simulation)

Returns the simulation's intervention event queue.

GEMS.fire_custom_loggers!Method
fire_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.fractionMethod
fraction(infectedFraction)

Returns fraction of individuals that shall be infected at the beginning in this start condition.

GEMS.hospitalization_triggersMethod
hospitalization_triggers(simulation)

Returns the list of HospitalizationTriggers registered in the simulation.

GEMS.incidenceFunction
incidence(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 object
  • pathogen::Pathogen: Pathogen for which the incidence shall be calculated
  • base_size::Int = 100_000 (optional): Reference popuation size for incidence calculation
  • duration::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 object
  • base_size::Int = 100_000 (optional): Reference popuation size for incidence calculation
  • duration::Int16 = Int16(7) (optional): Reference duration (in ticks) for the incidence calculation

Returns

  • Float64: Incidence
GEMS.increment!Method
increment!(simulation)

Increments the current simulation's tick counter by 1.

GEMS.infectionsMethod
infections(simulation::Simulation)

Calls the dataframe() function on the internal simulation's InfectionLogger.

GEMS.infoMethod
info(sim::Simulation)

Summary output for Simulation object configuration.

GEMS.intervalFunction
interval(trigger::TickTrigger)

Returns the interval associated with a TickTrigger.

GEMS.labelMethod
label(simulation::Simulation)

Returns simulation object's string label.

GEMS.limitFunction
limit(timesUp)

Returns time limit of a timesUp stop criterion.

GEMS.parametersFunction
parameters(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!Method
pathogen!(simulation, pathogen)

Sets the pathogen of the simulation.

GEMS.pathogenFunction
pathogen(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.pooltestsFunction
pooltests(simulation::Simulation)

Calls the dataframe() function on the internal simulation's PoolTestLogger.

GEMS.pooltestloggerFunction
pooltestlogger(simulation)

Returns the PoolTestLogger of the simulation.

GEMS.populationMethod
population(simulation)

Returns the population associated with the simulation run.

GEMS.populationDFMethod
populationDF(simulation::Simulation)

Calls the dataframe() function on the simulation's Population object.

GEMS.populationfileMethod
populationfile(simulation)

Returns populationfile that was used to initialize simulation.

GEMS.quarantineloggerMethod
quarantinelogger(simulation)

Returns the QuarantineLogger of the simulation.

GEMS.quarantinesFunction
quarantines(simulation::Simulation)

Calls the dataframe() function on the internal simulation's QuarantineLogger.

GEMS.remove_empty_settings!Method
remove_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!Method
reset!(simulation)

Resets the current simulation's tick counter to 0.

GEMS.region_infoMethod
region_info(sim::Simulation)

Returns a DataFrame containing information about the Municipalitys in the model with the following columns:

NameTypeDescription
agsAGSAmtlicher Gemeindeschlüssel (Community Identification Code)
pop_sizeInt64Number of individuals in that municipality
areaFloat64Area 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!Method
run!(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.settingsMethod
settings(simulation::Simulation)

Returns a dictionary containing all settings, separated by setting type (key).

GEMS.settingsMethod
settings(simulation::Simulation, settingtype::DataType)

Returns all settings of settingtype of the simulation.

GEMS.should_fireFunction
should_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_conditionFunction
start_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!Function
step!(simulation::Simulation)

Increments the simulation status by one tick and executes all events that shall be handled during this tick.

GEMS.stepmodFunction
stepmod(simulation::Simulation)

Returns the defined step mod.

GEMS.stop_criterionMethod
stop_criterion(simulation)

Returns stop criterion associated with the simulation run.

GEMS.strategiesMethod
strategy(simulation)

Returns the intervention Strategys registered in the simulation.

GEMS.symptom_triggersMethod
symptom_triggers(simulation)

Returns the list of SymptomTriggers registered in the simulation.

GEMS.testloggerMethod
testlogger(simulation)

Returns the TestLogger of the simulation.

GEMS.testsMethod
tests(simulation::Simulation)

Calls the dataframe() function on the internal simulation's TestLogger.

GEMS.testtypesMethod
testtypes(simulation)

Returns the test types registered in the simulation.

GEMS.tickMethod
tick(simulation)

Returns current tick of the simulation run.

GEMS.tick_triggersMethod
tick_triggers(simulation)

Returns the list of TickTriggers registered in the simulation.

GEMS.tickunitMethod
tickunit(simulation)

Returns the unit of the ticks as a char like in date formats, i.e. 'd' means days, 'h' mean hours, etc.