Settings

Overview Structs

Overview Functions

Structs

GEMS.DepartmentType
Department <: ContainerSetting

Represents a department within a workplace in the simulation.

Instantiation

The instantiation requires at least an id that be supplied as a keyword argument. All other fields are optional parameters.

d1 = Department(id = 1)
d2 = Department(id = 2, contains = [13, 14, 15]) # contains IDs of Offices

Parameters

  • id::Int32: Unique identifier of the department.
  • contains::Vector{Int32} = [] (optional): List of associated Offices
  • contains_type::DataType = Office (optional): Type of contained settings (Office)
  • contained::Int32 = DEFAULT_SETTING_ID (optional): Parent setting id (Workplace)
  • contained_type::DataType = Workplace (optional): Parent setting type (Workplace)
  • type::Int32 = -1 (optional): Numerical code representing the type of department.
  • last_infectious::Int16 = -1 (optional): The last simulation tick when an infectious individual was present.
  • contact_sampling_method::ContactSamplingMethod = RandomSampling() (optional): Sampling Method, defining how contacts are drawn.
  • isactive::Bool = false (optional): Whether the department is active in the simulation.
  • isopen::Bool = true (optional): Whether the setting is open for contacts.
GEMS.GlobalSettingType
GlobalSetting <: IndividualSetting

A type to a setting that contains all individuals at once (mainly for testing purposes). With this type, each individual can theoretically connect with any other individual.

There should only be one GlobalSetting instance in any simulation.

Fields

  • individuals::Vector{Individual}: List of associated individuals
  • contact_sampling_method::ContactSamplingMethod: Sampling Method, defining how contacts are drawn.
  • isactive::Bool: A flag to represent if the setting is considered active for simulation
  • isopen::Bool: Whether the setting is open for contacts.
  • lock::ReentrantLock: A lock to use in a parallelized setting to ensure data race free conditions
GEMS.HouseholdType
Household <: Geolocated

A type to represent households with associated individuals as members.

Instantiation

The instantiation requires at least an id that be supplied as a keyword argument. All other fields are optional parameters.

h1 = Household(id = 1)
h2 = Household(id = 2, individuals = [i1, i2, i3])

Parameters

  • id::Int32: Unique identifier of the household
  • individuals::Vector{Individual} = [] (optional): List of associated individuals
  • income::Int8 = -1 (optional): Category of income for the household
  • dwelling::Int8 = -1 *(optional)*: Category of dwelliung size
  • last_infectious::Int16 = -1 (optional): Tick indicating the last presence of an infected individual
  • contact_sampling_method::ContactSamplingMethod = RandomSampling() (optional): Sampling Method, defining how contacts are drawn.
  • ags::AGS = AGS() (optional): The Amtlicher Gemeindeschlüssel (AGS) of the Household.
  • lon::Float32 = NaN (optional): Longitude of the household
  • lat::Float32 = NaN: Latitude of the household
  • isactive::Bool = false (optional): A flag to represent if the setting is considered active for simulation
  • isopen::Bool = true (optional): Whether the setting is open for contacts.
GEMS.MunicipalityType
Municipality <: IndividualSetting

A type to represent (geographical) municipalities.

Instantiation

The instantiation requires at least an id that be supplied as a keyword argument. All other fields are optional parameters.

m1 = Municipality(id = 1)
m2 = Municipality(id = 2, individuals = [i1, i2, i3])

Parameters

  • id::Int32: Unique identifier of the municipality
  • individuals::Vector{Individual} = [] (optional): List of associated individuals
  • contact_sampling_method::ContactSamplingMethod = RandomSampling() (optional): Sampling Method, defining how contacts are drawn.
  • ags::AGS = AGS() (optional): The Amtlicher Gemeindeschlüssel (AGS) of the municipality.
  • isactive::Bool = false (optional): A flag to represent if the setting is considered active for simulation
  • isopen::Bool = true (optional): Whether the setting is open for contacts.
GEMS.OfficeType
Office <: Geolocated

Represents an office within a department in the simulation.

Instantiation

The instantiation requires at least an id that be supplied as a keyword argument. All other fields are optional parameters.

o1 = Office(id = 1)
o2 = Office(id = 2, individuals = [i1, i2, i3])

Parameters

  • id::Int32: Unique identifier of the office.
  • individuals::Vector{Individual} = [] (optional): List of individuals associated with this office
  • contained::Int32 = DEFAULT_SETTING_ID (optional): Parent setting id (Department)
  • contained_type::DataType = Department (optional): Parent setting tye (Department)
  • type::Int32 = -1 (optional): Numerical code representing the type of office
  • last_infectious::Int16 = -1 (optional): The last simulation tick when an infectious individual was present
  • contact_sampling_method::ContactSamplingMethod = RandomSampling() (optional): Sampling Method, defining how contacts are drawn
  • ags::AGS = AGS() (optional): The Amtlicher Gemeindeschlüssel (AGS) of the office
  • inroom::Int8 = -1 (optional): Describes the amount of indoor work done in the office
  • workhome::Int8 = -1 (optional): Describes the amount of work done from home
  • lon::Float32 = NaN (optional): Longitude of the office
  • lat::Float32 = NaN (optional): Latitude of the office
  • isactive::Bool = false (optional): Whether the office is active in the simulation
  • isopen::Bool = true (optional): Whether the setting is open for contacts
GEMS.SchoolType
School <: ContainerSetting

A type to represent a school (which has years and classes).

Instantiation

The instantiation requires at least an id that be supplied as a keyword argument. All other fields are optional parameters.

s1 = School(id = 1)
s2 = School(id = 2, contains = [13, 14, 15]) # contains IDs of school years

Parameters

  • id::Int32: Unique identifier of the school
  • contains::Vector{Int32} = [] (optional): List of associated SchoolYearss
  • contains_type::DataType = SchoolYear (optional): Type of contained settings (SchoolYear)
  • contained::Int32 = DEFAULT_SETTING_ID (optional): Parent setting id (SchoolComplex)
  • contained_type::DataType = School (optional): Parent setting tye (SchoolComplex)
  • type::Int32 = -1 (optional): Type of school (e.g. primary, highschool, ...)
  • contact_sampling_method::ContactSamplingMethod = RandomSampling() (optional): Sampling Method, defining how contacts are drawn.
  • isactive::Bool = false (optional): A flag to represent if the setting is considered active for simulation
  • isopen::Bool = true (optional): Whether the setting is open for contacts.
GEMS.SchoolClassType
SchoolClass <: Geolocated

A type to represent school classes. Should always be part of a school.

Instantiation

The instantiation requires at least an id that be supplied as a keyword argument. All other fields are optional parameters.

c1 = SchoolClass(id = 1)
c2 = SchoolClass(id = 2, individuals = [i1, i2, i3])

Parameters

  • id::Int32: Unique identifier of the school class
  • individuals::Vector{Individual} = [] (optional): List of associated individuals
  • type::Int32 = -1 (optional): Type of school class (e.g. grade)
  • contained::Int32 = DEFAULT_SETTING_ID (optional): Parent setting id (SchoolYear)
  • contained_type::DataType = SchoolYear (optional): Parent setting tye (SchoolYear)
  • last_infectious::Int16 = -1 (optional): Tick indicating the last presence of an infected individual
  • contact_sampling_method::ContactSamplingMethod = RandomSampling() (optional): Sampling Method, defining how contacts are drawn.
  • ags::Int32 = AGS() (optional): The Amtlicher Gemeindeschlüssel (AGS) of the schoolclass.
  • lon::Float32 = NaN (optional): Longitude of the schoolclass
  • lat::Float32 = NaN (optional): Latitude of the schoolclass
  • isactive::Bool = false (optional): A flag to represent if the setting is considered active for simulation
  • isopen::Bool = true (optional): Whether the setting is open for contacts.
GEMS.SchoolComplexType
SchoolComplex <: ContainerSetting

A type to represent a school complex (which has schools).

Instantiation

The instantiation requires at least an id that be supplied as a keyword argument. All other fields are optional parameters.

sc1 = SchoolComplex(id = 1)
sc2 = SchoolComplex(id = 2, contains = [13, 14, 15]) # contains IDs of schools

Parameters

  • id::Int32: Unique identifier of the school complex
  • contains::Vector{Int32} = [] (optional): List of associated Schools
  • contains_type::DataType = SchoolYear (optional): Type of contained settings (School)
  • contact_sampling_method::ContactSamplingMethod = RandomSampling() (optional): Sampling Method, defining how contacts are drawn.
  • isactive::Bool = false (optional): A flag to represent if the setting is considered active for simulation
  • isopen::Bool = true (optional): Whether the setting is open for contacts.
GEMS.SchoolYearType
SchoolYear <: ContainerSetting

A type to represent a schoolyear (which has classes).

Instantiation

The instantiation requires at least an id that be supplied as a keyword argument. All other fields are optional parameters.

y1 = SchoolYear(id = 1)
y2 = SchoolYear(id = 2, contains = [13, 14, 15]) # contains IDs of school classes

Parameters

  • id::Int32: Unique identifier of the schoolyear
  • contains::Vector{Int32} = [] (optional): List of associated SchoolClasses
  • contains_type::DataType = SchoolClass (optional): Type of contained settings (SchoolClass)
  • contained::Int32 = DEFAULT_SETTING_ID (optional): Parent setting id (School)
  • contained_type::DataType = School (optional): Parent setting tye (School)
  • type::Int32 = -1 (optional): Type of school year (e.g. grade)
  • contact_sampling_method::ContactSamplingMethod = RandomSampling() (optional): Sampling Method, defining how contacts are drawn.
  • isactive::Bool = false (optional): A flag to represent if the setting is considered active for simulation
  • isopen::Bool = true (optional): Whether the setting is open for contacts.
GEMS.SettingsContainerType
SettingsContainer

A container structure for all settings.

Fields

  • settings::Dict{DataType, Vector{Setting}}: A dictionary holding all known settings structured by type
GEMS.WorkplaceType
Workplace <: ContainerSetting

Represents a workplace in the simulation.

Instantiation

The instantiation requires at least an id that be supplied as a keyword argument. All other fields are optional parameters.

ws1 = Workplace(id = 1)
ws2 = Workplace(id = 2, contains = [13, 14, 15]) # contains IDs of Departments

Parameters

  • id::Int32: Unique identifier of the workplace.
  • contains::Vector{Int32} = [] (optional): List of associated Departments
  • contains_type::DataType = Department (optional): Type of contained settings (Department)
  • contained::Int32 = DEFAULT_SETTING_ID (optional): Parent setting id (WorkplaceSite)
  • contained_type::DataType = WorkplaceSite (optional): Parent setting type (WorkplaceSite)
  • type::Int32 = -1 (optional): Numerical code representing the type of workplace (e.g., farm, office).
  • last_infectious::Int16 -1 (optional): The last simulation tick when an infectious individual was present.
  • contact_sampling_method::ContactSamplingMethod = RandomSampling() (optional): Sampling Method, defining how contacts are drawn.
  • isactive::Bool = false (optional): Whether the workplace is active in the simulation.
  • isopen::Bool = true (optional): Whether the setting is open for contacts.
GEMS.WorkplaceSiteType
WorkplaceSite <: ContainerSetting

Represents a Workplace site in the simulation.

Instantiation

The instantiation requires at least an id that be supplied as a keyword argument. All other fields are optional parameters.

ws1 = WorkplaceSite(id = 1)
ws2 = WorkplaceSite(id = 2, contains = [13, 14, 15]) # contains IDs of Workplaces

Parameters

  • id::Int32: Unique identifier of the workplace.
  • contains::Vector{Int32} = [] (optional): List of associated Workplaces
  • contains_type::DataType = Workplace (optional): Type of contained settings (Workplace)
  • type::Int32 = -1 (optional): Numerical code representing the type of workplace site.
  • last_infectious::Int16 = -1 (optional): The last simulation tick when an infectious individual was present.
  • contact_sampling_method::ContactSamplingMethod = RandomSampling() (optional): Sampling Method, defining how contacts are drawn.
  • isactive::Bool = false (optional): Whether the workplace is active in the simulation.
  • isopen::Bool = true (optional): Whether the setting is open for contacts.

Functions

GEMS.activate!Function
activate!(setting::Setting)

Sets the setting active for simulation.

GEMS.add!Method
add!(setting::Setting, individual::Individual)

Adds the given individual to the setting.

GEMS.add!Method
add!(container::SettingsContainer, setting::Setting)

Add a setting to the container.

GEMS.add_type!Function
add_type!(container::SettingsContainer, settingtype::Type)

Add a settingtype to the container if it is not yet included. Creates a new vector for the provided type in the settings dictionary.

add_type!(container::SettingsContainer, settingtype::DataType)

Add a settingtype to the container if it is not yet included. Creates a new vector for the provided type in the settings dictionary.

GEMS.add_types!Function
add_types!(container::SettingsContainer, settingtypes::Vector{Type})

Adds settingtypes to the container if they are not yet included. Calls the add_type! function for each settingtype in the vector.

add_types!(container::SettingsContainer, settingtypes::Vector{DataType})

Adds settingtypes to the container if they are not yet included. Calls the add_type! function for each settingtype in the vector.

GEMS.agsMethod
ags(stng::ContainerSetting, sim::Simulation)

Get the ags of a ContainerSetting.

GEMS.agsMethod
ags(stng::IndividualSetting, sim::Simulation)

Get the ags of a IndividualSetting.

GEMS.agsMethod
ags(stng::IndividualSetting)

Get the ags of a IndividualSetting.

GEMS.avg_individualsFunction
avg_individuals(stngs::Vector{Setting}, simulation::Simulation)

Returns the average number of individuals across all provided settings.

GEMS.close!Function
close!(setting::Setting)

Closes the setting.

close!(setting::Setting, simulation::Simulation)

Sets the setting and all settings contained by it as closed (not open).

GEMS.contact_sampling_method!Function
contact_sampling_method(setting::Setting, csm::ContactSamplingMethod)

Sets the ContactSamplingMethod of this setting to the provided method.

GEMS.containedMethod
contained(setting::Setting)

Returns the contained value of the given Setting.

GEMS.contained_typeMethod
contained_type(setting::Setting)

Returns the contained_type value of the given Setting.

GEMS.contains_typeMethod
contains_type(setting::ContainerSetting)

Returns the contains_type value of the given ContainerSetting.

GEMS.deactivate!Method
deactivate!(setting::Setting)

Sets the setting as inactive for simulation.

GEMS.delete_dangling_ids!Method
delete_dangling_ids!(cntnr::SettingsContainer)

Sets all dangling IDs, i.e., IDs that do not point to any setting, to the default setting ID.

GEMS.geolocationFunction
geolocation(stng::ContainerSetting, sim::Simulation)

Get the location of a ContainerSetting by getting the location of the first contained setting.

geolocation(stng::IndividualSetting, sim::Simulation)

Get the location of a IndividualSetting. Fallback for non geolocated settings.

geolocation(stng::IndividualSetting)

Get the location of a IndividualSetting. Fallback for non geolocated settings.

geolocation(stng::IndividualSetting, sim::Simulation)

Get the location of a IndividualSetting.

geolocation(stng::IndividualSetting)

Get the location of a IndividualSetting.

GEMS.get_contained!Function
get_contained!(stng::Setting, dct::Dict{DataType, Vector{Int32}}, sim::Simulation)

Recursively gets the contained settings of the setting stng and adds them to the dictionary dct.

Parameters

  • stng::ContainerSetting: Setting that may contain more settings on lower levels
  • dct::Dict{DataType, Vector{Int32}}: Dictionary that will be filed with the found settings
  • sim::Simulation: Simulation object
get_contained!(stng::IndividualSetting, dct::Dict, sim::Simulation)

Gets the contained settings of an IndividualSetting, i.e., none.

Parameters

  • stng::IndividualSetting: Lowest-level setting
  • dct::Dict{DataType, Vector{Int32}}: Dictionary that will be filed with the found settings
  • sim::Simulation: Simulation object
GEMS.get_containers!Function
get_containers!(stng::Setting, dct::Dict{DataType, Int32}, sim::Simulation)

Recursively gets the containers of the setting stng and adds them to the dictionary dct.

Parameters

  • stng::Setting: Setting to get upper-level settings for
  • dct::Dict{DataType, Vector{Int32}}: Dictionary that will be filed with the found settings
  • sim::Simulation: Simulation object
GEMS.get_open_contained!Function
get_open_contained!(stng::ContainerSetting, dct::Dict{DataType, Vector{Int32}}, sim::Simulation)

Recursively gets the contained settings of the setting stng and adds them to the dictionary dct if the containing setting is open.

Parameters

  • stng::ContainerSetting: Setting that may contain more settings on lower levels
  • dct::Dict{DataType, Vector{Int32}}: Dictionary that will be filed with the found settings
  • sim::Simulation: Simulation object
get_open_contained!(stng::IndividualSetting, dct::Dict{DataType, Vector{Int32}}, sim::Simulation)

Adds the individualsetting to the provided dictionary if it is open.

Parameters

  • stng::IndividualSetting: Lowest-level setting
  • dct::Dict{DataType, Vector{Int32}}: Dictionary that will be filed with the found settings
  • sim::Simulation: Simulation object
GEMS.householdMethod
household(i::Individual, sim::Simulation)::Household

Returns the Household instance referenced in an individual.

GEMS.idMethod
id(setting::Setting)

Returns the unique identifier of the setting.

GEMS.individuals!Function
individuals!(setting::IndividualSetting, indivs::Vector{Individual}, simulation::Simulation)

Appends the individuals associated with a given IndividualSetting to the provided indivs vector.

Parameters

  • setting::IndividualSetting: Setting to get the individuals from
  • indivs::Vector{Individual}: List that will be appeneded with the setting's individuals
  • simulation::Simulation: Simulation object
individuals!(setting::ContainerSetting, indivs::Vector{Individual}, simulation::Simulation)

Appends the individuals associated with a given ContainerSetting to the provided indivs vector by recursively calling the individuals! function.

Parameters

  • setting::ContainerSetting: Setting to get the individuals from
  • indivs::Vector{Individual}: List that will be appeneded with the setting's individuals
  • simulation::Simulation: Simulation object
GEMS.individualsMethod
individuals(setting::IndividualSetting)

Returns the individuals associated with the given setting.

GEMS.individualsMethod
individuals(setting::IndividualSetting, simulation::Simulation)

Returns the individuals associated with a given IndividualSetting.

GEMS.individualsMethod
individuals(setting::ContainerSetting, indivs::Vector{Individual}, simulation::Simulation)::Vector{Individual}

Returns the individuals associated with a given ContainerSetting by recursively getting the individuals of all contained settings using the individuals! function.

GEMS.is_openMethod
isopen(setting::Setting)

Returns wether the setting is opened (contacts can occur) or not. Without considering its containers.

GEMS.isactiveMethod
isactive(setting::Setting)

Returns whether the setting is considered active for simulation, e.g. an infection could spread in the setting.

GEMS.latMethod
lat(stng::Geolocated)

Returns latitude of geolocated setting.

GEMS.lonMethod
lon(stng::Geolocated)

Returns longitude of geolocated setting.

GEMS.max_individualsMethod
max_individuals(stngs::Vector{Setting}, simulation::Simulation)

Returns the maximum number of individuals across all provided settings.

GEMS.min_individualsMethod
min_individuals(stngs::Vector{Setting}, simulation::Simulation)

Returns the minimum number of individuals across all provided settings.

GEMS.min_max_avg_individualsMethod
min_max_avg_individuals(stngs::Vector{Setting}, simulation::Simulation)

Returns a three-way tuple with (minimum, maximum, mean) number of individuals associated with a setting in the provided stngs vector.

GEMS.new_setting_ids!Method
new_setting_ids!(cntnr::SettingsContainer, renaming_dict::Dict = Dict())

This function checks and updates the ids of settings in a SettingsContainer object to ensure that they are continuous and start from 1. If the ids are not continuous or do not start from 1, the function will generate a warning and update the ids accordingly. This is then also used to update the contained and contains fields of the settings.

Arguments

  • cntnr::SettingsContainer: The SettingsContainer object containing the settings.
GEMS.open!Function
open!(setting::Setting)

Opens the setting.

open!(setting::Setting, simulation::Simulation)

Sets the setting and all settings contained by it as open.

GEMS.present_individualsFunction
present_individuals(setting::IndividualSetting, simulation::Simulation)

Returns the individuals present in a given IndividualSetting, i.e., only those in open settings.

present_individuals(setting::ContainerSetting, simulation::Simulation)

Returns the individuals present in a given ContainerSetting, i.e., only those in open contained settings.

GEMS.present_individuals!Function
present_individuals!(setting::IndividualSetting, indivs::Vector{Individual}, simulation::Simulation)

Pushes the individuals present in a given IndividualSetting, i.e., only those in open settings to the provided indivs vector.

Parameters

  • setting::IndividualSetting: Setting to get the individuals from
  • indivs::Vector{Individual}: List that will be appeneded with the setting's individuals
  • simulation::Simulation: Simulation object
present_individuals!(setting::ContainerSetting, indivs::Vector{Individual}, simulation::Simulation)

Pushes the individuals present in a given ContainerSetting, i.e., only those in open contained settings to the provided indivs vector.

Parameters

  • setting::ContainerSetting: Setting to get the individuals from
  • indivs::Vector{Individual}: List that will be appeneded with the setting's individuals
  • simulation::Simulation: Simulation object
GEMS.schoolclassMethod
schoolclass(i::Individual, sim::Simulation)::SchoolClass

Returns the SchoolClass instance referenced in an individual.

GEMS.sample_individualsFunction
sample_individuals(individuals::Vector{Individual}, n::Int64)

Returns a subsample of a vector of Individuals of sample size n.

sample_individuals(setting::IndividualSetting, n::Int64)

Returns a subsample of the setting's Individuals of sample size n.

GEMS.settingMethod
setting(container::SettingsContainer, type::DataType, id::Int32)

Returns a particular setting of a particular type and ID.

GEMS.settingcharMethod
settingchar(setting::Setting)

Returns a character that represents the type of setting.

GEMS.settingsMethod
settings(container::SettingsContainer)

Returns a dictionary with all concrete setting types as keys and vectors of all known settings as values.

GEMS.settingsMethod
settings(container::SettingsContainer, type::DataType)

Returns a vector of all known settings with provided type.

GEMS.settings_from_jld2!Method
settings_from_jld2!(jld2file::String, cntnr::SettingsContainer, d::Dict= Dict())

Loads the settings saved in jld2file and add them to the existing SettingsContainer. The renaming dictionary is used to find the correct updated values of the ids of the IndividualSettings and change the values in the containers accordingly. If the jld2file does not correspond to "" (corresponding to no settingfile) and does not exist, an error message is printed.

GEMS.settings_from_populationMethod
settings_from_population(population::Population, global_setting::Bool = false)

Creates all settings defined by the attributes of the individuals inside a given population. Return a dictionary with all known concrete setting types as keys and a vector of created settings.

GEMS.settingstringMethod
settingstring(c::Char)

Returns a string that represents the type of setting based on a char that is returned from the function settingchar.

GEMS.settingtypesFunction
settingtypes(container::SettingsContainer)

Returns all known setting types of the provided container.