Skip to content

Conversation

@annawendler
Copy link
Member

@annawendler annawendler commented Jan 9, 2026

Changes and Information

In the IDE-SECIR model, two indices were not adapted for multiple age groups. This was corrected here and appropriate test was added to check the correctness of the ageresolved simulation.

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 #1469

@annawendler annawendler self-assigned this Jan 9, 2026
@codecov
Copy link

codecov bot commented Jan 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.30%. Comparing base (79088be) to head (8fd7324).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1472      +/-   ##
==========================================
- Coverage   97.31%   97.30%   -0.02%     
==========================================
  Files         187      187              
  Lines       16017    16017              
==========================================
- Hits        15587    15585       -2     
- Misses        430      432       +2     

☔ 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.

Copy link
Member

@reneSchm reneSchm left a comment

Choose a reason for hiding this comment

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

Very nice documentation for the new test. The only important comment is on line 278 regarding testing interactions between age groups.

// age group and the population size as well as the initial values for the deaths and transitions are scaled by some
// factor. This way, the expected results for this model are determined by the results from the other test and the
// scaling factor. With this, we can check that the correct indices are used for each age group.
TEST(IdeSecirAgeres, checkSimulationFunctions)
Copy link
Member

Choose a reason for hiding this comment

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

Did you mean to use a new test suite, or do you want to reuse the one from above?

Suggested change
TEST(IdeSecirAgeres, checkSimulationFunctions)
TEST(TestIdeAgeres, checkSimulationFunctions)

// the second age group.
ScalarType baseline_scaling = 2.;

/*****************************************************************************************************************/
Copy link
Member

Choose a reason for hiding this comment

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

It is a best practice to avoid C style comments, i.e. use // instead of /* */.

If you want to separate sections, IMO it is best to use text as titles, e.g.


// <section title>

But I won't stop you from getting fancy with added stars or hash signs.

int Ri = get_state_flat_index(Eigen::Index(InfectionState::Recovered), group);
int Di = get_state_flat_index(Eigen::Index(InfectionState::Dead), group);
// The scheme of the ODE model for initialization is applied here.
populations[Eigen::Index(0)][Ri] = total_confirmed_cases[group] - populations[Eigen::Index(0)][ISyi] -
Copy link
Member

Choose a reason for hiding this comment

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

Off topic, but if a value is used as much as this Eigen::Index(0), it helps readability to give it a name. E.g. const Eigen::Index init_time_point = 0, if I read the context correctly.

Comment on lines +278 to +281
// Model with whole population in second age group with index 1. Use baseline values scaled by baseline_scaling.
considered_group = 1;
std::vector<ScalarType> N_vec_group1 = {0., baseline_scaling * population_baseline};
std::vector<ScalarType> deaths_vec_group1 = {0., baseline_scaling * deaths_baseline};
Copy link
Member

Choose a reason for hiding this comment

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

I would have expected that the second test uses both populations to check that there are no unexpected interactions between age groups. With the current setup, any interactions between age groups vanishes (as the "other" age group is always 0), so in theory that could hide indexing errors.
Do you want to cover that case?

Comment on lines +309 to +310
// Set working parameters.
for (size_t group = 0; group < num_agegroups; group++) {
Copy link
Member

Choose a reason for hiding this comment

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

This loop seems to be exactly the same as above, except for using model_group1. You could move some of the fairly lengthy setup into one or more functions (or lambda functions), so it is easier to spot that the setup is the same, and to make the test shorter.

Comment on lines +353 to +357
// Define vectors with expected results for first model.
int num_compartments = (int)mio::isecir::InfectionState::Count;
std::vector<ScalarType> secihurd_t0_group0(num_compartments * num_agegroups, 0.);
std::vector<ScalarType> secihurd_t1_group0(num_compartments * num_agegroups, 0.);
std::vector<ScalarType> transitions_t1_group0(num_transitions * num_agegroups, 0.);
Copy link
Member

Choose a reason for hiding this comment

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

I found these additional vectors and the following copy-transform-copy very confusing. You can replace the copy and the checks (i.e. lines 353-402) by the following:

    // Compare simulated compartments at time points t0 and t1.
    for (Eigen::Index i = 0; i < (Eigen::Index)secihurd_simulated_group0.get_num_elements(); i++) {
        EXPECT_NEAR(secihurd_simulated_group0[0][i], secihurd_t0_baseline[i], 1e-8);
        EXPECT_NEAR(secihurd_simulated_group0[1][i], 0.0, 1e-8);
        EXPECT_NEAR(secihurd_simulated_group1[0][i], 0.0, 1e-8);
        EXPECT_NEAR(secihurd_simulated_group1[1][i], baseline_scaling * secihurd_t1_baseline[i], 1e-8);
    }

    ASSERT_EQ(transitions_t1_baseline.size() * 2, transitions_simulated_group0.get_num_elements());
    // Compare simulated transitions with expected results at time point t1.
    for (size_t i = 0; i < transitions_t1_baseline.size(); i++) {
        const size_t age1 = i;
        const size_t age2 = i + transitions_t1_baseline.size();
        EXPECT_NEAR(transitions_simulated_group0.get_last_value()[age1], transitions_t1_baseline[i], 1e-8);
        EXPECT_NEAR(transitions_simulated_group1.get_last_value()[age1], 0.0, 1e-8);
        EXPECT_NEAR(transitions_simulated_group0.get_last_value()[age2], 0.0, 1e-8);
        EXPECT_NEAR(transitions_simulated_group1.get_last_value()[age2], baseline_scaling * transitions_t1_baseline[i],
                    1e-8);
    }

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.

Fix indices in IDE-SECIR model that have not been adapted to multiple age groups

3 participants