Skip to content

Conversation

@an-jung
Copy link
Collaborator

@an-jung an-jung commented Aug 7, 2025

Changes and Information

Please briefly list the changes (main added features, changed items, or corrected bugs) made:

  • added LCT SECIR Model for 2 DISEASES on the basis of the LCT SECIR model

If need be, add additional information and what the reviewer should look out for in particular:

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

  • Every addressed issue is linked (use the "Closes #ISSUE" keyword below)
  • New code adheres to coding guidelines
  • No large data files have been added (files should in sum not exceed 100 KB, avoid PDFs, Word docs, etc.)
  • Tests are added for new functionality and a local test run was successful (with and without OpenMP)
  • Appropriate documentation within the code (Doxygen) for new functionality has been added in the code
  • Appropriate external documentation (ReadTheDocs) for new functionality has been added to the online documentation
  • Proper attention to licenses, especially no new third-party software with conflicting license has been added
  • (For ABM development) Checked benchmark results and ran and posted a local test above from before and after development to ensure performance is monitored.

Checks by code reviewer(s)

  • Corresponding issue(s) is/are linked and addressed
  • Code is clean of development artifacts (no deactivated or commented code lines, no debugging printouts, etc.)
  • Appropriate unit tests have been added, CI passes, code coverage and performance is acceptable (did not decrease)
  • No large data files added in the whole history of commits(files should in sum not exceed 100 KB, avoid PDFs, Word docs, etc.)
  • On merge, add 2-5 lines with the changes (main added features, changed items, or corrected bugs) to the merge-commit-message. This can be taken from the briefly-list-the-changes above (best case) or the separate commit messages (worst case).

Closes #1294

@an-jung an-jung linked an issue Aug 7, 2025 that may be closed by this pull request
2 tasks
@an-jung an-jung added loc::backend This issue concerns the C++ backend implementation. model::lct Models using the linear chain trick labels Aug 7, 2025
@an-jung an-jung marked this pull request as ready for review August 7, 2025 12:00
@codecov
Copy link

codecov bot commented Aug 7, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.35%. Comparing base (08a6cf0) to head (ef6ce8a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1340      +/-   ##
==========================================
+ Coverage   97.26%   97.35%   +0.08%     
==========================================
  Files         176      178       +2     
  Lines       15439    15962     +523     
==========================================
+ Hits        15017    15540     +523     
  Misses        422      422              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

ScalarType tmax = 10;

// Set Parameters.
model.parameters.get<mio::lsecir2d::TimeExposed_a>()[0] = 3.;
Copy link
Member

@jubicker jubicker Aug 28, 2025

Choose a reason for hiding this comment

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

I'm not sure whether the naming of the parameters and also of infection states is the best choice. Maybe we should use longer but more self-speaking names, like TimeExposedDisease1,... and for infection states something like: InfectedNoSymptomsDisease1Naive and InfectedNoSymptomsDisease1RecoveredDisease2? Or is that too long? @annawendler what do you think?

Copy link
Member

Choose a reason for hiding this comment

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

I agree that the infection states are not that self-speaking but I also find the more explaining names really long and quite hard to read. I couldn't come up with a good compromise so I would go with the shorter names.

Copy link
Member

Choose a reason for hiding this comment

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

Regarding names of infection states, I thought of renaming Recovered_a to Recovered_1a and Recovered_ab to recovered_2ab to make it more explicit how many infections the individuals have gone through.

Copy link
Member

@annawendler annawendler left a comment

Choose a reason for hiding this comment

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

First part of review

Copy link
Member

@annawendler annawendler left a comment

Choose a reason for hiding this comment

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

In a recent commit the use of floating point types was reworked to allow for automatic differentiation. This also affected the LCT-SECIR model, e.g. we now have an additional template parameter FP for the model class. Can you adapt your model accordingly so that the models are consistent? If you have any questions just let us know :)

@mknaranja mknaranja changed the title 1294 add lct secir model with two disease strains 1294 add LCT SECIR model with two disease strains Sep 29, 2025
@mknaranja
Copy link
Member

@an-jung please use capitalization in github for shorthand notation such as LCT, SECIR, ...

Copy link
Member

@annawendler annawendler left a comment

Choose a reason for hiding this comment

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

Remaining part of review. Looks good in general! The interact() function was a bit unclear to me, see questions below. Otherwise my comments are mainly regarding documentation

using LctStateGroup = type_at_index_t<Group, LctStates...>;

size_t first_index_group = this->populations.template get_first_index_of_group<Group>();
auto params = this->parameters;
Copy link
Member

Choose a reason for hiding this comment

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

In the LCT-SECIR model we have `const auto& params = this->parameters;``, also in interact(). Why did you change this?

size_t Di_b = first_index_group + LctStateGroup::template get_first_index<InfectionState::Dead_b>();

// Calculate derivative of the Susceptible compartment.
// outflow generated by disease a and disease b both
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// outflow generated by disease a and disease b both
// The outflow is generated by disease a and disease b both.


// Calculate derivative of the Susceptible compartment.
// outflow generated by disease a and disease b both
double part_a = 0.; // part of people getting infected with disease a
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
double part_a = 0.; // part of people getting infected with disease a
FP part_a = 0.; // part of people getting infected with disease a

double part_a = 0.; // part of people getting infected with disease a
double part_b = 0.; // part of people getting infected with disease b
interact<Group, 0>(pop, y, t, dydt, &part_a, &part_b, first_index_group, 2);
// split flow
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// split flow
// Split flow.

For consistency please use full sentences in documentation.

// split flow
double div_part_both = ((part_a + part_b) < Limits<FP>::zero_tolerance()) ? 0.0 : 1.0 / (part_a + part_b);

// Start with derivatives of First Infections (X_1a, X_1b)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Start with derivatives of First Infections (X_1a, X_1b)
// Start with derivatives of first infections (X_1a, X_1b).

sin(3.141592653589793 * ((params.template get<StartDay<FP>>() + t) / 182.5 + 0.5));

if (which_disease == 0) { // disease a
dydt[compartment_index] +=
Copy link
Member

Choose a reason for hiding this comment

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

The variable compartment_index is only used within this if statement. Can you define the compartment_index depending on the variable which_disease so that you don't have to pass this as argument to interact()?

params.template get<RiskOfInfectionFromSymptomatic_b<FP>>()[Group2] * infectedSymptoms_2_b));
}
// To split the outflow from S between E_1a and E_1b:
*part_a += params.template get<TransmissionProbabilityOnContact_a<FP>>()[Group1] *
Copy link
Member

Choose a reason for hiding this comment

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

What about the contact patterns in part_a and part_b?

Copy link
Member

Choose a reason for hiding this comment

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

If I understand part_a and part_b correctly, these terms refer to the factor in front of S, i.e. you have
$S'(t) = -(part_a(t) +part_b(t)) S(t)$. This is the rate with which individuals become infected and is often called force of infection in the literature. This is why I would suggest to call these terms for example foi_a and foi_b to make this clearer.

(params.template get<RelativeTransmissionNoSymptoms_a<FP>>()[Group2] * infectedNoSymptoms_2_a +
params.template get<RiskOfInfectionFromSymptomatic_a<FP>>()[Group2] * infectedSymptoms_2_a);
}
else if (which_disease == 1) { // disease b
Copy link
Member

Choose a reason for hiding this comment

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

The rhs of the if statements is defined using the same terms as in part_a and part_b. Then you can define these terms first and use them both in the if terms and as summand for part_a and part_b to avoid code duplication and make it easier to understand.

size_t first_index_group2 = this->populations.template get_first_index_of_group<Group2>();

// Calculate sum of all subcompartments for InfectedNoSymptoms for disease a of Group2.
infectedNoSymptoms_2_a =
Copy link
Member

Choose a reason for hiding this comment

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

Does the 2 refer to the group here? If so, I would explicitly refer to group2 in the variable name

* @param[out] part_a Reference to amount of flow caused by people infected with disease a.
* @param[out] part_b Reference to amount of flow caused by people infected with disease b.
* @param[in] compartment_index Index of the compartment for that the outflow will be calculated.
* @param[in] which_disease Index for which infected people cause the outflow (0 = a, 1 = b, 2 = a and b).
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @param[in] which_disease Index for which infected people cause the outflow (0 = a, 1 = b, 2 = a and b).
* @param[in] relevant_disease Index for which infected people cause the outflow (0 = a, 1 = b, 2 = a and b).

I think that makes the meaning a bit clearer.

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

Labels

loc::backend This issue concerns the C++ backend implementation. model::lct Models using the linear chain trick

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add LCT SECIR model with two disease strains

5 participants