Source code for emodpy_tbhiv.interventions.triggered_pvc

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

[docs]def TPVC( camp, trigger_treatment_list, property_to_change, final_prop_value, revert=0, daily_prob=1, start_day=1, duration=-1, coverage=1.0, property_restrictions_list=[], nodeIDs=[], black_period=0, black_trigger='Blackout', event_name='PropertyValueChanger'): """ Create and return triggered campaign event that issues an PropertyValueChanger intervention. See :doc:`emod-tbhiv:parameter-campaign-individual-propertyvaluechanger` 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. property_to_change: Individual Property key (string). final_prop_value: New Individual Property value (string). revert: ... Defaults to 0. daily_prob: Daily probabilty of changing. Defaults to 1. 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. coverage: Fraction of qualifiers who receive intervention. Defaults to 1.0 (100%). property_restrictions_list: Optiional list of Individual Properties to limit the intervention to. nodeIDs: Optiona list of node ids to target. Defaults to all. black_period: Undocumented. black_trigger: Undocumented. event_name: Undocumented. Returns: New campaign event that can be added to the campaign. """ schema_path = camp.schema_path intervention = s2c.get_class_with_defaults( "PropertyValueChanger", schema_path ) # Third, do the actual settings intervention.Target_Property_Key = property_to_change intervention.Target_Property_Value = final_prop_value intervention.Daily_Probability = daily_prob intervention.Maximum_Duration = -1 intervention.Revert = revert event = common.TriggeredCampaignEvent( camp=camp, Start_Day=start_day, Event_Name=event_name, Triggers=trigger_treatment_list, Intervention_List=[ intervention ], Node_Ids=nodeIDs, Duration=duration, Property_Restrictions=property_restrictions_list, Demographic_Coverage=coverage ) purge_campaign_event( event ) return event
[docs]def new_intervention_as_file( camp, filename="tpvc.json" ): camp.add( TPVC( camp, trigger_treatment_list=["Births"], property_to_change="Risk", final_prop_value="High" ) ) camp.save( filename ) return filename