sleipnirgroup-jormungandr 0.2.1__cp312-abi3-macosx_14_0_universal2.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- jormungandr/__init__.py +8 -0
- jormungandr/__init__.pyi +1 -0
- jormungandr/_jormungandr.abi3.so +0 -0
- jormungandr/autodiff/__init__.py +58 -0
- jormungandr/autodiff/__init__.pyi +2528 -0
- jormungandr/optimization/__init__.py +39 -0
- jormungandr/optimization/__init__.pyi +674 -0
- jormungandr/py.typed +0 -0
- sleipnirgroup_jormungandr-0.2.1.dist-info/LICENSE.txt +11 -0
- sleipnirgroup_jormungandr-0.2.1.dist-info/METADATA +365 -0
- sleipnirgroup_jormungandr-0.2.1.dist-info/RECORD +13 -0
- sleipnirgroup_jormungandr-0.2.1.dist-info/WHEEL +4 -0
- sleipnirgroup_jormungandr-0.2.1.dist-info/entry_points.txt +0 -0
jormungandr/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Copyright (c) Sleipnir contributors
|
|
2
|
+
|
|
3
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
4
|
+
|
|
5
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
6
|
+
|
|
7
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
8
|
+
|
|
9
|
+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
10
|
+
|
|
11
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: sleipnirgroup-jormungandr
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: A linearity-exploiting reverse mode autodiff library and nonlinear program solver DSL.
|
|
5
|
+
License: Copyright (c) Sleipnir contributors
|
|
6
|
+
|
|
7
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
12
|
+
|
|
13
|
+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
14
|
+
|
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
16
|
+
|
|
17
|
+
Project-URL: Documentation, https://sleipnirgroup.github.io/Sleipnir/
|
|
18
|
+
Requires-Python: >=3.12
|
|
19
|
+
Requires-Dist: matplotlib
|
|
20
|
+
Requires-Dist: numpy
|
|
21
|
+
Requires-Dist: scipy
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# Sleipnir
|
|
25
|
+
|
|
26
|
+

|
|
27
|
+

|
|
28
|
+
[](https://pypi.org/project/sleipnirgroup-jormungandr/)
|
|
29
|
+
[](https://sleipnirgroup.github.io/Sleipnir/)
|
|
30
|
+
[](https://sleipnirgroup.github.io/Sleipnir/docs/cpp)
|
|
31
|
+
[](https://sleipnirgroup.github.io/Sleipnir/docs/py)
|
|
32
|
+
[](https://discord.gg/ad2EEZZwsS)
|
|
33
|
+
|
|
34
|
+
> Sparsity and Linearity-Exploiting Interior-Point solver - Now Internally Readable
|
|
35
|
+
|
|
36
|
+
Named after Odin's eight-legged horse from Norse mythology, Sleipnir is a linearity-exploiting reverse mode autodiff library, interior-point method, and nonlinear program solver DSL for C++23 and Python. The DSL automatically chooses the best solver based on the problem structure.
|
|
37
|
+
|
|
38
|
+
```cpp
|
|
39
|
+
#include <print>
|
|
40
|
+
|
|
41
|
+
#include <sleipnir/optimization/problem.hpp>
|
|
42
|
+
|
|
43
|
+
int main() {
|
|
44
|
+
// Find the x, y pair with the largest product for which x + 3y = 36
|
|
45
|
+
slp::Problem<double> problem;
|
|
46
|
+
|
|
47
|
+
auto x = problem.decision_variable();
|
|
48
|
+
auto y = problem.decision_variable();
|
|
49
|
+
|
|
50
|
+
problem.maximize(x * y);
|
|
51
|
+
problem.subject_to(x + 3 * y == 36);
|
|
52
|
+
problem.solve();
|
|
53
|
+
|
|
54
|
+
// x = 18.0, y = 6.0
|
|
55
|
+
std::println("x = {}, y = {}", x.value(), y.value());
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
#!/usr/bin/env python3
|
|
61
|
+
|
|
62
|
+
from jormungandr.optimization import Problem
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def main():
|
|
66
|
+
# Find the x, y pair with the largest product for which x + 3y = 36
|
|
67
|
+
problem = Problem()
|
|
68
|
+
|
|
69
|
+
x = problem.decision_variable()
|
|
70
|
+
y = problem.decision_variable()
|
|
71
|
+
|
|
72
|
+
problem.maximize(x * y)
|
|
73
|
+
problem.subject_to(x + 3 * y == 36)
|
|
74
|
+
problem.solve()
|
|
75
|
+
|
|
76
|
+
# x = 18.0, y = 6.0
|
|
77
|
+
print(f"x = {x.value()}, y = {y.value()}")
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
if __name__ == "__main__":
|
|
81
|
+
main()
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Here's the Python output with `problem.solve(diagnostics=True)`.
|
|
85
|
+
```bash
|
|
86
|
+
User-configured exit conditions:
|
|
87
|
+
↳ error below 1e-08
|
|
88
|
+
↳ iteration callback requested stop
|
|
89
|
+
↳ executed 5000 iterations
|
|
90
|
+
|
|
91
|
+
Problem structure:
|
|
92
|
+
↳ quadratic cost function
|
|
93
|
+
↳ linear equality constraints
|
|
94
|
+
↳ no inequality constraints
|
|
95
|
+
|
|
96
|
+
2 decision variables
|
|
97
|
+
1 equality constraint
|
|
98
|
+
↳ 1 linear
|
|
99
|
+
0 inequality constraints
|
|
100
|
+
|
|
101
|
+
Invoking SQP solver
|
|
102
|
+
|
|
103
|
+
┏━━━━┯━━━━┯━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━┯━━━━━┯━━━━━━━━┯━━━━━━━━┯━━┓
|
|
104
|
+
┃iter│type│time (ms)│ error │ cost │ infeas. │complement. │ μ │ reg │primal α│ dual α │↩ ┃
|
|
105
|
+
┡━━━━┷━━━━┷━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━┷━━━━━┷━━━━━━━━┷━━━━━━━━┷━━┩
|
|
106
|
+
│ 0 norm 0.006 1.799760e-03 -1.080000e+02 6.016734e-10 0.000000e+00 0.00e+00 10⁻⁴ 1.00e+00 1.00e+00 0│
|
|
107
|
+
│ 1 norm 0.008 1.199700e-07 -1.080000e+02 9.947598e-14 0.000000e+00 0.00e+00 10⁻⁴ 1.00e+00 1.00e+00 0│
|
|
108
|
+
│ 2 norm 0.002 4.998668e-12 -1.080000e+02 0.000000e+00 0.000000e+00 0.00e+00 10⁻⁴ 1.00e+00 1.00e+00 0│
|
|
109
|
+
└────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
|
110
|
+
┏━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━┯━━━━┓
|
|
111
|
+
┃ solver trace │ percent │total (ms)│each (ms)│runs┃
|
|
112
|
+
┡━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━┷━━━━┩
|
|
113
|
+
│solver 100.00%▕█████████▏ 0.056 0.056 1│
|
|
114
|
+
│ ↳ setup 5.36%▕▍ ▏ 0.003 0.003 1│
|
|
115
|
+
│ ↳ iteration 30.36%▕██▋ ▏ 0.017 0.005 3│
|
|
116
|
+
│ ↳ feasibility ✓ 0.00%▕ ▏ 0.000 0.000 3│
|
|
117
|
+
│ ↳ iter callbacks 0.00%▕ ▏ 0.000 0.000 3│
|
|
118
|
+
│ ↳ KKT matrix build 1.79%▕▏ ▏ 0.001 0.000 3│
|
|
119
|
+
│ ↳ KKT matrix decomp 14.29%▕█▎ ▏ 0.008 0.002 3│
|
|
120
|
+
│ ↳ KKT system solve 1.79%▕▏ ▏ 0.001 0.000 3│
|
|
121
|
+
│ ↳ line search 1.79%▕▏ ▏ 0.001 0.000 3│
|
|
122
|
+
│ ↳ SOC 0.00%▕ ▏ 0.000 0.000 0│
|
|
123
|
+
│ ↳ next iter prep 0.00%▕ ▏ 0.000 0.000 3│
|
|
124
|
+
│ ↳ f(x) 0.00%▕ ▏ 0.000 0.000 7│
|
|
125
|
+
│ ↳ ∇f(x) 1.79%▕▏ ▏ 0.001 0.000 4│
|
|
126
|
+
│ ↳ ∇²ₓₓL 0.00%▕ ▏ 0.000 0.000 4│
|
|
127
|
+
│ ↳ cₑ(x) 1.79%▕▏ ▏ 0.001 0.000 7│
|
|
128
|
+
│ ↳ ∂cₑ/∂x 0.00%▕ ▏ 0.000 0.000 4│
|
|
129
|
+
└────────────────────────────────────────────────────────────────────┘
|
|
130
|
+
┏━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━┯━━━━┓
|
|
131
|
+
┃ autodiff trace │ percent │total (ms)│each (ms)│runs┃
|
|
132
|
+
┡━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━┷━━━━┩
|
|
133
|
+
│setup 100.00%▕█████████▏ 0.013 0.013 1│
|
|
134
|
+
│ ↳ ∇f(x) 7.69%▕▋ ▏ 0.001 0.001 1│
|
|
135
|
+
│ ↳ ∂cₑ/∂x 7.69%▕▋ ▏ 0.001 0.001 1│
|
|
136
|
+
│ ↳ ∇²ₓₓL 38.46%▕███▍ ▏ 0.005 0.005 1│
|
|
137
|
+
└────────────────────────────────────────────────────────────────────┘
|
|
138
|
+
|
|
139
|
+
Exit: success
|
|
140
|
+
x = 17.99999999999167, y = 6.0000000000027764
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
The C++ API also supports arbitrary scalar types, so users can specify higher precision floating-point types at the cost of speed.
|
|
144
|
+
|
|
145
|
+
Sleipnir's internals are intended to be readable by those who aren't domain experts with links to explanatory material for its algorithms.
|
|
146
|
+
|
|
147
|
+
## Benchmarks
|
|
148
|
+
|
|
149
|
+
<table><tr>
|
|
150
|
+
<td><img src="flywheel-scalability-results.png" alt="flywheel-scalability-results"/></td>
|
|
151
|
+
<td><img src="cart-pole-scalability-results.png" alt="cart-pole-scalability-results"/></td>
|
|
152
|
+
</tr><tr>
|
|
153
|
+
<td>
|
|
154
|
+
<a href="flywheel-scalability-results-casadi.csv">
|
|
155
|
+
flywheel-scalability-results-casadi.csv
|
|
156
|
+
</a><br>
|
|
157
|
+
<a href="flywheel-scalability-results-sleipnir.csv">
|
|
158
|
+
flywheel-scalability-results-sleipnir.csv
|
|
159
|
+
</a>
|
|
160
|
+
</td>
|
|
161
|
+
<td>
|
|
162
|
+
<a href="cart-pole-scalability-results-casadi.csv">
|
|
163
|
+
cart-pole-scalability-results-casadi.csv
|
|
164
|
+
</a><br>
|
|
165
|
+
<a href="cart-pole-scalability-results-sleipnir.csv">
|
|
166
|
+
cart-pole-scalability-results-sleipnir.csv
|
|
167
|
+
</a>
|
|
168
|
+
</td>
|
|
169
|
+
</tr></table>
|
|
170
|
+
|
|
171
|
+
Generated by [tools/generate-scalability-results.sh](https://github.com/SleipnirGroup/Sleipnir/tree/main/tools/generate-scalability-results.sh) from [benchmarks/scalability](https://github.com/SleipnirGroup/Sleipnir/tree/main/benchmarks/scalability) source.
|
|
172
|
+
|
|
173
|
+
* CPU: AMD Ryzen 7 7840U
|
|
174
|
+
* RAM: 64 GB, 5600 MHz DDR5
|
|
175
|
+
* Compiler version: g++ (GCC) 15.2.1 20250813
|
|
176
|
+
|
|
177
|
+
The following thirdparty software was used in the benchmarks:
|
|
178
|
+
|
|
179
|
+
* CasADi 3.7.2 (autodiff and NLP solver frontend)
|
|
180
|
+
* Ipopt 3.14.19 (NLP solver backend)
|
|
181
|
+
* MUMPS 5.7.3 (linear solver)
|
|
182
|
+
|
|
183
|
+
Ipopt uses MUMPS by default because it has free licensing. Commercial linear solvers may be much faster.
|
|
184
|
+
|
|
185
|
+
See [benchmark details](https://github.com/SleipnirGroup/Sleipnir/?tab=readme-ov-file#benchmark-details) for more.
|
|
186
|
+
|
|
187
|
+
## Install
|
|
188
|
+
|
|
189
|
+
### Minimum system requirements
|
|
190
|
+
|
|
191
|
+
* Windows
|
|
192
|
+
* OS: Windows 10
|
|
193
|
+
* Runtime: [Microsoft Visual C++ 2022 redistributable](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170) from Visual Studio 2022 17.13
|
|
194
|
+
* Linux
|
|
195
|
+
* OS: Ubuntu 24.04
|
|
196
|
+
* Runtime: GCC 14 libstdc++ (run `sudo apt install g++-14`)
|
|
197
|
+
* macOS
|
|
198
|
+
* OS: macOS 14.5
|
|
199
|
+
* Runtime: Apple Clang 16.0.0 libc++ from Xcode 16.2 (run `xcode-select --install`)
|
|
200
|
+
|
|
201
|
+
### C++ library
|
|
202
|
+
|
|
203
|
+
To install Sleipnir system-wide, see the [build instructions](https://github.com/SleipnirGroup/Sleipnir/?tab=readme-ov-file#c-library-1).
|
|
204
|
+
|
|
205
|
+
To use Sleipnir within a CMake project, add the following to your CMakeLists.txt:
|
|
206
|
+
```cmake
|
|
207
|
+
include(FetchContent)
|
|
208
|
+
|
|
209
|
+
FetchContent_Declare(
|
|
210
|
+
Sleipnir
|
|
211
|
+
GIT_REPOSITORY https://github.com/SleipnirGroup/Sleipnir.git
|
|
212
|
+
GIT_TAG main
|
|
213
|
+
EXCLUDE_FROM_ALL
|
|
214
|
+
SYSTEM
|
|
215
|
+
)
|
|
216
|
+
FetchContent_MakeAvailable(Sleipnir)
|
|
217
|
+
|
|
218
|
+
target_link_libraries(MyApp PUBLIC Sleipnir::Sleipnir)
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Python library
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
pip install sleipnirgroup-jormungandr
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## API docs
|
|
228
|
+
|
|
229
|
+
See the [C++ API docs](https://sleipnirgroup.github.io/Sleipnir/docs/cpp) and [Python API docs](https://sleipnirgroup.github.io/Sleipnir/docs/py).
|
|
230
|
+
|
|
231
|
+
## Examples
|
|
232
|
+
|
|
233
|
+
See the [examples](https://github.com/SleipnirGroup/Sleipnir/tree/main/examples), [C++ optimization unit tests](https://github.com/SleipnirGroup/Sleipnir/tree/main/test/optimization), and [Python optimization unit tests](https://github.com/SleipnirGroup/Sleipnir/tree/main/jormungandr/test/optimization).
|
|
234
|
+
|
|
235
|
+
## Build
|
|
236
|
+
|
|
237
|
+
### Dependencies
|
|
238
|
+
|
|
239
|
+
* C++23 compiler
|
|
240
|
+
* On Windows 10 or greater, install [Visual Studio Community 2022](https://visualstudio.microsoft.com/vs/community/) and select the C++ programming language during installation
|
|
241
|
+
* On Ubuntu 24.04 or greater, install GCC 14 via `sudo apt install g++-14`
|
|
242
|
+
* On macOS 14.5 or greater, install the Xcode 16.2 command-line build tools via `xcode-select --install`
|
|
243
|
+
* [CMake](https://cmake.org/download/) 3.21 or greater
|
|
244
|
+
* On Windows, install from the link above
|
|
245
|
+
* On Linux, install via `sudo apt install cmake`
|
|
246
|
+
* On macOS, install via `brew install cmake`
|
|
247
|
+
* [Python](https://www.python.org/downloads/) 3.12 or greater
|
|
248
|
+
* On Windows, install from the link above
|
|
249
|
+
* On Linux, install via `sudo apt install python`
|
|
250
|
+
* On macOS, install via `brew install python`
|
|
251
|
+
* [Eigen](https://gitlab.com/libeigen/eigen)
|
|
252
|
+
* [small_vector](https://github.com/gharveymn/small_vector)
|
|
253
|
+
* [nanobind](https://github.com/wjakob/nanobind) (build only)
|
|
254
|
+
* [Catch2](https://github.com/catchorg/Catch2) (tests only)
|
|
255
|
+
|
|
256
|
+
Library dependencies which aren't installed locally will be automatically downloaded and built by CMake.
|
|
257
|
+
|
|
258
|
+
The benchmark executables require [CasADi](https://github.com/casadi/casadi) to be installed locally.
|
|
259
|
+
|
|
260
|
+
### C++ library
|
|
261
|
+
|
|
262
|
+
On Windows, open a [Developer PowerShell](https://learn.microsoft.com/en-us/visualstudio/ide/reference/command-prompt-powershell?view=vs-2022). On Linux or macOS, open a Bash shell.
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
# Clone the repository
|
|
266
|
+
git clone git@github.com:SleipnirGroup/Sleipnir
|
|
267
|
+
cd Sleipnir
|
|
268
|
+
|
|
269
|
+
# Configure; automatically downloads library dependencies
|
|
270
|
+
cmake -B build -S .
|
|
271
|
+
|
|
272
|
+
# Build
|
|
273
|
+
cmake --build build
|
|
274
|
+
|
|
275
|
+
# Test
|
|
276
|
+
ctest --test-dir build --output-on-failure
|
|
277
|
+
|
|
278
|
+
# Install
|
|
279
|
+
cmake --install build --prefix pkgdir
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
The following build types can be specified via `-DCMAKE_BUILD_TYPE` during CMake configure:
|
|
283
|
+
|
|
284
|
+
* Debug
|
|
285
|
+
* Optimizations off
|
|
286
|
+
* Debug symbols on
|
|
287
|
+
* Release
|
|
288
|
+
* Optimizations on
|
|
289
|
+
* Debug symbols off
|
|
290
|
+
* RelWithDebInfo (default)
|
|
291
|
+
* Release build type, but with debug info
|
|
292
|
+
* MinSizeRel
|
|
293
|
+
* Minimum size release build
|
|
294
|
+
* Asan
|
|
295
|
+
* Enables address sanitizer
|
|
296
|
+
* Tsan
|
|
297
|
+
* Enables thread sanitizer
|
|
298
|
+
* Ubsan
|
|
299
|
+
* Enables undefined behavior sanitizer
|
|
300
|
+
* Perf
|
|
301
|
+
* RelWithDebInfo build type, but with frame pointer so perf utility can use it
|
|
302
|
+
|
|
303
|
+
### Python library
|
|
304
|
+
|
|
305
|
+
On Windows, open a [Developer PowerShell](https://learn.microsoft.com/en-us/visualstudio/ide/reference/command-prompt-powershell?view=vs-2022). On Linux or macOS, open a Bash shell.
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
# Clone the repository
|
|
309
|
+
git clone git@github.com:SleipnirGroup/Sleipnir
|
|
310
|
+
cd Sleipnir
|
|
311
|
+
|
|
312
|
+
# Setup
|
|
313
|
+
pip install --user build
|
|
314
|
+
|
|
315
|
+
# Build
|
|
316
|
+
python -m build --wheel
|
|
317
|
+
|
|
318
|
+
# Install
|
|
319
|
+
pip install --user dist/sleipnirgroup_jormungandr-*.whl
|
|
320
|
+
|
|
321
|
+
# Test
|
|
322
|
+
pytest
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
## Test diagnostics
|
|
326
|
+
|
|
327
|
+
Passing the `--enable-diagnostics` flag to the test executable enables solver diagnostic prints.
|
|
328
|
+
|
|
329
|
+
Some test problems generate CSV files containing their solutions. These can be plotted with [tools/plot_test_problem_solutions.py](https://github.com/SleipnirGroup/Sleipnir/blob/main/tools/plot_test_problem_solutions.py).
|
|
330
|
+
|
|
331
|
+
## Benchmark details
|
|
332
|
+
|
|
333
|
+
### Running the benchmarks
|
|
334
|
+
|
|
335
|
+
Benchmark projects are in the [benchmarks folder](https://github.com/SleipnirGroup/Sleipnir/tree/main/benchmarks). To compile and run them, run the following in the repository root:
|
|
336
|
+
```bash
|
|
337
|
+
# Install CasADi and [matplotlib, numpy, scipy] pip packages first
|
|
338
|
+
cmake -B build -S . -DBUILD_BENCHMARKS=ON
|
|
339
|
+
cmake --build build
|
|
340
|
+
./tools/generate-scalability-results.sh
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
See the contents of `./tools/generate-scalability-results.sh` for how to run specific benchmarks.
|
|
344
|
+
|
|
345
|
+
### How we improved performance
|
|
346
|
+
|
|
347
|
+
#### Make more decisions at compile time
|
|
348
|
+
|
|
349
|
+
During problem setup, equality and inequality constraints are encoded as different types, so the appropriate setup behavior can be selected at compile time via operator overloads.
|
|
350
|
+
|
|
351
|
+
#### Reuse autodiff computation results that are still valid (aka caching)
|
|
352
|
+
|
|
353
|
+
The autodiff library automatically records the linearity of every node in the computational graph. Linear functions have constant first derivatives, and quadratic functions have constant second derivatives. The constant derivatives are computed in the initialization phase and reused for all solver iterations. Only nonlinear parts of the computational graph are recomputed during each solver iteration.
|
|
354
|
+
|
|
355
|
+
For quadratic problems, we compute the Lagrangian Hessian and constraint Jacobians once with no problem structure hints from the user.
|
|
356
|
+
|
|
357
|
+
#### Use a performant linear algebra library with fast sparse solvers
|
|
358
|
+
|
|
359
|
+
[Eigen](https://gitlab.com/libeigen/eigen) provides these. It also has no required dependencies, which makes cross compilation much easier.
|
|
360
|
+
|
|
361
|
+
#### Use a pool allocator for autodiff expression nodes
|
|
362
|
+
|
|
363
|
+
This promotes fast allocation/deallocation and good memory locality.
|
|
364
|
+
|
|
365
|
+
We could mitigate the solver's high last-level-cache miss rate (~42% on the machine above) further by breaking apart the expression nodes into fields that are commonly iterated together. We used to use a tape, which gave computational graph updates linear access patterns, but tapes are monotonic buffers with no way to reclaim storage.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
jormungandr/__init__.py,sha256=NuCdbJppMAg0g3EvNbhc8sWf_Tfi5ZHNI8EnxUULAuA,177
|
|
2
|
+
jormungandr/__init__.pyi,sha256=OmXO0_AKLaj0UiEnzGn7gac_-vlWsSETz2V2bjKzK7Y,65
|
|
3
|
+
jormungandr/_jormungandr.abi3.so,sha256=RH9v1ajLZAR1cuYgKTuSLkNCfXuldrGsBlDq7K_LqyM,2132904
|
|
4
|
+
jormungandr/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
jormungandr/autodiff/__init__.py,sha256=I2e8ciE5IppQ72nNCepqHz6yIZHUlLXMk54AfvJirwc,1416
|
|
6
|
+
jormungandr/autodiff/__init__.pyi,sha256=IJnDuFAy1sHwQscbro-OmE4mqaluYd3dI5OoTlLRAXk,63647
|
|
7
|
+
jormungandr/optimization/__init__.py,sha256=xYtHMhKtD4vQdi_XwGIUek8w8RIaqIA8gBgLYmv1SkE,1281
|
|
8
|
+
jormungandr/optimization/__init__.pyi,sha256=SFKagm7mcCTddV-m8yj-cg1agbC3cK0848PAHDwaljo,21370
|
|
9
|
+
sleipnirgroup_jormungandr-0.2.1.dist-info/LICENSE.txt,sha256=GO2ESyxbSNqb8hIL18kdV__AfVOlBY3CRXgXLxGamp0,1465
|
|
10
|
+
sleipnirgroup_jormungandr-0.2.1.dist-info/METADATA,sha256=ULGE7UnN6rumxVYtXAUXFU_UQCw6UoW5dx6mf8TMa5E,17716
|
|
11
|
+
sleipnirgroup_jormungandr-0.2.1.dist-info/WHEEL,sha256=4xmHDiinPPAq-jmWi42YSQefpO-poece0_d0MFNHsag,105
|
|
12
|
+
sleipnirgroup_jormungandr-0.2.1.dist-info/entry_points.txt,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
+
sleipnirgroup_jormungandr-0.2.1.dist-info/RECORD,,
|
|
File without changes
|