interventions
interventions
Define interventions, which are used to modify the state of the sim during run.
Interventions typically include things like testing, treatment, and vaccination.
Classes
Name | Description |
---|---|
BaseScreening | Base class for screening. |
BaseTest | Base class for screening and triage. |
BaseTreatment | Base treatment class. |
BaseTriage | Base class for triage. |
BaseVaccination | Base vaccination class for determining who will receive a vaccine. |
CampaignDelivery | Base class for any intervention that uses campaign delivery; handles interpolation of input years. |
Intervention | Base class for interventions. |
RoutineDelivery | Base class for any intervention that uses routine delivery; handles interpolation of input years. |
campaign_screening | Campaign screening - an instance of base screening combined with campaign delivery. |
campaign_triage | Campaign triage - an instance of base triage combined with campaign delivery. |
campaign_vx | Campaign vaccination - an instance of base vaccination combined with campaign delivery. |
routine_screening | Routine screening - an instance of base screening combined with routine delivery. |
routine_triage | Routine triage - an instance of base triage combined with routine delivery. |
routine_vx | Routine vaccination - an instance of base vaccination combined with routine delivery. |
treat_num | Treat a fixed number of people each timestep. |
BaseScreening
interventions.BaseScreening(self,
=None,
product=None,
prob=None,
eligibility**kwargs,
)
Base class for screening.
Parameters
Name | Type | Description | Default |
---|---|---|---|
kwargs | dict | passed to BaseTest | {} |
Methods
Name | Description |
---|---|
step | Perform screening by finding who’s eligible, finding who accepts, and applying the product. |
step
interventions.BaseScreening.step()
Perform screening by finding who’s eligible, finding who accepts, and applying the product.
BaseTest
interventions.BaseTest(self,
=None,
product=None,
prob=None,
eligibility**kwargs,
)
Base class for screening and triage.
Parameters
Name | Type | Description | Default |
---|---|---|---|
product | (Product) | the diagnostic to use | None |
prob | (float/arr) | annual probability of eligible people receiving the diagnostic | None |
eligibility | (inds/callable) | indices OR callable that returns inds | None |
kwargs | (dict) | passed to Intervention() | {} |
Methods
Name | Description |
---|---|
check_eligibility | Return an array of indices of agents eligible for screening at time t, |
deliver | Deliver the diagnostics by finding who’s eligible, finding who accepts, and applying the product. |
check_eligibility
interventions.BaseTest.check_eligibility()
Return an array of indices of agents eligible for screening at time t, e.g. matching demographic characteristics
deliver
interventions.BaseTest.deliver()
Deliver the diagnostics by finding who’s eligible, finding who accepts, and applying the product.
BaseTreatment
interventions.BaseTreatment(self,
=None,
product=None,
prob=None,
eligibility**kwargs,
)
Base treatment class.
Parameters
Name | Type | Description | Default |
---|---|---|---|
product | (str/Product) | the treatment product to use | None |
prob | (float/arr) | probability of treatment aong those eligible | None |
eligibility | (inds/callable) | indices OR callable that returns inds | None |
kwargs | (dict) | passed to Intervention() | {} |
Methods
Name | Description |
---|---|
get_accept_inds | Get indices of people who will acccept treatment; these people are then added to a queue or scheduled for receiving treatment |
get_candidates | Get candidates for treatment on this timestep. Implemented by derived classes. |
step | Perform treatment by getting candidates, checking their eligibility, and then treating them. |
get_accept_inds
interventions.BaseTreatment.get_accept_inds()
Get indices of people who will acccept treatment; these people are then added to a queue or scheduled for receiving treatment
get_candidates
interventions.BaseTreatment.get_candidates()
Get candidates for treatment on this timestep. Implemented by derived classes.
step
interventions.BaseTreatment.step()
Perform treatment by getting candidates, checking their eligibility, and then treating them.
BaseTriage
interventions.BaseTriage(self,
=None,
product=None,
prob=None,
eligibility**kwargs,
)
Base class for triage.
Parameters
Name | Type | Description | Default |
---|---|---|---|
kwargs | dict | passed to BaseTest | {} |
BaseVaccination
interventions.BaseVaccination(self,
*args,
=None,
product=None,
prob=None,
label**kwargs,
)
Base vaccination class for determining who will receive a vaccine.
Parameters
Name | Type | Description | Default |
---|---|---|---|
product | (str/Product) | the vaccine to use | None |
prob | (float/arr) | annual probability of eligible population getting vaccinated | None |
label | (str) | the name of vaccination strategy | None |
kwargs | (dict) | passed to Intervention() | {} |
Methods
Name | Description |
---|---|
step | Deliver the diagnostics by finding who’s eligible, finding who accepts, and applying the product. |
step
interventions.BaseVaccination.step()
Deliver the diagnostics by finding who’s eligible, finding who accepts, and applying the product.
CampaignDelivery
interventions.CampaignDelivery(self,
*args,
=None,
years=None,
interpolate=None,
prob**kwargs,
)
Base class for any intervention that uses campaign delivery; handles interpolation of input years.
Intervention
self, *args, eligibility=None, **kwargs) interventions.Intervention(
Base class for interventions.
The key method of the intervention is step()
, which is called with the sim on each timestep.
Attributes
Name | Description |
---|---|
has_product | Check if the intervention has a product |
Methods
Name | Description |
---|---|
check_eligibility | Return an array of indices of agents eligible for screening at time t |
check_eligibility
interventions.Intervention.check_eligibility()
Return an array of indices of agents eligible for screening at time t
RoutineDelivery
interventions.RoutineDelivery(self,
*args,
=None,
years=None,
start_year=None,
end_year=None,
prob=True,
annual_prob**kwargs,
)
Base class for any intervention that uses routine delivery; handles interpolation of input years.
campaign_screening
interventions.campaign_screening(self,
=None,
product=None,
prob=None,
eligibility**kwargs,
)
Campaign screening - an instance of base screening combined with campaign delivery. See base classes for a description of input arguments.
Examples:
screen1 = ss.campaign_screening(product=my_prod, prob=0.2, years=2030) # Screen 20% of the eligible population in 2020
screen2 = ss.campaign_screening(product=my_prod, prob=0.02, years=[2025,2030]) # Screen 20% of the eligible population in 2025 and again in 2030
campaign_triage
interventions.campaign_triage(self,
=None,
product=None,
prob=None,
eligibility**kwargs,
)
Campaign triage - an instance of base triage combined with campaign delivery. See base classes for a description of input arguments.
Examples: # Example: In 2030, triage all positive screens into confirmatory testing screened_pos = lambda sim: sim.interventions.screening.outcomes[‘positive’] triage1 = ss.campaign_triage(product=my_triage, eligibility=screen_pos, prob=0.9, years=2030)
campaign_vx
interventions.campaign_vx(self,
*args,
=None,
product=None,
prob=None,
label**kwargs,
)
Campaign vaccination - an instance of base vaccination combined with campaign delivery. See base classes for a description of input arguments.
routine_screening
interventions.routine_screening(self,
=None,
product=None,
prob=None,
eligibility**kwargs,
)
Routine screening - an instance of base screening combined with routine delivery. See base classes for a description of input arguments.
Examples:
screen1 = ss.routine_screening(product=my_prod, prob=0.02) # Screen 2% of the eligible population every year
screen2 = ss.routine_screening(product=my_prod, prob=0.02, start_year=2020) # Screen 2% every year starting in 2020
screen3 = ss.routine_screening(product=my_prod, prob=np.linspace(0.005,0.025,5), years=np.arange(2020,2025)) # Scale up screening over 5 years starting in 2020
routine_triage
interventions.routine_triage(self,
=None,
product=None,
prob=None,
eligibility**kwargs,
)
Routine triage - an instance of base triage combined with routine delivery. See base classes for a description of input arguments.
Example: # Example: Triage positive screens into confirmatory testing screened_pos = lambda sim: sim.interventions.screening.outcomes[‘positive’] triage = ss.routine_triage(product=my_triage, eligibility=screen_pos, prob=0.9, start_year=2030)
routine_vx
interventions.routine_vx(self,
*args,
=None,
product=None,
prob=None,
label**kwargs,
)
Routine vaccination - an instance of base vaccination combined with routine delivery. See base classes for a description of input arguments.
treat_num
self, max_capacity=None, **kwargs) interventions.treat_num(
Treat a fixed number of people each timestep.
Parameters
Name | Type | Description | Default |
---|---|---|---|
max_capacity | int | maximum number who can be treated each timestep | None |
Methods
Name | Description |
---|---|
add_to_queue | Add people who are willing to accept treatment to the queue |
get_candidates | Get the indices of people who are candidates for treatment |
step | Apply treatment. On each timestep, this method will add eligible people who are willing to accept treatment to a |
add_to_queue
interventions.treat_num.add_to_queue()
Add people who are willing to accept treatment to the queue
get_candidates
interventions.treat_num.get_candidates()
Get the indices of people who are candidates for treatment
step
interventions.treat_num.step()
Apply treatment. On each timestep, this method will add eligible people who are willing to accept treatment to a queue, and then will treat as many people in the queue as there is capacity for.