Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
197 commits
Select commit Hold shift + click to select a range
1679386
CHG: Docstring improveent
kilianvolmer Jul 16, 2025
83e789a
CHG: Docs trings update
kilianvolmer Jul 16, 2025
027358e
CHG: asymetric mobility introduction
kilianvolmer Jul 16, 2025
5a97cee
Merge branch 'main' into 1318-add-graph-with-timed-edges
kilianvolmer Jul 16, 2025
bf0aeab
FIX: typo
kilianvolmer Jul 16, 2025
e03d661
CHG: Add functions for parameter lookups
kilianvolmer Jul 16, 2025
80ef21a
NEW: asymmetric graph example
kilianvolmer Jul 18, 2025
bc05c3c
CHG: Add example MobilityEdge constructor
kilianvolmer Jul 18, 2025
0581191
CHG: Update directed edge implementation
kilianvolmer Jul 18, 2025
97fc970
CHG: Change parameters of apply_mobility
kilianvolmer Jul 25, 2025
5cc5213
CHG: add asymmetric graph
kilianvolmer Jul 25, 2025
8e49488
CHG: update TimedEdge
kilianvolmer Jul 25, 2025
ee13153
CHG: Add smm to example
kilianvolmer Jul 25, 2025
5a498b4
FIX: dimensions error
kilianvolmer Jul 28, 2025
c246556
FIX: link smm in CMake
kilianvolmer Jul 30, 2025
1ded562
CHG: update asymmetric graph
kilianvolmer Jul 30, 2025
fcf84e5
FIX: Use Smm simulation
kilianvolmer Jul 30, 2025
302beac
CHG: functional minimal asymmetric graph example
kilianvolmer Jul 30, 2025
301beef
CHG: full example code
kilianvolmer Jul 31, 2025
d176a05
CHG: Move heap from edges into graph
kilianvolmer Aug 1, 2025
f9c737e
Merge branch 'main' into 1318-add-graph-with-timed-edges
kilianvolmer Aug 1, 2025
5798064
CHG: Move geographical location to location file in memilio/geography
kilianvolmer Aug 5, 2025
122abea
CHG: Make node params protected
kilianvolmer Aug 5, 2025
89991f1
CHG: add mio::unused
kilianvolmer Aug 5, 2025
8674242
CHG: remove omp
kilianvolmer Aug 5, 2025
304c788
CHG:
kilianvolmer Aug 5, 2025
41839e5
FIX: asymmetric graph simulation using LocationNode
kilianvolmer Aug 6, 2025
0fd3f11
CHG: multiplications instead of divisions
kilianvolmer Aug 6, 2025
837de04
CHG: Add tests for GeographicalLocation
kilianvolmer Aug 6, 2025
b5415b8
CHG: remove make_asymmetric_mobility_sim
kilianvolmer Aug 6, 2025
5213747
CHG: Update LocationNode Constructor
kilianvolmer Aug 6, 2025
2af6d2c
CHG: Move geographical location to location file in memilio/geography
kilianvolmer Aug 5, 2025
02d6a37
CHG: multiplications instead of divisions
kilianvolmer Aug 6, 2025
abdb2f9
CHG: Add tests for GeographicalLocation
kilianvolmer Aug 6, 2025
7888062
CHG: Add data_types entry for GeographicLocation
kilianvolmer Aug 8, 2025
2905b84
NEW: add r-Tree to mio::geo
kilianvolmer Aug 11, 2025
2e27acd
CHG: add getter_functions for lat, long to Location Node
kilianvolmer Aug 11, 2025
ca6646f
CHG: unnecessary changes for CI
kilianvolmer Aug 12, 2025
ad9afc5
CHG: Make latitude and longitude privat
kilianvolmer Aug 12, 2025
b557c86
Merge branch '1342-Make-GeographicLocation-available-to-all-of-MEmili…
kilianvolmer Aug 12, 2025
711a25f
CHG: remove duplicate tests
kilianvolmer Aug 12, 2025
c5edf45
CHG: use ifndefs
kilianvolmer Aug 12, 2025
3ce4001
CHG: try fix CI as CI compiler does not support our c++ language stan…
kilianvolmer Aug 12, 2025
5a213de
CHG: Try fix CI
kilianvolmer Aug 12, 2025
91b066d
CHG: switch names of Location and geography tests
kilianvolmer Aug 12, 2025
07aeafe
CHG: update inlcludes and use numbers constants
kilianvolmer Aug 12, 2025
298e62e
CHG: Update includes
kilianvolmer Aug 12, 2025
26e72d9
Merge branch '1342-Make-GeographicLocation-available-to-all-of-MEmili…
kilianvolmer Aug 12, 2025
38e6d4c
CHG: explicitly denote pi for memilio.simulation to work
kilianvolmer Aug 12, 2025
bac5307
CHG: Make tree available in Timed Graph
kilianvolmer Aug 12, 2025
51ab550
CHG: functional smm example with agegroups, rest is broken
kilianvolmer Aug 13, 2025
6ae71d5
CHG: Speed up multiple neighbour queries
kilianvolmer Aug 13, 2025
3b9d953
FIX: inrange query km conversion, added test
kilianvolmer Aug 14, 2025
9de2584
CHG: add inrange query
kilianvolmer Aug 14, 2025
ae4cd25
Merge branch '1342-Make-GeographicLocation-available-to-all-of-MEmili…
kilianvolmer Aug 14, 2025
ab531a5
CHG: log exchanges of specified classes on the edges
kilianvolmer Aug 15, 2025
a871ba6
first working example
reneSchm Sep 3, 2025
d78bd7c
CHG: functional base model with template parameter list (not used yet)
kilianvolmer Sep 9, 2025
f2babee
CHG: Another compiling status that is not leading anywhere
kilianvolmer Sep 9, 2025
bf4b839
CHG: Compiling example with multiple age groups
kilianvolmer Sep 9, 2025
cdba056
Compiling solution without code duplicates
kilianvolmer Sep 9, 2025
c0cb41b
CHG: semifunctional state
kilianvolmer Sep 12, 2025
f65c9b2
typename FPMerge branch 'main' into abm-parameter-study
reneSchm Sep 17, 2025
ee5143b
CHG: Change numbers in rates
kilianvolmer Sep 26, 2025
4823827
CHG: Move Influence into AdoptionRate
kilianvolmer Sep 26, 2025
8932144
CHG: Update influences
kilianvolmer Oct 1, 2025
098e1ff
CHG: Change location of N, modify tests
kilianvolmer Oct 1, 2025
dcda987
[skip ci] CHG: Update Header
kilianvolmer Oct 1, 2025
ace1754
Merge branch 'main' into 1341-SMM-model-with-more-indices
kilianvolmer Oct 1, 2025
c58b74a
[skip ci] Update copyright information
kilianvolmer Oct 2, 2025
17cd0b9
CHG: REplace FLOAT test by double test
kilianvolmer Oct 2, 2025
1477021
Merge branch 'main' into 1318-add-graph-with-timed-edges
kilianvolmer Oct 2, 2025
78fb407
FIX: Add FPs
kilianvolmer Oct 2, 2025
0d9a09a
Merge branch '1341-SMM-model-with-more-indices' into 1318-add-graph-w…
kilianvolmer Oct 2, 2025
f37fbe1
Revert "[skip ci] Update copyright information"
kilianvolmer Oct 9, 2025
225004f
Merge branch 'main' into 1318-add-graph-with-timed-edges
kilianvolmer Oct 9, 2025
7f69da2
[wip] parameter studies v2
reneSchm Oct 9, 2025
eaaa5c2
[wip] add run_idx to create_sim function
reneSchm Oct 9, 2025
280afa5
mpi wokrks
xsaschako Oct 9, 2025
59708a8
CHG: Add CSV import for nodes, edges and exchanges
kilianvolmer Oct 9, 2025
88d7822
CHG: make smm simulation copy constructible
kilianvolmer Oct 9, 2025
a9ad34c
CHG: use nodes instead of edges
kilianvolmer Oct 15, 2025
1d2c5fe
CHG: add get_edge function
kilianvolmer Oct 15, 2025
c969d09
CHG: Filter for impossible exchanges
kilianvolmer Oct 15, 2025
6e8cb01
CHG: add reference?
kilianvolmer Oct 16, 2025
f52035d
use ParameterStudy2 in ode_secir examples
reneSchm Oct 16, 2025
6df3ab5
Merge branch 'abm-parameter-study' of github.com:SciCompMod/memilio i…
reneSchm Oct 16, 2025
e1a5c8f
FIX: multiple fixes
kilianvolmer Oct 16, 2025
9b9cbbd
CHG: clean up
kilianvolmer Oct 17, 2025
20dae7a
CHG: Add some missing TimeSeries features
kilianvolmer Oct 17, 2025
4b21c0a
CHG: Add quarantine option to LocaitonNode
kilianvolmer Oct 17, 2025
670c2f6
CHG: Add data collection and quarantines
kilianvolmer Oct 17, 2025
06d33f3
CHG: Clean up and add new functionality to example
kilianvolmer Oct 17, 2025
5176657
FIX: remove wrong includes
kilianvolmer Oct 17, 2025
47088f7
[wip] remove old ParameterStudies from cpp
reneSchm Oct 21, 2025
703e03a
Merge branch 'main' into abm-parameter-study
reneSchm Oct 21, 2025
2646042
Fix up ode_secir_read_graph
reneSchm Oct 21, 2025
9b593f5
patch python bindings to mostly emulate old ParameterStudy behaviour
reneSchm Oct 22, 2025
df4f000
explicit type conversion
reneSchm Oct 22, 2025
2d278c0
another explicit type conversion
reneSchm Oct 22, 2025
5fa14f4
improve coverage
reneSchm Oct 22, 2025
1e90200
CHG: minor possible improvements
kilianvolmer Oct 22, 2025
f505d35
CHG: New compartmental model
kilianvolmer Oct 23, 2025
c6e292a
move abm study, restore minimal abm
reneSchm Oct 23, 2025
3af580c
clean up examples, improve mpi handling
reneSchm Oct 23, 2025
4371622
add hdf5 dep to abm study example
reneSchm Oct 23, 2025
fe9ef05
improve non-PS coverage
reneSchm Oct 24, 2025
fcde395
remove Simulation template from ParameterStudy2.
reneSchm Oct 24, 2025
63b7a6d
remove developement artifacts
reneSchm Oct 24, 2025
9bae572
small cleanup, add test
reneSchm Oct 27, 2025
9e1de1e
Merge branch 'main' into abm-parameter-study
reneSchm Oct 27, 2025
651f1ba
change name back to ParameterStudy
reneSchm Oct 28, 2025
dab1c99
CHG: Add timers
kilianvolmer Oct 29, 2025
b5048d8
CHG: Add timers
kilianvolmer Oct 29, 2025
82cdfb1
Merge branch '1318-add-graph-with-timed-edges' of github.com:SciCompM…
kilianvolmer Oct 29, 2025
99e42d4
.
kilianvolmer Oct 29, 2025
187b36a
FIX
kilianvolmer Oct 29, 2025
bdc7cd6
CHG: Add -Wno-shadow
kilianvolmer Oct 29, 2025
ea3acde
update parameters to run
xsaschako Oct 29, 2025
fe1fb5c
CHG: Add more timers
kilianvolmer Oct 29, 2025
f23f5ff
Revert "update parameters to run"
reneSchm Oct 29, 2025
67f5af2
CHG: add more timers
kilianvolmer Oct 29, 2025
7a0b95d
Merge branch 'main' into 1318-add-graph-with-timed-edges
kilianvolmer Oct 29, 2025
70eee6b
Clean up merge
kilianvolmer Oct 29, 2025
955b205
FIX: Add rtree constructor from range again
kilianvolmer Oct 29, 2025
e85da31
CHG: Use global rng
kilianvolmer Oct 30, 2025
032491e
CHG: use global rng in edge function
kilianvolmer Oct 30, 2025
1b44d15
CHG: use global rng
kilianvolmer Oct 30, 2025
d33e36f
NEW: file for real data experiments
kilianvolmer Oct 30, 2025
21f06c6
CHG: Access parameters of the models
kilianvolmer Oct 30, 2025
c0b9101
Merge remote-tracking branch 'origin/abm-parameter-study' into 1318-a…
kilianvolmer Oct 30, 2025
e69f080
CHG: Add MPI parameter study
kilianvolmer Oct 31, 2025
4872829
CHG: Add local infectivity
kilianvolmer Oct 31, 2025
d75742d
Update data reader
kilianvolmer Nov 3, 2025
06a67b9
CHG: Add timers
kilianvolmer Nov 4, 2025
a8f94dd
NEW: Benchmarking file
kilianvolmer Nov 4, 2025
3715084
CHG: Add make_edges_unique
kilianvolmer Nov 5, 2025
b8566ee
CHG: Don't check edges uniqueness in lazy_add_edge
kilianvolmer Nov 5, 2025
317ecf2
CHG: Try add MPI distribution for rtree queries
kilianvolmer Nov 5, 2025
a4ec96c
FIX: MPI distributed rtree queries work
kilianvolmer Nov 5, 2025
f736260
CHG: Clean up parameter study
kilianvolmer Nov 5, 2025
e40c9c2
CHG: Add correctness check for current code version
kilianvolmer Nov 5, 2025
6e6c60a
CHG: remove correctness check
kilianvolmer Nov 5, 2025
14c753c
CHG: Update file
kilianvolmer Nov 5, 2025
e46e15e
CHG: Add Culling, vaccination
kilianvolmer Nov 6, 2025
b0c5e31
CHG: Add vaccination to advance function
kilianvolmer Nov 6, 2025
42accae
CHG: Add lazy edge addition function
kilianvolmer Nov 6, 2025
d14011b
FIX: start edge generation with correct node index
kilianvolmer Nov 6, 2025
6bb9762
CHG: Add vaccinations
kilianvolmer Nov 6, 2025
0f68aba
CHG: use more farms
kilianvolmer Nov 6, 2025
7fa39ae
CHG: Rename make_edges_unique
kilianvolmer Nov 12, 2025
52bbf8f
CHG: Add timer for advance function
kilianvolmer Nov 12, 2025
c237bb5
CHG: files for performance comparison
kilianvolmer Nov 12, 2025
3e5ad8e
CHG: Store first detection time
kilianvolmer Nov 13, 2025
32b1bec
CHG: Make add_edge void
kilianvolmer Nov 14, 2025
9b37c77
CHG: Make add_node void
kilianvolmer Nov 14, 2025
d908d71
CHG: Add GraphBuilder
kilianvolmer Nov 14, 2025
447a7ca
CHG: try fix bindigs
kilianvolmer Nov 14, 2025
928d01a
Merge branch 'main' into 1410-accelerate-add-edges-for-large-graphs
kilianvolmer Nov 14, 2025
5f35220
CHG: try fix bindings
kilianvolmer Nov 14, 2025
b08003b
Apply suggestions from code review
kilianvolmer Nov 17, 2025
be9571c
CHG: Add suggestions from code review
kilianvolmer Nov 17, 2025
5c6fed4
CHG: Add table
kilianvolmer Nov 17, 2025
7b2e073
Merge branch '1410-accelerate-add-edges-for-large-graphs' of github.c…
kilianvolmer Nov 17, 2025
c547df8
CHG: add new function for benchmarking
kilianvolmer Nov 17, 2025
43a3280
Merge branch '1410-accelerate-add-edges-for-large-graphs' into 1318-a…
kilianvolmer Nov 17, 2025
97e7dc6
Merge branch 'main' into 1341-SMM-model-with-more-indices
reneSchm Nov 21, 2025
d367215
generalize Region and State
reneSchm Nov 21, 2025
3337b98
CHG: Keep last edge instad of first one
kilianvolmer Nov 25, 2025
8355370
CHG: Print warning when duplicate edges are deleted
kilianvolmer Nov 25, 2025
69cb4e5
Merge branch '1410-accelerate-add-edges-for-large-graphs' into 1318-a…
kilianvolmer Nov 25, 2025
bdff456
CHG: Benchmarking script for new method comparison
kilianvolmer Nov 25, 2025
5a0f431
[ci skip] Add benchmark results to docs
kilianvolmer Nov 25, 2025
08691ec
Merge branch '1410-accelerate-add-edges-for-large-graphs' into 1318-a…
kilianvolmer Nov 25, 2025
673aae6
Merge branch 'main' into 1318-add-graph-with-timed-edges
kilianvolmer Nov 25, 2025
72a3304
fix asserts for debug builds
reneSchm Nov 25, 2025
d47625c
change test to use region as part of status
reneSchm Nov 25, 2025
fa4a0f7
CHG: Apply suggestions from code review
kilianvolmer Nov 26, 2025
3f3d421
FIX: use std::move on builder
kilianvolmer Nov 26, 2025
785275e
CHG: Move GraphBuilder to own file
kilianvolmer Nov 26, 2025
3cb8456
CHG: Simplify function
kilianvolmer Nov 26, 2025
807cb20
Merge branch '1410-accelerate-add-edges-for-large-graphs' into 1318-a…
kilianvolmer Nov 26, 2025
2648742
Merge branch 'main' into 1318-add-graph-with-timed-edges
kilianvolmer Nov 27, 2025
66a7347
CHG: ADd builder
kilianvolmer Nov 27, 2025
6c11210
CHG: Use GraphBuilder
kilianvolmer Nov 27, 2025
cfad582
FIX
kilianvolmer Nov 27, 2025
e0b4548
CHG: Use Builder
kilianvolmer Nov 27, 2025
d2deb8f
CHG: improve docstrings
kilianvolmer Dec 15, 2025
168116b
CHG: Update smm.rst
kilianvolmer Dec 15, 2025
5058c96
polish code docs
reneSchm Dec 19, 2025
b832df6
Merge branch 'main' into 1318-add-graph-with-timed-edges
kilianvolmer Jan 12, 2026
d62a115
Merge branch '1341-SMM-model-with-generic-indices' into 1318-add-grap…
kilianvolmer Jan 13, 2026
78efe34
Merge branch '1341-SMM-model-with-generic-indices' into 1318-add-grap…
kilianvolmer Jan 13, 2026
1604206
CHG: Cleanup
kilianvolmer Jan 13, 2026
541f430
CHG: Clean up adoption rates
kilianvolmer Jan 13, 2026
39e4c05
CHG: different arbitrary adoption rates
kilianvolmer Jan 14, 2026
11db1d2
CHG: Change params to search for infections via trade network
kilianvolmer Jan 14, 2026
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
2 changes: 1 addition & 1 deletion cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ endif()
# exclude some warnings we accept
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
string(APPEND MEMILIO_CXX_FLAGS_ENABLE_WARNING_ERRORS
"-Wno-unknown-warning;-Wno-pragmas;-Wno-deprecated-copy;-Wno-expansion-to-defined;")
"-Wno-unknown-warning;-Wno-pragmas;-Wno-deprecated-copy;-Wno-expansion-to-defined;-Wno-shadow;")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
string(APPEND MEMILIO_CXX_FLAGS_ENABLE_WARNING_ERRORS
"-Wno-unknown-warning-option;-Wno-deprecated;-Wno-gnu-zero-variadic-macro-arguments;")
Expand Down
16 changes: 16 additions & 0 deletions cpp/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,22 @@ add_executable(graph_stochastic_mobility_example graph_stochastic_mobility.cpp)
target_link_libraries(graph_stochastic_mobility_example PRIVATE memilio ode_secir)
target_compile_options(graph_stochastic_mobility_example PRIVATE ${MEMILIO_CXX_FLAGS_ENABLE_WARNING_ERRORS})

add_executable(asymmetric_graph_example asymmetric_graph.cpp)
target_link_libraries(asymmetric_graph_example PRIVATE memilio smm)
target_compile_options(asymmetric_graph_example PRIVATE ${MEMILIO_CXX_FLAGS_ENABLE_WARNING_ERRORS})

add_executable(asymmetric_graph_data asym_ex_data.cpp)
target_link_libraries(asymmetric_graph_data PRIVATE memilio smm)
target_compile_options(asymmetric_graph_data PRIVATE ${MEMILIO_CXX_FLAGS_ENABLE_WARNING_ERRORS})

add_executable(asym_ben asym_graph_ben.cpp)
target_link_libraries(asym_ben PRIVATE memilio smm)
target_compile_options(asym_ben PRIVATE ${MEMILIO_CXX_FLAGS_ENABLE_WARNING_ERRORS})

add_executable(asymmetric_params asymmetric_params.cpp)
target_link_libraries(asymmetric_params PRIVATE memilio smm)
target_compile_options(asymmetric_params PRIVATE ${MEMILIO_CXX_FLAGS_ENABLE_WARNING_ERRORS})

add_executable(abm_minimal_example abm_minimal.cpp)
target_link_libraries(abm_minimal_example PRIVATE memilio abm)
target_compile_options(abm_minimal_example PRIVATE ${MEMILIO_CXX_FLAGS_ENABLE_WARNING_ERRORS})
Expand Down
2 changes: 1 addition & 1 deletion cpp/examples/abm_parameter_study.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,4 @@ int main()
mio::mpi::finalize();

return 0;
}
}
121 changes: 121 additions & 0 deletions cpp/examples/asym_ex_data.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/*
* Copyright (C) 2020-2025 MEmilio
*
* Authors: Kilian Volmer
*
* Contact: Martin J. Kuehn <[email protected]>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "memilio/config.h"
#include "memilio/geography/geolocation.h"
#include "memilio/geography/rtree.h"
#include "memilio/geography/distance.h"
#include "memilio/mobility/graph_simulation.h"
#include "memilio/mobility/metapopulation_mobility_asymmetric.h"
#include "memilio/mobility/graph.h"
#include "memilio/mobility/graph_builder.h"
#include "memilio/utils/compiler_diagnostics.h"
#include "memilio/utils/index.h"
#include "memilio/utils/logging.h"
#include "memilio/timer/auto_timer.h"
#include "memilio/utils/parameter_distributions.h"
#include "memilio/utils/random_number_generator.h"
#include "smm/simulation.h"
#include "smm/parameters.h"
#include "fmd/infection_state.h"
#include "fmd/model.h"
#include "fmd/adoption_rates.h"
#include "thirdparty/csv.h"
#include <ranges>
#include <omp.h>

int main(int /*argc*/, char** /*argv*/)
{
const auto t0 = 0.;
const auto tmax = 1000.;
const auto dt = 1.; //initial time step
using mio::fmd::InfectionState;
using Status = mio::Index<InfectionState>;
using mio::regions::Region;

//total compartment sizes

using Model = mio::smm::Model<ScalarType, InfectionState, Status, Region>;

mio::fmd::Builder builder;
mio::log_info("Starting Graph generation");
{
mio::timing::AutoTimer<"Graph Nodes Generation"> timer;
io::CSVReader<4> farms("/home/kilian/Documents/data/read_data/farms.csv");
farms.read_header(io::ignore_extra_column, "id_dec", "x", "y", "farm_size");
size_t farm_id, num_cows;
double latitude, longitude;
while (farms.read_row(farm_id, latitude, longitude, num_cows)) {
auto curr_model = mio::fmd::create_model(num_cows, mio::fmd::generic_adoption_rates());
builder.add_node(farm_id, longitude, latitude, curr_model, t0);
}
}
mio::log_info("Nodes added to Graph");
auto rng = mio::RandomNumberGenerator();

std::vector<std::vector<size_t>> interesting_indices;
interesting_indices.push_back(
{Model(Status{InfectionState::Count}, Region(1)).populations.get_flat_index({Region(0), InfectionState::I})});

{
mio::timing::AutoTimer<"Graph Edges Generation"> timer;
io::CSVReader<2> edges("/home/kilian/Documents/data/read_data/edges.csv");
edges.read_header(io::ignore_extra_column, "from", "to");
size_t from, to;
while (edges.read_row(from, to)) {
builder.add_edge(from, to, interesting_indices);
}
}
auto graph = std::move(builder).build();
mio::log_info("Graph generated");

mio::fmd::generate_neighbours(graph, {mio::geo::kilometers(2.0)});

mio::log_info("Neighbors set");
auto sim = mio::make_mobility_sim(t0, dt, std::move(graph));

io::CSVReader<4> exchanges("/home/kilian/Documents/data/read_data/exchanges.csv");
exchanges.read_header(io::ignore_extra_column, "from_dec", "to_dec", "day", "weight");

size_t date, num_animals;
size_t from, to;
while (exchanges.read_row(from, to, date, num_animals)) {
sim.add_exchange(date, num_animals, from, to);
}
mio::log_info("Exchanges added");

// #ifdef MEMILIO_ENABLE_OPENMP
// #pragma omp parallel for
// for (size_t i = 0; i < 100; ++i) {
// #endif

auto sim2(sim);
mio::log_info("new Simulation created");

sim2.advance(tmax);
mio::log_info("Simulation finished");

auto sth = sim2.exchanges_per_timestep().export_csv("Exchange_statistics.csv", {"Commuter Sick", "Commuter Total"});

sth = sim2.statistics_per_timestep().export_csv("Simulation_statistics.csv");

mio::log_info("Finished postprocessing");

return 0;
}
168 changes: 168 additions & 0 deletions cpp/examples/asym_graph_ben.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
/*
* Copyright (C) 2020-2025 MEmilio
*
* Authors: Kilian Volmer
*
* Contact: Martin J. Kuehn <[email protected]>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "memilio/config.h"
#include "memilio/geography/geolocation.h"
#include "memilio/geography/rtree.h"
#include "memilio/geography/distance.h"
#include "memilio/mobility/graph_simulation.h"
#include "memilio/mobility/metapopulation_mobility_asymmetric.h"
#include "memilio/mobility/graph.h"
#include "memilio/mobility/graph_builder.h"
#include "memilio/utils/compiler_diagnostics.h"
#include "memilio/utils/index.h"
#include "memilio/utils/logging.h"
#include "memilio/timer/auto_timer.h"
#include "memilio/utils/parameter_distributions.h"
#include "memilio/utils/random_number_generator.h"
#include "smm/simulation.h"
#include "smm/parameters.h"
#include "fmd/infection_state.h"
#include "fmd/model.h"
#include "fmd/adoption_rates.h"
#include "thirdparty/csv.h"
#include <ranges>
#include <omp.h>
#include <chrono>

int main(int /*argc*/, char** /*argv*/)
{
const auto t0 = 0.;
// const auto tmax = 100.;
const auto dt = 1.; //initial time step

//total compartment sizes
using mio::fmd::InfectionState;
using Status = mio::Index<InfectionState>;
using mio::regions::Region;

using Model = mio::smm::Model<ScalarType, InfectionState, Status, Region>;
auto home = Region(0);

auto adoption_rates = mio::fmd::generic_adoption_rates();

mio::log_info("Reading CSVs");
std::vector<ScalarType> latitudes, longitudes;
std::vector<int> farm_ids, num_cows_vec, dates, num_animals_exchanges;
std::vector<int> froms, tos, from_exchanges, to_exchanges;
io::CSVReader<4> farms("../../../farms16mio.csv");
farms.read_header(io::ignore_extra_column, "farms", "num_cows", "latitude", "longitude");
int farm_id, num_cows;
double latitude, longitude;
while (farms.read_row(farm_id, num_cows, latitude, longitude)) {
farm_ids.push_back(farm_id);
num_cows_vec.push_back(num_cows);
latitudes.push_back(latitude);
longitudes.push_back(longitude);
}
io::CSVReader<2> edges("../../../edges16mio.csv");
edges.read_header(io::ignore_extra_column, "from", "to");
size_t from, to;
while (edges.read_row(from, to)) {
froms.push_back(from);
tos.push_back(to);
}
io::CSVReader<4> exchanges("../../../trade16mio.csv");
exchanges.read_header(io::ignore_extra_column, "date", "num_animals", "from", "to");
int date, num_animals;
while (exchanges.read_row(date, num_animals, from, to)) {
dates.push_back(date);
num_animals_exchanges.push_back(num_animals);
from_exchanges.push_back(from);
to_exchanges.push_back(to);
}
std::vector<std::vector<size_t>> interesting_indices;
interesting_indices.push_back(
{Model(Status{InfectionState::Count}, Region(1)).populations.get_flat_index({home, InfectionState::I})});

for (size_t num_edges_benchmark = 1024; num_edges_benchmark < 16000000; num_edges_benchmark *= 2) {
mio::log_info("Running with {} edges", num_edges_benchmark);

mio::fmd::Graph graph;
mio::fmd::Builder builder;

auto start = std::chrono::high_resolution_clock::now();

for (size_t i = 0; i < farm_ids.size(); ++i) {
Model curr_model(Status{InfectionState::Count}, Region(1));
curr_model.populations[{home, InfectionState::S}] = num_cows_vec[i];
curr_model.populations[{home, InfectionState::E}] = 0;
curr_model.populations[{home, InfectionState::I}] = 0;
curr_model.populations[{home, InfectionState::INS}] = 0;
curr_model.populations[{home, InfectionState::ICS}] = 0;
curr_model.populations[{home, InfectionState::R}] = 0;
curr_model.populations[{home, InfectionState::V}] = 0;
curr_model.populations[{home, InfectionState::D}] = 0;
curr_model.parameters.get<mio::smm::AdoptionRates<ScalarType, Status, Region>>() = adoption_rates;
graph.add_node(farm_ids[i], longitudes[i], latitudes[i], curr_model, t0);
}
auto rng = mio::RandomNumberGenerator();

for (size_t i = 0; i < num_edges_benchmark; ++i) {
graph.add_edge(froms[i], tos[i], interesting_indices);
}
auto end = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);

mio::log_info("Classic graph generation finished for {} edges in {} milliseconds", num_edges_benchmark,
duration.count());
start = std::chrono::high_resolution_clock::now();
for (size_t i = 0; i < farm_ids.size(); ++i) {
Model curr_model(Status{InfectionState::Count}, Region(1));
curr_model.populations[{home, InfectionState::S}] = num_cows_vec[i];
curr_model.populations[{home, InfectionState::E}] = 0;
curr_model.populations[{home, InfectionState::I}] = 0;
curr_model.populations[{home, InfectionState::INS}] = 0;
curr_model.populations[{home, InfectionState::ICS}] = 0;
curr_model.populations[{home, InfectionState::R}] = 0;
curr_model.populations[{home, InfectionState::V}] = 0;
curr_model.populations[{home, InfectionState::D}] = 0;
curr_model.parameters.get<mio::smm::AdoptionRates<ScalarType, Status, Region>>() = adoption_rates;
builder.add_node(farm_ids[i], longitudes[i], latitudes[i], curr_model, t0);
}
for (size_t i = 0; i < num_edges_benchmark; ++i) {
builder.add_edge(from_exchanges[i], to_exchanges[i], interesting_indices);
}
auto graph2 = std::move(builder).build(true);
end = std::chrono::high_resolution_clock::now();
duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);

mio::log_info("New graph construction finished using {} edges in {} milliseconds", num_edges_benchmark,
duration.count());

// auto nodes = graph.nodes() | std::views::transform([](const auto& node) {
// return &node.property;
// });
// auto tree = mio::geo::RTree(nodes.begin(), nodes.end());

// for (auto& node : graph.nodes()) {
// node.property.set_regional_neighbors(
// tree.in_range_indices_query(node.property.get_location(), {mio::geo::kilometers(2.0)}));
// }

auto sim = mio::make_mobility_sim(t0, dt, std::move(graph));

for (size_t i = 0; i < dates.size(); ++i) {
sim.add_exchange(dates[i], num_animals_exchanges[i], from_exchanges[i], to_exchanges[i]);
}

mio::log_info("Starting and immediately finishing simulation");
}
return 0;
}
Loading
Loading