-
Notifications
You must be signed in to change notification settings - Fork 16
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
1081 rework ABM state transitions #1107
base: main
Are you sure you want to change the base?
Conversation
…e-state-transitions-in-the-infection
…e-state-transitions-in-the-infection
Signed-off-by: DavidKerkmann <[email protected]>
Signed-off-by: DavidKerkmann <[email protected]>
…state-transitions-in-the-infection
…e-state-transitions-in-the-infection
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1107 +/- ##
==========================================
- Coverage 96.97% 96.30% -0.67%
==========================================
Files 148 149 +1
Lines 13718 14061 +343
==========================================
+ Hits 13303 13542 +239
- Misses 415 519 +104 ☔ View full report in Codecov by Sentry. |
…m/SciCompMod/memilio into 1081-rework-abm-state-transitions
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.
Thank you for the implementation!
Apart from some smaller things, we could talk again about the detailed implementation of the distributions, I think @reneSchm will have some more comments and ideas once he has taken a deeper look. Many lines from the param distribtuions are listed as not tested, this could be fixed afterwards.
Related issues that will be closed should be linked correctly. We can have a look together, so that we also know what has to be done next.
// Distribution that can be used for the time spend in InfectionStates | ||
using InfectionStateTimesDistributionsParameters = LogNormalDistribution<double>::ParamType; | ||
|
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.
// Distribution that can be used for the time spend in InfectionStates | |
using InfectionStateTimesDistributionsParameters = LogNormalDistribution<double>::ParamType; |
* @brief Individual virus shed factor to account for variability in infectious viral load spread. | ||
*/ | ||
struct VirusShedFactor { | ||
using Type = CustomIndexArray<UniformDistribution<double>::ParamType, VirusVariant, AgeGroup>; |
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.
I'd make this and all other parameters where a fixed distribution is hardcoded also changable through the wrapper.
std::min(std::max(min_val, (1 - dev_rel * 2.6) * v), 0.1 * std::numeric_limits<double>::max()), | ||
std::min(std::max(min_val, (1 + dev_rel * 2.6) * v), 0.5 * std::numeric_limits<double>::max()), |
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.
One could use the definitions from lower_bound and upper_bound from above.
@@ -34,7 +35,7 @@ LocationType random_mobility(PersonalRandomNumberGenerator& rng, const Person& p | |||
auto make_transition = [current_loc](auto l) { | |||
return std::make_pair(l, l == current_loc ? 0. : 1.); | |||
}; | |||
if (t < params.get<LockdownDate>()) { | |||
if (t < params.get<mio::abm::LockdownDate>()) { |
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.
Is the mio::abm::
suddenly needed here (and below)?
/** | ||
* @brief Time that a Person is infected but not yet infectious. | ||
* @brief Time that a Person is infected but not yet infectious in day unit | ||
*/ | ||
struct IncubationPeriod { |
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.
I thought a bit more about the naming and came to the conclusion that IncubationPeriod doesn't really fit, as it usually describes the time from Exposure to the first Symptoms. Therefore, we should rename it. Perhaps ExposedToInfectedNoSymptoms
?
@@ -56,139 +57,184 @@ std::vector<Model> ensemble_params_percentile(const std::vector<std::vector<Mode | |||
auto& new_params = get_param(percentile[n]); | |||
new_params = single_element[static_cast<size_t>(num_runs * p)]; | |||
}; | |||
mio::unused(param_percentile); |
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.
mio::unused(param_percentile); |
return model.parameters.template get<IncubationPeriod>()[{virus_variant, age_group}]; | ||
}, | ||
[](auto& dist1, auto& dist2) { | ||
return dist1.params()[0] < dist2.params()[0]; |
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.
I am not sure if always using the first param is a good idea for ordering in general, but it is a good default case. Perhaps we can create a function for each dist that explains how to order, and then always call this function here?
EXPECT_THAT(self.get_lower_bound(), | ||
FloatingPointEqual(p_other_uniform_distribution->get_lower_bound(), 1e-12, 1e-12)); | ||
EXPECT_THAT(self.get_upper_bound(), | ||
FloatingPointEqual(p_other_uniform_distribution->get_upper_bound(), 1e-12, 1e-12)); | ||
|
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.
Why are these checks gone? The lower and upper bounds still exist for these distributions.
// Set trips to use weekday trips on weekends. | ||
data.use_weekday_trips_on_weekend(); |
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.
// Set trips to use weekday trips on weekends. | |
data.use_weekday_trips_on_weekend(); |
Duplication?
// Set trips to use weekday trips on weekends. | ||
data.use_weekday_trips_on_weekend(); | ||
|
||
// Mock the distribution to prevent infections or state transitions in the test. | ||
// Mock the distribution to prevent infectionsin the test. |
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.
// Mock the distribution to prevent infectionsin the test. | |
// Mock the distribution to prevent infections in the test. |
if (m_dist == nullptr) { | ||
log_error("Distribution is not defined. Parameters cannot be deduced."); | ||
} | ||
return m_dist->params(); |
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.
Logging is not enough here, as a nullptr dereference is undefined behaviour. If we are lucky, this return will immediately cause a segfault and crash.
Changes and Information
Please briefly list the changes (main added features, changed items, or corrected bugs) made:
Merge Request - Guideline Checklist
Please check our git workflow. Use the draft feature if the Pull Request is not yet ready to review.
Checks by code author
Checks by code reviewer(s)
coses #1081