Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
5075322
added first ideas
lenaploetzke Apr 3, 2024
ac16bc6
added command for b2 headers
lenaploetzke Apr 3, 2024
13e4d4a
change command for msvc
lenaploetzke Apr 4, 2024
6820e42
changed to .bat
lenaploetzke Apr 4, 2024
cb02f40
delete invalid character
lenaploetzke Apr 4, 2024
f8e7be6
use other slashes
lenaploetzke Apr 4, 2024
da1a8c0
try "
lenaploetzke Apr 4, 2024
eb59ff2
rm ./
lenaploetzke Apr 4, 2024
3ff1487
update boost version
lenaploetzke Apr 8, 2024
84f3911
rm auto keyword
lenaploetzke Apr 8, 2024
23b08cf
add auto
lenaploetzke Apr 8, 2024
f94fa5d
try what happens
lenaploetzke Apr 8, 2024
7ce0e7a
add .exe
lenaploetzke Apr 8, 2024
7d53977
try two backslashes
lenaploetzke Apr 8, 2024
262496f
add cxx standard
lenaploetzke Apr 8, 2024
12bc2f4
rm quiet flag
lenaploetzke Apr 8, 2024
556b89a
add quiet flag
lenaploetzke Apr 8, 2024
0c12918
added flag
lenaploetzke Apr 8, 2024
e930a90
add start
lenaploetzke Apr 9, 2024
cd0c24b
add help flag
lenaploetzke Apr 9, 2024
7e84851
try dir
lenaploetzke Apr 9, 2024
ebbe4e1
just b2
lenaploetzke Apr 9, 2024
19a0f9f
problem with "
lenaploetzke Apr 9, 2024
9bab72c
b2 quiet again
lenaploetzke Apr 9, 2024
f84d083
adapted documentation
lenaploetzke Apr 9, 2024
653334c
added if clause
lenaploetzke Apr 10, 2024
6e09cc6
Included reviewer suggestions
lenaploetzke Apr 10, 2024
7517f99
Update cpp/memilio/math/README.md
lenaploetzke Apr 11, 2024
568e22e
added reviewer suggestions
lenaploetzke Apr 12, 2024
5213953
use add_custom_target
lenaploetzke Apr 12, 2024
07c1f87
removed actions quiet
lenaploetzke Apr 15, 2024
6fa5805
aded ls
lenaploetzke Apr 15, 2024
fa914c2
added an option for pycode generation
lenaploetzke Apr 15, 2024
f8fecba
added ALL flag
lenaploetzke Apr 15, 2024
f69f3f7
try to add boost headers to wheel
reneSchm Apr 16, 2024
332dc6f
try to delay listing boost dirs
reneSchm Apr 16, 2024
8d12ba6
try double wildcard instead of listing files
reneSchm Apr 16, 2024
0136aa0
try a glob
reneSchm Apr 16, 2024
2fadf93
try to add build in test explicitly
lenaploetzke Apr 17, 2024
db30e10
added reviewer suggestions
lenaploetzke Apr 18, 2024
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/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The following table lists the dependencies that are used. Most of them are requi
|---------|----------|----------|-----------------------|-------|
| spdlog | 1.11.0 | Yes | Yes (git repo) | https://github.com/gabime/spdlog |
| Eigen | 3.3.9 | Yes | Yes (git repo) | http://gitlab.com/libeigen/eigen |
| Boost | 1.75.0 | Yes | Yes (.tar.gz archive) | https://www.boost.org/ |
| Boost | 1.84.0 | Yes | Yes (git repo) | https://github.com/boostorg/boost |
| JsonCpp | 1.9.5 | No | Yes (git repo) | https://github.com/open-source-parsers/jsoncpp |
| HDF5 | 1.12.0 | No | No | https://www.hdfgroup.org/, package libhdf5-dev on apt (Ubuntu) |
| GoogleTest | 1.10 | For Tests only | Yes (git repo) | https://github.com/google/googletest |
Expand Down
55 changes: 0 additions & 55 deletions cpp/cmake/BuildBoost.cmake

This file was deleted.

4 changes: 2 additions & 2 deletions cpp/examples/ode_secir_parameter_study.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ write_single_run_result(const size_t run,
const mio::Graph<mio::SimulationNode<mio::osecir::Simulation<>>, mio::MigrationEdge>& graph)
{
std::string abs_path;
BOOST_OUTCOME_TRY(created, mio::create_directory("results", abs_path));
BOOST_OUTCOME_TRY(auto&& created, mio::create_directory("results", abs_path));

if (run == 0) {
std::cout << "Results are stored in " << abs_path << '\n';
Expand All @@ -48,7 +48,7 @@ write_single_run_result(const size_t run,
//omit edges to save space as they are not sampled
int inode = 0;
for (auto&& node : graph.nodes()) {
BOOST_OUTCOME_TRY(js_node_model, serialize_json(node.property.get_result(), mio::IOF_OmitDistributions));
BOOST_OUTCOME_TRY(auto&& js_node_model, serialize_json(node.property.get_result(), mio::IOF_OmitDistributions));
Json::Value js_node(Json::objectValue);
js_node["NodeId"] = node.id;
js_node["Model"] = js_node_model;
Expand Down
4 changes: 2 additions & 2 deletions cpp/examples/serialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ mio::IOResult<void> print_json()
//If the operation failed, the error is returned immediately.
//If the operation was succesful, the result is unpacked and assigned to a new variable.
//e.g.
BOOST_OUTCOME_TRY(js, rslt);
//could also be BOOST_OUTCOME_TRY(js, mio::serialize_json(b)) in one line
BOOST_OUTCOME_TRY(auto&& js, rslt);
//could also be BOOST_OUTCOME_TRY(auto&& js, mio::serialize_json(b)) in one line

//print json (Json::Value) to console
//could also write to file or do anything else.
Expand Down
21 changes: 10 additions & 11 deletions cpp/memilio/io/binary_serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,7 @@ class BinarySerializerContext : public SerializerBase
BinarySerializerObject create_object(const std::string& type)
{
auto obj = BinarySerializerObject(m_stream, m_status, m_flags);
if (m_flags & IOF_IncludeTypeInfo)
{
if (m_flags & IOF_IncludeTypeInfo) {
obj.add_element("Type", type);
}
return obj;
Expand All @@ -269,13 +268,14 @@ class BinarySerializerContext : public SerializerBase
BinarySerializerObject expect_object(const std::string& type)
{
auto obj = BinarySerializerObject(m_stream, m_status, m_flags);
if (m_flags & IOF_IncludeTypeInfo)
{
if (m_flags & IOF_IncludeTypeInfo) {
auto type_result = obj.expect_element("Type", Tag<std::string>{});
if (!type_result) {
*m_status = IOStatus(StatusCode::InvalidType, "No TypeInfo in stream.");
} else if(type_result.value() != type) {
*m_status = IOStatus(StatusCode::InvalidType, "Unexpected type in stream:" + type_result.value() + ". Expected " + type);
}
else if (type_result.value() != type) {
*m_status = IOStatus(StatusCode::InvalidType,
"Unexpected type in stream:" + type_result.value() + ". Expected " + type);
}
}
return BinarySerializerObject(m_stream, m_status, m_flags);
Expand Down Expand Up @@ -400,11 +400,11 @@ template <class T>
IOResult<std::vector<T>> BinarySerializerObject::expect_list(const std::string& name, Tag<T>)
{
mio::unused(name);
BOOST_OUTCOME_TRY(size, expect_element("Size", Tag<size_t>{}));
BOOST_OUTCOME_TRY(auto&& size, expect_element("Size", Tag<size_t>{}));
std::vector<T> v;
v.reserve(size);
for (auto i = size_t(0); i < size; ++i) {
BOOST_OUTCOME_TRY(t, expect_element("Item", Tag<T>{}));
BOOST_OUTCOME_TRY(auto&& t, expect_element("Item", Tag<T>{}));
v.emplace_back(std::move(t));
}
return success(v);
Expand All @@ -424,9 +424,9 @@ template <class T>
IOResult<boost::optional<T>> BinarySerializerObject::expect_optional(const std::string& name, Tag<T>)
{
mio::unused(name);
BOOST_OUTCOME_TRY(size, expect_element("Exists", Tag<size_t>{}));
BOOST_OUTCOME_TRY(auto&& size, expect_element("Exists", Tag<size_t>{}));
if (size) {
BOOST_OUTCOME_TRY(t, expect_element("Value", Tag<T>{}));
BOOST_OUTCOME_TRY(auto&& t, expect_element("Value", Tag<T>{}));
return mio::success(t);
}
return mio::success(boost::optional<T>{});
Expand All @@ -448,7 +448,6 @@ ByteStream serialize_binary(const T& t, int flags = 0)
return stream;
}


/**
* Deserialize an object from binary format.
* @param stream ByteStream that contains the bytes that represent the object.
Expand Down
2 changes: 1 addition & 1 deletion cpp/memilio/io/cli.h
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ mio::IOResult<void> command_line_interface(const std::string& executable_name, c
i++; // skip the PrintOption argument
for (; i < argc && !Identifier(argv[i]).is_option(); i++) {
// try to get the parameter's json value
BOOST_OUTCOME_TRY(value, get_param(parameters, argv[i]));
BOOST_OUTCOME_TRY(auto&& value, get_param(parameters, argv[i]));
// print the name (or alias) and value
os << "Option " << argv[i] << ":\n" << value << "\n";
}
Expand Down
2 changes: 1 addition & 1 deletion cpp/memilio/io/epi_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ std::vector<const char*> VaccinationDataEntry::age_group_names = {"0-4", "5-14",

IOResult<std::vector<int>> get_node_ids(const std::string& path, bool is_node_for_county, bool rki_age_groups)
{
BOOST_OUTCOME_TRY(population_data, read_population_data(path, rki_age_groups));
BOOST_OUTCOME_TRY(auto&& population_data, read_population_data(path, rki_age_groups));
std::vector<int> id;
id.reserve(population_data.size());
for (auto&& entry : population_data) {
Expand Down
14 changes: 7 additions & 7 deletions cpp/memilio/io/epi_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class StringDate : public Date
return apply(
io,
[](auto&& str_) -> IOResult<StringDate> {
BOOST_OUTCOME_TRY(date, parse_date(str_));
BOOST_OUTCOME_TRY(auto&& date, parse_date(str_));
return success(date);
},
str);
Expand Down Expand Up @@ -177,7 +177,7 @@ class ConfirmedCasesDataEntry
*/
inline IOResult<std::vector<ConfirmedCasesDataEntry>> deserialize_confirmed_cases_data(const Json::Value& jsvalue)
{
BOOST_OUTCOME_TRY(cases_data, deserialize_json(jsvalue, Tag<std::vector<ConfirmedCasesDataEntry>>{}));
BOOST_OUTCOME_TRY(auto&& cases_data, deserialize_json(jsvalue, Tag<std::vector<ConfirmedCasesDataEntry>>{}));
//filter entries with unknown age group
auto it = std::remove_if(cases_data.begin(), cases_data.end(), [](auto&& rki_entry) {
return rki_entry.age_group >= AgeGroup(ConfirmedCasesDataEntry::age_group_names.size());
Expand All @@ -193,7 +193,7 @@ inline IOResult<std::vector<ConfirmedCasesDataEntry>> deserialize_confirmed_case
*/
inline IOResult<std::vector<ConfirmedCasesDataEntry>> read_confirmed_cases_data(const std::string& filename)
{
BOOST_OUTCOME_TRY(jsvalue, read_json(filename));
BOOST_OUTCOME_TRY(auto&& jsvalue, read_json(filename));
return deserialize_confirmed_cases_data(jsvalue);
}

Expand Down Expand Up @@ -259,7 +259,7 @@ IOResult<std::vector<T>> unpack_all(const std::vector<IOResult<T>>& v)
std::vector<T> w;
w.reserve(v.size());
for (auto&& r : v) {
BOOST_OUTCOME_TRY(t, r);
BOOST_OUTCOME_TRY(auto&& t, r);
w.push_back(t);
}
return success(w);
Expand Down Expand Up @@ -400,7 +400,7 @@ interpolate_to_rki_age_groups(const std::vector<PopulationDataEntry>& population
inline IOResult<std::vector<PopulationDataEntry>> deserialize_population_data(const Json::Value& jsvalue,
bool rki_age_groups = true)
{
BOOST_OUTCOME_TRY(population_data, deserialize_json(jsvalue, Tag<std::vector<PopulationDataEntry>>{}));
BOOST_OUTCOME_TRY(auto&& population_data, deserialize_json(jsvalue, Tag<std::vector<PopulationDataEntry>>{}));
if (rki_age_groups) {
return success(details::interpolate_to_rki_age_groups(population_data));
}
Expand All @@ -418,7 +418,7 @@ inline IOResult<std::vector<PopulationDataEntry>> deserialize_population_data(co
inline IOResult<std::vector<PopulationDataEntry>> read_population_data(const std::string& filename,
bool rki_age_group = true)
{
BOOST_OUTCOME_TRY(jsvalue, read_json(filename));
BOOST_OUTCOME_TRY(auto&& jsvalue, read_json(filename));
return deserialize_population_data(jsvalue, rki_age_group);
}

Expand Down Expand Up @@ -507,7 +507,7 @@ inline IOResult<std::vector<VaccinationDataEntry>> deserialize_vaccination_data(
*/
inline IOResult<std::vector<VaccinationDataEntry>> read_vaccination_data(const std::string& filename)
{
BOOST_OUTCOME_TRY(jsvalue, read_json(filename));
BOOST_OUTCOME_TRY(auto&& jsvalue, read_json(filename));
return deserialize_vaccination_data(jsvalue);
}

Expand Down
6 changes: 3 additions & 3 deletions cpp/memilio/io/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ inline const std::error_code& make_error_code(const IOStatus& status)
* extern void use_int(int i);
* IOResult<void> parse_and_use_int(const std::string& s)
* {
* BOOST_OUTCOME_TRY(i, parse_int(s));
* BOOST_OUTCOME_TRY(auto&& i, parse_int(s));
* use_int(i);
* return success();
* }
Expand Down Expand Up @@ -482,7 +482,7 @@ details::ApplyResultT<F, T...> apply(IOContext& io, F f, const IOResult<T>&... r
IOStatus status[] = {(rs ? IOStatus{} : rs.error())...};
auto iter_err = std::find_if(std::begin(status), std::end(status), [](auto& s) {
return s.is_error();
});
});

//evaluate f if all succesful
auto result =
Expand Down Expand Up @@ -658,7 +658,7 @@ void serialize_internal(IOContext& io, E e)
template <class IOContext, class E, std::enable_if_t<std::is_enum<E>::value, void*> = nullptr>
IOResult<E> deserialize_internal(IOContext& io, Tag<E> /*tag*/)
{
BOOST_OUTCOME_TRY(i, mio::deserialize(io, mio::Tag<std::underlying_type_t<E>>{}));
BOOST_OUTCOME_TRY(auto&& i, mio::deserialize(io, mio::Tag<std::underlying_type_t<E>>{}));
return success(E(i));
}

Expand Down
6 changes: 3 additions & 3 deletions cpp/memilio/io/json_serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ class JsonContext : public SerializerBase
Container v;
for (auto&& el : array) {
auto ctxt = JsonContext(el, io.m_status, io.m_flags);
BOOST_OUTCOME_TRY(val, mio::deserialize(ctxt, Tag<typename Container::value_type>{}));
BOOST_OUTCOME_TRY(auto&& val, mio::deserialize(ctxt, Tag<typename Container::value_type>{}));
v.insert(v.end(), val);
}
return success(std::move(v));
Expand Down Expand Up @@ -502,7 +502,7 @@ IOResult<Json::Value> serialize_json(const T& t, int flags = IOF_None)
template <class T>
IOResult<void> write_json(const std::string& path, const T& t, int flags = IOF_None)
{
BOOST_OUTCOME_TRY(js, serialize_json(t, flags));
BOOST_OUTCOME_TRY(auto&& js, serialize_json(t, flags));
return write_json(path, js);
}

Expand Down Expand Up @@ -552,7 +552,7 @@ IOResult<T> deserialize_json(const Json::Value& js, Tag<T> tag, int flags = IOF_
template <class T>
IOResult<T> read_json(const std::string& path, Tag<T> tag, int flags = IOF_None)
{
BOOST_OUTCOME_TRY(js, read_json(path));
BOOST_OUTCOME_TRY(auto&& js, read_json(path));
return deserialize_json(js, tag, flags);
}

Expand Down
4 changes: 2 additions & 2 deletions cpp/memilio/io/mobility_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ IOResult<int> count_lines(const std::string& filename)

IOResult<Eigen::MatrixXd> read_mobility_formatted(const std::string& filename)
{
BOOST_OUTCOME_TRY(num_lines, count_lines(filename));
BOOST_OUTCOME_TRY(auto&& num_lines, count_lines(filename));

if (num_lines == 0) {
return success(Eigen::MatrixXd(0, 0));
Expand Down Expand Up @@ -99,7 +99,7 @@ IOResult<Eigen::MatrixXd> read_mobility_formatted(const std::string& filename)

IOResult<Eigen::MatrixXd> read_mobility_plain(const std::string& filename)
{
BOOST_OUTCOME_TRY(num_lines, count_lines(filename));
BOOST_OUTCOME_TRY(auto&& num_lines, count_lines(filename));

if (num_lines == 0) {
return success(Eigen::MatrixXd(0, 0));
Expand Down
15 changes: 8 additions & 7 deletions cpp/memilio/io/mobility_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ IOResult<void> write_graph(const Graph<Model, MigrationParameters>& graph, const
assert(graph.nodes().size() > 0 && "Graph Nodes are empty");

std::string abs_path;
BOOST_OUTCOME_TRY(created, create_directory(directory, abs_path));
BOOST_OUTCOME_TRY(auto&& created, create_directory(directory, abs_path));

if (created) {
log_info("Results are stored in {:s}/results.", mio::get_current_dir_name());
Expand All @@ -97,7 +97,7 @@ IOResult<void> write_graph(const Graph<Model, MigrationParameters>& graph, const
for (auto inode = size_t(0); inode < graph.nodes().size(); ++inode) {
//node
const auto node = graph.nodes()[inode];
BOOST_OUTCOME_TRY(js_node_model, serialize_json(node.property, ioflags));
BOOST_OUTCOME_TRY(auto&& js_node_model, serialize_json(node.property, ioflags));
Json::Value js_node(Json::objectValue);
js_node["NodeId"] = node.id;
js_node["Model"] = js_node_model;
Expand All @@ -109,7 +109,7 @@ IOResult<void> write_graph(const Graph<Model, MigrationParameters>& graph, const
if (out_edges.size()) {
Json::Value js_edges(Json::arrayValue);
for (auto& e : graph.out_edges(inode)) {
BOOST_OUTCOME_TRY(js_edge_params, serialize_json(e.property, ioflags));
BOOST_OUTCOME_TRY(auto&& js_edge_params, serialize_json(e.property, ioflags));
Json::Value js_edge{Json::objectValue};
js_edge["StartNodeIndex"] = Json::UInt64(e.start_node_idx);
js_edge["EndNodeIndex"] = Json::UInt64(e.end_node_idx);
Expand Down Expand Up @@ -150,13 +150,13 @@ IOResult<Graph<Model, MigrationParameters>> read_graph(const std::string& direct
if (!file_exists(node_filename, node_filename)) {
break;
}
BOOST_OUTCOME_TRY(js_node, read_json(node_filename));
BOOST_OUTCOME_TRY(auto&& js_node, read_json(node_filename));
if (!js_node["NodeId"].isInt()) {
log_error("NodeId field must be an integer.");
return failure(StatusCode::InvalidType, node_filename + ", NodeId must be an integer.");
}
auto node_id = js_node["NodeId"].asInt();
BOOST_OUTCOME_TRY(model, deserialize_json(js_node["Model"], Tag<Model>{}, ioflags));
BOOST_OUTCOME_TRY(auto&& model, deserialize_json(js_node["Model"], Tag<Model>{}, ioflags));
graph.add_node(node_id, model);
}

Expand All @@ -165,7 +165,7 @@ IOResult<Graph<Model, MigrationParameters>> read_graph(const std::string& direct
for (auto inode = size_t(0); inode < graph.nodes().size(); ++inode) {
//list of edges
auto edge_filename = path_join(abs_path, "GraphEdges_node" + std::to_string(inode) + ".json");
BOOST_OUTCOME_TRY(js_edges, read_json(edge_filename));
BOOST_OUTCOME_TRY(auto&& js_edges, read_json(edge_filename));

for (auto& e : js_edges) {
auto start_node_idx = inode;
Expand All @@ -180,7 +180,8 @@ IOResult<Graph<Model, MigrationParameters>> read_graph(const std::string& direct
return failure(StatusCode::OutOfRange,
edge_filename + ", EndNodeIndex not in range of number of graph nodes.");
}
BOOST_OUTCOME_TRY(parameters, deserialize_json(e["Parameters"], Tag<MigrationParameters>{}, ioflags));
BOOST_OUTCOME_TRY(auto&& parameters,
deserialize_json(e["Parameters"], Tag<MigrationParameters>{}, ioflags));
graph.add_edge(start_node_idx, end_node_idx, parameters);
}
}
Expand Down
Loading