rtc-tools 2.7.0a2__py3-none-any.whl → 2.7.0.dev1__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.
Potentially problematic release.
This version of rtc-tools might be problematic. Click here for more details.
- {rtc_tools-2.7.0a2.dist-info → rtc_tools-2.7.0.dev1.dist-info}/METADATA +24 -16
- {rtc_tools-2.7.0a2.dist-info → rtc_tools-2.7.0.dev1.dist-info}/RECORD +14 -14
- {rtc_tools-2.7.0a2.dist-info → rtc_tools-2.7.0.dev1.dist-info}/WHEEL +1 -1
- {rtc_tools-2.7.0a2.dist-info → rtc_tools-2.7.0.dev1.dist-info}/entry_points.txt +0 -1
- rtctools/_version.py +4 -4
- rtctools/data/csv.py +18 -7
- rtctools/data/interpolation/bspline1d.py +5 -1
- rtctools/data/pi.py +56 -25
- rtctools/optimization/goal_programming_mixin.py +8 -0
- rtctools/optimization/goal_programming_mixin_base.py +1 -0
- rtctools/optimization/modelica_mixin.py +2 -2
- rtctools/simulation/simulation_problem.py +19 -0
- {rtc_tools-2.7.0a2.dist-info → rtc_tools-2.7.0.dev1.dist-info}/COPYING.LESSER +0 -0
- {rtc_tools-2.7.0a2.dist-info → rtc_tools-2.7.0.dev1.dist-info}/top_level.txt +0 -0
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: rtc-tools
|
|
3
|
-
Version: 2.7.
|
|
3
|
+
Version: 2.7.0.dev1
|
|
4
4
|
Summary: Toolbox for control and optimization of water systems.
|
|
5
5
|
Home-page: https://oss.deltares.nl/web/rtc-tools/home
|
|
6
|
+
Download-URL: http://gitlab.com/deltares/rtc-tools/
|
|
6
7
|
Author: Deltares
|
|
7
8
|
Maintainer: Deltares
|
|
8
|
-
License: UNKNOWN
|
|
9
|
-
Download-URL: http://gitlab.com/deltares/rtc-tools/
|
|
10
9
|
Platform: Windows
|
|
11
10
|
Platform: Linux
|
|
12
11
|
Platform: Mac OS-X
|
|
@@ -24,20 +23,29 @@ Classifier: Operating System :: Microsoft :: Windows
|
|
|
24
23
|
Classifier: Operating System :: POSIX
|
|
25
24
|
Classifier: Operating System :: Unix
|
|
26
25
|
Classifier: Operating System :: MacOS
|
|
27
|
-
Requires-Python: >=3.
|
|
26
|
+
Requires-Python: >=3.9
|
|
28
27
|
License-File: COPYING.LESSER
|
|
29
|
-
Requires-Dist: casadi
|
|
30
|
-
Requires-Dist: numpy
|
|
31
|
-
Requires-Dist: scipy
|
|
32
|
-
Requires-Dist: pymoca
|
|
33
|
-
Requires-Dist: rtc-tools-channel-flow
|
|
34
|
-
Requires-Dist: defusedxml
|
|
35
|
-
Provides-Extra: all
|
|
36
|
-
Requires-Dist: netCDF4 ; extra == 'all'
|
|
28
|
+
Requires-Dist: casadi!=3.6.6,==3.6.*,>=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
|
|
37
34
|
Provides-Extra: netcdf
|
|
38
|
-
Requires-Dist: netCDF4
|
|
35
|
+
Requires-Dist: netCDF4; extra == "netcdf"
|
|
36
|
+
Provides-Extra: all
|
|
37
|
+
Requires-Dist: netCDF4; extra == "all"
|
|
38
|
+
Dynamic: author
|
|
39
|
+
Dynamic: classifier
|
|
40
|
+
Dynamic: description
|
|
41
|
+
Dynamic: download-url
|
|
42
|
+
Dynamic: home-page
|
|
43
|
+
Dynamic: maintainer
|
|
44
|
+
Dynamic: platform
|
|
45
|
+
Dynamic: provides-extra
|
|
46
|
+
Dynamic: requires-dist
|
|
47
|
+
Dynamic: requires-python
|
|
48
|
+
Dynamic: summary
|
|
39
49
|
|
|
40
50
|
RTC-Tools is the Deltares toolbox for control and optimization of water systems.
|
|
41
51
|
|
|
42
|
-
|
|
43
|
-
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
rtctools/__init__.py,sha256=91hvS2-ryd2Pvw0COpsUzTwJwSnTZ035REiej-1hNI4,107
|
|
2
|
-
rtctools/_version.py,sha256=
|
|
2
|
+
rtctools/_version.py,sha256=ZJWaMwzY28qcZR8VLceCjHCoMmz_54mkIUutjeH3dyQ,502
|
|
3
3
|
rtctools/rtctoolsapp.py,sha256=UnkuiJhv0crEEVs8H6PYvMuc2y_q6V_xLuyKEgXj9GM,4200
|
|
4
4
|
rtctools/util.py,sha256=PaeKfDUA174ODZbY5fZjCTf-F-TdhW7yEuP189Ro190,9075
|
|
5
5
|
rtctools/_internal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -8,29 +8,29 @@ rtctools/_internal/caching.py,sha256=p4gqSL7kCI7Hff-KjMEP7mhJCQSiU_lYm2MR7E18gBM
|
|
|
8
8
|
rtctools/_internal/casadi_helpers.py,sha256=oAf5zyFkZbaMhvhgMnQkOi2A6dBOzj-VAUkYwBf-Jxk,1410
|
|
9
9
|
rtctools/_internal/debug_check_helpers.py,sha256=UgQTEPw4PyR7MbYLewSSWQqTwQj7xr5yUBk820O9Kk4,1084
|
|
10
10
|
rtctools/data/__init__.py,sha256=EllgSmCdrlvQZSd1VilvjPaeYJGhY9ErPiQtedmuFoA,157
|
|
11
|
-
rtctools/data/csv.py,sha256=
|
|
11
|
+
rtctools/data/csv.py,sha256=hEpoTH3nhZaAvRN4r-9-nYeAjaFiNDRoiZWg8GxM3yo,5539
|
|
12
12
|
rtctools/data/netcdf.py,sha256=xpk4Ggl7gItNG6lO7p3OJPR-elK8_CiCtxUI7cX0gwk,19109
|
|
13
|
-
rtctools/data/pi.py,sha256=
|
|
13
|
+
rtctools/data/pi.py,sha256=5w50zWgI79Vu5EMMz-MKoManXYqsjxfFgcZN6Z3eeiQ,46638
|
|
14
14
|
rtctools/data/rtc.py,sha256=1yGJZGq2Z36MYLiLuZaHnxupL4mgw-Wuu54PAG05kcM,9077
|
|
15
15
|
rtctools/data/storage.py,sha256=67J4BRTl0AMEzlKNZ8Xdpy_4cGtwx8Lo_tL2n0G4S9w,13206
|
|
16
16
|
rtctools/data/interpolation/__init__.py,sha256=GBubCIT5mFoSTV-lOk7cpwvZekNMEe5bvqSQJ9HE34M,73
|
|
17
17
|
rtctools/data/interpolation/bspline.py,sha256=qevB842XWCH3fWlWMBqKMy1mw37ust-0YtSnb9PKCEc,948
|
|
18
|
-
rtctools/data/interpolation/bspline1d.py,sha256=
|
|
18
|
+
rtctools/data/interpolation/bspline1d.py,sha256=HAh7m5xLBuiFKzMzuYEqZX_GmCPChKjV7ynTS6iRZOc,6166
|
|
19
19
|
rtctools/data/interpolation/bspline2d.py,sha256=ScmX0fPDxbUVtj3pbUE0L7UJocqroD_6fUT-4cvdRMc,1693
|
|
20
20
|
rtctools/optimization/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
21
21
|
rtctools/optimization/collocated_integrated_optimization_problem.py,sha256=Bv1a1O4QTAdIpe9SOA9_oEDDph-oj-9q5yfN4SFMdW8,131343
|
|
22
22
|
rtctools/optimization/control_tree_mixin.py,sha256=CC6TWp3kFQgMokx6213pRLx9iY17Fd0VcwG4Wpwa0Uo,8974
|
|
23
23
|
rtctools/optimization/csv_lookup_table_mixin.py,sha256=h4WKuPR1BJbYuJfQ9lx4rXalB6yYK-zajINabRL7BrA,17298
|
|
24
24
|
rtctools/optimization/csv_mixin.py,sha256=sRp5paHWfCw2bz-23Nw-HdFLS3CZTpVwaBdFo98DbvE,12252
|
|
25
|
-
rtctools/optimization/goal_programming_mixin.py,sha256=
|
|
26
|
-
rtctools/optimization/goal_programming_mixin_base.py,sha256=
|
|
25
|
+
rtctools/optimization/goal_programming_mixin.py,sha256=r2pPzcqi-VlstPx4CdtUT0JeemduiYBV5zeH4kA9QGs,33301
|
|
26
|
+
rtctools/optimization/goal_programming_mixin_base.py,sha256=IvA3cfJmUW9SaDGATD7r4Rrjku9T4oI2H68imPTlq2A,43816
|
|
27
27
|
rtctools/optimization/homotopy_mixin.py,sha256=Kh0kMfxB-Fo1FBGW5tPOQk24Xx_Mmw_p0YuSQotdkMU,6905
|
|
28
28
|
rtctools/optimization/initial_state_estimation_mixin.py,sha256=74QYfG-VYYTNVg-kAnCG6QoY3_sUmaID0ideF7bPkkY,3116
|
|
29
29
|
rtctools/optimization/io_mixin.py,sha256=AsZQ7YOUcUbWoczmjTXaSje5MUEsPNbQyZBJ6qzSjzU,11821
|
|
30
30
|
rtctools/optimization/linearization_mixin.py,sha256=mG5S7uwvwDydw-eBPyQKnLyKoy08EBjQh25vu97afhY,1049
|
|
31
31
|
rtctools/optimization/linearized_order_goal_programming_mixin.py,sha256=LQ2qpYt0YGLpEoerif4FJ5wwzq16q--27bsRjcqIU5A,9087
|
|
32
32
|
rtctools/optimization/min_abs_goal_programming_mixin.py,sha256=WMOv9EF8cfDJgTunzXfI_cUmBSQK26u1HJB_9EAarfM,14031
|
|
33
|
-
rtctools/optimization/modelica_mixin.py,sha256=
|
|
33
|
+
rtctools/optimization/modelica_mixin.py,sha256=9MnZ2tz9WWMeUg7UuS7TNOuqvfZhuTDvZsDfS6HcBIo,17796
|
|
34
34
|
rtctools/optimization/netcdf_mixin.py,sha256=-zkXh3sMYE50c3kHsrmUVGWMSFm-0cXQpGrCm0yn-Tc,7563
|
|
35
35
|
rtctools/optimization/optimization_problem.py,sha256=qzpc81NaZMeoXKuayFmBF15iXYuNAk5yxmaER_Gcz_A,44131
|
|
36
36
|
rtctools/optimization/pi_mixin.py,sha256=n_ZyifuNPxcRoJXKR6Ks7DgK_b7-EToYJ23_khOwpzo,11786
|
|
@@ -41,10 +41,10 @@ rtctools/simulation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSu
|
|
|
41
41
|
rtctools/simulation/csv_mixin.py,sha256=rGDUFPsqGHmF0_dWdXeWzWzMpkPmwCNweTBVrwSh31g,6704
|
|
42
42
|
rtctools/simulation/io_mixin.py,sha256=SJasNGI--OQ9Y-Z61oeeaGCxSrNddYz4AOVfJYbmf74,6209
|
|
43
43
|
rtctools/simulation/pi_mixin.py,sha256=vcizArZsOn7tGlSFCsUmkjmRFA1A1kMNqUllLlkVc9Y,9831
|
|
44
|
-
rtctools/simulation/simulation_problem.py,sha256=
|
|
45
|
-
rtc_tools-2.7.
|
|
46
|
-
rtc_tools-2.7.
|
|
47
|
-
rtc_tools-2.7.
|
|
48
|
-
rtc_tools-2.7.
|
|
49
|
-
rtc_tools-2.7.
|
|
50
|
-
rtc_tools-2.7.
|
|
44
|
+
rtctools/simulation/simulation_problem.py,sha256=8k3MjznzvFIut04NAiu7UAhfndAvNTkQFsO9vbmNd-0,49567
|
|
45
|
+
rtc_tools-2.7.0.dev1.dist-info/COPYING.LESSER,sha256=46mU2C5kSwOnkqkw9XQAJlhBL2JAf1_uCD8lVcXyMRg,7652
|
|
46
|
+
rtc_tools-2.7.0.dev1.dist-info/METADATA,sha256=FDvd6uh5Dduh-AaeJvVDay1GYtocMqUDwKPyW6JflXM,1691
|
|
47
|
+
rtc_tools-2.7.0.dev1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
48
|
+
rtc_tools-2.7.0.dev1.dist-info/entry_points.txt,sha256=DVS8sWf3b9ph9h8srEr6zmQ7ZKGwblwgZgGPZg-jRNQ,150
|
|
49
|
+
rtc_tools-2.7.0.dev1.dist-info/top_level.txt,sha256=pnBrb58PFPd1kp1dqa-JHU7R55h3alDNJIJnF3Jf9Dw,9
|
|
50
|
+
rtc_tools-2.7.0.dev1.dist-info/RECORD,,
|
rtctools/_version.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
# This file was generated by 'versioneer.py' (0.
|
|
2
|
+
# This file was generated by 'versioneer.py' (0.29) from
|
|
3
3
|
# revision-control system data, or from the parent directory name of an
|
|
4
4
|
# unpacked source archive. Distribution tarballs contain a pre-generated copy
|
|
5
5
|
# of this file.
|
|
@@ -8,11 +8,11 @@ import json
|
|
|
8
8
|
|
|
9
9
|
version_json = '''
|
|
10
10
|
{
|
|
11
|
-
"date": "
|
|
11
|
+
"date": "2025-01-29T10:45:25+0100",
|
|
12
12
|
"dirty": false,
|
|
13
13
|
"error": null,
|
|
14
|
-
"full-revisionid": "
|
|
15
|
-
"version": "2.7.
|
|
14
|
+
"full-revisionid": "41dd2517c9c4cd952cd3da53b551b988bc5b64ba",
|
|
15
|
+
"version": "2.7.0.dev1"
|
|
16
16
|
}
|
|
17
17
|
''' # END VERSION_JSON
|
|
18
18
|
|
rtctools/data/csv.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
import sys
|
|
3
3
|
from datetime import datetime
|
|
4
|
+
from typing import Union
|
|
4
5
|
|
|
5
6
|
import numpy as np
|
|
6
7
|
|
|
@@ -41,6 +42,21 @@ def _boolean_to_nan(data, fname):
|
|
|
41
42
|
return data
|
|
42
43
|
|
|
43
44
|
|
|
45
|
+
def _string_to_datetime(string: Union[str, bytes]) -> datetime:
|
|
46
|
+
"""Convert a string to a datetime object."""
|
|
47
|
+
if isinstance(string, bytes):
|
|
48
|
+
string = string.decode("utf-8")
|
|
49
|
+
return datetime.strptime(string, "%Y-%m-%d %H:%M:%S")
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _string_to_float(string: Union[str, bytes]) -> float:
|
|
53
|
+
"""Convert a string to a float."""
|
|
54
|
+
if isinstance(string, bytes):
|
|
55
|
+
string = string.decode("utf-8")
|
|
56
|
+
string = string.replace(",", ".")
|
|
57
|
+
return float(string)
|
|
58
|
+
|
|
59
|
+
|
|
44
60
|
def load(fname, delimiter=",", with_time=False):
|
|
45
61
|
"""
|
|
46
62
|
Check delimiter of csv and read contents to an array. Assumes no date-time conversion needed.
|
|
@@ -53,7 +69,7 @@ def load(fname, delimiter=",", with_time=False):
|
|
|
53
69
|
"""
|
|
54
70
|
c = {}
|
|
55
71
|
if with_time:
|
|
56
|
-
c.update({0:
|
|
72
|
+
c.update({0: _string_to_datetime})
|
|
57
73
|
|
|
58
74
|
# Check delimiter of csv file. If semicolon, check if decimal separator is
|
|
59
75
|
# a comma.
|
|
@@ -73,12 +89,7 @@ def load(fname, delimiter=",", with_time=False):
|
|
|
73
89
|
# If commas are used as decimal separator, we need additional
|
|
74
90
|
# converters.
|
|
75
91
|
if n_comma_decimal:
|
|
76
|
-
c.update(
|
|
77
|
-
{
|
|
78
|
-
i + len(c): lambda str: float(str.decode("utf-8").replace(",", "."))
|
|
79
|
-
for i in range(1 + n_semicolon - len(c))
|
|
80
|
-
}
|
|
81
|
-
)
|
|
92
|
+
c.update({i + len(c): _string_to_float for i in range(1 + n_semicolon - len(c))})
|
|
82
93
|
|
|
83
94
|
# Read the csv file and convert to array
|
|
84
95
|
try:
|
|
@@ -55,6 +55,7 @@ class BSpline1D(BSpline):
|
|
|
55
55
|
epsilon=1e-7,
|
|
56
56
|
delta=1e-4,
|
|
57
57
|
interior_pts=None,
|
|
58
|
+
ipopt_options=None,
|
|
58
59
|
):
|
|
59
60
|
"""
|
|
60
61
|
fit() returns a tck tuple like scipy.interpolate.splrep, but adjusts
|
|
@@ -153,7 +154,10 @@ class BSpline1D(BSpline):
|
|
|
153
154
|
nlp = {"x": c, "f": f, "g": g}
|
|
154
155
|
my_solver = "ipopt"
|
|
155
156
|
solver = nlpsol(
|
|
156
|
-
"solver",
|
|
157
|
+
"solver",
|
|
158
|
+
my_solver,
|
|
159
|
+
nlp,
|
|
160
|
+
{"print_time": 0, "expand": True, "ipopt": ipopt_options},
|
|
157
161
|
)
|
|
158
162
|
sol = solver(lbg=lbg, ubg=ubg)
|
|
159
163
|
stats = solver.stats()
|
rtctools/data/pi.py
CHANGED
|
@@ -369,8 +369,6 @@ class Timeseries:
|
|
|
369
369
|
self.__folder = folder
|
|
370
370
|
self.__basename = basename
|
|
371
371
|
|
|
372
|
-
self.__path_xml = os.path.join(self.__folder, basename + ".xml")
|
|
373
|
-
|
|
374
372
|
self.__internal_dtype = np.float64
|
|
375
373
|
self.__pi_dtype = np.float32
|
|
376
374
|
|
|
@@ -378,7 +376,7 @@ class Timeseries:
|
|
|
378
376
|
if self.make_new_file:
|
|
379
377
|
self.__reset_xml_tree()
|
|
380
378
|
else:
|
|
381
|
-
self.__tree = DefusedElementTree.parse(self.
|
|
379
|
+
self.__tree = DefusedElementTree.parse(self.path)
|
|
382
380
|
self.__xml_root = self.__tree.getroot()
|
|
383
381
|
|
|
384
382
|
self.__values = [{}]
|
|
@@ -801,13 +799,20 @@ class Timeseries:
|
|
|
801
799
|
# Add series to xml
|
|
802
800
|
self.__xml_root.append(series)
|
|
803
801
|
|
|
804
|
-
def write(self):
|
|
802
|
+
def write(self, output_folder=None, output_filename=None) -> None:
|
|
805
803
|
"""
|
|
806
804
|
Writes the time series data to disk.
|
|
805
|
+
|
|
806
|
+
:param output_folder: The folder in which the output file is located.
|
|
807
|
+
If None, the original folder is used.
|
|
808
|
+
:param output_filename: The name of the output file without extension.
|
|
809
|
+
If None, the original filename is used.
|
|
807
810
|
"""
|
|
811
|
+
xml_path = self.output_path(output_folder, output_filename)
|
|
812
|
+
binary_path = self.output_binary_path(output_folder, output_filename)
|
|
808
813
|
|
|
809
814
|
if self.__binary:
|
|
810
|
-
f = io.open(
|
|
815
|
+
f = io.open(binary_path, "wb")
|
|
811
816
|
|
|
812
817
|
if self.make_new_file:
|
|
813
818
|
# Force reinitialization in case write() is called more than once
|
|
@@ -876,29 +881,26 @@ class Timeseries:
|
|
|
876
881
|
events = series.findall("pi:event", ns)
|
|
877
882
|
|
|
878
883
|
t = self.__start_datetime
|
|
879
|
-
for i in
|
|
884
|
+
for i, value in enumerate(values):
|
|
880
885
|
if self.dt is None:
|
|
881
886
|
t = self.times[i]
|
|
882
|
-
# Set the date/time, so that any date/time steps that
|
|
883
|
-
# are wrong in the placeholder file are corrected.
|
|
884
|
-
events[i].set("date", t.strftime("%Y-%m-%d"))
|
|
885
|
-
events[i].set("time", t.strftime("%H:%M:%S"))
|
|
886
887
|
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
888
|
+
if i < len(events):
|
|
889
|
+
event = events[i]
|
|
890
|
+
else:
|
|
891
|
+
event = ET.Element("pi:event")
|
|
892
|
+
series.append(event)
|
|
893
|
+
|
|
894
|
+
# Always set the date/time, so that any date/time steps
|
|
895
|
+
# that are wrong in the placeholder file are corrected.
|
|
895
896
|
event.set("date", t.strftime("%Y-%m-%d"))
|
|
896
897
|
event.set("time", t.strftime("%H:%M:%S"))
|
|
898
|
+
|
|
897
899
|
if nans[i]:
|
|
898
900
|
event.set("value", miss_val)
|
|
899
901
|
else:
|
|
900
|
-
event.set("value", str(
|
|
901
|
-
|
|
902
|
+
event.set("value", str(value))
|
|
903
|
+
|
|
902
904
|
if self.dt:
|
|
903
905
|
t += self.dt
|
|
904
906
|
|
|
@@ -911,7 +913,7 @@ class Timeseries:
|
|
|
911
913
|
f.close()
|
|
912
914
|
|
|
913
915
|
self.format_xml_data()
|
|
914
|
-
self.__tree.write(
|
|
916
|
+
self.__tree.write(xml_path)
|
|
915
917
|
|
|
916
918
|
def format_xml_data(self):
|
|
917
919
|
"""
|
|
@@ -1170,16 +1172,45 @@ class Timeseries:
|
|
|
1170
1172
|
self.__end_datetime = end_datetime
|
|
1171
1173
|
|
|
1172
1174
|
@property
|
|
1173
|
-
def path(self):
|
|
1174
|
-
|
|
1175
|
+
def path(self) -> str:
|
|
1176
|
+
"""
|
|
1177
|
+
The path to the original xml file.
|
|
1178
|
+
"""
|
|
1179
|
+
return os.path.join(self.__folder, self.__basename + ".xml")
|
|
1175
1180
|
|
|
1176
1181
|
@property
|
|
1177
|
-
def binary_path(self):
|
|
1182
|
+
def binary_path(self) -> str:
|
|
1178
1183
|
"""
|
|
1179
|
-
The path
|
|
1184
|
+
The path to the original binary data .bin file.
|
|
1180
1185
|
"""
|
|
1181
1186
|
return os.path.join(self.__folder, self.__basename + ".bin")
|
|
1182
1187
|
|
|
1188
|
+
def _output_path_without_extension(self, output_folder=None, output_filename=None) -> str:
|
|
1189
|
+
"""
|
|
1190
|
+
Get the output path without file extension.
|
|
1191
|
+
"""
|
|
1192
|
+
if output_folder is None:
|
|
1193
|
+
output_folder = self.__folder
|
|
1194
|
+
if output_filename is None:
|
|
1195
|
+
output_filename = self.__basename
|
|
1196
|
+
return os.path.join(output_folder, output_filename)
|
|
1197
|
+
|
|
1198
|
+
def output_path(self, output_folder=None, output_filename=None) -> str:
|
|
1199
|
+
"""
|
|
1200
|
+
Get the path to the output xml file.
|
|
1201
|
+
|
|
1202
|
+
The optional arguments are the same as in :py:method:`write`.
|
|
1203
|
+
"""
|
|
1204
|
+
return self._output_path_without_extension(output_folder, output_filename) + ".xml"
|
|
1205
|
+
|
|
1206
|
+
def output_binary_path(self, output_folder=None, output_filename=None) -> str:
|
|
1207
|
+
"""
|
|
1208
|
+
Get the path to the output binary file.
|
|
1209
|
+
|
|
1210
|
+
The optional arguments are the same as in :py:method:`write`.
|
|
1211
|
+
"""
|
|
1212
|
+
return self._output_path_without_extension(output_folder, output_filename) + ".bin"
|
|
1213
|
+
|
|
1183
1214
|
def items(self, ensemble_member=0):
|
|
1184
1215
|
"""
|
|
1185
1216
|
Returns an iterator over all timeseries IDs and value arrays for the given
|
|
@@ -667,6 +667,7 @@ class GoalProgrammingMixin(_GoalProgrammingMixinBase):
|
|
|
667
667
|
logger.info("Starting goal programming")
|
|
668
668
|
|
|
669
669
|
success = False
|
|
670
|
+
self.skip_priority = False
|
|
670
671
|
|
|
671
672
|
self.__constraint_store = [OrderedDict() for ensemble_member in range(self.ensemble_size)]
|
|
672
673
|
self.__path_constraint_store = [
|
|
@@ -691,6 +692,13 @@ class GoalProgrammingMixin(_GoalProgrammingMixinBase):
|
|
|
691
692
|
# Call the pre priority hook
|
|
692
693
|
self.priority_started(priority)
|
|
693
694
|
|
|
695
|
+
if self.skip_priority:
|
|
696
|
+
logger.info(
|
|
697
|
+
"priority {} was removed in priority_started. No optimization problem "
|
|
698
|
+
"is solved at this priority.".format(priority)
|
|
699
|
+
)
|
|
700
|
+
continue
|
|
701
|
+
|
|
694
702
|
(
|
|
695
703
|
self.__subproblem_epsilons,
|
|
696
704
|
self.__subproblem_objectives,
|
|
@@ -1081,6 +1081,7 @@ class _GoalProgrammingMixinBase(OptimizationProblem, metaclass=ABCMeta):
|
|
|
1081
1081
|
|
|
1082
1082
|
:param priority: The priority level that was started.
|
|
1083
1083
|
"""
|
|
1084
|
+
self.skip_priority = False
|
|
1084
1085
|
pass
|
|
1085
1086
|
|
|
1086
1087
|
def priority_completed(self, priority: int) -> None:
|
|
@@ -54,8 +54,8 @@ class ModelicaMixin(OptimizationProblem):
|
|
|
54
54
|
self.__pymoca_model = pymoca.backends.casadi.api.transfer_model(
|
|
55
55
|
kwargs["model_folder"], model_name, compiler_options
|
|
56
56
|
)
|
|
57
|
-
except RuntimeError as error:
|
|
58
|
-
if compiler_options.get("cache", False):
|
|
57
|
+
except (RuntimeError, ModuleNotFoundError) as error:
|
|
58
|
+
if not compiler_options.get("cache", False):
|
|
59
59
|
raise error
|
|
60
60
|
compiler_options["cache"] = False
|
|
61
61
|
logger.warning(f"Loading model {model_name} using a cache file failed: {error}.")
|
|
@@ -838,6 +838,8 @@ class SimulationProblem(DataStoreAccessor):
|
|
|
838
838
|
self.set_var("time", self.get_current_time() + dt)
|
|
839
839
|
|
|
840
840
|
# take a step
|
|
841
|
+
if np.isnan(self.__state_vector).any():
|
|
842
|
+
logger.error("Found a nan in the state vector (before making the step)")
|
|
841
843
|
guess = self.__state_vector[: self.__n_states]
|
|
842
844
|
if len(self.__mx["parameters"]) > 0:
|
|
843
845
|
next_state = self.__do_step(
|
|
@@ -845,6 +847,23 @@ class SimulationProblem(DataStoreAccessor):
|
|
|
845
847
|
)
|
|
846
848
|
else:
|
|
847
849
|
next_state = self.__do_step(guess, dt, self.__state_vector)
|
|
850
|
+
|
|
851
|
+
try:
|
|
852
|
+
if np.isnan(next_state).any():
|
|
853
|
+
index_to_name = {index[0]: name for name, index in self.__indices.items()}
|
|
854
|
+
named_next_state = {
|
|
855
|
+
index_to_name[i]: float(next_state[i]) for i in range(0, next_state.shape[0])
|
|
856
|
+
}
|
|
857
|
+
variables_with_nan = [
|
|
858
|
+
name for name, value in named_next_state.items() if np.isnan(value)
|
|
859
|
+
]
|
|
860
|
+
if variables_with_nan:
|
|
861
|
+
logger.error(
|
|
862
|
+
f"Found nan(s) in the next_state vector for:\n\t {variables_with_nan}"
|
|
863
|
+
)
|
|
864
|
+
except (KeyError, IndexError, TypeError):
|
|
865
|
+
logger.warning("Something went wrong while checking for nans in the next_state vector")
|
|
866
|
+
|
|
848
867
|
# Check convergence of rootfinder
|
|
849
868
|
rootfinder_stats = self.__do_step.stats()
|
|
850
869
|
|
|
File without changes
|
|
File without changes
|