Skip to content

1612 Fix ABM crash for persons without assigned location of requested activity type - #1613

Open
xsaschako wants to merge 1 commit into
mainfrom
1612-fix-abm-missing-assigned-location
Open

xsaschako wants to merge 1 commit into
mainfrom
1612-fix-abm-missing-assigned-location

Conversation

@xsaschako

@xsaschako xsaschako commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Changes and Information

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

  • Added Person::has_assigned_location(ActivityType).
  • try_mobility_rule in Model::perform_mobility and GraphABModel::perform_mobility returns false (person stays) if the person has no assigned location of the requested ActivityType, instead of accessing an empty vector out of bounds.
  • Person::get_assigned_location asserts that a location of the requested type is assigned.
  • m_assigned_location_model_ids is now sized with ActivityType::Count instead of LocationType::Count.
  • New test TestModel.mobilityWithMissingAssignedLocations.

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 and checked in the preview.
  • 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 #1612

… activity type

Mobility rules can return an ActivityType for which the person has no
assigned location (e.g. no workplace), which made get_assigned_location
access an empty vector out of bounds. Add Person::has_assigned_location
and skip the rule in Model and GraphABModel if no location is assigned.
Also size m_assigned_location_model_ids by ActivityType::Count.
@xsaschako xsaschako added class::bug Bugs found in the software loc::backend This issue concerns the C++ backend implementation. model::abm This issue concerns any kind of agent-based model. labels Nov 26, 2026
@codecov

codecov Bot commented Nov 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 97.51%. Comparing base (f0c2cf2) to head (1540529).

Files with missing lines Patch % Lines
cpp/models/graph_abm/graph_abmodel.h 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1613      +/-   ##
==========================================
- Coverage   97.52%   97.51%   -0.01%     
==========================================
  Files         190      190              
  Lines       16104    16111       +7     
==========================================
+ Hits        15705    15711       +6     
- Misses        399      400       +1     

☔ View full report in Codecov by Harness.
📢 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.

This branch has not been deployed

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

Labels

class::bug Bugs found in the software loc::backend This issue concerns the C++ backend implementation. model::abm This issue concerns any kind of agent-based model.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ABM crashes if a person has no assigned location for the activity type returned by a mobility rule

2 participants