Linear Scale-Up Model
This module contains tools for applying a linear scale-up to an intervention
- class vivarium_public_health.treatment.scale_up.LinearScaleUp(treatment)[source]
Apply a linear scale-up to intervention coverage over a configured time period.
This component linearly interpolates an intervention’s exposure parameter between a start value and an end value over a specified date range. Before the start date, the start value is used; after the end date, the end value is used. Endpoint values can be sourced from artifact data or from scalar parameters in the configuration.
For example, for an intervention called
treatmentthe configuration could look like this:configuration: treatment_scale_up: date: start: "2020-01-01" end: "2020-12-31" value: start: 0.0 end: 0.9
- Parameters:
treatment (str)
- CONFIGURATION_DEFAULTS: dict[str, Any] = {'treatment': {'date': {'end': '2020-12-31', 'start': '2020-01-01'}, 'value': {'end': 'data', 'start': 'data'}}}
A dictionary containing the defaults for any configurations managed by this component. An empty dictionary indicates no managed configurations. Components will look for a
data_sourcesblock in this dictionary to build lookup tables automatically.
- property configuration_defaults: dict[str, Any]
Provides default configuration values for this component.
Configuration structure:
{treatment_name}_scale_up: date: start: str Start date for the scale-up period in ISO format (``"YYYY-MM-DD"``). Default is ``"2020-01-01"``. end: str End date for the scale-up period in ISO format. Default is ``"2020-12-31"``. value: start: str or float Value at the start of scale-up. Can be ``"data"`` to load from artifact, or a numeric value. Default is ``"data"``. end: str or float Value at the end of scale-up. Can be ``"data"`` to load from artifact, or a numeric value. Default is ``"data"``.The scale-up linearly interpolates between start and end values over the specified date range. Outside this range, values are clamped to the nearest endpoint value.
- setup(builder)[source]
Set up the component by loading dates, values, and registering the modifier.
- get_is_intervention_scenario(builder)[source]
Determine whether the current simulation is an intervention scenario.
- get_scale_up_dates(builder)[source]
Load the scale-up start and end dates from the configuration.
- Parameters:
builder (
Builder) – Access point for utilizing framework interfaces during setup.- Return type:
tuple[Timestamp,Timestamp]- Returns:
A tuple of
(start_date, end_date)aspandas.Timestampobjects.
- get_scale_up_values(builder)[source]
Get the values at the start and end of the scale-up period.
- Parameters:
builder (
Builder) – Interface to access simulation managers.- Return type:
- Returns:
A tuple of lookup tables returning the values at the start and end of the scale-up period.
- register_intervention_modifiers(builder)[source]
Register the coverage effect modifier on the treatment’s exposure pipeline.
- coverage_effect(idx, target)[source]
Modify the treatment’s exposure parameters based on the current scale-up progress.
Compute the linear interpolation progress between the scale-up start and end dates, then apply
apply_scale_up()to adjust the target values.- Parameters:
idx (
Index) – Index of the simulants to modify.target (
Series) – Current exposure parameter values for the given simulants.
- Return type:
Series- Returns:
The modified exposure parameter values.
- get_endpoint_value_from_data(builder, endpoint_type)[source]
Get the value at the start or end of the scale-up period from data.
- Parameters:
- Return type:
- Returns:
A lookup table returning the value at the start or end of the scale-up period.
- apply_scale_up(idx, target, scale_up_progress)[source]
Apply the linearly interpolated scale-up adjustment to the target values.
The adjustment is computed as:
adjustment = progress * (end_value - start_value)
and is added to the current target values.
- Parameters:
idx (
Index) – Index of the simulants to modify.target (
Series) – Current target values.scale_up_progress (
float) – A float between 0.0 and 1.0 representing how far through the scale-up period the simulation has progressed.
- Return type:
Series- Returns:
The target values with the scale-up adjustment applied.