Disease States

This module contains tools to manage standard disease states.

class vivarium_public_health.disease.state.BaseDiseaseState(state_id, allow_self_transition=False, side_effect_function=None, cause_type='cause')[source]
Parameters:
  • state_id (str) –

  • allow_self_transition (bool) –

  • side_effect_function (Callable | None) –

  • cause_type (str) –

property columns_created

Provides names of columns created by the component.

Returns:

Names of the columns created by this component, or an empty list if none.

Return type:

List[str]

property columns_required: List[str] | None

Provides names of columns required by the component.

Returns:

Names of required columns not created by this component. An empty list means all available columns are needed. None means no additional columns are necessary.

Return type:

Optional[List[str]]

property initialization_requirements: Dict[str, List[str]]

Provides the names of all values required by this component during simulant initialization.

Returns:

A dictionary containing the additional requirements of this component during simulant initialization. An omitted key or an empty list for a key implies no requirements for that key during initialization.

Return type:

Dict[str, List[str]]

on_initialize_simulants(pop_data)[source]

Adds this state’s columns to the simulation state table.

Parameters:

pop_data (SimulantData) –

Return type:

None

get_initialization_parameters()[source]

Exclude side effect function and cause type from name and __repr__.

Return type:

Dict[str, Any]

get_initial_event_times(pop_data)[source]
Parameters:

pop_data (SimulantData) –

Return type:

DataFrame

transition_side_effect(index, event_time)[source]

Updates the simulation state and triggers any side effects associated with this state.

Parameters:
  • index (Index) – An iterable of integer labels for the simulants.

  • event_time (pandas.Timestamp) – The time at which this transition occurs.

Return type:

None

get_transition_names()[source]
Return type:

List[str]

add_rate_transition(output, get_data_functions=None, triggered=Trigger.NOT_TRIGGERED)[source]

Builds a RateTransition from this state to the given state.

Parameters:
  • output (BaseDiseaseState) – The end state after the transition.

  • get_data_functions (Dict[str, Callable]) – map from transition type to the function to pull that transition’s data

  • triggered

Returns:

The created transition object.

Return type:

RateTransition

add_proportion_transition(output, get_data_functions=None, triggered=Trigger.NOT_TRIGGERED)[source]

Builds a ProportionTransition from this state to the given state.

Parameters:
  • output (BaseDiseaseState) – The end state after the transition.

  • get_data_functions (Dict[str, Callable]) – map from transition type to the function to pull that transition’s data

Returns:

The created transition object.

Return type:

RateTransition

add_dwell_time_transition(output, triggered=Trigger.NOT_TRIGGERED)[source]
Parameters:

output (BaseDiseaseState) –

Return type:

Transition

class vivarium_public_health.disease.state.NonDiseasedState(state_id, allow_self_transition=False, side_effect_function=None, cause_type='cause', name_prefix='')[source]
Parameters:
  • state_id (str) –

  • allow_self_transition (bool) –

  • side_effect_function (Callable | None) –

  • cause_type (str) –

  • name_prefix (str) –

add_rate_transition(output, get_data_functions=None, **kwargs)[source]

Builds a RateTransition from this state to the given state.

Parameters:
  • output (BaseDiseaseState) – The end state after the transition.

  • get_data_functions (Dict[str, Callable]) – map from transition type to the function to pull that transition’s data

  • triggered

Returns:

The created transition object.

Return type:

RateTransition

class vivarium_public_health.disease.state.SusceptibleState(state_id, allow_self_transition=False, side_effect_function=None, cause_type='cause')[source]
Parameters:
  • state_id (str) –

  • allow_self_transition (bool) –

  • side_effect_function (Callable | None) –

  • cause_type (str) –

class vivarium_public_health.disease.state.RecoveredState(state_id, allow_self_transition=False, side_effect_function=None, cause_type='cause')[source]
Parameters:
  • state_id (str) –

  • allow_self_transition (bool) –

  • side_effect_function (Callable | None) –

  • cause_type (str) –

class vivarium_public_health.disease.state.DiseaseState(state_id, allow_self_transition=False, side_effect_function=None, cause_type='cause', get_data_functions=None, cleanup_function=None)[source]

State representing a disease in a state machine model.

Parameters:
setup(builder)[source]

Performs this component’s simulation setup.

Parameters:

builder (engine.Builder) – Interface to several simulation tools.

Return type:

None

load_prevalence_data(builder)[source]
Parameters:

builder (Builder) –

Return type:

Number | timedelta | datetime | DataFrame | List[Number | timedelta | datetime] | Tuple[Number | timedelta | datetime]

get_prevalence(builder, prevalence_data)[source]

Builds a LookupTable for the prevalence of this state.

Parameters:
Returns:

The LookupTable for the prevalence of this state.

Return type:

LookupTable

load_birth_prevalence_data(builder)[source]
Parameters:

builder (Builder) –

Return type:

Number | timedelta | datetime | DataFrame | List[Number | timedelta | datetime] | Tuple[Number | timedelta | datetime]

get_birth_prevalence(builder, birth_prevalence_data)[source]

Builds a LookupTable for the birth prevalence of this state.

Parameters:
Returns:

The LookupTable for the birth prevalence of this state.

Return type:

LookupTable

load_dwell_time_data(builder)[source]
Parameters:

builder (Builder) –

Return type:

Number | timedelta | datetime | DataFrame | List[Number | timedelta | datetime] | Tuple[Number | timedelta | datetime]

get_dwell_time_pipeline(builder, dwell_time_data)[source]
Parameters:
Return type:

Pipeline

load_disability_weight_data(builder)[source]
Parameters:

builder (Builder) –

Return type:

Number | timedelta | datetime | DataFrame | List[Number | timedelta | datetime] | Tuple[Number | timedelta | datetime]

get_base_disability_weight(builder, disability_weight_data)[source]

Builds a LookupTable for the base disability weight of this state.

Parameters:
Returns:

The LookupTable for the disability weight of this state.

Return type:

LookupTable

get_disability_weight_pipeline(builder)[source]
Parameters:

builder (Builder) –

Return type:

Pipeline

load_excess_mortality_rate_data(builder)[source]
Parameters:

builder (Builder) –

Return type:

Number | timedelta | datetime | DataFrame | List[Number | timedelta | datetime] | Tuple[Number | timedelta | datetime]

get_base_excess_mortality_rate(builder, excess_mortality_data)[source]

Builds a LookupTable for the base excess mortality rate of this state.

Parameters:
Returns:

The LookupTable for the base excess mortality rate of this state.

Return type:

LookupTable

get_excess_mortality_rate_pipeline(builder)[source]
Parameters:

builder (Builder) –

Return type:

Pipeline

get_joint_paf(builder)[source]
Parameters:

builder (Builder) –

Return type:

Pipeline

get_randomness_prevalence(builder)[source]
Parameters:

builder (Builder) –

Return type:

RandomnessStream

add_rate_transition(output, get_data_functions=None, **kwargs)[source]

Builds a RateTransition from this state to the given state.

Parameters:
  • output (BaseDiseaseState) – The end state after the transition.

  • get_data_functions (Dict[str, Callable]) – map from transition type to the function to pull that transition’s data

  • triggered

Returns:

The created transition object.

Return type:

RateTransition

add_dwell_time_transition(output, **kwargs)[source]
Parameters:

output (BaseDiseaseState) –

Return type:

Transition

next_state(index, event_time, population_view)[source]

Moves a population among different disease states.

Parameters:
  • index (Index) – An iterable of integer labels for the simulants.

  • event_time (Timestamp) – The time at which this transition occurs.

  • population_view (PopulationView) – A view of the internal state of the simulation.

Return type:

None

compute_disability_weight(index)[source]

Gets the disability weight associated with this state.

Parameters:

index (Index) – An iterable of integer labels for the simulants.

Returns:

An iterable of disability weights indexed by the provided index.

Return type:

pandas.Series

compute_excess_mortality_rate(index)[source]
Parameters:

index (Index) –

Return type:

Series

adjust_mortality_rate(index, rates_df)[source]

Modifies the baseline mortality rate for a simulant if they are in this state.

Parameters:
  • index (Index) – An iterable of integer labels for the simulants.

  • rates_df (pandas.DataFrame) –

Return type:

DataFrame

get_initial_event_times(pop_data)[source]
Parameters:

pop_data (SimulantData) –

Return type:

DataFrame

with_condition(index)[source]
Parameters:

index (Index) –

Return type:

Index

class vivarium_public_health.disease.state.TransientDiseaseState(state_id, allow_self_transition=False, side_effect_function=None, cause_type='cause')[source]
Parameters:
  • state_id (str) –

  • allow_self_transition (bool) –

  • side_effect_function (Callable | None) –

  • cause_type (str) –