ltbams 1.0.13__py3-none-any.whl → 1.0.14__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.
- ams/_version.py +3 -3
- ams/cli.py +2 -7
- ams/core/common.py +7 -3
- ams/core/documenter.py +2 -1
- ams/core/matprocessor.py +4 -4
- ams/core/model.py +14 -6
- ams/core/param.py +5 -3
- ams/core/symprocessor.py +8 -2
- ams/core/var.py +1 -1
- ams/extension/eva.py +11 -7
- ams/interface.py +7 -7
- ams/io/json.py +20 -16
- ams/io/matpower.py +6 -6
- ams/io/psse.py +2 -1
- ams/io/xlsx.py +21 -16
- ams/main.py +53 -45
- ams/models/distributed/esd1.py +4 -7
- ams/models/distributed/ev.py +10 -6
- ams/models/distributed/pvd1.py +4 -7
- ams/models/group.py +17 -18
- ams/models/renewable/regc.py +14 -22
- ams/models/timeslot.py +30 -0
- ams/models/zone.py +2 -4
- ams/opt/optzbase.py +4 -3
- ams/report.py +2 -7
- ams/routines/dcopf.py +7 -4
- ams/routines/dcopf2.py +14 -4
- ams/routines/dopf.py +2 -2
- ams/routines/ed.py +5 -5
- ams/routines/pflow.py +1 -1
- ams/routines/routine.py +8 -1
- ams/routines/rted.py +5 -5
- ams/routines/uc.py +2 -2
- ams/shared.py +69 -0
- ams/system.py +93 -18
- ams/utils/paths.py +6 -10
- docs/source/genroutineref.py +12 -0
- docs/source/release-notes.rst +6 -0
- {ltbams-1.0.13.dist-info → ltbams-1.0.14.dist-info}/METADATA +18 -22
- {ltbams-1.0.13.dist-info → ltbams-1.0.14.dist-info}/RECORD +43 -43
- {ltbams-1.0.13.dist-info → ltbams-1.0.14.dist-info}/WHEEL +0 -0
- {ltbams-1.0.13.dist-info → ltbams-1.0.14.dist-info}/entry_points.txt +0 -0
- {ltbams-1.0.13.dist-info → ltbams-1.0.14.dist-info}/top_level.txt +0 -0
ams/models/distributed/ev.py
CHANGED
@@ -12,13 +12,17 @@ class EV1(ModelData, Model):
|
|
12
12
|
"""
|
13
13
|
Aggregated EV model for scheduling at transmission level.
|
14
14
|
|
15
|
-
For co-simulation with
|
15
|
+
For co-simulation with ANDES, it is expected to be used in
|
16
16
|
conjunction with the dynamic models `EV1` or `EV2`.
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
References
|
19
|
+
----------
|
20
|
+
1. J. Wang et al., "Electric Vehicles Charging Time Constrained
|
21
|
+
Deliverable Provision of Secondary Frequency Regulation," in IEEE
|
22
|
+
Transactions on Smart Grid, vol. 15, no. 4, pp. 3892-3903, July
|
23
|
+
2024, doi: 10.1109/TSG.2024.3356948.
|
24
|
+
2. ANDES Documentation, EV1,
|
25
|
+
https://andes.readthedocs.io/en/stable/groupdoc/DG.html#ev1
|
22
26
|
"""
|
23
27
|
|
24
28
|
def __init__(self, system, config):
|
@@ -53,7 +57,7 @@ class EV1(ModelData, Model):
|
|
53
57
|
|
54
58
|
class EV2(EV1):
|
55
59
|
"""
|
56
|
-
|
60
|
+
Alias for EV1.
|
57
61
|
"""
|
58
62
|
|
59
63
|
def __init__(self, system=None, config=None) -> None:
|
ams/models/distributed/pvd1.py
CHANGED
@@ -52,13 +52,10 @@ class PVD1(PVD1Data, Model):
|
|
52
52
|
``vt3``, ``vrflag``, ``ft0``, ``ft1``, ``ft2``, ``ft3``, ``frflag``,
|
53
53
|
``tip``, ``tiq``, ``recflag``.
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
Available:
|
60
|
-
|
61
|
-
https://docs.andes.app/en/latest/groupdoc/DG.html#pvd1
|
55
|
+
References
|
56
|
+
----------
|
57
|
+
1. ANDES Documentation, PVD1,
|
58
|
+
https://andes.readthedocs.io/en/stable/groupdoc/DG.html#pvd1
|
62
59
|
"""
|
63
60
|
|
64
61
|
def __init__(self, system, config):
|
ams/models/group.py
CHANGED
@@ -3,22 +3,24 @@ import logging
|
|
3
3
|
from andes.models.group import GroupBase as adGroupBase
|
4
4
|
from andes.core.service import BackRef
|
5
5
|
|
6
|
+
from ams.utils.misc import deprec_get_idx
|
7
|
+
|
6
8
|
logger = logging.getLogger(__name__)
|
7
9
|
|
8
10
|
|
9
11
|
class GroupBase(adGroupBase):
|
10
12
|
"""
|
11
|
-
Base class for groups
|
13
|
+
Base class for groups, revised from
|
14
|
+
`andes.models.group.GroupBase`.
|
12
15
|
|
13
16
|
Add common_vars and common_params to the group class.
|
14
|
-
|
15
|
-
This class is revised from ``andes.models.group.GroupBase``.
|
16
17
|
"""
|
17
18
|
|
18
19
|
def __init__(self):
|
19
20
|
super().__init__()
|
20
21
|
self.common_params.extend(('idx',))
|
21
22
|
|
23
|
+
@deprec_get_idx
|
22
24
|
def get_idx(self):
|
23
25
|
"""
|
24
26
|
Return the value of group idx sorted in a human-readable style.
|
@@ -27,6 +29,9 @@ class GroupBase(adGroupBase):
|
|
27
29
|
-----
|
28
30
|
This function sorts the idx values using a custom sorting key,
|
29
31
|
which handles varying length strings with letters and numbers.
|
32
|
+
|
33
|
+
.. deprecated:: 1.0.0
|
34
|
+
Use ``get_all_idxes`` instead.
|
30
35
|
"""
|
31
36
|
all_idx = [mdl.idx.v for mdl in self.models.values()]
|
32
37
|
flat_list = [item for sublist in all_idx for item in sublist]
|
@@ -94,13 +99,10 @@ class RenGen(GroupBase):
|
|
94
99
|
See ANDES Documentation SynGen here for the notes on replacing StaticGen and setting the power
|
95
100
|
ratio parameters.
|
96
101
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
Available:
|
102
|
-
|
103
|
-
https://docs.andes.app/en/latest/groupdoc/RenGen.html#rengen
|
102
|
+
References
|
103
|
+
----------
|
104
|
+
1. ANDES Documentation, RenGen,
|
105
|
+
https://andes.readthedocs.io/en/stable/groupdoc/RenGen.html#rengen
|
104
106
|
"""
|
105
107
|
|
106
108
|
def __init__(self):
|
@@ -129,13 +131,10 @@ class DG(GroupBase):
|
|
129
131
|
See ANDES Documentation SynGen here for the notes on replacing StaticGen and setting the power
|
130
132
|
ratio parameters.
|
131
133
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
Available:
|
137
|
-
|
138
|
-
https://docs.andes.app/en/latest/groupdoc/SynGen.html#syngen
|
134
|
+
References
|
135
|
+
----------
|
136
|
+
1. ANDES Documentation, SynGen,
|
137
|
+
https://andes.readthedocs.io/en/stable/groupdoc/SynGen.html#syngen
|
139
138
|
"""
|
140
139
|
|
141
140
|
def __init__(self):
|
@@ -182,7 +181,7 @@ class StaticGen(GroupBase):
|
|
182
181
|
Notes
|
183
182
|
-----
|
184
183
|
For co-simulation with ANDES, refer to the `ANDES StaticGen Documentation
|
185
|
-
<https://
|
184
|
+
<https://andes.readthedocs.io/en/stable/groupdoc/StaticGen.html#staticgen>`_ for
|
186
185
|
replacing static generators with dynamic generators.
|
187
186
|
"""
|
188
187
|
|
ams/models/renewable/regc.py
CHANGED
@@ -39,12 +39,10 @@ class REGCA1(REGCData, Model):
|
|
39
39
|
"""
|
40
40
|
Renewable generator scheduling model.
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
Available:
|
47
|
-
https://docs.andes.app/en/latest/groupdoc/RenGen.html#regca1
|
42
|
+
References
|
43
|
+
----------
|
44
|
+
1. ANDES Documentation, REGCA1,
|
45
|
+
https://andes.readthedocs.io/en/stable/groupdoc/RenGen.html#regca1
|
48
46
|
"""
|
49
47
|
|
50
48
|
def __init__(self, system=None, config=None) -> None:
|
@@ -56,7 +54,7 @@ class REGCA1(REGCData, Model):
|
|
56
54
|
class REGCV1(REGCData, Model):
|
57
55
|
"""
|
58
56
|
Voltage-controlled converter model (virtual synchronous generator) with
|
59
|
-
inertia emulation.
|
57
|
+
inertia emulation, for scheduling purposes.
|
60
58
|
|
61
59
|
Here Mmax and Dmax are assumed to be constant, but they might subject to
|
62
60
|
the operating condition of the converter.
|
@@ -67,13 +65,10 @@ class REGCV1(REGCData, Model):
|
|
67
65
|
- Generation cost is defined by model :ref:`GCost`
|
68
66
|
- Inertia emulation cost is defined by model :ref:`VSGCost`
|
69
67
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
Available:
|
75
|
-
|
76
|
-
https://docs.andes.app/en/latest/groupdoc/RenGen.html#regcv1
|
68
|
+
References
|
69
|
+
----------
|
70
|
+
1. ANDES Documentation, REGCV1,
|
71
|
+
https://andes.readthedocs.io/en/stable/groupdoc/RenGen.html#regcv1
|
77
72
|
"""
|
78
73
|
|
79
74
|
def __init__(self, system=None, config=None) -> None:
|
@@ -100,15 +95,12 @@ class REGCV1(REGCData, Model):
|
|
100
95
|
|
101
96
|
class REGCV2(REGCV1):
|
102
97
|
"""
|
103
|
-
|
104
|
-
|
105
|
-
Reference:
|
106
|
-
|
107
|
-
[1] ANDES Documentation, REGCV2
|
108
|
-
|
109
|
-
Available:
|
98
|
+
Alias for REGCV1, for scheduling purposes.
|
110
99
|
|
111
|
-
|
100
|
+
References
|
101
|
+
----------
|
102
|
+
1. ANDES Documentation, REGCV2,
|
103
|
+
https://andes.readthedocs.io/en/stable/groupdoc/RenGen.html#regcv2
|
112
104
|
"""
|
113
105
|
|
114
106
|
def __init__(self, system=None, config=None) -> None:
|
ams/models/timeslot.py
CHANGED
@@ -10,12 +10,42 @@ from ams.core.model import Model
|
|
10
10
|
def str_list_oconv(x):
|
11
11
|
"""
|
12
12
|
Convert list into a list literal.
|
13
|
+
|
14
|
+
Revised from `andes.models.timeseries.str_list_oconv`, where
|
15
|
+
the output type is converted to a list of strings.
|
13
16
|
"""
|
14
17
|
# NOTE: convert elements to string from number first, then join them
|
15
18
|
str_x = [str(i) for i in x]
|
16
19
|
return ','.join(str_x)
|
17
20
|
|
18
21
|
|
22
|
+
class GCommit(ModelData, Model):
|
23
|
+
"""
|
24
|
+
Time slot model for generator commitment decisions.
|
25
|
+
|
26
|
+
This class holds commitment decisions for generators,
|
27
|
+
and should be used in multi-period scheduling routines that need
|
28
|
+
generator commitment decisions.
|
29
|
+
|
30
|
+
For example, in Unit Commitment (UC) problems, there is a variable
|
31
|
+
`ugd` representing the unit commitment decisions for each generator.
|
32
|
+
After solving the UC problem, the `ugd` values can be used for
|
33
|
+
Economic Dispatch (ED) as a parameter.
|
34
|
+
|
35
|
+
.. versionadded:: 1.0.13
|
36
|
+
"""
|
37
|
+
|
38
|
+
def __init__(self, system=None, config=None):
|
39
|
+
ModelData.__init__(self)
|
40
|
+
Model.__init__(self, system, config)
|
41
|
+
|
42
|
+
self.ug = NumParam(info='unit commitment decisions',
|
43
|
+
tex_name=r'u_{g}',
|
44
|
+
iconvert=str_list_iconv,
|
45
|
+
oconvert=str_list_oconv,
|
46
|
+
vtype=int)
|
47
|
+
|
48
|
+
|
19
49
|
class TimeSlot(ModelData, Model):
|
20
50
|
"""
|
21
51
|
Base model for time slot data used in multi-interval scheduling.
|
ams/models/zone.py
CHANGED
@@ -17,9 +17,8 @@ class Zone(ModelData, Model):
|
|
17
17
|
|
18
18
|
Notes
|
19
19
|
-----
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
- A zone is a collection of buses.
|
21
|
+
- The ``Zone`` model is not defined in ANDES up to version 1.9.3.
|
23
22
|
"""
|
24
23
|
|
25
24
|
def __init__(self, system, config):
|
@@ -39,7 +38,6 @@ class Zone(ModelData, Model):
|
|
39
38
|
-------
|
40
39
|
str
|
41
40
|
Formatted table
|
42
|
-
|
43
41
|
"""
|
44
42
|
if self.n:
|
45
43
|
header = ['Zone ID', 'Bus ID']
|
ams/opt/optzbase.py
CHANGED
@@ -174,13 +174,14 @@ class OptzBase:
|
|
174
174
|
"""
|
175
175
|
Return all the indexes of this item.
|
176
176
|
|
177
|
-
.. note::
|
178
|
-
New in version 1.0.0.
|
179
|
-
|
180
177
|
Returns
|
181
178
|
-------
|
182
179
|
list
|
183
180
|
A list of indexes.
|
181
|
+
|
182
|
+
Notes
|
183
|
+
-----
|
184
|
+
.. versionadded:: 1.0.0
|
184
185
|
"""
|
185
186
|
|
186
187
|
if self.is_group:
|
ams/report.py
CHANGED
@@ -30,13 +30,8 @@ def report_info(system) -> list:
|
|
30
30
|
|
31
31
|
class Report:
|
32
32
|
"""
|
33
|
-
Report class to store routine analysis reports
|
34
|
-
|
35
|
-
Notes
|
36
|
-
-----
|
37
|
-
Revised from the ANDES project (https://github.com/CURENT/andes).
|
38
|
-
Original author: Hantao Cui
|
39
|
-
License: GPL3
|
33
|
+
Report class to store routine analysis reports,
|
34
|
+
revised from `andes.report.Report`.
|
40
35
|
"""
|
41
36
|
|
42
37
|
def __init__(self, system):
|
ams/routines/dcopf.py
CHANGED
@@ -17,19 +17,22 @@ logger = logging.getLogger(__name__)
|
|
17
17
|
|
18
18
|
class DCOPF(DCPFBase):
|
19
19
|
"""
|
20
|
-
DC optimal power flow (DCOPF).
|
20
|
+
DC optimal power flow (DCOPF) using B-theta formulation.
|
21
21
|
|
22
22
|
Notes
|
23
23
|
-----
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
- The nodal price is calculated as ``pi`` in ``pic``.
|
25
|
+
- Devices online status of ``StaticGen``, ``StaticLoad``, and ``Shunt`` are considered in the connectivity
|
26
|
+
matrices ``Cft``, ``Cg``, ``Cl``, and ``Csh``.
|
27
27
|
|
28
28
|
References
|
29
29
|
----------
|
30
30
|
1. R. D. Zimmerman, C. E. Murillo-Sanchez, and R. J. Thomas, “MATPOWER: Steady-State
|
31
31
|
Operations, Planning, and Analysis Tools for Power Systems Research and Education,” IEEE
|
32
32
|
Trans. Power Syst., vol. 26, no. 1, pp. 12-19, Feb. 2011
|
33
|
+
2. Y. Chen et al., "Security-Constrained Unit Commitment for Electricity Market: Modeling,
|
34
|
+
Solution Methods, and Future Challenges," in IEEE Transactions on Power Systems, vol. 38, no. 5,
|
35
|
+
pp. 4668-4681, Sept. 2023
|
33
36
|
"""
|
34
37
|
|
35
38
|
def __init__(self, system, config):
|
ams/routines/dcopf2.py
CHANGED
@@ -18,15 +18,25 @@ logger = logging.getLogger(__name__)
|
|
18
18
|
|
19
19
|
class DCOPF2(DCOPF):
|
20
20
|
"""
|
21
|
-
DC optimal power flow (DCOPF) using PTDF.
|
21
|
+
DC optimal power flow (DCOPF) using PTDF formulation.
|
22
|
+
|
22
23
|
For large cases, it is recommended to build the PTDF first, especially when incremental
|
23
24
|
build is necessary.
|
24
25
|
|
25
26
|
Notes
|
26
27
|
-----
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
- This routine requires PTDF matrix.
|
29
|
+
- Nodal price ``pi`` is calculated with three parts.
|
30
|
+
- Bus angle ``aBus`` is calculated after solving the problem.
|
31
|
+
|
32
|
+
References
|
33
|
+
----------
|
34
|
+
1. R. D. Zimmerman, C. E. Murillo-Sanchez, and R. J. Thomas, “MATPOWER: Steady-State
|
35
|
+
Operations, Planning, and Analysis Tools for Power Systems Research and Education,” IEEE
|
36
|
+
Trans. Power Syst., vol. 26, no. 1, pp. 12-19, Feb. 2011
|
37
|
+
2. Y. Chen et al., "Security-Constrained Unit Commitment for Electricity Market: Modeling,
|
38
|
+
Solution Methods, and Future Challenges," in IEEE Transactions on Power Systems, vol. 38, no. 5,
|
39
|
+
pp. 4668-4681, Sept. 2023
|
30
40
|
"""
|
31
41
|
|
32
42
|
def __init__(self, system, config):
|
ams/routines/dopf.py
CHANGED
@@ -17,7 +17,7 @@ class DOPF(DCOPF):
|
|
17
17
|
UNDER DEVELOPMENT!
|
18
18
|
|
19
19
|
References
|
20
|
-
|
20
|
+
----------
|
21
21
|
1. L. Bai, J. Wang, C. Wang, C. Chen, and F. Li, “Distribution Locational Marginal Pricing (DLMP)
|
22
22
|
for Congestion Management and Voltage Support,” IEEE Trans. Power Syst., vol. 33, no. 4,
|
23
23
|
pp. 4061-4073, Jul. 2018, doi: 10.1109/TPWRS.2017.2767632.
|
@@ -116,7 +116,7 @@ class DOPFVIS(DOPF):
|
|
116
116
|
UNDER DEVELOPMENT!
|
117
117
|
|
118
118
|
References
|
119
|
-
|
119
|
+
----------
|
120
120
|
1. L. Bai, J. Wang, C. Wang, C. Chen, and F. Li, “Distribution Locational Marginal Pricing (DLMP)
|
121
121
|
for Congestion Management and Voltage Support,” IEEE Trans. Power Syst., vol. 33, no. 4,
|
122
122
|
pp. 4061-4073, Jul. 2018, doi: 10.1109/TPWRS.2017.2767632.
|
ams/routines/ed.py
CHANGED
@@ -120,11 +120,11 @@ class ED(RTED, MPBase, SRBase):
|
|
120
120
|
|
121
121
|
Notes
|
122
122
|
-----
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
123
|
+
- Formulations has been adjusted with interval ``config.t``
|
124
|
+
- The tie-line flow is not implemented in this model.
|
125
|
+
- ``EDTSlot.ug`` is used instead of ``StaticGen.u`` for generator commitment.
|
126
|
+
- Following reserves are balanced for each "Area": RegUp reserve ``rbu``,
|
127
|
+
RegDn reserve ``rbd``, and Spinning reserve ``rsr``.
|
128
128
|
"""
|
129
129
|
|
130
130
|
def __init__(self, system, config):
|
ams/routines/pflow.py
CHANGED
@@ -30,7 +30,7 @@ class PFlow(RoutineBase):
|
|
30
30
|
----------
|
31
31
|
1. M. L. Crow, Computational methods for electric power systems. 2015.
|
32
32
|
2. ANDES Documentation - Simulation and Plot.
|
33
|
-
https://
|
33
|
+
https://andes.readthedocs.io/en/stable/_examples/ex1.html
|
34
34
|
"""
|
35
35
|
|
36
36
|
def __init__(self, system, config):
|
ams/routines/routine.py
CHANGED
@@ -445,6 +445,8 @@ class RoutineBase:
|
|
445
445
|
-------
|
446
446
|
bool
|
447
447
|
True if the loading is successful, False otherwise.
|
448
|
+
|
449
|
+
.. versionadded:: 1.0.13
|
448
450
|
"""
|
449
451
|
try:
|
450
452
|
with open(path, 'r') as f:
|
@@ -496,12 +498,15 @@ class RoutineBase:
|
|
496
498
|
-------
|
497
499
|
str
|
498
500
|
The exported json file name
|
501
|
+
|
502
|
+
.. versionadded:: 1.0.13
|
499
503
|
"""
|
500
504
|
if not self.converged:
|
501
505
|
logger.warning("Routine did not converge, aborting export.")
|
502
506
|
return None
|
503
507
|
|
504
|
-
path, file_name = get_export_path(self.system,
|
508
|
+
path, file_name = get_export_path(self.system,
|
509
|
+
self.class_name + '_out',
|
505
510
|
path=path, fmt='json')
|
506
511
|
|
507
512
|
data_dict = dict()
|
@@ -1123,6 +1128,8 @@ def group_data(rtn: RoutineBase, data_dict: Dict, items: Dict, attr: str):
|
|
1123
1128
|
Dictionary of items to collect data from.
|
1124
1129
|
attr : str
|
1125
1130
|
Attribute to collect data for.
|
1131
|
+
|
1132
|
+
.. versionadded:: 1.0.13
|
1126
1133
|
"""
|
1127
1134
|
for key, item in items.items():
|
1128
1135
|
if item.owner is None:
|
ams/routines/rted.py
CHANGED
@@ -125,10 +125,10 @@ class RTED(DCOPF, RTEDBase, SFRBase):
|
|
125
125
|
|
126
126
|
Notes
|
127
127
|
-----
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
128
|
+
- Formulations has been adjusted with interval ``config.t``, 5/60 [Hour] by default.
|
129
|
+
- The tie-line flow related constraints are ommited in this formulation.
|
130
|
+
- Power generation is balanced for the entire system.
|
131
|
+
- SFR is balanced for each area.
|
132
132
|
"""
|
133
133
|
|
134
134
|
def __init__(self, system, config):
|
@@ -487,7 +487,7 @@ class RTEDVIS(RTED, VISBase):
|
|
487
487
|
Please ensure that the parameters `dvm` and `dvd` are set according to the system base.
|
488
488
|
|
489
489
|
References
|
490
|
-
|
490
|
+
----------
|
491
491
|
1. B. She, F. Li, H. Cui, J. Wang, Q. Zhang and R. Bo, "Virtual Inertia Scheduling (VIS) for
|
492
492
|
Real-Time Economic Dispatch of IBR-Penetrated Power Systems," in IEEE Transactions on
|
493
493
|
Sustainable Energy, vol. 15, no. 2, pp. 938-951, April 2024, doi: 10.1109/TSTE.2023.3319307.
|
ams/routines/uc.py
CHANGED
@@ -69,8 +69,8 @@ class UC(DCOPF, RTEDBase, MPBase, SRBase, NSRBase):
|
|
69
69
|
|
70
70
|
Notes
|
71
71
|
-----
|
72
|
-
|
73
|
-
|
72
|
+
- The formulations has been adjusted with interval ``config.t``
|
73
|
+
- The tie-line flow has not been implemented in formulations.
|
74
74
|
|
75
75
|
References
|
76
76
|
----------
|
ams/shared.py
CHANGED
@@ -15,6 +15,7 @@ from andes.utils.lazyimport import LazyImport
|
|
15
15
|
|
16
16
|
from andes.system import System as adSystem
|
17
17
|
|
18
|
+
from ._version import get_versions
|
18
19
|
|
19
20
|
logger = logging.getLogger(__name__)
|
20
21
|
|
@@ -46,6 +47,15 @@ _max_length = 80 # NOQA
|
|
46
47
|
copyright_msg = "Copyright (C) 2023-2025 Jinning Wang"
|
47
48
|
nowarranty_msg = "AMS comes with ABSOLUTELY NO WARRANTY"
|
48
49
|
report_time = strftime("%m/%d/%Y %I:%M:%S %p")
|
50
|
+
version_msg = f"AMS {get_versions()['version']}"
|
51
|
+
|
52
|
+
summary_row = {'field': 'Info',
|
53
|
+
'comment': version_msg,
|
54
|
+
'comment2': report_time,
|
55
|
+
'comment3': nowarranty_msg,
|
56
|
+
'comment4': copyright_msg}
|
57
|
+
|
58
|
+
summary_name = "Summary" # ensure model Summary's name is consistent
|
49
59
|
|
50
60
|
# NOTE: copied from CVXPY documentation, last checked on 2024/10/30, v1.5
|
51
61
|
mip_solvers = ['CBC', 'COPT', 'GLPK_MI', 'CPLEX', 'GUROBI',
|
@@ -162,3 +172,62 @@ def _update_pbar(pbar, current, total):
|
|
162
172
|
if pbar.n < pbar.total: # Check if it's not already at total
|
163
173
|
pbar.update(pbar.total - pbar.n) # Update remaining
|
164
174
|
pbar.close()
|
175
|
+
|
176
|
+
|
177
|
+
def ams_params_not_in_andes(mdl_name, am_params):
|
178
|
+
"""
|
179
|
+
Helper function to return parameters not in the ANDES model.
|
180
|
+
If the model is not in the ANDES system, it returns an empty list.
|
181
|
+
|
182
|
+
Parameters
|
183
|
+
----------
|
184
|
+
mdl_name : str
|
185
|
+
The name of the model.
|
186
|
+
am_params : list
|
187
|
+
A list of parameters from the AMS model.
|
188
|
+
|
189
|
+
Returns
|
190
|
+
-------
|
191
|
+
list
|
192
|
+
A list of parameters that are not in the ANDES model.
|
193
|
+
"""
|
194
|
+
if mdl_name not in ad_models:
|
195
|
+
return []
|
196
|
+
ad_params = list(empty_adsys.models[mdl_name].params.keys())
|
197
|
+
return list(set(am_params) - set(ad_params))
|
198
|
+
|
199
|
+
|
200
|
+
def model2df(instance, skip_empty, to_andes):
|
201
|
+
"""
|
202
|
+
Prepare a DataFrame from the model instance for output.
|
203
|
+
|
204
|
+
Parameters
|
205
|
+
----------
|
206
|
+
instance : ams.model.Model
|
207
|
+
The model instance to prepare.
|
208
|
+
skip_empty : bool
|
209
|
+
Whether to skip empty models.
|
210
|
+
to_andes : bool
|
211
|
+
Whether to prepare the DataFrame for ANDES.
|
212
|
+
|
213
|
+
Returns
|
214
|
+
-------
|
215
|
+
pd.DataFrame
|
216
|
+
The prepared DataFrame.
|
217
|
+
"""
|
218
|
+
name = instance.class_name
|
219
|
+
|
220
|
+
if skip_empty and instance.n == 0:
|
221
|
+
return None
|
222
|
+
|
223
|
+
if name not in ad_models and to_andes:
|
224
|
+
return None
|
225
|
+
|
226
|
+
instance.cache.refresh("df_in")
|
227
|
+
df = instance.cache.df_in
|
228
|
+
|
229
|
+
if to_andes:
|
230
|
+
skipped_params = ams_params_not_in_andes(name, df.columns.tolist())
|
231
|
+
df = df.drop(skipped_params, axis=1, errors='ignore')
|
232
|
+
|
233
|
+
return df
|