Source code for emodpy_tbhiv.interventions.age_targeted_vaccine

from emod_api import schema_to_class as s2c
import emod_api.interventions.common as common
import emod_api.interventions.utils as utils
from emodpy_tbhiv.interventions import purge_campaign_event

co_event = "AgeTargetedVaccineDistributed"


[docs]def AgeTargetedVaccine( camp, trigger_treatment_list, initial_efficacy=1.0, vaccine_take=1, vtype='AcquisitionBlocking', coverage=1, age_min_yrs=0, age_max_yrs=125, box_duration_yrs=1, immune_decay_yrs=0, start_day=1, duration=-1, property_restrictions_list=[], nodeIDs=[], cost=0, black_period=0, black_trigger='Blackout', event_name='Vaccine'): """ Create and return triggered campaign event that issues a (generalized) Vaccine intervention. See :doc:`emod-tbhiv:parameter-campaign-individual-simplevaccine` Args: camp: The :py:obj:`emod_api:emod_api.campaign` module instance which serves as the campaign accumulator. trigger_treatment_list: List of 1 or more triggers (or events or signals) which are listened to and trigger the distribution of the intervention. There is no default. initial_efficacy: Initial efficacy of the vaccine. Defaults to 1.0. vaccine_take: Fraction of the population receiving the vaccine for whom it is efficacious. Defaults to 1.0. vtype: ... Defaults to "AcquisitionBlocking" age_min_yrs: Lower age bound, in years. Defaults to 0. age_max_yrs: Upper age bound, in years. Defaults to 125. box_duration_yrs: Period of time over which the initial efficacy persists before decay. Defaults to 1 year. immune_decay_yrs: Period of time over which the efficacy decays to 0. Defaults to 0. start_day: The timestep when this campaign event takes effect. Defaults to 1. duration: How long the campaign event remains in effect. Defaults to forever. property_restrictions_list: Optiional list of Individual Properties to limit the intervention to. nodeIDs: Optional list of node ids to target. Defaults to all. coverage: Fraction of population to reach. cost: Per unit 'price' of each intervention. black_period: Undocumented. black_trigger: Undocumented. event_name: Undocumented. Returns: New campaign event that can be added to the campaign. """ if box_duration_yrs > 150: raise ValueError( f"It seems that your value of box_duration_yrs ({box_duration_yrs}) might be in units of days instead of years." ) if immune_decay_yrs > 150: raise ValueError( f"It seems that your value of immune_duration_yrs ({immune_duration_yrs}) might be in units of days instead of years." ) schema_path = camp.schema_path act_intervention = s2c.get_class_with_defaults( "SimpleVaccine", schema_path) act_intervention.Vaccine_Take = vaccine_take act_intervention.Vaccine_Type = vtype act_intervention.Cost_To_Consumer = cost waning = s2c.get_class_with_defaults( "WaningEffectBoxExponential", schema_path ) #waning = s2c.get_class_with_defaults("WaningEffectBox", schema_path) waning.Initial_Effect = initial_efficacy waning.Box_Duration = box_duration_yrs*365 waning.Decay_Time_Constant = immune_decay_yrs*365 act_intervention.Waning_Config = waning bcast_intervention = s2c.get_class_with_defaults( "BroadcastEvent", schema_path) bcast_intervention.Broadcast_Event = camp.get_send_trigger(co_event) event = common.TriggeredCampaignEvent( camp=camp, Start_Day=start_day, Event_Name=event_name, Triggers=trigger_treatment_list, Intervention_List=[act_intervention, bcast_intervention], Node_Ids=nodeIDs, Property_Restrictions=property_restrictions_list, Demographic_Coverage=coverage, Target_Age_Min=age_min_yrs, Target_Age_Max=age_max_yrs, Duration=duration ) purge_campaign_event(event) return event
[docs]def new_intervention_as_file(camp, filename="vaccine.json"): camp.add(AgeTargetedVaccine(camp, trigger_treatment_list=["Births"])) camp.save(filename) return filename