Skip to content

Comments

Albrja/mic 6764/treatment update#65

Merged
albrja merged 11 commits intomainfrom
albrja/mic-6764/treatment-update
Jan 23, 2026
Merged

Albrja/mic 6764/treatment update#65
albrja merged 11 commits intomainfrom
albrja/mic-6764/treatment-update

Conversation

@albrja
Copy link
Collaborator

@albrja albrja commented Jan 23, 2026

Albrja/mic 6764/treatment update

Update treatment model

Changes and notes

-updates Treatment disease model to only have 1 state for each treatment effect and waning
-update treatment ramp up to be time specific and not time and location specific
-update how "short" treatment is sampled
-add observer for treatment duration

Verification and Testing

-validated component updates and observer in interactive simulation

@@ -1,21 +1,21 @@
input_draw_count: 25
random_seed_count: 100
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't merge any changes to this file

WANING_EFFECT_SHORT_STATE: str = "waning_effect_short"
NO_EFFECT_AFTER_SHORT_STATE: str = "no_effect_after_short"
NO_EFFECT_AFTER_LONG_STATE: str = "no_effect_after_long"
TREATMENT_EFFECT: str = "treatment_effect"
Copy link
Contributor

Choose a reason for hiding this comment

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

Make sure to clarify these state name changes to Nathaniel b/c he'll need to update the notebook

configuration:
input_data:
input_draw_number: 0
artifact_path: '/mnt/team/simulation_science/pub/models/vivarium_csu_alzheimers/artifacts/model8.3/united_states_of_america.hdf'
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, probably best not to merge this change


Parameters
----------
step_size : int
Copy link
Contributor

Choose a reason for hiding this comment

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

I know AI did this, but don't add the type hints in the docstring (both under Parameters and under Returns). That's not DRY since we already type hint both in the signature.

"treatment_effect.dwell_time",
modifier=self.get_treatment_effect_duration,
component=self,
required_resources=[COLUMNS.TREATMENT_DURATION, "treatment_effect.dwell_time"],
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you really need to add the very pipeline that you're modifying as a required resource? That seems silly and easy to fix

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I guess I am not sure but it seems like I would want it.

self.population_view.subview(COLUMNS.TREATMENT_DURATION).get(index).squeeze()
)
# Treatment length is in months, target is dwell time in days (float)
effect_duration = (treatment_length / 9.0) * target
Copy link
Contributor

Choose a reason for hiding this comment

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

The "9.0" should be added as a constant to date_values.py, e.g. FULL_TREATMENT_DURATION

effect_duration = (effect_duration / self.step_size).round() * self.step_size
return effect_duration

def get_waning_effect_duration(
Copy link
Contributor

Choose a reason for hiding this comment

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

This is actually identical to the one above it. Delete this and rename the other one something like modify_dwell_time and then use that for both pipeline modifiers

full_effect_states = [
TREATMENT_DISEASE_MODEL.FULL_EFFECT_LONG_STATE,
TREATMENT_DISEASE_MODEL.FULL_EFFECT_SHORT_STATE,
# TODO: update to combine states, check artifact
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove todo


# Dwell times are number of days in waning effect
dwell_times = self.waning_dwell_time_pipeline(waning_mask[waning_mask].index)
dwell_times = dwell_times / (self.step_size() / pd.Timedelta(days=1))
Copy link
Contributor

Choose a reason for hiding this comment

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

This is confusing. Would this work?
dwell_times = dwell_times / pd.Timedelta(days=self.step_size())

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, doing the division is getting rid of the Timedelta units so it is then just 182 since dwell time is a series of floats for number of days.

return pop.squeeze(axis=1).dt.date.apply(semesterize)

def map_treatment_durations(self, pop: pd.DataFrame) -> pd.Series:
durations = pop.fillna(0.0)
Copy link
Contributor

Choose a reason for hiding this comment

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

If you just set everyone who didn't get treated to have a treatment duration of 0 instead of np.nan, you wouldn't need any mapping at all.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The idea is that in the interactive sim it might be confusing if someone has 0 months of treatment duration but they have never tested positive or ultimately had the chance to be treated. Maybe you wouldn't find that confusing? I do not feel strongly.

@albrja albrja merged commit 66b901d into main Jan 23, 2026
3 checks passed
@albrja albrja deleted the albrja/mic-6764/treatment-update branch January 23, 2026 19:15
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