tlo.methods.scenario_switcher module

class ImprovedHealthSystemAndCareSeekingScenarioSwitcher(name=None, resourcefilepath=None)

This is the ImprovedHealthSystemAndCareSeekingScenarioSwitcher module. It provides switches that can be used by the Scenario class to control the overall performance of the HealthSystem and healthcare seeking, which are mediated by many parameters across many modules, and which are of the types pd.Series and pd.DataFrame, which cannot be changed via the Scenario class (see https://github.com/UCL/TLOmodel/issues/988). It does this by loading a ResourceFile that contains parameter value to be updated, and makes these changes at the point pre_initialise_population. As this module is declared as an (Optional) dependency of the module that would be loaded first in the simulation (i.e. Demography), this module is registered first and so this module’s pre_initialise_population method is called before any other. This provides a close approximation to what would happen if the parameters were being changed by the Scenario class.

Construct a new disease module ready to be included in a simulation.

Initialises an empty parameters dictionary and module-specific random number generator.

Parameters:

name – the name to use for this module. Defaults to the concrete subclass’ name.

Bases: tlo.core.Module

PARAMETERS:

Item

Type

Description

max_healthsystem_function

LIST

If True, over-writes parameters that define maximal health system function.Parameter passed through to get_parameters_for_improved_healthsystem_and_healthcare_seeking.

max_healthcare_seeking

LIST

If True, over-writes parameters that define maximal healthcare-seeking behaviour. Parameter passed through to get_parameters_for_improved_healthsystem_and_healthcare_seeking.

year_of_switch

INT

The year in which the state changes. The state changes on 1st January of that year.

Class attributes:

INIT_DEPENDENCIES : set()

METADATA : set()

OPTIONAL_INIT_DEPENDENCIES : set()

__annotations__ : {}

Functions (defined or overridden in class ImprovedHealthSystemAndCareSeekingScenarioSwitcher):

__init__(name=None, resourcefilepath=None)

Construct a new disease module ready to be included in a simulation.

Initialises an empty parameters dictionary and module-specific random number generator.

Parameters:

name – the name to use for this module. Defaults to the concrete subclass’ name.

read_parameters(data_folder)

Read-in parameters and process them into the internal storage structures required.

pre_initialise_population()

Set the parameters for the first period of the simulation. Note that this is happening here and not in initialise_simulation because we want to make sure that the parameters are changed before other modules call pre_initialise_population. We ensure that this module’s method is the first to be called as this module is declared as an (Optional) dependency of the module that is loaded first in the simulation (i.e. Demography). This provides a close approximation to what would happen if the parameters were being changed by the Scenario class.

update_parameters()

Update the parameters in the simulation’s modules.

initialise_population(population)

Set our property values for the initial population.

This method is called by the simulation when creating the initial population, and is responsible for assigning initial values, for every individual, of those properties ‘owned’ by this module, i.e. those declared in its PROPERTIES dictionary.

By default, all Property``s in ``self.PROPERTIES will have their columns in the population dataframe set to the default value.

Modules that wish to implement this behaviour do not need to implement this method, it will be inherited automatically. Modules that wish to perform additional steps during the initialise_population stage should reimplement this method and call

`python super().initialise_population(population=population) `

at the beginning of the method, then proceed with their additional steps. Modules that do not wish to inherit this default behaviour should re-implement initialise_population without the call to super() above.

TODO: We probably need to declare somehow which properties we ‘read’ here, so the simulation knows what order to initialise modules in!

Parameters:

population – The population of individuals in the simulation.

initialise_simulation(sim)

Schedule an event at which the parameters are changed.

on_birth(mother_id, child_id)

Initialise our properties for a newborn individual.

Must be implemented by subclasses.

This is called by the simulation whenever a new person is born.

Parameters:
  • mother_id – the person id for the mother of this child (can be -1 if the mother is not identified).

  • child_id – the person id of new child

class ScenarioSwitchEvent(module)

Create a new event.

Note that just creating an event does not schedule it to happen; that must be done by calling Simulation.schedule_event.

Parameters:
  • module – the module that created this event. All subclasses of Event take this as the first argument in their constructor, but may also take further keyword arguments.

  • priority – a keyword-argument to set the priority (see Priority enum)

Bases: tlo.events.Event, tlo.events.PopulationScopeEventMixin

Class attributes:

__annotations__ : {}

Functions (defined or overridden in class ScenarioSwitchEvent):

__init__(module)

Create a new event.

Note that just creating an event does not schedule it to happen; that must be done by calling Simulation.schedule_event.

Parameters:
  • module – the module that created this event. All subclasses of Event take this as the first argument in their constructor, but may also take further keyword arguments.

  • priority – a keyword-argument to set the priority (see Priority enum)

apply(population)

Run the function that updates the simulation parameters.