ltbams 0.9.9__tar.gz → 0.9.11__tar.gz
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.
- ltbams-0.9.11/CONTRIBUTING.rst +102 -0
- {ltbams-0.9.9 → ltbams-0.9.11}/LICENSE +1 -1
- ltbams-0.9.11/MANIFEST.in +17 -0
- ltbams-0.9.11/PKG-INFO +11 -0
- {ltbams-0.9.9 → ltbams-0.9.11}/README.md +17 -4
- ltbams-0.9.11/ams/__init__.py +13 -0
- {ltbams-0.9.9 → ltbams-0.9.11}/ams/_version.py +4 -4
- ltbams-0.9.11/ams/benchmarks.py +302 -0
- ltbams-0.9.11/ams/cases/5bus/pjm5bus_demo.xlsx +0 -0
- ltbams-0.9.11/ams/cases/5bus/pjm5bus_jumper.xlsx +0 -0
- ltbams-0.9.11/ams/cases/5bus/pjm5bus_uced.json +1062 -0
- ltbams-0.9.11/ams/cases/5bus/pjm5bus_uced.xlsx +0 -0
- ltbams-0.9.11/ams/cases/5bus/pjm5bus_uced_esd1.xlsx +0 -0
- ltbams-0.9.11/ams/cases/5bus/pjm5bus_uced_ev.xlsx +0 -0
- ltbams-0.9.11/ams/cases/ieee123/ieee123.xlsx +0 -0
- ltbams-0.9.11/ams/cases/ieee123/ieee123_regcv1.xlsx +0 -0
- ltbams-0.9.11/ams/cases/ieee14/ieee14.json +1166 -0
- ltbams-0.9.11/ams/cases/ieee14/ieee14.raw +92 -0
- ltbams-0.9.11/ams/cases/ieee14/ieee14_uced.xlsx +0 -0
- ltbams-0.9.11/ams/cases/ieee39/ieee39.xlsx +0 -0
- ltbams-0.9.11/ams/cases/ieee39/ieee39_uced.xlsx +0 -0
- ltbams-0.9.11/ams/cases/ieee39/ieee39_uced_esd1.xlsx +0 -0
- ltbams-0.9.11/ams/cases/ieee39/ieee39_uced_pvd1.xlsx +0 -0
- ltbams-0.9.11/ams/cases/ieee39/ieee39_uced_vis.xlsx +0 -0
- ltbams-0.9.11/ams/cases/matpower/benchmark.json +1594 -0
- ltbams-0.9.11/ams/cases/matpower/case118.m +787 -0
- ltbams-0.9.11/ams/cases/matpower/case14.m +129 -0
- ltbams-0.9.11/ams/cases/matpower/case300.m +1315 -0
- ltbams-0.9.11/ams/cases/matpower/case39.m +205 -0
- ltbams-0.9.11/ams/cases/matpower/case5.m +62 -0
- ltbams-0.9.11/ams/cases/matpower/case_ACTIVSg2000.m +9460 -0
- ltbams-0.9.11/ams/cases/npcc/npcc.m +644 -0
- ltbams-0.9.11/ams/cases/npcc/npcc_uced.xlsx +0 -0
- ltbams-0.9.11/ams/cases/pglib/pglib_opf_case39_epri__api.m +243 -0
- ltbams-0.9.11/ams/cases/wecc/wecc.m +714 -0
- ltbams-0.9.11/ams/cases/wecc/wecc_uced.xlsx +0 -0
- {ltbams-0.9.9 → ltbams-0.9.11}/ams/cli.py +6 -0
- ltbams-0.9.11/ams/core/__init__.py +2 -0
- ltbams-0.9.11/ams/core/documenter.py +584 -0
- ltbams-0.9.11/ams/core/matprocessor.py +780 -0
- ltbams-0.9.11/ams/core/model.py +300 -0
- ltbams-0.9.11/ams/core/param.py +277 -0
- ltbams-0.9.11/ams/core/service.py +898 -0
- ltbams-0.9.11/ams/core/symprocessor.py +216 -0
- ltbams-0.9.11/ams/core/var.py +59 -0
- ltbams-0.9.11/ams/extension/__init__.py +5 -0
- ltbams-0.9.11/ams/extension/eva.py +401 -0
- ltbams-0.9.11/ams/interface.py +991 -0
- ltbams-0.9.11/ams/io/__init__.py +133 -0
- ltbams-0.9.11/ams/io/json.py +82 -0
- ltbams-0.9.11/ams/io/matpower.py +406 -0
- ltbams-0.9.11/ams/io/psse.py +6 -0
- ltbams-0.9.11/ams/io/pypower.py +103 -0
- ltbams-0.9.11/ams/io/xlsx.py +80 -0
- {ltbams-0.9.9 → ltbams-0.9.11}/ams/main.py +79 -2
- ltbams-0.9.11/ams/models/__init__.py +24 -0
- ltbams-0.9.11/ams/models/area.py +40 -0
- ltbams-0.9.11/ams/models/bus.py +52 -0
- ltbams-0.9.11/ams/models/cost.py +169 -0
- ltbams-0.9.11/ams/models/distributed/__init__.py +3 -0
- ltbams-0.9.11/ams/models/distributed/esd1.py +71 -0
- ltbams-0.9.11/ams/models/distributed/ev.py +60 -0
- ltbams-0.9.11/ams/models/distributed/pvd1.py +67 -0
- ltbams-0.9.11/ams/models/group.py +244 -0
- ltbams-0.9.11/ams/models/info.py +26 -0
- ltbams-0.9.11/ams/models/line.py +238 -0
- ltbams-0.9.11/ams/models/region.py +52 -0
- ltbams-0.9.11/ams/models/renewable/__init__.py +5 -0
- ltbams-0.9.11/ams/models/renewable/regc.py +119 -0
- ltbams-0.9.11/ams/models/reserve.py +94 -0
- ltbams-0.9.11/ams/models/shunt.py +14 -0
- ltbams-0.9.11/ams/models/static/__init__.py +2 -0
- ltbams-0.9.11/ams/models/static/gen.py +165 -0
- ltbams-0.9.11/ams/models/static/pq.py +61 -0
- ltbams-0.9.11/ams/models/timeslot.py +69 -0
- ltbams-0.9.11/ams/opt/__init__.py +5 -0
- ltbams-0.9.11/ams/opt/omodel.py +1223 -0
- ltbams-0.9.11/ams/pypower/__init__.py +8 -0
- ltbams-0.9.11/ams/pypower/_compat.py +9 -0
- ltbams-0.9.11/ams/pypower/core/__init__.py +8 -0
- ltbams-0.9.11/ams/pypower/core/pips.py +894 -0
- ltbams-0.9.11/ams/pypower/core/ppoption.py +244 -0
- ltbams-0.9.11/ams/pypower/core/ppver.py +18 -0
- ltbams-0.9.11/ams/pypower/core/solver.py +2451 -0
- ltbams-0.9.11/ams/pypower/eps.py +6 -0
- ltbams-0.9.11/ams/pypower/idx.py +174 -0
- ltbams-0.9.11/ams/pypower/io.py +604 -0
- ltbams-0.9.11/ams/pypower/make/__init__.py +11 -0
- ltbams-0.9.11/ams/pypower/make/matrices.py +665 -0
- ltbams-0.9.11/ams/pypower/make/pdv.py +506 -0
- ltbams-0.9.11/ams/pypower/routines/__init__.py +7 -0
- ltbams-0.9.11/ams/pypower/routines/cpf.py +513 -0
- ltbams-0.9.11/ams/pypower/routines/cpf_callbacks.py +114 -0
- ltbams-0.9.11/ams/pypower/routines/opf.py +1803 -0
- ltbams-0.9.11/ams/pypower/routines/opffcns.py +1946 -0
- ltbams-0.9.11/ams/pypower/routines/pflow.py +852 -0
- ltbams-0.9.11/ams/pypower/toggle.py +1098 -0
- ltbams-0.9.11/ams/pypower/utils.py +293 -0
- {ltbams-0.9.9 → ltbams-0.9.11}/ams/report.py +6 -0
- ltbams-0.9.11/ams/routines/__init__.py +21 -0
- ltbams-0.9.11/ams/routines/acopf.py +120 -0
- ltbams-0.9.11/ams/routines/cpf.py +65 -0
- ltbams-0.9.11/ams/routines/dcopf.py +381 -0
- ltbams-0.9.11/ams/routines/dcpf.py +188 -0
- ltbams-0.9.11/ams/routines/dopf.py +150 -0
- ltbams-0.9.11/ams/routines/ed.py +308 -0
- ltbams-0.9.11/ams/routines/pflow.py +111 -0
- ltbams-0.9.11/ams/routines/routine.py +985 -0
- ltbams-0.9.11/ams/routines/rted.py +572 -0
- ltbams-0.9.11/ams/routines/type.py +160 -0
- ltbams-0.9.11/ams/routines/uc.py +373 -0
- {ltbams-0.9.9 → ltbams-0.9.11}/ams/shared.py +31 -8
- {ltbams-0.9.9 → ltbams-0.9.11}/ams/system.py +6 -6
- ltbams-0.9.11/ams/utils/__init__.py +59 -0
- ltbams-0.9.11/ams/utils/paths.py +257 -0
- ltbams-0.9.11/docs/Makefile +21 -0
- ltbams-0.9.11/docs/make.bat +35 -0
- ltbams-0.9.11/docs/source/_templates/autosummary/base.rst +5 -0
- ltbams-0.9.11/docs/source/_templates/autosummary/class.rst +35 -0
- ltbams-0.9.11/docs/source/_templates/autosummary/module.rst +65 -0
- ltbams-0.9.11/docs/source/_templates/autosummary/module_toctree.rst +66 -0
- ltbams-0.9.11/docs/source/api.rst +102 -0
- ltbams-0.9.11/docs/source/conf.py +203 -0
- ltbams-0.9.11/docs/source/examples/index.rst +33 -0
- ltbams-0.9.11/docs/source/genmodelref.py +61 -0
- ltbams-0.9.11/docs/source/genroutineref.py +47 -0
- ltbams-0.9.11/docs/source/getting_started/copyright.rst +20 -0
- ltbams-0.9.11/docs/source/getting_started/formats/index.rst +20 -0
- ltbams-0.9.11/docs/source/getting_started/formats/matpower.rst +183 -0
- ltbams-0.9.11/docs/source/getting_started/formats/psse.rst +46 -0
- ltbams-0.9.11/docs/source/getting_started/formats/pypower.rst +223 -0
- ltbams-0.9.11/docs/source/getting_started/formats/xlsx.png +0 -0
- ltbams-0.9.11/docs/source/getting_started/formats/xlsx.rst +23 -0
- ltbams-0.9.11/docs/source/getting_started/index.rst +76 -0
- ltbams-0.9.11/docs/source/getting_started/install.rst +234 -0
- ltbams-0.9.11/docs/source/getting_started/overview.rst +26 -0
- ltbams-0.9.11/docs/source/getting_started/testcase.rst +45 -0
- ltbams-0.9.11/docs/source/getting_started/verification.rst +13 -0
- ltbams-0.9.11/docs/source/images/dcopf_time.png +0 -0
- ltbams-0.9.11/docs/source/images/sponsors/CURENT_Logo_NameOnTrans.png +0 -0
- ltbams-0.9.11/docs/source/images/sponsors/CURENT_Logo_Transparent.png +0 -0
- ltbams-0.9.11/docs/source/images/sponsors/CURENT_Logo_Transparent_Name.png +0 -0
- ltbams-0.9.11/docs/source/images/sponsors/doe.png +0 -0
- ltbams-0.9.11/docs/source/index.rst +109 -0
- ltbams-0.9.11/docs/source/modeling/example.rst +159 -0
- ltbams-0.9.11/docs/source/modeling/index.rst +17 -0
- ltbams-0.9.11/docs/source/modeling/model.rst +210 -0
- ltbams-0.9.11/docs/source/modeling/routine.rst +122 -0
- ltbams-0.9.11/docs/source/modeling/system.rst +51 -0
- ltbams-0.9.11/docs/source/release-notes.rst +332 -0
- ltbams-0.9.11/ltbams.egg-info/PKG-INFO +11 -0
- ltbams-0.9.11/ltbams.egg-info/SOURCES.txt +185 -0
- ltbams-0.9.11/ltbams.egg-info/top_level.txt +2 -0
- {ltbams-0.9.9 → ltbams-0.9.11}/pyproject.toml +7 -22
- ltbams-0.9.11/requirements-extra.txt +19 -0
- ltbams-0.9.11/requirements.txt +12 -0
- ltbams-0.9.11/setup.py +17 -0
- ltbams-0.9.11/tests/__init__.py +0 -0
- ltbams-0.9.11/tests/test_andes_mats.py +61 -0
- ltbams-0.9.11/tests/test_benchmarks.py +149 -0
- {ltbams-0.9.9 → ltbams-0.9.11}/tests/test_case.py +2 -2
- ltbams-0.9.9/tests/test_andes.py → ltbams-0.9.11/tests/test_interop.py +7 -60
- ltbams-0.9.11/tests/test_io.py +32 -0
- ltbams-0.9.11/tests/test_jumper.py +27 -0
- ltbams-0.9.9/tests/test_mats.py → ltbams-0.9.11/tests/test_matp.py +4 -0
- {ltbams-0.9.9 → ltbams-0.9.11}/tests/test_routine.py +3 -85
- ltbams-0.9.11/tests/test_rtn_dcopf.py +77 -0
- ltbams-0.9.11/tests/test_rtn_ed.py +184 -0
- ltbams-0.9.11/tests/test_rtn_pflow.py +219 -0
- ltbams-0.9.11/tests/test_rtn_rted.py +176 -0
- ltbams-0.9.11/tests/test_rtn_uc.py +165 -0
- ltbams-0.9.9/PKG-INFO +0 -859
- ltbams-0.9.9/ams/__init__.py +0 -20
- ltbams-0.9.9/ltbams.egg-info/PKG-INFO +0 -859
- ltbams-0.9.9/ltbams.egg-info/SOURCES.txt +0 -36
- ltbams-0.9.9/ltbams.egg-info/entry_points.txt +0 -2
- ltbams-0.9.9/ltbams.egg-info/requires.txt +0 -31
- ltbams-0.9.9/ltbams.egg-info/top_level.txt +0 -1
- ltbams-0.9.9/setup.py +0 -8
- ltbams-0.9.9/tests/test_dctypes.py +0 -111
- {ltbams-0.9.9 → ltbams-0.9.11}/ams/__main__.py +0 -0
- {ltbams-0.9.9 → ltbams-0.9.11}/ltbams.egg-info/dependency_links.txt +0 -0
- {ltbams-0.9.9 → ltbams-0.9.11}/setup.cfg +0 -0
- {ltbams-0.9.9 → ltbams-0.9.11}/tests/test_1st_system.py +0 -0
- {ltbams-0.9.9 → ltbams-0.9.11}/tests/test_addressing.py +1 -1
- {ltbams-0.9.9 → ltbams-0.9.11}/tests/test_cli.py +0 -0
- {ltbams-0.9.9 → ltbams-0.9.11}/tests/test_export_csv.py +0 -0
- {ltbams-0.9.9 → ltbams-0.9.11}/tests/test_group.py +0 -0
- {ltbams-0.9.9 → ltbams-0.9.11}/tests/test_known_good.py +0 -0
- {ltbams-0.9.9 → ltbams-0.9.11}/tests/test_model.py +0 -0
- {ltbams-0.9.9 → ltbams-0.9.11}/tests/test_paths.py +0 -0
- {ltbams-0.9.9 → ltbams-0.9.11}/tests/test_report.py +0 -0
- {ltbams-0.9.9 → ltbams-0.9.11}/tests/test_repr.py +0 -0
- {ltbams-0.9.9 → ltbams-0.9.11}/tests/test_service.py +0 -0
- {ltbams-0.9.9 → ltbams-0.9.11}/versioneer.py +0 -0
@@ -0,0 +1,102 @@
|
|
1
|
+
============
|
2
|
+
Contributing
|
3
|
+
============
|
4
|
+
|
5
|
+
Contributions are welcome, and they are greatly appreciated! Every
|
6
|
+
little bit helps, and credit will always be given.
|
7
|
+
|
8
|
+
You can contribute in many ways:
|
9
|
+
|
10
|
+
Types of Contributions
|
11
|
+
----------------------
|
12
|
+
|
13
|
+
Report Bugs
|
14
|
+
~~~~~~~~~~~
|
15
|
+
|
16
|
+
Report bugs at https://github.com/CURENT/ams/issues.
|
17
|
+
|
18
|
+
If you are reporting a bug, please include:
|
19
|
+
|
20
|
+
* Any details about your local setup that might be helpful in troubleshooting.
|
21
|
+
* Detailed steps to reproduce the bug.
|
22
|
+
|
23
|
+
Fix Bugs
|
24
|
+
~~~~~~~~
|
25
|
+
|
26
|
+
Look through the GitHub issues for bugs. Anything tagged with "bug"
|
27
|
+
is open to whoever wants to implement it.
|
28
|
+
|
29
|
+
Implement Features
|
30
|
+
~~~~~~~~~~~~~~~~~~
|
31
|
+
|
32
|
+
Look through the GitHub issues for features. Anything tagged with "feature"
|
33
|
+
is open to whoever wants to implement it.
|
34
|
+
|
35
|
+
Write Documentation
|
36
|
+
~~~~~~~~~~~~~~~~~~~
|
37
|
+
|
38
|
+
AMS could always use more documentation, whether
|
39
|
+
as part of the official AMS docs, in docstrings,
|
40
|
+
or even on the web in blog posts, articles, and such.
|
41
|
+
|
42
|
+
Submit Feedback
|
43
|
+
~~~~~~~~~~~~~~~
|
44
|
+
|
45
|
+
The best way to send feedback is to file an issue at https://github.com/CURENT/ams/issues.
|
46
|
+
|
47
|
+
If you are proposing a feature:
|
48
|
+
|
49
|
+
* Explain in detail how it would work.
|
50
|
+
* Keep the scope as narrow as possible, to make it easier to implement.
|
51
|
+
* Remember that this is a volunteer-driven project, and that contributions
|
52
|
+
are welcome :)
|
53
|
+
|
54
|
+
Get Started!
|
55
|
+
------------
|
56
|
+
|
57
|
+
Ready to contribute? Here's how to set up `ams` for local development.
|
58
|
+
|
59
|
+
1. Fork the `ams` repo on GitHub.
|
60
|
+
2. Clone your fork locally::
|
61
|
+
|
62
|
+
$ git clone git@github.com:your_name_here/ams.git
|
63
|
+
|
64
|
+
3. Install your local copy into a virtualenv. Assuming you have virtualenv wrapper installed, this is how you
|
65
|
+
set up your fork for local development::
|
66
|
+
|
67
|
+
$ mkvirtualenv ams
|
68
|
+
$ cd ams/
|
69
|
+
$ pip install -e .[dev]
|
70
|
+
|
71
|
+
4. Create a branch for local development::
|
72
|
+
|
73
|
+
$ git checkout -b name-of-your-bugfix-or-feature
|
74
|
+
|
75
|
+
Now you can make your changes locally.
|
76
|
+
|
77
|
+
5. When you're done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox::
|
78
|
+
|
79
|
+
$ flake8 ams tests
|
80
|
+
$ ams selftest
|
81
|
+
|
82
|
+
|
83
|
+
6. Commit your changes and push your branch to GitHub::
|
84
|
+
|
85
|
+
$ git add .
|
86
|
+
$ git commit -m "Your detailed description of your changes."
|
87
|
+
$ git push origin name-of-your-bugfix-or-feature
|
88
|
+
|
89
|
+
7. Submit a pull request through the GitHub website.
|
90
|
+
|
91
|
+
Pull Request Guidelines
|
92
|
+
-----------------------
|
93
|
+
|
94
|
+
Before you submit a pull request, check that it meets these guidelines:
|
95
|
+
|
96
|
+
1. The pull request should include tests.
|
97
|
+
2. If the pull request adds functionality, the docs should be updated. Put
|
98
|
+
your new functionality into a function with a docstring, and add the
|
99
|
+
feature to the list in README.rst.
|
100
|
+
3. The pull request should work for Python 3.9 and up. Check
|
101
|
+
https://github.com/CURENT/ams/actions
|
102
|
+
and make sure that the tests pass for all supported Python versions.
|
@@ -670,7 +670,7 @@ Also add information on how to contact you by electronic and paper mail.
|
|
670
670
|
If the program does terminal interaction, make it output a short
|
671
671
|
notice like this when it starts in an interactive mode:
|
672
672
|
|
673
|
-
AMS Copyright (C) 2023 Jinning Wang
|
673
|
+
AMS Copyright (C) 2023 - 2024 Jinning Wang
|
674
674
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
675
675
|
This is free software, and you are welcome to redistribute it
|
676
676
|
under certain conditions; type `show c' for details.
|
@@ -0,0 +1,17 @@
|
|
1
|
+
include CONTRIBUTING.rst
|
2
|
+
include LICENSE
|
3
|
+
include README.md
|
4
|
+
include requirements.txt
|
5
|
+
include requirements-extra.txt
|
6
|
+
|
7
|
+
recursive-exclude * __pycache__
|
8
|
+
recursive-exclude * *.py[co]
|
9
|
+
|
10
|
+
recursive-include ams/cases *.xlsx *.m *.raw *.dyr *.py *.json
|
11
|
+
recursive-include docs *.rst *.png conf.py Makefile make.bat
|
12
|
+
|
13
|
+
include versioneer.py
|
14
|
+
include ams/_version.py
|
15
|
+
|
16
|
+
# If including data files in the package, add them like:
|
17
|
+
# include path/to/data_file
|
ltbams-0.9.11/PKG-INFO
ADDED
@@ -4,11 +4,10 @@ Python Software for Power System Scheduling Modeling and Co-Simulation with Dyna
|
|
4
4
|
|
5
5
|
[](https://github.com/CURENT/ams/blob/master/LICENSE)
|
6
6
|

|
7
|
-
[](https://www.python.org/)
|
7
|
+
[](https://www.python.org/)
|
8
8
|

|
9
9
|
[](https://github.com/CURENT/ams/commits/master/)
|
10
10
|
[](https://github.com/CURENT/ams/commits/develop/)
|
11
|
-
[](https://hits.dwyl.com/CURENT/ams)
|
12
11
|
[](https://libraries.io/pypi/ltbams)
|
13
12
|
[](https://mango-dune-07a8b7110.1.azurestaticapps.net/?repo=CURENT%2Fams)
|
14
13
|
|
@@ -60,8 +59,9 @@ Use the following resources to get involved.
|
|
60
59
|
# Installation
|
61
60
|
|
62
61
|
***NOTE:***
|
63
|
-
-
|
64
|
-
- `
|
62
|
+
- Version **0.9.9** has known issues. Please avoid using this version
|
63
|
+
- `kvxopt` is recommended to install via `conda` as sometimes ``pip`` struggles to set the correct path for compiled libraries
|
64
|
+
- `cvxpy` versions **below 1.5** are incompatible with `numpy` versions **2.0 and above**
|
65
65
|
|
66
66
|
AMS is released as ``ltbams`` on PyPI and conda-forge.
|
67
67
|
Install from PyPI using pip:
|
@@ -82,6 +82,19 @@ Install from GitHub source:
|
|
82
82
|
pip install git+https://github.com/CURENT/ams.git
|
83
83
|
```
|
84
84
|
|
85
|
+
# Example Usage
|
86
|
+
|
87
|
+
Using AMS to run a Real-Time Economic Dispatch (RTED) simulation:
|
88
|
+
|
89
|
+
```python
|
90
|
+
import ams
|
91
|
+
|
92
|
+
ss = ams.load(ams.get_case('ieee14_uced.xlsx'))
|
93
|
+
ss.RTED.run()
|
94
|
+
|
95
|
+
print(ss.RTED.pg.v)
|
96
|
+
```
|
97
|
+
|
85
98
|
# Sponsors and Contributors
|
86
99
|
AMS is the scheduling simulation engine for the CURENT Largescale Testbed (LTB).
|
87
100
|
More information about CURENT LTB can be found at the [LTB Repository][LTB Repository].
|
@@ -0,0 +1,13 @@
|
|
1
|
+
from . import _version
|
2
|
+
__version__ = _version.get_versions()['version']
|
3
|
+
|
4
|
+
from ams import benchmarks # NOQA
|
5
|
+
|
6
|
+
from ams.main import config_logger, load, run # NOQA
|
7
|
+
from ams.system import System # NOQA
|
8
|
+
from ams.utils.paths import get_case, list_cases # NOQA
|
9
|
+
from ams.shared import ppc2df # NOQA
|
10
|
+
|
11
|
+
__author__ = 'Jining Wang'
|
12
|
+
|
13
|
+
__all__ = ['System', 'get_case', 'System']
|
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
# This file was generated by 'versioneer.py' (0.
|
2
|
+
# This file was generated by 'versioneer.py' (0.22) 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": "2024-
|
11
|
+
"date": "2024-11-14T16:34:57-0500",
|
12
12
|
"dirty": false,
|
13
13
|
"error": null,
|
14
|
-
"full-revisionid": "
|
15
|
-
"version": "0.9.
|
14
|
+
"full-revisionid": "9dcd290dc6532149fcd0b4f26fb5e9af4bf4bf36",
|
15
|
+
"version": "0.9.11"
|
16
16
|
}
|
17
17
|
''' # END VERSION_JSON
|
18
18
|
|
@@ -0,0 +1,302 @@
|
|
1
|
+
"""
|
2
|
+
Benchmark functions.
|
3
|
+
"""
|
4
|
+
|
5
|
+
import datetime
|
6
|
+
import sys
|
7
|
+
import importlib.metadata as importlib_metadata
|
8
|
+
import logging
|
9
|
+
|
10
|
+
try:
|
11
|
+
import pandapower as pdp
|
12
|
+
PANDAPOWER_AVAILABLE = True
|
13
|
+
except ImportError:
|
14
|
+
PANDAPOWER_AVAILABLE = False
|
15
|
+
logging.warning("pandapower is not available. Some functionalities will be disabled.")
|
16
|
+
|
17
|
+
from andes.utils.misc import elapsed
|
18
|
+
|
19
|
+
import ams
|
20
|
+
|
21
|
+
logger = logging.getLogger(__name__)
|
22
|
+
|
23
|
+
_failed_time = -1
|
24
|
+
_failed_obj = -1
|
25
|
+
|
26
|
+
cols_pre = ['ams_mats', 'ams_parse', 'ams_eval', 'ams_final', 'ams_postinit']
|
27
|
+
|
28
|
+
|
29
|
+
def get_tool_versions(tools=None):
|
30
|
+
"""
|
31
|
+
Get the current time, Python version, and versions of specified tools.
|
32
|
+
|
33
|
+
Parameters
|
34
|
+
----------
|
35
|
+
tools : list of str, optional
|
36
|
+
List of tool names to check versions. If None, a default list of tools is used.
|
37
|
+
|
38
|
+
Returns
|
39
|
+
-------
|
40
|
+
dict
|
41
|
+
A dictionary containing the tool names and their versions.
|
42
|
+
"""
|
43
|
+
if tools is None:
|
44
|
+
tools = ['ltbams', 'andes', 'cvxpy',
|
45
|
+
'gurobipy', 'mosek', 'piqp',
|
46
|
+
'pandapower', 'numba']
|
47
|
+
|
48
|
+
# Get current time and Python version
|
49
|
+
last_run_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
50
|
+
python_version = sys.version
|
51
|
+
|
52
|
+
# Collect tool versions
|
53
|
+
tool_versions = {}
|
54
|
+
for tool in tools:
|
55
|
+
try:
|
56
|
+
version = importlib_metadata.version(tool)
|
57
|
+
tool_versions[tool] = version
|
58
|
+
except importlib_metadata.PackageNotFoundError:
|
59
|
+
logger.error(f"Package {tool} not found.")
|
60
|
+
tool_versions[tool] = "Not installed"
|
61
|
+
|
62
|
+
# Print the results in a formatted way
|
63
|
+
logger.warning(f"Last run time: {last_run_time}")
|
64
|
+
logger.warning(f"Python: {python_version}\n")
|
65
|
+
|
66
|
+
# Calculate the width of the columns
|
67
|
+
max_tool_length = max(len(tool) for tool in tool_versions)
|
68
|
+
max_version_length = max(len(version) for version in tool_versions.values())
|
69
|
+
|
70
|
+
# Print the header
|
71
|
+
logger.warning(f"{'Tool':<{max_tool_length}} {'Version':<{max_version_length}}")
|
72
|
+
logger.warning(f"{'-' * max_tool_length} {'-' * max_version_length}")
|
73
|
+
|
74
|
+
# Print each tool and its version
|
75
|
+
for tool, version in tool_versions.items():
|
76
|
+
logger.warning(f"{tool:<{max_tool_length}} {version:<{max_version_length}}")
|
77
|
+
|
78
|
+
return tool_versions
|
79
|
+
|
80
|
+
|
81
|
+
def time_routine_solve(system, routine='DCOPF', **kwargs):
|
82
|
+
"""
|
83
|
+
Run the specified routine with the given solver and method.
|
84
|
+
|
85
|
+
Parameters
|
86
|
+
----------
|
87
|
+
system : ams.System
|
88
|
+
The system object containing the routine.
|
89
|
+
routine : str, optional
|
90
|
+
The name of the routine to run. Defaults to 'DCOPF'.
|
91
|
+
|
92
|
+
Other Parameters
|
93
|
+
----------------
|
94
|
+
solver : str, optional
|
95
|
+
The solver to use.
|
96
|
+
ignore_dpp : bool, optional
|
97
|
+
Whether to ignore DPP. Defaults to True.
|
98
|
+
|
99
|
+
Returns
|
100
|
+
-------
|
101
|
+
tuple
|
102
|
+
A tuple containing the elapsed time (s) and the objective value ($).
|
103
|
+
"""
|
104
|
+
rtn = system.routines[routine]
|
105
|
+
solver = kwargs.get('solver', None)
|
106
|
+
try:
|
107
|
+
t, _ = elapsed()
|
108
|
+
rtn.run(**kwargs)
|
109
|
+
_, s0 = elapsed(t)
|
110
|
+
elapsed_time = float(s0.split(' ')[0])
|
111
|
+
obj_value = rtn.obj.v
|
112
|
+
except Exception as e:
|
113
|
+
logger.error(f"Error running routine {routine} with solver {solver}: {e}")
|
114
|
+
elapsed_time = _failed_time
|
115
|
+
obj_value = _failed_obj
|
116
|
+
return elapsed_time, obj_value
|
117
|
+
|
118
|
+
|
119
|
+
def pre_solve(system, routine):
|
120
|
+
"""
|
121
|
+
Time the routine preparation process.
|
122
|
+
|
123
|
+
Parameters
|
124
|
+
----------
|
125
|
+
system : ams.System
|
126
|
+
The system object containing the routine.
|
127
|
+
routine : str
|
128
|
+
The name of the routine to prepare
|
129
|
+
|
130
|
+
Returns
|
131
|
+
-------
|
132
|
+
dict
|
133
|
+
A dictionary containing the preparation times in seconds for each step:
|
134
|
+
'mats', 'parse', 'evaluate', 'finalize', 'postinit'.
|
135
|
+
"""
|
136
|
+
rtn = system.routines[routine]
|
137
|
+
|
138
|
+
# Initialize AMS
|
139
|
+
# --- matrices build ---
|
140
|
+
t_mats, _ = elapsed()
|
141
|
+
system.mats.build(force=True)
|
142
|
+
_, s_mats = elapsed(t_mats)
|
143
|
+
|
144
|
+
# --- code generation ---
|
145
|
+
t_parse, _ = elapsed()
|
146
|
+
rtn.om.parse(force=True)
|
147
|
+
_, s_parse = elapsed(t_parse)
|
148
|
+
|
149
|
+
# --- code evaluation ---
|
150
|
+
t_evaluate, _ = elapsed()
|
151
|
+
rtn.om.evaluate(force=True)
|
152
|
+
_, s_evaluate = elapsed(t_evaluate)
|
153
|
+
|
154
|
+
# --- problem finalization ---
|
155
|
+
t_finalize, _ = elapsed()
|
156
|
+
rtn.om.finalize(force=True)
|
157
|
+
_, s_finalize = elapsed(t_finalize)
|
158
|
+
|
159
|
+
# --- rest init process ---
|
160
|
+
t_postinit, _ = elapsed()
|
161
|
+
rtn.init()
|
162
|
+
_, s_postinit = elapsed(t_postinit)
|
163
|
+
|
164
|
+
s_float = [float(s.split(' ')[0]) for s in [s_mats, s_parse, s_evaluate, s_finalize, s_postinit]]
|
165
|
+
|
166
|
+
pre_time = dict(zip(cols_pre, s_float))
|
167
|
+
return pre_time
|
168
|
+
|
169
|
+
|
170
|
+
def time_pdp_dcopf(ppn):
|
171
|
+
"""
|
172
|
+
Test the execution time of DCOPF using pandapower.
|
173
|
+
|
174
|
+
Parameters
|
175
|
+
----------
|
176
|
+
ppn : pandapowerNet
|
177
|
+
The pandapower network object.
|
178
|
+
|
179
|
+
Returns
|
180
|
+
-------
|
181
|
+
tuple
|
182
|
+
A tuple containing the elapsed time (s) and the objective value ($).
|
183
|
+
"""
|
184
|
+
try:
|
185
|
+
t_pdp, _ = elapsed()
|
186
|
+
pdp.rundcopp(ppn)
|
187
|
+
_, s_pdp = elapsed(t_pdp)
|
188
|
+
elapsed_time = float(s_pdp.split(' ')[0])
|
189
|
+
obj_value = ppn.res_cost
|
190
|
+
except Exception as e:
|
191
|
+
logger.error(f"Error running pandapower: {e}")
|
192
|
+
elapsed_time = _failed_time
|
193
|
+
obj_value = _failed_obj
|
194
|
+
return elapsed_time, obj_value
|
195
|
+
|
196
|
+
|
197
|
+
def time_routine(system, routine='DCOPF', solvers=['CLARABEL'],
|
198
|
+
**kwargs):
|
199
|
+
"""
|
200
|
+
Time the specified routine with the given solvers.
|
201
|
+
|
202
|
+
Parameters
|
203
|
+
----------
|
204
|
+
system : ams.System
|
205
|
+
The system object containing the routine.
|
206
|
+
routine : str, optional
|
207
|
+
The name of the routine to run. Defaults to 'DCOPF'.
|
208
|
+
solvers : list of str, optional
|
209
|
+
List of solvers to use. Defaults to ['CLARABEL'].
|
210
|
+
|
211
|
+
Other Parameters
|
212
|
+
----------------
|
213
|
+
ignore_dpp : bool, optional
|
214
|
+
Whether to ignore DPP. Defaults to True.
|
215
|
+
|
216
|
+
Returns
|
217
|
+
-------
|
218
|
+
tuple
|
219
|
+
A tuple containing the preparation times and the solution times in
|
220
|
+
seconds for each solver.
|
221
|
+
"""
|
222
|
+
pre_time = pre_solve(system, routine)
|
223
|
+
sol = {f'{solver}': {'time': 0, 'obj': 0} for solver in solvers}
|
224
|
+
|
225
|
+
for solver in solvers:
|
226
|
+
if solver != 'pandapower':
|
227
|
+
s, obj = time_routine_solve(system, routine, solver=solver, **kwargs)
|
228
|
+
sol[solver]['time'] = s
|
229
|
+
sol[solver]['obj'] = obj
|
230
|
+
elif solver == 'pandapower' and PANDAPOWER_AVAILABLE and routine == 'DCOPF':
|
231
|
+
ppc = ams.io.pypower.system2ppc(system)
|
232
|
+
ppn = pdp.converter.from_ppc(ppc, f_hz=system.config.freq)
|
233
|
+
s, obj = time_pdp_dcopf(ppn)
|
234
|
+
sol[solver]['time'] = s
|
235
|
+
sol[solver]['obj'] = obj
|
236
|
+
else:
|
237
|
+
sol[solver]['time'] = _failed_time
|
238
|
+
sol[solver]['obj'] = _failed_obj
|
239
|
+
|
240
|
+
return pre_time, sol
|
241
|
+
|
242
|
+
|
243
|
+
def time_dcopf_with_lf(system, solvers=['CLARABEL'], load_factors=[1], ignore_dpp=False):
|
244
|
+
"""
|
245
|
+
Time the execution of DCOPF with varying load factors.
|
246
|
+
|
247
|
+
Parameters
|
248
|
+
----------
|
249
|
+
system : ams.System
|
250
|
+
The system object containing the routine.
|
251
|
+
solvers : list of str, optional
|
252
|
+
List of solvers to use. Defaults to ['CLARABEL'].
|
253
|
+
load_factors : list of float, optional
|
254
|
+
List of load factors to apply. Defaults to None.
|
255
|
+
ignore_dpp : bool, optional
|
256
|
+
Whether to ignore DPP.
|
257
|
+
|
258
|
+
Returns
|
259
|
+
-------
|
260
|
+
tuple
|
261
|
+
A tuple containing the list of times and the list of objective values.
|
262
|
+
"""
|
263
|
+
pre_time = pre_solve(system, 'DCOPF')
|
264
|
+
sol = {f'{solver}': {'time': 0, 'obj': 0} for solver in solvers}
|
265
|
+
|
266
|
+
pd0 = system.PQ.p0.v.copy()
|
267
|
+
pq_idx = system.PQ.idx.v
|
268
|
+
|
269
|
+
for solver in solvers:
|
270
|
+
if solver != 'pandapower':
|
271
|
+
obj_all = 0
|
272
|
+
t_all, _ = elapsed()
|
273
|
+
for lf_k in load_factors:
|
274
|
+
system.PQ.set(src='p0', attr='v', idx=pq_idx, value=lf_k * pd0)
|
275
|
+
system.DCOPF.update(params=['pd'])
|
276
|
+
_, obj = time_routine_solve(system, 'DCOPF',
|
277
|
+
solver=solver, ignore_dpp=ignore_dpp)
|
278
|
+
obj_all += obj
|
279
|
+
_, s_all = elapsed(t_all)
|
280
|
+
system.PQ.set(src='p0', attr='v', idx=pq_idx, value=pd0)
|
281
|
+
s = float(s_all.split(' ')[0])
|
282
|
+
sol[solver]['time'] = s
|
283
|
+
sol[solver]['obj'] = obj_all
|
284
|
+
elif solver == 'pandapower' and PANDAPOWER_AVAILABLE:
|
285
|
+
ppc = ams.io.pypower.system2ppc(system)
|
286
|
+
ppn = pdp.converter.from_ppc(ppc, f_hz=system.config.freq)
|
287
|
+
p_mw0 = ppn.load['p_mw'].copy()
|
288
|
+
t_all, _ = elapsed()
|
289
|
+
obj_all = 0
|
290
|
+
for lf_k in load_factors:
|
291
|
+
ppn.load['p_mw'] = lf_k * p_mw0
|
292
|
+
_, obj = time_pdp_dcopf(ppn)
|
293
|
+
obj_all += obj
|
294
|
+
_, s_all = elapsed(t_all)
|
295
|
+
s = float(s_all.split(' ')[0])
|
296
|
+
sol[solver]['time'] = s
|
297
|
+
sol[solver]['obj'] = obj_all
|
298
|
+
else:
|
299
|
+
sol[solver]['time'] = _failed_time
|
300
|
+
sol[solver]['obj'] = _failed_obj
|
301
|
+
|
302
|
+
return pre_time, sol
|
Binary file
|
Binary file
|