Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cohort update time condition #395

Merged
merged 1 commit into from
Jul 18, 2024

Conversation

acavelan
Copy link
Collaborator

@acavelan acavelan commented Jul 18, 2024

Human cohort membership is tested and updated in 3 places:

Human::isInSubPop() mostly used during the deployment of interventions, just before the beginning of the time-step

Human::updateCohortSet() used during the Clinical model update, at the beginning of Human::update()

Human::removeFirstEvent() used during the Clinical model update and and just after a survey.

However, updateCohortSet() used the following condition:

if( duration >= sim::nowOrTs0() )

while isInSubPop() and removeFirstEvent() used:

if( duration > sim::nowOrTs0() )

Given that all of these tests are done in the same time-frame (after a survey, before the end of the time-step), they must use the same condition.

Old time-line example:

  • Cohort created at time t with duration 2
    • Time-step update
    • Cohort update: t + 2 >= t: nothing to do
  • Cohort deployment with isInSubPop: t + 2 > t + 1: nothing to do
    • Time-step update
    • Cohort update: t + 2 >= t + 1: nothing to do
  • Cohort deployment with isInSubPop: t + 2 > t + 2: nothing to do
    • Time-step update
    • Cohort update: t + 2 >= t + 2: human removed from cohort

New time-line example:

  • Cohort created at time t with duration 2
    • Time-step update
    • Cohort update: t + 2 >= t: nothing to do
  • Cohort deployment with isInSubPop: t + 2 >= t + 1: nothing to do
    • Time-step update
    • Cohort update: t + 2 >= t + 1: nothing to do
  • Cohort deployment with isInSubPop: t + 2 >= t + 2: human no longer in the cohort
    • Time-step update
    • Cohort update: t + 2 >= t + 2: human removed from cohort

Note that the change has no effect on the tests. This only affect intervention deployment conditional on cohort membership, when duration is finite, wihich is a specific case that is not part of the test suite yet.

@acavelan acavelan requested a review from melissapenny July 18, 2024 08:39
Copy link
Collaborator

@melissapenny melissapenny left a comment

Choose a reason for hiding this comment

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

Thank you for the fix, well spotted

@acavelan acavelan merged commit 4678bbd into SwissTPH:main Jul 18, 2024
8 checks passed
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.

2 participants