Interventions

Overview Structs

Overview Functions

Triggers

Structs

GEMS.HospitalizationTriggerType
HospitalizationTrigger <: ITrigger

A struct defining an IStrategy that shall be fired upon an individual's admittance to hospital.

GEMS.ITickTriggerType
ITickTrigger <: TickTrigger

A struct defining an IStrategy with timed execution for all individuals in the model. The switch_tick sets a threshold for the onset of strategy execution based on the current tick. The interval defines a reoccurence (optional). If no switch_tick is given, the strategy will be fired in each tick. If only the interval is given, the strategy will be fired from tick 1 onwards in the specified interval.

Parameters

  • strategy::IStrategy: Strategy that will be triggered
  • switch_tick::Int16 = Int16(-1) (optional): Threshold for the strategy onset
  • interval::Int16 = Int16(-1) (optional): Trigger strategy in reoccuring intervals

Examples

ITickTrigger(my_daily_testing_strategy)

will trigger my_daily_testing_strategy each tick for each individuals.

ITickTrigger(my_home_office_strategy, switch_tick = Int16(20), interval = Int16(7))

will trigger my_home_office_strategy from tick 20 in a 7-tick interval for each individuals.

ITickTrigger(my_lockdown_strategy, switch_tick = Int16(50)

will trigger the my_lockdown_strategy once on tick 50.

GEMS.STickTriggerType
STickTrigger <: TickTrigger

A struct defining an SStrategy with timed execution for all settings of a specified settingtype in the model. The switch_tick sets a threshold for the onset of strategy execution based on the current tick. The interval defines a reoccurence (optional). If no switch_tick is given, the strategy will be fired in each tick. If only the interval is given, the strategy will be fired from tick 1 onwards in the specified interval.

Parameters

  • settingtype::DataType: Type of settings (e.g. Household) that the triggered strategy will be applied to
  • strategy::SStrategy: Strategy that will be triggered
  • switch_tick::Int16 = Int16(-1) (optional): Threshold for the strategy onset
  • interval::Int16 = Int16(-1) (optional): Trigger strategy in reoccuring intervals

Examples

STickTrigger(School, my_daily_testing_strategy)

will trigger my_daily_testing_strategy each tick for each school.

STickTrigger(Office, my_pool_testing_strategy, switch_tick = Int16(20), interval = Int16(7))

will trigger my_pool_testing_strategy from tick 20 in a 7-tick interval for each office.

STickTrigger(School, my_schhool_closure_strategy, switch_tick = Int16(50)

will trigger the my_schhool_closure_strategy once on tick 50 for all schools.

GEMS.SymptomTriggerType
SymptomTrigger <: ITrigger

A struct defining an IStrategy that shall be fired upon an individual experiencing symptoms.

Functions

GEMS.strategyFunction
strategy(trigger::SymptomTrigger)

Returns the IStrategy object associated with a SymptomTrigger.

strategy(trigger::HospitalizationTrigger)

Returns the IStrategy object associated with a HospitalizationTrigger.

strategy(trigger::TickTrigger)

Returns the intervention strategy associated with a TickTrigger.

GEMS.switch_tickFunction
switch_tick(trigger::TickTrigger)

Returns the switch_tick associated with a TickTrigger.

Strategies

Constructors

GEMS.IStrategyMethod
IStrategy(name::String, sim::Simulation; condition::Function = x -> true)

Creates an IStrategy object.

Parameters

  • name::String: Name of the strategy
  • sim::Simulation: Simulation object (required to interlink test with simulation)
  • condition::Function = x -> true (optional): Predicate function than can be used to limit the execution of this strategy to only cerain individuals.

Examples

my_str = IStrategy("self-isolation", sim)
add_measure!(my_str, SelfIsolation(14))

s_trigger = SymptomTrigger(my_str)
add_symptom_trigger!(sim, s_trigger) 

The above code will create a new strategy called, 'self-isolation'. Using the add_measure! function, you can now begin to populate your strategy with specific intervention measures, e.g. with a SelfIsolation measure. The second part creates a SymptomTrigger that will now fire your strategy once an individual experiences symptoms.

If you want to limit the execution of your strategy to only certain individuals e.g. based on their age, you can do that be adding a condition predicate function, such as:

my_str = IStrategy("self-isolation", sim, condition = i -> age(i) > 65)
add_measure!(my_str, SelfIsolation(14))

s_trigger = SymptomTrigger(my_str)
add_symptom_trigger!(sim, s_trigger) 

The added condition will cause the strategy only to be executed for individuals who experience symptoms and are 65 or older.

GEMS.SStrategyMethod
SStrategy(name::String, sim::Simulation; condition::Function = x -> true)

Creates an SStrategy object.

Parameters

  • name::String: Name of the strategy
  • sim::Simulation: Simulation object (required to interlink test with simulation)
  • condition::Function = x -> true (optional): Predicate function than can be used to limit the execution of this strategy to only cerain settings.

Examples

my_str = SStrategy("close-offices", sim)
add_measure!(my_str, CloseSetting())

t_trigger = STickTrigger(Office, my_str, switch_tick = Int16(20))
add_tick_trigger!(sim, t_trigger)

The above code will create a new strategy called, 'close-offices'. Using the add_measure! function, you can now begin to populate your strategy with specific intervention measures, e.g. with a CloseSetting measure. The second part creates a STickTrigger for the setting type Office and the switch_tick 20. Therefore, this trigger will call your strategy for all settings of type Office at tick 20, closing them indefinitely.

If you want to limit the execution of your strategy to only certain settings e.g. based on their size, you can do that be adding a condition predicate function, such as:

my_str = SStrategy("close-offices", sim, condition = s -> size(s) > 10)
add_measure!(my_str, CloseSetting())

t_trigger = STickTrigger(Office, my_str, switch_tick = Int16(20))
add_tick_trigger!(sim, t_trigger)

The added condition will cause the strategy only to be executed for settings that have more than 10 individuals associated.

GEMS.MeasureEntryType
MeasureEntry{T <: Measure}

This struct represents a tuple of an intervention-measure, an integer-offset, a delay-function and a condition. It is the internal data structure for Strategies.

Functions

GEMS.add_measure!Function
add_measure!(str::Strategy, measure::Measure; offset::Int64 = 0, delay::Function = x -> 0, condition::Function = x -> true)

Adds IMeasures to IStrategys and SMeasures to SStrategys.

Parameters:

  • str::Strategy: Strategy that the measure will be added to
  • measure::Measure: Measure that will be added to te strategy
  • offset::Int64 = 0 (optional): The number of ticks between the time the measure was triggered and the time the measure will be executed.
  • delay::Function = x -> 0 (optional): Single-argument function that must resolve to an integer. The delay will extend the offset.
  • condition::Function = x -> true (optional): Predicate function conditioning the exeuction of a measure.

Examples

my_str = IStrategy("self-isolation", sim)
add_measure!(my_str, SelfIsolation(14), offset = 2)

s_trigger = SymptomTrigger(my_str)
add_symptom_trigger!(sim, s_trigger) 

The above code shows how a SelfIsolation measure, putting an individual in self-isolation for 14 days, is added to a custom IStrategy. The strategy is triggered once an individual experiences symptoms (SymptomTrigger). The offset argument, however, specifies that it takes another two ticks before the individual is put into self-isolation.

my_str = IStrategy("self-isolation", sim)
add_measure!(my_str, SelfIsolation(14), delay = i -> age(i) > 65 ? 2 : 0)

This example starts the self-isolation measure with a delay of two ticks if the individual is above 65 and otherwise immediately.

my_str = IStrategy("self-isolation", sim)
add_measure!(my_str, SelfIsolation(14), condition = i -> age(i) > 65)

This example only lets individuals go into self-isolation who are 65 and above. All these optional arguments and predicate functions can be combined. The calculated delay is added to the offset (if specified).

GEMS.conditionFunction
condition(me::MeasureEntry)

Returns the condition function associated with a MeasureEntry.

condition(str::Strategy)

Returns the condition function of a Strategy.

GEMS.delayMethod
delay(me::MeasureEntry)

Returns the delay function associated with a MeasureEntry.

GEMS.measureMethod
measure(me::MeasureEntry)

Returns the measure associated with a MeasureEntry.

GEMS.measuresMethod
measures(str::Strategy)

Returns the measures encapsulated in a Strategy; A vector of MeasureEntrys

GEMS.nameMethod
name(str::Strategy)

Returns the name of a Strategy.

GEMS.offsetMethod
offset(me::MeasureEntry)

Returns the offset associated with a MeasureEntry.

Measures

Constructors

GEMS.CancelSelfIsolationType
CancelSelfIsolation <: IMeasure

Intervention struct to cancel an individual's (household isolation).

Example

my_str = IStrategy("cancel-isolation", sim)
add_measure!(my_str, CancelSelfIsolaton())

The above example creates an IStrategy called 'my_str' and adds an instance of the CancelSelfIsolation measure to the strategy.

GEMS.ChangeContactMethodType
ChangeContactMethod <: SMeasure

Intervention struct to replace a setting's contact sampling method. Needs to be initialized with an argument of type ContactSamplingMethod.

Example

    my_str = SStrategy("reduce-contacts", sim)
    add_measure!(my_str, ChangeContactMethod(ContactparameterSampling(1)))

The above example creates an SStrategy called 'my_str' and adds an instance of the ChangeContactMethod measure that should change the contact sampling method to a ContactparameterSampling method with 1 contact per tick. We call this strategy 'reduce-contacts', of course assuming that the previous contact sampling methdod generated more contacts per tick (which of course depends on your particular initial configuration)

GEMS.CloseSettingType
CloseSetting <: SMeasure

Intervention struct to close a setting, effectively preventing all contacts from happening during closure.

Example

my_str = SStrategy("close-school", sim)
add_measure!(my_str, CloseSetting())

The above example creates an SStrategy called 'my_str' and adds an instance of the CloseSetting measure which will close the respective setting once called. You can, for example, use an STickTrigger to close all schools at a given simulation time. The following code would close all schools at tick 20:

stt = STickTrigger(SchoolClass, my_str, switch_tick = Int16(20))
add_tick_trigger!(sim, stt)
GEMS.CustomIMeasureType
CustomIMeasure <: IMeasure

Intervention struct to apply custom logic to an indivudal when this measure is executed. The field measure_logic must contain a two-argument function where the first argument is an Individual and the second argument is the Simulation struct. Upon execution of the measure, this function will be called with these two arguments.

Example

my_str = IStrategy("change-risk-behavior", sim)
add_measure!(my_str, CustomIMeasure((i, simobj) -> mandate_compliance!(i, .8)))

The above example creates an IStrategy called 'my_str' and adds an instance of the CustomIMeasure measure that is being instantiated with a function changing an individual's mandate_compliance attribute to 80%. This could, for example, be used to model changing risk perceptions over time. While the above example does not require the Simulation object, it is still being passed, to make the whole simulation state available at all times.

GEMS.CustomSMeasureType
CustomSMeasure <: SMeasure

Intervention struct to apply custom logic to a setting when this measure is executed. The field measure_logic must contain a two-argument function where the first argument is a Setting and the second argument is the Simulation struct. Upon execution of the measure, this function will be called with these two arguments.

Example

my_str = SStrategy("close-large-settings", sim)
add_measure!(my_str, CustomSMeasure((s, simobj) -> (size(s) > 50 ? close!(s) : nothing)))

The above example creates an SStrategy called 'my_str' and adds an instance of the CustomSMeasure measure that is being instantiated with a function closing the setting if it contains more than 50 individuals. While the above example does not require the Simulation object, it is still being passed, to make the whole simulation state available at all times. The example above contains conditioned logic to demonstrate how the CustomSMeasure works. You can, of course, achieve the same effect as in the example, if you use a regular CloseSetting measure and limit its execution to large settings by supplying the condition keyword to the add_measure! function.

GEMS.FindMembersType
FindMembers <: SMeasure

Intervention struct to detect individuals that are associated with a setting and apply a follow-up strategy to the respective individuals. This measure effecively allows to switch between SStrategy and IStrategy.

Optional Arguments

  • sample_size::Int64: Limiting the number of individuals to an integer maximum
  • sample_fraction::Float64: Limiting the number of individuals to a fraction of the overall assigned members. Must be between (0-1)
  • selectionfilter::Function: Filters individuals based on their characteristics

Example

isolate_str = IStrategy("self-isolation", sim)
add_measure!(isolate_str, SelfIsolation(14))

my_str = SStrategy("find-coworkers", sim)
add_measure!(my_str, FindMembers(isolate_str))

The above example first creates an individual strategy (IStrategy) called 'isolate_str' and adds an instance of the SelfIsolation measure which will send the respective individual in self-isolation if excuted. It then creates an SStrategy called 'my_str' and adds an instance of the FindMembers measure that detects the setting's members and calls the previously defined 'isolate_str' on all of them. This mechanism can, for example, be used to send all individuals in self-isolation who are associated with a particular office (maybe beause a symptomatic case was detected).

The FindMembers struct can also be used to sample a subset of individuals from a setting. During the COVID-19 pandemic, many restaurants required a negative antigen test in order to serve customers. From a modeling perspective, this is a case where the Test-measure is not triggered by surrounding infection dynamics, but rather randomly. The FindMembers measure can be used to represent these mechanics:

FindMembers(my_follow_up_str, sample_size = 5)

The above measure will always apply the 'my_follow_up_str' to exactly 5 individuals sampled from the setting.

FindMembers(my_follow_up_str, sample_fraction = 0.01)

This measure will apply the 'my_follow_up_str' to 1% of the members in the setting. It can be used to randomly draw individuals, e.g., from a geographic region (Municipality).

FindMembers(my_follow_up_str, selectionfilter = i -> age(i) >= 65)

This measure will apply the 'my_follow_up_str' only to individuals of the setting who are 65 years or older. The filter is always applied before the sample_size or sample_fraction.

GEMS.FindSettingType
FindSetting <: IMeasure

Intervention struct to detect a particular setting of an individual and apply follow-up strategy to the respective setting. This measure effecively allows to switch between IStrategy and SStrategy.

Example

close_str = SStrategy("close-office", sim)
add_measure!(close_str, CloseSetting())

my_str = IStrategy("find-office", sim)
add_measure!(my_str, FindSetting(Office, close_str))

s_trigger = SymptomTrigger(my_str)
add_symptom_trigger!(sim, s_trigger) 

The above example first creates a setting strategy (SStrategy) called 'close_str' and adds an instance of the CloseSetting measure which will close the respective setting indefinitely if excuted. It then creates an IStrategy called 'my_str' and adds an instance of the FindSetting measure that detects the individual's office setting and calls the previously defined 'close_str' on it. Lastly, a SymptomTrigger is defined to run this cascade of strategy once an individual experiences symptoms. The example will close the office an individual is associated with if it experiences symptoms.

GEMS.FindSettingMembersType
FindSettingMembers <: IMeasure

Intervention struct that returns members of a setting which is associated with an index-individual, e.g., 'People I know at work'. It requires a settingtype, defining which of the individual's settings shall be quieried, as well as a follow_up IStrategy that will be applied to all found setting members. An optional nonself boolean flag indicates whether this measure shall also return the index individual.

Examples

my_str = IStrategy("identify-household-members", sim)
add_measure!(my_str, FindSettingMembers(Household, my_other_strategy, nonself = true))

The above example creates an IStrategy called 'my_str' and adds an instance of the FindSettingMembers measure that should return all household members except the index individual (all people that the individual lives with). It will trigger the follow-up strategy 'my_other_strategy' for all members.

my_str = IStrategy("identify-household-members", sim)
add_measure!(my_str, FindSettingMembers(Office, my_other_strategy))

The above example creates an IStrategy called 'my_str' and adds an instance of the FindSettingMembers measure that should return all Office members including the index individual. It will trigger the follow-up strategy 'my_other_strategy' for everyone in that office.

GEMS.IsOpenType
IsOpen <: SMeasure

Intervention struct to differentiate follow-up setting strategies for currently open or currently closed settings. You can pass a positive_followup- or a negative_followup stategy via the respective optional arguments.

Example

isolate_str = IStrategy("self-isolation", sim)
add_measure!(isolate_str, SelfIsolation(14))

find_coworkers_str = SStrategy("find-coworkers", sim)
add_measure!(find_coworkers_str, FindMembers(isolate_str))

my_str = SStrategy("is-open?", sim)
add_measure!(my_str, IsOpen(positive_followup = find_coworkers_str)))

The above example first creates an individual strategy (IStrategy) called 'isolate_str' and adds an instance of the SelfIsolation measure which will send the respective individual in self-isolation if excuted. It then creates an SStrategy called 'find_coworkers_str' and adds an instance of the FindMembers measure that detects the setting's members and calls the previously defined 'isolate_str' on all of them. We now only want to send all co-workers, if the setting is open (and thus might have induced infectious conctacts). Therefore, another SStrategy called 'my_str' is instantiated and an instance of the IsOpen measure is added with the 'find_coworkers_str' strategy being the positive follow-up.

GEMS.OpenSettingType
OpenSetting <: SMeasure

Intervention struct to open a setting, effectively re-enabling the setting and allow contacts.

Example

my_str = SStrategy("reopen-school", sim)
add_measure!(my_str, OpenSetting())

The above example creates an SStrategy called 'my_str' and adds an instance of the OpenSetting measure which will open the respective setting once called. You can, for example, use an STickTrigger to reopen all schools at a given simulation time (after they were closed earlier). The following code would open all schools at tick 20:

stt = STickTrigger(SchoolClass, my_str, switch_tick = Int16(20))
add_tick_trigger!(sim, stt)
GEMS.PoolTestType
PoolTest <: SMeasure

Intervention struct to apply a pathogen pool test to all individuals in a specified setting. Instantiate a PoolTest measure with a name and a type. A PoolTest will return a positive result if at least one of the individuals present at a given setting is infected. The name will determine the labeling of the test series in the logger and can be chosen arbitrarily. The type must be a TestType object that you need to define beforehand. It contains information, e.g., about the sensitivity and specificity of the respective test type.

The PoolTest measure is different from the TestAll measure as the former just uses one test to evaluate whether any of the individuals is infected and the latter applies a separate test to all individuals.

Optional Arguments

  • positive_followup::SStrategy: What to do with the setting if the test is positive
  • negative_followup::SStrategy: What to do with the setting if the test is negative

Example

pcr_test = TestType("PCR Test", pathogen(sim), sim)

my_str = SStrategy("school-pool-test", sim)
add_measure!(my_str, PoolTest("pool-test", pcr_test, positive_followup = my_close_school_str))

The above example first instantiates a TestType for the pathogen registered in the Simulation object, creates an SStrategy called 'my_str' and adds an instance of the PoolTest measure to the strategy. The PoolTest measure has a follow-up strategy called 'my_close_school_str' in case the test result is positive. A follow-up strategy could, for example, be a school-closure strategy. While the above example does not have a follow-up strategy for a negative test, you can ofcouse have both.

GEMS.SelfIsolationType
SelfIsolation <: IMeasure

Intervention struct to put an individual into self-isolation (household isolation) for the time (in ticks) specified in duration

Example

my_str = IStrategy("self-isolation", sim)
add_measure!(my_str, SelfIsolation(14))

The above example creates an IStrategy called 'my_str' and adds an instance of the SelfIsolation measure that should last for 14 days to the strategy.

GEMS.TestType
Test <: IMeasure

Intervention struct to apply a pathogen test to an individual. Instantiate a Test measure with a name and a type. The name will determine the labeling of the test series in the logger and can be chosen arbitrarily. The type must be a TestType object that you need to define beforehand. It contains information, e.g., about the sensitivity and specificity of the respective test type. Tests are generally separated into 'reportable' tests that contribute to the statistics of 'detected cases' or non-'reportable' which might still change an individual's behavior (such as a rapid-self-test at home) but will not be reported to the authorities.

Optional Arguments

  • positive_followup::IStrategy: What to do with the individual if the test is positive
  • negative_followup::IStrategy: What to do with the individual if the test is negative
  • reportable::Bool: Whether a positive result should contribute to the statistics of 'detected cases'. The default is true.

Example

antigen_test = TestType("Antigen Test", pathogen(sim), sim)

my_str = IStrategy("self-test", sim)
add_measure!(my_str, Test("self-test", antigen_test, positive_followup = my_other_strategy))

The above example first instantiates a TestType for the pathogen registered in the Simulation object, creates an IStrategy called 'my_str' and adds an instance of the Test measure to the strategy. The Test measure has a follow-up strategy called 'my_other_strategy' in case the test result is positive. A follow-up strategy could, for example, be a self-isolation strategy. While the above example does not have a follow-up strategy for a negative test, you can of couse have both.

GEMS.TestAllType
TestAll <: SMeasure

Intervention struct to apply a pathogen test to each individual in a specified setting. Instantiate a TestAll measure with a name and a type. A TestAll will return a positive result if at least one of the individuals present at a given setting has a positive test result. However, the logger will contain test results for each of the individuals. The name will determine the labeling of the test series in the logger and can be chosen arbitrarily. The type must be a TestType object that you need to define beforehand. It contains information, e.g., about the sensitivity and specificity of the respective test type.

The TestAll measure is different from the PoolTest measure as the latter just uses one test to evaluate whether any of the individuals is infected and the former applies a separate test to all individuals.

Optional Arguments

  • positive_followup::SStrategy: What to do with the setting if the test is positive
  • negative_followup::SStrategy: What to do with the setting if the test is negative
  • reportable::Bool: Whether a positive result should contribute to the statistics of 'detected cases'. The default is true.

Example

pcr_test = TestType("PCR Test", pathogen(sim), sim)

my_str = SStrategy("test-household-members", sim)
add_measure!(my_str, TestAll("pcr-test", pcr_test, positive_followup = my_isolate_household_str))

The above example first instantiates a TestType for the pathogen registered in the Simulation object, creates an SStrategy called 'my_str' and adds an instance of the PoolTest measure to the strategy. The PoolTest measure has a follow-up strategy called 'my_isolate_household_str' in case the test result is positive. A follow-up strategy could, for example, be a hosuehold-isolation strategy. While the above example does not have a follow-up strategy for a negative test, you can of couse have both.

GEMS.TestTypeType
TestType <: AbstractTestType

A type to specify a type of pathogen test (e.g. 'PCR Test') and its parameterization.

Fields

  • name::String: Name of the test (e.g. 'Rapid Test' or 'PCR Test')
  • pathogen::Pathogen: Pathogen that this test will detect
  • sensitivity::Float64 = 1.0: Probability (0-1) that this test will positively identify an infection (true positive rate)
  • specificity::Float64 = 1.0: Probability (0-1) that this test will negatively identify a non-infection (true negative rate)
GEMS.TraceInfectiousContactsType
TraceInfectiousContacts <: IMeasure

Intervention struct to trace individuals that have been infected by the index individual, this measure is called with. The follow_up argument provides an IStrategy that is being exceuted for all detected contacts. The optional success_rate (0-1) argument can be used to model sub-perfect tracing (the default is 100%).

Example

my_str = IStrategy("contact-tracing", sim)
add_measure!(my_str, TraceInfectiousContacts(my_other_str, success_rate = 0.5))

The above example creates an IStrategy called 'my_str' and adds an instance of the TraceInfectiousContacts measure that will trigger the 'my_other_str' for all detected infections. The success_rate is 50%.

Functions

GEMS.apply_pool_testFunction
apply_pool_test(setting::Setting, testtype::TestType, sim::Simulation; subset::Union{Vector{Individual}, Nothing} = nothing)

Subjects a collection of individuals to a pool test of the specified TestType and logs the result in the simulation's PoolTestLogger. Returns a boolean; true if test was positive (at least one infected individual) and false otherwise. Note that this fuction might return false positives and false negatives, depending on the TestType parameterization. If no subset of individuals (as a vector) is provided, this function will take all individuals assigned to the specified setting.

Parameters

  • setting::Setting: Setting that is being pool-tested
  • testtype::TestType: type of test that will be used (e.g. 'PCR'; needs to be defined as TestType beforehand)
  • sim::Simulation: Simulation object
  • subset::Union{Vector{Individual}, Nothing} = nothing (optional): Provide a subset of individuals to apply the pool test to

Returns

  • Bool: Test result (Note: Pay attention to test sensitivity and specificity of the respective TestType as this might lead to false negatives or false positives)
GEMS.apply_testFunction
apply_test(ind::Individual, testtype::TestType, sim::Simulation, reportable::Bool)

Subjects the individual to a test of the specified TestType and logs the result in the simulation's TestLogger. Returns a boolean; true if test was positive and false otherwise. Note that this fuction might return false positives and false negatives, depending on the TestType parameterization. If the reportable attribute is true, a positive test will lead to the detection of a previously undetected individual.

Parameters

  • ind::Individual: Individual to be tested
  • testtype::TestType: type of test that will be used (e.g. 'PCR'; needs to be defined as TestType beforehand)
  • sim::Simulation: Simulation object
  • reportable::Bool: If true, a positive test result will be 'reported'

Returns

  • Bool: Test result (Note: Pay attention to test sensitivity and specificity of the respective TestType as this might lead to false negatives or false positives)
GEMS.durationMethod
duration(si::SelfIsolation)

Returns the duration attribute from a SelfIsolation struct.

GEMS.follow_upFunction
follow_up(h::Handover)

Returns the follow-up strategy associated with a Handover struct.

follow_up(fs::FindSetting)

Returns the follow_up strategy attribute from a FindSetting struct.

follow_up(fsm::FindSettingMembers)

Returns the follow_up strategy attribute from a FindSettingMembers struct.

follow_up(tic::TraceInfectiousContacts)

Returns the follow_up strategy attribute from a TraceInfectiousContacts struct.

follow_up(fs::FindMembers)

Returns the follow_up strategy attribute of a FindMembers measure struct.

GEMS.i_measuretypesFunction
i_measuretypes()

Returns a list of all IMeasure types available.

GEMS.measure_logicFunction
measure_logic(measure::CustomIMeasure)

Returns the measure_logic (function) attribute from a CustomIMeasure struct.

measure_logic(measure::CustomSMeasure)

Returns the measure_logic (function) attribute from a CustomSMeasure struct.

GEMS.nameMethod
name(t::PoolTest)

Returns the name of a test-series from a PoolTest measure struct.

GEMS.nameMethod
name(t::TestAll)

Returns the name of a test-series from a TestAll measure struct.

GEMS.nameMethod
name(tt::TestType)

Returns the TestType's name.

GEMS.nameMethod
name(t::Test)

Returns the name of a test-series from a Test measure struct.

GEMS.negative_followupFunction
negative_followup(t::Test)

Returns the negative_followup strategy from a Test measure struct.

negative_followup(t::IsOpen)

Returns the negative_followup strategy attribute of an IsOpen measure struct.

negative_followup(t::PoolTest)

Returns the negative_followup strategy from a PoolTest measure struct.

negative_followup(t::TestAll)

Returns the negative_followup strategy from a TestAll measure struct.

GEMS.nonselfMethod
nonself(fsm::FindSettingMembers)

Returns the nonself strategy attribute from a FindSettingMembers struct.

GEMS.positive_followupFunction
positive_followup(t::Test)

Returns the positive_followup strategy from a Test measure struct.

positive_followup(t::IsOpen)

Returns the positive_followup strategy attribute of an IsOpen measure struct.

positive_followup(t::PoolTest)

Returns the positive_followup strategy from a PoolTest measure struct.

positive_followup(t::TestAll)

Returns the positive_followup strategy from a TestAll measure struct.

GEMS.process_measureFunction

Abstract wrapper function for intervention processing. Requires contrete subtype implementation

Abstract wrapper function for intervention processing. Requires contrete subtype implementation

process_measure(sim::Simulation, ind::Individual, cancel::CancelSelfIsolation)

Cancels an individuals self-isolation (household isolation) by setting the individual's quarantine_release_tick to 'now'.

Parameters

  • sim::Simulation: Simulation object
  • ind::Individual: Individual that this measure will be applied to (focus individual)
  • cancel::CancelSelfIsolation: Measure instance
process_measure(sim::Simulation, ind::Individual, custom::CustomIMeasure)

Applies a custom logic to the individual as specified in the CustomIMeasure's measure_logic field.

Parameters

  • sim::Simulation: Simulation object
  • ind::Individual: Individual that this measure will be applied to (focus individual)
  • custom::CustomIMeasure: Measure instance
process_measure(sim::Simulation, ind::Individual, measure::FindSetting)

Detects a particular setting (specified by the FindSetting measure's settingtype attribute) for an individual and hands over a follow_up strategy for the respective setting object.

Parameters

  • sim::Simulation: Simulation object
  • ind::Individual: Individual that this measure will be applied to (focus individual)
  • measure::FindSetting: Measure instance

Returns

  • Handover: Struct that contains the detected setting and the followup SStrategy defined in the input FindSetting measure.
process_measure(sim::Simulation, ind::Individual, measure::FindSettingMembers)

Finds all members of one of the settings an individual is associated with. the measure's field settingtype specifies which kind of setting shall be queried, the nonself boolean flag indicates whether the index individual shall be among the returning members. The follow_up strategy is handed over to all found members (and enqueued in the EventQueue in a subsequent step)

Parameters

  • sim::Simulation: Simulation object
  • ind::Individual: Individual that this measure will be applied to (focus individual)
  • measure::FindSettingMembers: Measure instance

Returns

  • Handover: Struct that contains the list of detected setting members and the followup IStrategy defined in the input FindSettingMemers measure.
process_measure(sim::Simulation, ind::Individual, isolation::SelfIsolation)

Puts an individual into self-isolation (household isolation) for the time (in ticks) specified in the SelfIsolation's duration attribute.

Parameters

  • sim::Simulation: Simulation object
  • ind::Individual: Individual that this measure will be applied to (focus individual)
  • isolation::SelfIsolation: Measure instance
process_measure(sim::Simulation, ind::Individual, test::Test)

Apply a test of TestType (as specified in the Test measure) to an individual. The test will automatically be logged in the Simulation's internal loggers. If a follow-up strategy is set (for either positive or negative results), the follow-up strategy is handed over to the EventQueue for this individual.

Parameters

  • sim::Simulation: Simulation object
  • ind::Individual: Individual that this measure will be applied to (focus individual)
  • test::Test: Measure instance

Returns

  • Handover: Struct that contains the focus individual (ind) and the respective followup IStrategy defined in the input Test measure depending on whether the test returned a positive or negative result.
process_measure(sim::Simulation, ind::Individual, measure::TraceInfectiousContacts)

Detects individuals that have been infected by the index individual. The TraceInfectiousContacts measure's success_rate argument can be used to model sub-perfect tracing (the default is 100%). The follow_up strategy of the TraceInfectiousContacts measure is handed over to all detected contacts.

Parameters

  • sim::Simulation: Simulation object
  • ind::Individual: Individual that this measure will be applied to (focus individual)
  • measure::TraceInfectiousContacts: Measure instance

Returns

  • Handover: Struct that contains the list of detected infectious individuals and the followup IStrategy defined in the input TraceInfectiousContacts measure.
process_measure(sim::Simulation, s::Setting, measure::ChangeContactMethod)

Replaces the contact sampling method in the setting that was passed with a new sampling method specified in the ChangeContactMethod measure.

Parameters

  • sim::Simulation: Simulation object
  • s::Setting: Setting that this measure will be applied to (focus setting)
  • measure::ChangeContactMethod: Measure instance
process_measure(sim::Simulation, s::Setting, close::CloseSetting)

Closes the passed setting s indefinitely, effectively preventing all contacts.

Parameters

  • sim::Simulation: Simulation object
  • s::Setting: Setting that this measure will be applied to (focus setting)
  • close::CloseSetting: Measure instance
process_measure(sim::Simulation, s::Setting, custom::CustomSMeasure)

Applies a custom logic to the setting as specified in the CustomSMeasure's measure_logic field.

Parameters

  • sim::Simulation: Simulation object
  • s::Setting: Setting that this measure will be applied to (focus setting)
  • custom::CustomSMeasure: Measure instance
process_measure(sim::Simulation, s::Setting, measure::FindMembers)

Returns the individuals (members) associated with setting s and hands over the follow_up strategy as specified in the FindMembers measure. The sample_size, sample_fraction, and selectionfilter attributes of the FindMembers measure can be used to condition or limit the results.

Parameters

  • sim::Simulation: Simulation object
  • s::Setting: Setting that this measure will be applied to (focus setting)
  • measure::FindMembers: Measure instance

Returns

  • Handover: Struct that contains the list of setting members and the followup IStrategy defined in the input FindMembers measure.
process_measure(sim::Simulation, s::Setting, measure::IsOpen)

Evaluates whether the setting s is currently open and hands over the respective follow-up strategies as specified in the IsOpen measure.

Parameters

  • sim::Simulation: Simulation object
  • s::Setting: Setting that this measure will be applied to (focus setting)
  • measure::IsOpen: Measure instance

Returns

  • Handover: Struct that contains the focus setting (s) and the respective followup SStrategy defined in the input IsOpen measure depending on whether the setting is open or closed.
process_measure(sim::Simulation, s::Setting, close::OpenSetting)

(Re-)Opens the passed setting s indefinitely, again allowing contacts to happen.

Parameters

  • sim::Simulation: Simulation object
  • s::Setting: Setting that this measure will be applied to (focus setting)
  • close::OpenSetting: Measure instance
process_measure(sim::Simulation, s::Setting, measure::PoolTest)

Apply a test of TestType (as specified in the PoolTest measure) to a setting. The test will automatically be logged in the Simulation's internal loggers. If a follow-up strategy is set (for either positive or negative results), the follow-up strategy is handed over to the EventQueue for this setting.

Parameters

  • sim::Simulation: Simulation object
  • s::Setting: Setting that this measure will be applied to (focus setting)
  • measure::PoolTest: Measure instance

Returns

  • Handover: Struct that contains the focus setting (s) and the respective followup SStrategy defined in the input PoolTest measure depending on whether the test returned a positive or negative result.
process_measure(sim::Simulation, s::Setting, measure::TestAll)

Apply a test of TestType (as specified in the TestAll measure) to each individual of a setting. The test results will automatically be logged in the Simulation's internal loggers. If a follow-up strategy is set (for either positive or negative results), the follow-up strategy is handed over to the EventQueue for this setting.

Parameters

  • sim::Simulation: Simulation object
  • s::Setting: Setting that this measure will be applied to (focus setting)
  • measure::TestAll: Measure instance

Returns

  • Handover: Struct that contains the focus setting (s) and the respective followup SStrategy defined in the input TestAll measure depending on whether the test returned a at least one positive or all negative result.
GEMS.reportableMethod
reportable(t::Test)

Returns the reportable boolean flag from a Test measure struct.

GEMS.reportableMethod
reportable(t::TestAll)

Returns the reportable boolean flag from a TestAll measure struct.

GEMS.s_measuretypesFunction
s_measuretypes()

Returns a list of all SMeasure types available.

GEMS.sample_fractionMethod
sample_fraction(fs::FindMembers)

Returns the sample_fraction attribute of a FindMembers measure struct.

GEMS.sample_sizeMethod
sample_size(fs::FindMembers)

Returns the sample_size attribute of a FindMembers measure struct.

GEMS.sampling_methodMethod
sampling_method(measure::ChangeContactMethod)

Returns the sampling_method attribute from a ChangeContactMethod struct.

GEMS.selectionfilterMethod
selectionfilter(fs::FindMembers)

Returns the selectionfilter attribute of a FindMembers measure struct.

GEMS.sensitivityMethod
sensitivity(tt::TestType)

Returns the TestType's sensitivity.

GEMS.specificityMethod
specificity(tt::TestType)

Returns the TestType's specificity.

GEMS.success_rateMethod
success_rate(tic::TraceInfectiousContacts)

Returns the success_rate attribute from a TraceInfectiousContacts struct.

GEMS.typeFunction
type(t::Test)

Returns the test type from a Test measure struct.

type(t::PoolTest)

Returns the test type from a PoolTest measure struct.

type(t::TestAll)

Returns the test type from a TestAll measure struct.

Event Handling

Constructors

GEMS.EventQueueType
EventQueue

Data structure to store intervention events.

GEMS.HandoverType
Handover

The Handover struct provides a standard data structure for handling outputs of the process_measure() functions. It is being used to pass follow-up strategies to focal objects that are being determined within the process_measure() functions. The Handovers organize how follow-up strategies are passed to the event queue. There is no application for Handovers outside of process_measure() functions.

Fields

  • focal_objects::Union{Vector{<:Individual},Vector{<:Setting}}: List of focal objects (either all Individuals or all Settings)
  • follow_up::Union{<:Strategy, Nothing}: Strategy that shall be triggered for all focus objects in the focal_objects list

Examples

The code below defines how a Test measure shall be processed. First, the passed individual ind is being tested. The function then returns a new Handover with the focus object (the individual) and the either positive- or negative-follow-up stategy that are defined in the Test measure.

function process_measure(sim::Simulation, ind::Individual, test::Test)
    test_pos = apply_test(ind, test |> type, sim, test |> reportable)
    return Handover(ind, test_pos ? test |> positive_followup : test |> negative_followup)
end

The handovers can be instantiated with single focal objects (Individuals or Settings) as well as vectors of focal objects (Vector{Individual} or Vector{Setting}). It's also possible to instantiate a Handover with nothing as the follow_up strategy which is sometimmes helpful if you don't know whether there will be a subsequent strategy or not.

Here are some more examples on how to instantiate Handovers:

i1 = Indiviual(...)
i2 = Indiviual(...)
s = Household(...)
istr = IStrategy("my_istr", sim)
sstr = SStrategy("my_sstr", sim)

h1 = Handover(i1, istr)
h2 = Handover([i1, i2], istr)
h3 = Handover(s, nothing)
h4 = Handover([s], sstr)

Note: Naturally, A Handover must either have all Individuals and an IStrategy or all Settingss and an SStrategy.

GEMS.IMeasureEventType
IMeasureEvent <: Event

Struct associate a specific Individual with a specific IMeasure which is stored in the intervention event queue.

GEMS.SMeasureEventType
SMeasureEvent <: Event

Struct associate a specific Setting with a specific SMeasure which is stored in the intervention event queue.

Functions

GEMS.dequeue!Method
dequeue!(queue::EventQueue)

Removes and returns the first Event of the EventQueue.

GEMS.enqueue!Method
enqueue!(queue::EventQueue, event::Event, tick::Int16)

Adds a new Event to the EventQueue at the specified tick.