emod_api.interventions.common module#

emod_api.interventions.common.BroadcastEvent(camp, Event_Trigger: str = 'Births')[source]#

Wrapper function to create and return a BroadcastEvent intervention.

Parameters:
  • camp – emod_api.campaign object with schema_path set.

  • Event_Trigger – A valid trigger/event/signal.

Returns:

Schema-based smart dictionary representing a new BroadastEvent intervention ready to be added to a campaign.

Return type:

ReadOnlyDict

emod_api.interventions.common.BroadcastEventToOtherNodes(camp, Event_Trigger, Node_Selection_Type='DISTANCE_ONLY', Max_Distance_To_Other_Nodes_Km=-1, Include_My_Node=1)[source]#

Wrapper function to create and return a BroadcastEventToOtherNodes intervention.

Parameters:
  • camp – emod_api.campaign object with schema_path set.

  • Event_Trigger – A valid trigger/event/signal.

  • Node_Selection_Type – TBD.

  • Max_Distance_To_Other_Nodes_Km – TBD.

  • Include_My_Node – TBD.

Returns:

Schema-based smart dictionary representing a new BroadastEvent intervention ready to be added to a campaign.

Return type:

ReadOnlyDict

emod_api.interventions.common.MultiInterventionDistributor(camp, Intervention_List)[source]#

Wrapper function to create and return a MultiInterventionDistributor intervention.

Parameters:
  • camp – emod_api.campaign object with schema_path set.

  • Intervention_List – List of 1 or more valid intervention dictionaries to be

  • together. (distributed) –

Returns:

Schema-based smart dictionary representing a new MultiInterventionDistributor intervention ready to be added to a campaign.

Return type:

ReadOnlyDict

emod_api.interventions.common.DelayedIntervention(camp, Configs: List[dict], Delay_Dict: dict)[source]#

Wrapper function to create and return a DelayedIntervention intervention.

Parameters:
  • camp – emod_api.campaign object with schema_path set.

  • Configs – A list of individual-level interventions

  • Delay_Dict – Dictionary with delay parameters, please use emod_api.utils.Distributions to generate the delay parameters.

Returns:

Schema-based smart dictionary representing a new DelayedIntervention intervention ready to be added to a campaign.

Return type:

ReadOnlyDict

emod_api.interventions.common.HSB(camp, Event_Or_Config='Event', Config=None, Event='NoTrigger', Tendency=1.0, Single_Use=True, Name='HSB')[source]#

Wrapper function to create and return a HealthSeekingBehaviour intervention.

Parameters:
  • camp – emod_api.campaign object with schema_path set.

  • Event_Or_Config – “Event” or “Config”.

  • Config – Complete, valid intervention configuration to be distributed.

  • Event – Event/Trigger/Signal to be broadcast, alternative to an intervention.

  • Tendency – Daily probability of ‘seeking care’ aka distributing payload intervention.

  • Single_Use – One-and-done, or continuous?

  • Name – Intervention Name. Useful if you want to provide uniqueness and not worry about

  • management. (duplicate intervention) –

Returns:

Schema-based smart dictionary representing a new HSB intervention ready to be added to a campaign.

Return type:

ReadOnlyDict

emod_api.interventions.common.NLHTI(camp, Triggers: List[str], Interventions: List[dict], Property_Restrictions=None, Demographic_Coverage=1.0, Target_Age_Min: float = 0, Target_Age_Max: float = 45625, Target_Gender='All', Target_Residents_Only=False, Duration: float = -1, Blackout_Event_Trigger=None, Blackout_Period=None, Blackout_On_First_Occurrence=None, Disqualifying_Properties=None)[source]#

Wrapper function to create and return a NodeLevelHealthTriggeredIntervention intervention.

Parameters:
  • camp – emod_api.campaign object with schema_path set.

  • Triggers – List of Triggers/Events/Signals

  • Interventions – List of interventions to distrbute when signal is heard.

  • Property_Restrictions – Individual Properties that an agent must have to qualify for intervention.

  • Demographic_Coverage – Percentage of individuals to receive intervention.

  • Target_Age_Min – Minimum age (in years).

  • Target_Age_Max – Maximum age (in years).

  • Target_Gender – All, Male, or Female.

  • Target_Residents_Only – Not used.

  • Duration – How long this listen-and-distribute should last.

  • Blackout_Event_Trigger – Not used.

  • Blackout_Period – Not used.

  • Blackout_On_First_Occurrence – Not used.

  • Disqualifying_Properties – Not used.

Returns:

Schema-based smart dictionary representing a new NLHTI intervention ready to be added to a campaign.

Return type:

ReadOnlyDict

emod_api.interventions.common.PropertyValueChanger(camp, Target_Property_Key, Target_Property_Value, Daily_Probability=1.0, Maximum_Duration=1, Revert=-1, Intervention_Name='', Event_Trigger_Distributed='', Event_Trigger_Expired='')[source]#

Wrapper function to create and return a PropertyValueChanger intervention.

Parameters:
  • camp – emod_api.campaign object with schema_path set.

  • IP. (Target_Property_Value. The value part of the new key-value pair of the) –

  • IP.

  • IP.

  • key (New_Property_Value.. Optional IP) – value part to be set, common to all interventions.

  • Target_Property_Value. (Daily_Probability. The daily probability that an individual will move to the) –

  • works (Maximum_Duration. The maximum amount of time individuals have to move to a new group. This timing) – in conjunction with Daily_Probability.

  • group. (Revert. The number of days before an individual moves back to their original) –

  • policy. (Intervention_Name. Optional Intervention_Name. Useful if managing a replacement) –

  • distributed. (Event_Trigger_Distributed. Optional broadcast trigger to be published when PVC is) –

  • expired. (Event_Trigger_Expired. Optional broadcast trigger to be published when PVC is) –

Returns:

Schema-based smart dictionary representing a new PropertyValueChanger intervention ready to be added to a campaign.

Return type:

ReadOnlyDict

emod_api.interventions.common.ScheduledCampaignEvent(camp, Start_Day: int, Node_Ids=None, Nodeset_Config=None, Number_Repetitions: int = 1, Timesteps_Between_Repetitions: int = -1, Event_Name: str = 'Scheduled_Campaign_Event', Property_Restrictions=None, Demographic_Coverage: float = 1.0, Target_Age_Min=0, Target_Age_Max=45625, Target_Gender: str = 'All', Target_Residents_Only: bool = False, Intervention_List=None)[source]#

Wrapper function to create and return a ScheduledCampaignEvent intervention. The alternative to a ScheduledCampaignEvent is a TriggeredCampaignEvent.

Parameters:
  • camp – emod_api.campaign object with schema_path set.

  • Start_Day – When to start.

  • Event_Name – Name for overall campaign event, of no functional meaning. Not in schema and not yet used.

  • Node_Ids – Nodes to target with this intervenion

  • Nodeset_Config

    Nodes to target with this intervenion, return from utils.do_nodes().

    Deprecated since version 2.x: Use parameter Node_Ids instead

  • Property_Restrictions – Individual Properties a person must have to receive the intervention(s).

  • Number_Repetitions – N/A

  • Timesteps_Between_Repetitions – N/A

  • Demographic_Coverage – Percentage of individuals to receive intervention.

  • Target_Age_Min – Minimum age (in years).

  • Target_Age_Max – Maximum age (in years).

  • Target_Gender – All, Male, or Female.

  • Intervention_List – List of 1 or more valid intervention dictionaries to be

  • together. (distributed) –

Returns:

Schema-based smart dictionary representing a new ScheduledCampaignEvent intervention ready to be added to a campaign.

Return type:

ReadOnlyDict

emod_api.interventions.common.TriggeredCampaignEvent(camp, Start_Day: int, Event_Name: str, Triggers: List[str], Intervention_List: List[dict], Node_Ids: List[int] | None = None, Nodeset_Config: dict | None = None, Node_Property_Restrictions: List[dict] | None = None, Property_Restrictions: List[dict] | None = None, Number_Repetitions: int = 1, Timesteps_Between_Repetitions: int = -1, Demographic_Coverage: float = 1.0, Target_Age_Min: float = 0, Target_Age_Max: float = 45625, Target_Gender: str = 'All', Target_Residents_Only: bool = False, Duration: float = -1, Blackout_Event_Trigger: str | None = None, Blackout_Period: float = 0, Blackout_On_First_Occurrence=0, Disqualifying_Properties: List[str] | None = None, Delay: dict | None = None)[source]#

Wrapper function to create and return a TriggeredCampaignEvent intervention. The alternative to a TriggeredCampaignEvent is a ScheduledCampaignEvent.

Parameters:
  • camp – emod_api.campaign object with schema_path set.

  • Start_Day – When to start.

  • Event_Name – Name for overall campaign event, of no functional meaning. Not in schema and not yet used.

  • Node_Ids – Nodes to target with this intervenion

  • Nodeset_Config

    Nodes to target with this intervenion, return from utils.do_nodes().

    Deprecated since version 2.x: Use parameter Node_Ids instead

  • Triggers – List of triggers/events/signals to listen to in order to trigger distribution.

  • Intervention_List – List of 1 or more valid individual-level intervention dictionaries to be

  • together. (distributed) –

  • Node_Property_Restrictions – N/A.

  • Property_Restrictions – Individual Properties a person must have to receive the intervention(s).

  • Demographic_Coverage – Percentage of individuals to receive intervention.

  • Target_Age_Min – Minimum age (in years).

  • Target_Age_Max – Maximum age (in years).

  • Target_Gender – All, Male, or Female.

  • Target_Residents_Only – TBD.

  • Duration – How long this listen-and-distribute should last.

  • Blackout_Event_Trigger – Not used.

  • Blackout_Period – Not used.

  • Blackout_On_First_Occurrence – Not used.

  • Disqualifying_Properties – Not used.

  • Delay – Optional delay between trigger and actual distribution, a distribution dictionary generated by emod_api.utils.Distributions class.

Returns:

Schema-based smart dictionary representing a new TriggeredCampaignEvent intervention ready to be added to a campaign.

Return type:

ReadOnlyDict

emod_api.interventions.common.StandardDiagnostic(camp, Base_Sensitivity: float = 1.0, Base_Specificity: float = 1.0, Days_To_Diagnosis: float = 0.0, Event_Trigger_Distributed: str | None = None, Event_Trigger_Expired: str | None = None, Positive_Diagnosis_Intervention=None, Positive_Diagnosis_Event: str = 'PositiveResult', Negative_Diagnosis_Intervention=None, Negative_Diagnosis_Event: str = 'NegativeResult', Treatment_Fraction: float = 1.0)[source]#

Wrapper function to create and return a StandardDiagnostic intervention.

Parameters:
  • camp – emod_api.campaign object with schema_path set.

  • Base_Sensitivity – base sensitivity [0..1]

  • Base_Specificity – base specificity [0..1]

  • Days_To_Diagnosis – days to diagnosis

  • Event_Trigger_Distributed – A trigger that is fired when intervention was distributed

  • Event_Trigger_Expired – A trigger that is fired when intervention has expired

  • Positive_Diagnosis_Intervention – Intervention that is distributed in case of a positive diagnosis. If set, no events may be configured.

  • Positive_Diagnosis_Event – A trigger that is fired in case of a positive diagnosis

  • Negative_Diagnosis_Intervention – Intervention that is distributed in case of a Negative diagnosis. If set, no events may be configured. Not used outside of Malaria-Ongoing yet.

  • Negative_Diagnosis_Event – A trigger that is fired in case of a Negative diagnosis. Not used outside of Malaria-Ongoing yet.

  • Treatment_Fraction – treatment fraction [0..1]

Returns:

Schema-based smart dictionary representing a new MultiInterventionDistributor intervention ready to be added to a campaign.

Return type:

ReadOnlyDict

emod_api.interventions.common.triggered_campaign_delay_event(camp, start_day, trigger, delay, intervention, ip_targeting=None, coverage=1.0)[source]#

Create and return a campaign event that responds to a trigger after a delay with an intervention.

Parameters:
  • camp – emod_api.campaign object with schema_path set.

  • start_day – Day the event will start.

  • delay – Dictionary with delay parameters, please use emod_api.utils.Distributions to generate the delay parameters.

  • trigger – E.g., “NewInfection”.

  • intervention – List of 1 or more valid intervention dictionaries to be distributed together.

  • ip_targeting – Optional Individual Properties required for someone to receive the intervention(s).

  • coverage – Fraction of the population that will receive the intervention.

Returns:

Campaign event.

emod_api.interventions.common.triggered_campaign_event_with_optional_delay(camp, start_day, triggers, intervention, delay=None, duration=-1, ip_targeting=None, coverage=1.0, target_age_min=0, target_age_max=45625, target_sex='All', target_residents_only=False, blackout=True, check_at_trigger=False)[source]#

Create and return a campaign event that responds to a trigger after a delay with an intervention.

Parameters:
  • camp – emod_api.campaign object with schema_path set.

  • start_day – When to start.

  • triggers – List of signals to listen for/trigger on. E.g., “NewInfection”.

  • intervention – List of 1 or more valid intervention dictionaries to be distributed together.

  • delay – Optional dictionary of 1 or 2 params that are the literal Delay_Distribution parameters,

  • "Delay_Period_Exponential" (but without the distribution, which is inferred. E.g., {) – 5 }. If omitted,

  • immediate. (intervention is) –

  • duration – How long to listen.

  • ip_targeting – Optional Individual Properties required for someone to receive the intervntion(s).

  • coverage – Fraction of target population to reach.

  • target_age_min – Minimum age to target.

  • target_age_max – Maximum age to target.

  • target_sex – Optional target just “MALE” or “FEMALE” individuals.

  • target_residents_only – Set to True to target only the individuals who started the simulation in this node and are still in the node.

  • blackout – Set to True if you don’t want the triggered intervention to be distributed to the same person more than once a day.

  • check_at_trigger – if triggered event is delayed, you have an option to check individual/node’s eligibility at the initial trigger or when the event is actually distributed after delay.

Returns:

Campaign event.

emod_api.interventions.common.change_individual_property_at_age(camp, new_ip_key, new_ip_value, change_age_in_days, revert_in_days, ip_targeting_key, ip_targeting_value, coverage=1.0)[source]#

Create and return a campaign event that changes a person’s Individual Properties once they turns a certain age. e.g., change_individual_property_at_age(cb, ‘ForestGoing’, ‘LovesForest’, coverage=0.6, change_age_in_days=15*365, revert=20*365)

Parameters:
  • camp – emod_api.campaign object with schema_path set.

  • new_ip_key – The new IP key.

  • new_ip_value – The new IP value.

  • change_age_in_days – The age at which the individual transitions (in units of days).

  • revert_in_days – How many days they remain with the new property.

  • ip_targeting_key – The IP key a person must have to receive this.

  • ip_targeting_value – The IP value a person must have to receive this.

  • coverage – Optional fraction to limit this to a subset of the target population.

Returns:

Campaign event.

emod_api.interventions.common.change_individual_property_triggered(camp, triggers: list, new_ip_key: str, new_ip_value: str, start_day: int = 0, daily_prob: float = 1, max_duration: int = 9.3228e+35, revert_in_days: int = -1, node_ids: list | None = None, ip_restrictions: list | None = None, coverage: float = 1.0, target_age_min: float = 0, target_age_max: float = 45625, target_sex: str = 'All', target_residents_only: bool = False, delay=None, listening_duration: int = -1, blackout: bool = True, check_at_trigger: bool = False)[source]#

Change Individual Properties when a certain trigger is observed.

Parameters:
  • camp – The instance containing the campaign builder and accumulator.

  • triggers – A list of the events that will trigger the intervention.

  • new_ip_key – The individual property key to assign to the individual. For example, InterventionStatus.

  • new_ip_value – The individual property value to assign to the individual. For example, RecentDrug.

  • start_day – The day on which to start distributing the intervention (Start_Day parameter).

  • node_ids – The list of nodes to apply this intervention to. If not provided, defaults to all nodes.

  • daily_prob – The daily probability that an individual’s property value will be updated (Daily_Probability parameter).

  • max_duration – The maximum amount of time individuals have to move to a new daily_prob; individuals not moved to the new value by the end of max_duration keep the same value.

  • revert_in_days – The number of days before a node reverts to its original property value. Default of 0 means the new value is kept forever.

  • ip_restrictions – The IndividualProperty key:value pairs to target.

  • coverage – The proportion of the population that will receive the intervention (Demographic_Coverage parameter).

  • target_age_min – Minimum age to target.

  • target_age_max – Maximum age to target.

  • target_sex – Optional target just “MALE” or “FEMALE” individuals.

  • target_residents_only – Set to True to target only the individuals who started the simulation in this node and are still in the node.

  • delay – The number of days the campaign is delayed after being triggered.

  • listening_duration – The number of time steps that the triggered campaign will be active for. Default is -1, which is indefinitely.

  • blackout (advanced) – Set to True if you don’t want the triggered intervention to be distributed to the same person more than once a day.

  • check_at_trigger (advanced) – if triggered event is delayed, you have an option to check individual/node’s eligibility at the initial trigger or when the event is actually distributed after delay.

  • Returns – N/A.

emod_api.interventions.common.change_individual_property_scheduled(camp, new_ip_key, new_ip_value, start_day: int = 0, number_repetitions: int = 1, timesteps_between_reps: int = -1, node_ids: list | None = None, daily_prob: float = 1, max_duration: int = 9.3228e+35, revert_in_days: int = -1, ip_restrictions: list | None = None, coverage: float = 1.0, target_age_min: float = 0, target_age_max: float = 45625, target_sex: str = 'All', target_residents_only: bool = False)[source]#

Change Individual Properties at a given time.

Parameters:
  • camp – The instance containing the campaign builder and accumulator.

  • new_ip_key – The individual property key to assign to the individual. For example, InterventionStatus.

  • new_ip_value – The individual property value to assign to the individual. For example, RecentDrug.

  • start_day – The day on which to start distributing the intervention (Start_Day parameter).

  • node_ids – The list of nodes to apply this intervention to. If not provided, defaults to all nodes.

  • daily_prob – The daily probability that an individual’s property value will be updated (Daily_Probability parameter).

  • max_duration – The maximum amount of time individuals have to move to a new daily_prob; individuals not moved to the new value by the end of max_duration keep the same value.

  • revert_in_days – The number of days before an individual reverts to its original property value. Default of -1 means the new value is kept forever.

  • ip_restrictions – The IndividualProperty key:value pairs to target.

  • coverage – The proportion of the population that will receive the intervention (Demographic_Coverage parameter).

  • target_age_min – Minimum age to target.

  • target_age_max – Maximum age to target.

  • target_sex – Optional target just “MALE” or “FEMALE” individuals.

  • target_residents_only – Set to True to target only the individuals who started the simulation in this node and are still in the node.

  • Returns – N/A.

emod_api.interventions.common.change_individual_property(camp, target_property_name: str, target_property_value: str, start_day: int = 0, number_repetitions: int = 1, timesteps_between_reps: int = -1, node_ids: list | None = None, daily_prob: float = 1, max_duration: int = 9.3228e+35, revert: int = -1, coverage: float = 1, ip_restrictions: list | None = None, target_age_min: float = 0, target_age_max: float = 45625, target_sex: str = 'All', target_residents_only: bool = False, trigger_condition_list: list | None = None, triggered_campaign_delay: int = 0, listening_duration: int = -1, blackout_flag: bool = True, check_eligibility_at_trigger: bool = False)[source]#

Add an intervention that changes the individual property value to another on a particular day OR after a triggering event using the PropertyValueChanger class. Deprecated. Prefer change_individual_property_scheduled or change_individual_property_triggered depending on the use case.

Parameters:
  • camp – emod_api.campaign object with schema_path set.

  • target_property_name – The individual property key to assign to the individual. For example, Risk.

  • target_property_value – The individual property value to assign to the individual. For example, High.

  • start_day – The day on which to start distributing the intervention.

  • number_repetitions – Optional repeater value. Does not work with triggers.

  • timesteps_between_reps – Gap between repetitions, optional. Does not work with triggers.

  • node_ids – The list of nodes to apply this intervention to. Defaults to all.

  • daily_prob – The daily probability that an individual’s property value will be updated (Daily_Probability parameter).

  • max_duration – The number of days to continue the intervention after start_day.

  • revert – The number of days before an individual reverts to its original property value. Default of -1 means the new value is kept forever.

  • coverage – The proportion of the population that will receive the intervention (Demographic_Coverage parameter).

  • ip_restrictions – The IndividualProperty key:value pairs to target. Usually this will be the same key but different from the target_property_xxx entries.

  • target_residents_only – Set to True to target only the individuals who started the simulation in this node and are still in the node.

  • target_age_min – Optional minimum age, defaults to 0.

  • target_age_max – Optional maximum age, defaults to inf.

  • target_sex – Optional target sex, defaults to both.

  • triggered_campaign_delay – The number of days the campaign is delayed after being triggered.

  • trigger_condition_list – A list of the events that will trigger the intervention. If included, start_day is the day when monitoring for triggers begins.

  • listening_duration – The number of time steps that the triggered campaign will be active for. Default is -1, which is indefinitely.

  • blackout_flag – Set to True if you don’t want the triggered intervention to be distributed to the same person more than once a day.

  • check_eligibility_at_trigger – if triggered event is delayed, you have an option to check individual/node’s eligibility at the initial trigger or when the event is actually distributed after delay.

Returns:

None