-
Notifications
You must be signed in to change notification settings - Fork 2
Change hospitalization in measles models to pre-computed assignment #143
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
base: master
Are you sure you want to change the base?
Conversation
…mpling - Add `hospitalize_if_infected` vector to ModelMeaslesMixingRiskQuarantine, ModelMeaslesMixing, and ModelMeaslesSchool - Pre-compute hospitalization status in reset() method for each agent - Modify m_update_rash and m_update_isolated to use pre-computed vector: agents either go to Hospitalized or Recovered when recovering from rash - Update test files to reflect new transition probability calculations: Rash→Hospitalized = (1/RashPeriod) × HospitalizationRate Rash→Recovered = (1/RashPeriod) × (1 - HospitalizationRate) Co-authored-by: gvegayon <893619+gvegayon@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #143 +/- ##
==========================================
- Coverage 88.53% 88.47% -0.06%
==========================================
Files 53 53
Lines 4647 4623 -24
==========================================
- Hits 4114 4090 -24
Misses 533 533 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request changes how hospitalization works in measles models by pre-computing hospitalization outcomes at simulation initialization rather than sampling daily during the rash period. This makes the hospitalization rate parameter more interpretable as a true population-level rate rather than a competing hazard probability.
Key changes:
- Added
hospitalize_if_infectedboolean vector to all three measles models, sampled once duringreset()based on the hospitalization rate parameter - Modified
m_update_rashandm_update_isolatedupdate functions to check pre-computed hospitalization status deterministically when agents recover from rash - Updated test expectations to reflect new probability model where hospitalization is determined at recovery rather than competing daily with recovery
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
include/epiworld/models/measlesschool.hpp |
Added hospitalize_if_infected vector, pre-computed in reset(), and modified rash/isolated update functions to use it deterministically |
include/epiworld/models/measlesmixing.hpp |
Same pattern as measlesschool, plus added getter method for hospitalization vector and replaced resize()+std::fill() with assign() |
include/epiworld/models/measlesmixingriskquarantine.hpp |
Same pattern as other models but with bug: hospitalization from isolated state ignores unisolate flag |
epiworld.hpp |
Single header file reflecting all changes from individual headers, including the same bug in ModelMeaslesMixingRiskQuarantine |
tests/14a-measles.cpp |
Updated probability calculations and fixed incorrect state labels in comments (prodromal→rash, rash→isolated) |
tests/14b-measles.cpp |
Updated probability calculations and fixed incorrect state labels in comments |
tests/19a-measles-mixing.cpp |
Updated probability calculations for new competing hazard model |
tests/19b-measles-mixing.cpp |
Updated probability calculations for new competing hazard model |
tests/20a-measles-mixing-risk-quarantine-basic.cpp |
Updated probability calculations for new competing hazard model |
tests/20b-measles-mixing-risk-quarantine-transitions.cpp |
Updated probability calculations and transition expectations |
| // Check pre-computed hospitalization: if marked, go to hospitalized | ||
| if (model->hospitalize_if_infected[p->get_id()]) | ||
| { | ||
| p->change_state(m, DETECTED_HOSPITALIZED); |
Copilot
AI
Dec 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hospitalization transition from isolated state should respect the unisolate flag. When unisolate is true, the agent should transition to HOSPITALIZED, not DETECTED_HOSPITALIZED. This is inconsistent with the implementations in ModelMeaslesSchool and ModelMeaslesMixing, which both use a ternary operator to check unisolate.
| p->change_state(m, DETECTED_HOSPITALIZED); | |
| p->change_state(m, unisolate ? HOSPITALIZED : DETECTED_HOSPITALIZED); |
| // Check pre-computed hospitalization: if marked, go to hospitalized | ||
| if (model->hospitalize_if_infected[p->get_id()]) | ||
| { | ||
| p->change_state(m, DETECTED_HOSPITALIZED); |
Copilot
AI
Dec 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hospitalization transition from isolated state should respect the unisolate flag. When unisolate is true, the agent should transition to HOSPITALIZED, not DETECTED_HOSPITALIZED. This is inconsistent with the implementations in ModelMeaslesSchool and ModelMeaslesMixing, which both use a ternary operator to check unisolate.
| p->change_state(m, DETECTED_HOSPITALIZED); | |
| p->change_state(m, unisolate ? HOSPITALIZED : DETECTED_HOSPITALIZED); |
Hospitalization was being sampled daily during the rash period. This PR changes it to pre-compute which agents will be hospitalized at simulation start, making the parameter easier to interpret as a true rate.
Model changes
hospitalize_if_infectedvector pre-computed inreset()using the hospitalization rate parameterm_update_rashandm_update_isolatednow check this vector when recovering from rash:ModelMeaslesMixingRiskQuarantine,ModelMeaslesMixing,ModelMeaslesSchoolTransition probability changes
Old (daily competing hazard):
New (deterministic at recovery):
Notes
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.