memilio icon indicating copy to clipboard operation
memilio copied to clipboard

646 Use graph model with abms

Open jubicker opened this issue 1 year ago • 3 comments

Changes and Information

  • Create simulation graph nodes and mobility edges for ABM

  • Add world id to world and location and include id in functions where necesarry

  • Add activeness vector for persons to world

  • Add tests and example for abm graph model

  • The performance has slightly decreased (5-10%), because an additional check in some functions is now necessary whether a person is active in the current world (e.g. in migration and interaction function). For more information about performance, see the comment below

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

  • [x] Every addressed issue is linked (use the "Closes #ISSUE" keyword below)
  • [x] New code adheres to coding guidelines
  • [x] No large data files have been added (files should in sum not exceed 100 KB, avoid PDFs, Word docs, etc.)
  • [x] Tests are added for new functionality and a local test run was successful (with and without OpenMP)
  • [x] Appropriate documentation for new functionality has been added (Doxygen in the code and Markdown files if necessary)
  • [x] Proper attention to licenses, especially no new third-party software with conflicting license has been added
  • [x] (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).

jubicker avatar Jul 09 '24 08:07 jubicker

Codecov Report

Attention: Patch coverage is 79.61165% with 42 lines in your changes missing coverage. Please review.

Project coverage is 95.87%. Comparing base (d59fbd7) to head (1f85548). Report is 2 commits behind head on main.

Files Patch % Lines
cpp/models/abm/world.h 62.79% 16 Missing :warning:
cpp/models/graph_abm/graph_abm_mobility.h 77.41% 14 Missing :warning:
cpp/models/graph_abm/mobility_rules.cpp 56.25% 7 Missing :warning:
cpp/models/abm/world.cpp 89.13% 5 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1065      +/-   ##
==========================================
- Coverage   96.08%   95.87%   -0.22%     
==========================================
  Files         131      133       +2     
  Lines       11048    11188     +140     
==========================================
+ Hits        10616    10726     +110     
- Misses        432      462      +30     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jul 09 '24 08:07 codecov[bot]

Performance Measures: The following are the mean results of 10 executions of the abm benchmark for a single thread (OMP_NUM_THREADS=1)

Main:

---------------------------------------------------------------------------
Benchmark                                 Time             CPU
---------------------------------------------------------------------------
abm_benchmark/abm_benchmark_50k        3178,6 ms      3177,1 ms
abm_benchmark/abm_benchmark_100k      7128,8 ms      7125,8 ms
abm_benchmark/abm_benchmark_200k      14771 ms       14766,3 ms

Graph_ABM:

---------------------------------------------------------------------------
Benchmark                                 Time             CPU
---------------------------------------------------------------------------
abm_benchmark/abm_benchmark_50k        3537,5 ms      3535,5 ms
abm_benchmark/abm_benchmark_100k      7611 ms         7608 ms
abm_benchmark/abm_benchmark_200k      15674,8 ms    15669,6 ms

So 5-10% performance loss.

jubicker avatar Jul 24 '24 09:07 jubicker

Some more Benchmarks:

I got the following results for 5 executions of the abm benchmarks for one single thread. For every benchmark I added inactive agents and compared the results for num_inactive_agents=0, num_agents, 2x num_agents, 3x num_agents.

For 50k agents:

---------------------------------------------------------------------------
Benchmark                        Time         Deviation from no inactive
---------------------------------------------------------------------------
abm_benchmark_50k_0_inactive     3568,8 ms     0%
abm_benchmark_50k_1_inactive     4072,6 ms     14%
abm_benchmark_50k_2_inactive     4584 ms       28%
abm_benchmark_50k_3_inactive     5093,8 ms     43%

For 100k agents:

---------------------------------------------------------------------------
Benchmark                        Time         Deviation from no inactive
---------------------------------------------------------------------------
abm_benchmark_100k_0_inactive     7707,2 ms     0%
abm_benchmark_100k_1_inactive     8705 ms       13%
abm_benchmark_100k_2_inactive     9699,6 ms     26%
abm_benchmark_100k_3_inactive     10720,2 ms    39%

For 200k agents:

---------------------------------------------------------------------------
Benchmark                        Time         Deviation from no inactive
---------------------------------------------------------------------------
abm_benchmark_200k_0_inactive     15850 ms     0%
abm_benchmark_200k_1_inactive     17898,6 ms   13%
abm_benchmark_200k_2_inactive     19949,2 ms   26%
abm_benchmark_200k_3_inactive     22033,6 ms   39%

jubicker avatar Jul 31 '24 11:07 jubicker