Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9061f4d
move utils/base_dir.h to io/directories.h,
reneSchm Apr 17, 2026
3130ae9
add create_directory_or_exit as a shortcut for opening directories in…
reneSchm Apr 17, 2026
ead1d74
move example output using example_result_dir,
reneSchm Apr 17, 2026
73eefeb
replace result output with print_table
reneSchm Apr 17, 2026
9b7977c
use correct cmake method for path options
reneSchm Apr 20, 2026
f5c0357
make std::filesystem::path loggable
reneSchm Apr 21, 2026
3e74eae
switch from boost::filesystem to std::filesystem,
reneSchm Apr 21, 2026
45efdcb
update sbml converter
reneSchm Apr 21, 2026
e283c3d
update benchmark config dir syntax
reneSchm Apr 21, 2026
e68bb7f
start of msvc workarounds
reneSchm Apr 21, 2026
f2325a5
msvc workarounds 2
reneSchm Apr 21, 2026
b705009
msvc workarounds 3
reneSchm Apr 21, 2026
e33d453
msvc workarounds 4
reneSchm Apr 22, 2026
26f97ff
msvc workarounds 5
reneSchm Apr 22, 2026
d59fd5e
speed up sbml test by not building test suite
reneSchm Apr 22, 2026
4889b64
serialize paths as (generic) string,
reneSchm Apr 22, 2026
a9f635c
add tests for new features
reneSchm Apr 22, 2026
ea84545
[ci skip] update version strings
reneSchm Apr 22, 2026
caa5e4a
msvc workarounds 6
reneSchm Apr 22, 2026
5a16a0e
remove path serialization due to msvc bug
reneSchm Apr 22, 2026
e387735
shorten create_directory using ternaries
reneSchm Apr 23, 2026
8aa3aaf
Merge branch 'main' into 1429-move-example-output-to-example_results
reneSchm May 6, 2026
c2b5467
add include for apple build
reneSchm May 6, 2026
3f7722a
clean up directories.h implementation
reneSchm May 8, 2026
7ab3b40
fixes from review
reneSchm May 8, 2026
1d3ee5c
bump python version for CI
reneSchm May 8, 2026
b6bf68c
bump pre-commit-hooks and match cpython versions
reneSchm May 8, 2026
5442935
bump pyupgrade
reneSchm May 8, 2026
f478f1a
fully upgrade to python 3.9+,
reneSchm May 8, 2026
e71745d
try newer twill version
reneSchm May 8, 2026
d99adb8
abandon 3.14 and downgrade to 3.13 for now
reneSchm May 8, 2026
905ad80
try letting pip choose newer pyfakefs
reneSchm May 8, 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
16 changes: 8 additions & 8 deletions .github/actions/build-py/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ runs:
cd pycode/memilio-${{ inputs.package }}/
# else stay in root directory
fi
/opt/python/cp38-cp38/bin/python -m pip install --upgrade pip setuptools wheel
/opt/python/cp312-cp312/bin/python -m pip install --upgrade pip setuptools wheel
/opt/python/cp38-cp38/bin/python -m pip install scikit-build scikit-build-core
/opt/python/cp312-cp312/bin/python -m pip install scikit-build scikit-build-core
/opt/python/cp39-cp39/bin/python -m pip install --upgrade pip setuptools wheel
/opt/python/cp314-cp314/bin/python -m pip install --upgrade pip setuptools wheel
/opt/python/cp39-cp39/bin/python -m pip install scikit-build scikit-build-core
/opt/python/cp314-cp314/bin/python -m pip install scikit-build scikit-build-core
# Install setuptools-scm only for memilio-simulation
if [ "${{ inputs.package }}" == "simulation" ]; then
/opt/python/cp38-cp38/bin/python -m pip install setuptools-scm
/opt/python/cp312-cp312/bin/python -m pip install setuptools-scm
/opt/python/cp39-cp39/bin/python -m pip install setuptools-scm
/opt/python/cp314-cp314/bin/python -m pip install setuptools-scm
fi
/opt/python/cp38-cp38/bin/python -m build --no-isolation --wheel
/opt/python/cp312-cp312/bin/python -m build --no-isolation --wheel
/opt/python/cp39-cp39/bin/python -m build --no-isolation --wheel
/opt/python/cp314-cp314/bin/python -m build --no-isolation --wheel
# Exclude memilio-generation, because its a pure python package, cmake is only used in the build process to retrieve data from cpp
if [[ -f "CMakeLists.txt" ]] && [ "${{ inputs.package }}" != "generation" ]; then
# includes native dependencies in the wheel
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/sbml-test/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ runs:
shell: bash
run: |
cd cpp/build
cmake -DCMAKE_BUILD_TYPE=Release -DMEMILIO_ENABLE_SBML=ON -Dsbml_DIR=/usr/lib/x86_64-linux-gnu/cmake ..
cmake -DCMAKE_BUILD_TYPE=Release -DMEMILIO_BUILD_TESTS=OFF -DMEMILIO_ENABLE_SBML=ON -Dsbml_DIR=/usr/lib/x86_64-linux-gnu/cmake ..
cmake --build . -j 4
- name: Run SBML importer
shell: bash
Expand All @@ -49,5 +49,5 @@ runs:
shell: bash
run: |
cd cpp/build
cmake -DCMAKE_BUILD_TYPE=Release -DMEMILIO_ENABLE_SBML=ON -Dsbml_DIR=/usr/lib/x86_64-linux-gnu/cmake ..
cmake -DCMAKE_BUILD_TYPE=Release -DMEMILIO_BUILD_TESTS=OFF -DMEMILIO_ENABLE_SBML=ON -Dsbml_DIR=/usr/lib/x86_64-linux-gnu/cmake ..
cmake --build . -j 4
2 changes: 1 addition & 1 deletion .github/actions/test-py/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ inputs:
version:
description: "Python version to use for the test."
required: false
default: "3.8"
default: "3.9"
coverage:
description: "Generate coverage report from running the tests, ON or OFF, default OFF."
required: false
Expand Down
8 changes: 4 additions & 4 deletions .github/actions/test-pylint/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ runs:
sudo apt-get -qq update
sudo apt-get -qq -y install python3-pip gnupg
python -m pip install --upgrade pip
# Pylint runs against the prebuilt wheels in pycode/wheelhouse/*cp312*.
# Pylint runs against the prebuilt wheels in pycode/wheelhouse/*cp314*.
# So, use current latest supported Python version.
- name: Set up Python 3.12
- name: Set up Python 3.13
uses: actions/setup-python@v6
with:
python-version: "3.12"
python-version: "3.13"
- name: Download Python Wheels
uses: actions/download-artifact@v7
with:
Expand All @@ -28,7 +28,7 @@ runs:
shell: bash
run: |
shopt -s nullglob
for pkg in pycode/wheelhouse/*cp312*.whl; do python -m pip install "$pkg"; done # packages that contain native extensions are version specific
for pkg in pycode/wheelhouse/*cp314*.whl; do python -m pip install "$pkg"; done # packages that contain native extensions are version specific
for pkg in pycode/wheelhouse/*py3*.whl; do python -m pip install "$pkg"; done # pure python packages are not version specific
python -m pip install --upgrade-strategy only-if-needed --prefer-binary --find-links pycode/wheelhouse "memilio-${{ inputs.package }}[dev]"
- name: Run pylint
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/epidata_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: 3.12
python-version: 3.13
- uses: pre-commit/action@v3.0.1

build-py-epidata:
Expand All @@ -51,7 +51,7 @@ jobs:
needs: build-py-epidata
strategy:
matrix:
version: ["3.8", "3.12"]
version: ["3.9", "3.13"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
Expand All @@ -66,7 +66,7 @@ jobs:
needs: [build-py-plot, build-py-epidata]
strategy:
matrix:
version: ["3.8", "3.12"]
version: ["3.9", "3.13"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
Expand Down Expand Up @@ -123,13 +123,13 @@ jobs:
with:
name: python-wheels-epidata
path: pycode/wheelhouse
- name: Set up Python 3.12
- name: Set up Python 3.13
uses: actions/setup-python@v6
with:
python-version: 3.12
python-version: 3.13
- name: Install Python Wheels
run: |
for pkg in `ls pycode/wheelhouse/*cp312*.whl`; do python -m pip install $pkg; done # packages that contain native extensions are version specific
for pkg in `ls pycode/wheelhouse/*cp314*.whl`; do python -m pip install $pkg; done # packages that contain native extensions are version specific
for pkg in `ls pycode/wheelhouse/*py3*.whl`; do python -m pip install $pkg; done # pure python packages are not version specific
- name: Download Data
run: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: 3.12
python-version: 3.13
- uses: pre-commit/action@v3.0.1

build-cpp-gcc_clang:
Expand Down Expand Up @@ -339,7 +339,7 @@ jobs:
if: github.event.pull_request.draft == false
strategy:
matrix:
version: ["3.8", "3.12"]
version: ["3.9", "3.13"]
needs: build-py-generation
runs-on: ubuntu-latest
steps:
Expand All @@ -353,7 +353,7 @@ jobs:
needs: build-py-simulation
strategy:
matrix:
version: ["3.8", "3.12"]
version: ["3.9", "3.13"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
Expand All @@ -366,7 +366,7 @@ jobs:
needs: [build-py-surrogatemodel, build-py-simulation]
strategy:
matrix:
version: ["3.8", "3.12"]
version: ["3.9", "3.13"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
exclude: ^(docs|cpp)/
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v6.0.0
hooks:
- id: check-merge-conflict
- id: check-yaml
- repo: https://github.com/asottile/pyupgrade
rev: v3.2.2
rev: v3.21.2
hooks:
- id: pyupgrade
args: [--py37-plus]
args: [--py39-plus]
- repo: https://github.com/hhatto/autopep8
rev: v2.3.2
hooks:
Expand Down
19 changes: 15 additions & 4 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,21 @@ option(MEMILIO_ENABLE_IPOPT "Enable numerical optimization with Ipopt, requires
option(MEMILIO_ENABLE_PROFILING "Enable runtime performance profiling of memilio." OFF)
option(MEMILIO_ENABLE_LIKWID_MARKER "Enable performance measuring with likwid markers." OFF)

mark_as_advanced(MEMILIO_USE_BUNDLED_SPDLOG MEMILIO_SANITIZE_ADDRESS MEMILIO_SANITIZE_UNDEFINED)
cmake_path(CONVERT "${PROJECT_SOURCE_DIR}/.." TO_CMAKE_PATH_LIST PROJECT_ROOT_NORMALIZED NORMALIZE)
set(MEMILIO_BASE_DIR "${PROJECT_ROOT_NORMALIZED}" CACHE PATH
"Path to the MEmilio project root, used for file I/O. Accessed via mio::base_dir().")
set(MEMILIO_DATA_DIR "${PROJECT_ROOT_NORMALIZED}/data" CACHE PATH
"Path to the MEmilio data directory. Accessed via mio::data_dir().")

mark_as_advanced(
MEMILIO_USE_BUNDLED_SPDLOG
MEMILIO_SANITIZE_ADDRESS
MEMILIO_SANITIZE_UNDEFINED
MEMILIO_BUILD_SHARED_LIBS
MEMILIO_BUILD_STATIC_LIBS
MEMILIO_BASE_DIR
MEMILIO_DATA_DIR
)

# try to treat AppleClang as Clang, but warn about missing support
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
Expand Down Expand Up @@ -77,9 +91,6 @@ set(CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_INSTALL_RPATH "${CMAKE_BINARY_DIR}/lib" "${CMAKE_BINARY_DIR}/bin")

# sets MEMILIO_BASE_DIR to the directory containing cpp (i.e., the root of the git repo)
cmake_path(CONVERT "${PROJECT_SOURCE_DIR}/.." TO_CMAKE_PATH_LIST MEMILIO_BASE_DIR NORMALIZE)

# code coverage analysis
# Note: this only works under linux and with make
# Ninja creates different directory names which do not work together with this scrupt
Expand Down
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

| Library | Version | Required | Bundled | Notes |
|---------|----------|----------|-----------------------|-------|
| spdlog | 1.15.0 | Yes | Yes (git repo) | https://github.com/gabime/spdlog |
| spdlog | 1.17.0 | Yes | Yes (git repo) | https://github.com/gabime/spdlog |
| Eigen | 3.4.0 | Yes | Yes (git repo) | http://gitlab.com/libeigen/eigen |
| Boost | 1.84.0 | Yes | Yes (git repo) | https://github.com/boostorg/boost |
| JsonCpp | 1.9.6 | No | Yes (git repo) | https://github.com/open-source-parsers/jsoncpp |
Expand Down
4 changes: 2 additions & 2 deletions cpp/benchmarks/flow_simulation_ode_secirvvs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
#include "benchmarks/flow_simulation_ode_secirvvs.h"
#include "memilio/compartments/flow_simulation.h"
#include "memilio/compartments/simulation.h"
#include "memilio/utils/base_dir.h"
#include "memilio/io/directories.h"
#include "ode_secirvvs/model.h"
#include <string>

const std::string config_path = mio::base_dir() + "cpp/benchmarks/simulation.config";
const std::string config_path = (mio::base_dir() / "cpp/benchmarks/simulation.config").string();

// simulation without flows (not in Model definition and not calculated by Simulation)
void flowless_sim(::benchmark::State& state)
Expand Down
4 changes: 2 additions & 2 deletions cpp/benchmarks/flow_simulation_ode_seir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
#include "benchmarks/simulation.h"
#include "memilio/compartments/flow_simulation.h"
#include "memilio/compartments/simulation.h"
#include "memilio/utils/base_dir.h"
#include "memilio/io/directories.h"
#include "ode_seir/model.h"

#include <string>

const std::string config_path = mio::base_dir() + "cpp/benchmarks/simulation.config";
const std::string config_path = (mio::base_dir() / "cpp/benchmarks/simulation.config").string();

namespace mio
{
Expand Down
4 changes: 2 additions & 2 deletions cpp/benchmarks/graph_simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
#include "memilio/compartments/simulation.h"
#include "memilio/math/adapt_rk.h"
#include "memilio/mobility/metapopulation_mobility_instant.h"
#include "memilio/utils/base_dir.h"
#include "memilio/io/directories.h"
#include "ode_secirvvs/model.h"
#include <string>

const std::string config_path = mio::base_dir() + "cpp/benchmarks/graph_simulation.config";
const std::string config_path = (mio::base_dir() / "cpp/benchmarks/graph_simulation.config").string();

mio::osecirvvs::Model<ScalarType> create_model(size_t num_agegroups, const ScalarType tmax)
{
Expand Down
6 changes: 3 additions & 3 deletions cpp/benchmarks/integrator_step.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "memilio/math/adapt_rk.h"
#include "memilio/math/stepper_wrapper.h"
#include "memilio/utils/base_dir.h"
#include "memilio/io/directories.h"

template <class Integrator>
void integrator_step(::benchmark::State& state)
Expand All @@ -33,8 +33,8 @@ void integrator_step(::benchmark::State& state)
// with "num_agegroups" agegroups, and taking "yt" as the state of the simulation at "t_init"
// NOTE: yt must have #agegroups * #compartments entries
// benchmark setup
auto cfg =
mio::benchmark::IntegratorStepConfig::initialize(mio::base_dir() + "cpp/benchmarks/integrator_step.config");
auto cfg = mio::benchmark::IntegratorStepConfig::initialize(
(mio::base_dir() / "cpp/benchmarks/integrator_step.config").string());
//auto cfg = mio::benchmark::IntegratorStepConfig::initialize();
auto model = mio::benchmark::model::SecirAgeres(cfg.num_agegroups);
// set deriv function and integrator
Expand Down
5 changes: 3 additions & 2 deletions cpp/benchmarks/simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@

#include "memilio/math/adapt_rk.h"
#include "memilio/math/stepper_wrapper.h"
#include "memilio/utils/base_dir.h"
#include "memilio/io/directories.h"

template <class Integrator>
void simulation(::benchmark::State& state)
{
// suppress non-critical messages
mio::set_log_level(mio::LogLevel::critical);
// setup benchmark parameters
auto cfg = mio::benchmark::SimulationConfig::initialize(mio::base_dir() + "cpp/benchmarks/simulation.config");
auto cfg =
mio::benchmark::SimulationConfig::initialize((mio::base_dir() / "cpp/benchmarks/simulation.config").string());
//auto cfg = mio::benchmark::SimulationConfig::initialize(10);
auto model = mio::benchmark::model::SecirAgeres(cfg.num_agegroups);

Expand Down
26 changes: 11 additions & 15 deletions cpp/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# configure directory that contains the data files used by examples
file(TO_CMAKE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../data" MEMILIO_DATA_DIR)
configure_file(data_dir.h.in data_dir.h)

add_executable(euler_example euler_test.cpp)
target_link_libraries(euler_example PRIVATE memilio)
target_compile_options(euler_example PRIVATE ${MEMILIO_CXX_FLAGS_ENABLE_WARNING_ERRORS})
Expand All @@ -18,17 +14,17 @@ add_executable(adapt_rk_example adapt_rk_test.cpp)
target_link_libraries(adapt_rk_example PRIVATE memilio)
target_compile_options(adapt_rk_example PRIVATE ${MEMILIO_CXX_FLAGS_ENABLE_WARNING_ERRORS})

add_executable(ode_seir_example ode_seir.cpp)
target_link_libraries(ode_seir_example PRIVATE memilio ode_seir)
target_compile_options(ode_seir_example PRIVATE ${MEMILIO_CXX_FLAGS_ENABLE_WARNING_ERRORS})

add_executable(ode_seirdb_example ode_seirdb.cpp)
target_link_libraries(ode_seirdb_example PRIVATE memilio ode_seirdb)
target_compile_options(ode_seirdb_example PRIVATE ${MEMILIO_CXX_FLAGS_ENABLE_WARNING_ERRORS})

add_executable(ode_seir_ageres_example ode_seir_ageres.cpp)
target_link_libraries(ode_seir_ageres_example PRIVATE memilio ode_seir)
target_compile_options(ode_seir_ageres_example PRIVATE ${MEMILIO_CXX_FLAGS_ENABLE_WARNING_ERRORS})
add_executable(ode_seir_example ode_seir.cpp)
target_link_libraries(ode_seir_example PRIVATE memilio ode_seir)
target_compile_options(ode_seir_example PRIVATE ${MEMILIO_CXX_FLAGS_ENABLE_WARNING_ERRORS})
add_executable(ode_seirdb_example ode_seirdb.cpp)
target_link_libraries(ode_seirdb_example PRIVATE memilio ode_seirdb)
target_compile_options(ode_seirdb_example PRIVATE ${MEMILIO_CXX_FLAGS_ENABLE_WARNING_ERRORS})
add_executable(ode_seir_ageres_example ode_seir_ageres.cpp)
target_link_libraries(ode_seir_ageres_example PRIVATE memilio ode_seir)
target_compile_options(ode_seir_ageres_example PRIVATE ${MEMILIO_CXX_FLAGS_ENABLE_WARNING_ERRORS})

add_executable(ode_sir_example ode_sir.cpp)
target_link_libraries(ode_sir_example PRIVATE memilio ode_sir)
Expand Down
5 changes: 4 additions & 1 deletion cpp/examples/abm_history_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
#include "abm/simulation.h"
#include "abm/model.h"
#include "abm/location_type.h"
#include "memilio/io/io.h"
#include "memilio/utils/abstract_parameter_distribution.h"
#include "memilio/io/history.h"
#include "memilio/io/directories.h"
#include "memilio/utils/parameter_distributions.h"

#include <fstream>
Expand All @@ -43,7 +45,8 @@ void write_log_to_file(const T& history)
auto loc_id = std::get<1>(logg);
auto time_points = std::get<0>(logg);
std::string input;
std::ofstream myfile("test_output.txt");
std::ofstream myfile(mio::create_directories_or_exit(mio::example_results_dir("abm_history_object")) /
"test_output.txt");
myfile << "Locations as numbers:\n";
for (auto&& id : loc_id[0]) {
myfile << convert_loc_id_to_string(id) << "\n";
Expand Down
11 changes: 5 additions & 6 deletions cpp/examples/abm_minimal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "abm/lockdown_rules.h"
#include "abm/model.h"
#include "abm/common_abm_loggers.h"
#include "memilio/io/directories.h"

#include <fstream>

Expand Down Expand Up @@ -161,14 +162,12 @@ int main()
// Run the simulation until tmax with the history object.
sim.advance(tmax, historyTimeSeries);

// The results are written into the file "abm_minimal.txt" as a table with 9 columns.
// The first column is Time. The other columns correspond to the number of people with a certain infection state at this Time:
// Time = Time in days, S = Susceptible, E = Exposed, I_NS = InfectedNoSymptoms, I_Sy = InfectedSymptoms, I_Sev = InfectedSevere,
// I_Crit = InfectedCritical, R = Recovered, D = Dead
std::ofstream outfile("abm_minimal.txt");
// Write results to a file. Also print the filepath to make it easier to find
auto outpath = mio::create_directories_or_exit(mio::example_results_dir("abm_minimal")) / "history.txt";
std::ofstream outfile(outpath);
std::get<0>(historyTimeSeries.get_log())
.print_table(outfile, {"S", "E", "I_NS", "I_Sy", "I_Sev", "I_Crit", "R", "D"}, 7, 4);
std::cout << "Results written to abm_minimal.txt" << std::endl;
std::cout << "Results written to " << outpath << std::endl;

return 0;
}
Loading
Loading