Skip to content

Commit 912af85

Browse files
authored
Merge pull request #9 from SteveBronder/feature/benchmarks
Benchmarks against solve_ivp
2 parents 0fdd859 + fb06dcd commit 912af85

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+8384
-3041
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@ build/*
22
examples/build/*
33
riccati/__pycache__/*
44
.vscode/*
5-
env/*
5+
.venv/*
66
tests/python/__pycache__/test*
7+
nohup.out
8+
src/pyriccaticpp/__pycache__/*.pyc

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ project(
55
LANGUAGES C CXX)
66

77
include(FetchContent)
8-
set(CMAKE_CXX_STANDARD 20)
8+
set(CMAKE_CXX_STANDARD 17)
99
set(CMAKE_CXX_STANDARD_REQUIRED NO)
1010
cmake_policy(SET CMP0135 NEW)
1111
cmake_policy(SET CMP0077 NEW)
1212
set(CMAKE_CXX_EXTENSIONS NO)
13-
if (CMAKE_BUILD_TYPE MATCHES Debug)
13+
if (CMAKE_BUILD_TYPE MATCHES DEBUG)
1414
set(CMAKE_VERBOSE_MAKEFILE YES)
1515
endif()
1616
option(RICCATI_BUILD_TESTING "Build the test targets for the library" OFF)
@@ -69,7 +69,7 @@ endif()
6969

7070
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
7171
set(CMAKE_CXX_FLAGS_RELEASE
72-
"-O3 -march=native -mtune=native -DRICCATI_DEBUG=false"
72+
"-O3 -march=native -mtune=native"
7373
CACHE STRING "Flags used by the C++ compiler during Release builds."
7474
FORCE)
7575
endif()

README.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ $$
4444

4545
![bench1](./imgs/bremer_together1.png)
4646

47-
The blue area in the graph of errors is the best possible lower bound for error calculated by Bremer.
48-
Because the results of each algorithm are compared relative to Bremer's values, the algorithms may report
47+
The blue area in the graph of errors is the best possible lower bound for error calculated by Bremer.
48+
Because the results of each algorithm are compared relative to Bremer's values, the algorithms may report
4949
smaller values than the actual possible error, but should be considered bounded by the blue area.
5050

5151
## Documentation
@@ -93,6 +93,19 @@ cd build/tests
9393
make -j4 riccati_test && ctest
9494
```
9595

96+
For the python tests and benchmarks it is recommended to setup a virtual environment
97+
98+
```bash
99+
# From the top level of this directory
100+
python -m venv ./.venv
101+
source ./.venv/bin/activate
102+
pip install -r requirements.txt
103+
# Install pyriccaticpp
104+
pip install .
105+
# Now run benchmarks
106+
python3 ./benchmarks/solve_ivp_bench.py
107+
```
108+
96109
## Example
97110

98111
As an example we will solve Bremer's Eq. 237 where the omega and gamma functions are given by the following.
@@ -103,8 +116,8 @@ l = 10
103116
\gamma(x) = 0
104117
$$
105118

106-
In the code we use the `riccati::vectorize` function to convert the scalar functions to vector functions.
107-
We then use the `riccati::make_solver` function to create the solver object.
119+
In the code we use the `riccati::vectorize` function to convert the scalar functions to vector functions.
120+
We then use the `riccati::make_solver` function to create the solver object.
108121
Finally we use the `riccati::evolve` function to solve the ODE.
109122

110123
```cpp
@@ -130,4 +143,4 @@ FetchContent_MakeAvailable(riccaticpp)
130143
target_link_libraries(target_name riccati)
131144
```
132145

133-
See the example [here]()
146+
See the example [here]()

benchmarks/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ target_link_libraries(brenner237 riccati Eigen3::Eigen)
1010
message(STATUS ${CMAKE_CURRENT_SOURCE_DIR})
1111
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fig1.py
1212
${CMAKE_CURRENT_BINARY_DIR}/fig1.py COPYONLY)
13-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/data/eq237.txt
13+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/data/eq237.csv
1414
${CMAKE_CURRENT_BINARY_DIR}/data/eq237.txt COPYONLY)
1515

1616
ExternalProject_Add(

benchmarks/data/eq237.csv

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
lamb,y1,relative_error
2+
1e1,0.2913132934408612e0,7e-14
3+
1e2,0.5294889561602804e0,5e-13
4+
1e3,-0.6028749132401260e0,3e-12
5+
1e4,-0.4813631690625038e0,5e-11
6+
1e5,0.6558931145821987e0,3e-10
7+
1e6,-0.4829009413372087e0,5e-9
8+
1e7,-0.6634949630196019e0,4e-8

benchmarks/data/eq237.txt

Lines changed: 0 additions & 9 deletions
This file was deleted.

benchmarks/fig1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ def f(t, y):
542542
outdir = os.getcwd() + "/data/"
543543
epss, epshs, ns = [1e-12, 1e-6], [1e-13, 1e-9], [35, 20]
544544

545-
#Let the benchmark run
545+
# Let the benchmark run
546546
for x in range(30):
547547
for algo in Algo:
548548
for m in np.logspace(1, 7, num=7):

0 commit comments

Comments
 (0)