tlo.methods.scenario_switcher module

class ScenarioSwitcher(name=None, resourcefilepath=None)[source]

The ScenarioSwitcher module. This is a utility module that can be used to make changes to parameters in registered simulation models, including parameters of the form pd.Series and pd.DataFrame that cannot be changed via the Scenario class (see It loads 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.

Bases: tlo.core.Module







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



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

Class attributes:


METADATA : set()


Functions (defined or overridden in class ScenarioSwitcher):

__init__(name=None, resourcefilepath=None)[source]

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

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


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


Default values for parameters. These are hard-coded.


Set our property values for the initial population.

Must be implemented by subclasses.

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.

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


population – the population of individuals


Retrieve parameters to be updated and update them in the other registered disease modules.


Get ready for simulation start.

Must be implemented by subclasses.

This method is called just before the main simulation loop begins, and after all modules have read their parameters and the initial population has been created. It is a good place to add initial events to the event queue.

on_birth(mother_id, child_id)[source]

Initialise our properties for a newborn individual.

Must be implemented by subclasses.

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

  • mother – the mother for this child (can be -1 if the mother is not identified).

  • child – the new child