Skip to content

Abm paper test bs #1251

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

Draft
wants to merge 514 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
514 commits
Select commit Hold shift + click to select a range
ffff14a
short tesrt
xsaschako Aug 3, 2024
1b2c96b
omp improvment
xsaschako Aug 3, 2024
af9be81
another improvement for cluster
xsaschako Aug 3, 2024
04d9b3e
change some things
xsaschako Aug 4, 2024
1f07c32
add pa function for person
xsaschako Aug 4, 2024
d35b7b9
some fixes
xsaschako Aug 4, 2024
107e8fa
some improvements
xsaschako Aug 6, 2024
41b405b
cluster ready
xsaschako Aug 6, 2024
ae61b52
cluster
xsaschako Aug 6, 2024
9b2c3e1
grid search cluster
xsaschako Aug 6, 2024
7f70ee8
plots done
xsaschako Aug 6, 2024
3be0829
add quarantine factor, change some params
xsaschako Aug 6, 2024
e1e838a
minor improvements
xsaschako Aug 7, 2024
220e78f
some fixes
xsaschako Aug 7, 2024
857f677
fix some bugs and add some plots and refactor some things
xsaschako Aug 7, 2024
2326811
cluster
xsaschako Aug 7, 2024
fe742f0
Update logger for reproduction number
DavidKerkmann Aug 8, 2024
47bbdb4
Remove unused variables
DavidKerkmann Aug 8, 2024
31fad05
Small error in integral formula
DavidKerkmann Aug 8, 2024
85fa8ee
analyzer update
xsaschako Aug 8, 2024
efde6c1
paper update
xsaschako Aug 8, 2024
9fc270f
cluster update
xsaschako Aug 8, 2024
01ae8a6
cluster update
xsaschako Aug 8, 2024
483a148
Bracket mistake fix
DavidKerkmann Aug 8, 2024
abd3eb9
add 25 and 75 percentil
xsaschako Aug 8, 2024
ce46772
cluster run
xsaschako Aug 8, 2024
0039281
cluster
xsaschako Aug 8, 2024
94b7e71
push for cluster
xsaschako Aug 8, 2024
ff4d03e
cluster
xsaschako Aug 8, 2024
ff1b33e
cluster
xsaschako Aug 8, 2024
bd5e097
trash abm make new, make better, rinse repeat
xsaschako Aug 10, 2024
67ba95a
cluster params
xsaschako Aug 10, 2024
6200830
reweork simulation
xsaschako Aug 11, 2024
465b31f
p95/05
xsaschako Aug 11, 2024
98a9670
cluster runs
xsaschako Aug 11, 2024
76ad8e3
omp change
xsaschako Aug 11, 2024
854803c
new guestimates
xsaschako Aug 12, 2024
efdc6d5
quick bugfix
xsaschako Aug 14, 2024
56dba36
new par_varaition plots
xsaschako Aug 15, 2024
6d37816
huge refactoring etc
xsaschako Aug 15, 2024
3463a4d
scale y_axis
xsaschako Aug 15, 2024
a244820
parameters settings
xsaschako Aug 16, 2024
f1db06a
push grad_search enhancecments
xsaschako Aug 18, 2024
c4f980b
just calc from dead
xsaschako Aug 18, 2024
e1a3c22
grid search
xsaschako Aug 18, 2024
a4dbc92
bugfix
xsaschako Aug 18, 2024
acd892e
some param changes
xsaschako Aug 18, 2024
87fd1e1
link bs data
xsaschako Aug 19, 2024
d7a164f
change setup markdown
xsaschako Aug 19, 2024
04598aa
change punctual grid search
xsaschako Aug 20, 2024
3949c66
cluster
xsaschako Aug 20, 2024
086616c
cluuster
xsaschako Aug 20, 2024
4d956ae
cluster
xsaschako Aug 20, 2024
653c9ab
benchmark
xsaschako Aug 20, 2024
dd2823a
benchmarks
xsaschako Aug 20, 2024
6bc3d5f
6.4mio
xsaschako Aug 20, 2024
21579f1
scaling results
xsaschako Aug 20, 2024
b2c3625
cluster grid search
xsaschako Aug 20, 2024
b891bb8
quick update
xsaschako Aug 20, 2024
31cdc27
cluster
xsaschako Aug 20, 2024
e12e136
cluster
xsaschako Aug 20, 2024
7f321da
lets see
xsaschako Aug 20, 2024
52c1149
paaper
xsaschako Aug 20, 2024
4df2b66
this the run?
xsaschako Aug 21, 2024
a9051a1
cluster
xsaschako Aug 21, 2024
0e124a5
add scenario plotter and other improvements
xsaschako Aug 21, 2024
4fd6c7a
cluster
xsaschako Aug 21, 2024
1b20e76
benchmark_results again
xsaschako Aug 21, 2024
baf1288
scenario plotter
xsaschako Aug 21, 2024
2a72daa
icu oimprovement
xsaschako Aug 21, 2024
66d9f17
further sim improvs
xsaschako Aug 21, 2024
c8fb8e3
forgit this
xsaschako Aug 21, 2024
be97f95
sc a par vari
xsaschako Aug 21, 2024
5619748
scenario improv
xsaschako Aug 21, 2024
eedd8b6
scaling improv
xsaschako Aug 21, 2024
15a76d4
update parameters
xsaschako Aug 21, 2024
4402035
paper improv
xsaschako Aug 21, 2024
33caa44
upload for cluster
xsaschako Aug 21, 2024
8f713e5
location fix
xsaschako Aug 22, 2024
ecb2a40
Merge branch 'abm_paper_test_bs' of https://github.com/SciCompMod/mem…
xsaschako Aug 22, 2024
8d46306
some plot improvs
xsaschako Aug 22, 2024
1517632
analysze results imrpv
xsaschako Aug 22, 2024
c01c89e
paper params
xsaschako Aug 22, 2024
a6392e4
perf improcv loc flag
xsaschako Aug 22, 2024
2121e0f
plot enhancement
xsaschako Aug 22, 2024
1d8ebd3
scenario 2 cluster
xsaschako Aug 22, 2024
d54e6c8
redo
xsaschako Aug 22, 2024
0c7872e
par var
xsaschako Aug 22, 2024
441128a
short easter event diff
xsaschako Aug 23, 2024
fa1652e
mask improv
xsaschako Aug 23, 2024
baf9815
dath date before 16 days
xsaschako Aug 23, 2024
50ea98c
some plot improvs
xsaschako Aug 23, 2024
d453ce9
better rmse icu
xsaschako Aug 23, 2024
0245dfb
18 days dead and paper sim improvs
xsaschako Aug 23, 2024
681a3bc
benchmark?
xsaschako Aug 23, 2024
09f4729
omp
xsaschako Aug 23, 2024
9382e36
improooovements
xsaschako Aug 23, 2024
481213b
picc improvs
xsaschako Aug 23, 2024
9d2fe9f
don't save single results
xsaschako Aug 23, 2024
9810267
test123
xsaschako Aug 23, 2024
c356733
test
xsaschako Aug 23, 2024
c6f410f
ewd
xsaschako Aug 23, 2024
85855c3
omp??!"
xsaschako Aug 23, 2024
6ab0506
rest
xsaschako Aug 23, 2024
6fc5e62
423
xsaschako Aug 23, 2024
0439107
fw
xsaschako Aug 23, 2024
f8d1c4b
31
xsaschako Aug 24, 2024
805d33a
paper grid search
xsaschako Aug 24, 2024
e9e5962
mrlekw
xsaschako Aug 24, 2024
b9195f3
papersss
xsaschako Aug 24, 2024
84b4272
clustere
xsaschako Aug 24, 2024
4b47a56
par_var_oimprocs
xsaschako Aug 24, 2024
428db2a
cluster
xsaschako Aug 24, 2024
230595f
777
xsaschako Aug 24, 2024
50726d3
999
xsaschako Aug 24, 2024
afe1d9d
griddd
xsaschako Aug 24, 2024
01fd1c7
bf
xsaschako Aug 24, 2024
9ebdae9
101010
xsaschako Aug 24, 2024
22f4e01
cluster test 1
xsaschako Aug 24, 2024
f3b7850
cluster test 2
xsaschako Aug 24, 2024
7579fd1
omp change back
xsaschako Aug 24, 2024
a687fac
cluster
xsaschako Aug 24, 2024
d84c4db
clluster 2
xsaschako Aug 24, 2024
d97cb50
test1
xsaschako Aug 24, 2024
4066f11
cluster?
xsaschako Aug 24, 2024
3eb8cda
cluster
xsaschako Aug 24, 2024
d21833a
path
xsaschako Aug 24, 2024
31e4baa
fix bug
xsaschako Aug 24, 2024
7ec1b4d
big fat bug fix
xsaschako Aug 24, 2024
c800981
prep cluster run
xsaschako Aug 24, 2024
7b34032
secando
xsaschako Aug 24, 2024
1fef381
omp fix
xsaschako Aug 24, 2024
13efcfc
other gs
xsaschako Aug 25, 2024
def4b7d
cluster run the second
xsaschako Aug 25, 2024
8b69d37
grid
xsaschako Aug 25, 2024
3f43374
cluster grid
xsaschako Aug 25, 2024
8ed3a75
paper weights
xsaschako Aug 25, 2024
c79b46b
grid search
xsaschako Aug 26, 2024
1c47df4
grid 2
xsaschako Aug 26, 2024
0f086c0
grid 3
xsaschako Aug 26, 2024
602ed71
grid search
xsaschako Aug 26, 2024
28ca7e6
grid search
xsaschako Aug 26, 2024
bcba19d
test
xsaschako Aug 26, 2024
8c00962
everything wrooong
xsaschako Aug 26, 2024
837857f
params
xsaschako Aug 26, 2024
4784355
grid search
xsaschako Aug 26, 2024
834431d
buggg
xsaschako Aug 26, 2024
6e1074b
cluster
xsaschako Aug 26, 2024
11f1c8e
cluster2
xsaschako Aug 26, 2024
a307a91
test run
xsaschako Aug 26, 2024
38d1a76
cluster run
xsaschako Aug 26, 2024
6f65572
send it
xsaschako Aug 26, 2024
62a98a1
new gird search
xsaschako Aug 26, 2024
8e01420
grid search
xsaschako Aug 26, 2024
e290969
2
xsaschako Aug 26, 2024
a791e88
3
xsaschako Aug 26, 2024
d6726bf
4
xsaschako Aug 26, 2024
117ff34
5
xsaschako Aug 26, 2024
de81d15
grid search
xsaschako Aug 27, 2024
24c7a6c
cluster...
xsaschako Aug 27, 2024
b46bc4c
4.0
xsaschako Aug 27, 2024
d027eb8
omp
xsaschako Aug 27, 2024
808d3d7
test
xsaschako Aug 27, 2024
8b2d7cf
cluster test
xsaschako Aug 27, 2024
f84a37f
cluster
xsaschako Aug 27, 2024
2aa2dc8
ss
xsaschako Aug 27, 2024
fc9b714
test
xsaschako Aug 27, 2024
870e777
2
xsaschako Aug 27, 2024
77c4f81
128 test
xsaschako Aug 27, 2024
91b3515
chill
xsaschako Aug 27, 2024
6aebe2e
cluster grid
xsaschako Aug 27, 2024
2b10970
gridsearch
xsaschako Aug 27, 2024
110a776
cluster search
xsaschako Aug 27, 2024
df8f94b
grid search
xsaschako Aug 27, 2024
d5d6830
2
xsaschako Aug 27, 2024
361d03a
grid search
xsaschako Aug 27, 2024
0c0c7fa
again
xsaschako Aug 27, 2024
6e61389
big grid search
xsaschako Aug 27, 2024
c434688
grid point 1
xsaschako Aug 27, 2024
6329bef
grid point 2
xsaschako Aug 27, 2024
0160e0e
grid poiint 3
xsaschako Aug 27, 2024
f9fbbae
big grid search
xsaschako Aug 27, 2024
d0ebf2a
grid search
xsaschako Aug 28, 2024
61b3a1c
grid 2
xsaschako Aug 28, 2024
e888680
grid 3
xsaschako Aug 28, 2024
d2a033f
griddd
xsaschako Aug 28, 2024
43195fe
grid 3
xsaschako Aug 28, 2024
928bf5c
scenario 1
xsaschako Aug 28, 2024
c3a444e
scnario 2
xsaschako Aug 28, 2024
48b4cb6
Revert "scnario 2"
xsaschako Aug 28, 2024
8878acc
par variaiotn
xsaschako Aug 28, 2024
f552f68
par var 2
xsaschako Aug 28, 2024
d9aa11c
par var 2
xsaschako Aug 28, 2024
b766062
cluster point 1
xsaschako Aug 28, 2024
bc20bdd
grid point 2 paper
xsaschako Aug 28, 2024
008ef17
point 3
xsaschako Aug 28, 2024
328b236
scenario 2
xsaschako Aug 28, 2024
f803bfd
Revert "scenario 2"
xsaschako Aug 28, 2024
b33f181
revert for normal simulation
xsaschako Aug 28, 2024
7ad764d
grid 1
xsaschako Aug 29, 2024
53c7378
grid 2
xsaschako Aug 29, 2024
c92b252
grid 3
xsaschako Aug 29, 2024
fb8cb3a
grid 1
xsaschako Aug 29, 2024
5b11e2b
grid search
xsaschako Aug 30, 2024
77788a8
grid point 1
xsaschako Aug 30, 2024
668d25d
grid point 2
xsaschako Aug 30, 2024
6a9a5cf
grid point 3
xsaschako Aug 30, 2024
5a5190f
better formatation
xsaschako Sep 16, 2024
78f88a1
benchmark
xsaschako Sep 17, 2024
1ce9b87
benchmakr_change
xsaschako Sep 17, 2024
c2bc07c
some imrpvoements
xsaschako Sep 18, 2024
1110be8
counter per person
xsaschako Sep 18, 2024
f1a251f
cluster run?
xsaschako Sep 18, 2024
598f017
grid search again
xsaschako Sep 19, 2024
228ae1b
grid search again22
xsaschako Sep 19, 2024
39656d0
some plotting changes
xsaschako Sep 19, 2024
889c9a3
short bugfix
xsaschako Sep 20, 2024
be90d04
some plotting changes
xsaschako Sep 20, 2024
fe1c312
some plotting changes
xsaschako Sep 20, 2024
0f9d9f1
grid_search_step2
xsaschako Sep 20, 2024
c69f6e1
bugfix
xsaschako Sep 20, 2024
5d66fa4
grid point 2
xsaschako Sep 20, 2024
b0dccd6
grid_point3
xsaschako Sep 20, 2024
4526a40
128ergridruns
xsaschako Sep 20, 2024
44816b6
128gs2
xsaschako Sep 20, 2024
7991cfb
128rungs3
xsaschako Sep 20, 2024
1bf16dd
grid_Search128_par1
xsaschako Sep 20, 2024
4485299
gs128_1
xsaschako Sep 20, 2024
8157a43
grid128_2
xsaschako Sep 20, 2024
4f8b732
gs128_3
xsaschako Sep 20, 2024
4b14b9e
par_var1
xsaschako Sep 20, 2024
7939221
parvar2
xsaschako Sep 20, 2024
36d3bb9
parvar3
xsaschako Sep 20, 2024
89ada50
scenario1
xsaschako Sep 20, 2024
fa8dd76
omp change
xsaschako Sep 20, 2024
8671d2a
short fix
xsaschako Sep 20, 2024
a12fc8a
scenario2
xsaschako Sep 20, 2024
5be6985
Revert "scenario2"
xsaschako Sep 21, 2024
3ba3c16
scenario 2 again
xsaschako Sep 21, 2024
2916296
mask change
xsaschako Sep 28, 2024
eb7aa12
mask change
xsaschako Oct 1, 2024
72fb84b
cluster urn
xsaschako Oct 2, 2024
0101544
Revert "scenario 2 again"
xsaschako Oct 2, 2024
1fb68d8
Add function for constant viral shed to compare results
DavidKerkmann Oct 4, 2024
cf89d79
Fixed unused t in constant viral shed
DavidKerkmann Oct 4, 2024
f829c5a
some improvs
xsaschako Oct 5, 2024
2df2edd
Fix typo and improve viral shed plot
DavidKerkmann Oct 11, 2024
749c3a7
some new testthings
xsaschako Jan 9, 2025
bf5a169
vis_script
xsaschako Apr 1, 2025
4e16152
no titles and 0 fix
xsaschako Apr 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ option(MEMILIO_BUILD_TESTS "Build memilio unit tests." ON)
option(MEMILIO_BUILD_EXAMPLES "Build memilio examples." ON)
option(MEMILIO_BUILD_MODELS "Build memilio models." ON)
option(MEMILIO_BUILD_SIMULATIONS "Build memilio simulations that were used for scientific articles." ON)
option(MEMILIO_BUILD_BENCHMARKS "Build memilio benchmarks with google benchmark." OFF)
option(MEMILIO_BUILD_BENCHMARKS "Build memilio benchmarks with google benchmark." ON)
option(MEMILIO_USE_BUNDLED_SPDLOG "Use spdlog bundled with epi" ON)
option(MEMILIO_USE_BUNDLED_EIGEN "Use eigen bundled with epi" ON)
option(MEMILIO_USE_BUNDLED_BOOST "Use boost bundled with epi (only for epi-io)" ON)
Expand All @@ -15,8 +15,8 @@ option(MEMILIO_SANITIZE_ADDRESS "Enable address sanitizer." OFF)
option(MEMILIO_SANITIZE_UNDEFINED "Enable undefined behavior sanitizer." OFF)
option(MEMILIO_BUILD_SHARED_LIBS "Build memilio as a shared library." ON)
option(MEMILIO_BUILD_STATIC_LIBS "Build memilio as a static library." ON)
option(MEMILIO_ENABLE_MPI "Build memilio with MPI." OFF)
option(MEMILIO_ENABLE_OPENMP "Enable Multithreading with OpenMP." OFF)
option(MEMILIO_ENABLE_MPI "Build memilio with MPI." ON)
option(MEMILIO_ENABLE_OPENMP "Enable Multithreading with OpenMP." ON)

mark_as_advanced(MEMILIO_USE_BUNDLED_SPDLOG MEMILIO_SANITIZE_ADDRESS MEMILIO_SANITIZE_UNDEFINED)

Expand Down
37 changes: 31 additions & 6 deletions cpp/benchmarks/abm.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "abm/simulation.h"
#include "memilio/math/interpolation.h"
#include "memilio/utils/stl_util.h"
#include "benchmark/benchmark.h"

Expand Down Expand Up @@ -35,7 +36,7 @@ mio::abm::Simulation make_simulation(size_t num_persons, std::initializer_list<u
{mio::abm::LocationType::School, mio::abm::LocationType::Work, mio::abm::LocationType::SocialEvent,
mio::abm::LocationType::BasicsShop, mio::abm::LocationType::Hospital, mio::abm::LocationType::ICU}) {

const auto num_locs = std::max(size_t(1), num_persons / 2'000);
const auto num_locs = std::max(size_t(1), num_persons / 100);
std::vector<mio::abm::LocationId> locs(num_locs);
std::generate(locs.begin(), locs.end(), [&] {
return world.add_location(loc_type);
Expand Down Expand Up @@ -108,6 +109,13 @@ mio::abm::Simulation make_simulation(size_t num_persons, std::initializer_list<u
mio::abm::TestingScheme(random_criteria(), mio::abm::days(3), mio::abm::TimePoint(0),
mio::abm::TimePoint(0) + mio::abm::days(10), {}, 0.5));

// Necessary to set a parameter for the world
world.parameters.get<mio::abm::HighViralLoadProtectionFactor>() = [](ScalarType days) -> ScalarType {
return mio::linear_interpolation_of_data_set<ScalarType, ScalarType>(
{{0, 0.863}, {1, 0.969}, {7, 0.029}, {10, 0.002}, {14, 0.0014}, {21, 0}}, days);
};
world.parameters.get<mio::abm::InfectionRateFromViralShed>() = 100;

return mio::abm::Simulation(mio::abm::TimePoint(0), std::move(world));
}

Expand All @@ -118,6 +126,15 @@ mio::abm::Simulation make_simulation(size_t num_persons, std::initializer_list<u
*/
void abm_benchmark(benchmark::State& state, size_t num_persons, std::initializer_list<uint32_t> seeds)
{
int tid = -1;
std::cout << "Number of persons = " << num_persons << "\n";
#pragma omp parallel private(tid) // Start of parallel region: forks threads
{
tid = omp_get_thread_num(); // default is number of CPUs on machine
if (tid == 0) {
printf("Number of threads = %d\n", omp_get_num_threads());
}
} // ** end of the the parallel: joins threads
mio::set_log_level(mio::LogLevel::warn);

for (auto&& _ : state) {
Expand All @@ -126,7 +143,7 @@ void abm_benchmark(benchmark::State& state, size_t num_persons, std::initializer
state.ResumeTiming();

//simulated time should be long enough to have full infection runs and migration to every location
auto final_time = sim.get_time() + mio::abm::days(10);
auto final_time = sim.get_time() + mio::abm::days(5);
sim.advance(final_time);

//debug output can be enabled to check for unexpected results (e.g. infections dieing out)
Expand All @@ -152,8 +169,16 @@ void abm_benchmark(benchmark::State& state, size_t num_persons, std::initializer
//have to be adjusted to get the benchmark back to normal.
//For small sizes (e.g. 10k) extreme cases are too likely, i.e. infections die out
//or overwhelm everything, so we don't benchmark these. Results should be mostly transferrable.
BENCHMARK_CAPTURE(abm_benchmark, abm_benchmark_50k, 50000, {14159265u, 35897932u})->Unit(benchmark::kMillisecond);
BENCHMARK_CAPTURE(abm_benchmark, abm_benchmark_100k, 100000, {38462643u, 38327950u})->Unit(benchmark::kMillisecond);
BENCHMARK_CAPTURE(abm_benchmark, abm_benchmark_200k, 200000, {28841971u, 69399375u})->Unit(benchmark::kMillisecond);

BENCHMARK_CAPTURE(abm_benchmark, abm_benchmark_25k_pt, 25000, {14159265u, 35897932u})->Unit(benchmark::kMillisecond);
BENCHMARK_CAPTURE(abm_benchmark, abm_benchmark_50k_pt, 50000, {14159265u, 35897932u})->Unit(benchmark::kMillisecond);
BENCHMARK_CAPTURE(abm_benchmark, abm_benchmark_100k_pt, 100000, {14159265u, 35897932u})->Unit(benchmark::kMillisecond);
BENCHMARK_CAPTURE(abm_benchmark, abm_benchmark_200k_pt, 200000, {14159265u, 35897932u})->Unit(benchmark::kMillisecond);
BENCHMARK_CAPTURE(abm_benchmark, abm_benchmark_400k_pt, 400000, {14159265u, 35897932u})->Unit(benchmark::kMillisecond);
BENCHMARK_CAPTURE(abm_benchmark, abm_benchmark_800k_pt, 800000, {14159265u, 35897932u})->Unit(benchmark::kMillisecond);
BENCHMARK_CAPTURE(abm_benchmark, abm_benchmark_1600k_pt, 1600000, {14159265u, 35897932u})
->Unit(benchmark::kMillisecond);
BENCHMARK_CAPTURE(abm_benchmark, abm_benchmark_3200k_pt, 3200000, {14159265u, 35897932u})
->Unit(benchmark::kMillisecond);
BENCHMARK_CAPTURE(abm_benchmark, abm_benchmark_3200k_pt, 6400000, {14159265u, 35897932u})
->Unit(benchmark::kMillisecond);
BENCHMARK_MAIN();
7 changes: 4 additions & 3 deletions cpp/examples/abm_history_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,11 @@ int main()
auto probability = 0.5;
auto start_date = mio::abm::TimePoint(0);
auto end_date = mio::abm::TimePoint(0) + mio::abm::days(30);
auto test_type = mio::abm::AntigenTest();
auto test_type = mio::abm::TestType::Antigen;
auto test_parameters = world.parameters.get<mio::abm::TestData>()[test_type];
auto testing_criteria_work = mio::abm::TestingCriteria();
auto testing_scheme_work =
mio::abm::TestingScheme(testing_criteria_work, testing_min_time, start_date, end_date, test_type, probability);
auto testing_scheme_work = mio::abm::TestingScheme(testing_criteria_work, testing_min_time, start_date, end_date,
test_parameters, probability);
world.get_testing_strategy().add_testing_scheme(mio::abm::LocationType::Work, testing_scheme_work);

// Assign infection state to each person.
Expand Down
11 changes: 6 additions & 5 deletions cpp/examples/abm_minimal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ int main()
world.parameters.get<mio::abm::IncubationPeriod>() = 4.;

// Set the age group the can go to school is AgeGroup(1) (i.e. 5-14)
world.parameters.get<mio::abm::AgeGroupGotoSchool>() = false;
world.parameters.get<mio::abm::AgeGroupGotoSchool>() = false;
world.parameters.get<mio::abm::AgeGroupGotoSchool>()[age_group_5_to_14] = true;
// Set the age group the can go to work is AgeGroup(2) and AgeGroup(3) (i.e. 15-34 and 35-59)
world.parameters.get<mio::abm::AgeGroupGotoWork>() = false;
world.parameters.get<mio::abm::AgeGroupGotoWork>() = false;
world.parameters.get<mio::abm::AgeGroupGotoWork>()[age_group_15_to_34] = true;
world.parameters.get<mio::abm::AgeGroupGotoWork>()[age_group_35_to_59] = true;

Expand Down Expand Up @@ -110,10 +110,11 @@ int main()
auto probability = 0.5;
auto start_date = mio::abm::TimePoint(0);
auto end_date = mio::abm::TimePoint(0) + mio::abm::days(10);
auto test_type = mio::abm::AntigenTest();
auto test_type = mio::abm::TestType::Antigen;
auto test_parameters = world.parameters.get<mio::abm::TestData>()[test_type];
auto testing_criteria_work = mio::abm::TestingCriteria();
auto testing_scheme_work =
mio::abm::TestingScheme(testing_criteria_work, testing_min_time, start_date, end_date, test_type, probability);
auto testing_scheme_work = mio::abm::TestingScheme(testing_criteria_work, testing_min_time, start_date, end_date,
test_parameters, probability);
world.get_testing_strategy().add_testing_scheme(mio::abm::LocationType::Work, testing_scheme_work);

// Assign infection state to each person.
Expand Down
2 changes: 1 addition & 1 deletion cpp/memilio/epidemiology/damping.h
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ class Dampings
static void inclusive_exclusive_sum_rec(Iter b, Iter e, Matrix& sum)
{
if (b != e) {
sum = sum + std::get<Matrix>(*b) - (sum.array() * std::get<Matrix>(*b).array()).matrix();
sum = (sum + std::get<Matrix>(*b) - (sum.array() * std::get<Matrix>(*b).array()).matrix()).eval();
inclusive_exclusive_sum_rec(++b, e, sum);
}
}
Expand Down
11 changes: 7 additions & 4 deletions cpp/memilio/io/epi_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ class VaccinationDataEntry
public:
static std::vector<const char*> age_group_names;

double num_vaccinations_completed;
double num_vaccinations_completed, num_vaccinations_partially;
Date date;
AgeGroup age_group;
boost::optional<regions::StateId> state_id;
Expand All @@ -468,14 +468,16 @@ class VaccinationDataEntry
{
auto obj = io.expect_object("VaccinationDataEntry");
auto num_vaccinations_completed = obj.expect_element("Vacc_completed", Tag<double>{});
auto num_vaccinations_partially = obj.expect_element("Vacc_partially", Tag<double>{});
auto date = obj.expect_element("Date", Tag<StringDate>{});
auto age_group_str = obj.expect_element("Age_RKI", Tag<std::string>{});
auto state_id = obj.expect_optional("ID_State", Tag<regions::StateId>{});
auto county_id = obj.expect_optional("ID_County", Tag<regions::CountyId>{});
auto district_id = obj.expect_optional("ID_District", Tag<regions::DistrictId>{});
return mio::apply(
io,
[](auto nf, auto d, auto&& a_str, auto sid, auto cid, auto did) -> IOResult<VaccinationDataEntry> {
[](auto nf, auto nf2, auto d, auto&& a_str, auto sid, auto cid,
auto did) -> IOResult<VaccinationDataEntry> {
auto it = std::find(age_group_names.begin(), age_group_names.end(), a_str);
auto a = AgeGroup(0);
if (it != age_group_names.end()) {
Expand All @@ -484,9 +486,10 @@ class VaccinationDataEntry
else {
return failure(StatusCode::InvalidValue, "Invalid vaccination data age group.");
}
return success(VaccinationDataEntry{nf, d, a, sid, cid, did});
return success(VaccinationDataEntry{nf, nf2, d, a, sid, cid, did});
},
num_vaccinations_completed, date, age_group_str, state_id, county_id, district_id);
num_vaccinations_completed, num_vaccinations_partially, date, age_group_str, state_id, county_id,
district_id);
}
};

Expand Down
6 changes: 5 additions & 1 deletion cpp/memilio/io/result_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,15 @@ IOResult<void> save_result_with_params(const std::vector<TimeSeries<double>>& re
template <class Model>
IOResult<void> save_results(const std::vector<std::vector<TimeSeries<double>>>& ensemble_results,
const std::vector<std::vector<Model>>& ensemble_params, const std::vector<int>& county_ids,
const fs::path& result_dir, bool save_single_runs = true, bool save_percentiles = true)
const fs::path& result_dir, bool save_single_runs = true, bool save_percentiles = true,
bool just_one_ag = false)
{
//save results and sum of results over nodes
auto ensemble_result_sum = sum_nodes(ensemble_results);
auto num_groups = (int)(size_t)ensemble_params[0][0].parameters.get_num_groups();
if (just_one_ag) {
num_groups = 1;
}
if (save_single_runs) {
for (size_t i = 0; i < ensemble_result_sum.size(); ++i) {
BOOST_OUTCOME_TRY(save_result(ensemble_result_sum[i], {0}, num_groups,
Expand Down
25 changes: 21 additions & 4 deletions cpp/memilio/utils/random_number_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ static_assert(sizeof(Key<uint32_t>) == sizeof(uint32_t), "Empty Base Optimizatio
* @tparam an unsigned integer type that determines the size of the counter, i.e., the length of the random sequence.
*/
template <class T>
struct MEMILIO_ENABLE_EBO Counter : TypeSafe<T, Counter<T>>, OperatorComparison<Counter<T>>, OperatorAdditionSubtraction<Counter<T>> {
struct MEMILIO_ENABLE_EBO Counter : TypeSafe<T, Counter<T>>,
OperatorComparison<Counter<T>>,
OperatorAdditionSubtraction<Counter<T>> {
static_assert(std::is_unsigned<T>::value, "Underlying Integer type must be unsigned.");
using TypeSafe<T, Counter<T>>::TypeSafe;
};
Expand Down Expand Up @@ -243,12 +245,13 @@ Counter<UIntC> rng_totalsequence_counter(UIntN subsequence_idx, CounterS counter
static_assert(N_BITS <= C_BITS, "Subsequence index must not be bigger than total sequence counter.");
static_assert(N_BITS <= sizeof(UIntN) * BITS_PER_BYTE, "Subsequence index must be at least N bits");

assert(UIntC(subsequence_idx) <= (UIntC(1) << N_BITS) && "Subsequence index is too large."); //(1 << N) is the same as (2^N)
assert(UIntC(subsequence_idx) <= (UIntC(1) << N_BITS) &&
"Subsequence index is too large."); //(1 << N) is the same as (2^N)

//N high bits: subsequence idx
//S low bits: subsequence counter
//=> C = N + S bits: total sequence counter
//example:
//example:
//subsequence index uint32_t(181) = 0x000000B5
//subsequence counter uint32_t(41309) = 0x0000A15D
//total sequence counter = 0x000000B50000A15D
Expand All @@ -271,7 +274,7 @@ Counter<UIntC> rng_totalsequence_counter(UIntN subsequence_idx, CounterS counter
template <class UIntS, class CounterC>
Counter<UIntS> rng_subsequence_counter(CounterC counter)
{
using UIntC = typename CounterC::ValueType;
using UIntC = typename CounterC::ValueType;
static const UIntC C_BYTES = sizeof(UIntC);
static const UIntC S_BYTES = sizeof(UIntS);

Expand Down Expand Up @@ -673,6 +676,20 @@ using UniformDistribution = DistributionAdapter<std::uniform_real_distribution<R
template <class Int>
using PoissonDistribution = DistributionAdapter<std::poisson_distribution<Int>>;

/**
* adapted lognormal_distribution.
* @see DistributionAdapter
*/
template <class Real>
using LogNormalDistribution = DistributionAdapter<std::lognormal_distribution<Real>>;

/**
* adapted gamma_distribution.
* @see DistributionAdapter
*/
template <class Real>
using GammaDistribution = DistributionAdapter<std::gamma_distribution<Real>>;

} // namespace mio

#endif
1 change: 1 addition & 0 deletions cpp/models/abm/abm.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@
#include "abm/vaccine.h"
#include "abm/household.h"
#include "abm/lockdown_rules.h"
#include "abm/analyze_result.h"

#endif
Loading