Skip to content

Conversation

@marghe-molaro
Copy link
Collaborator

@marghe-molaro marghe-molaro commented Nov 20, 2025

This PR offers users the option to use an emulated version of the RTI module. It will require #1758 to run.

@tamuri, a couple of "conceptual" issues:

  • One of the advantages of using an emulator is the need for much fewer module-specific properties in the population dataframe. However, because properties are declared before parameters are initialised, it is not possible for the module to know a priori whether the user will opt to use the emulator or not, and hence how many properties to declare. Do you have any suggestions? Could I initially declare all properties and then remove redundant ones if parameter 'use_RTI_emulator' is initialised to True? (Not very elegant)
  • As discussed yesterday, I wanted to include a one-time warning for the user if the emulator is being used under the "wrong" HealthSystem assumptions. This would however require knowing how the HealthSystem parameters have been initialised, but this would require relying on a known order of parameter initialisation. Where can I issue this warning while avoid issuing this repeatedly during runtime?
  • There is some RTI-specific logic in the HealthSystem; in the future I think we would instead iterate over all modules to check if the use_{module}_emulator parameter is set to True for any of them. But is this ok for now?

Many thanks,
Margherita

Copy link
Collaborator

@tamuri tamuri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Marghertia. We could tidy this up by having a new EmulatedRTI class that is separate from the RTI class. If there are things that need to be shared, you could make a base class (e.g. BaseRTI) and have both RTI and EmulatedRTI inherit that. But you may not need to because most of the code is not run in the EmulatedRTI.

Each on these classes could have their own polling event class or, if they too share code (looks like it does) the common bits could be extracted into a shared helper function or, similarly, make a BaseRTIPollingEvent and have the simulated and emulated event class use/inherit.

This would avoid the long if-else blocks and keeps the emulated RTI stuff together and separate. You might not need the 'use_emulated' in the end because a different module will be registered at simulation start.

@@ -1,3 +1,4 @@
0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

'age_years', 'sex', 'prob_of_dying_before_next_poll']].copy()


# Artificially increase risk for men under 50 by 50
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be removed for the merge...?

self._write_hsi_event_counts_to_log_and_reset()
self._write_never_ran_hsi_event_counts_to_log_and_reset()


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extraneous newline

def write_to_log_and_reset_counters(self):
"""Log summary statistics reset the data structures. This usually occurs at the end of the year."""


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove newline

df.loc[DALYweightunderlimit, 'rt_disability'] = 0
assert (df.loc[injured_index, 'rt_disability'] > 0).all()


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove newline


def run_simulation_to(self, *, to_date: Date) -> None:
"""Run simulation up to a specified date.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rollback both changes in this file

Types.INT,
"limit on the number of times an HSI event can run"
),
'use_RTI_emulator': Parameter(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename this to use_emulator - you're already in RTI

@tamuri
Copy link
Collaborator

tamuri commented Nov 21, 2025

Also need to add some tests for emulated RTI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants