Skip to content

Commit 65caee5

Browse files
committed
add export to csv to ode tutorials, adapt numbering, adapt cmakelists
1 parent 4bdc5c1 commit 65caee5

15 files changed

Lines changed: 59 additions & 28 deletions

cpp-tutorials/CMakeLists.txt

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,29 +46,20 @@ target_link_libraries(tutorial_ide PRIVATE memilio ide_secir)
4646
add_executable(tutorial_lct tutorial_lct.cpp)
4747
target_link_libraries(tutorial_lct PRIVATE memilio lct_secir)
4848

49-
add_executable(tutorial1 tutorial1.cpp)
50-
target_link_libraries(tutorial1 PRIVATE memilio ode_secir Boost::filesystem)
49+
add_executable(tutorial01 tutorial01.cpp)
50+
target_link_libraries(tutorial01 PRIVATE memilio ode_secir Boost::filesystem)
5151

52-
add_executable(tutorial2 tutorial2.cpp)
53-
target_link_libraries(tutorial2 PRIVATE memilio ode_secir Boost::filesystem)
52+
add_executable(tutorial02 tutorial02.cpp)
53+
target_link_libraries(tutorial02 PRIVATE memilio ode_secir Boost::filesystem)
5454

55-
add_executable(tutorial3 tutorial3.cpp)
56-
target_link_libraries(tutorial3 PRIVATE memilio ode_secir Boost::filesystem)
55+
add_executable(tutorial03 tutorial03.cpp)
56+
target_link_libraries(tutorial03 PRIVATE memilio ode_secir Boost::filesystem)
5757

58-
add_executable(exercise3 exercises/exercise3.cpp)
59-
target_link_libraries(exercise3 PRIVATE memilio ode_secir Boost::filesystem)
58+
add_executable(tutorial05 tutorial05.cpp)
59+
target_link_libraries(tutorial05 PRIVATE memilio ode_secir Boost::filesystem)
6060

61-
add_executable(tutorial5 tutorial5.cpp)
62-
target_link_libraries(tutorial5 PRIVATE memilio ode_secir Boost::filesystem)
63-
64-
add_executable(exercise5 exercises/exercise5.cpp)
65-
target_link_libraries(exercise5 PRIVATE memilio ode_secir Boost::filesystem)
66-
67-
add_executable(tutorial7 tutorial7.cpp)
68-
target_link_libraries(tutorial7 PRIVATE memilio ode_secir Boost::filesystem)
69-
70-
add_executable(exercise7 exercises/exercise7.cpp)
71-
target_link_libraries(exercise7 PRIVATE memilio ode_secir Boost::filesystem)
61+
add_executable(tutorial07 tutorial07.cpp)
62+
target_link_libraries(tutorial07 PRIVATE memilio ode_secir Boost::filesystem)
7263

7364
add_executable(tutorial10 tutorial10.cpp)
7465
target_link_libraries(tutorial10 PRIVATE memilio ode_secir Boost::filesystem)

cpp-tutorials/exercises/CMakeLists.txt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11

2-
add_executable(exercise1 exercise1.cpp)
3-
target_link_libraries(exercise1 PRIVATE memilio ode_secir Boost::filesystem)
2+
add_executable(exercise01 exercise01.cpp)
3+
target_link_libraries(exercise01 PRIVATE memilio ode_secir Boost::filesystem)
44

5-
add_executable(exercise2 exercise2.cpp)
6-
target_link_libraries(exercise2 PRIVATE memilio ode_secir Boost::filesystem)
5+
add_executable(exercise02 exercise02.cpp)
6+
target_link_libraries(exercise02 PRIVATE memilio ode_secir Boost::filesystem)
7+
8+
add_executable(exercise03 exercise03.cpp)
9+
target_link_libraries(exercise03 PRIVATE memilio ode_secir Boost::filesystem)
10+
11+
add_executable(exercise05 exercise05.cpp)
12+
target_link_libraries(exercise05 PRIVATE memilio ode_secir Boost::filesystem)
13+
14+
add_executable(exercise07 exercise07.cpp)
15+
target_link_libraries(exercise07 PRIVATE memilio ode_secir Boost::filesystem)
716

817
add_executable(exercise10 exercise10.cpp)
918
target_link_libraries(exercise10 PRIVATE memilio ode_secir Boost::filesystem)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,7 @@ int main()
6060

6161
// *** Print results. ***
6262
interpolated_result.print_table({"S", "E", "C", "C_confirmed", "I", "I_confirmed", "H", "U", "R", "D"}, 12, 4);
63+
64+
// We export the results as csv which is saved in the current folder. Then we can plot the results using plot_secir_results.py.
65+
auto export_status = result.export_csv("../../cpp-tutorials/exercises/results_ode.csv");
6366
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,7 @@ int main()
5858

5959
// *** Print results. ***
6060
interpolated_result.print_table({"S", "E", "C", "C_confirmed", "I", "I_confirmed", "H", "U", "R", "D"}, 12, 4);
61+
62+
// We export the results as csv which is saved in the current folder. Then we can plot the results using plot_secir_results.py.
63+
auto export_status = result.export_csv("../../cpp-tutorials/exercises/results_ode_npis.csv");
6164
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ int main()
4444
model.parameters.get<mio::osecir::CriticalPerSevere<ScalarType>>()[mio::AgeGroup(1)] = 0.25 * 1.5;
4545
model.parameters.get<mio::osecir::CriticalPerSevere<ScalarType>>()[mio::AgeGroup(2)] = 0.25 * 2;
4646

47+
//EXERCISE: Please increase the percentage of severe cases per symptomatic cases in age group 2 by 10%.
48+
4749
//Set contact frequency
4850
ScalarType contact_frequency = 10;
4951
mio::ContactMatrixGroup<ScalarType>& contact_matrix =
@@ -69,4 +71,7 @@ int main()
6971

7072
// *** Print results. ***
7173
interpolated_result.print_table();
74+
75+
// We export the results as csv which is saved in the current folder. Then we can plot the results using plot_secir_results.py.
76+
auto export_status = result.export_csv("../../cpp-tutorials/exercises/results_ode_ageres.csv");
7277
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,7 @@ int main()
111111

112112
// *** Print results. ***
113113
interpolated_result_r0.print_table();
114+
115+
// We export the results for region 0 as csv which is saved in the current folder. Then we can plot the results using plot_secir_results.py.
116+
auto export_status = result_region0.export_csv("../../cpp-tutorials/exercises/results_ode_region0.csv");
114117
}

cpp-tutorials/exercises/exercise_ide.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,5 +155,5 @@ int main()
155155
{"S->E", "E->C", "C->I", "C->R", "I->H", "I->R", "H->U", "H->R", "U->D", "U->R"}, 12, 4);
156156

157157
// We export the results as csv which is saved in the current folder. Then we can plot the results using plot_secir_results.py.
158-
auto export_status = sim.get_result().export_csv("../../cpp-tutorials/results_ide.csv");
158+
auto export_status = sim.get_result().export_csv("../../cpp-tutorials/exercises/results_ide.csv");
159159
}

cpp-tutorials/exercises/exercise_lct.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,12 @@ int main()
132132
interpolated_results.print_table({"S", "E", "C", "I", "H", "U", "R", "D "}, 12, 4);
133133

134134
// We export the results as csv which is saved in the current folder. Then we can plot the results using plot_secir_results.py.
135-
auto export_status = population_no_subcompartments.export_csv("../../cpp-tutorials/results_lct.csv");
135+
auto export_status = population_no_subcompartments.export_csv("../../cpp-tutorials/exercises/results_lct.csv");
136+
137+
if (export_status == mio::success()) {
138+
std::cout << "success \n";
139+
}
140+
else {
141+
std::cout << "no success\n";
142+
}
136143
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,7 @@ int main()
5757

5858
// *** Print results. ***
5959
interpolated_result.print_table({"S", "E", "C", "C_confirmed", "I", "I_confirmed", "H", "U", "R", "D"}, 12, 4);
60+
61+
// We export the results as csv which is saved in the current folder. Then we can plot the results using plot_secir_results.py.
62+
auto export_status = result.export_csv("../../cpp-tutorials/results_ode.csv");
6063
}

0 commit comments

Comments
 (0)