rtc-tools 2.7.3__py3-none-any.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.
- rtc_tools-2.7.3.dist-info/METADATA +53 -0
- rtc_tools-2.7.3.dist-info/RECORD +50 -0
- rtc_tools-2.7.3.dist-info/WHEEL +5 -0
- rtc_tools-2.7.3.dist-info/entry_points.txt +3 -0
- rtc_tools-2.7.3.dist-info/licenses/COPYING.LESSER +165 -0
- rtc_tools-2.7.3.dist-info/top_level.txt +1 -0
- rtctools/__init__.py +5 -0
- rtctools/_internal/__init__.py +0 -0
- rtctools/_internal/alias_tools.py +188 -0
- rtctools/_internal/caching.py +25 -0
- rtctools/_internal/casadi_helpers.py +99 -0
- rtctools/_internal/debug_check_helpers.py +41 -0
- rtctools/_version.py +21 -0
- rtctools/data/__init__.py +4 -0
- rtctools/data/csv.py +150 -0
- rtctools/data/interpolation/__init__.py +3 -0
- rtctools/data/interpolation/bspline.py +31 -0
- rtctools/data/interpolation/bspline1d.py +169 -0
- rtctools/data/interpolation/bspline2d.py +54 -0
- rtctools/data/netcdf.py +467 -0
- rtctools/data/pi.py +1236 -0
- rtctools/data/rtc.py +228 -0
- rtctools/data/storage.py +343 -0
- rtctools/optimization/__init__.py +0 -0
- rtctools/optimization/collocated_integrated_optimization_problem.py +3208 -0
- rtctools/optimization/control_tree_mixin.py +221 -0
- rtctools/optimization/csv_lookup_table_mixin.py +462 -0
- rtctools/optimization/csv_mixin.py +300 -0
- rtctools/optimization/goal_programming_mixin.py +769 -0
- rtctools/optimization/goal_programming_mixin_base.py +1094 -0
- rtctools/optimization/homotopy_mixin.py +165 -0
- rtctools/optimization/initial_state_estimation_mixin.py +89 -0
- rtctools/optimization/io_mixin.py +320 -0
- rtctools/optimization/linearization_mixin.py +33 -0
- rtctools/optimization/linearized_order_goal_programming_mixin.py +235 -0
- rtctools/optimization/min_abs_goal_programming_mixin.py +385 -0
- rtctools/optimization/modelica_mixin.py +482 -0
- rtctools/optimization/netcdf_mixin.py +177 -0
- rtctools/optimization/optimization_problem.py +1302 -0
- rtctools/optimization/pi_mixin.py +292 -0
- rtctools/optimization/planning_mixin.py +19 -0
- rtctools/optimization/single_pass_goal_programming_mixin.py +676 -0
- rtctools/optimization/timeseries.py +56 -0
- rtctools/rtctoolsapp.py +131 -0
- rtctools/simulation/__init__.py +0 -0
- rtctools/simulation/csv_mixin.py +171 -0
- rtctools/simulation/io_mixin.py +195 -0
- rtctools/simulation/pi_mixin.py +255 -0
- rtctools/simulation/simulation_problem.py +1293 -0
- rtctools/util.py +241 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rtc-tools
|
|
3
|
+
Version: 2.7.3
|
|
4
|
+
Summary: Toolbox for control and optimization of water systems.
|
|
5
|
+
Home-page: https://oss.deltares.nl/web/rtc-tools/home
|
|
6
|
+
Download-URL: http://github.com/deltares/rtc-tools/
|
|
7
|
+
Author: Deltares
|
|
8
|
+
Maintainer: Deltares
|
|
9
|
+
Platform: Windows
|
|
10
|
+
Platform: Linux
|
|
11
|
+
Platform: Mac OS-X
|
|
12
|
+
Platform: Unix
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Intended Audience :: Information Technology
|
|
16
|
+
Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
|
|
17
|
+
Classifier: Programming Language :: Python
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: GIS
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
22
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
23
|
+
Classifier: Operating System :: POSIX
|
|
24
|
+
Classifier: Operating System :: Unix
|
|
25
|
+
Classifier: Operating System :: MacOS
|
|
26
|
+
Requires-Python: >=3.9
|
|
27
|
+
License-File: COPYING.LESSER
|
|
28
|
+
Requires-Dist: casadi!=3.6.6,<3.8,>=3.6.3
|
|
29
|
+
Requires-Dist: numpy>=1.16.0
|
|
30
|
+
Requires-Dist: scipy>=1.0.0
|
|
31
|
+
Requires-Dist: pymoca==0.9.*,>=0.9.1
|
|
32
|
+
Requires-Dist: rtc-tools-channel-flow>=1.2.0
|
|
33
|
+
Requires-Dist: defusedxml>=0.7.0
|
|
34
|
+
Requires-Dist: importlib_metadata>=5.0.0; python_version < "3.10"
|
|
35
|
+
Provides-Extra: netcdf
|
|
36
|
+
Requires-Dist: netCDF4; extra == "netcdf"
|
|
37
|
+
Provides-Extra: all
|
|
38
|
+
Requires-Dist: netCDF4; extra == "all"
|
|
39
|
+
Dynamic: author
|
|
40
|
+
Dynamic: classifier
|
|
41
|
+
Dynamic: description
|
|
42
|
+
Dynamic: download-url
|
|
43
|
+
Dynamic: home-page
|
|
44
|
+
Dynamic: license-file
|
|
45
|
+
Dynamic: maintainer
|
|
46
|
+
Dynamic: platform
|
|
47
|
+
Dynamic: provides-extra
|
|
48
|
+
Dynamic: requires-dist
|
|
49
|
+
Dynamic: requires-python
|
|
50
|
+
Dynamic: summary
|
|
51
|
+
|
|
52
|
+
RTC-Tools is the Deltares toolbox for control and optimization of water systems.
|
|
53
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
rtc_tools-2.7.3.dist-info/licenses/COPYING.LESSER,sha256=46mU2C5kSwOnkqkw9XQAJlhBL2JAf1_uCD8lVcXyMRg,7652
|
|
2
|
+
rtctools/__init__.py,sha256=91hvS2-ryd2Pvw0COpsUzTwJwSnTZ035REiej-1hNI4,107
|
|
3
|
+
rtctools/_version.py,sha256=FPeE0b8LMExvwWratemPrdlvRPvhjDk884SpY1gsgOA,497
|
|
4
|
+
rtctools/rtctoolsapp.py,sha256=o9T64PSScxtusfWNh9ZaiCfwFBSC7fl0o6K0zH-thJE,4337
|
|
5
|
+
rtctools/util.py,sha256=8IGva7xWcAH-9Xcr1LaxUpYoZjF6vbo1eqdNJ9pKgGA,9098
|
|
6
|
+
rtctools/_internal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
rtctools/_internal/alias_tools.py,sha256=XuQSAhhFuVtwn0yrAObZWIKPsSF4j2axXRtEmitIFPs,5310
|
|
8
|
+
rtctools/_internal/caching.py,sha256=p4gqSL7kCI7Hff-KjMEP7mhJCQSiU_lYm2MR7E18gBM,905
|
|
9
|
+
rtctools/_internal/casadi_helpers.py,sha256=j_j-StW37jgacXiiJJbzBySWX9zL9-CYxzch_VoRVoI,3146
|
|
10
|
+
rtctools/_internal/debug_check_helpers.py,sha256=UgQTEPw4PyR7MbYLewSSWQqTwQj7xr5yUBk820O9Kk4,1084
|
|
11
|
+
rtctools/data/__init__.py,sha256=EllgSmCdrlvQZSd1VilvjPaeYJGhY9ErPiQtedmuFoA,157
|
|
12
|
+
rtctools/data/csv.py,sha256=hEpoTH3nhZaAvRN4r-9-nYeAjaFiNDRoiZWg8GxM3yo,5539
|
|
13
|
+
rtctools/data/netcdf.py,sha256=tMs-zcSlOR0HhajUKJVbXGNoi3GeKCM3X4DjuW8FDo8,19130
|
|
14
|
+
rtctools/data/pi.py,sha256=Q7WS0sMkDrTQcCSWmOnuAknt76TWXjooCayt2Qz6j10,47345
|
|
15
|
+
rtctools/data/rtc.py,sha256=tYPOzZSFE02bAXX3lgcGR1saoQNIv6oWVWH8CS0dl5Q,9079
|
|
16
|
+
rtctools/data/storage.py,sha256=67J4BRTl0AMEzlKNZ8Xdpy_4cGtwx8Lo_tL2n0G4S9w,13206
|
|
17
|
+
rtctools/data/interpolation/__init__.py,sha256=GBubCIT5mFoSTV-lOk7cpwvZekNMEe5bvqSQJ9HE34M,73
|
|
18
|
+
rtctools/data/interpolation/bspline.py,sha256=qevB842XWCH3fWlWMBqKMy1mw37ust-0YtSnb9PKCEc,948
|
|
19
|
+
rtctools/data/interpolation/bspline1d.py,sha256=HAh7m5xLBuiFKzMzuYEqZX_GmCPChKjV7ynTS6iRZOc,6166
|
|
20
|
+
rtctools/data/interpolation/bspline2d.py,sha256=ScmX0fPDxbUVtj3pbUE0L7UJocqroD_6fUT-4cvdRMc,1693
|
|
21
|
+
rtctools/optimization/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
|
+
rtctools/optimization/collocated_integrated_optimization_problem.py,sha256=0s44Ft3e673SMid95bew-OVCyal6Px4eRbgXxNqakRs,134190
|
|
23
|
+
rtctools/optimization/control_tree_mixin.py,sha256=6OMvjT5rFvvXU3_O6Uwz8xvBQpRH9d5z4mMOtOQ4-a4,9036
|
|
24
|
+
rtctools/optimization/csv_lookup_table_mixin.py,sha256=TUYAT-u-mzH6HLP0iJHnLBVqV5tWnhYAqDC4Aj17MJg,17399
|
|
25
|
+
rtctools/optimization/csv_mixin.py,sha256=_6iPVK_EJ8PxnukepzkhFtidceucsozRML_DDEycYik,12453
|
|
26
|
+
rtctools/optimization/goal_programming_mixin.py,sha256=vdnKnz1Ov3OFN-J9KQiiAwHbrLjWH6o_PeZz2YfLz6k,33320
|
|
27
|
+
rtctools/optimization/goal_programming_mixin_base.py,sha256=qJQQcJlJdio4GTcrKfuBi6Nho9u16pDuuprzK0LUyhA,43835
|
|
28
|
+
rtctools/optimization/homotopy_mixin.py,sha256=Kh0kMfxB-Fo1FBGW5tPOQk24Xx_Mmw_p0YuSQotdkMU,6905
|
|
29
|
+
rtctools/optimization/initial_state_estimation_mixin.py,sha256=74QYfG-VYYTNVg-kAnCG6QoY3_sUmaID0ideF7bPkkY,3116
|
|
30
|
+
rtctools/optimization/io_mixin.py,sha256=AsZQ7YOUcUbWoczmjTXaSje5MUEsPNbQyZBJ6qzSjzU,11821
|
|
31
|
+
rtctools/optimization/linearization_mixin.py,sha256=mG5S7uwvwDydw-eBPyQKnLyKoy08EBjQh25vu97afhY,1049
|
|
32
|
+
rtctools/optimization/linearized_order_goal_programming_mixin.py,sha256=LQ2qpYt0YGLpEoerif4FJ5wwzq16q--27bsRjcqIU5A,9087
|
|
33
|
+
rtctools/optimization/min_abs_goal_programming_mixin.py,sha256=WMOv9EF8cfDJgTunzXfI_cUmBSQK26u1HJB_9EAarfM,14031
|
|
34
|
+
rtctools/optimization/modelica_mixin.py,sha256=RIRJs6V7evduKydXtNZqov_0PchyCV4XxTJRwu3FC0s,18328
|
|
35
|
+
rtctools/optimization/netcdf_mixin.py,sha256=-zkXh3sMYE50c3kHsrmUVGWMSFm-0cXQpGrCm0yn-Tc,7563
|
|
36
|
+
rtctools/optimization/optimization_problem.py,sha256=45cJplYqluAqets4-MLtqrxce6g1woYQoDuU7GyqH6E,44909
|
|
37
|
+
rtctools/optimization/pi_mixin.py,sha256=G_6RPlXO-IOjqYxNsMZGY4fmnfxVpwN-_T5Ka3rDwK4,11788
|
|
38
|
+
rtctools/optimization/planning_mixin.py,sha256=O_Y74X8xZmaNZR4iYOe7BR06s9hnmcapbuHYHQTBPPQ,724
|
|
39
|
+
rtctools/optimization/single_pass_goal_programming_mixin.py,sha256=5lo7L4sFPWkR7Dm8NxrnN3f3WDXEXzc30ZecdPpxaOI,26422
|
|
40
|
+
rtctools/optimization/timeseries.py,sha256=nCrsGCJThBMh9lvngEpbBDa834_QvklVvkxJqwX4a1M,1734
|
|
41
|
+
rtctools/simulation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
42
|
+
rtctools/simulation/csv_mixin.py,sha256=rGDUFPsqGHmF0_dWdXeWzWzMpkPmwCNweTBVrwSh31g,6704
|
|
43
|
+
rtctools/simulation/io_mixin.py,sha256=WIKOQxr3fS-aNbgjet9iWoUayuD22zLIYmqlWEqxXHo,6215
|
|
44
|
+
rtctools/simulation/pi_mixin.py,sha256=_TU2DrK2MQqVsyrHBD9W4SDEuot9dYmgTDNiXkDAJfk,9833
|
|
45
|
+
rtctools/simulation/simulation_problem.py,sha256=v5Lk2x-yuVb5s7ne5fFgxONxGniLHTyTR0XRzYRl1fw,50005
|
|
46
|
+
rtc_tools-2.7.3.dist-info/METADATA,sha256=xqNyDcIphu2nP_A7ltzab5hGbCkI-HQmSgGf4Qhf_u0,1771
|
|
47
|
+
rtc_tools-2.7.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
48
|
+
rtc_tools-2.7.3.dist-info/entry_points.txt,sha256=DVS8sWf3b9ph9h8srEr6zmQ7ZKGwblwgZgGPZg-jRNQ,150
|
|
49
|
+
rtc_tools-2.7.3.dist-info/top_level.txt,sha256=pnBrb58PFPd1kp1dqa-JHU7R55h3alDNJIJnF3Jf9Dw,9
|
|
50
|
+
rtc_tools-2.7.3.dist-info/RECORD,,
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
rtctools
|
rtctools/__init__.py
ADDED
|
File without changes
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
from collections.abc import MutableSet
|
|
2
|
+
from typing import Generic, Iterator, Mapping, Tuple, TypeVar
|
|
3
|
+
|
|
4
|
+
from pymoca.backends.casadi.alias_relation import AliasRelation # noqa: F401
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class OrderedSet(MutableSet):
|
|
8
|
+
"""
|
|
9
|
+
Adapted from https://code.activestate.com/recipes/576694/
|
|
10
|
+
with some additional methods:
|
|
11
|
+
__getstate__, __setstate__, __getitem__
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
def __init__(self, iterable=None):
|
|
15
|
+
self.end = end = []
|
|
16
|
+
end += [None, end, end] # sentinel node for doubly linked list
|
|
17
|
+
self.map = {} # key --> [key, prev, next]
|
|
18
|
+
if iterable is not None:
|
|
19
|
+
self |= iterable
|
|
20
|
+
|
|
21
|
+
def __len__(self):
|
|
22
|
+
return len(self.map)
|
|
23
|
+
|
|
24
|
+
def __contains__(self, key):
|
|
25
|
+
return key in self.map
|
|
26
|
+
|
|
27
|
+
def __getstate__(self):
|
|
28
|
+
"""Avoids max depth RecursionError when using pickle"""
|
|
29
|
+
return list(self)
|
|
30
|
+
|
|
31
|
+
def __setstate__(self, state):
|
|
32
|
+
"""Tells pickle how to restore instance"""
|
|
33
|
+
self.__init__(state)
|
|
34
|
+
|
|
35
|
+
def __getitem__(self, index):
|
|
36
|
+
if isinstance(index, slice):
|
|
37
|
+
start, stop, stride = index.indices(len(self))
|
|
38
|
+
return [self.__getitem__(i) for i in range(start, stop, stride)]
|
|
39
|
+
else:
|
|
40
|
+
end = self.end
|
|
41
|
+
curr = end[2]
|
|
42
|
+
i = 0
|
|
43
|
+
while curr is not end:
|
|
44
|
+
if i == index:
|
|
45
|
+
return curr[0]
|
|
46
|
+
curr = curr[2]
|
|
47
|
+
i += 1
|
|
48
|
+
raise IndexError("set index {} out of range with length {}".format(index, len(self)))
|
|
49
|
+
|
|
50
|
+
def add(self, key):
|
|
51
|
+
if key not in self.map:
|
|
52
|
+
end = self.end
|
|
53
|
+
curr = end[1]
|
|
54
|
+
curr[2] = end[1] = self.map[key] = [key, curr, end]
|
|
55
|
+
|
|
56
|
+
def discard(self, key):
|
|
57
|
+
if key in self.map:
|
|
58
|
+
key, prev, next = self.map.pop(key)
|
|
59
|
+
prev[2] = next
|
|
60
|
+
next[1] = prev
|
|
61
|
+
|
|
62
|
+
def __iter__(self):
|
|
63
|
+
end = self.end
|
|
64
|
+
curr = end[2]
|
|
65
|
+
while curr is not end:
|
|
66
|
+
yield curr[0]
|
|
67
|
+
curr = curr[2]
|
|
68
|
+
|
|
69
|
+
def __reversed__(self):
|
|
70
|
+
end = self.end
|
|
71
|
+
curr = end[1]
|
|
72
|
+
while curr is not end:
|
|
73
|
+
yield curr[0]
|
|
74
|
+
curr = curr[1]
|
|
75
|
+
|
|
76
|
+
def pop(self, last=True):
|
|
77
|
+
if not self:
|
|
78
|
+
raise KeyError("set is empty")
|
|
79
|
+
key = self.end[1][0] if last else self.end[2][0]
|
|
80
|
+
self.discard(key)
|
|
81
|
+
return key
|
|
82
|
+
|
|
83
|
+
def __repr__(self):
|
|
84
|
+
if not self:
|
|
85
|
+
return "%s()" % (self.__class__.__name__,)
|
|
86
|
+
return "%s(%r)" % (self.__class__.__name__, list(self))
|
|
87
|
+
|
|
88
|
+
def __eq__(self, other):
|
|
89
|
+
if isinstance(other, OrderedSet):
|
|
90
|
+
return len(self) == len(other) and list(self) == list(other)
|
|
91
|
+
return set(self) == set(other)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
# End snippet
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
KT = TypeVar("KT")
|
|
98
|
+
VT = TypeVar("VT")
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
class AliasDict(Generic[KT, VT]):
|
|
102
|
+
def __init__(self, relation, other=None, signed_values=True):
|
|
103
|
+
self.__relation = relation
|
|
104
|
+
self.__d = {}
|
|
105
|
+
self.__signed_values = signed_values
|
|
106
|
+
if other:
|
|
107
|
+
self.update(other)
|
|
108
|
+
|
|
109
|
+
def __canonical_signed(self, key: KT):
|
|
110
|
+
var, sign = self.__relation.canonical_signed(key)
|
|
111
|
+
if self.__signed_values:
|
|
112
|
+
return var, sign
|
|
113
|
+
else:
|
|
114
|
+
return var, 1
|
|
115
|
+
|
|
116
|
+
def __setitem__(self, key: KT, val: VT):
|
|
117
|
+
var, sign = self.__canonical_signed(key)
|
|
118
|
+
if isinstance(val, tuple):
|
|
119
|
+
assert len(val) == 2
|
|
120
|
+
if sign < 0:
|
|
121
|
+
self.__d[var] = (-val[1], -val[0])
|
|
122
|
+
else:
|
|
123
|
+
self.__d[var] = val
|
|
124
|
+
elif isinstance(val, list) and sign < 0:
|
|
125
|
+
self.__d[var] = [-x for x in val]
|
|
126
|
+
else:
|
|
127
|
+
self.__d[var] = -val if sign < 0 else val
|
|
128
|
+
|
|
129
|
+
def __getitem__(self, key: KT):
|
|
130
|
+
var, sign = self.__canonical_signed(key)
|
|
131
|
+
val = self.__d[var]
|
|
132
|
+
if isinstance(val, tuple):
|
|
133
|
+
if sign < 0:
|
|
134
|
+
return (-val[1], -val[0])
|
|
135
|
+
else:
|
|
136
|
+
return val
|
|
137
|
+
elif isinstance(val, list) and sign < 0:
|
|
138
|
+
return [-x for x in val]
|
|
139
|
+
else:
|
|
140
|
+
return -val if sign < 0 else val
|
|
141
|
+
|
|
142
|
+
def __delitem__(self, key: KT):
|
|
143
|
+
var, sign = self.__canonical_signed(key)
|
|
144
|
+
del self.__d[var]
|
|
145
|
+
|
|
146
|
+
def __contains__(self, key: KT):
|
|
147
|
+
var, sign = self.__canonical_signed(key)
|
|
148
|
+
return var in self.__d
|
|
149
|
+
|
|
150
|
+
def __len__(self) -> int:
|
|
151
|
+
return len(self.__d)
|
|
152
|
+
|
|
153
|
+
def __iter__(self) -> Iterator[KT]:
|
|
154
|
+
return iter(self.__d)
|
|
155
|
+
|
|
156
|
+
def update(self, other: Mapping[KT, VT]):
|
|
157
|
+
for key, value in other.items():
|
|
158
|
+
self[key] = value
|
|
159
|
+
|
|
160
|
+
def get(self, key: KT, default: VT = None):
|
|
161
|
+
if key in self:
|
|
162
|
+
return self[key]
|
|
163
|
+
else:
|
|
164
|
+
return default
|
|
165
|
+
|
|
166
|
+
def setdefault(self, key: KT, default: VT):
|
|
167
|
+
if key in self:
|
|
168
|
+
return self[key]
|
|
169
|
+
else:
|
|
170
|
+
self[key] = default
|
|
171
|
+
return default
|
|
172
|
+
|
|
173
|
+
def keys(self) -> Iterator[KT]:
|
|
174
|
+
return self.__d.keys()
|
|
175
|
+
|
|
176
|
+
def values(self) -> Iterator[VT]:
|
|
177
|
+
return self.__d.values()
|
|
178
|
+
|
|
179
|
+
def items(self) -> Iterator[Tuple[KT, VT]]:
|
|
180
|
+
return self.__d.items()
|
|
181
|
+
|
|
182
|
+
def copy(self):
|
|
183
|
+
copy = AliasDict(self.__relation, None, self.__signed_values)
|
|
184
|
+
copy.__d = self.__d.copy()
|
|
185
|
+
return copy
|
|
186
|
+
|
|
187
|
+
def __repr__(self):
|
|
188
|
+
return self.__d.__repr__()
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
def cached(f):
|
|
2
|
+
def wrapper(self, ensemble_member=None):
|
|
3
|
+
def call():
|
|
4
|
+
if ensemble_member is not None:
|
|
5
|
+
return f(self, ensemble_member)
|
|
6
|
+
else:
|
|
7
|
+
return f(self)
|
|
8
|
+
|
|
9
|
+
# Add a check so that caching is applied to the 'toplevel'
|
|
10
|
+
# method implementation in the class hierarchy only.
|
|
11
|
+
call_in_progress = "__" + f.__name__ + "_in_progress"
|
|
12
|
+
if hasattr(self, call_in_progress):
|
|
13
|
+
return call()
|
|
14
|
+
cache_name = "__" + f.__name__
|
|
15
|
+
if ensemble_member is not None:
|
|
16
|
+
cache_name = "{}[{}]".format(cache_name, ensemble_member)
|
|
17
|
+
if hasattr(self, cache_name):
|
|
18
|
+
return getattr(self, cache_name)
|
|
19
|
+
setattr(self, call_in_progress, True)
|
|
20
|
+
value = call()
|
|
21
|
+
setattr(self, cache_name, value)
|
|
22
|
+
delattr(self, call_in_progress)
|
|
23
|
+
return value
|
|
24
|
+
|
|
25
|
+
return wrapper
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
|
|
5
|
+
import casadi as ca
|
|
6
|
+
|
|
7
|
+
logger = logging.getLogger("rtctools")
|
|
8
|
+
|
|
9
|
+
# Limit the number of times we try to substitute in external functions, e.g. in
|
|
10
|
+
# case of infinite recursion. Generally unlikely that we will hit this limit for
|
|
11
|
+
# any reasonable use case.
|
|
12
|
+
MAX_SUBSTITUTE_DEPTH = 10
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def is_affine(expr, symbols):
|
|
16
|
+
try:
|
|
17
|
+
Af = ca.Function("f", [symbols], [ca.jacobian(expr, symbols)]).expand()
|
|
18
|
+
except RuntimeError as error:
|
|
19
|
+
if "'eval_sx' not defined for" in str(error):
|
|
20
|
+
Af = ca.Function("f", [symbols], [ca.jacobian(expr, symbols)])
|
|
21
|
+
else:
|
|
22
|
+
raise
|
|
23
|
+
return Af.sparsity_jac(0, 0).nnz() == 0
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def nullvertcat(*L):
|
|
27
|
+
"""
|
|
28
|
+
Like vertcat, but creates an MX with consistent dimensions even if L is empty.
|
|
29
|
+
"""
|
|
30
|
+
if len(L) == 0:
|
|
31
|
+
return ca.DM(0, 1)
|
|
32
|
+
else:
|
|
33
|
+
return ca.vertcat(*L)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def reduce_matvec(e, v):
|
|
37
|
+
"""
|
|
38
|
+
Reduces the MX graph e of linear operations on p into a matrix-vector product.
|
|
39
|
+
|
|
40
|
+
This reduces the number of nodes required to represent the linear operations.
|
|
41
|
+
"""
|
|
42
|
+
Af = ca.Function("Af", [ca.MX()], [ca.jacobian(e, v)])
|
|
43
|
+
A = Af(ca.DM())
|
|
44
|
+
return ca.reshape(ca.mtimes(A, v), e.shape)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def substitute_in_external(
|
|
48
|
+
expr: list[ca.MX],
|
|
49
|
+
symbols: list[ca.MX],
|
|
50
|
+
values: list[ca.MX | ca.DM | float],
|
|
51
|
+
/,
|
|
52
|
+
resolve_numerically=False,
|
|
53
|
+
):
|
|
54
|
+
# We expect expr to be a list of (at most) length 1
|
|
55
|
+
assert len(expr) <= 1
|
|
56
|
+
|
|
57
|
+
if not expr or len(symbols) == 0 or all(isinstance(x, ca.DM) for x in expr):
|
|
58
|
+
return expr
|
|
59
|
+
elif not resolve_numerically:
|
|
60
|
+
f = ca.Function("f", symbols, expr)
|
|
61
|
+
return f.call(values, True, False)
|
|
62
|
+
else:
|
|
63
|
+
# CasADi < 3.7 workaround: f.call() with MX values returns wrapped
|
|
64
|
+
# results like f(...){0}. Resolve symbolics with ca.substitute(), and
|
|
65
|
+
# convert resulting MX constants to floats first. Remove when dropping
|
|
66
|
+
# support for CasADi 3.6.x.
|
|
67
|
+
resolved_values = list(values)
|
|
68
|
+
for _ in range(MAX_SUBSTITUTE_DEPTH):
|
|
69
|
+
for i, v in enumerate(resolved_values):
|
|
70
|
+
if isinstance(v, ca.MX) and not v.is_constant():
|
|
71
|
+
resolved_values[i] = ca.substitute([v], symbols, resolved_values)[0]
|
|
72
|
+
elif isinstance(v, ca.MX):
|
|
73
|
+
resolved_values[i] = float(v)
|
|
74
|
+
|
|
75
|
+
# Substitute in expression using f.call() for external function support
|
|
76
|
+
f = ca.Function("f", symbols, expr).expand()
|
|
77
|
+
expr = f.call(resolved_values, True, False)
|
|
78
|
+
if expr[0].is_constant():
|
|
79
|
+
break
|
|
80
|
+
|
|
81
|
+
return expr
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def interpolate(ts, xs, t, equidistant, mode=0):
|
|
85
|
+
if mode == 0:
|
|
86
|
+
mode_str = "linear"
|
|
87
|
+
elif mode == 1:
|
|
88
|
+
mode_str = "floor"
|
|
89
|
+
else:
|
|
90
|
+
mode_str = "ceil"
|
|
91
|
+
|
|
92
|
+
# CasADi fails if there is just a single point. Just "extrapolate" based on
|
|
93
|
+
# that point, just as CasADi would do for entries in 't' outside the range
|
|
94
|
+
# of 'ts'.
|
|
95
|
+
if len(ts) == 1:
|
|
96
|
+
assert xs.size1() == 1
|
|
97
|
+
return ca.vertcat(*[xs] * len(t))
|
|
98
|
+
|
|
99
|
+
return ca.interp1d(ts, xs, t, mode_str, equidistant)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from enum import IntEnum
|
|
3
|
+
|
|
4
|
+
logger = logging.getLogger("rtctools")
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class DebugLevel(IntEnum):
|
|
8
|
+
NONE = 0
|
|
9
|
+
LOW = 10
|
|
10
|
+
MEDIUM = 20
|
|
11
|
+
HIGH = 30
|
|
12
|
+
VERYHIGH = 40
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def debug_check(level):
|
|
16
|
+
def noop(*args, **kwargs):
|
|
17
|
+
pass
|
|
18
|
+
|
|
19
|
+
def wrap(func):
|
|
20
|
+
def func_wrapper(*args, **kwargs):
|
|
21
|
+
this = args[0]
|
|
22
|
+
filter_ = this._debug_check_level
|
|
23
|
+
do_check = False
|
|
24
|
+
if callable(filter_):
|
|
25
|
+
if filter_(level, func.__qualname__):
|
|
26
|
+
do_check = True
|
|
27
|
+
elif filter_ >= level:
|
|
28
|
+
do_check = True
|
|
29
|
+
|
|
30
|
+
if do_check:
|
|
31
|
+
logger.info("Starting debug check '{}'".format(func.__qualname__))
|
|
32
|
+
extra_options = this._debug_check_options.get(func.__qualname__, {})
|
|
33
|
+
ret = func(*args, **kwargs, **extra_options)
|
|
34
|
+
logger.info("Finished debug check '{}'".format(func.__qualname__))
|
|
35
|
+
return ret
|
|
36
|
+
else:
|
|
37
|
+
return noop(*args, **kwargs)
|
|
38
|
+
|
|
39
|
+
return func_wrapper
|
|
40
|
+
|
|
41
|
+
return wrap
|
rtctools/_version.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
# This file was generated by 'versioneer.py' (0.29) from
|
|
3
|
+
# revision-control system data, or from the parent directory name of an
|
|
4
|
+
# unpacked source archive. Distribution tarballs contain a pre-generated copy
|
|
5
|
+
# of this file.
|
|
6
|
+
|
|
7
|
+
import json
|
|
8
|
+
|
|
9
|
+
version_json = '''
|
|
10
|
+
{
|
|
11
|
+
"date": "2026-01-20T14:58:22+0100",
|
|
12
|
+
"dirty": false,
|
|
13
|
+
"error": null,
|
|
14
|
+
"full-revisionid": "20585c7d4d1b615468ea7f7dab44a240aeb1f05c",
|
|
15
|
+
"version": "2.7.3"
|
|
16
|
+
}
|
|
17
|
+
''' # END VERSION_JSON
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def get_versions():
|
|
21
|
+
return json.loads(version_json)
|