-
Notifications
You must be signed in to change notification settings - Fork 17
1250 enhance testing logic in abm #1276
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: main
Are you sure you want to change the base?
Conversation
…enhance testing strategy checks
…g scheme handling in tests
…ance serialization, and improve test logic
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 PR enhances the testing logic for the ABM by simplifying testing criteria, updating the API for testing schemes, and improving serialization. Key changes include:
- Replacing previous testing scheme APIs (e.g. run_scheme) with new methods (run_scheme_and_check_if_test_positive and is_active with time parameter).
- Updating functions to add testing schemes by location type or id.
- Adapting tests and serialization accordingly.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
cpp/tests/test_abm_testing_strategy.cpp | Refactored test cases to use new testing scheme API and updated evaluation logic. |
cpp/tests/test_abm_serialization.cpp | Updated reference JSON keys to match the new serialization format. |
cpp/tests/test_abm_model.cpp | Modified test scenarios to use the new location-based testing scheme assignment. |
cpp/models/graph_abm/graph_abmodel.h | Updated testing scheme call to use the new run_strategy_and_check_if_entry_allowed API. |
cpp/models/abm/testing_strategy.h | Removed outdated functions and updated API for adding testing schemes. |
cpp/models/abm/testing_strategy.cpp | Changes to testing scheme activation and strategy evaluation logic. |
cpp/models/abm/model.cpp | Modified integration of testing strategy in mobility methods. |
cpp/benchmarks/abm.cpp | Replaced old API calls with the new testing scheme API for location types. |
Co-authored-by: Copilot <[email protected]>
…th add_testing_scheme_location_type for consistency across examples
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1276 +/- ##
==========================================
- Coverage 97.28% 97.23% -0.05%
==========================================
Files 168 168
Lines 14858 14838 -20
==========================================
- Hits 14454 14428 -26
- Misses 404 410 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
cpp/models/abm/model.cpp
Outdated
// the Person cannot move if the performed TestingStrategy is positive | ||
if (!m_testing_strategy.run_strategy(personal_rng, person, target_location, t)) { | ||
// The person cannot move if he has a positive test result | ||
if(!m_testing_strategy.run_strategy_and_check_if_entry_allowed(personal_rng, person, target_location, t)){ |
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.
Shorten function names and maybe improve documentation
… consistency and readability across the codebase
…ction and update tests to remove direct calls
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.
Thanks for the improvements and also the nice new tests!
There are only a couple of remarks and inquiries.
if (person.get_compliance(InterventionType::Testing) < | ||
1.0 && // Dont need to draw a random number if the person is compliant either way | ||
!person.is_compliant( | ||
rng, InterventionType::Testing)) { // If the person is not compliant with the testing intervention | ||
return true; // Assume positive test result as this should not allow entry although it is not the same | ||
} |
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.
If a person is not compliant but has a valid test certificate from before, entry should still be allowed. This happens frequently with people that have moderate compliance, I suppose.
model.get_testing_strategy().add_testing_scheme(testing_scheme_work); | ||
model.get_testing_strategy().add_scheme(testing_scheme_work); |
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.
Any specific reason for this rename here and in all other places?
} | ||
} | ||
} | ||
return true; | ||
|
||
// If the location is a home, entry is always allowed regardless of testing, no early return here because we still need to 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.
Not sure. Why do we need to test if a person goes home? This would say that there is a testing scheme that tests if a person has to test if going home.
@@ -187,88 +172,74 @@ class TestingStrategy | |||
* A LocalStrategy with id of value LocationId::invalid_id() is used for all Locations with LocationType type. |
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.
Requires adaptation.
To be fair, I think we don't really need this struct anymore with these changes.
|
||
// Reactivate the scheme. | ||
testing_scheme1.update_activity_status(mio::abm::TimePoint(0)); | ||
EXPECT_EQ(testing_scheme1.is_active(mio::abm::TimePoint(60 * 60 * 24 * 3 + 200)), false); |
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.
Could also be rewritten with days(3)
.
// Create PCR test parameters with high accuracy but long wait time | ||
const auto test_params_pcr = mio::abm::TestParameters{0.95, 0.99, mio::abm::hours(24), mio::abm::TestType::PCR}; | ||
|
||
// Create rapid test parameters with lower accuracy but quick results (we need to set this to 24 hours to avoid the person getting healthy randomly) |
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.
Not sure I understand this. Can you elaborate why a person can get healthy? We look into the past with the evaluation time.
|
||
// Test at shop with specific ID - should run the scheme | ||
bool result1 = test_strategy.run_and_check(rng, person, shop1, start_date); | ||
EXPECT_EQ(result1, false); // Person should not be allowed to enter after positive 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.
EXPECT_EQ(result1, false); // Person should not be allowed to enter after positive test | |
EXPECT_EQ(result1, false); // Person should not be allowed to enter after not complying to the test |
Changes and Information
Please briefly list the changes (main added features, changed items, or corrected bugs) made:
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
Checks by code reviewer(s)