mirror of
https://github.com/ANL-CEEESA/UnitCommitment.jl.git
synced 2025-12-06 08:18:51 -06:00
Compare commits
98 Commits
update-dep
...
feature/mi
| Author | SHA1 | Date | |
|---|---|---|---|
|
b0b6b9b2dc
|
|||
|
58cc33ac69
|
|||
|
b555f9885a
|
|||
|
b39b14afa4
|
|||
|
d49712f41b
|
|||
|
beaf0b785f
|
|||
| 9853b15f1c | |||
| 81d4ff5b9d | |||
|
|
ad50cdd935 | ||
|
|
8f0661c93f | ||
|
|
ca092a67ce | ||
|
|
82cefe2652 | ||
|
|
cd96b28076 | ||
|
|
3086e71611 | ||
|
|
0bb175078b | ||
|
|
2fb89045cd | ||
|
|
f31921fc4f | ||
|
|
6ea769a68c | ||
|
|
2d510ca7ea | ||
|
|
d602b686bc | ||
|
|
53052ec895 | ||
|
|
f59914f265 | ||
|
|
7201acde78 | ||
| 7a96f8cc1e | |||
|
b8ada6432a
|
|||
|
03bf1c4c04
|
|||
|
3961aedaf5
|
|||
|
|
9dc3607c56 | ||
|
|
ec2d56602b | ||
|
40270b0030
|
|||
|
|
7c41a9761c | ||
|
|
6f9420874d | ||
|
|
eff5908b13 | ||
|
|
adcaf6fc55 | ||
|
|
46259f7c1c | ||
|
|
e8d8272510
|
||
|
6db2ca76e8
|
|||
|
4adb3344ac
|
|||
|
|
316d0bdf5a | ||
|
|
33f8ec26d5 | ||
|
|
41790db448 | ||
|
|
baf529a15d | ||
|
|
b71a1c3d5f | ||
|
|
bea42d174c | ||
|
|
896ef0f3e3 | ||
|
|
cb7f9e3b27 | ||
| 319a787904 | |||
|
b1c963f217
|
|||
|
19534a128f
|
|||
|
|
51f6aa9a80 | ||
|
|
f2c0388cac | ||
|
|
3564358a63 | ||
|
|
b2ed0f67c1 | ||
|
|
2a6c206e08 | ||
|
|
30a4284119 | ||
|
|
71ed55cb40 | ||
|
|
0b95df25ec | ||
|
|
5f5c8b66eb | ||
| 52f1ff9a27 | |||
|
414128cc0b
|
|||
|
20939dc4b7
|
|||
|
d8741f04a0
|
|||
|
3b6d810884
|
|||
|
204c5d900f
|
|||
|
cb9334c0a3
|
|||
|
31e0613134
|
|||
|
4827c29230
|
|||
|
19e84bac07
|
|||
|
d7d2a3fcf6
|
|||
|
784ebfa199
|
|||
|
d2e11eee42
|
|||
|
34ca6952fb
|
|||
|
|
bc3aee38f8 | ||
|
|
415732f0ec | ||
|
|
5c91dc2ac9 | ||
|
|
ad4a754d63 | ||
|
|
481f5a904c | ||
|
|
7e8a2ee026 | ||
|
|
c95b01dadf | ||
|
|
8fc84412eb | ||
| 6573bb7ea2 | |||
| 1769f2a932 | |||
| 4dc39363e8 | |||
| 5fef01cd99 | |||
| 18daaf5358 | |||
| b68b4ff9e4 | |||
| 6e30645084 | |||
| 678e6aa2f5 | |||
| fd25580967 | |||
| dc693896a3 | |||
| ddebcc6ddb | |||
| 3282e5bc3a | |||
| 15de1901c8 | |||
| bf2dc4ddc4 | |||
| 5ca566f147 | |||
| 3220650e39 | |||
| ca0d250dfa | |||
| 2bd68b49a5 |
33
.github/workflows/test.yml
vendored
33
.github/workflows/test.yml
vendored
@@ -1,4 +1,4 @@
|
|||||||
name: Tests
|
name: Build & Test
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
pull_request:
|
pull_request:
|
||||||
@@ -6,19 +6,30 @@ on:
|
|||||||
- cron: '45 10 * * *'
|
- cron: '45 10 * * *'
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
|
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
julia-version: ['1.6', '1.7']
|
version: ['1.6', '1.7', '1.8', '1.9']
|
||||||
julia-arch: [x64]
|
os:
|
||||||
os: [ubuntu-latest, windows-latest, macOS-latest]
|
- ubuntu-latest
|
||||||
exclude:
|
arch:
|
||||||
- os: macOS-latest
|
- x64
|
||||||
julia-arch: x86
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: julia-actions/setup-julia@latest
|
- uses: julia-actions/setup-julia@v1
|
||||||
with:
|
with:
|
||||||
version: ${{ matrix.julia-version }}
|
version: ${{ matrix.version }}
|
||||||
- uses: julia-actions/julia-buildpkg@latest
|
arch: ${{ matrix.arch }}
|
||||||
- uses: julia-actions/julia-runtest@latest
|
- name: Run tests
|
||||||
|
shell: julia --color=yes --project=test {0}
|
||||||
|
run: |
|
||||||
|
using Pkg
|
||||||
|
Pkg.develop(path=".")
|
||||||
|
Pkg.update()
|
||||||
|
using UnitCommitmentT
|
||||||
|
try
|
||||||
|
runtests()
|
||||||
|
catch
|
||||||
|
exit(1)
|
||||||
|
end
|
||||||
27
.zenodo.json
Normal file
27
.zenodo.json
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"creators": [
|
||||||
|
{
|
||||||
|
"orcid": "0000-0002-5022-9802",
|
||||||
|
"affiliation": "Argonne National Laboratory",
|
||||||
|
"name": "Santos Xavier, Alinson"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"affiliation": "University of Florida",
|
||||||
|
"name": "Kazachkov, Aleksandr M."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"affiliation": "Technische Universität Berlin",
|
||||||
|
"name": "Yurdakul, Ogün"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"affiliation": "Purdue University",
|
||||||
|
"name": "He, Jun"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"affiliation": "Argonne National Laboratory",
|
||||||
|
"name": "Qiu, Feng"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"title": "UnitCommitment.jl: A Julia/JuMP Optimization Package for Security-Constrained Unit Commitment",
|
||||||
|
"description": "<b>UnitCommitment.jl</b> (UC.jl) is an optimization package for the Security-Constrained Unit Commitment Problem (SCUC), a fundamental optimization problem in power systems used, for example, to clear the day-ahead electricity markets. The package provides benchmark instances for the problem and Julia/JuMP implementations of state-of-the-art mixed-integer programming formulations."
|
||||||
|
}
|
||||||
15
CHANGELOG.md
15
CHANGELOG.md
@@ -11,6 +11,21 @@ All notable changes to this project will be documented in this file.
|
|||||||
[semver]: https://semver.org/spec/v2.0.0.html
|
[semver]: https://semver.org/spec/v2.0.0.html
|
||||||
[pkjjl]: https://pkgdocs.julialang.org/v1/compatibility/#compat-pre-1.0
|
[pkjjl]: https://pkgdocs.julialang.org/v1/compatibility/#compat-pre-1.0
|
||||||
|
|
||||||
|
## [0.3.0] - 2022-07-18
|
||||||
|
### Added
|
||||||
|
- Add support for multiple reserve products and zonal reserves.
|
||||||
|
- Add flexiramp reserve products, following WanHob2016's formulation (@oyurdakul, #21).
|
||||||
|
- Add 365 variations for each MATPOWER instance, corresponding to each day of the year.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- To support multiple/zonal reserves, the input data format has been modified as follows:
|
||||||
|
- In `Generators`, replace `Provides spinning reserves?` by `Reserve eligibility`
|
||||||
|
- In `Parameters`, remove `Reserve shortfall penalty`
|
||||||
|
- Revise `Reserves` section
|
||||||
|
- To allow new versions of UnitCommitment.jl to read old instance files, a new required field `Version` has been added to the `Parameters` section. To load v0.2 files in v0.3, please add `{"Parameters":{"Version":"0.2"}}` to the file.
|
||||||
|
- Benchmark test cases are now downloaded on-the-fly as needed, instead of being stored in our GitHub repository. Test cases can also be directly downloaded from: https://axavier.org/UnitCommitment.jl/
|
||||||
|
|
||||||
|
|
||||||
## [0.2.2] - 2021-07-21
|
## [0.2.2] - 2021-07-21
|
||||||
### Fixed
|
### Fixed
|
||||||
- Fix small bug in validation scripts related to startup costs
|
- Fix small bug in validation scripts related to startup costs
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
Copyright © 2020, UChicago Argonne, LLC
|
Copyright © 2020-2022, UChicago Argonne, LLC
|
||||||
|
|
||||||
All Rights Reserved
|
All Rights Reserved
|
||||||
|
|
||||||
|
|||||||
20
Makefile
20
Makefile
@@ -2,22 +2,10 @@
|
|||||||
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
||||||
# Released under the modified BSD license. See COPYING.md for more details.
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
|
|
||||||
VERSION := 0.2
|
VERSION := 0.3
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -rfv build Manifest.toml test/Manifest.toml deps/formatter/build deps/formatter/Manifest.toml
|
|
||||||
|
|
||||||
docs:
|
docs:
|
||||||
cd docs; make clean; make dirhtml
|
cd docs; julia --project=. make.jl; cd ..
|
||||||
rsync -avP --delete-after docs/_build/dirhtml/ ../docs/$(VERSION)/
|
rsync -avP --delete-after docs/build/ ../docs/$(VERSION)/
|
||||||
|
|
||||||
format:
|
.PHONY: docs
|
||||||
cd deps/formatter; ../../juliaw format.jl
|
|
||||||
|
|
||||||
test: test/Manifest.toml
|
|
||||||
./juliaw test/runtests.jl
|
|
||||||
|
|
||||||
test/Manifest.toml: test/Project.toml
|
|
||||||
julia --project=test -e "using Pkg; Pkg.instantiate()"
|
|
||||||
|
|
||||||
.PHONY: docs test format install-deps
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ name = "UnitCommitment"
|
|||||||
uuid = "64606440-39ea-11e9-0f29-3303a1d3d877"
|
uuid = "64606440-39ea-11e9-0f29-3303a1d3d877"
|
||||||
authors = ["Santos Xavier, Alinson <axavier@anl.gov>"]
|
authors = ["Santos Xavier, Alinson <axavier@anl.gov>"]
|
||||||
repo = "https://github.com/ANL-CEEESA/UnitCommitment.jl"
|
repo = "https://github.com/ANL-CEEESA/UnitCommitment.jl"
|
||||||
version = "0.2.2"
|
version = "0.3.0"
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
|
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
|
||||||
@@ -13,11 +13,15 @@ JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
|
|||||||
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
|
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
|
||||||
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
|
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
|
||||||
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
|
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
|
||||||
|
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
|
||||||
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
|
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
|
||||||
PackageCompiler = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d"
|
PackageCompiler = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d"
|
||||||
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
|
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
|
||||||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
|
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
|
||||||
|
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
|
||||||
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
|
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
|
||||||
|
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
|
||||||
|
TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f"
|
||||||
|
|
||||||
[compat]
|
[compat]
|
||||||
DataStructures = "0.18"
|
DataStructures = "0.18"
|
||||||
@@ -25,6 +29,8 @@ Distributions = "0.25"
|
|||||||
GZip = "0.5"
|
GZip = "0.5"
|
||||||
JSON = "0.21"
|
JSON = "0.21"
|
||||||
JuMP = "1"
|
JuMP = "1"
|
||||||
|
MPI = "0.20"
|
||||||
MathOptInterface = "1"
|
MathOptInterface = "1"
|
||||||
PackageCompiler = "1"
|
PackageCompiler = "1"
|
||||||
|
TimerOutputs = "0.5"
|
||||||
julia = "1"
|
julia = "1"
|
||||||
|
|||||||
18
README.md
18
README.md
@@ -87,20 +87,22 @@ UnitCommitment.write("/tmp/output.json", solution)
|
|||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
1. [Usage](https://anl-ceeesa.github.io/UnitCommitment.jl/0.2/usage/)
|
1. [Usage](https://anl-ceeesa.github.io/UnitCommitment.jl/0.3/usage/)
|
||||||
2. [Data Format](https://anl-ceeesa.github.io/UnitCommitment.jl/0.2/format/)
|
2. [Data Format](https://anl-ceeesa.github.io/UnitCommitment.jl/0.3/format/)
|
||||||
3. [Instances](https://anl-ceeesa.github.io/UnitCommitment.jl/0.2/instances/)
|
3. [Instances](https://anl-ceeesa.github.io/UnitCommitment.jl/0.3/instances/)
|
||||||
4. [JuMP Model](https://anl-ceeesa.github.io/UnitCommitment.jl/0.2/model/)
|
4. [JuMP Model](https://anl-ceeesa.github.io/UnitCommitment.jl/0.3/model/)
|
||||||
|
5. [API Reference](https://anl-ceeesa.github.io/UnitCommitment.jl/0.3/api/)
|
||||||
|
|
||||||
## Authors
|
## Authors
|
||||||
* **Alinson S. Xavier** (Argonne National Laboratory)
|
* **Alinson S. Xavier** (Argonne National Laboratory)
|
||||||
* **Aleksandr M. Kazachkov** (University of Florida)
|
* **Aleksandr M. Kazachkov** (University of Florida)
|
||||||
* **Ogün Yurdakul** (Technische Universität Berlin)
|
* **Ogün Yurdakul** (Technische Universität Berlin)
|
||||||
|
* **Jun He** (Purdue University)
|
||||||
* **Feng Qiu** (Argonne National Laboratory)
|
* **Feng Qiu** (Argonne National Laboratory)
|
||||||
|
|
||||||
## Acknowledgments
|
## Acknowledgments
|
||||||
|
|
||||||
* We would like to **Yonghong Chen** (Midcontinent Independent System Operator), **Feng Pan** (Pacific Northwest National Laboratory) for valuable feedback on early versions of this package.
|
* We would like to thank **Yonghong Chen** (Midcontinent Independent System Operator), **Feng Pan** (Pacific Northwest National Laboratory) for valuable feedback on early versions of this package.
|
||||||
|
|
||||||
* Based upon work supported by **Laboratory Directed Research and Development** (LDRD) funding from Argonne National Laboratory, provided by the Director, Office of Science, of the U.S. Department of Energy under Contract No. DE-AC02-06CH11357
|
* Based upon work supported by **Laboratory Directed Research and Development** (LDRD) funding from Argonne National Laboratory, provided by the Director, Office of Science, of the U.S. Department of Energy under Contract No. DE-AC02-06CH11357
|
||||||
|
|
||||||
@@ -110,15 +112,15 @@ UnitCommitment.write("/tmp/output.json", solution)
|
|||||||
|
|
||||||
If you use UnitCommitment.jl in your research (instances, models or algorithms), we kindly request that you cite the package as follows:
|
If you use UnitCommitment.jl in your research (instances, models or algorithms), we kindly request that you cite the package as follows:
|
||||||
|
|
||||||
* **Alinson S. Xavier, Aleksandr M. Kazachkov, Feng Qiu**. "UnitCommitment.jl: A Julia/JuMP Optimization Package for Security-Constrained Unit Commitment". Zenodo (2020). [DOI: 10.5281/zenodo.4269874](https://doi.org/10.5281/zenodo.4269874).
|
* **Alinson S. Xavier, Aleksandr M. Kazachkov, Ogün Yurdakul, Feng Qiu**. "UnitCommitment.jl: A Julia/JuMP Optimization Package for Security-Constrained Unit Commitment (Version 0.3)". Zenodo (2022). [DOI: 10.5281/zenodo.4269874](https://doi.org/10.5281/zenodo.4269874).
|
||||||
|
|
||||||
If you use the instances, we additionally request that you cite the original sources, as described in the [instances page](docs/instances.md).
|
If you use the instances, we additionally request that you cite the original sources, as described in the documentation.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
```text
|
```text
|
||||||
UnitCommitment.jl: A Julia/JuMP Optimization Package for Security-Constrained Unit Commitment
|
UnitCommitment.jl: A Julia/JuMP Optimization Package for Security-Constrained Unit Commitment
|
||||||
Copyright © 2020-2021, UChicago Argonne, LLC. All Rights Reserved.
|
Copyright © 2020-2022, UChicago Argonne, LLC. All Rights Reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification, are permitted
|
Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
provided that the following conditions are met:
|
provided that the following conditions are met:
|
||||||
|
|||||||
5
deps/formatter/Project.toml
vendored
5
deps/formatter/Project.toml
vendored
@@ -1,5 +0,0 @@
|
|||||||
[deps]
|
|
||||||
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
|
|
||||||
|
|
||||||
[compat]
|
|
||||||
JuliaFormatter = "0.14.4"
|
|
||||||
9
deps/formatter/format.jl
vendored
9
deps/formatter/format.jl
vendored
@@ -1,9 +0,0 @@
|
|||||||
using JuliaFormatter
|
|
||||||
format(
|
|
||||||
[
|
|
||||||
"../../src",
|
|
||||||
"../../test",
|
|
||||||
"../../benchmark/run.jl",
|
|
||||||
],
|
|
||||||
verbose=true,
|
|
||||||
)
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
SPHINXOPTS ?=
|
|
||||||
SPHINXBUILD ?= sphinx-build
|
|
||||||
SOURCEDIR = .
|
|
||||||
BUILDDIR = _build
|
|
||||||
|
|
||||||
help:
|
|
||||||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
||||||
|
|
||||||
.PHONY: help Makefile
|
|
||||||
|
|
||||||
# Catch-all target: route all unknown targets to Sphinx using the new
|
|
||||||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
|
||||||
%: Makefile
|
|
||||||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
||||||
9
docs/Project.toml
Normal file
9
docs/Project.toml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
[deps]
|
||||||
|
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
|
||||||
|
Glob = "c27321d9-0574-5035-807b-f59d2c89b15c"
|
||||||
|
HiGHS = "87dc4568-4c63-4d18-b0c0-bb2238e4078b"
|
||||||
|
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
|
||||||
|
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
|
||||||
|
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
|
||||||
|
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
|
||||||
|
UnitCommitment = "64606440-39ea-11e9-0f29-3303a1d3d877"
|
||||||
49
docs/_static/custom.css
vendored
49
docs/_static/custom.css
vendored
@@ -1,49 +0,0 @@
|
|||||||
h1.site-logo {
|
|
||||||
font-size: 30px !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1.site-logo small {
|
|
||||||
font-size: 20px !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1.site-logo {
|
|
||||||
font-size: 30px !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1.site-logo small {
|
|
||||||
font-size: 20px !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
tbody, thead, pre {
|
|
||||||
border: 1px solid rgba(0, 0, 0, 0.25);
|
|
||||||
}
|
|
||||||
|
|
||||||
table td, th {
|
|
||||||
padding: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
table p {
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
table td code {
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
table tr,
|
|
||||||
table th {
|
|
||||||
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
table tr:last-child {
|
|
||||||
border-bottom: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
pre {
|
|
||||||
box-shadow: inherit !important;
|
|
||||||
background-color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.text-align\:center {
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
16
docs/conf.py
16
docs/conf.py
@@ -1,16 +0,0 @@
|
|||||||
project = "UnitCommitment.jl"
|
|
||||||
copyright = "2020-2021, UChicago Argonne, LLC"
|
|
||||||
author = ""
|
|
||||||
release = "0.2"
|
|
||||||
extensions = ["myst_parser"]
|
|
||||||
templates_path = ["_templates"]
|
|
||||||
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
|
|
||||||
html_theme = "sphinx_book_theme"
|
|
||||||
html_static_path = ["_static"]
|
|
||||||
html_css_files = ["custom.css"]
|
|
||||||
html_theme_options = {
|
|
||||||
"repository_url": "https://github.com/ANL-CEEESA/UnitCommitment.jl/",
|
|
||||||
"use_repository_button": True,
|
|
||||||
"extra_navbar": "",
|
|
||||||
}
|
|
||||||
html_title = f"UnitCommitment.jl<br/><small>{release}</small>"
|
|
||||||
1158
docs/example/out.json
Normal file
1158
docs/example/out.json
Normal file
File diff suppressed because it is too large
Load Diff
495
docs/example/s1.json
Normal file
495
docs/example/s1.json
Normal file
@@ -0,0 +1,495 @@
|
|||||||
|
{
|
||||||
|
"Parameters": {
|
||||||
|
"Version": "0.3",
|
||||||
|
"Time horizon (h)": 4
|
||||||
|
},
|
||||||
|
"Generators": {
|
||||||
|
"g1": {
|
||||||
|
"Bus": "b1",
|
||||||
|
"Production cost curve (MW)": [
|
||||||
|
100,
|
||||||
|
110,
|
||||||
|
130,
|
||||||
|
135
|
||||||
|
],
|
||||||
|
"Production cost curve ($)": [
|
||||||
|
1400,
|
||||||
|
1600,
|
||||||
|
2200,
|
||||||
|
2400
|
||||||
|
],
|
||||||
|
"Startup delays (h)": [
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
3
|
||||||
|
],
|
||||||
|
"Startup costs ($)": [
|
||||||
|
1000.0,
|
||||||
|
1500.0,
|
||||||
|
2000.0
|
||||||
|
],
|
||||||
|
"Initial status (h)": -100,
|
||||||
|
"Initial power (MW)": 0
|
||||||
|
},
|
||||||
|
"g2": {
|
||||||
|
"Bus": "b2",
|
||||||
|
"Production cost curve (MW)": [
|
||||||
|
0,
|
||||||
|
47,
|
||||||
|
94,
|
||||||
|
140
|
||||||
|
],
|
||||||
|
"Production cost curve ($)": [
|
||||||
|
0,
|
||||||
|
2256.00,
|
||||||
|
4733.37,
|
||||||
|
7395.39
|
||||||
|
],
|
||||||
|
"Startup delays (h)": [
|
||||||
|
1,
|
||||||
|
4
|
||||||
|
],
|
||||||
|
"Startup costs ($)": [
|
||||||
|
3000.0,
|
||||||
|
4000.0
|
||||||
|
],
|
||||||
|
"Ramp up limit (MW)": 98.0,
|
||||||
|
"Ramp down limit (MW)": 98.0,
|
||||||
|
"Startup limit (MW)": 98.0,
|
||||||
|
"Shutdown limit (MW)": 98.0,
|
||||||
|
"Minimum uptime (h)": 4,
|
||||||
|
"Minimum downtime (h)": 4,
|
||||||
|
"Maximum daily energy (MWh)": null,
|
||||||
|
"Maximum daily starts": null,
|
||||||
|
"Initial status (h)": -8,
|
||||||
|
"Initial power (MW)": 0,
|
||||||
|
"Reserve eligibility": [
|
||||||
|
"r1"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"g3": {
|
||||||
|
"Bus": "b3",
|
||||||
|
"Production cost curve (MW)": [
|
||||||
|
0,
|
||||||
|
33,
|
||||||
|
66,
|
||||||
|
100
|
||||||
|
],
|
||||||
|
"Production cost curve ($)": [
|
||||||
|
0,
|
||||||
|
1113.75,
|
||||||
|
2369.07,
|
||||||
|
3891.54
|
||||||
|
],
|
||||||
|
"Startup delays (h)": [
|
||||||
|
1,
|
||||||
|
4,
|
||||||
|
8
|
||||||
|
],
|
||||||
|
"Startup costs ($)": [
|
||||||
|
1000.0,
|
||||||
|
2000.0,
|
||||||
|
3000.0
|
||||||
|
],
|
||||||
|
"Ramp up limit (MW)": 70.0,
|
||||||
|
"Ramp down limit (MW)": 70.0,
|
||||||
|
"Startup limit (MW)": 70.0,
|
||||||
|
"Shutdown limit (MW)": 70.0,
|
||||||
|
"Must run?": true,
|
||||||
|
"Minimum uptime (h)": 1,
|
||||||
|
"Minimum downtime (h)": 1,
|
||||||
|
"Maximum daily energy (MWh)": null,
|
||||||
|
"Maximum daily starts": null,
|
||||||
|
"Initial status (h)": -6,
|
||||||
|
"Initial power (MW)": 0,
|
||||||
|
"Reserve eligibility": [
|
||||||
|
"r1"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"g4": {
|
||||||
|
"Bus": "b6",
|
||||||
|
"Production cost curve (MW)": [
|
||||||
|
33,
|
||||||
|
66,
|
||||||
|
100
|
||||||
|
],
|
||||||
|
"Production cost curve ($)": [
|
||||||
|
1113.75,
|
||||||
|
2369.07,
|
||||||
|
3891.54
|
||||||
|
],
|
||||||
|
"Initial status (h)": -100,
|
||||||
|
"Initial power (MW)": 0,
|
||||||
|
"Reserve eligibility": [
|
||||||
|
"r1"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"g5": {
|
||||||
|
"Bus": "b8",
|
||||||
|
"Production cost curve (MW)": [
|
||||||
|
33,
|
||||||
|
66,
|
||||||
|
100
|
||||||
|
],
|
||||||
|
"Production cost curve ($)": [
|
||||||
|
1113.75,
|
||||||
|
2369.07,
|
||||||
|
3891.54
|
||||||
|
],
|
||||||
|
"Initial status (h)": -100,
|
||||||
|
"Initial power (MW)": 0,
|
||||||
|
"Reserve eligibility": [
|
||||||
|
"r1"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"g6": {
|
||||||
|
"Bus": "b8",
|
||||||
|
"Production cost curve (MW)": [
|
||||||
|
100
|
||||||
|
],
|
||||||
|
"Production cost curve ($)": [
|
||||||
|
10000.00
|
||||||
|
],
|
||||||
|
"Initial status (h)": -100,
|
||||||
|
"Initial power (MW)": 0,
|
||||||
|
"Reserve eligibility": [
|
||||||
|
"r1"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Buses": {
|
||||||
|
"b1": {
|
||||||
|
"Load (MW)": 0.0
|
||||||
|
},
|
||||||
|
"b2": {
|
||||||
|
"Load (MW)": [
|
||||||
|
26.01527,
|
||||||
|
24.46212,
|
||||||
|
23.29725,
|
||||||
|
22.90897
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"b3": {
|
||||||
|
"Load (MW)": [
|
||||||
|
112.93263,
|
||||||
|
106.19039,
|
||||||
|
101.1337,
|
||||||
|
99.44814
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"b4": {
|
||||||
|
"Load (MW)": [
|
||||||
|
57.30552,
|
||||||
|
53.88429,
|
||||||
|
51.31838,
|
||||||
|
50.46307
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"b5": {
|
||||||
|
"Load (MW)": [
|
||||||
|
9.11134,
|
||||||
|
8.56738,
|
||||||
|
8.15941,
|
||||||
|
8.02342
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"b6": {
|
||||||
|
"Load (MW)": [
|
||||||
|
13.42723,
|
||||||
|
12.62561,
|
||||||
|
12.02439,
|
||||||
|
11.82398
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"b7": {
|
||||||
|
"Load (MW)": 0.0
|
||||||
|
},
|
||||||
|
"b8": {
|
||||||
|
"Load (MW)": 0.0
|
||||||
|
},
|
||||||
|
"b9": {
|
||||||
|
"Load (MW)": [
|
||||||
|
35.36638,
|
||||||
|
33.25495,
|
||||||
|
31.67138,
|
||||||
|
31.14353
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"b10": {
|
||||||
|
"Load (MW)": [
|
||||||
|
10.78974,
|
||||||
|
10.14558,
|
||||||
|
9.66246,
|
||||||
|
9.50141
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"b11": {
|
||||||
|
"Load (MW)": [
|
||||||
|
4.19601,
|
||||||
|
3.9455,
|
||||||
|
3.75762,
|
||||||
|
3.69499
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"b12": {
|
||||||
|
"Load (MW)": [
|
||||||
|
7.31305,
|
||||||
|
6.87645,
|
||||||
|
6.549,
|
||||||
|
6.43985
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"b13": {
|
||||||
|
"Load (MW)": [
|
||||||
|
16.18461,
|
||||||
|
15.21837,
|
||||||
|
14.49368,
|
||||||
|
14.25212
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"b14": {
|
||||||
|
"Load (MW)": [
|
||||||
|
17.86302,
|
||||||
|
16.79657,
|
||||||
|
15.99673,
|
||||||
|
15.73012
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Transmission lines": {
|
||||||
|
"l1": {
|
||||||
|
"Source bus": "b1",
|
||||||
|
"Target bus": "b2",
|
||||||
|
"Reactance (ohms)": 0.05917000000000001,
|
||||||
|
"Susceptance (S)": 29.496860773945063,
|
||||||
|
"Normal flow limit (MW)": 300.0,
|
||||||
|
"Emergency flow limit (MW)": 400.0,
|
||||||
|
"Flow limit penalty ($/MW)": 1000.0
|
||||||
|
},
|
||||||
|
"l2": {
|
||||||
|
"Source bus": "b1",
|
||||||
|
"Target bus": "b5",
|
||||||
|
"Reactance (ohms)": 0.22304000000000002,
|
||||||
|
"Susceptance (S)": 7.825184953346168
|
||||||
|
},
|
||||||
|
"l3": {
|
||||||
|
"Source bus": "b2",
|
||||||
|
"Target bus": "b3",
|
||||||
|
"Reactance (ohms)": 0.19797,
|
||||||
|
"Susceptance (S)": 8.816129979261149
|
||||||
|
},
|
||||||
|
"l4": {
|
||||||
|
"Source bus": "b2",
|
||||||
|
"Target bus": "b4",
|
||||||
|
"Reactance (ohms)": 0.17632,
|
||||||
|
"Susceptance (S)": 9.898645939169292
|
||||||
|
},
|
||||||
|
"l5": {
|
||||||
|
"Source bus": "b2",
|
||||||
|
"Target bus": "b5",
|
||||||
|
"Reactance (ohms)": 0.17388,
|
||||||
|
"Susceptance (S)": 10.037550333530765
|
||||||
|
},
|
||||||
|
"l6": {
|
||||||
|
"Source bus": "b3",
|
||||||
|
"Target bus": "b4",
|
||||||
|
"Reactance (ohms)": 0.17103,
|
||||||
|
"Susceptance (S)": 10.204813494675376
|
||||||
|
},
|
||||||
|
"l7": {
|
||||||
|
"Source bus": "b4",
|
||||||
|
"Target bus": "b5",
|
||||||
|
"Reactance (ohms)": 0.04211,
|
||||||
|
"Susceptance (S)": 41.44690695783257
|
||||||
|
},
|
||||||
|
"l8": {
|
||||||
|
"Source bus": "b4",
|
||||||
|
"Target bus": "b7",
|
||||||
|
"Reactance (ohms)": 0.20911999999999997,
|
||||||
|
"Susceptance (S)": 8.346065665619404
|
||||||
|
},
|
||||||
|
"l9": {
|
||||||
|
"Source bus": "b4",
|
||||||
|
"Target bus": "b9",
|
||||||
|
"Reactance (ohms)": 0.55618,
|
||||||
|
"Susceptance (S)": 3.1380654680037567
|
||||||
|
},
|
||||||
|
"l10": {
|
||||||
|
"Source bus": "b5",
|
||||||
|
"Target bus": "b6",
|
||||||
|
"Reactance (ohms)": 0.25201999999999997,
|
||||||
|
"Susceptance (S)": 6.92536009838239
|
||||||
|
},
|
||||||
|
"l11": {
|
||||||
|
"Source bus": "b6",
|
||||||
|
"Target bus": "b11",
|
||||||
|
"Reactance (ohms)": 0.1989,
|
||||||
|
"Susceptance (S)": 8.774908255376218
|
||||||
|
},
|
||||||
|
"l12": {
|
||||||
|
"Source bus": "b6",
|
||||||
|
"Target bus": "b12",
|
||||||
|
"Reactance (ohms)": 0.25581,
|
||||||
|
"Susceptance (S)": 6.8227561549365925
|
||||||
|
},
|
||||||
|
"l13": {
|
||||||
|
"Source bus": "b6",
|
||||||
|
"Target bus": "b13",
|
||||||
|
"Reactance (ohms)": 0.13027,
|
||||||
|
"Susceptance (S)": 13.397783465067395
|
||||||
|
},
|
||||||
|
"l14": {
|
||||||
|
"Source bus": "b7",
|
||||||
|
"Target bus": "b8",
|
||||||
|
"Reactance (ohms)": 0.17615,
|
||||||
|
"Susceptance (S)": 9.908198989465395
|
||||||
|
},
|
||||||
|
"l15": {
|
||||||
|
"Source bus": "b7",
|
||||||
|
"Target bus": "b9",
|
||||||
|
"Reactance (ohms)": 0.11001,
|
||||||
|
"Susceptance (S)": 15.865187273832648
|
||||||
|
},
|
||||||
|
"l16": {
|
||||||
|
"Source bus": "b9",
|
||||||
|
"Target bus": "b10",
|
||||||
|
"Reactance (ohms)": 0.0845,
|
||||||
|
"Susceptance (S)": 20.65478404727017
|
||||||
|
},
|
||||||
|
"l17": {
|
||||||
|
"Source bus": "b9",
|
||||||
|
"Target bus": "b14",
|
||||||
|
"Reactance (ohms)": 0.27038,
|
||||||
|
"Susceptance (S)": 6.4550974628091184
|
||||||
|
},
|
||||||
|
"l18": {
|
||||||
|
"Source bus": "b10",
|
||||||
|
"Target bus": "b11",
|
||||||
|
"Reactance (ohms)": 0.19207,
|
||||||
|
"Susceptance (S)": 9.08694357262628
|
||||||
|
},
|
||||||
|
"l19": {
|
||||||
|
"Source bus": "b12",
|
||||||
|
"Target bus": "b13",
|
||||||
|
"Reactance (ohms)": 0.19988,
|
||||||
|
"Susceptance (S)": 8.73188539120637
|
||||||
|
},
|
||||||
|
"l20": {
|
||||||
|
"Source bus": "b13",
|
||||||
|
"Target bus": "b14",
|
||||||
|
"Reactance (ohms)": 0.34802,
|
||||||
|
"Susceptance (S)": 5.0150257226433235
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Contingencies": {
|
||||||
|
"c1": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l1"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c2": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l2"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c3": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l3"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c4": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l4"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c5": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l5"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c6": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l6"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c7": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l7"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c8": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l8"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c9": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l9"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c10": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l10"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c11": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l11"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c12": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l12"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c13": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l13"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c15": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l15"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c16": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l16"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c17": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l17"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c18": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l18"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c19": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l19"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c20": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l20"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Price-sensitive loads": {
|
||||||
|
"ps1": {
|
||||||
|
"Bus": "b3",
|
||||||
|
"Revenue ($/MW)": 100.0,
|
||||||
|
"Demand (MW)": 50.0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Reserves": {
|
||||||
|
"r1": {
|
||||||
|
"Type": "Spinning",
|
||||||
|
"Amount (MW)": 100.0,
|
||||||
|
"Shortfall penalty ($/MW)": 1000.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
495
docs/example/s2.json
Normal file
495
docs/example/s2.json
Normal file
@@ -0,0 +1,495 @@
|
|||||||
|
{
|
||||||
|
"Parameters": {
|
||||||
|
"Version": "0.3",
|
||||||
|
"Time horizon (h)": 4
|
||||||
|
},
|
||||||
|
"Generators": {
|
||||||
|
"g1": {
|
||||||
|
"Bus": "b1",
|
||||||
|
"Production cost curve (MW)": [
|
||||||
|
100,
|
||||||
|
110,
|
||||||
|
130,
|
||||||
|
135
|
||||||
|
],
|
||||||
|
"Production cost curve ($)": [
|
||||||
|
1400,
|
||||||
|
1600,
|
||||||
|
2200,
|
||||||
|
2400
|
||||||
|
],
|
||||||
|
"Startup delays (h)": [
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
3
|
||||||
|
],
|
||||||
|
"Startup costs ($)": [
|
||||||
|
1000.0,
|
||||||
|
1500.0,
|
||||||
|
2000.0
|
||||||
|
],
|
||||||
|
"Initial status (h)": -100,
|
||||||
|
"Initial power (MW)": 0
|
||||||
|
},
|
||||||
|
"g2": {
|
||||||
|
"Bus": "b2",
|
||||||
|
"Production cost curve (MW)": [
|
||||||
|
0,
|
||||||
|
47,
|
||||||
|
94,
|
||||||
|
140
|
||||||
|
],
|
||||||
|
"Production cost curve ($)": [
|
||||||
|
0,
|
||||||
|
2256.00,
|
||||||
|
4733.37,
|
||||||
|
7395.39
|
||||||
|
],
|
||||||
|
"Startup delays (h)": [
|
||||||
|
1,
|
||||||
|
4
|
||||||
|
],
|
||||||
|
"Startup costs ($)": [
|
||||||
|
3000.0,
|
||||||
|
4000.0
|
||||||
|
],
|
||||||
|
"Ramp up limit (MW)": 98.0,
|
||||||
|
"Ramp down limit (MW)": 98.0,
|
||||||
|
"Startup limit (MW)": 98.0,
|
||||||
|
"Shutdown limit (MW)": 98.0,
|
||||||
|
"Minimum uptime (h)": 4,
|
||||||
|
"Minimum downtime (h)": 4,
|
||||||
|
"Maximum daily energy (MWh)": null,
|
||||||
|
"Maximum daily starts": null,
|
||||||
|
"Initial status (h)": -8,
|
||||||
|
"Initial power (MW)": 0,
|
||||||
|
"Reserve eligibility": [
|
||||||
|
"r1"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"g3": {
|
||||||
|
"Bus": "b3",
|
||||||
|
"Production cost curve (MW)": [
|
||||||
|
0,
|
||||||
|
33,
|
||||||
|
66,
|
||||||
|
100
|
||||||
|
],
|
||||||
|
"Production cost curve ($)": [
|
||||||
|
0,
|
||||||
|
1113.75,
|
||||||
|
2369.07,
|
||||||
|
3891.54
|
||||||
|
],
|
||||||
|
"Startup delays (h)": [
|
||||||
|
1,
|
||||||
|
4,
|
||||||
|
8
|
||||||
|
],
|
||||||
|
"Startup costs ($)": [
|
||||||
|
1000.0,
|
||||||
|
2000.0,
|
||||||
|
3000.0
|
||||||
|
],
|
||||||
|
"Ramp up limit (MW)": 70.0,
|
||||||
|
"Ramp down limit (MW)": 70.0,
|
||||||
|
"Startup limit (MW)": 70.0,
|
||||||
|
"Shutdown limit (MW)": 70.0,
|
||||||
|
"Must run?": true,
|
||||||
|
"Minimum uptime (h)": 1,
|
||||||
|
"Minimum downtime (h)": 1,
|
||||||
|
"Maximum daily energy (MWh)": null,
|
||||||
|
"Maximum daily starts": null,
|
||||||
|
"Initial status (h)": -6,
|
||||||
|
"Initial power (MW)": 0,
|
||||||
|
"Reserve eligibility": [
|
||||||
|
"r1"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"g4": {
|
||||||
|
"Bus": "b6",
|
||||||
|
"Production cost curve (MW)": [
|
||||||
|
33,
|
||||||
|
66,
|
||||||
|
100
|
||||||
|
],
|
||||||
|
"Production cost curve ($)": [
|
||||||
|
1113.75,
|
||||||
|
2369.07,
|
||||||
|
3891.54
|
||||||
|
],
|
||||||
|
"Initial status (h)": -100,
|
||||||
|
"Initial power (MW)": 0,
|
||||||
|
"Reserve eligibility": [
|
||||||
|
"r1"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"g5": {
|
||||||
|
"Bus": "b8",
|
||||||
|
"Production cost curve (MW)": [
|
||||||
|
33,
|
||||||
|
66,
|
||||||
|
100
|
||||||
|
],
|
||||||
|
"Production cost curve ($)": [
|
||||||
|
1113.75,
|
||||||
|
2369.07,
|
||||||
|
3891.54
|
||||||
|
],
|
||||||
|
"Initial status (h)": -100,
|
||||||
|
"Initial power (MW)": 0,
|
||||||
|
"Reserve eligibility": [
|
||||||
|
"r1"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"g6": {
|
||||||
|
"Bus": "b8",
|
||||||
|
"Production cost curve (MW)": [
|
||||||
|
100
|
||||||
|
],
|
||||||
|
"Production cost curve ($)": [
|
||||||
|
10000.00
|
||||||
|
],
|
||||||
|
"Initial status (h)": -100,
|
||||||
|
"Initial power (MW)": 0,
|
||||||
|
"Reserve eligibility": [
|
||||||
|
"r1"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Buses": {
|
||||||
|
"b1": {
|
||||||
|
"Load (MW)": 0.0
|
||||||
|
},
|
||||||
|
"b2": {
|
||||||
|
"Load (MW)": [
|
||||||
|
26.01527,
|
||||||
|
24.46212,
|
||||||
|
23.29725,
|
||||||
|
22.90897
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"b3": {
|
||||||
|
"Load (MW)": [
|
||||||
|
112.93263,
|
||||||
|
106.19039,
|
||||||
|
101.1337,
|
||||||
|
99.44814
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"b4": {
|
||||||
|
"Load (MW)": [
|
||||||
|
57.30552,
|
||||||
|
53.88429,
|
||||||
|
51.31838,
|
||||||
|
50.46307
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"b5": {
|
||||||
|
"Load (MW)": [
|
||||||
|
9.11134,
|
||||||
|
8.56738,
|
||||||
|
8.15941,
|
||||||
|
8.02342
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"b6": {
|
||||||
|
"Load (MW)": [
|
||||||
|
13.42723,
|
||||||
|
12.62561,
|
||||||
|
12.02439,
|
||||||
|
11.82398
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"b7": {
|
||||||
|
"Load (MW)": 0.0
|
||||||
|
},
|
||||||
|
"b8": {
|
||||||
|
"Load (MW)": 0.0
|
||||||
|
},
|
||||||
|
"b9": {
|
||||||
|
"Load (MW)": [
|
||||||
|
35.36638,
|
||||||
|
33.25495,
|
||||||
|
31.67138,
|
||||||
|
31.14353
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"b10": {
|
||||||
|
"Load (MW)": [
|
||||||
|
10.78974,
|
||||||
|
10.14558,
|
||||||
|
9.66246,
|
||||||
|
9.50141
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"b11": {
|
||||||
|
"Load (MW)": [
|
||||||
|
4.19601,
|
||||||
|
3.9455,
|
||||||
|
3.75762,
|
||||||
|
3.69499
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"b12": {
|
||||||
|
"Load (MW)": [
|
||||||
|
7.31305,
|
||||||
|
6.87645,
|
||||||
|
6.549,
|
||||||
|
6.43985
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"b13": {
|
||||||
|
"Load (MW)": [
|
||||||
|
16.18461,
|
||||||
|
15.21837,
|
||||||
|
14.49368,
|
||||||
|
14.25212
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"b14": {
|
||||||
|
"Load (MW)": [
|
||||||
|
17.86302,
|
||||||
|
16.79657,
|
||||||
|
15.99673,
|
||||||
|
15.73012
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Transmission lines": {
|
||||||
|
"l1": {
|
||||||
|
"Source bus": "b1",
|
||||||
|
"Target bus": "b2",
|
||||||
|
"Reactance (ohms)": 0.05917000000000001,
|
||||||
|
"Susceptance (S)": 29.496860773945063,
|
||||||
|
"Normal flow limit (MW)": 300.0,
|
||||||
|
"Emergency flow limit (MW)": 400.0,
|
||||||
|
"Flow limit penalty ($/MW)": 1000.0
|
||||||
|
},
|
||||||
|
"l2": {
|
||||||
|
"Source bus": "b1",
|
||||||
|
"Target bus": "b5",
|
||||||
|
"Reactance (ohms)": 0.22304000000000002,
|
||||||
|
"Susceptance (S)": 7.825184953346168
|
||||||
|
},
|
||||||
|
"l3": {
|
||||||
|
"Source bus": "b2",
|
||||||
|
"Target bus": "b3",
|
||||||
|
"Reactance (ohms)": 0.19797,
|
||||||
|
"Susceptance (S)": 8.816129979261149
|
||||||
|
},
|
||||||
|
"l4": {
|
||||||
|
"Source bus": "b2",
|
||||||
|
"Target bus": "b4",
|
||||||
|
"Reactance (ohms)": 0.17632,
|
||||||
|
"Susceptance (S)": 9.898645939169292
|
||||||
|
},
|
||||||
|
"l5": {
|
||||||
|
"Source bus": "b2",
|
||||||
|
"Target bus": "b5",
|
||||||
|
"Reactance (ohms)": 0.17388,
|
||||||
|
"Susceptance (S)": 10.037550333530765
|
||||||
|
},
|
||||||
|
"l6": {
|
||||||
|
"Source bus": "b3",
|
||||||
|
"Target bus": "b4",
|
||||||
|
"Reactance (ohms)": 0.17103,
|
||||||
|
"Susceptance (S)": 10.204813494675376
|
||||||
|
},
|
||||||
|
"l7": {
|
||||||
|
"Source bus": "b4",
|
||||||
|
"Target bus": "b5",
|
||||||
|
"Reactance (ohms)": 0.04211,
|
||||||
|
"Susceptance (S)": 41.44690695783257
|
||||||
|
},
|
||||||
|
"l8": {
|
||||||
|
"Source bus": "b4",
|
||||||
|
"Target bus": "b7",
|
||||||
|
"Reactance (ohms)": 0.20911999999999997,
|
||||||
|
"Susceptance (S)": 8.346065665619404
|
||||||
|
},
|
||||||
|
"l9": {
|
||||||
|
"Source bus": "b4",
|
||||||
|
"Target bus": "b9",
|
||||||
|
"Reactance (ohms)": 0.55618,
|
||||||
|
"Susceptance (S)": 3.1380654680037567
|
||||||
|
},
|
||||||
|
"l10": {
|
||||||
|
"Source bus": "b5",
|
||||||
|
"Target bus": "b6",
|
||||||
|
"Reactance (ohms)": 0.25201999999999997,
|
||||||
|
"Susceptance (S)": 6.92536009838239
|
||||||
|
},
|
||||||
|
"l11": {
|
||||||
|
"Source bus": "b6",
|
||||||
|
"Target bus": "b11",
|
||||||
|
"Reactance (ohms)": 0.1989,
|
||||||
|
"Susceptance (S)": 8.774908255376218
|
||||||
|
},
|
||||||
|
"l12": {
|
||||||
|
"Source bus": "b6",
|
||||||
|
"Target bus": "b12",
|
||||||
|
"Reactance (ohms)": 0.25581,
|
||||||
|
"Susceptance (S)": 6.8227561549365925
|
||||||
|
},
|
||||||
|
"l13": {
|
||||||
|
"Source bus": "b6",
|
||||||
|
"Target bus": "b13",
|
||||||
|
"Reactance (ohms)": 0.13027,
|
||||||
|
"Susceptance (S)": 13.397783465067395
|
||||||
|
},
|
||||||
|
"l14": {
|
||||||
|
"Source bus": "b7",
|
||||||
|
"Target bus": "b8",
|
||||||
|
"Reactance (ohms)": 0.17615,
|
||||||
|
"Susceptance (S)": 9.908198989465395
|
||||||
|
},
|
||||||
|
"l15": {
|
||||||
|
"Source bus": "b7",
|
||||||
|
"Target bus": "b9",
|
||||||
|
"Reactance (ohms)": 0.11001,
|
||||||
|
"Susceptance (S)": 15.865187273832648
|
||||||
|
},
|
||||||
|
"l16": {
|
||||||
|
"Source bus": "b9",
|
||||||
|
"Target bus": "b10",
|
||||||
|
"Reactance (ohms)": 0.0845,
|
||||||
|
"Susceptance (S)": 20.65478404727017
|
||||||
|
},
|
||||||
|
"l17": {
|
||||||
|
"Source bus": "b9",
|
||||||
|
"Target bus": "b14",
|
||||||
|
"Reactance (ohms)": 0.27038,
|
||||||
|
"Susceptance (S)": 6.4550974628091184
|
||||||
|
},
|
||||||
|
"l18": {
|
||||||
|
"Source bus": "b10",
|
||||||
|
"Target bus": "b11",
|
||||||
|
"Reactance (ohms)": 0.19207,
|
||||||
|
"Susceptance (S)": 9.08694357262628
|
||||||
|
},
|
||||||
|
"l19": {
|
||||||
|
"Source bus": "b12",
|
||||||
|
"Target bus": "b13",
|
||||||
|
"Reactance (ohms)": 0.19988,
|
||||||
|
"Susceptance (S)": 8.73188539120637
|
||||||
|
},
|
||||||
|
"l20": {
|
||||||
|
"Source bus": "b13",
|
||||||
|
"Target bus": "b14",
|
||||||
|
"Reactance (ohms)": 0.34802,
|
||||||
|
"Susceptance (S)": 5.0150257226433235
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Contingencies": {
|
||||||
|
"c1": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l1"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c2": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l2"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c3": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l3"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c4": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l4"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c5": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l5"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c6": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l6"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c7": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l7"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c8": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l8"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c9": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l9"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c10": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l10"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c11": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l11"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c12": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l12"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c13": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l13"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c15": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l15"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c16": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l16"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c17": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l17"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c18": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l18"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c19": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l19"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c20": {
|
||||||
|
"Affected lines": [
|
||||||
|
"l20"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Price-sensitive loads": {
|
||||||
|
"ps1": {
|
||||||
|
"Bus": "b3",
|
||||||
|
"Revenue ($/MW)": 100.0,
|
||||||
|
"Demand (MW)": 50.0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Reserves": {
|
||||||
|
"r1": {
|
||||||
|
"Type": "Spinning",
|
||||||
|
"Amount (MW)": 100.0,
|
||||||
|
"Shortfall penalty ($/MW)": 1000.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
323
docs/format.md
323
docs/format.md
@@ -1,323 +0,0 @@
|
|||||||
```{sectnum}
|
|
||||||
---
|
|
||||||
start: 2
|
|
||||||
depth: 2
|
|
||||||
suffix: .
|
|
||||||
---
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
Data Format
|
|
||||||
===========
|
|
||||||
|
|
||||||
|
|
||||||
Input Data Format
|
|
||||||
-----------------
|
|
||||||
|
|
||||||
Instances are specified by JSON files containing the following main sections:
|
|
||||||
|
|
||||||
* Parameters
|
|
||||||
* Buses
|
|
||||||
* Generators
|
|
||||||
* Price-sensitive loads
|
|
||||||
* Transmission lines
|
|
||||||
* Reserves
|
|
||||||
* Contingencies
|
|
||||||
|
|
||||||
Each section is described in detail below. For a complete example, see [case14](https://github.com/ANL-CEEESA/UnitCommitment.jl/tree/dev/instances/matpower/case14).
|
|
||||||
|
|
||||||
### Parameters
|
|
||||||
|
|
||||||
This section describes system-wide parameters, such as power balance and reserve shortfall penalties, and optimization parameters, such as the length of the planning horizon and the time.
|
|
||||||
|
|
||||||
| Key | Description | Default | Time series?
|
|
||||||
| :----------------------------- | :------------------------------------------------ | :------: | :------------:
|
|
||||||
| `Time horizon (h)` | Length of the planning horizon (in hours). | Required | N
|
|
||||||
| `Time step (min)` | Length of each time step (in minutes). Must be a divisor of 60 (e.g. 60, 30, 20, 15, etc). | `60` | N
|
|
||||||
| `Power balance penalty ($/MW)` | Penalty for system-wide shortage or surplus in production (in $/MW). This is charged per time step. For example, if there is a shortage of 1 MW for three time steps, three times this amount will be charged. | `1000.0` | Y
|
|
||||||
| `Reserve shortfall penalty ($/MW)` | Penalty for system-wide shortage in meeting reserve requirements (in $/MW). This is charged per time step. Negative value implies reserve constraints must always be satisfied. | `-1` | Y
|
|
||||||
| `Flexiramp penalty ($/MW)` | Penalty for system-wide shortage in meeting flexible ramping product requirements (in $/MW). This is charged per time step. | `500` | Y
|
|
||||||
|
|
||||||
|
|
||||||
#### Example
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"Parameters": {
|
|
||||||
"Time horizon (h)": 4,
|
|
||||||
"Power balance penalty ($/MW)": 1000.0,
|
|
||||||
"Reserve shortfall penalty ($/MW)": -1.0,
|
|
||||||
"Flexiramp penalty ($/MW)": 100.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Buses
|
|
||||||
|
|
||||||
This section describes the characteristics of each bus in the system.
|
|
||||||
|
|
||||||
| Key | Description | Default | Time series?
|
|
||||||
| :----------------- | :------------------------------------------------------------ | ------- | :-------------:
|
|
||||||
| `Load (MW)` | Fixed load connected to the bus (in MW). | Required | Y
|
|
||||||
|
|
||||||
|
|
||||||
#### Example
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"Buses": {
|
|
||||||
"b1": {
|
|
||||||
"Load (MW)": 0.0
|
|
||||||
},
|
|
||||||
"b2": {
|
|
||||||
"Load (MW)": [
|
|
||||||
26.01527,
|
|
||||||
24.46212,
|
|
||||||
23.29725,
|
|
||||||
22.90897
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
### Generators
|
|
||||||
|
|
||||||
This section describes all generators in the system, including thermal units, renewable units and virtual units.
|
|
||||||
|
|
||||||
| Key | Description | Default | Time series?
|
|
||||||
| :------------------------ | :------------------------------------------------| ------- | :-----------:
|
|
||||||
| `Bus` | Identifier of the bus where this generator is located (string). | Required | N
|
|
||||||
| `Production cost curve (MW)` and `Production cost curve ($)` | Parameters describing the piecewise-linear production costs. See below for more details. | Required | Y
|
|
||||||
| `Startup costs ($)` and `Startup delays (h)` | Parameters describing how much it costs to start the generator after it has been shut down for a certain amount of time. If `Startup costs ($)` and `Startup delays (h)` are set to `[300.0, 400.0]` and `[1, 4]`, for example, and the generator is shut down at time `00:00` (h:min), then it costs \$300 to start up the generator at any time between `01:00` and `03:59`, and \$400 to start the generator at time `04:00` or any time after that. The number of startup cost points is unlimited, and may be different for each generator. Startup delays must be strictly increasing and the first entry must equal `Minimum downtime (h)`. | `[0.0]` and `[1]` | N
|
|
||||||
| `Minimum uptime (h)` | Minimum amount of time the generator must stay operational after starting up (in hours). For example, if the generator starts up at time `00:00` (h:min) and `Minimum uptime (h)` is set to 4, then the generator can only shut down at time `04:00`. | `1` | N
|
|
||||||
| `Minimum downtime (h)` | Minimum amount of time the generator must stay offline after shutting down (in hours). For example, if the generator shuts down at time `00:00` (h:min) and `Minimum downtime (h)` is set to 4, then the generator can only start producing power again at time `04:00`. | `1` | N
|
|
||||||
| `Ramp up limit (MW)` | Maximum increase in production from one time step to the next (in MW). For example, if the generator is producing 100 MW at time step 1 and if this parameter is set to 40 MW, then the generator will produce at most 140 MW at time step 2. | `+inf` | N
|
|
||||||
| `Ramp down limit (MW)` | Maximum decrease in production from one time step to the next (in MW). For example, if the generator is producing 100 MW at time step 1 and this parameter is set to 40 MW, then the generator will produce at least 60 MW at time step 2. | `+inf` | N
|
|
||||||
| `Startup limit (MW)` | Maximum amount of power a generator can produce immediately after starting up (in MW). For example, if `Startup limit (MW)` is set to 100 MW and the unit is off at time step 1, then it may produce at most 100 MW at time step 2.| `+inf` | N
|
|
||||||
| `Shutdown limit (MW)` | Maximum amount of power a generator can produce immediately before shutting down (in MW). Specifically, the generator can only shut down at time step `t+1` if its production at time step `t` is below this limit. | `+inf` | N
|
|
||||||
| `Initial status (h)` | If set to a positive number, indicates the amount of time (in hours) the generator has been on at the beginning of the simulation, and if set to a negative number, the amount of time the generator has been off. For example, if `Initial status (h)` is `-2`, this means that the generator was off since `-02:00` (h:min). The simulation starts at time `00:00`. If `Initial status (h)` is `3`, this means that the generator was on since `-03:00`. A value of zero is not acceptable. | Required | N
|
|
||||||
| `Initial power (MW)` | Amount of power the generator at time step `-1`, immediately before the planning horizon starts. | Required | N
|
|
||||||
| `Must run?` | If `true`, the generator should be committed, even if that is not economical (Boolean). | `false` | Y
|
|
||||||
| `Provides spinning reserves?` | If `true`, this generator may provide spinning reserves (Boolean). | `true` | Y
|
|
||||||
| `Provides flexible capacity?` | If `true`, this generator may provide flexible ramping product (Boolean). | `true` | Y
|
|
||||||
|
|
||||||
|
|
||||||
#### Production costs and limits
|
|
||||||
|
|
||||||
Production costs are represented as piecewise-linear curves. Figure 1 shows an example cost curve with three segments, where it costs \$1400, \$1600, \$2200 and \$2400 to generate, respectively, 100, 110, 130 and 135 MW of power. To model this generator, `Production cost curve (MW)` should be set to `[100, 110, 130, 135]`, and `Production cost curve ($)` should be set to `[1400, 1600, 2200, 2400]`.
|
|
||||||
Note that this curve also specifies the production limits. Specifically, the first point identifies the minimum power output when the unit is operational, while the last point identifies the maximum power output.
|
|
||||||
|
|
||||||
<center>
|
|
||||||
<img src="../_static/cost_curve.png" style="max-width: 500px"/>
|
|
||||||
<div><b>Figure 1.</b> Piecewise-linear production cost curve.</div>
|
|
||||||
<br/>
|
|
||||||
</center>
|
|
||||||
|
|
||||||
#### Additional remarks:
|
|
||||||
|
|
||||||
* For time-dependent production limits or time-dependent production costs, the usage of nested arrays is allowed. For example, if `Production cost curve (MW)` is set to `[5.0, [10.0, 12.0, 15.0, 20.0]]`, then the unit may generate at most 10, 12, 15 and 20 MW of power during time steps 1, 2, 3 and 4, respectively. The minimum output for all time periods is fixed to at 5 MW.
|
|
||||||
* There is no limit to the number of piecewise-linear segments, and different generators may have a different number of segments.
|
|
||||||
* If `Production cost curve (MW)` and `Production cost curve ($)` both contain a single element, then the generator must produce exactly that amount of power when operational. To specify that the generator may produce any amount of power up to a certain limit `P`, the parameter `Production cost curve (MW)` should be set to `[0, P]`.
|
|
||||||
* Production cost curves must be convex.
|
|
||||||
|
|
||||||
#### Example
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"Generators": {
|
|
||||||
"gen1": {
|
|
||||||
"Bus": "b1",
|
|
||||||
"Production cost curve (MW)": [100.0, 110.0, 130.0, 135.0],
|
|
||||||
"Production cost curve ($)": [1400.0, 1600.0, 2200.0, 2400.0],
|
|
||||||
"Startup costs ($)": [300.0, 400.0],
|
|
||||||
"Startup delays (h)": [1, 4],
|
|
||||||
"Ramp up limit (MW)": 232.68,
|
|
||||||
"Ramp down limit (MW)": 232.68,
|
|
||||||
"Startup limit (MW)": 232.68,
|
|
||||||
"Shutdown limit (MW)": 232.68,
|
|
||||||
"Minimum downtime (h)": 4,
|
|
||||||
"Minimum uptime (h)": 4,
|
|
||||||
"Initial status (h)": 12,
|
|
||||||
"Must run?": false,
|
|
||||||
"Provides spinning reserves?": true,
|
|
||||||
"Provides flexible capacity?": false,
|
|
||||||
},
|
|
||||||
"gen2": {
|
|
||||||
"Bus": "b5",
|
|
||||||
"Production cost curve (MW)": [0.0, [10.0, 8.0, 0.0, 3.0]],
|
|
||||||
"Production cost curve ($)": [0.0, 0.0],
|
|
||||||
"Provides spinning reserves?": true,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Price-sensitive loads
|
|
||||||
|
|
||||||
This section describes components in the system which may increase or reduce their energy consumption according to the energy prices. Fixed loads (as described in the `buses` section) are always served, regardless of the price, unless there is significant congestion in the system or insufficient production capacity. Price-sensitive loads, on the other hand, are only served if it is economical to do so.
|
|
||||||
|
|
||||||
| Key | Description | Default | Time series?
|
|
||||||
| :---------------- | :------------------------------------------------ | :------: | :------------:
|
|
||||||
| `Bus` | Bus where the load is located. Multiple price-sensitive loads may be placed at the same bus. | Required | N
|
|
||||||
| `Revenue ($/MW)` | Revenue obtained for serving each MW of power to this load. | Required | Y
|
|
||||||
| `Demand (MW)` | Maximum amount of power required by this load. Any amount lower than this may be served. | Required | Y
|
|
||||||
|
|
||||||
|
|
||||||
#### Example
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"Price-sensitive loads": {
|
|
||||||
"p1": {
|
|
||||||
"Bus": "b3",
|
|
||||||
"Revenue ($/MW)": 23.0,
|
|
||||||
"Demand (MW)": 50.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Transmission Lines
|
|
||||||
|
|
||||||
This section describes the characteristics of transmission system, such as its topology and the susceptance of each transmission line.
|
|
||||||
|
|
||||||
| Key | Description | Default | Time series?
|
|
||||||
| :--------------------- | :----------------------------------------------- | ------- | :------------:
|
|
||||||
| `Source bus` | Identifier of the bus where the transmission line originates. | Required | N
|
|
||||||
| `Target bus` | Identifier of the bus where the transmission line reaches. | Required | N
|
|
||||||
| `Reactance (ohms)` | Reactance of the transmission line (in ohms). | Required | N
|
|
||||||
| `Susceptance (S)` | Susceptance of the transmission line (in siemens). | Required | N
|
|
||||||
| `Normal flow limit (MW)` | Maximum amount of power (in MW) allowed to flow through the line when the system is in its regular, fully-operational state. | `+inf` | Y
|
|
||||||
| `Emergency flow limit (MW)` | Maximum amount of power (in MW) allowed to flow through the line when the system is in degraded state (for example, after the failure of another transmission line). | `+inf` | Y
|
|
||||||
| `Flow limit penalty ($/MW)` | Penalty for violating the flow limits of the transmission line (in $/MW). This is charged per time step. For example, if there is a thermal violation of 1 MW for three time steps, then three times this amount will be charged. | `5000.0` | Y
|
|
||||||
|
|
||||||
#### Example
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"Transmission lines": {
|
|
||||||
"l1": {
|
|
||||||
"Source bus": "b1",
|
|
||||||
"Target bus": "b2",
|
|
||||||
"Reactance (ohms)": 0.05917,
|
|
||||||
"Susceptance (S)": 29.49686,
|
|
||||||
"Normal flow limit (MW)": 15000.0,
|
|
||||||
"Emergency flow limit (MW)": 20000.0,
|
|
||||||
"Flow limit penalty ($/MW)": 5000.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
### Reserves
|
|
||||||
|
|
||||||
This section describes the hourly amount of reserves required.
|
|
||||||
|
|
||||||
|
|
||||||
| Key | Description | Default | Time series?
|
|
||||||
| :-------------------- | :------------------------------------------------- | --------- | :----:
|
|
||||||
| `Spinning (MW)` | Minimum amount of system-wide spinning reserves (in MW). Only generators which are online may provide this reserve. | `0.0` | Y
|
|
||||||
| `Up-flexiramp (MW)` | Minimum amount of system-wide upward flexible ramping product (in MW). Only generators which are online may provide this reserve. | `0.0` | Y
|
|
||||||
| `Down-flexiramp (MW)` | Minimum amount of system-wide downward flexible ramping product (in MW). Only generators which are online may provide this reserve. | `0.0` | Y
|
|
||||||
|
|
||||||
#### Example 1
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"Reserves": {
|
|
||||||
"Spinning (MW)": [
|
|
||||||
57.30552,
|
|
||||||
53.88429,
|
|
||||||
51.31838,
|
|
||||||
50.46307
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Example 2
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"Reserves": {
|
|
||||||
"Up-flexiramp (MW)": [
|
|
||||||
20.31042,
|
|
||||||
23.65273,
|
|
||||||
27.41784,
|
|
||||||
25.34057
|
|
||||||
],
|
|
||||||
"Down-flexiramp (MW)": [
|
|
||||||
19.41546,
|
|
||||||
21.45377,
|
|
||||||
23.53402,
|
|
||||||
24.80973
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Contingencies
|
|
||||||
|
|
||||||
This section describes credible contingency scenarios in the optimization, such as the loss of a transmission line or generator.
|
|
||||||
|
|
||||||
| Key | Description | Default
|
|
||||||
| :-------------------- | :----------------------------------------------- | ----------
|
|
||||||
| `Affected generators` | List of generators affected by this contingency. May be omitted if no generators are affected. | `[]`
|
|
||||||
| `Affected lines` | List of transmission lines affected by this contingency. May be omitted if no lines are affected. | `[]`
|
|
||||||
|
|
||||||
#### Example
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"Contingencies": {
|
|
||||||
"c1": {
|
|
||||||
"Affected lines": ["l1", "l2", "l3"],
|
|
||||||
"Affected generators": ["g1"]
|
|
||||||
},
|
|
||||||
"c2": {
|
|
||||||
"Affected lines": ["l4"]
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Additional remarks
|
|
||||||
|
|
||||||
#### Time series parameters
|
|
||||||
|
|
||||||
Many numerical properties in the JSON file can be specified either as a single floating point number if they are time-independent, or as an array containing exactly `T` elements, if they are time-dependent, where `T` is the number of time steps in the planning horizon. For example, both formats below are valid when `T=3`:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"Load (MW)": 800.0,
|
|
||||||
"Load (MW)": [800.0, 850.0, 730.0]
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
The value `T` depends on both `Time horizon (h)` and `Time step (min)`, as the table below illustrates.
|
|
||||||
|
|
||||||
Time horizon (h) | Time step (min) | T
|
|
||||||
:---------------:|:---------------:|:----:
|
|
||||||
24 | 60 | 24
|
|
||||||
24 | 15 | 96
|
|
||||||
24 | 5 | 288
|
|
||||||
36 | 60 | 36
|
|
||||||
36 | 15 | 144
|
|
||||||
36 | 5 | 432
|
|
||||||
|
|
||||||
Output Data Format
|
|
||||||
------------------
|
|
||||||
|
|
||||||
The output data format is also JSON-based, but it is not currently documented since we expect it to change significantly in a future version of the package.
|
|
||||||
|
|
||||||
|
|
||||||
Current limitations
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
* All reserves are system-wide. Zonal reserves are not currently supported.
|
|
||||||
* Upward and downward flexible ramping products can only be acquired under the WanHob2016 formulation, which does not support spinning reserves.
|
|
||||||
* Network topology remains the same for all time periods
|
|
||||||
* Only N-1 transmission contingencies are supported. Generator contingencies are not currently supported.
|
|
||||||
* Time-varying minimum production amounts are not currently compatible with ramp/startup/shutdown limits.
|
|
||||||
|
|
||||||
|
|
||||||
18
docs/make.jl
Normal file
18
docs/make.jl
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using Documenter, UnitCommitment, JuMP
|
||||||
|
|
||||||
|
function make()
|
||||||
|
makedocs(
|
||||||
|
sitename="UnitCommitment.jl",
|
||||||
|
pages=[
|
||||||
|
"Home" => "index.md",
|
||||||
|
"usage.md",
|
||||||
|
"format.md",
|
||||||
|
"instances.md",
|
||||||
|
"model.md",
|
||||||
|
"api.md",
|
||||||
|
],
|
||||||
|
format = Documenter.HTML(
|
||||||
|
assets=["assets/custom.css"],
|
||||||
|
)
|
||||||
|
)
|
||||||
|
end
|
||||||
244
docs/model.md
244
docs/model.md
@@ -1,244 +0,0 @@
|
|||||||
```{sectnum}
|
|
||||||
---
|
|
||||||
start: 4
|
|
||||||
depth: 2
|
|
||||||
suffix: .
|
|
||||||
---
|
|
||||||
```
|
|
||||||
|
|
||||||
JuMP Model
|
|
||||||
==========
|
|
||||||
|
|
||||||
In this page, we describe the JuMP optimization model produced by the function `UnitCommitment.build_model`. A detailed understanding of this model is not necessary if you are just interested in using the package to solve some standard unit commitment cases, but it may be useful, for example, if you need to solve a slightly different problem, with additional variables and constraints. The notation in this page generally follows [KnOsWa20].
|
|
||||||
|
|
||||||
Decision variables
|
|
||||||
------------------
|
|
||||||
|
|
||||||
### Generators
|
|
||||||
|
|
||||||
Name | Symbol | Description | Unit
|
|
||||||
-----|:--------:|-------------|:------:
|
|
||||||
`is_on[g,t]` | $u_{g}(t)$ | True if generator `g` is on at time `t`. | Binary
|
|
||||||
`switch_on[g,t]` | $v_{g}(t)$ | True is generator `g` switches on at time `t`. | Binary
|
|
||||||
`switch_off[g,t]` | $w_{g}(t)$ | True if generator `g` switches off at time `t`. | Binary
|
|
||||||
`prod_above[g,t]` |$p'_{g}(t)$ | Amount of power produced by generator `g` above its minimum power output at time `t`. For example, if the minimum power of generator `g` is 100 MW and `g` is producing 115 MW of power at time `t`, then `prod_above[g,t]` equals `15.0`. | MW
|
|
||||||
`segprod[g,t,k]` | $p^k_g(t)$ | Amount of power from piecewise linear segment `k` produced by generator `g` at time `t`. For example, if cost curve for generator `g` is defined by the points `(100, 1400)`, `(110, 1600)`, `(130, 2200)` and `(135, 2400)`, and if the generator is producing 115 MW of power at time `t`, then `segprod[g,t,:]` equals `[10.0, 5.0, 0.0]`.| MW
|
|
||||||
`reserve[g,t]` | $r_g(t)$ | Amount of reserves provided by generator `g` at time `t`. | MW
|
|
||||||
`startup[g,t,s]` | $\delta^s_g(t)$ | True if generator `g` switches on at time `t` incurring start-up costs from start-up category `s`. | Binary
|
|
||||||
|
|
||||||
|
|
||||||
### Buses
|
|
||||||
|
|
||||||
Name | Symbol | Description | Unit
|
|
||||||
-----|:------:|-------------|:------:
|
|
||||||
`net_injection[b,t]` | $n_b(t)$ | Net injection at bus `b` at time `t`. | MW
|
|
||||||
`curtail[b,t]` | $s^+_b(t)$ | Amount of load curtailed at bus `b` at time `t` | MW
|
|
||||||
|
|
||||||
|
|
||||||
### Price-sensitive loads
|
|
||||||
|
|
||||||
Name | Symbol | Description | Unit
|
|
||||||
-----|:------:|-------------|:------:
|
|
||||||
`loads[s,t]` | $d_{s}(t)$ | Amount of power served to price-sensitive load `s` at time `t`. | MW
|
|
||||||
|
|
||||||
### Transmission lines
|
|
||||||
|
|
||||||
Name | Symbol | Description | Unit
|
|
||||||
-----|:------:|-------------|:------:
|
|
||||||
`flow[l,t]` | $f_l(t)$ | Power flow on line `l` at time `t`. | MW
|
|
||||||
`overflow[l,t]` | $f^+_l(t)$ | Amount of flow above the limit for line `l` at time `t`. | MW
|
|
||||||
|
|
||||||
```{warning}
|
|
||||||
|
|
||||||
Since transmission and N-1 security constraints are enforced in a lazy way, most of the `flow[l,t]` variables are never added to the model. Accessing `model[:flow][l,t]` without first checking that the variable exists will likely generate an error.
|
|
||||||
```
|
|
||||||
|
|
||||||
Objective function
|
|
||||||
------------------
|
|
||||||
|
|
||||||
$$
|
|
||||||
\begin{align}
|
|
||||||
\text{minimize} \;\; &
|
|
||||||
\sum_{t \in \mathcal{T}}
|
|
||||||
\sum_{g \in \mathcal{G}}
|
|
||||||
C^\text{min}_g(t) u_g(t) \\
|
|
||||||
&
|
|
||||||
+ \sum_{t \in \mathcal{T}}
|
|
||||||
\sum_{g \in \mathcal{G}}
|
|
||||||
\sum_{g \in \mathcal{K}_g}
|
|
||||||
C^k_g(t) p^k_g(t) \\
|
|
||||||
&
|
|
||||||
+ \sum_{t \in \mathcal{T}}
|
|
||||||
\sum_{g \in \mathcal{G}}
|
|
||||||
\sum_{s \in \mathcal{S}_g}
|
|
||||||
C^s_{g}(t) \delta^s_g(t) \\
|
|
||||||
&
|
|
||||||
+ \sum_{t \in \mathcal{T}}
|
|
||||||
\sum_{l \in \mathcal{L}}
|
|
||||||
C^\text{overflow}_{l}(t) f^+_l(t) \\
|
|
||||||
&
|
|
||||||
+ \sum_{t \in \mathcal{T}}
|
|
||||||
\sum_{b \in \mathcal{B}}
|
|
||||||
C^\text{curtail}(t) s^+_b(t) \\
|
|
||||||
&
|
|
||||||
- \sum_{t \in \mathcal{T}}
|
|
||||||
\sum_{s \in \mathcal{PS}}
|
|
||||||
R_{s}(t) d_{s}(t) \\
|
|
||||||
|
|
||||||
\end{align}
|
|
||||||
$$
|
|
||||||
where
|
|
||||||
- $\mathcal{B}$ is the set of buses
|
|
||||||
- $\mathcal{G}$ is the set of generators
|
|
||||||
- $\mathcal{L}$ is the set of transmission lines
|
|
||||||
- $\mathcal{PS}$ is the set of price-sensitive loads
|
|
||||||
- $\mathcal{S}_g$ is the set of start-up categories for generator $g$
|
|
||||||
- $\mathcal{T}$ is the set of time steps
|
|
||||||
- $C^\text{curtail}(t)$ is the curtailment penalty (in \$/MW)
|
|
||||||
- $C^\text{min}_g(t)$ is the cost of keeping generator $g$ on and producing at minimum power during time $t$ (in \$)
|
|
||||||
- $C^\text{overflow}_{l}(t)$ is the flow limit penalty for line $l$ at time $t$ (in \$/MW)
|
|
||||||
- $C^k_g(t)$ is the cost for generator $g$ to produce 1 MW of power at time $t$ under piecewise linear segment $k$
|
|
||||||
- $C^s_{g}(t)$ is the cost of starting up generator $g$ at time $t$ under start-up category $s$ (in \$)
|
|
||||||
- $R_{s}(t)$ is the revenue obtained from serving price-sensitive load $s$ at time $t$ (in \$/MW)
|
|
||||||
|
|
||||||
|
|
||||||
Constraints
|
|
||||||
-----------
|
|
||||||
|
|
||||||
TODO
|
|
||||||
|
|
||||||
|
|
||||||
Inspecting and modifying the model
|
|
||||||
----------------------------------
|
|
||||||
|
|
||||||
### Accessing decision variables
|
|
||||||
|
|
||||||
After building a model using `UnitCommitment.build_model`, it is possible to obtain a reference to the decision variables by calling `model[:varname][index]`. For example, `model[:is_on]["g1",1]` returns a direct reference to the JuMP variable indicating whether generator named "g1" is on at time 1. The script below illustrates how to build a model, solve it and display the solution without using the function `UnitCommitment.solution`.
|
|
||||||
|
|
||||||
```julia
|
|
||||||
using Cbc
|
|
||||||
using Printf
|
|
||||||
using JuMP
|
|
||||||
using UnitCommitment
|
|
||||||
|
|
||||||
# Load benchmark instance
|
|
||||||
instance = UnitCommitment.read_benchmark("matpower/case118/2017-02-01")
|
|
||||||
|
|
||||||
# Build JuMP model
|
|
||||||
model = UnitCommitment.build_model(
|
|
||||||
instance=instance,
|
|
||||||
optimizer=Cbc.Optimizer,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Solve the model
|
|
||||||
UnitCommitment.optimize!(model)
|
|
||||||
|
|
||||||
# Display commitment status
|
|
||||||
for g in instance.units
|
|
||||||
for t in 1:instance.time
|
|
||||||
@printf(
|
|
||||||
"%-10s %5d %5.1f %5.1f %5.1f\n",
|
|
||||||
g.name,
|
|
||||||
t,
|
|
||||||
value(model[:is_on][g.name, t]),
|
|
||||||
value(model[:switch_on][g.name, t]),
|
|
||||||
value(model[:switch_off][g.name, t]),
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
```
|
|
||||||
|
|
||||||
### Fixing variables, modifying objective function and adding constraints
|
|
||||||
|
|
||||||
Since we now have a direct reference to the JuMP decision variables, it is possible to fix variables, change the coefficients in the objective function, or even add new constraints to the model before solving it. The script below shows how can this be accomplished. For more information on modifying an existing model, [see the JuMP documentation](https://jump.dev/JuMP.jl/stable/manual/variables/).
|
|
||||||
|
|
||||||
```julia
|
|
||||||
using Cbc
|
|
||||||
using JuMP
|
|
||||||
using UnitCommitment
|
|
||||||
|
|
||||||
# Load benchmark instance
|
|
||||||
instance = UnitCommitment.read_benchmark("matpower/case118/2017-02-01")
|
|
||||||
|
|
||||||
# Construct JuMP model
|
|
||||||
model = UnitCommitment.build_model(
|
|
||||||
instance=instance,
|
|
||||||
optimizer=Cbc.Optimizer,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Fix a decision variable to 1.0
|
|
||||||
JuMP.fix(
|
|
||||||
model[:is_on]["g1",1],
|
|
||||||
1.0,
|
|
||||||
force=true,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Change the objective function
|
|
||||||
JuMP.set_objective_coefficient(
|
|
||||||
model,
|
|
||||||
model[:switch_on]["g2",1],
|
|
||||||
1000.0,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Create a new constraint
|
|
||||||
@constraint(
|
|
||||||
model,
|
|
||||||
model[:is_on]["g3",1] + model[:is_on]["g4",1] <= 1,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Solve the model
|
|
||||||
UnitCommitment.optimize!(model)
|
|
||||||
```
|
|
||||||
|
|
||||||
### Adding new component to a bus
|
|
||||||
|
|
||||||
The following snippet shows how to add a new grid component to a particular bus. For each time step, we create decision variables for the new grid component, add these variables to the objective function, then attach the component to a particular bus by modifying some existing model constraints.
|
|
||||||
|
|
||||||
```julia
|
|
||||||
using Cbc
|
|
||||||
using JuMP
|
|
||||||
using UnitCommitment
|
|
||||||
|
|
||||||
# Load instance and build base model
|
|
||||||
instance = UnitCommitment.read_benchmark("matpower/case118/2017-02-01")
|
|
||||||
model = UnitCommitment.build_model(
|
|
||||||
instance=instance,
|
|
||||||
optimizer=Cbc.Optimizer,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Get the number of time steps in the original instance
|
|
||||||
T = instance.time
|
|
||||||
|
|
||||||
# Create decision variables for the new grid component.
|
|
||||||
# In this example, we assume that the new component can
|
|
||||||
# inject up to 10 MW of power at each time step, so we
|
|
||||||
# create new continuous variables 0 ≤ x[t] ≤ 10.
|
|
||||||
@variable(model, x[1:T], lower_bound=0.0, upper_bound=10.0)
|
|
||||||
|
|
||||||
# For each time step
|
|
||||||
for t in 1:T
|
|
||||||
|
|
||||||
# Add production costs to the objective function.
|
|
||||||
# In this example, we assume a cost of $5/MW.
|
|
||||||
set_objective_coefficient(model, x[t], 5.0)
|
|
||||||
|
|
||||||
# Attach the new component to bus b1, by modifying the
|
|
||||||
# constraint `eq_net_injection`.
|
|
||||||
set_normalized_coefficient(
|
|
||||||
model[:eq_net_injection]["b1", t],
|
|
||||||
x[t],
|
|
||||||
1.0,
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Solve the model
|
|
||||||
UnitCommitment.optimize!(model)
|
|
||||||
|
|
||||||
# Show optimal values for the x variables
|
|
||||||
@show value.(x)
|
|
||||||
```
|
|
||||||
|
|
||||||
References
|
|
||||||
----------
|
|
||||||
* [KnOsWa20] **Bernard Knueven, James Ostrowski and Jean-Paul Watson.** "On Mixed-Integer Programming Formulations for the Unit Commitment Problem". INFORMS Journal on Computing (2020). [DOI: 10.1287/ijoc.2019.0944](https://doi.org/10.1287/ijoc.2019.0944)
|
|
||||||
|
|
||||||
62
docs/src/api.md
Normal file
62
docs/src/api.md
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
# API Reference
|
||||||
|
|
||||||
|
## Read data, build model & optimize
|
||||||
|
|
||||||
|
```@docs
|
||||||
|
UnitCommitment.read
|
||||||
|
UnitCommitment.read_benchmark
|
||||||
|
UnitCommitment.build_model
|
||||||
|
UnitCommitment.optimize!
|
||||||
|
UnitCommitment.solution
|
||||||
|
UnitCommitment.validate
|
||||||
|
UnitCommitment.write
|
||||||
|
```
|
||||||
|
|
||||||
|
## Locational Marginal Prices
|
||||||
|
|
||||||
|
### Conventional LMPs
|
||||||
|
```@docs
|
||||||
|
UnitCommitment.compute_lmp(::JuMP.Model,::UnitCommitment.ConventionalLMP)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Approximated Extended LMPs
|
||||||
|
```@docs
|
||||||
|
UnitCommitment.AELMP
|
||||||
|
UnitCommitment.compute_lmp(::JuMP.Model,::UnitCommitment.AELMP)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Modify instance
|
||||||
|
|
||||||
|
```@docs
|
||||||
|
UnitCommitment.slice
|
||||||
|
UnitCommitment.randomize!(::UnitCommitment.UnitCommitmentInstance)
|
||||||
|
UnitCommitment.generate_initial_conditions!
|
||||||
|
```
|
||||||
|
|
||||||
|
## Formulations
|
||||||
|
|
||||||
|
```@docs
|
||||||
|
UnitCommitment.Formulation
|
||||||
|
UnitCommitment.ShiftFactorsFormulation
|
||||||
|
UnitCommitment.ArrCon2000
|
||||||
|
UnitCommitment.CarArr2006
|
||||||
|
UnitCommitment.DamKucRajAta2016
|
||||||
|
UnitCommitment.Gar1962
|
||||||
|
UnitCommitment.KnuOstWat2018
|
||||||
|
UnitCommitment.MorLatRam2013
|
||||||
|
UnitCommitment.PanGua2016
|
||||||
|
UnitCommitment.WanHob2016
|
||||||
|
```
|
||||||
|
|
||||||
|
## Solution Methods
|
||||||
|
|
||||||
|
```@docs
|
||||||
|
UnitCommitment.XavQiuWanThi2019.Method
|
||||||
|
```
|
||||||
|
|
||||||
|
## Randomization Methods
|
||||||
|
|
||||||
|
```@docs
|
||||||
|
UnitCommitment.XavQiuAhm2021.Randomization
|
||||||
|
```
|
||||||
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
36
docs/src/assets/custom.css
Normal file
36
docs/src/assets/custom.css
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
@media screen and (min-width: 1056px) {
|
||||||
|
#documenter .docs-main {
|
||||||
|
max-width: 65rem !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
tbody, thead, pre {
|
||||||
|
border: 1px solid rgba(0, 0, 0, 0.25);
|
||||||
|
}
|
||||||
|
|
||||||
|
table td, th {
|
||||||
|
padding: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table p {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
table td code {
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
table tr,
|
||||||
|
table th {
|
||||||
|
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
table tr:last-child {
|
||||||
|
border-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
code {
|
||||||
|
background-color: transparent;
|
||||||
|
color: rgb(232, 62, 140);
|
||||||
|
}
|
||||||
408
docs/src/format.md
Normal file
408
docs/src/format.md
Normal file
@@ -0,0 +1,408 @@
|
|||||||
|
Data Format
|
||||||
|
===========
|
||||||
|
|
||||||
|
Input Data Format
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
An instance of the stochastic security-constrained unit commitment (SCUC) problem is composed multiple scenarios. Each scenario should be described in an individual JSON file containing the main section belows. For deterministic instances, a single scenario file, following the same format below, may also be provided. Fields that are allowed to differ among scenarios are marked as "uncertain". Fields that are allowed to be time-dependent are marked as "time series".
|
||||||
|
|
||||||
|
* [Parameters](#Parameters)
|
||||||
|
* [Buses](#Buses)
|
||||||
|
* [Generators](#Generators)
|
||||||
|
* [Storage units](#Storage-units)
|
||||||
|
* [Price-sensitive loads](#Price-sensitive-loads)
|
||||||
|
* [Transmission lines](#Transmission-lines)
|
||||||
|
* [Reserves](#Reserves)
|
||||||
|
* [Contingencies](#Contingencies)
|
||||||
|
|
||||||
|
Each section is described in detail below. See [case118/2017-01-01.json.gz](https://axavier.org/UnitCommitment.jl/0.3/instances/matpower/case118/2017-01-01.json.gz) for a complete example.
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
This section describes system-wide parameters, such as power balance penalty, and optimization parameters, such as the length of the planning horizon and the time.
|
||||||
|
|
||||||
|
| Key | Description | Default | Time series? | Uncertain?
|
||||||
|
| :----------------------------- | :------------------------------------------------ | :------: | :------------:| :----------:
|
||||||
|
| `Version` | Version of UnitCommitment.jl this file was written for. Required to ensure that the file remains readable in future versions of the package. If you are following this page to construct the file, this field should equal `0.4`. | Required | No | No
|
||||||
|
| `Time horizon (min)` or `Time horizon (h)` | Length of the planning horizon (in minutes or hours). Either `Time horizon (min)` or `Time horizon (h)` is required, but not both. | Required | No | No
|
||||||
|
| `Time step (min)` | Length of each time step (in minutes). Must be a divisor of 60 (e.g. 60, 30, 20, 15, etc). | `60` | No | No
|
||||||
|
| `Power balance penalty ($/MW)` | Penalty for system-wide shortage or surplus in production (in $/MW). This is charged per time step. For example, if there is a shortage of 1 MW for three time steps, three times this amount will be charged. | `1000.0` | No | Yes
|
||||||
|
| `Scenario name` | Name of the scenario. | `"s1"` | No | ---
|
||||||
|
| `Scenario weight` | Weight of the scenario. The scenario weight can be any positive real number, that is, it does not have to be between zero and one. The package normalizes the weights to ensure that the probability of all scenarios sum up to one. | 1.0 | No | ---
|
||||||
|
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"Parameters": {
|
||||||
|
"Version": "0.3",
|
||||||
|
"Time horizon (h)": 4,
|
||||||
|
"Power balance penalty ($/MW)": 1000.0,
|
||||||
|
"Scenario name": "s1",
|
||||||
|
"Scenario weight": 0.5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Buses
|
||||||
|
|
||||||
|
This section describes the characteristics of each bus in the system.
|
||||||
|
|
||||||
|
| Key | Description | Default | Time series? | Uncertain?
|
||||||
|
| :----------------- | :------------------------------------------------------------ | ------- | :-----------: | :---:
|
||||||
|
| `Load (MW)` | Fixed load connected to the bus (in MW). | Required | Yes | Yes
|
||||||
|
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"Buses": {
|
||||||
|
"b1": {
|
||||||
|
"Load (MW)": 0.0
|
||||||
|
},
|
||||||
|
"b2": {
|
||||||
|
"Load (MW)": [
|
||||||
|
26.01527,
|
||||||
|
24.46212,
|
||||||
|
23.29725,
|
||||||
|
22.90897
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Generators
|
||||||
|
|
||||||
|
This section describes all generators in the system. Two types of units can be specified:
|
||||||
|
|
||||||
|
- **Thermal units:** Units that produce power by converting heat into electrical energy, such as coal and oil power plants. These units use a more complex model, with binary decision variables, and various constraints to enforce ramp rates and minimum up/down time.
|
||||||
|
- **Profiled units:** Simplified model for units that do not require the constraints mentioned above, only a maximum and minimum power output for each time period. Typically used for renewables and hydro.
|
||||||
|
|
||||||
|
#### Thermal Units
|
||||||
|
|
||||||
|
| Key | Description | Default | Time series? | Uncertain?
|
||||||
|
| :------------------------ | :------------------------------------------------| ------- | :-----------: | :---:
|
||||||
|
| `Bus` | Identifier of the bus where this generator is located (string). | Required | No | Yes
|
||||||
|
| `Type` | Type of the generator (string). For thermal generators, this must be `Thermal`. | Required | No | No
|
||||||
|
| `Production cost curve (MW)` and `Production cost curve ($)` | Parameters describing the piecewise-linear production costs. See below for more details. | Required | Yes | Yes
|
||||||
|
| `Startup costs ($)` and `Startup delays (h)` | Parameters describing how much it costs to start the generator after it has been shut down for a certain amount of time. If `Startup costs ($)` and `Startup delays (h)` are set to `[300.0, 400.0]` and `[1, 4]`, for example, and the generator is shut down at time `00:00` (h:min), then it costs \$300 to start up the generator at any time between `01:00` and `03:59`, and \$400 to start the generator at time `04:00` or any time after that. The number of startup cost points is unlimited, and may be different for each generator. Startup delays must be strictly increasing and the first entry must equal `Minimum downtime (h)`. | `[0.0]` and `[1]` | No | Yes
|
||||||
|
| `Minimum uptime (h)` | Minimum amount of time the generator must stay operational after starting up (in hours). For example, if the generator starts up at time `00:00` (h:min) and `Minimum uptime (h)` is set to 4, then the generator can only shut down at time `04:00`. | `1` | No | Yes
|
||||||
|
| `Minimum downtime (h)` | Minimum amount of time the generator must stay offline after shutting down (in hours). For example, if the generator shuts down at time `00:00` (h:min) and `Minimum downtime (h)` is set to 4, then the generator can only start producing power again at time `04:00`. | `1` | No | Yes
|
||||||
|
| `Ramp up limit (MW)` | Maximum increase in production from one time step to the next (in MW). For example, if the generator is producing 100 MW at time step 1 and if this parameter is set to 40 MW, then the generator will produce at most 140 MW at time step 2. | `+inf` | No | Yes
|
||||||
|
| `Ramp down limit (MW)` | Maximum decrease in production from one time step to the next (in MW). For example, if the generator is producing 100 MW at time step 1 and this parameter is set to 40 MW, then the generator will produce at least 60 MW at time step 2. | `+inf` | No | Yes
|
||||||
|
| `Startup limit (MW)` | Maximum amount of power a generator can produce immediately after starting up (in MW). For example, if `Startup limit (MW)` is set to 100 MW and the unit is off at time step 1, then it may produce at most 100 MW at time step 2.| `+inf` | No | Yes
|
||||||
|
| `Shutdown limit (MW)` | Maximum amount of power a generator can produce immediately before shutting down (in MW). Specifically, the generator can only shut down at time step `t+1` if its production at time step `t` is below this limit. | `+inf` | No | Yes
|
||||||
|
| `Initial status (h)` | If set to a positive number, indicates the amount of time (in hours) the generator has been on at the beginning of the simulation, and if set to a negative number, the amount of time the generator has been off. For example, if `Initial status (h)` is `-2`, this means that the generator was off since `-02:00` (h:min). The simulation starts at time `00:00`. If `Initial status (h)` is `3`, this means that the generator was on since `-03:00`. A value of zero is not acceptable. | Required | No | No
|
||||||
|
| `Initial power (MW)` | Amount of power the generator at time step `-1`, immediately before the planning horizon starts. | Required | No | No
|
||||||
|
| `Must run?` | If `true`, the generator should be committed, even if that is not economical (Boolean). | `false` | Yes | Yes
|
||||||
|
| `Reserve eligibility` | List of reserve products this generator is eligibe to provide. By default, the generator is not eligible to provide any reserves. | `[]` | No | Yes
|
||||||
|
| `Commitment status` | List of commitment status over the time horizon. At time `t`, if `true`, the generator must be commited at that time period; if `false`, the generator must not be commited at that time period. If `null` at time `t`, the generator's commitment status is then decided by the model. By default, the status is a list of `null` values. | `null` | Yes | Yes
|
||||||
|
|
||||||
|
#### Profiled Units
|
||||||
|
|
||||||
|
| Key | Description | Default | Time series? | Uncertain?
|
||||||
|
| :---------------- | :------------------------------------------------ | :------: | :------------: | :---:
|
||||||
|
| `Bus` | Identifier of the bus where this generator is located (string). | Required | No | Yes
|
||||||
|
| `Type` | Type of the generator (string). For profiled generators, this must be `Profiled`. | Required | No | No
|
||||||
|
| `Cost ($/MW)` | Cost incurred for serving each MW of power by this generator. | Required | Yes | Yes
|
||||||
|
| `Minimum power (MW)` | Minimum amount of power this generator may supply. | `0.0` | Yes | Yes
|
||||||
|
| `Maximum power (MW)` | Maximum amount of power this generator may supply. | Required | Yes | Yes
|
||||||
|
|
||||||
|
#### Production costs and limits
|
||||||
|
|
||||||
|
Production costs are represented as piecewise-linear curves. Figure 1 shows an example cost curve with three segments, where it costs \$1400, \$1600, \$2200 and \$2400 to generate, respectively, 100, 110, 130 and 135 MW of power. To model this generator, `Production cost curve (MW)` should be set to `[100, 110, 130, 135]`, and `Production cost curve ($)` should be set to `[1400, 1600, 2200, 2400]`.
|
||||||
|
Note that this curve also specifies the production limits. Specifically, the first point identifies the minimum power output when the unit is operational, while the last point identifies the maximum power output.
|
||||||
|
|
||||||
|
```@raw html
|
||||||
|
<center>
|
||||||
|
<img src="../assets/cost_curve.png" style="max-width: 500px"/>
|
||||||
|
<div><b>Figure 1.</b> Piecewise-linear production cost curve.</div>
|
||||||
|
<br/>
|
||||||
|
</center>
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Additional remarks:
|
||||||
|
|
||||||
|
* For time-dependent production limits or time-dependent production costs, the usage of nested arrays is allowed. For example, if `Production cost curve (MW)` is set to `[5.0, [10.0, 12.0, 15.0, 20.0]]`, then the unit may generate at most 10, 12, 15 and 20 MW of power during time steps 1, 2, 3 and 4, respectively. The minimum output for all time periods is fixed to at 5 MW.
|
||||||
|
* There is no limit to the number of piecewise-linear segments, and different generators may have a different number of segments.
|
||||||
|
* If `Production cost curve (MW)` and `Production cost curve ($)` both contain a single element, then the generator must produce exactly that amount of power when operational. To specify that the generator may produce any amount of power up to a certain limit `P`, the parameter `Production cost curve (MW)` should be set to `[0, P]`.
|
||||||
|
* Production cost curves must be convex.
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"Generators": {
|
||||||
|
"gen1": {
|
||||||
|
"Bus": "b1",
|
||||||
|
"Type": "Thermal",
|
||||||
|
"Production cost curve (MW)": [100.0, 110.0, 130.0, 135.0],
|
||||||
|
"Production cost curve ($)": [1400.0, 1600.0, 2200.0, 2400.0],
|
||||||
|
"Startup costs ($)": [300.0, 400.0],
|
||||||
|
"Startup delays (h)": [1, 4],
|
||||||
|
"Ramp up limit (MW)": 232.68,
|
||||||
|
"Ramp down limit (MW)": 232.68,
|
||||||
|
"Startup limit (MW)": 232.68,
|
||||||
|
"Shutdown limit (MW)": 232.68,
|
||||||
|
"Minimum downtime (h)": 4,
|
||||||
|
"Minimum uptime (h)": 4,
|
||||||
|
"Initial status (h)": 12,
|
||||||
|
"Initial power (MW)": 115,
|
||||||
|
"Must run?": false,
|
||||||
|
"Reserve eligibility": ["r1"]
|
||||||
|
},
|
||||||
|
"gen2": {
|
||||||
|
"Bus": "b5",
|
||||||
|
"Type": "Thermal",
|
||||||
|
"Production cost curve (MW)": [0.0, [10.0, 8.0, 0.0, 3.0]],
|
||||||
|
"Production cost curve ($)": [0.0, 0.0],
|
||||||
|
"Initial status (h)": -100,
|
||||||
|
"Initial power (MW)": 0,
|
||||||
|
"Reserve eligibility": ["r1", "r2"],
|
||||||
|
"Commitment status": [true, false, null, true]
|
||||||
|
},
|
||||||
|
"gen3": {
|
||||||
|
"Bus": "b6",
|
||||||
|
"Type": "Profiled",
|
||||||
|
"Minimum power (MW)": 10.0,
|
||||||
|
"Maximum power (MW)": 120.0,
|
||||||
|
"Cost ($/MW)": 100.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Storage units
|
||||||
|
|
||||||
|
This section describes energy storage units in the system which charge and discharge power. The storage units consume power while charging, and generate power while discharging.
|
||||||
|
|
||||||
|
| Key | Description | Default | Time series? | Uncertain?
|
||||||
|
| :---------------- | :------------------------------------------------ | :------: | :------------: | :----:
|
||||||
|
| `Bus` | Bus where the storage unit is located. Multiple storage units may be placed at the same bus. | Required | No | Yes
|
||||||
|
| `Minimum level (MWh)` | Minimum of energy level this storage unit may contain. | `0.0` | Yes | Yes
|
||||||
|
| `Maximum level (MWh)` | Maximum of energy level this storage unit may contain. | Required | Yes | Yes
|
||||||
|
| `Allow simultaneous charging and discharging` | If `false`, the storage unit is not allowed to charge and discharge at the same time (Boolean). | `true` | Yes | Yes
|
||||||
|
| `Charge cost ($/MW)` | Cost incurred for charging each MW of power into this storage unit. | Required | Yes | Yes
|
||||||
|
| `Discharge cost ($/MW)` | Cost incurred for discharging each MW of power from this storage unit. | Required | Yes | Yes
|
||||||
|
| `Charge efficiency` | Efficiency rate to charge power into this storage unit. This value must be greater than or equal to `0.0`, and less than or equal to `1.0`. | `1.0` | Yes | Yes
|
||||||
|
| `Discharge efficiency` | Efficiency rate to discharge power from this storage unit. This value must be greater than or equal to `0.0`, and less than or equal to `1.0`. | `1.0` | Yes | Yes
|
||||||
|
| `Loss factor` | The energy dissipation rate of this storage unit. This value must be greater than or equal to `0.0`, and less than or equal to `1.0`. | `0.0` | Yes | Yes
|
||||||
|
| `Minimum charge rate (MW)` | Minimum amount of power rate this storage unit may charge. | `0.0` | Yes | Yes
|
||||||
|
| `Maximum charge rate (MW)` | Maximum amount of power rate this storage unit may charge. | Required | Yes | Yes
|
||||||
|
| `Minimum discharge rate (MW)` | Minimum amount of power rate this storage unit may discharge. | `0.0` | Yes | Yes
|
||||||
|
| `Maximum discharge rate (MW)` | Maximum amount of power rate this storage unit may discharge. | Required | Yes | Yes
|
||||||
|
| `Initial level (MWh)` | Amount of energy this storage unit at time step `-1`, immediately before the planning horizon starts. | `0.0` | No | Yes
|
||||||
|
| `Last period minimum level (MWh)` | Minimum of energy level this storage unit may contain in the last time step. By default, this value is the same as the last value of `Minimum level (MWh)`. | `Minimum level (MWh)` | No | Yes
|
||||||
|
| `Last period maximum level (MWh)` | Maximum of energy level this storage unit may contain in the last time step. By default, this value is the same as the last value of `Maximum level (MWh)`. | `Maximum level (MWh)` | No | Yes
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"Storage units": {
|
||||||
|
"su1": {
|
||||||
|
"Bus": "b2",
|
||||||
|
"Maximum level (MWh)": 100.0,
|
||||||
|
"Charge cost ($/MW)": 2.0,
|
||||||
|
"Discharge cost ($/MW)": 2.5,
|
||||||
|
"Maximum charge rate (MW)": 10.0,
|
||||||
|
"Maximum discharge rate (MW)": 8.0
|
||||||
|
},
|
||||||
|
"su2": {
|
||||||
|
"Bus": "b2",
|
||||||
|
"Minimum level (MWh)": 10.0,
|
||||||
|
"Maximum level (MWh)": 100.0,
|
||||||
|
"Allow simultaneous charging and discharging": false,
|
||||||
|
"Charge cost ($/MW)": 3.0,
|
||||||
|
"Discharge cost ($/MW)": 3.5,
|
||||||
|
"Charge efficiency": 0.8,
|
||||||
|
"Discharge efficiency": 0.85,
|
||||||
|
"Loss factor": 0.01,
|
||||||
|
"Minimum charge rate (MW)": 5.0,
|
||||||
|
"Maximum charge rate (MW)": 10.0,
|
||||||
|
"Minimum discharge rate (MW)": 2.0,
|
||||||
|
"Maximum discharge rate (MW)": 10.0,
|
||||||
|
"Initial level (MWh)": 70.0,
|
||||||
|
"Last period minimum level (MWh)": 80.0,
|
||||||
|
"Last period maximum level (MWh)": 85.0
|
||||||
|
},
|
||||||
|
"su3": {
|
||||||
|
"Bus": "b9",
|
||||||
|
"Minimum level (MWh)": [10.0, 11.0, 12.0, 13.0],
|
||||||
|
"Maximum level (MWh)": [100.0, 110.0, 120.0, 130.0],
|
||||||
|
"Allow simultaneous charging and discharging": [false, false, true, true],
|
||||||
|
"Charge cost ($/MW)": [2.0, 2.1, 2.2, 2.3],
|
||||||
|
"Discharge cost ($/MW)": [1.0, 1.1, 1.2, 1.3],
|
||||||
|
"Charge efficiency": [0.8, 0.81, 0.82, 0.82],
|
||||||
|
"Discharge efficiency": [0.85, 0.86, 0.87, 0.88],
|
||||||
|
"Loss factor": [0.01, 0.01, 0.02, 0.02],
|
||||||
|
"Minimum charge rate (MW)": [5.0, 5.1, 5.2, 5.3],
|
||||||
|
"Maximum charge rate (MW)": [10.0, 10.1, 10.2, 10.3],
|
||||||
|
"Minimum discharge rate (MW)": [4.0, 4.1, 4.2, 4.3],
|
||||||
|
"Maximum discharge rate (MW)": [8.0, 8.1, 8.2, 8.3],
|
||||||
|
"Initial level (MWh)": 20.0,
|
||||||
|
"Last period minimum level (MWh)": 21.0,
|
||||||
|
"Last period maximum level (MWh)": 22.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Price-sensitive loads
|
||||||
|
|
||||||
|
This section describes components in the system which may increase or reduce their energy consumption according to the energy prices. Fixed loads (as described in the `buses` section) are always served, regardless of the price, unless there is significant congestion in the system or insufficient production capacity. Price-sensitive loads, on the other hand, are only served if it is economical to do so.
|
||||||
|
|
||||||
|
| Key | Description | Default | Time series? | Uncertain?
|
||||||
|
| :---------------- | :------------------------------------------------ | :------: | :------------: | :----:
|
||||||
|
| `Bus` | Bus where the load is located. Multiple price-sensitive loads may be placed at the same bus. | Required | No | Yes
|
||||||
|
| `Revenue ($/MW)` | Revenue obtained for serving each MW of power to this load. | Required | Yes | Yes
|
||||||
|
| `Demand (MW)` | Maximum amount of power required by this load. Any amount lower than this may be served. | Required | Yes | Yes
|
||||||
|
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"Price-sensitive loads": {
|
||||||
|
"p1": {
|
||||||
|
"Bus": "b3",
|
||||||
|
"Revenue ($/MW)": 23.0,
|
||||||
|
"Demand (MW)": 50.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Transmission lines
|
||||||
|
|
||||||
|
This section describes the characteristics of transmission system, such as its topology and the susceptance of each transmission line.
|
||||||
|
|
||||||
|
| Key | Description | Default | Time series? | Uncertain?
|
||||||
|
| :--------------------- | :----------------------------------------------- | ------- | :------------: | :---:
|
||||||
|
| `Source bus` | Identifier of the bus where the transmission line originates. | Required | No | Yes
|
||||||
|
| `Target bus` | Identifier of the bus where the transmission line reaches. | Required | No | Yes
|
||||||
|
| `Susceptance (S)` | Susceptance of the transmission line (in siemens). | Required | No | Yes
|
||||||
|
| `Normal flow limit (MW)` | Maximum amount of power (in MW) allowed to flow through the line when the system is in its regular, fully-operational state. | `+inf` | Yes | Yes
|
||||||
|
| `Emergency flow limit (MW)` | Maximum amount of power (in MW) allowed to flow through the line when the system is in degraded state (for example, after the failure of another transmission line). | `+inf` | Y | Yes
|
||||||
|
| `Flow limit penalty ($/MW)` | Penalty for violating the flow limits of the transmission line (in $/MW). This is charged per time step. For example, if there is a thermal violation of 1 MW for three time steps, then three times this amount will be charged. | `5000.0` | Yes | Yes
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"Transmission lines": {
|
||||||
|
"l1": {
|
||||||
|
"Source bus": "b1",
|
||||||
|
"Target bus": "b2",
|
||||||
|
"Susceptance (S)": 29.49686,
|
||||||
|
"Normal flow limit (MW)": 15000.0,
|
||||||
|
"Emergency flow limit (MW)": 20000.0,
|
||||||
|
"Flow limit penalty ($/MW)": 5000.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Reserves
|
||||||
|
|
||||||
|
This section describes the hourly amount of reserves required.
|
||||||
|
|
||||||
|
|
||||||
|
| Key | Description | Default | Time series? | Uncertain?
|
||||||
|
| :-------------------- | :------------------------------------------------- | --------- | :----: | :---:
|
||||||
|
| `Type` | Type of reserve product. Must be either "spinning" or "flexiramp". | Required | No | No
|
||||||
|
| `Amount (MW)` | Amount of reserves required. | Required | Yes | Yes
|
||||||
|
| `Shortfall penalty ($/MW)` | Penalty for shortage in meeting the reserve requirements (in $/MW). This is charged per time step. Negative value implies reserve constraints must always be satisfied. | `-1` | Yes | Yes
|
||||||
|
|
||||||
|
#### Example 1
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"Reserves": {
|
||||||
|
"r1": {
|
||||||
|
"Type": "spinning",
|
||||||
|
"Amount (MW)": [
|
||||||
|
57.30552,
|
||||||
|
53.88429,
|
||||||
|
51.31838,
|
||||||
|
50.46307
|
||||||
|
],
|
||||||
|
"Shortfall penalty ($/MW)": 5.0
|
||||||
|
},
|
||||||
|
"r2": {
|
||||||
|
"Type": "flexiramp",
|
||||||
|
"Amount (MW)": [
|
||||||
|
20.31042,
|
||||||
|
23.65273,
|
||||||
|
27.41784,
|
||||||
|
25.34057
|
||||||
|
],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Contingencies
|
||||||
|
|
||||||
|
This section describes credible contingency scenarios in the optimization, such as the loss of a transmission line or generator.
|
||||||
|
|
||||||
|
| Key | Description | Default | Uncertain?
|
||||||
|
| :-------------------- | :----------------------------------------------- | :--------: | :---:
|
||||||
|
| `Affected generators` | List of generators affected by this contingency. May be omitted if no generators are affected. | `[]` | Yes
|
||||||
|
| `Affected lines` | List of transmission lines affected by this contingency. May be omitted if no lines are affected. | `[]` | Yes
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"Contingencies": {
|
||||||
|
"c1": {
|
||||||
|
"Affected lines": ["l1", "l2", "l3"],
|
||||||
|
"Affected generators": ["g1"]
|
||||||
|
},
|
||||||
|
"c2": {
|
||||||
|
"Affected lines": ["l4"]
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Additional remarks
|
||||||
|
|
||||||
|
#### Time series parameters
|
||||||
|
|
||||||
|
Many numerical properties in the JSON file can be specified either as a single floating point number if they are time-independent, or as an array containing exactly `T` elements, if they are time-dependent, where `T` is the number of time steps in the planning horizon. For example, both formats below are valid when `T=3`:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"Load (MW)": 800.0,
|
||||||
|
"Load (MW)": [800.0, 850.0, 730.0]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The value `T` depends on both `Time horizon (h)` and `Time step (min)`, as the table below illustrates.
|
||||||
|
|
||||||
|
Time horizon (h) | Time step (min) | T
|
||||||
|
:---------------:|:---------------:|:----:
|
||||||
|
24 | 60 | 24
|
||||||
|
24 | 15 | 96
|
||||||
|
24 | 5 | 288
|
||||||
|
36 | 60 | 36
|
||||||
|
36 | 15 | 144
|
||||||
|
36 | 5 | 432
|
||||||
|
|
||||||
|
Output Data Format
|
||||||
|
------------------
|
||||||
|
|
||||||
|
The output data format is also JSON-based, but it is not currently documented since we expect it to change significantly in a future version of the package.
|
||||||
|
|
||||||
|
|
||||||
|
Current limitations
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
* Network topology must remain the same for all time periods.
|
||||||
|
* Only N-1 transmission contingencies are supported. Generator contingencies are not currently supported.
|
||||||
|
* Time-varying minimum production amounts are not currently compatible with ramp/startup/shutdown limits.
|
||||||
|
* Flexible ramping products can only be acquired under the `WanHob2016` formulation, which does not support spinning reserves.
|
||||||
|
* The set of generators must be the same in all scenarios.
|
||||||
@@ -1,29 +1,29 @@
|
|||||||
# UnitCommitment.jl
|
# UnitCommitment.jl
|
||||||
|
|
||||||
**UnitCommitment.jl** (UC.jl) is a Julia/JuMP optimization package for the Security-Constrained Unit Commitment Problem (SCUC), a fundamental optimization problem in power systems used, for example, to clear the day-ahead electricity markets. The package provides benchmark instances for the problem and Julia/JuMP implementations of state-of-the-art mixed-integer programming formulations.
|
**UnitCommitment.jl** (UC.jl) is an optimization package for the Security-Constrained Unit Commitment Problem (SCUC), a fundamental optimization problem in power systems used, for example, to clear the day-ahead electricity markets. Both deterministic and two-stage stochastic versions of the problem are supported. The package provides benchmark instances for the problem, a flexible and well-documented data format for the problem, as well as Julia/JuMP implementations of state-of-the-art mixed-integer programming formulations and solution methods.
|
||||||
|
|
||||||
## Package Components
|
## Package Components
|
||||||
|
|
||||||
* **Data Format:** The package proposes an extensible and fully-documented JSON-based data specification format for SCUC, developed in collaboration with Independent System Operators (ISOs), which describes the most important aspects of the problem. The format supports all the most common generator characteristics (including ramping, piecewise-linear production cost curves and time-dependent startup costs), as well as operating reserves, price-sensitive loads, transmission networks and contingencies.
|
* **Data Format:** The package proposes an extensible and fully-documented JSON-based data specification format for SCUC, developed in collaboration with Independent System Operators (ISOs), which describes the most important aspects of the problem. The format supports all the most common thermal generator characteristics (including ramping, piecewise-linear production cost curves and time-dependent startup costs), as well as profiled generators, reserves, price-sensitive loads, battery storage, transmission, and contingencies.
|
||||||
* **Benchmark Instances:** The package provides a diverse collection of large-scale benchmark instances collected from the literature, converted into a common data format, and extended using data-driven methods to make them more challenging and realistic.
|
* **Benchmark Instances:** The package provides a diverse collection of large-scale benchmark instances collected from the literature, converted into a common data format, and extended using data-driven methods to make them more challenging and realistic.
|
||||||
* **Model Implementation**: The package provides a Julia/JuMP implementations of state-of-the-art formulations and solution methods for SCUC, including multiple ramping formulations ([ArrCon2000][ArrCon2000], [MorLatRam2013][MorLatRam2013], [DamKucRajAta2016][DamKucRajAta2016], [PanGua2016][PanGua2016]), multiple piecewise-linear costs formulations ([Gar1962][Gar1962], [CarArr2006][CarArr2006], [KnuOstWat2018][KnuOstWat2018]) and contingency screening methods ([XavQiuWanThi2019][XavQiuWanThi2019]). Our goal is to keep these implementations up-to-date as new methods are proposed in the literature.
|
* **Model Implementation**: The package provides a Julia/JuMP implementations of state-of-the-art formulations and solution methods for the deterministic and stochastic SCUC, including multiple ramping formulations ([ArrCon2000](https://doi.org/10.1109/59.871739), [MorLatRam2013](https://doi.org/10.1109/TPWRS.2013.2251373), [DamKucRajAta2016](https://doi.org/10.1007/s10107-015-0919-9), [PanGua2016](https://doi.org/10.1287/opre.2016.1520)), piecewise-linear costs formulations ([Gar1962](https://doi.org/10.1109/AIEEPAS.1962.4501405), [CarArr2006](https://doi.org/10.1109/TPWRS.2006.876672), [KnuOstWat2018](https://doi.org/10.1109/TPWRS.2017.2783850)), contingency screening methods ([XavQiuWanThi2019](https://doi.org/10.1109/TPWRS.2019.2892620)) and decomposition methods. Our goal is to keep these implementations up-to-date as new methods are proposed in the literature.
|
||||||
* **Benchmark Tools:** The package provides automated benchmark scripts to accurately evaluate the performance impact of proposed code changes.
|
* **Benchmark Tools:** The package provides automated benchmark scripts to accurately evaluate the performance impact of proposed code changes.
|
||||||
|
|
||||||
[ArrCon2000]: https://doi.org/10.1109/59.871739
|
## Table of Contents
|
||||||
[CarArr2006]: https://doi.org/10.1109/TPWRS.2006.876672
|
|
||||||
[DamKucRajAta2016]: https://doi.org/10.1007/s10107-015-0919-9
|
|
||||||
[Gar1962]: https://doi.org/10.1109/AIEEPAS.1962.4501405
|
|
||||||
[KnuOstWat2018]: https://doi.org/10.1109/TPWRS.2017.2783850
|
|
||||||
[MorLatRam2013]: https://doi.org/10.1109/TPWRS.2013.2251373
|
|
||||||
[PanGua2016]: https://doi.org/10.1287/opre.2016.1520
|
|
||||||
[XavQiuWanThi2019]: https://doi.org/10.1109/TPWRS.2019.2892620
|
|
||||||
|
|
||||||
### Authors
|
```@contents
|
||||||
|
Pages = ["usage.md", "format.md", "instances.md", "model.md", "api.md"]
|
||||||
|
Depth = 3
|
||||||
|
```
|
||||||
|
|
||||||
|
## Authors
|
||||||
* **Alinson S. Xavier** (Argonne National Laboratory)
|
* **Alinson S. Xavier** (Argonne National Laboratory)
|
||||||
* **Aleksandr M. Kazachkov** (University of Florida)
|
* **Aleksandr M. Kazachkov** (University of Florida)
|
||||||
|
* **Ogün Yurdakul** (Technische Universität Berlin)
|
||||||
|
* **Jun He** (Purdue University)
|
||||||
* **Feng Qiu** (Argonne National Laboratory)
|
* **Feng Qiu** (Argonne National Laboratory)
|
||||||
|
|
||||||
### Acknowledgments
|
## Acknowledgments
|
||||||
|
|
||||||
* We would like to thank **Yonghong Chen** (Midcontinent Independent System Operator), **Feng Pan** (Pacific Northwest National Laboratory) for valuable feedback on early versions of this package.
|
* We would like to thank **Yonghong Chen** (Midcontinent Independent System Operator), **Feng Pan** (Pacific Northwest National Laboratory) for valuable feedback on early versions of this package.
|
||||||
|
|
||||||
@@ -31,19 +31,19 @@
|
|||||||
|
|
||||||
* Based upon work supported by the **U.S. Department of Energy Advanced Grid Modeling Program** under Grant DE-OE0000875.
|
* Based upon work supported by the **U.S. Department of Energy Advanced Grid Modeling Program** under Grant DE-OE0000875.
|
||||||
|
|
||||||
### Citing
|
## Citing
|
||||||
|
|
||||||
If you use UnitCommitment.jl in your research (instances, models or algorithms), we kindly request that you cite the package as follows:
|
If you use UnitCommitment.jl in your research (instances, models or algorithms), we kindly request that you cite the package as follows:
|
||||||
|
|
||||||
* **Alinson S. Xavier, Aleksandr M. Kazachkov, Feng Qiu**, "UnitCommitment.jl: A Julia/JuMP Optimization Package for Security-Constrained Unit Commitment". Zenodo (2020). [DOI: 10.5281/zenodo.4269874](https://doi.org/10.5281/zenodo.4269874).
|
* **Alinson S. Xavier, Aleksandr M. Kazachkov, Ogün Yurdakul, Jun He, Feng Qiu**, "UnitCommitment.jl: A Julia/JuMP Optimization Package for Security-Constrained Unit Commitment (Version 0.4)". Zenodo (2023). [DOI: 10.5281/zenodo.4269874](https://doi.org/10.5281/zenodo.4269874).
|
||||||
|
|
||||||
If you use the instances, we additionally request that you cite the original sources, as described in the [instances page](instances.md).
|
If you use the instances, we additionally request that you cite the original sources, as described in the [instances page](instances.md).
|
||||||
|
|
||||||
### License
|
## License
|
||||||
|
|
||||||
```text
|
```text
|
||||||
UnitCommitment.jl: A Julia/JuMP Optimization Package for Security-Constrained Unit Commitment
|
UnitCommitment.jl: A Julia/JuMP Optimization Package for Security-Constrained Unit Commitment
|
||||||
Copyright © 2020, UChicago Argonne, LLC. All Rights Reserved.
|
Copyright © 2020-2023, UChicago Argonne, LLC. All Rights Reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification, are permitted
|
Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
provided that the following conditions are met:
|
provided that the following conditions are met:
|
||||||
@@ -67,16 +67,3 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING N
|
|||||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
POSSIBILITY OF SUCH DAMAGE.
|
POSSIBILITY OF SUCH DAMAGE.
|
||||||
```
|
```
|
||||||
|
|
||||||
## Site contents
|
|
||||||
|
|
||||||
```{toctree}
|
|
||||||
---
|
|
||||||
maxdepth: 2
|
|
||||||
---
|
|
||||||
usage.md
|
|
||||||
format.md
|
|
||||||
instances.md
|
|
||||||
model.md
|
|
||||||
```
|
|
||||||
|
|
||||||
@@ -1,19 +1,11 @@
|
|||||||
```{sectnum}
|
|
||||||
---
|
|
||||||
start: 3
|
|
||||||
depth: 2
|
|
||||||
suffix: .
|
|
||||||
---
|
|
||||||
```
|
|
||||||
|
|
||||||
Instances
|
Instances
|
||||||
=========
|
=========
|
||||||
|
|
||||||
UnitCommitment.jl provides a large collection of benchmark instances collected from the literature and converted to a [common data format](format.md). In some cases, as indicated below, the original instances have been extended, with realistic parameters, using data-driven methods. If you use these instances in your research, we request that you cite UnitCommitment.jl, as well as the original sources, as listed below. Benchmark instances can be loaded with `UnitCommitment.read_benchmark(name)`, as explained in the [usage section](usage.md).
|
UnitCommitment.jl provides a large collection of benchmark instances collected from the literature and converted to a [common data format](format.md). In some cases, as indicated below, the original instances have been extended, with realistic parameters, using data-driven methods. If you use these instances in your research, we request that you cite UnitCommitment.jl, as well as the original sources, as listed below. Benchmark instances can be loaded with `UnitCommitment.read_benchmark(name)`, as explained in the [usage section](usage.md). Instance files can also be [directly downloaded from our website](https://axavier.org/UnitCommitment.jl/0.3/instances/).
|
||||||
|
|
||||||
|
!!! warning
|
||||||
|
|
||||||
```{warning}
|
|
||||||
The instances included in UC.jl are still under development and may change in the future. If you use these instances in your research, for reproducibility, you should specify what version of UC.jl they came from.
|
The instances included in UC.jl are still under development and may change in the future. If you use these instances in your research, for reproducibility, you should specify what version of UC.jl they came from.
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
MATPOWER
|
MATPOWER
|
||||||
@@ -33,7 +25,7 @@ Because most MATPOWER test cases were originally designed for power flow studies
|
|||||||
|
|
||||||
* **Contingencies** were set to include all N-1 transmission line contingencies that do not generate islands or isolated buses. More specifically, there is one contingency for each transmission line, as long as that transmission line is not a bridge in the network graph.
|
* **Contingencies** were set to include all N-1 transmission line contingencies that do not generate islands or isolated buses. More specifically, there is one contingency for each transmission line, as long as that transmission line is not a bridge in the network graph.
|
||||||
|
|
||||||
For each MATPOWER test case, UC.jl provides two variations (`2017-02-01` and `2017-08-01`) corresponding respectively to a winter and to a summer test case.
|
For each MATPOWER test case, UC.jl provides 365 variations (`2017-01-01` to `2017-12-31`) corresponding different days of the year.
|
||||||
|
|
||||||
### MATPOWER/UW-PSTCA
|
### MATPOWER/UW-PSTCA
|
||||||
|
|
||||||
@@ -41,11 +33,11 @@ A variety of smaller IEEE test cases, [compiled by University of Washington](htt
|
|||||||
|
|
||||||
| Name | Buses | Generators | Lines | Contingencies | References |
|
| Name | Buses | Generators | Lines | Contingencies | References |
|
||||||
|------|-------|------------|-------|---------------|--------|
|
|------|-------|------------|-------|---------------|--------|
|
||||||
| `matpower/case14/2017-02-01` | 14 | 5 | 20 | 19 | [MTPWR, PSTCA]
|
| `matpower/case14/2017-01-01` | 14 | 5 | 20 | 19 | [MTPWR, PSTCA]
|
||||||
| `matpower/case30/2017-02-01` | 30 | 6 | 41 | 38 | [MTPWR, PSTCA]
|
| `matpower/case30/2017-01-01` | 30 | 6 | 41 | 38 | [MTPWR, PSTCA]
|
||||||
| `matpower/case57/2017-02-01` | 57 | 7 | 80 | 79 | [MTPWR, PSTCA]
|
| `matpower/case57/2017-01-01` | 57 | 7 | 80 | 79 | [MTPWR, PSTCA]
|
||||||
| `matpower/case118/2017-02-01` | 118 | 54 | 186 | 177 | [MTPWR, PSTCA]
|
| `matpower/case118/2017-01-01` | 118 | 54 | 186 | 177 | [MTPWR, PSTCA]
|
||||||
| `matpower/case300/2017-02-01` | 300 | 69 | 411 | 320 | [MTPWR, PSTCA]
|
| `matpower/case300/2017-01-01` | 300 | 69 | 411 | 320 | [MTPWR, PSTCA]
|
||||||
|
|
||||||
|
|
||||||
### MATPOWER/Polish
|
### MATPOWER/Polish
|
||||||
@@ -54,14 +46,14 @@ Test cases based on the Polish 400, 220 and 110 kV networks, originally provided
|
|||||||
|
|
||||||
| Name | Buses | Generators | Lines | Contingencies | References |
|
| Name | Buses | Generators | Lines | Contingencies | References |
|
||||||
|------|-------|------------|-------|---------------|--------|
|
|------|-------|------------|-------|---------------|--------|
|
||||||
| `matpower/case2383wp/2017-02-01` | 2383 | 323 | 2896 | 2240 | [MTPWR]
|
| `matpower/case2383wp/2017-01-01` | 2383 | 323 | 2896 | 2240 | [MTPWR]
|
||||||
| `matpower/case2736sp/2017-02-01` | 2736 | 289 | 3504 | 3159 | [MTPWR]
|
| `matpower/case2736sp/2017-01-01` | 2736 | 289 | 3504 | 3159 | [MTPWR]
|
||||||
| `matpower/case2737sop/2017-02-01` | 2737 | 267 | 3506 | 3161 | [MTPWR]
|
| `matpower/case2737sop/2017-01-01` | 2737 | 267 | 3506 | 3161 | [MTPWR]
|
||||||
| `matpower/case2746wop/2017-02-01` | 2746 | 443 | 3514 | 3155 | [MTPWR]
|
| `matpower/case2746wop/2017-01-01` | 2746 | 443 | 3514 | 3155 | [MTPWR]
|
||||||
| `matpower/case2746wp/2017-02-01` | 2746 | 457 | 3514 | 3156 | [MTPWR]
|
| `matpower/case2746wp/2017-01-01` | 2746 | 457 | 3514 | 3156 | [MTPWR]
|
||||||
| `matpower/case3012wp/2017-02-01` | 3012 | 496 | 3572 | 2854 | [MTPWR]
|
| `matpower/case3012wp/2017-01-01` | 3012 | 496 | 3572 | 2854 | [MTPWR]
|
||||||
| `matpower/case3120sp/2017-02-01` | 3120 | 483 | 3693 | 2950 | [MTPWR]
|
| `matpower/case3120sp/2017-01-01` | 3120 | 483 | 3693 | 2950 | [MTPWR]
|
||||||
| `matpower/case3375wp/2017-02-01` | 3374 | 590 | 4161 | 3245 | [MTPWR]
|
| `matpower/case3375wp/2017-01-01` | 3374 | 590 | 4161 | 3245 | [MTPWR]
|
||||||
|
|
||||||
### MATPOWER/PEGASE
|
### MATPOWER/PEGASE
|
||||||
|
|
||||||
@@ -69,11 +61,11 @@ Test cases from the [Pan European Grid Advanced Simulation and State Estimation
|
|||||||
|
|
||||||
| Name | Buses | Generators | Lines | Contingencies | References |
|
| Name | Buses | Generators | Lines | Contingencies | References |
|
||||||
|------|-------|------------|-------|---------------|--------|
|
|------|-------|------------|-------|---------------|--------|
|
||||||
| `matpower/case89pegase/2017-02-01` | 89 | 12 | 210 | 192 | [JoFlMa16, FlPaCa13, MTPWR]
|
| `matpower/case89pegase/2017-01-01` | 89 | 12 | 210 | 192 | [JoFlMa16, FlPaCa13, MTPWR]
|
||||||
| `matpower/case1354pegase/2017-02-01` | 1354 | 260 | 1991 | 1288 | [JoFlMa16, FlPaCa13, MTPWR]
|
| `matpower/case1354pegase/2017-01-01` | 1354 | 260 | 1991 | 1288 | [JoFlMa16, FlPaCa13, MTPWR]
|
||||||
| `matpower/case2869pegase/2017-02-01` | 2869 | 510 | 4582 | 3579 | [JoFlMa16, FlPaCa13, MTPWR]
|
| `matpower/case2869pegase/2017-01-01` | 2869 | 510 | 4582 | 3579 | [JoFlMa16, FlPaCa13, MTPWR]
|
||||||
| `matpower/case9241pegase/2017-02-01` | 9241 | 1445 | 16049 | 13932 | [JoFlMa16, FlPaCa13, MTPWR]
|
| `matpower/case9241pegase/2017-01-01` | 9241 | 1445 | 16049 | 13932 | [JoFlMa16, FlPaCa13, MTPWR]
|
||||||
| `matpower/case13659pegase/2017-02-01` | 13659 | 4092 | 20467 | 13932 | [JoFlMa16, FlPaCa13, MTPWR]
|
| `matpower/case13659pegase/2017-01-01` | 13659 | 4092 | 20467 | 13932 | [JoFlMa16, FlPaCa13, MTPWR]
|
||||||
|
|
||||||
### MATPOWER/RTE
|
### MATPOWER/RTE
|
||||||
|
|
||||||
@@ -81,14 +73,14 @@ Test cases from the R&D Division at [Reseau de Transport d'Electricite](https://
|
|||||||
|
|
||||||
| Name | Buses | Generators | Lines | Contingencies | References |
|
| Name | Buses | Generators | Lines | Contingencies | References |
|
||||||
|------|-------|------------|-------|---------------|--------|
|
|------|-------|------------|-------|---------------|--------|
|
||||||
| `matpower/case1888rte/2017-02-01` | 1888 | 296 | 2531 | 1484 | [MTPWR, JoFlMa16]
|
| `matpower/case1888rte/2017-01-01` | 1888 | 296 | 2531 | 1484 | [MTPWR, JoFlMa16]
|
||||||
| `matpower/case1951rte/2017-02-01` | 1951 | 390 | 2596 | 1497 | [MTPWR, JoFlMa16]
|
| `matpower/case1951rte/2017-01-01` | 1951 | 390 | 2596 | 1497 | [MTPWR, JoFlMa16]
|
||||||
| `matpower/case2848rte/2017-02-01` | 2848 | 544 | 3776 | 2242 | [MTPWR, JoFlMa16]
|
| `matpower/case2848rte/2017-01-01` | 2848 | 544 | 3776 | 2242 | [MTPWR, JoFlMa16]
|
||||||
| `matpower/case2868rte/2017-02-01` | 2868 | 596 | 3808 | 2260 | [MTPWR, JoFlMa16]
|
| `matpower/case2868rte/2017-01-01` | 2868 | 596 | 3808 | 2260 | [MTPWR, JoFlMa16]
|
||||||
| `matpower/case6468rte/2017-02-01` | 6468 | 1262 | 9000 | 6094 | [MTPWR, JoFlMa16]
|
| `matpower/case6468rte/2017-01-01` | 6468 | 1262 | 9000 | 6094 | [MTPWR, JoFlMa16]
|
||||||
| `matpower/case6470rte/2017-02-01` | 6470 | 1306 | 9005 | 6085 | [MTPWR, JoFlMa16]
|
| `matpower/case6470rte/2017-01-01` | 6470 | 1306 | 9005 | 6085 | [MTPWR, JoFlMa16]
|
||||||
| `matpower/case6495rte/2017-02-01` | 6495 | 1352 | 9019 | 6060 | [MTPWR, JoFlMa16]
|
| `matpower/case6495rte/2017-01-01` | 6495 | 1352 | 9019 | 6060 | [MTPWR, JoFlMa16]
|
||||||
| `matpower/case6515rte/2017-02-01` | 6515 | 1368 | 9037 | 6063 | [MTPWR, JoFlMa16]
|
| `matpower/case6515rte/2017-01-01` | 6515 | 1368 | 9037 | 6063 | [MTPWR, JoFlMa16]
|
||||||
|
|
||||||
|
|
||||||
PGLIB-UC Instances
|
PGLIB-UC Instances
|
||||||
@@ -288,7 +280,7 @@ Tejada19
|
|||||||
References
|
References
|
||||||
----------
|
----------
|
||||||
|
|
||||||
* [UCJL] **Alinson S. Xavier, Aleksandr M. Kazachkov, Feng Qiu.** "UnitCommitment.jl: A Julia/JuMP Optimization Package for Security-Constrained Unit Commitment". Zenodo (2020). [DOI: 10.5281/zenodo.4269874](https://doi.org/10.5281/zenodo.4269874)
|
* [UCJL] **Alinson S. Xavier, Aleksandr M. Kazachkov, Ogün Yurdakul, Feng Qiu.** "UnitCommitment.jl: A Julia/JuMP Optimization Package for Security-Constrained Unit Commitment (Version 0.3)". Zenodo (2022). [DOI: 10.5281/zenodo.4269874](https://doi.org/10.5281/zenodo.4269874)
|
||||||
|
|
||||||
* [KnOsWa20] **Bernard Knueven, James Ostrowski and Jean-Paul Watson.** "On Mixed-Integer Programming Formulations for the Unit Commitment Problem". INFORMS Journal on Computing (2020). [DOI: 10.1287/ijoc.2019.0944](https://doi.org/10.1287/ijoc.2019.0944)
|
* [KnOsWa20] **Bernard Knueven, James Ostrowski and Jean-Paul Watson.** "On Mixed-Integer Programming Formulations for the Unit Commitment Problem". INFORMS Journal on Computing (2020). [DOI: 10.1287/ijoc.2019.0944](https://doi.org/10.1287/ijoc.2019.0944)
|
||||||
|
|
||||||
@@ -296,14 +288,9 @@ References
|
|||||||
|
|
||||||
* [BaBlEh19] **Clayton Barrows, Aaron Bloom, Ali Ehlen, Jussi Ikaheimo, Jennie Jorgenson, Dheepak Krishnamurthy, Jessica Lau et al.** "The IEEE Reliability Test System: A Proposed 2019 Update." IEEE Transactions on Power Systems (2019). [DOI: 10.1109/TPWRS.2019.2925557](https://doi.org/10.1109/TPWRS.2019.2925557)
|
* [BaBlEh19] **Clayton Barrows, Aaron Bloom, Ali Ehlen, Jussi Ikaheimo, Jennie Jorgenson, Dheepak Krishnamurthy, Jessica Lau et al.** "The IEEE Reliability Test System: A Proposed 2019 Update." IEEE Transactions on Power Systems (2019). [DOI: 10.1109/TPWRS.2019.2925557](https://doi.org/10.1109/TPWRS.2019.2925557)
|
||||||
|
|
||||||
* [JoFlMa16] **C. Josz, S. Fliscounakis, J. Maeght, and P. Panciatici.** "AC Power Flow
|
* [JoFlMa16] **C. Josz, S. Fliscounakis, J. Maeght, and P. Panciatici.** "AC Power Flow Data in MATPOWER and QCQP Format: iTesla, RTE Snapshots, and PEGASE". [ArXiv (2016)](https://arxiv.org/abs/1603.01533).
|
||||||
Data in MATPOWER and QCQP Format: iTesla, RTE Snapshots, and PEGASE". [ArXiv (2016)](https://arxiv.org/abs/1603.01533).
|
|
||||||
|
|
||||||
* [FlPaCa13] **S. Fliscounakis, P. Panciatici, F. Capitanescu, and L. Wehenkel.**
|
* [FlPaCa13] **S. Fliscounakis, P. Panciatici, F. Capitanescu, and L. Wehenkel.** "Contingency ranking with respect to overloads in very large power systems taking into account uncertainty, preventive and corrective actions", Power Systems, IEEE Trans. on, (28)4:4909-4917, 2013. [DOI: 10.1109/TPWRS.2013.2251015](https://doi.org/10.1109/TPWRS.2013.2251015)
|
||||||
"Contingency ranking with respect to overloads in very large power
|
|
||||||
systems taking into account uncertainty, preventive and corrective
|
|
||||||
actions", Power Systems, IEEE Trans. on, (28)4:4909-4917, 2013.
|
|
||||||
[DOI: 10.1109/TPWRS.2013.2251015](https://doi.org/10.1109/TPWRS.2013.2251015)
|
|
||||||
|
|
||||||
* [MTPWR] **D. Zimmerman, C. E. Murillo-Sandnchez and R. J. Thomas.** "Matpower: Steady-state operations, planning, and analysis tools forpower systems research and education", IEEE Transactions on PowerSystems, vol. 26, no. 1, pp. 12 –19, Feb. 2011. [DOI: 10.1109/TPWRS.2010.2051168](https://doi.org/10.1109/TPWRS.2010.2051168)
|
* [MTPWR] **D. Zimmerman, C. E. Murillo-Sandnchez and R. J. Thomas.** "Matpower: Steady-state operations, planning, and analysis tools forpower systems research and education", IEEE Transactions on PowerSystems, vol. 26, no. 1, pp. 12 –19, Feb. 2011. [DOI: 10.1109/TPWRS.2010.2051168](https://doi.org/10.1109/TPWRS.2010.2051168)
|
||||||
|
|
||||||
233
docs/src/model.md
Normal file
233
docs/src/model.md
Normal file
@@ -0,0 +1,233 @@
|
|||||||
|
JuMP Model
|
||||||
|
==========
|
||||||
|
|
||||||
|
In this page, we describe the JuMP optimization model produced by the function `build_model`. A detailed understanding of this model is not necessary if you are just interested in using the package to solve some standard unit commitment cases, but it may be useful, for example, if you need to solve a slightly different problem, with additional variables and constraints. The notation in this page generally follows [KnOsWa20].
|
||||||
|
|
||||||
|
Decision variables
|
||||||
|
------------------
|
||||||
|
|
||||||
|
UC.jl models the security-constrained unit commitment problem as a two-stage stochastic program. In this approach, some of the decision variables are *first-stage decisions*, which are taken before the uncertainty is realized and must therefore be the same across all scenarios, while the remaining variables are *second-stage decisions*, which can attain a different values in each scenario. In the current version of the package, all binary variables (which model commitment decisions of thermal units) are first-stage decisions and all continuous variables are second-stage decisions.
|
||||||
|
|
||||||
|
!!! note
|
||||||
|
|
||||||
|
UC.jl treats deterministic SCUC instances as a special case of the stochastic problem in which there is only one scenario, named `"s1"` by default. To access second-stage decisions, therefore, you must provide this scenario name as the value for `sn`. For example, `model[:prod_above]["s1", g, t]`.
|
||||||
|
|
||||||
|
### Generators
|
||||||
|
|
||||||
|
In this section, we describe the decision variables associated with the generators, which include both thermal units (e.g., natural gas-fired power plant) and profiled units (e.g., wind turbine).
|
||||||
|
|
||||||
|
#### Thermal Units
|
||||||
|
|
||||||
|
Name | Description | Unit | Stage
|
||||||
|
:-----|:-------------|:------: | :------:
|
||||||
|
`is_on[g,t]` | True if generator `g` is on at time `t`. | Binary | 1
|
||||||
|
`switch_on[g,t]` | True is generator `g` switches on at time `t`. | Binary| 1
|
||||||
|
`switch_off[g,t]` | True if generator `g` switches off at time `t`. | Binary| 1
|
||||||
|
`startup[g,t,s]` | True if generator `g` switches on at time `t` incurring start-up costs from start-up category `s`. | Binary| 1
|
||||||
|
`prod_above[sn,g,t]` | Amount of power produced by generator `g` above its minimum power output at time `t` in scenario `sn`. For example, if the minimum power of generator `g` is 100 MW and `g` is producing 115 MW of power at time `t` in scenario `sn`, then `prod_above[sn,g,t]` equals `15.0`. | MW | 2
|
||||||
|
`segprod[sn,g,t,k]` | Amount of power from piecewise linear segment `k` produced by generator `g` at time `t` in scenario `sn`. For example, if cost curve for generator `g` is defined by the points `(100, 1400)`, `(110, 1600)`, `(130, 2200)` and `(135, 2400)`, and if the generator is producing 115 MW of power at time `t` in scenario `sn`, then `segprod[sn,g,t,:]` equals `[10.0, 5.0, 0.0]`.| MW | 2
|
||||||
|
`reserve[sn,r,g,t]` | Amount of reserve `r` provided by unit `g` at time `t` in scenario `sn`. | MW | 2
|
||||||
|
|
||||||
|
!!! warning
|
||||||
|
|
||||||
|
The first-stage decision variables of the JuMP model are `is_on[g,t]`, `switch_on[g,t]`, `switch_off[g,t]`, and `startup[g,t,s]`. As such, the dictionaries corresponding to these variables do not include the scenario index in their keys. In contrast, all other variables of the created JuMP model are allowed to obtain a different value in each scenario and are thus modeled as second-stage decision variables. Accordingly, the dictionaries of all second-stage decision variables have the scenario index in their keys. This is true even if the model is created to solve the deterministic SCUC, in which case the default scenario index `s1` is included in the dictionary key.
|
||||||
|
|
||||||
|
|
||||||
|
#### Profiled Units
|
||||||
|
|
||||||
|
Name | Description | Unit | Stage
|
||||||
|
:-----|:-------------|:------: | :------:
|
||||||
|
`prod_profiled[s,t]` | Amount of power produced by profiled unit `g` at time `t`. | MW | 2
|
||||||
|
|
||||||
|
|
||||||
|
### Buses
|
||||||
|
|
||||||
|
Name | Description | Unit | Stage
|
||||||
|
:-----|:-------------|:------:| :------:
|
||||||
|
`net_injection[sn,b,t]` | Net injection at bus `b` at time `t` in scenario `sn`. | MW | 2
|
||||||
|
`curtail[sn,b,t]` | Amount of load curtailed at bus `b` at time `t` in scenario `sn`. | MW | 2
|
||||||
|
|
||||||
|
|
||||||
|
### Price-sensitive loads
|
||||||
|
|
||||||
|
Name | Description | Unit | Stage
|
||||||
|
:-----|:-------------|:------:| :------:
|
||||||
|
`loads[sn,s,t]` | Amount of power served to price-sensitive load `s` at time `t` in scenario `sn`. | MW | 2
|
||||||
|
|
||||||
|
### Transmission lines
|
||||||
|
|
||||||
|
Name | Description | Unit | Stage
|
||||||
|
:-----|:-------------|:------:| :------:
|
||||||
|
`flow[sn,l,t]` | Power flow on line `l` at time `t` in scenario `sn`. | MW | 2
|
||||||
|
`overflow[sn,l,t]` | Amount of flow above the limit for line `l` at time `t` in scenario `sn`. | MW | 2
|
||||||
|
|
||||||
|
!!! warning
|
||||||
|
|
||||||
|
Since transmission and N-1 security constraints are enforced in a lazy way, most of the `flow[l,t]` variables are never added to the model. Accessing `model[:flow][sn,l,t]` without first checking that the variable exists will likely generate an error.
|
||||||
|
|
||||||
|
Objective function
|
||||||
|
------------------
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
|
Constraints
|
||||||
|
-----------
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
|
|
||||||
|
Inspecting and modifying the model
|
||||||
|
----------------------------------
|
||||||
|
|
||||||
|
### Accessing decision variables
|
||||||
|
|
||||||
|
After building a model using `UnitCommitment.build_model`, it is possible to obtain a reference to the decision variables by calling `model[:varname][index]`. For example, `model[:is_on]["g1",1]` returns a direct reference to the JuMP variable indicating whether generator named "g1" is on at time 1. The script below illustrates how to build a model, solve it and display the solution without using the function `UnitCommitment.solution`.
|
||||||
|
|
||||||
|
```julia
|
||||||
|
using Cbc
|
||||||
|
using Printf
|
||||||
|
using JuMP
|
||||||
|
using UnitCommitment
|
||||||
|
|
||||||
|
# Load benchmark instance
|
||||||
|
instance = UnitCommitment.read_benchmark("matpower/case118/2017-02-01")
|
||||||
|
|
||||||
|
# Build JuMP model
|
||||||
|
model = UnitCommitment.build_model(
|
||||||
|
instance=instance,
|
||||||
|
optimizer=Cbc.Optimizer,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Solve the model
|
||||||
|
UnitCommitment.optimize!(model)
|
||||||
|
|
||||||
|
# Display commitment status
|
||||||
|
for g in instance.units
|
||||||
|
for t in 1:instance.time
|
||||||
|
@printf(
|
||||||
|
"%-10s %5d %5.1f %5.1f %5.1f\n",
|
||||||
|
g.name,
|
||||||
|
t,
|
||||||
|
value(model[:is_on][g.name, t]),
|
||||||
|
value(model[:switch_on][g.name, t]),
|
||||||
|
value(model[:switch_off][g.name, t]),
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
### Fixing variables, modifying objective function and adding constraints
|
||||||
|
|
||||||
|
Since we now have a direct reference to the JuMP decision variables, it is possible to fix variables, change the coefficients in the objective function, or even add new constraints to the model before solving it.
|
||||||
|
!!! warning
|
||||||
|
|
||||||
|
It is important to take into account the stage of the decision variables in modifying the optimization model. In changing a deterministic SCUC model, modifying the second-stage decision variables requires adding the term `s1`, which is the default scenario name assigned to the second-stage decision variables in the SCUC model. For an SUC model, the package permits the modification of the second-stage decision variables individually for each scenario.
|
||||||
|
|
||||||
|
The script below shows how the JuMP model can be modified after it is created. For more information on modifying an existing model, [see the JuMP documentation](https://jump.dev/JuMP.jl/stable/manual/variables/).
|
||||||
|
|
||||||
|
```julia
|
||||||
|
using Cbc
|
||||||
|
using JuMP
|
||||||
|
using UnitCommitment
|
||||||
|
|
||||||
|
# Load benchmark instance
|
||||||
|
instance = UnitCommitment.read_benchmark("matpower/case118/2017-02-01")
|
||||||
|
|
||||||
|
# Construct JuMP model
|
||||||
|
model = UnitCommitment.build_model(
|
||||||
|
instance=instance,
|
||||||
|
optimizer=Cbc.Optimizer,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Fix the commitment status of the generator "g1" in time period 1 to 1.0
|
||||||
|
JuMP.fix(
|
||||||
|
model[:is_on]["g1",1],
|
||||||
|
1.0,
|
||||||
|
force=true,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Fix the production level of the generator "g1" above its minimum level in time period 1 and
|
||||||
|
# in scenario "s1" to 20.0 MW. Observe that the three-tuple dictionary key involves the scenario
|
||||||
|
# index "s1", as production above minimum is a second-stage decision variable.
|
||||||
|
JuMP.fix(
|
||||||
|
model[:prod_above]["s1", "g1", 1],
|
||||||
|
20.0,
|
||||||
|
force=true,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Enforce the curtailment of 20.0 MW of load at bus "b2" in time period 4 in scenario "s1".
|
||||||
|
JuMP.fix(
|
||||||
|
curtail["s1", "b2", 4] =
|
||||||
|
20.0,
|
||||||
|
force=true,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Change the objective function
|
||||||
|
JuMP.set_objective_coefficient(
|
||||||
|
model,
|
||||||
|
model[:switch_on]["g2",1],
|
||||||
|
1000.0,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Create a new constraint
|
||||||
|
@constraint(
|
||||||
|
model,
|
||||||
|
model[:is_on]["g3",1] + model[:is_on]["g4",1] <= 1,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Solve the model
|
||||||
|
UnitCommitment.optimize!(model)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Adding new component to a bus
|
||||||
|
|
||||||
|
The following snippet shows how to add a new grid component to a particular bus. For each time step, we create decision variables for the new grid component, add these variables to the objective function, then attach the component to a particular bus by modifying some existing model constraints.
|
||||||
|
|
||||||
|
```julia
|
||||||
|
using Cbc
|
||||||
|
using JuMP
|
||||||
|
using UnitCommitment
|
||||||
|
|
||||||
|
# Load instance and build base model
|
||||||
|
instance = UnitCommitment.read_benchmark("matpower/case118/2017-02-01")
|
||||||
|
model = UnitCommitment.build_model(
|
||||||
|
instance=instance,
|
||||||
|
optimizer=Cbc.Optimizer,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Get the number of time steps in the original instance
|
||||||
|
T = instance.time
|
||||||
|
|
||||||
|
# Create decision variables for the new grid component.
|
||||||
|
# In this example, we assume that the new component can
|
||||||
|
# inject up to 10 MW of power at each time step, so we
|
||||||
|
# create new continuous variables 0 ≤ x[t] ≤ 10.
|
||||||
|
@variable(model, x[1:T], lower_bound=0.0, upper_bound=10.0)
|
||||||
|
|
||||||
|
# For each time step
|
||||||
|
for t in 1:T
|
||||||
|
|
||||||
|
# Add production costs to the objective function.
|
||||||
|
# In this example, we assume a cost of $5/MW.
|
||||||
|
set_objective_coefficient(model, x[t], 5.0)
|
||||||
|
|
||||||
|
# Attach the new component to bus b1 in scenario s1, by modifying the
|
||||||
|
# constraint `eq_net_injection`.
|
||||||
|
set_normalized_coefficient(
|
||||||
|
model[:eq_net_injection]["s1", "b1", t],
|
||||||
|
x[t],
|
||||||
|
1.0,
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Solve the model
|
||||||
|
UnitCommitment.optimize!(model)
|
||||||
|
|
||||||
|
# Show optimal values for the x variables
|
||||||
|
@show value.(x)
|
||||||
|
```
|
||||||
|
|
||||||
|
References
|
||||||
|
----------
|
||||||
|
* [KnOsWa20] **Bernard Knueven, James Ostrowski and Jean-Paul Watson.** "On Mixed-Integer Programming Formulations for the Unit Commitment Problem". INFORMS Journal on Computing (2020). [DOI: 10.1287/ijoc.2019.0944](https://doi.org/10.1287/ijoc.2019.0944)
|
||||||
|
|
||||||
381
docs/src/usage.md
Normal file
381
docs/src/usage.md
Normal file
@@ -0,0 +1,381 @@
|
|||||||
|
Usage
|
||||||
|
=====
|
||||||
|
|
||||||
|
Installation
|
||||||
|
------------
|
||||||
|
|
||||||
|
UnitCommitment.jl was tested and developed with [Julia 1.9](https://julialang.org/). To install Julia, please follow the [installation guide on the official Julia website](https://julialang.org/downloads/). To install UnitCommitment.jl, run the Julia interpreter, type `]` to open the package manager, then type:
|
||||||
|
|
||||||
|
```text
|
||||||
|
pkg> add UnitCommitment@0.4
|
||||||
|
```
|
||||||
|
|
||||||
|
To solve the optimization models, a mixed-integer linear programming (MILP) solver is also required. Please see the [JuMP installation guide](https://jump.dev/JuMP.jl/stable/installation/) for more instructions on installing a solver. Typical open-source choices are [HiGHS](https://github.com/jump-dev/HiGHS.jl), [Cbc](https://github.com/JuliaOpt/Cbc.jl) and [GLPK](https://github.com/JuliaOpt/GLPK.jl). In the instructions below, HiGHS will be used, but any other MILP solver listed in JuMP installation guide should also be compatible.
|
||||||
|
|
||||||
|
Typical Usage
|
||||||
|
-------------
|
||||||
|
|
||||||
|
### Solving user-provided instances
|
||||||
|
|
||||||
|
The first step to use UC.jl is to construct JSON files that describe each scenario of your deterministic or stochastic unit commitment instance. See [Data Format](format.md) for a complete description of the data format UC.jl expects. The next steps, as shown below, are to: (1) read the scenario files; (2) build the optimization model; (3) run the optimization; and (4) extract the optimal solution.
|
||||||
|
|
||||||
|
```julia
|
||||||
|
using HiGHS
|
||||||
|
using JuMP
|
||||||
|
using UnitCommitment
|
||||||
|
|
||||||
|
# 1. Read instance
|
||||||
|
instance = UnitCommitment.read(["example/s1.json", "example/s2.json"])
|
||||||
|
|
||||||
|
# 2. Construct optimization model
|
||||||
|
model = UnitCommitment.build_model(
|
||||||
|
instance=instance,
|
||||||
|
optimizer=HiGHS.Optimizer,
|
||||||
|
)
|
||||||
|
|
||||||
|
# 3. Solve model
|
||||||
|
UnitCommitment.optimize!(model)
|
||||||
|
|
||||||
|
# 4. Write solution to a file
|
||||||
|
solution = UnitCommitment.solution(model)
|
||||||
|
UnitCommitment.write("example/out.json", solution)
|
||||||
|
```
|
||||||
|
|
||||||
|
To read multiple files from a given folder, the [Glob](https://github.com/vtjnash/Glob.jl) package can be used:
|
||||||
|
|
||||||
|
```jldoctest usage1; output = false
|
||||||
|
using Glob
|
||||||
|
using UnitCommitment
|
||||||
|
|
||||||
|
instance = UnitCommitment.read(glob("s*.json", "example/"))
|
||||||
|
|
||||||
|
# output
|
||||||
|
UnitCommitmentInstance(2 scenarios, 6 thermal units, 0 profiled units, 14 buses, 20 lines, 19 contingencies, 1 price sensitive loads, 4 time steps)
|
||||||
|
```
|
||||||
|
|
||||||
|
To solve deterministic instances, a single scenario file may be provided.
|
||||||
|
|
||||||
|
```jldoctest usage1; output = false
|
||||||
|
instance = UnitCommitment.read("example/s1.json")
|
||||||
|
|
||||||
|
# output
|
||||||
|
UnitCommitmentInstance(1 scenarios, 6 thermal units, 0 profiled units, 14 buses, 20 lines, 19 contingencies, 1 price sensitive loads, 4 time steps)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Solving benchmark instances
|
||||||
|
|
||||||
|
UnitCommitment.jl contains a large number of deterministic benchmark instances collected from the literature and converted into a common data format. To solve one of these instances individually, instead of constructing your own, the function `read_benchmark` can be used, as shown below. See [Instances](instances.md) for the complete list of available instances.
|
||||||
|
|
||||||
|
```jldoctest usage1; output = false
|
||||||
|
instance = UnitCommitment.read_benchmark("matpower/case3375wp/2017-02-01")
|
||||||
|
|
||||||
|
# output
|
||||||
|
UnitCommitmentInstance(1 scenarios, 590 thermal units, 0 profiled units, 3374 buses, 4161 lines, 3245 contingencies, 0 price sensitive loads, 36 time steps)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Customizing the formulation
|
||||||
|
|
||||||
|
By default, `build_model` uses a formulation that combines modeling components from different publications, and that has been carefully tested, using our own benchmark scripts, to provide good performance across a wide variety of instances. This default formulation is expected to change over time, as new methods are proposed in the literature. You can, however, construct your own formulation, based on the modeling components that you choose, as shown in the next example.
|
||||||
|
|
||||||
|
```julia
|
||||||
|
using HiGHS
|
||||||
|
using UnitCommitment
|
||||||
|
|
||||||
|
import UnitCommitment:
|
||||||
|
Formulation,
|
||||||
|
KnuOstWat2018,
|
||||||
|
MorLatRam2013,
|
||||||
|
ShiftFactorsFormulation
|
||||||
|
|
||||||
|
instance = UnitCommitment.read_benchmark(
|
||||||
|
"matpower/case118/2017-02-01",
|
||||||
|
)
|
||||||
|
|
||||||
|
model = UnitCommitment.build_model(
|
||||||
|
instance = instance,
|
||||||
|
optimizer = HiGHS.Optimizer,
|
||||||
|
formulation = Formulation(
|
||||||
|
pwl_costs = KnuOstWat2018.PwlCosts(),
|
||||||
|
ramping = MorLatRam2013.Ramping(),
|
||||||
|
startup_costs = MorLatRam2013.StartupCosts(),
|
||||||
|
transmission = ShiftFactorsFormulation(
|
||||||
|
isf_cutoff = 0.005,
|
||||||
|
lodf_cutoff = 0.001,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Generating initial conditions
|
||||||
|
|
||||||
|
When creating random unit commitment instances for benchmark purposes, it is often hard to compute, in advance, sensible initial conditions for all thermal generators. Setting initial conditions naively (for example, making all generators initially off and producing no power) can easily cause the instance to become infeasible due to excessive ramping. Initial conditions can also make it hard to modify existing instances. For example, increasing the system load without carefully modifying the initial conditions may make the problem infeasible or unrealistically challenging to solve.
|
||||||
|
|
||||||
|
To help with this issue, UC.jl provides a utility function which can generate feasible initial conditions by solving a single-period optimization problem, as shown below:
|
||||||
|
|
||||||
|
```julia
|
||||||
|
using HiGHS
|
||||||
|
using UnitCommitment
|
||||||
|
|
||||||
|
# Read original instance
|
||||||
|
instance = UnitCommitment.read("example/s1.json")
|
||||||
|
|
||||||
|
# Generate initial conditions (in-place)
|
||||||
|
UnitCommitment.generate_initial_conditions!(instance, HiGHS.Optimizer)
|
||||||
|
|
||||||
|
# Construct and solve optimization model
|
||||||
|
model = UnitCommitment.build_model(
|
||||||
|
instance=instance,
|
||||||
|
optimizer=HiGHS.Optimizer,
|
||||||
|
)
|
||||||
|
UnitCommitment.optimize!(model)
|
||||||
|
```
|
||||||
|
|
||||||
|
!!! warning
|
||||||
|
|
||||||
|
The function `generate_initial_conditions!` may return different initial conditions after each call, even if the same instance and the same optimizer is provided. The particular algorithm may also change in a future version of UC.jl. For these reasons, it is recommended that you generate initial conditions exactly once for each instance and store them for later use.
|
||||||
|
|
||||||
|
## Verifying solutions
|
||||||
|
|
||||||
|
When developing new formulations, it is very easy to introduce subtle errors in the model that result in incorrect solutions. To help avoiding this, UC.jl includes a utility function that verifies if a given solution is feasible, and, if not, prints all the validation errors it found. The implementation of this function is completely independent from the implementation of the optimization model, and therefore can be used to validate it.
|
||||||
|
|
||||||
|
```jldoctest; output = false
|
||||||
|
using JSON
|
||||||
|
using UnitCommitment
|
||||||
|
|
||||||
|
# Read instance
|
||||||
|
instance = UnitCommitment.read("example/s1.json")
|
||||||
|
|
||||||
|
# Read solution (potentially produced by other packages)
|
||||||
|
solution = JSON.parsefile("example/out.json")
|
||||||
|
|
||||||
|
# Validate solution and print validation errors
|
||||||
|
UnitCommitment.validate(instance, solution)
|
||||||
|
|
||||||
|
# output
|
||||||
|
|
||||||
|
true
|
||||||
|
```
|
||||||
|
|
||||||
|
## Progressive Hedging
|
||||||
|
|
||||||
|
By default, UC.jl uses the Extensive Form (EF) when solving stochastic instances. This approach involves constructing a single JuMP model that contains data and decision variables for all scenarios. Although EF has optimality guarantees and performs well with small test cases, it can become computationally intractable for large instances or substantial number of scenarios.
|
||||||
|
|
||||||
|
Progressive Hedging (PH) is an alternative (heuristic) solution method provided by UC.jl in which the problem is decomposed into smaller scenario-based subproblems, which are then solved in parallel in separate Julia processes, potentially across multiple machines. Quadratic penalty terms are used to enforce convergence of first-stage decision variables. The method is closely related to the Alternative Direction Method of Multipliers (ADMM) and can handle larger instances, although it is not guaranteed to converge to the optimal solution. Our implementation of PH relies on Message Passing Interface (MPI) for communication. We refer to [MPI.jl Documentation](https://github.com/JuliaParallel/MPI.jl) for more details on installing MPI.
|
||||||
|
|
||||||
|
The following example shows how to solve SCUC instances using progressive hedging. The script should be saved in a file, say `ph.jl`, and executed using `mpiexec -n <num-scenarios> julia ph.jl`.
|
||||||
|
|
||||||
|
|
||||||
|
```julia
|
||||||
|
using HiGHS
|
||||||
|
using MPI
|
||||||
|
using UnitCommitment
|
||||||
|
using Glob
|
||||||
|
|
||||||
|
# 1. Initialize MPI
|
||||||
|
MPI.Init()
|
||||||
|
|
||||||
|
# 2. Configure progressive hedging method
|
||||||
|
ph = UnitCommitment.ProgressiveHedging()
|
||||||
|
|
||||||
|
# 3. Read problem instance
|
||||||
|
instance = UnitCommitment.read(["example/s1.json", "example/s2.json"], ph)
|
||||||
|
|
||||||
|
# 4. Build JuMP model
|
||||||
|
model = UnitCommitment.build_model(
|
||||||
|
instance = instance,
|
||||||
|
optimizer = HiGHS.Optimizer,
|
||||||
|
)
|
||||||
|
|
||||||
|
# 5. Run the decentralized optimization algorithm
|
||||||
|
UnitCommitment.optimize!(model, ph)
|
||||||
|
|
||||||
|
# 6. Fetch the solution
|
||||||
|
solution = UnitCommitment.solution(model, ph)
|
||||||
|
|
||||||
|
# 7. Close MPI
|
||||||
|
MPI.Finalize()
|
||||||
|
```
|
||||||
|
|
||||||
|
When using PH, the model can be customized as usual, with different formulations or additional user-provided constraints. Note that `read`, in this case, takes `ph` as an argument. This allows each Julia process to read only the instance files that are relevant to it. Similarly, the `solution` function gathers the optimal solution of each processes and returns a combined dictionary.
|
||||||
|
|
||||||
|
Each process solves a sub-problem with $\frac{s}{p}$ scenarios, where $s$ is the total number of scenarios and $p$ is the number of MPI processes. For instance, if we have 15 scenario files and 5 processes, then each process will solve a JuMP model that contains data for 3 scenarios. If the total number of scenarios is not divisible by the number of processes, then an error will be thrown.
|
||||||
|
|
||||||
|
|
||||||
|
!!! warning
|
||||||
|
|
||||||
|
Currently, PH can handle only equiprobable scenarios. Further, `solution(model, ph)` can only handle cases where only one scenario is modeled in each process.
|
||||||
|
|
||||||
|
|
||||||
|
## Computing Locational Marginal Prices
|
||||||
|
|
||||||
|
Locational marginal prices (LMPs) refer to the cost of supplying electricity at a particular location of the network. Multiple methods for computing LMPs have been proposed in the literature. UnitCommitment.jl implements two commonly-used methods: conventional LMPs and Approximated Extended LMPs (AELMPs). To compute LMPs for a given unit commitment instance, the `compute_lmp` function can be used, as shown in the examples below. The function accepts three arguments -- a solved SCUC model, an LMP method, and a linear optimizer -- and it returns a dictionary mapping `(bus_name, time)` to the marginal price.
|
||||||
|
|
||||||
|
|
||||||
|
!!! warning
|
||||||
|
|
||||||
|
Most mixed-integer linear optimizers, such as `HiGHS`, `Gurobi` and `CPLEX` can be used with `compute_lmp`, with the notable exception of `Cbc`, which does not support dual value evaluations. If using `Cbc`, please provide `Clp` as the linear optimizer.
|
||||||
|
|
||||||
|
### Conventional LMPs
|
||||||
|
|
||||||
|
LMPs are conventionally computed by: (1) solving the SCUC model, (2) fixing all binary variables to their optimal values, and (3) re-solving the resulting linear programming model. In this approach, the LMPs are defined as the dual variables' values associated with the net injection constraints. The example below shows how to compute conventional LMPs for a given unit commitment instance. First, we build and optimize the SCUC model. Then, we call the `compute_lmp` function, providing as the second argument `ConventionalLMP()`.
|
||||||
|
|
||||||
|
|
||||||
|
```julia
|
||||||
|
using UnitCommitment
|
||||||
|
using HiGHS
|
||||||
|
|
||||||
|
import UnitCommitment: ConventionalLMP
|
||||||
|
|
||||||
|
# Read benchmark instance
|
||||||
|
instance = UnitCommitment.read_benchmark("matpower/case118/2018-01-01")
|
||||||
|
|
||||||
|
# Build the model
|
||||||
|
model = UnitCommitment.build_model(
|
||||||
|
instance = instance,
|
||||||
|
optimizer = HiGHS.Optimizer,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Optimize the model
|
||||||
|
UnitCommitment.optimize!(model)
|
||||||
|
|
||||||
|
# Compute the LMPs using the conventional method
|
||||||
|
lmp = UnitCommitment.compute_lmp(
|
||||||
|
model,
|
||||||
|
ConventionalLMP(),
|
||||||
|
optimizer = HiGHS.Optimizer,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Access the LMPs
|
||||||
|
# Example: "s1" is the scenario name, "b1" is the bus name, 1 is the first time slot
|
||||||
|
@show lmp["s1","b1", 1]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Approximate Extended LMPs
|
||||||
|
|
||||||
|
Approximate Extended LMPs (AELMPs) are an alternative method to calculate locational marginal prices which attemps to minimize uplift payments. The method internally works by modifying the instance data in three ways: (1) it sets the minimum power output of each generator to zero, (2) it averages the start-up cost over the offer blocks for each generator, and (3) it relaxes all integrality constraints. To compute AELMPs, as shown in the example below, we call `compute_lmp` and provide `AELMP()` as the second argument.
|
||||||
|
|
||||||
|
This method has two configurable parameters: `allow_offline_participation` and `consider_startup_costs`. If `allow_offline_participation = true`, then offline generators are allowed to participate in the pricing. If instead `allow_offline_participation = false`, offline generators are not allowed and therefore are excluded from the system. A solved UC model is optional if offline participation is allowed, but is required if not allowed. The method forces offline participation to be allowed if the UC model supplied by the user is not solved. For the second field, If `consider_startup_costs = true`, then start-up costs are integrated and averaged over each unit production; otherwise the production costs stay the same. By default, both fields are set to `true`.
|
||||||
|
|
||||||
|
!!! warning
|
||||||
|
|
||||||
|
This approximation method is still under active research, and has several limitations. The implementation provided in the package is based on MISO Phase I only. It only supports fast start resources. More specifically, the minimum up/down time of all generators must be 1, the initial power of all generators must be 0, and the initial status of all generators must be negative. The method does not support time-varying start-up costs. The method does not support multiple scenarios. If offline participation is not allowed, AELMPs treats an asset to be offline if it is never on throughout all time periods.
|
||||||
|
|
||||||
|
```julia
|
||||||
|
using UnitCommitment
|
||||||
|
using HiGHS
|
||||||
|
|
||||||
|
import UnitCommitment: AELMP
|
||||||
|
|
||||||
|
# Read benchmark instance
|
||||||
|
instance = UnitCommitment.read_benchmark("matpower/case118/2017-02-01")
|
||||||
|
|
||||||
|
# Build the model
|
||||||
|
model = UnitCommitment.build_model(
|
||||||
|
instance = instance,
|
||||||
|
optimizer = HiGHS.Optimizer,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Optimize the model
|
||||||
|
UnitCommitment.optimize!(model)
|
||||||
|
|
||||||
|
# Compute the AELMPs
|
||||||
|
aelmp = UnitCommitment.compute_lmp(
|
||||||
|
model,
|
||||||
|
AELMP(
|
||||||
|
allow_offline_participation = false,
|
||||||
|
consider_startup_costs = true
|
||||||
|
),
|
||||||
|
optimizer = HiGHS.Optimizer
|
||||||
|
)
|
||||||
|
|
||||||
|
# Access the AELMPs
|
||||||
|
# Example: "s1" is the scenario name, "b1" is the bus name, 1 is the first time slot
|
||||||
|
# Note: although scenario is supported, the query still keeps the scenario keys for consistency.
|
||||||
|
@show aelmp["s1", "b1", 1]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Time Decomposition
|
||||||
|
|
||||||
|
Solving unit commitment instances that have long time horizons (for example, year-long 8760-hour instances) requires a substantial amount of computational power. To address this issue, UC.jl offers a time decomposition method, which breaks the instance down into multiple overlapping subproblems, solves them sequentially, then reassembles the solution.
|
||||||
|
|
||||||
|
When solving a unit commitment instance with a dense time slot structure, computational complexity can become a significant challenge. For instance, if the instance contains hourly data for an entire year (8760 hours), solving such a model can require a substantial amount of computational power. To address this issue, UC.jl provides a time_decomposition method within the `optimize!` function. This method decomposes the problem into multiple sub-problems, solving them sequentially.
|
||||||
|
|
||||||
|
The `optimize!` function takes 5 parameters: a unit commitment instance, a `TimeDecomposition` method, an optimizer, and two optional functions `after_build` and `after_optimize`. It returns a solution dictionary. The `TimeDecomposition` method itself requires four arguments: `time_window`, `time_increment`, `inner_method` (optional), and `formulation` (optional). These arguments define the time window for each sub-problem, the time increment to move to the next sub-problem, the method used to solve each sub-problem, and the formulation employed, respectively. The two functions, namely `after_build` and `after_optimize`, are invoked subsequent to the construction and optimization of each sub-model, respectively. It is imperative that the `after_build` function requires its two arguments to be consistently mapped to `model` and `instance`, while the `after_optimize` function necessitates its three arguments to be consistently mapped to `solution`, `model`, and `instance`.
|
||||||
|
|
||||||
|
The code snippet below illustrates an example of solving an instance by decomposing the model into multiple 36-hour sub-problems using the `XavQiuWanThi2019` method. Each sub-problem advances 24 hours at a time. The first sub-problem covers time steps 1 to 36, the second covers time steps 25 to 60, the third covers time steps 49 to 84, and so on. The initial power levels and statuses of the second and subsequent sub-problems are set based on the results of the first 24 hours from each of their immediate prior sub-problems. In essence, this approach addresses the complexity of solving a large problem by tackling it in 24-hour intervals, while incorporating an additional 12-hour buffer to mitigate the closing window effect for each sub-problem. Furthermore, the `after_build` function imposes the restriction that `g3` and `g4` cannot be activated simultaneously during the initial time slot of each sub-problem. On the other hand, the `after_optimize` function is invoked to calculate the conventional Locational Marginal Prices (LMPs) for each sub-problem, and subsequently appends the computed values to the `lmps` vector.
|
||||||
|
|
||||||
|
> **Warning**
|
||||||
|
> Specifying `TimeDecomposition` as the value of the `inner_method` field of another `TimeDecomposition` causes errors when calling the `optimize!` function due to the different argument structures between the two `optimize!` functions.
|
||||||
|
|
||||||
|
```julia
|
||||||
|
using UnitCommitment, JuMP, Cbc, HiGHS
|
||||||
|
|
||||||
|
import UnitCommitment:
|
||||||
|
TimeDecomposition,
|
||||||
|
ConventionalLMP,
|
||||||
|
XavQiuWanThi2019,
|
||||||
|
Formulation
|
||||||
|
|
||||||
|
# specifying the after_build and after_optimize functions
|
||||||
|
function after_build(model, instance)
|
||||||
|
@constraint(
|
||||||
|
model,
|
||||||
|
model[:is_on]["g3", 1] + model[:is_on]["g4", 1] <= 1,
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
lmps = []
|
||||||
|
function after_optimize(solution, model, instance)
|
||||||
|
lmp = UnitCommitment.compute_lmp(
|
||||||
|
model,
|
||||||
|
ConventionalLMP(),
|
||||||
|
optimizer = HiGHS.Optimizer,
|
||||||
|
)
|
||||||
|
return push!(lmps, lmp)
|
||||||
|
end
|
||||||
|
|
||||||
|
# assume the instance is given as a 120h problem
|
||||||
|
instance = UnitCommitment.read("instance.json")
|
||||||
|
|
||||||
|
solution = UnitCommitment.optimize!(
|
||||||
|
instance,
|
||||||
|
TimeDecomposition(
|
||||||
|
time_window = 36, # solve 36h problems
|
||||||
|
time_increment = 24, # advance by 24h each time
|
||||||
|
inner_method = XavQiuWanThi2019.Method(),
|
||||||
|
formulation = Formulation(),
|
||||||
|
),
|
||||||
|
optimizer = Cbc.Optimizer,
|
||||||
|
after_build = after_build,
|
||||||
|
after_optimize = after_optimize,
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Day-ahead (DA) Market to Real-time (RT) Markets
|
||||||
|
The UC.jl package offers a comprehensive set of functions for solving marketing problems. The primary function, `solve_market`, facilitates the solution of day-ahead (DA) markets, which can be either deterministic or stochastic in nature. Subsequently, it sequentially maps the commitment status obtained from the DA market to all the real-time (RT) markets, which are deterministic instances. It is essential to ensure that the time span of the DA market encompasses all the RT markets, and the file paths for the RT markets must be specified in chronological order. Each RT market should represent a single time slot, and it is recommended to include a few additional time slots to mitigate the closing window effect.
|
||||||
|
|
||||||
|
The `solve_market` function accepts several parameters, including the file path (or a list of file paths in the case of stochastic markets) for the DA market, a list of file paths for the RT markets, the market settings specified by the `MarketSettings` structure, and an optimizer. The `MarketSettings` structure itself requires three optional arguments: `inner_method`, `lmp_method`, and `formulation`. If the computation of Locational Marginal Prices (LMPs) is not desired, the `lmp_method` can be set to `nothing`. Additional optional parameters include a linear programming optimizer for solving LMPs (if a different optimizer than the required one is desired), callback functions `after_build_da` and `after_optimize_da`, which are invoked after the construction and optimization of the DA market, and callback functions `after_build_rt` and `after_optimize_rt`, which are invoked after the construction and optimization of each RT market. It is crucial to note that the `after_build` function requires its two arguments to consistently correspond to `model` and `instance`, while the `after_optimize` function requires its three arguments to consistently correspond to `solution`, `model`, and `instance`.
|
||||||
|
|
||||||
|
As an illustrative example, suppose the DA market predicts hourly data for a 24-hour period, while the RT markets represent 5-minute intervals. In this scenario, each RT market file corresponds to a specific 5-minute interval, with the first RT market representing the initial 5 minutes, the second RT market representing the subsequent 5 minutes, and so on. Consequently, there should be 12 RT market files for each hour. To mitigate the closing window effect, except for the last few RT markets, each RT market should contain three time slots, resulting in a total time span of 15 minutes. However, only the first time slot is considered in the final solution. The last two RT markets should only contain 2 and 1 time slot(s), respectively, to ensure that the total time covered by all RT markets does not exceed the time span of the DA market. The code snippet below demonstrates a simplified example of how to utilize the `solve_market` function. Please note that it only serves as a simplified example and may require further customization based on the specific requirements of your use case.
|
||||||
|
|
||||||
|
```julia
|
||||||
|
using UnitCommitment, Cbc, HiGHS
|
||||||
|
|
||||||
|
import UnitCommitment:
|
||||||
|
MarketSettings,
|
||||||
|
XavQiuWanThi2019,
|
||||||
|
ConventionalLMP,
|
||||||
|
Formulation
|
||||||
|
|
||||||
|
solution = UnitCommitment.solve_market(
|
||||||
|
"da_instance.json",
|
||||||
|
["rt_instance_1.json", "rt_instance_2.json", "rt_instance_3.json"],
|
||||||
|
MarketSettings(
|
||||||
|
inner_method = XavQiuWanThi2019.Method(),
|
||||||
|
lmp_method = ConventionalLMP(),
|
||||||
|
formulation = Formulation(),
|
||||||
|
),
|
||||||
|
optimizer = Cbc.Optimizer,
|
||||||
|
lp_optimizer = HiGHS.Optimizer,
|
||||||
|
)
|
||||||
|
```
|
||||||
149
docs/usage.md
149
docs/usage.md
@@ -1,149 +0,0 @@
|
|||||||
```{sectnum}
|
|
||||||
---
|
|
||||||
start: 1
|
|
||||||
depth: 2
|
|
||||||
suffix: .
|
|
||||||
---
|
|
||||||
```
|
|
||||||
|
|
||||||
Usage
|
|
||||||
=====
|
|
||||||
|
|
||||||
Installation
|
|
||||||
------------
|
|
||||||
|
|
||||||
UnitCommitment.jl was tested and developed with [Julia 1.6](https://julialang.org/). To install Julia, please follow the [installation guide on the official Julia website](https://julialang.org/downloads/platform.html). To install UnitCommitment.jl, run the Julia interpreter, type `]` to open the package manager, then type:
|
|
||||||
|
|
||||||
```text
|
|
||||||
pkg> add UnitCommitment@0.2
|
|
||||||
```
|
|
||||||
|
|
||||||
To test that the package has been correctly installed, run:
|
|
||||||
|
|
||||||
```text
|
|
||||||
pkg> test UnitCommitment
|
|
||||||
```
|
|
||||||
|
|
||||||
If all tests pass, the package should now be ready to be used by any Julia script on the machine.
|
|
||||||
|
|
||||||
To solve the optimization models, a mixed-integer linear programming (MILP) solver is also required. Please see the [JuMP installation guide](https://jump.dev/JuMP.jl/stable/installation/) for more instructions on installing a solver. Typical open-source choices are [Cbc](https://github.com/JuliaOpt/Cbc.jl) and [GLPK](https://github.com/JuliaOpt/GLPK.jl). In the instructions below, Cbc will be used, but any other MILP solver listed in JuMP installation guide should also be compatible.
|
|
||||||
|
|
||||||
Typical Usage
|
|
||||||
-------------
|
|
||||||
|
|
||||||
### Solving user-provided instances
|
|
||||||
|
|
||||||
The first step to use UC.jl is to construct a JSON file describing your unit commitment instance. See [Data Format](format.md) for a complete description of the data format UC.jl expects. The next steps, as shown below, are to: (1) read the instance from file; (2) construct the optimization model; (3) run the optimization; and (4) extract the optimal solution.
|
|
||||||
|
|
||||||
```julia
|
|
||||||
using Cbc
|
|
||||||
using JSON
|
|
||||||
using UnitCommitment
|
|
||||||
|
|
||||||
# 1. Read instance
|
|
||||||
instance = UnitCommitment.read("/path/to/input.json")
|
|
||||||
|
|
||||||
# 2. Construct optimization model
|
|
||||||
model = UnitCommitment.build_model(
|
|
||||||
instance=instance,
|
|
||||||
optimizer=Cbc.Optimizer,
|
|
||||||
)
|
|
||||||
|
|
||||||
# 3. Solve model
|
|
||||||
UnitCommitment.optimize!(model)
|
|
||||||
|
|
||||||
# 4. Write solution to a file
|
|
||||||
solution = UnitCommitment.solution(model)
|
|
||||||
UnitCommitment.write("/path/to/output.json", solution)
|
|
||||||
```
|
|
||||||
|
|
||||||
### Solving benchmark instances
|
|
||||||
|
|
||||||
UnitCommitment.jl contains a large number of benchmark instances collected from the literature and converted into a common data format. To solve one of these instances individually, instead of constructing your own, the function `read_benchmark` can be used, as shown below. See [Instances](instances.md) for the complete list of available instances.
|
|
||||||
|
|
||||||
```julia
|
|
||||||
using UnitCommitment
|
|
||||||
instance = UnitCommitment.read_benchmark("matpower/case3375wp/2017-02-01")
|
|
||||||
```
|
|
||||||
|
|
||||||
Advanced usage
|
|
||||||
--------------
|
|
||||||
|
|
||||||
### Customizing the formulation
|
|
||||||
|
|
||||||
By default, `build_model` uses a formulation that combines modeling components from different publications, and that has been carefully tested, using our own benchmark scripts, to provide good performance across a wide variety of instances. This default formulation is expected to change over time, as new methods are proposed in the literature. You can, however, construct your own formulation, based on the modeling components that you choose, as shown in the next example.
|
|
||||||
|
|
||||||
```julia
|
|
||||||
using Cbc
|
|
||||||
using UnitCommitment
|
|
||||||
|
|
||||||
import UnitCommitment:
|
|
||||||
Formulation,
|
|
||||||
KnuOstWat2018,
|
|
||||||
MorLatRam2013,
|
|
||||||
ShiftFactorsFormulation
|
|
||||||
|
|
||||||
instance = UnitCommitment.read_benchmark(
|
|
||||||
"matpower/case118/2017-02-01",
|
|
||||||
)
|
|
||||||
|
|
||||||
model = UnitCommitment.build_model(
|
|
||||||
instance = instance,
|
|
||||||
optimizer = Cbc.Optimizer,
|
|
||||||
formulation = Formulation(
|
|
||||||
pwl_costs = KnuOstWat2018.PwlCosts(),
|
|
||||||
ramping = MorLatRam2013.Ramping(),
|
|
||||||
startup_costs = MorLatRam2013.StartupCosts(),
|
|
||||||
transmission = ShiftFactorsFormulation(
|
|
||||||
isf_cutoff = 0.005,
|
|
||||||
lodf_cutoff = 0.001,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
```
|
|
||||||
|
|
||||||
### Generating initial conditions
|
|
||||||
|
|
||||||
When creating random unit commitment instances for benchmark purposes, it is often hard to compute, in advance, sensible initial conditions for all generators. Setting initial conditions naively (for example, making all generators initially off and producing no power) can easily cause the instance to become infeasible due to excessive ramping. Initial conditions can also make it hard to modify existing instances. For example, increasing the system load without carefully modifying the initial conditions may make the problem infeasible or unrealistically challenging to solve.
|
|
||||||
|
|
||||||
To help with this issue, UC.jl provides a utility function which can generate feasible initial conditions by solving a single-period optimization problem, as shown below:
|
|
||||||
|
|
||||||
```julia
|
|
||||||
using Cbc
|
|
||||||
using UnitCommitment
|
|
||||||
|
|
||||||
# Read original instance
|
|
||||||
instance = UnitCommitment.read("instance.json")
|
|
||||||
|
|
||||||
# Generate initial conditions (in-place)
|
|
||||||
UnitCommitment.generate_initial_conditions!(instance, Cbc.Optimizer)
|
|
||||||
|
|
||||||
# Construct and solve optimization model
|
|
||||||
model = UnitCommitment.build_model(
|
|
||||||
instance=instance,
|
|
||||||
optimizer=Cbc.Optimizer,
|
|
||||||
)
|
|
||||||
UnitCommitment.optimize!(model)
|
|
||||||
```
|
|
||||||
|
|
||||||
```{warning}
|
|
||||||
The function `generate_initial_conditions!` may return different initial conditions after each call, even if the same instance and the same optimizer is provided. The particular algorithm may also change in a future version of UC.jl. For these reasons, it is recommended that you generate initial conditions exactly once for each instance and store them for later use.
|
|
||||||
```
|
|
||||||
|
|
||||||
### Verifying solutions
|
|
||||||
|
|
||||||
When developing new formulations, it is very easy to introduce subtle errors in the model that result in incorrect solutions. To help with this, UC.jl includes a utility function that verifies if a given solution is feasible, and, if not, prints all the validation errors it found. The implementation of this function is completely independent from the implementation of the optimization model, and therefore can be used to validate it. The function can also be used to verify solutions produced by other optimization packages, as long as they follow the [UC.jl data format](format.md).
|
|
||||||
|
|
||||||
```julia
|
|
||||||
using JSON
|
|
||||||
using UnitCommitment
|
|
||||||
|
|
||||||
# Read instance
|
|
||||||
instance = UnitCommitment.read("instance.json")
|
|
||||||
|
|
||||||
# Read solution (potentially produced by other packages)
|
|
||||||
solution = JSON.parsefile("solution.json")
|
|
||||||
|
|
||||||
# Validate solution and print validation errors
|
|
||||||
UnitCommitment.validate(instance, solution)
|
|
||||||
```
|
|
||||||
Binary file not shown.
75
juliaw
75
juliaw
@@ -1,75 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
|
|
||||||
# Copyright (C) 2020-2021, UChicago Argonne, LLC. All rights reserved.
|
|
||||||
# Released under the modified BSD license. See COPYING.md for more details.
|
|
||||||
|
|
||||||
if [ ! -e Project.toml ]; then
|
|
||||||
echo "juliaw: Project.toml not found"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -e Manifest.toml ]; then
|
|
||||||
julia --project=. -e 'using Pkg; Pkg.instantiate()' || exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -e build/sysimage.so -o Project.toml -nt build/sysimage.so ]; then
|
|
||||||
echo "juliaw: rebuilding system image..."
|
|
||||||
|
|
||||||
# Generate temporary project folder
|
|
||||||
rm -rf $HOME/.juliaw
|
|
||||||
mkdir -p $HOME/.juliaw/src
|
|
||||||
cp Project.toml Manifest.toml $HOME/.juliaw
|
|
||||||
NAME=$(julia -e 'using TOML; toml = TOML.parsefile("Project.toml"); "name" in keys(toml) && print(toml["name"])')
|
|
||||||
if [ ! -z $NAME ]; then
|
|
||||||
cat > $HOME/.juliaw/src/$NAME.jl << EOF
|
|
||||||
module $NAME
|
|
||||||
end
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Add PackageCompiler dependencies to temporary project
|
|
||||||
julia --project=$HOME/.juliaw -e 'using Pkg; Pkg.add(["PackageCompiler", "TOML", "Logging"])'
|
|
||||||
|
|
||||||
# Generate system image scripts
|
|
||||||
cat > $HOME/.juliaw/sysimage.jl << EOF
|
|
||||||
using PackageCompiler
|
|
||||||
using TOML
|
|
||||||
using Logging
|
|
||||||
|
|
||||||
Logging.disable_logging(Logging.Info)
|
|
||||||
mkpath("$PWD/build")
|
|
||||||
|
|
||||||
println("juliaw: generating precompilation statements...")
|
|
||||||
run(\`julia --project="$PWD" --trace-compile="$PWD"/build/precompile.jl \$(ARGS)\`)
|
|
||||||
|
|
||||||
println("juliaw: finding dependencies...")
|
|
||||||
project = TOML.parsefile("Project.toml")
|
|
||||||
manifest = TOML.parsefile("Manifest.toml")
|
|
||||||
deps = Symbol[]
|
|
||||||
for dep in keys(project["deps"])
|
|
||||||
if dep in keys(manifest)
|
|
||||||
# Up to Julia 1.6
|
|
||||||
dep_entry = manifest[dep][1]
|
|
||||||
else
|
|
||||||
# Julia 1.7+
|
|
||||||
dep_entry = manifest["deps"][dep][1]
|
|
||||||
end
|
|
||||||
if "path" in keys(dep_entry)
|
|
||||||
println(" - \$(dep) [skip]")
|
|
||||||
else
|
|
||||||
println(" - \$(dep)")
|
|
||||||
push!(deps, Symbol(dep))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
println("juliaw: building system image...")
|
|
||||||
create_sysimage(
|
|
||||||
deps,
|
|
||||||
precompile_statements_file = "$PWD/build/precompile.jl",
|
|
||||||
sysimage_path = "$PWD/build/sysimage.so",
|
|
||||||
)
|
|
||||||
EOF
|
|
||||||
julia --project=$HOME/.juliaw $HOME/.juliaw/sysimage.jl $*
|
|
||||||
else
|
|
||||||
julia --project=. --sysimage build/sysimage.so $*
|
|
||||||
fi
|
|
||||||
@@ -4,9 +4,15 @@
|
|||||||
|
|
||||||
module UnitCommitment
|
module UnitCommitment
|
||||||
|
|
||||||
|
using Requires
|
||||||
|
|
||||||
|
using Base: String
|
||||||
|
|
||||||
include("instance/structs.jl")
|
include("instance/structs.jl")
|
||||||
include("model/formulations/base/structs.jl")
|
include("model/formulations/base/structs.jl")
|
||||||
include("solution/structs.jl")
|
include("solution/structs.jl")
|
||||||
|
include("lmp/structs.jl")
|
||||||
|
include("market/structs.jl")
|
||||||
|
|
||||||
include("model/formulations/ArrCon2000/structs.jl")
|
include("model/formulations/ArrCon2000/structs.jl")
|
||||||
include("model/formulations/CarArr2006/structs.jl")
|
include("model/formulations/CarArr2006/structs.jl")
|
||||||
@@ -16,10 +22,13 @@ include("model/formulations/KnuOstWat2018/structs.jl")
|
|||||||
include("model/formulations/MorLatRam2013/structs.jl")
|
include("model/formulations/MorLatRam2013/structs.jl")
|
||||||
include("model/formulations/PanGua2016/structs.jl")
|
include("model/formulations/PanGua2016/structs.jl")
|
||||||
include("solution/methods/XavQiuWanThi2019/structs.jl")
|
include("solution/methods/XavQiuWanThi2019/structs.jl")
|
||||||
|
include("solution/methods/ProgressiveHedging/structs.jl")
|
||||||
include("model/formulations/WanHob2016/structs.jl")
|
include("model/formulations/WanHob2016/structs.jl")
|
||||||
|
include("solution/methods/TimeDecomposition/structs.jl")
|
||||||
|
|
||||||
include("import/egret.jl")
|
include("import/egret.jl")
|
||||||
include("instance/read.jl")
|
include("instance/read.jl")
|
||||||
|
include("instance/migrate.jl")
|
||||||
include("model/build.jl")
|
include("model/build.jl")
|
||||||
include("model/formulations/ArrCon2000/ramp.jl")
|
include("model/formulations/ArrCon2000/ramp.jl")
|
||||||
include("model/formulations/base/bus.jl")
|
include("model/formulations/base/bus.jl")
|
||||||
@@ -28,6 +37,8 @@ include("model/formulations/base/psload.jl")
|
|||||||
include("model/formulations/base/sensitivity.jl")
|
include("model/formulations/base/sensitivity.jl")
|
||||||
include("model/formulations/base/system.jl")
|
include("model/formulations/base/system.jl")
|
||||||
include("model/formulations/base/unit.jl")
|
include("model/formulations/base/unit.jl")
|
||||||
|
include("model/formulations/base/punit.jl")
|
||||||
|
include("model/formulations/base/storage.jl")
|
||||||
include("model/formulations/CarArr2006/pwlcosts.jl")
|
include("model/formulations/CarArr2006/pwlcosts.jl")
|
||||||
include("model/formulations/DamKucRajAta2016/ramp.jl")
|
include("model/formulations/DamKucRajAta2016/ramp.jl")
|
||||||
include("model/formulations/Gar1962/pwlcosts.jl")
|
include("model/formulations/Gar1962/pwlcosts.jl")
|
||||||
@@ -44,6 +55,10 @@ include("solution/methods/XavQiuWanThi2019/enforce.jl")
|
|||||||
include("solution/methods/XavQiuWanThi2019/filter.jl")
|
include("solution/methods/XavQiuWanThi2019/filter.jl")
|
||||||
include("solution/methods/XavQiuWanThi2019/find.jl")
|
include("solution/methods/XavQiuWanThi2019/find.jl")
|
||||||
include("solution/methods/XavQiuWanThi2019/optimize.jl")
|
include("solution/methods/XavQiuWanThi2019/optimize.jl")
|
||||||
|
include("solution/methods/TimeDecomposition/optimize.jl")
|
||||||
|
include("solution/methods/ProgressiveHedging/optimize.jl")
|
||||||
|
include("solution/methods/ProgressiveHedging/read.jl")
|
||||||
|
include("solution/methods/ProgressiveHedging/solution.jl")
|
||||||
include("solution/optimize.jl")
|
include("solution/optimize.jl")
|
||||||
include("solution/solution.jl")
|
include("solution/solution.jl")
|
||||||
include("solution/warmstart.jl")
|
include("solution/warmstart.jl")
|
||||||
@@ -55,5 +70,15 @@ include("utils/log.jl")
|
|||||||
include("utils/benchmark.jl")
|
include("utils/benchmark.jl")
|
||||||
include("validation/repair.jl")
|
include("validation/repair.jl")
|
||||||
include("validation/validate.jl")
|
include("validation/validate.jl")
|
||||||
|
include("lmp/conventional.jl")
|
||||||
|
include("lmp/aelmp.jl")
|
||||||
|
include("market/market.jl")
|
||||||
|
|
||||||
|
function __init__()
|
||||||
|
@require MIPLearn = "2b1277c3-b477-4c49-a15e-7ba350325c68" begin
|
||||||
|
include("solution/methods/MIPLearn/structs.jl")
|
||||||
|
include("solution/methods/MIPLearn/miplearn.jl")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ function read_egret_solution(path::String)::OrderedDict
|
|||||||
|
|
||||||
solution = OrderedDict()
|
solution = OrderedDict()
|
||||||
is_on = solution["Is on"] = OrderedDict()
|
is_on = solution["Is on"] = OrderedDict()
|
||||||
production = solution["Production (MW)"] = OrderedDict()
|
production = solution["Thermal production (MW)"] = OrderedDict()
|
||||||
reserve = solution["Reserve (MW)"] = OrderedDict()
|
reserve = solution["Reserve (MW)"] = OrderedDict()
|
||||||
production_cost = solution["Production cost (\$)"] = OrderedDict()
|
production_cost = solution["Thermal production cost (\$)"] = OrderedDict()
|
||||||
startup_cost = solution["Startup cost (\$)"] = OrderedDict()
|
startup_cost = solution["Startup cost (\$)"] = OrderedDict()
|
||||||
|
|
||||||
for (gen_name, gen_dict) in egret["elements"]["generator"]
|
for (gen_name, gen_dict) in egret["elements"]["generator"]
|
||||||
|
|||||||
50
src/instance/migrate.jl
Normal file
50
src/instance/migrate.jl
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
# UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
|
||||||
|
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
||||||
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
|
|
||||||
|
using DataStructures
|
||||||
|
using JSON
|
||||||
|
|
||||||
|
function _migrate(json)
|
||||||
|
version = json["Parameters"]["Version"]
|
||||||
|
if version === nothing
|
||||||
|
error(
|
||||||
|
"The provided input file cannot be loaded because it does not " *
|
||||||
|
"specify what version of UnitCommitment.jl it was written for. " *
|
||||||
|
"Please modify the \"Parameters\" section of the file and include " *
|
||||||
|
"a \"Version\" entry. For example: {\"Parameters\":{\"Version\":\"0.3\"}}",
|
||||||
|
)
|
||||||
|
end
|
||||||
|
version = VersionNumber(version)
|
||||||
|
version >= v"0.3" || _migrate_to_v03(json)
|
||||||
|
version >= v"0.4" || _migrate_to_v04(json)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
function _migrate_to_v03(json)
|
||||||
|
# Migrate reserves
|
||||||
|
if json["Reserves"] !== nothing &&
|
||||||
|
json["Reserves"]["Spinning (MW)"] !== nothing
|
||||||
|
amount = json["Reserves"]["Spinning (MW)"]
|
||||||
|
json["Reserves"] = DefaultOrderedDict(nothing)
|
||||||
|
json["Reserves"]["r1"] = DefaultOrderedDict(nothing)
|
||||||
|
json["Reserves"]["r1"]["Type"] = "spinning"
|
||||||
|
json["Reserves"]["r1"]["Amount (MW)"] = amount
|
||||||
|
for (gen_name, gen) in json["Generators"]
|
||||||
|
if gen["Provides spinning reserves?"] == true
|
||||||
|
gen["Reserve eligibility"] = ["r1"]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function _migrate_to_v04(json)
|
||||||
|
# Migrate thermal units
|
||||||
|
if json["Generators"] !== nothing
|
||||||
|
for (gen_name, gen) in json["Generators"]
|
||||||
|
if gen["Type"] === nothing
|
||||||
|
gen["Type"] = "Thermal"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -8,20 +8,18 @@ using DataStructures
|
|||||||
using GZip
|
using GZip
|
||||||
import Base: getindex, time
|
import Base: getindex, time
|
||||||
|
|
||||||
const INSTANCES_URL = "https://axavier.org/UnitCommitment.jl/0.2/instances"
|
const INSTANCES_URL = "https://axavier.org/UnitCommitment.jl/0.3/instances"
|
||||||
|
|
||||||
"""
|
"""
|
||||||
read_benchmark(name::AbstractString)::UnitCommitmentInstance
|
read_benchmark(name::AbstractString)::UnitCommitmentInstance
|
||||||
|
|
||||||
Read one of the benchmark unit commitment instances included in the package.
|
Read one of the benchmark instances included in the package. See
|
||||||
See "Instances" section of the documentation for the entire list of benchmark
|
[Instances](instances.md) for the entire list of benchmark instances available.
|
||||||
instances available.
|
|
||||||
|
|
||||||
Example
|
# Example
|
||||||
-------
|
```julia
|
||||||
|
|
||||||
import UnitCommitment
|
|
||||||
instance = UnitCommitment.read_benchmark("matpower/case3375wp/2017-02-01")
|
instance = UnitCommitment.read_benchmark("matpower/case3375wp/2017-02-01")
|
||||||
|
```
|
||||||
"""
|
"""
|
||||||
function read_benchmark(
|
function read_benchmark(
|
||||||
name::AbstractString;
|
name::AbstractString;
|
||||||
@@ -45,26 +43,76 @@ function read_benchmark(
|
|||||||
return UnitCommitment.read(filename)
|
return UnitCommitment.read(filename)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function _repair_scenario_names_and_probabilities!(
|
||||||
|
scenarios::Vector{UnitCommitmentScenario},
|
||||||
|
path::Vector{String},
|
||||||
|
)::Nothing
|
||||||
|
total_weight = sum([sc.probability for sc in scenarios])
|
||||||
|
for (sc_path, sc) in zip(path, scenarios)
|
||||||
|
sc.name !== "" ||
|
||||||
|
(sc.name = first(split(last(split(sc_path, "/")), ".")))
|
||||||
|
sc.probability = (sc.probability / total_weight)
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
read(path::AbstractString)::UnitCommitmentInstance
|
read(path::AbstractString)::UnitCommitmentInstance
|
||||||
|
|
||||||
Read a unit commitment instance from a file. The file may be gzipped.
|
Read a deterministic test case from the given file. The file may be gzipped.
|
||||||
|
|
||||||
Example
|
# Example
|
||||||
-------
|
|
||||||
|
|
||||||
import UnitCommitment
|
```julia
|
||||||
instance = UnitCommitment.read("/path/to/input.json.gz")
|
instance = UnitCommitment.read("s1.json.gz")
|
||||||
|
```
|
||||||
"""
|
"""
|
||||||
function read(path::AbstractString)::UnitCommitmentInstance
|
function read(path::String)::UnitCommitmentInstance
|
||||||
if endswith(path, ".gz")
|
scenarios = Vector{UnitCommitmentScenario}()
|
||||||
return _read(gzopen(path))
|
scenario = _read_scenario(path)
|
||||||
else
|
scenario.name = "s1"
|
||||||
return _read(open(path))
|
scenario.probability = 1.0
|
||||||
end
|
scenarios = [scenario]
|
||||||
|
instance =
|
||||||
|
UnitCommitmentInstance(time = scenario.time, scenarios = scenarios)
|
||||||
|
return instance
|
||||||
end
|
end
|
||||||
|
|
||||||
function _read(file::IO)::UnitCommitmentInstance
|
"""
|
||||||
|
read(path::Vector{String})::UnitCommitmentInstance
|
||||||
|
|
||||||
|
Read a stochastic unit commitment instance from the given files. Each file
|
||||||
|
describes a scenario. The files may be gzipped.
|
||||||
|
|
||||||
|
# Example
|
||||||
|
|
||||||
|
```julia
|
||||||
|
instance = UnitCommitment.read(["s1.json.gz", "s2.json.gz"])
|
||||||
|
```
|
||||||
|
"""
|
||||||
|
function read(paths::Vector{String})::UnitCommitmentInstance
|
||||||
|
scenarios = UnitCommitmentScenario[]
|
||||||
|
for p in paths
|
||||||
|
push!(scenarios, _read_scenario(p))
|
||||||
|
end
|
||||||
|
_repair_scenario_names_and_probabilities!(scenarios, paths)
|
||||||
|
instance =
|
||||||
|
UnitCommitmentInstance(time = scenarios[1].time, scenarios = scenarios)
|
||||||
|
return instance
|
||||||
|
end
|
||||||
|
|
||||||
|
function _read_scenario(path::String)::UnitCommitmentScenario
|
||||||
|
if endswith(path, ".gz")
|
||||||
|
scenario = _read(gzopen(path))
|
||||||
|
elseif endswith(path, ".json")
|
||||||
|
scenario = _read(open(path))
|
||||||
|
else
|
||||||
|
error("Unsupported input format")
|
||||||
|
end
|
||||||
|
return scenario
|
||||||
|
end
|
||||||
|
|
||||||
|
function _read(file::IO)::UnitCommitmentScenario
|
||||||
return _from_json(
|
return _from_json(
|
||||||
JSON.parse(file, dicttype = () -> DefaultOrderedDict(nothing)),
|
JSON.parse(file, dicttype = () -> DefaultOrderedDict(nothing)),
|
||||||
)
|
)
|
||||||
@@ -79,32 +127,54 @@ function _read_json(path::String)::OrderedDict
|
|||||||
return JSON.parse(file, dicttype = () -> DefaultOrderedDict(nothing))
|
return JSON.parse(file, dicttype = () -> DefaultOrderedDict(nothing))
|
||||||
end
|
end
|
||||||
|
|
||||||
function _from_json(json; repair = true)
|
function _from_json(json; repair = true)::UnitCommitmentScenario
|
||||||
units = Unit[]
|
_migrate(json)
|
||||||
|
thermal_units = ThermalUnit[]
|
||||||
buses = Bus[]
|
buses = Bus[]
|
||||||
contingencies = Contingency[]
|
contingencies = Contingency[]
|
||||||
lines = TransmissionLine[]
|
lines = TransmissionLine[]
|
||||||
loads = PriceSensitiveLoad[]
|
loads = PriceSensitiveLoad[]
|
||||||
|
reserves = Reserve[]
|
||||||
|
profiled_units = ProfiledUnit[]
|
||||||
|
storage_units = StorageUnit[]
|
||||||
|
|
||||||
function scalar(x; default = nothing)
|
function scalar(x; default = nothing)
|
||||||
x !== nothing || return default
|
x !== nothing || return default
|
||||||
return x
|
return x
|
||||||
end
|
end
|
||||||
|
|
||||||
|
time_horizon = json["Parameters"]["Time horizon (min)"]
|
||||||
|
if time_horizon === nothing
|
||||||
time_horizon = json["Parameters"]["Time (h)"]
|
time_horizon = json["Parameters"]["Time (h)"]
|
||||||
if time_horizon === nothing
|
if time_horizon === nothing
|
||||||
time_horizon = json["Parameters"]["Time horizon (h)"]
|
time_horizon = json["Parameters"]["Time horizon (h)"]
|
||||||
end
|
end
|
||||||
time_horizon !== nothing || error("Missing parameter: Time horizon (h)")
|
if time_horizon !== nothing
|
||||||
|
time_horizon *= 60
|
||||||
|
end
|
||||||
|
end
|
||||||
|
time_horizon !== nothing || error("Missing parameter: Time horizon (min)")
|
||||||
|
isinteger(time_horizon) ||
|
||||||
|
error("Time horizon must be an integer in minutes")
|
||||||
|
time_horizon = Int(time_horizon)
|
||||||
time_step = scalar(json["Parameters"]["Time step (min)"], default = 60)
|
time_step = scalar(json["Parameters"]["Time step (min)"], default = 60)
|
||||||
(60 % time_step == 0) ||
|
(60 % time_step == 0) ||
|
||||||
error("Time step $time_step is not a divisor of 60")
|
error("Time step $time_step is not a divisor of 60")
|
||||||
|
(time_horizon % time_step == 0) || error(
|
||||||
|
"Time step $time_step is not a divisor of time horizon $time_horizon",
|
||||||
|
)
|
||||||
time_multiplier = 60 ÷ time_step
|
time_multiplier = 60 ÷ time_step
|
||||||
T = time_horizon * time_multiplier
|
T = time_horizon ÷ time_step
|
||||||
|
|
||||||
|
probability = json["Parameters"]["Scenario weight"]
|
||||||
|
probability !== nothing || (probability = 1)
|
||||||
|
scenario_name = json["Parameters"]["Scenario name"]
|
||||||
|
scenario_name !== nothing || (scenario_name = "")
|
||||||
|
|
||||||
name_to_bus = Dict{String,Bus}()
|
name_to_bus = Dict{String,Bus}()
|
||||||
name_to_line = Dict{String,TransmissionLine}()
|
name_to_line = Dict{String,TransmissionLine}()
|
||||||
name_to_unit = Dict{String,Unit}()
|
name_to_unit = Dict{String,ThermalUnit}()
|
||||||
|
name_to_reserve = Dict{String,Reserve}()
|
||||||
|
|
||||||
function timeseries(x; default = nothing)
|
function timeseries(x; default = nothing)
|
||||||
x !== nothing || return default
|
x !== nothing || return default
|
||||||
@@ -117,15 +187,6 @@ function _from_json(json; repair = true)
|
|||||||
json["Parameters"]["Power balance penalty (\$/MW)"],
|
json["Parameters"]["Power balance penalty (\$/MW)"],
|
||||||
default = [1000.0 for t in 1:T],
|
default = [1000.0 for t in 1:T],
|
||||||
)
|
)
|
||||||
# Penalty price for shortage in meeting system-wide flexiramp requirements
|
|
||||||
flexiramp_shortfall_penalty = timeseries(
|
|
||||||
json["Parameters"]["Flexiramp penalty (\$/MW)"],
|
|
||||||
default = [500.0 for t in 1:T],
|
|
||||||
)
|
|
||||||
shortfall_penalty = timeseries(
|
|
||||||
json["Parameters"]["Reserve shortfall penalty (\$/MW)"],
|
|
||||||
default = [-1.0 for t in 1:T],
|
|
||||||
)
|
|
||||||
|
|
||||||
# Read buses
|
# Read buses
|
||||||
for (bus_name, dict) in json["Buses"]
|
for (bus_name, dict) in json["Buses"]
|
||||||
@@ -133,24 +194,54 @@ function _from_json(json; repair = true)
|
|||||||
bus_name,
|
bus_name,
|
||||||
length(buses),
|
length(buses),
|
||||||
timeseries(dict["Load (MW)"]),
|
timeseries(dict["Load (MW)"]),
|
||||||
Unit[],
|
ThermalUnit[],
|
||||||
PriceSensitiveLoad[],
|
PriceSensitiveLoad[],
|
||||||
|
ProfiledUnit[],
|
||||||
|
StorageUnit[],
|
||||||
)
|
)
|
||||||
name_to_bus[bus_name] = bus
|
name_to_bus[bus_name] = bus
|
||||||
push!(buses, bus)
|
push!(buses, bus)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Read reserves
|
||||||
|
if "Reserves" in keys(json)
|
||||||
|
for (reserve_name, dict) in json["Reserves"]
|
||||||
|
r = Reserve(
|
||||||
|
name = reserve_name,
|
||||||
|
type = lowercase(dict["Type"]),
|
||||||
|
amount = timeseries(dict["Amount (MW)"]),
|
||||||
|
thermal_units = [],
|
||||||
|
shortfall_penalty = scalar(
|
||||||
|
dict["Shortfall penalty (\$/MW)"],
|
||||||
|
default = -1,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
name_to_reserve[reserve_name] = r
|
||||||
|
push!(reserves, r)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Read units
|
# Read units
|
||||||
for (unit_name, dict) in json["Generators"]
|
for (unit_name, dict) in json["Generators"]
|
||||||
|
# Read and validate unit type
|
||||||
|
unit_type = scalar(dict["Type"], default = nothing)
|
||||||
|
unit_type !== nothing || error("unit $unit_name has no type specified")
|
||||||
bus = name_to_bus[dict["Bus"]]
|
bus = name_to_bus[dict["Bus"]]
|
||||||
|
|
||||||
|
if lowercase(unit_type) === "thermal"
|
||||||
# Read production cost curve
|
# Read production cost curve
|
||||||
K = length(dict["Production cost curve (MW)"])
|
K = length(dict["Production cost curve (MW)"])
|
||||||
curve_mw = hcat(
|
curve_mw = hcat(
|
||||||
[timeseries(dict["Production cost curve (MW)"][k]) for k in 1:K]...,
|
[
|
||||||
|
timeseries(dict["Production cost curve (MW)"][k]) for
|
||||||
|
k in 1:K
|
||||||
|
]...,
|
||||||
)
|
)
|
||||||
curve_cost = hcat(
|
curve_cost = hcat(
|
||||||
[timeseries(dict["Production cost curve (\$)"][k]) for k in 1:K]...,
|
[
|
||||||
|
timeseries(dict["Production cost curve (\$)"][k]) for
|
||||||
|
k in 1:K
|
||||||
|
]...,
|
||||||
)
|
)
|
||||||
min_power = curve_mw[:, 1]
|
min_power = curve_mw[:, 1]
|
||||||
max_power = curve_mw[:, K]
|
max_power = curve_mw[:, K]
|
||||||
@@ -177,15 +268,26 @@ function _from_json(json; repair = true)
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Read reserve eligibility
|
||||||
|
unit_reserves = Reserve[]
|
||||||
|
if "Reserve eligibility" in keys(dict)
|
||||||
|
unit_reserves =
|
||||||
|
[name_to_reserve[n] for n in dict["Reserve eligibility"]]
|
||||||
|
end
|
||||||
|
|
||||||
# Read and validate initial conditions
|
# Read and validate initial conditions
|
||||||
initial_power = scalar(dict["Initial power (MW)"], default = nothing)
|
initial_power =
|
||||||
initial_status = scalar(dict["Initial status (h)"], default = nothing)
|
scalar(dict["Initial power (MW)"], default = nothing)
|
||||||
|
initial_status =
|
||||||
|
scalar(dict["Initial status (h)"], default = nothing)
|
||||||
if initial_power === nothing
|
if initial_power === nothing
|
||||||
initial_status === nothing ||
|
initial_status === nothing || error(
|
||||||
error("unit $unit_name has initial status but no initial power")
|
"unit $unit_name has initial status but no initial power",
|
||||||
|
)
|
||||||
else
|
else
|
||||||
initial_status !== nothing ||
|
initial_status !== nothing || error(
|
||||||
error("unit $unit_name has initial power but no initial status")
|
"unit $unit_name has initial power but no initial status",
|
||||||
|
)
|
||||||
initial_status != 0 ||
|
initial_status != 0 ||
|
||||||
error("unit $unit_name has invalid initial status")
|
error("unit $unit_name has invalid initial status")
|
||||||
if initial_status < 0 && initial_power > 1e-3
|
if initial_status < 0 && initial_power > 1e-3
|
||||||
@@ -194,7 +296,13 @@ function _from_json(json; repair = true)
|
|||||||
initial_status *= time_multiplier
|
initial_status *= time_multiplier
|
||||||
end
|
end
|
||||||
|
|
||||||
unit = Unit(
|
# Read commitment status
|
||||||
|
commitment_status = scalar(
|
||||||
|
dict["Commitment status"],
|
||||||
|
default = Vector{Union{Bool,Nothing}}(nothing, T),
|
||||||
|
)
|
||||||
|
|
||||||
|
unit = ThermalUnit(
|
||||||
unit_name,
|
unit_name,
|
||||||
bus,
|
bus,
|
||||||
max_power,
|
max_power,
|
||||||
@@ -202,42 +310,40 @@ function _from_json(json; repair = true)
|
|||||||
timeseries(dict["Must run?"], default = [false for t in 1:T]),
|
timeseries(dict["Must run?"], default = [false for t in 1:T]),
|
||||||
min_power_cost,
|
min_power_cost,
|
||||||
segments,
|
segments,
|
||||||
scalar(dict["Minimum uptime (h)"], default = 1) * time_multiplier,
|
scalar(dict["Minimum uptime (h)"], default = 1) *
|
||||||
scalar(dict["Minimum downtime (h)"], default = 1) * time_multiplier,
|
time_multiplier,
|
||||||
|
scalar(dict["Minimum downtime (h)"], default = 1) *
|
||||||
|
time_multiplier,
|
||||||
scalar(dict["Ramp up limit (MW)"], default = 1e6),
|
scalar(dict["Ramp up limit (MW)"], default = 1e6),
|
||||||
scalar(dict["Ramp down limit (MW)"], default = 1e6),
|
scalar(dict["Ramp down limit (MW)"], default = 1e6),
|
||||||
scalar(dict["Startup limit (MW)"], default = 1e6),
|
scalar(dict["Startup limit (MW)"], default = 1e6),
|
||||||
scalar(dict["Shutdown limit (MW)"], default = 1e6),
|
scalar(dict["Shutdown limit (MW)"], default = 1e6),
|
||||||
initial_status,
|
initial_status,
|
||||||
initial_power,
|
initial_power,
|
||||||
timeseries(
|
|
||||||
dict["Provides spinning reserves?"],
|
|
||||||
default = [true for t in 1:T],
|
|
||||||
),
|
|
||||||
timeseries(
|
|
||||||
dict["Provides flexible capacity?"],
|
|
||||||
default = [true for t in 1:T],
|
|
||||||
),
|
|
||||||
startup_categories,
|
startup_categories,
|
||||||
|
unit_reserves,
|
||||||
|
commitment_status,
|
||||||
)
|
)
|
||||||
push!(bus.units, unit)
|
push!(bus.thermal_units, unit)
|
||||||
name_to_unit[unit_name] = unit
|
for r in unit_reserves
|
||||||
push!(units, unit)
|
push!(r.thermal_units, unit)
|
||||||
end
|
end
|
||||||
|
name_to_unit[unit_name] = unit
|
||||||
# Read spinning, up-flexiramp, and down-flexiramp reserve requirements
|
push!(thermal_units, unit)
|
||||||
reserves = Reserves(zeros(T), zeros(T), zeros(T))
|
elseif lowercase(unit_type) === "profiled"
|
||||||
if "Reserves" in keys(json)
|
bus = name_to_bus[dict["Bus"]]
|
||||||
reserves.spinning =
|
pu = ProfiledUnit(
|
||||||
timeseries(json["Reserves"]["Spinning (MW)"], default = zeros(T))
|
unit_name,
|
||||||
reserves.upflexiramp = timeseries(
|
bus,
|
||||||
json["Reserves"]["Up-flexiramp (MW)"],
|
timeseries(scalar(dict["Minimum power (MW)"], default = 0.0)),
|
||||||
default = zeros(T),
|
timeseries(dict["Maximum power (MW)"]),
|
||||||
)
|
timeseries(dict["Cost (\$/MW)"]),
|
||||||
reserves.dwflexiramp = timeseries(
|
|
||||||
json["Reserves"]["Down-flexiramp (MW)"],
|
|
||||||
default = zeros(T),
|
|
||||||
)
|
)
|
||||||
|
push!(bus.profiled_units, pu)
|
||||||
|
push!(profiled_units, pu)
|
||||||
|
else
|
||||||
|
error("unit $unit_name has an invalid type")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Read transmission lines
|
# Read transmission lines
|
||||||
@@ -248,7 +354,6 @@ function _from_json(json; repair = true)
|
|||||||
length(lines) + 1,
|
length(lines) + 1,
|
||||||
name_to_bus[dict["Source bus"]],
|
name_to_bus[dict["Source bus"]],
|
||||||
name_to_bus[dict["Target bus"]],
|
name_to_bus[dict["Target bus"]],
|
||||||
scalar(dict["Reactance (ohms)"]),
|
|
||||||
scalar(dict["Susceptance (S)"]),
|
scalar(dict["Susceptance (S)"]),
|
||||||
timeseries(
|
timeseries(
|
||||||
dict["Normal flow limit (MW)"],
|
dict["Normal flow limit (MW)"],
|
||||||
@@ -271,7 +376,7 @@ function _from_json(json; repair = true)
|
|||||||
# Read contingencies
|
# Read contingencies
|
||||||
if "Contingencies" in keys(json)
|
if "Contingencies" in keys(json)
|
||||||
for (cont_name, dict) in json["Contingencies"]
|
for (cont_name, dict) in json["Contingencies"]
|
||||||
affected_units = Unit[]
|
affected_units = ThermalUnit[]
|
||||||
affected_lines = TransmissionLine[]
|
affected_lines = TransmissionLine[]
|
||||||
if "Affected lines" in keys(dict)
|
if "Affected lines" in keys(dict)
|
||||||
affected_lines =
|
affected_lines =
|
||||||
@@ -301,7 +406,55 @@ function _from_json(json; repair = true)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
instance = UnitCommitmentInstance(
|
# Read storage units
|
||||||
|
if "Storage units" in keys(json)
|
||||||
|
for (storage_name, dict) in json["Storage units"]
|
||||||
|
bus = name_to_bus[dict["Bus"]]
|
||||||
|
min_level =
|
||||||
|
timeseries(scalar(dict["Minimum level (MWh)"], default = 0.0))
|
||||||
|
max_level = timeseries(dict["Maximum level (MWh)"])
|
||||||
|
storage = StorageUnit(
|
||||||
|
storage_name,
|
||||||
|
bus,
|
||||||
|
min_level,
|
||||||
|
max_level,
|
||||||
|
timeseries(
|
||||||
|
scalar(
|
||||||
|
dict["Allow simultaneous charging and discharging"],
|
||||||
|
default = true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
timeseries(dict["Charge cost (\$/MW)"]),
|
||||||
|
timeseries(dict["Discharge cost (\$/MW)"]),
|
||||||
|
timeseries(scalar(dict["Charge efficiency"], default = 1.0)),
|
||||||
|
timeseries(scalar(dict["Discharge efficiency"], default = 1.0)),
|
||||||
|
timeseries(scalar(dict["Loss factor"], default = 0.0)),
|
||||||
|
timeseries(
|
||||||
|
scalar(dict["Minimum charge rate (MW)"], default = 0.0),
|
||||||
|
),
|
||||||
|
timeseries(dict["Maximum charge rate (MW)"]),
|
||||||
|
timeseries(
|
||||||
|
scalar(dict["Minimum discharge rate (MW)"], default = 0.0),
|
||||||
|
),
|
||||||
|
timeseries(dict["Maximum discharge rate (MW)"]),
|
||||||
|
scalar(dict["Initial level (MWh)"], default = 0.0),
|
||||||
|
scalar(
|
||||||
|
dict["Last period minimum level (MWh)"],
|
||||||
|
default = min_level[T],
|
||||||
|
),
|
||||||
|
scalar(
|
||||||
|
dict["Last period maximum level (MWh)"],
|
||||||
|
default = max_level[T],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
push!(bus.storage_units, storage)
|
||||||
|
push!(storage_units, storage)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario = UnitCommitmentScenario(
|
||||||
|
name = scenario_name,
|
||||||
|
probability = probability,
|
||||||
buses_by_name = Dict(b.name => b for b in buses),
|
buses_by_name = Dict(b.name => b for b in buses),
|
||||||
buses = buses,
|
buses = buses,
|
||||||
contingencies_by_name = Dict(c.name => c for c in contingencies),
|
contingencies_by_name = Dict(c.name => c for c in contingencies),
|
||||||
@@ -312,14 +465,20 @@ function _from_json(json; repair = true)
|
|||||||
price_sensitive_loads_by_name = Dict(ps.name => ps for ps in loads),
|
price_sensitive_loads_by_name = Dict(ps.name => ps for ps in loads),
|
||||||
price_sensitive_loads = loads,
|
price_sensitive_loads = loads,
|
||||||
reserves = reserves,
|
reserves = reserves,
|
||||||
shortfall_penalty = shortfall_penalty,
|
reserves_by_name = name_to_reserve,
|
||||||
flexiramp_shortfall_penalty = flexiramp_shortfall_penalty,
|
|
||||||
time = T,
|
time = T,
|
||||||
units_by_name = Dict(g.name => g for g in units),
|
time_step = time_step,
|
||||||
units = units,
|
thermal_units_by_name = Dict(g.name => g for g in thermal_units),
|
||||||
|
thermal_units = thermal_units,
|
||||||
|
profiled_units_by_name = Dict(pu.name => pu for pu in profiled_units),
|
||||||
|
profiled_units = profiled_units,
|
||||||
|
storage_units_by_name = Dict(su.name => su for su in storage_units),
|
||||||
|
storage_units = storage_units,
|
||||||
|
isf = spzeros(Float64, length(lines), length(buses) - 1),
|
||||||
|
lodf = spzeros(Float64, length(lines), length(lines)),
|
||||||
)
|
)
|
||||||
if repair
|
if repair
|
||||||
UnitCommitment.repair!(instance)
|
UnitCommitment.repair!(scenario)
|
||||||
end
|
end
|
||||||
return instance
|
return scenario
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,8 +6,10 @@ mutable struct Bus
|
|||||||
name::String
|
name::String
|
||||||
offset::Int
|
offset::Int
|
||||||
load::Vector{Float64}
|
load::Vector{Float64}
|
||||||
units::Vector
|
thermal_units::Vector
|
||||||
price_sensitive_loads::Vector
|
price_sensitive_loads::Vector
|
||||||
|
profiled_units::Vector
|
||||||
|
storage_units::Vector
|
||||||
end
|
end
|
||||||
|
|
||||||
mutable struct CostSegment
|
mutable struct CostSegment
|
||||||
@@ -20,7 +22,15 @@ mutable struct StartupCategory
|
|||||||
cost::Float64
|
cost::Float64
|
||||||
end
|
end
|
||||||
|
|
||||||
mutable struct Unit
|
Base.@kwdef mutable struct Reserve
|
||||||
|
name::String
|
||||||
|
type::String
|
||||||
|
amount::Vector{Float64}
|
||||||
|
thermal_units::Vector
|
||||||
|
shortfall_penalty::Float64
|
||||||
|
end
|
||||||
|
|
||||||
|
mutable struct ThermalUnit
|
||||||
name::String
|
name::String
|
||||||
bus::Bus
|
bus::Bus
|
||||||
max_power::Vector{Float64}
|
max_power::Vector{Float64}
|
||||||
@@ -36,9 +46,9 @@ mutable struct Unit
|
|||||||
shutdown_limit::Float64
|
shutdown_limit::Float64
|
||||||
initial_status::Union{Int,Nothing}
|
initial_status::Union{Int,Nothing}
|
||||||
initial_power::Union{Float64,Nothing}
|
initial_power::Union{Float64,Nothing}
|
||||||
provides_spinning_reserves::Vector{Bool}
|
|
||||||
provides_flexiramp_reserves::Vector{Bool}
|
|
||||||
startup_categories::Vector{StartupCategory}
|
startup_categories::Vector{StartupCategory}
|
||||||
|
reserves::Vector{Reserve}
|
||||||
|
commitment_status::Vector{Union{Bool,Nothing}}
|
||||||
end
|
end
|
||||||
|
|
||||||
mutable struct TransmissionLine
|
mutable struct TransmissionLine
|
||||||
@@ -46,23 +56,16 @@ mutable struct TransmissionLine
|
|||||||
offset::Int
|
offset::Int
|
||||||
source::Bus
|
source::Bus
|
||||||
target::Bus
|
target::Bus
|
||||||
reactance::Float64
|
|
||||||
susceptance::Float64
|
susceptance::Float64
|
||||||
normal_flow_limit::Vector{Float64}
|
normal_flow_limit::Vector{Float64}
|
||||||
emergency_flow_limit::Vector{Float64}
|
emergency_flow_limit::Vector{Float64}
|
||||||
flow_limit_penalty::Vector{Float64}
|
flow_limit_penalty::Vector{Float64}
|
||||||
end
|
end
|
||||||
|
|
||||||
mutable struct Reserves
|
|
||||||
spinning::Vector{Float64}
|
|
||||||
upflexiramp::Vector{Float64}
|
|
||||||
dwflexiramp::Vector{Float64}
|
|
||||||
end
|
|
||||||
|
|
||||||
mutable struct Contingency
|
mutable struct Contingency
|
||||||
name::String
|
name::String
|
||||||
lines::Vector{TransmissionLine}
|
lines::Vector{TransmissionLine}
|
||||||
units::Vector{Unit}
|
thermal_units::Vector{ThermalUnit}
|
||||||
end
|
end
|
||||||
|
|
||||||
mutable struct PriceSensitiveLoad
|
mutable struct PriceSensitiveLoad
|
||||||
@@ -72,34 +75,75 @@ mutable struct PriceSensitiveLoad
|
|||||||
revenue::Vector{Float64}
|
revenue::Vector{Float64}
|
||||||
end
|
end
|
||||||
|
|
||||||
Base.@kwdef mutable struct UnitCommitmentInstance
|
mutable struct ProfiledUnit
|
||||||
|
name::String
|
||||||
|
bus::Bus
|
||||||
|
min_power::Vector{Float64}
|
||||||
|
max_power::Vector{Float64}
|
||||||
|
cost::Vector{Float64}
|
||||||
|
end
|
||||||
|
|
||||||
|
mutable struct StorageUnit
|
||||||
|
name::String
|
||||||
|
bus::Bus
|
||||||
|
min_level::Vector{Float64}
|
||||||
|
max_level::Vector{Float64}
|
||||||
|
simultaneous_charge_and_discharge::Vector{Bool}
|
||||||
|
charge_cost::Vector{Float64}
|
||||||
|
discharge_cost::Vector{Float64}
|
||||||
|
charge_efficiency::Vector{Float64}
|
||||||
|
discharge_efficiency::Vector{Float64}
|
||||||
|
loss_factor::Vector{Float64}
|
||||||
|
min_charge_rate::Vector{Float64}
|
||||||
|
max_charge_rate::Vector{Float64}
|
||||||
|
min_discharge_rate::Vector{Float64}
|
||||||
|
max_discharge_rate::Vector{Float64}
|
||||||
|
initial_level::Float64
|
||||||
|
min_ending_level::Float64
|
||||||
|
max_ending_level::Float64
|
||||||
|
end
|
||||||
|
|
||||||
|
Base.@kwdef mutable struct UnitCommitmentScenario
|
||||||
buses_by_name::Dict{AbstractString,Bus}
|
buses_by_name::Dict{AbstractString,Bus}
|
||||||
buses::Vector{Bus}
|
buses::Vector{Bus}
|
||||||
contingencies_by_name::Dict{AbstractString,Contingency}
|
contingencies_by_name::Dict{AbstractString,Contingency}
|
||||||
contingencies::Vector{Contingency}
|
contingencies::Vector{Contingency}
|
||||||
|
isf::Array{Float64,2}
|
||||||
lines_by_name::Dict{AbstractString,TransmissionLine}
|
lines_by_name::Dict{AbstractString,TransmissionLine}
|
||||||
lines::Vector{TransmissionLine}
|
lines::Vector{TransmissionLine}
|
||||||
|
lodf::Array{Float64,2}
|
||||||
|
name::String
|
||||||
power_balance_penalty::Vector{Float64}
|
power_balance_penalty::Vector{Float64}
|
||||||
price_sensitive_loads_by_name::Dict{AbstractString,PriceSensitiveLoad}
|
price_sensitive_loads_by_name::Dict{AbstractString,PriceSensitiveLoad}
|
||||||
price_sensitive_loads::Vector{PriceSensitiveLoad}
|
price_sensitive_loads::Vector{PriceSensitiveLoad}
|
||||||
reserves::Reserves
|
probability::Float64
|
||||||
shortfall_penalty::Vector{Float64}
|
profiled_units_by_name::Dict{AbstractString,ProfiledUnit}
|
||||||
flexiramp_shortfall_penalty::Vector{Float64}
|
profiled_units::Vector{ProfiledUnit}
|
||||||
|
reserves_by_name::Dict{AbstractString,Reserve}
|
||||||
|
reserves::Vector{Reserve}
|
||||||
|
thermal_units_by_name::Dict{AbstractString,ThermalUnit}
|
||||||
|
thermal_units::Vector{ThermalUnit}
|
||||||
|
storage_units_by_name::Dict{AbstractString,StorageUnit}
|
||||||
|
storage_units::Vector{StorageUnit}
|
||||||
time::Int
|
time::Int
|
||||||
units_by_name::Dict{AbstractString,Unit}
|
time_step::Int
|
||||||
units::Vector{Unit}
|
end
|
||||||
|
|
||||||
|
Base.@kwdef mutable struct UnitCommitmentInstance
|
||||||
|
time::Int
|
||||||
|
scenarios::Vector{UnitCommitmentScenario}
|
||||||
end
|
end
|
||||||
|
|
||||||
function Base.show(io::IO, instance::UnitCommitmentInstance)
|
function Base.show(io::IO, instance::UnitCommitmentInstance)
|
||||||
|
sc = instance.scenarios[1]
|
||||||
print(io, "UnitCommitmentInstance(")
|
print(io, "UnitCommitmentInstance(")
|
||||||
print(io, "$(length(instance.units)) units, ")
|
print(io, "$(length(instance.scenarios)) scenarios, ")
|
||||||
print(io, "$(length(instance.buses)) buses, ")
|
print(io, "$(length(sc.thermal_units)) thermal units, ")
|
||||||
print(io, "$(length(instance.lines)) lines, ")
|
print(io, "$(length(sc.profiled_units)) profiled units, ")
|
||||||
print(io, "$(length(instance.contingencies)) contingencies, ")
|
print(io, "$(length(sc.buses)) buses, ")
|
||||||
print(
|
print(io, "$(length(sc.lines)) lines, ")
|
||||||
io,
|
print(io, "$(length(sc.contingencies)) contingencies, ")
|
||||||
"$(length(instance.price_sensitive_loads)) price sensitive loads, ",
|
print(io, "$(length(sc.price_sensitive_loads)) price sensitive loads, ")
|
||||||
)
|
|
||||||
print(io, "$(instance.time) time steps")
|
print(io, "$(instance.time) time steps")
|
||||||
print(io, ")")
|
print(io, ")")
|
||||||
return
|
return
|
||||||
|
|||||||
212
src/lmp/aelmp.jl
Normal file
212
src/lmp/aelmp.jl
Normal file
@@ -0,0 +1,212 @@
|
|||||||
|
# UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
|
||||||
|
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
||||||
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
|
|
||||||
|
using JuMP
|
||||||
|
|
||||||
|
"""
|
||||||
|
function compute_lmp(
|
||||||
|
model::JuMP.Model,
|
||||||
|
method::AELMP;
|
||||||
|
optimizer,
|
||||||
|
)::OrderedDict{Tuple{String,Int},Float64}
|
||||||
|
|
||||||
|
Calculates the approximate extended locational marginal prices of the given unit commitment instance.
|
||||||
|
|
||||||
|
The AELPM does the following three things:
|
||||||
|
|
||||||
|
1. It sets the minimum power output of each generator to zero
|
||||||
|
2. It averages the start-up cost over the offer blocks for each generator
|
||||||
|
3. It relaxes all integrality constraints
|
||||||
|
|
||||||
|
Returns a dictionary mapping `(bus_name, time)` to the marginal price.
|
||||||
|
|
||||||
|
WARNING: This approximation method is not fully developed. The implementation is based on MISO Phase I only.
|
||||||
|
|
||||||
|
1. It only supports Fast Start resources. More specifically, the minimum up/down time has to be zero.
|
||||||
|
2. The method does NOT support time-varying start-up costs.
|
||||||
|
3. An asset is considered offline if it is never on throughout all time periods.
|
||||||
|
4. The method does NOT support multiple scenarios.
|
||||||
|
|
||||||
|
Arguments
|
||||||
|
---------
|
||||||
|
|
||||||
|
- `model`:
|
||||||
|
the UnitCommitment model, must be solved before calling this function if offline participation is not allowed.
|
||||||
|
|
||||||
|
- `method`:
|
||||||
|
the AELMP method.
|
||||||
|
|
||||||
|
- `optimizer`:
|
||||||
|
the optimizer for solving the LP problem.
|
||||||
|
|
||||||
|
Examples
|
||||||
|
--------
|
||||||
|
|
||||||
|
```julia
|
||||||
|
using UnitCommitment
|
||||||
|
using HiGHS
|
||||||
|
|
||||||
|
import UnitCommitment: AELMP
|
||||||
|
|
||||||
|
# Read benchmark instance
|
||||||
|
instance = UnitCommitment.read_benchmark("matpower/case118/2017-02-01")
|
||||||
|
|
||||||
|
# Build the model
|
||||||
|
model = UnitCommitment.build_model(
|
||||||
|
instance = instance,
|
||||||
|
optimizer = HiGHS.Optimizer,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Optimize the model
|
||||||
|
UnitCommitment.optimize!(model)
|
||||||
|
|
||||||
|
# Compute the AELMPs
|
||||||
|
aelmp = UnitCommitment.compute_lmp(
|
||||||
|
model,
|
||||||
|
AELMP(
|
||||||
|
allow_offline_participation = false,
|
||||||
|
consider_startup_costs = true
|
||||||
|
),
|
||||||
|
optimizer = HiGHS.Optimizer
|
||||||
|
)
|
||||||
|
|
||||||
|
# Access the AELMPs
|
||||||
|
# Example: "s1" is the scenario name, "b1" is the bus name, 1 is the first time slot
|
||||||
|
# Note: although scenario is supported, the query still keeps the scenario keys for consistency.
|
||||||
|
@show aelmp["s1", "b1", 1]
|
||||||
|
```
|
||||||
|
"""
|
||||||
|
function compute_lmp(
|
||||||
|
model::JuMP.Model,
|
||||||
|
method::AELMP;
|
||||||
|
optimizer,
|
||||||
|
)::OrderedDict{Tuple{String,String,Int},Float64}
|
||||||
|
@info "Building the approximation model..."
|
||||||
|
instance = deepcopy(model[:instance])
|
||||||
|
_aelmp_check_parameters(instance, model, method)
|
||||||
|
_modify_scenario!(instance.scenarios[1], model, method)
|
||||||
|
|
||||||
|
# prepare the result dictionary and solve the model
|
||||||
|
elmp = OrderedDict()
|
||||||
|
@info "Solving the approximation model."
|
||||||
|
approx_model = build_model(instance = instance, variable_names = true)
|
||||||
|
|
||||||
|
# relax the binary constraint, and relax integrality
|
||||||
|
for v in all_variables(approx_model)
|
||||||
|
if is_binary(v)
|
||||||
|
unset_binary(v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
relax_integrality(approx_model)
|
||||||
|
set_optimizer(approx_model, optimizer)
|
||||||
|
|
||||||
|
# solve the model
|
||||||
|
set_silent(approx_model)
|
||||||
|
optimize!(approx_model)
|
||||||
|
|
||||||
|
# access the dual values
|
||||||
|
@info "Getting dual values (AELMPs)."
|
||||||
|
for (key, val) in approx_model[:eq_net_injection]
|
||||||
|
elmp[key] = dual(val)
|
||||||
|
end
|
||||||
|
return elmp
|
||||||
|
end
|
||||||
|
|
||||||
|
function _aelmp_check_parameters(
|
||||||
|
instance::UnitCommitmentInstance,
|
||||||
|
model::JuMP.Model,
|
||||||
|
method::AELMP,
|
||||||
|
)
|
||||||
|
# CHECK: model cannot have multiple scenarios
|
||||||
|
if length(instance.scenarios) > 1
|
||||||
|
error("The method does NOT support multiple scenarios.")
|
||||||
|
end
|
||||||
|
sc = instance.scenarios[1]
|
||||||
|
# CHECK: model must be solved if allow_offline_participation=false
|
||||||
|
if !method.allow_offline_participation
|
||||||
|
if isnothing(model) || !has_values(model)
|
||||||
|
error(
|
||||||
|
"A solved UC model is required if allow_offline_participation=false.",
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
all_units = sc.thermal_units
|
||||||
|
# CHECK: model cannot handle non-fast-starts (MISO Phase I: can ONLY solve fast-starts)
|
||||||
|
if any(u -> u.min_uptime > 1 || u.min_downtime > 1, all_units)
|
||||||
|
error(
|
||||||
|
"The minimum up/down time of all generators must be 1. AELMP only supports fast-starts.",
|
||||||
|
)
|
||||||
|
end
|
||||||
|
if any(u -> u.initial_power > 0, all_units)
|
||||||
|
error("The initial power of all generators must be 0.")
|
||||||
|
end
|
||||||
|
if any(u -> u.initial_status >= 0, all_units)
|
||||||
|
error("The initial status of all generators must be negative.")
|
||||||
|
end
|
||||||
|
# CHECK: model does not support startup costs (in time series)
|
||||||
|
if any(u -> length(u.startup_categories) > 1, all_units)
|
||||||
|
error("The method does NOT support time-varying start-up costs.")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function _modify_scenario!(
|
||||||
|
sc::UnitCommitmentScenario,
|
||||||
|
model::JuMP.Model,
|
||||||
|
method::AELMP,
|
||||||
|
)
|
||||||
|
# this function modifies the sc units (generators)
|
||||||
|
if !method.allow_offline_participation
|
||||||
|
# 1. remove (if NOT allowing) the offline generators
|
||||||
|
units_to_remove = []
|
||||||
|
for unit in sc.thermal_units
|
||||||
|
# remove based on the solved UC model result
|
||||||
|
# remove the unit if it is never on
|
||||||
|
if all(t -> value(model[:is_on][unit.name, t]) == 0, sc.time)
|
||||||
|
# unregister from the bus
|
||||||
|
filter!(x -> x.name != unit.name, unit.bus.thermal_units)
|
||||||
|
# unregister from the reserve
|
||||||
|
for r in unit.reserves
|
||||||
|
filter!(x -> x.name != unit.name, r.thermal_units)
|
||||||
|
end
|
||||||
|
# append the name to the remove list
|
||||||
|
push!(units_to_remove, unit.name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# unregister the units from the remove list
|
||||||
|
filter!(x -> !(x.name in units_to_remove), sc.thermal_units)
|
||||||
|
end
|
||||||
|
|
||||||
|
for unit in sc.thermal_units
|
||||||
|
# 2. set min generation requirement to 0 by adding 0 to production curve and cost
|
||||||
|
# min_power & min_costs are vectors with dimension T
|
||||||
|
if unit.min_power[1] != 0
|
||||||
|
first_cost_segment = unit.cost_segments[1]
|
||||||
|
pushfirst!(
|
||||||
|
unit.cost_segments,
|
||||||
|
CostSegment(
|
||||||
|
ones(size(first_cost_segment.mw)) * unit.min_power[1],
|
||||||
|
ones(size(first_cost_segment.cost)) *
|
||||||
|
unit.min_power_cost[1] / unit.min_power[1],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
unit.min_power = zeros(size(first_cost_segment.mw))
|
||||||
|
unit.min_power_cost = zeros(size(first_cost_segment.cost))
|
||||||
|
end
|
||||||
|
|
||||||
|
# 3. average the start-up costs (if considering)
|
||||||
|
# if consider_startup_costs = false, then use the current first_startup_cost
|
||||||
|
first_startup_cost = unit.startup_categories[1].cost
|
||||||
|
if method.consider_startup_costs
|
||||||
|
additional_unit_cost = first_startup_cost / unit.max_power[1]
|
||||||
|
for i in eachindex(unit.cost_segments)
|
||||||
|
unit.cost_segments[i].cost .+= additional_unit_cost
|
||||||
|
end
|
||||||
|
first_startup_cost = 0.0 # zero out the start up cost
|
||||||
|
end
|
||||||
|
unit.startup_categories =
|
||||||
|
StartupCategory[StartupCategory(0, first_startup_cost)]
|
||||||
|
end
|
||||||
|
return sc.thermal_units_by_name =
|
||||||
|
Dict(g.name => g for g in sc.thermal_units)
|
||||||
|
end
|
||||||
92
src/lmp/conventional.jl
Normal file
92
src/lmp/conventional.jl
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
# UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
|
||||||
|
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
||||||
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
|
|
||||||
|
using JuMP
|
||||||
|
|
||||||
|
"""
|
||||||
|
function compute_lmp(
|
||||||
|
model::JuMP.Model,
|
||||||
|
method::ConventionalLMP;
|
||||||
|
optimizer,
|
||||||
|
)::OrderedDict{Tuple{String,String,Int},Float64}
|
||||||
|
|
||||||
|
Calculates conventional locational marginal prices of the given unit commitment
|
||||||
|
instance. Returns a dictionary mapping `(bus_name, time)` to the marginal price.
|
||||||
|
|
||||||
|
Arguments
|
||||||
|
---------
|
||||||
|
|
||||||
|
- `model`:
|
||||||
|
the UnitCommitment model, must be solved before calling this function.
|
||||||
|
|
||||||
|
- `method`:
|
||||||
|
the LMP method.
|
||||||
|
|
||||||
|
- `optimizer`:
|
||||||
|
the optimizer for solving the LP problem.
|
||||||
|
|
||||||
|
Examples
|
||||||
|
--------
|
||||||
|
|
||||||
|
```julia
|
||||||
|
using UnitCommitment
|
||||||
|
using HiGHS
|
||||||
|
|
||||||
|
import UnitCommitment: ConventionalLMP
|
||||||
|
|
||||||
|
# Read benchmark instance
|
||||||
|
instance = UnitCommitment.read_benchmark("matpower/case118/2018-01-01")
|
||||||
|
|
||||||
|
# Build the model
|
||||||
|
model = UnitCommitment.build_model(
|
||||||
|
instance = instance,
|
||||||
|
optimizer = HiGHS.Optimizer,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Optimize the model
|
||||||
|
UnitCommitment.optimize!(model)
|
||||||
|
|
||||||
|
# Compute the LMPs using the conventional method
|
||||||
|
lmp = UnitCommitment.compute_lmp(
|
||||||
|
model,
|
||||||
|
ConventionalLMP(),
|
||||||
|
optimizer = HiGHS.Optimizer,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Access the LMPs
|
||||||
|
# Example: "s1" is the scenario name, "b1" is the bus name, 1 is the first time slot
|
||||||
|
@show lmp["s1", "b1", 1]
|
||||||
|
```
|
||||||
|
"""
|
||||||
|
function compute_lmp(
|
||||||
|
model::JuMP.Model,
|
||||||
|
::ConventionalLMP;
|
||||||
|
optimizer,
|
||||||
|
)::OrderedDict{Tuple{String,String,Int},Float64}
|
||||||
|
if !has_values(model)
|
||||||
|
error("The UC model must be solved before calculating the LMPs.")
|
||||||
|
end
|
||||||
|
lmp = OrderedDict()
|
||||||
|
|
||||||
|
@info "Fixing binary variables and relaxing integrality..."
|
||||||
|
vals = Dict(v => value(v) for v in all_variables(model))
|
||||||
|
for v in all_variables(model)
|
||||||
|
if is_binary(v)
|
||||||
|
unset_binary(v)
|
||||||
|
fix(v, vals[v])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
relax_integrality(model)
|
||||||
|
set_optimizer(model, optimizer)
|
||||||
|
|
||||||
|
@info "Solving the LP..."
|
||||||
|
JuMP.optimize!(model)
|
||||||
|
|
||||||
|
@info "Getting dual values (LMPs)..."
|
||||||
|
for (key, val) in model[:eq_net_injection]
|
||||||
|
lmp[key] = dual(val)
|
||||||
|
end
|
||||||
|
|
||||||
|
return lmp
|
||||||
|
end
|
||||||
28
src/lmp/structs.jl
Normal file
28
src/lmp/structs.jl
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
# UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
|
||||||
|
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
||||||
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
|
|
||||||
|
abstract type PricingMethod end
|
||||||
|
|
||||||
|
struct ConventionalLMP <: PricingMethod end
|
||||||
|
|
||||||
|
"""
|
||||||
|
struct AELMP <: PricingMethod
|
||||||
|
allow_offline_participation::Bool = true
|
||||||
|
consider_startup_costs::Bool = true
|
||||||
|
end
|
||||||
|
|
||||||
|
Approximate Extended LMPs.
|
||||||
|
|
||||||
|
Arguments
|
||||||
|
---------
|
||||||
|
|
||||||
|
- `allow_offline_participation`:
|
||||||
|
If true, offline assets are allowed to participate in pricing.
|
||||||
|
- `consider_startup_costs`:
|
||||||
|
If true, the start-up costs are averaged over each unit production; otherwise the production costs stay the same.
|
||||||
|
"""
|
||||||
|
Base.@kwdef struct AELMP <: PricingMethod
|
||||||
|
allow_offline_participation::Bool = true
|
||||||
|
consider_startup_costs::Bool = true
|
||||||
|
end
|
||||||
220
src/market/market.jl
Normal file
220
src/market/market.jl
Normal file
@@ -0,0 +1,220 @@
|
|||||||
|
# UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
|
||||||
|
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
||||||
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
|
|
||||||
|
"""
|
||||||
|
solve_market(
|
||||||
|
da_path::Union{String, Vector{String}},
|
||||||
|
rt_paths::Vector{String},
|
||||||
|
settings::MarketSettings;
|
||||||
|
optimizer,
|
||||||
|
lp_optimizer = nothing,
|
||||||
|
after_build_da = nothing,
|
||||||
|
after_optimize_da = nothing,
|
||||||
|
after_build_rt = nothing,
|
||||||
|
after_optimize_rt = nothing,
|
||||||
|
)::OrderedDict
|
||||||
|
|
||||||
|
Solve the day-ahead and the real-time markets by the means of commitment status mapping.
|
||||||
|
The method firstly acquires the commitment status outcomes through the resolution of the day-ahead market;
|
||||||
|
and secondly resolves each real-time market based on the corresponding results obtained previously.
|
||||||
|
|
||||||
|
Arguments
|
||||||
|
---------
|
||||||
|
|
||||||
|
- `da_path`:
|
||||||
|
the data file path of the day-ahead market, can be stochastic.
|
||||||
|
|
||||||
|
- `rt_paths`:
|
||||||
|
the list of data file paths of the real-time markets, must be deterministic for each market.
|
||||||
|
|
||||||
|
- `settings`:
|
||||||
|
the MarketSettings which include the problem formulation, the solving method, and LMP method.
|
||||||
|
|
||||||
|
- `optimizer`:
|
||||||
|
the optimizer for solving the problem.
|
||||||
|
|
||||||
|
- `lp_optimizer`:
|
||||||
|
the linear programming optimizer for solving the LMP problem, defaults to `nothing`.
|
||||||
|
If not specified by the user, the program uses `optimizer` instead.
|
||||||
|
|
||||||
|
- `after_build_da`:
|
||||||
|
a user-defined function that allows modifying the DA model after building,
|
||||||
|
must have 2 arguments `model` and `instance` in order.
|
||||||
|
|
||||||
|
- `after_optimize_da`:
|
||||||
|
a user-defined function that allows handling additional steps after optimizing the DA model,
|
||||||
|
must have 3 arguments `solution`, `model` and `instance` in order.
|
||||||
|
|
||||||
|
- `after_build_rt`:
|
||||||
|
a user-defined function that allows modifying each RT model after building,
|
||||||
|
must have 2 arguments `model` and `instance` in order.
|
||||||
|
|
||||||
|
- `after_optimize_rt`:
|
||||||
|
a user-defined function that allows handling additional steps after optimizing each RT model,
|
||||||
|
must have 3 arguments `solution`, `model` and `instance` in order.
|
||||||
|
|
||||||
|
|
||||||
|
Examples
|
||||||
|
--------
|
||||||
|
|
||||||
|
```julia
|
||||||
|
using UnitCommitment, Cbc, HiGHS
|
||||||
|
|
||||||
|
import UnitCommitment:
|
||||||
|
MarketSettings,
|
||||||
|
XavQiuWanThi2019,
|
||||||
|
ConventionalLMP,
|
||||||
|
Formulation
|
||||||
|
|
||||||
|
solution = UnitCommitment.solve_market(
|
||||||
|
"da_instance.json",
|
||||||
|
["rt_instance_1.json", "rt_instance_2.json", "rt_instance_3.json"],
|
||||||
|
MarketSettings(
|
||||||
|
inner_method = XavQiuWanThi2019.Method(),
|
||||||
|
lmp_method = ConventionalLMP(),
|
||||||
|
formulation = Formulation(),
|
||||||
|
),
|
||||||
|
optimizer = Cbc.Optimizer,
|
||||||
|
lp_optimizer = HiGHS.Optimizer,
|
||||||
|
)
|
||||||
|
"""
|
||||||
|
|
||||||
|
function solve_market(
|
||||||
|
da_path::Union{String,Vector{String}},
|
||||||
|
rt_paths::Vector{String},
|
||||||
|
settings::MarketSettings;
|
||||||
|
optimizer,
|
||||||
|
lp_optimizer = nothing,
|
||||||
|
after_build_da = nothing,
|
||||||
|
after_optimize_da = nothing,
|
||||||
|
after_build_rt = nothing,
|
||||||
|
after_optimize_rt = nothing,
|
||||||
|
)::OrderedDict
|
||||||
|
# solve da instance as usual
|
||||||
|
@info "Solving the day-ahead market with file $da_path..."
|
||||||
|
instance_da = UnitCommitment.read(da_path)
|
||||||
|
# LP optimizer is optional: if not specified, use optimizer
|
||||||
|
lp_optimizer = lp_optimizer === nothing ? optimizer : lp_optimizer
|
||||||
|
# build and optimize the DA market
|
||||||
|
model_da, solution_da = _build_and_optimize(
|
||||||
|
instance_da,
|
||||||
|
settings,
|
||||||
|
optimizer = optimizer,
|
||||||
|
lp_optimizer = lp_optimizer,
|
||||||
|
after_build = after_build_da,
|
||||||
|
after_optimize = after_optimize_da,
|
||||||
|
)
|
||||||
|
# prepare the final solution
|
||||||
|
solution = OrderedDict()
|
||||||
|
solution["Day-ahead market"] = solution_da
|
||||||
|
solution["Real-time markets"] = OrderedDict()
|
||||||
|
|
||||||
|
# count the time, sc.time = n-slots, sc.time_step = slot-interval
|
||||||
|
# sufficient to look at only one scenario
|
||||||
|
sc = instance_da.scenarios[1]
|
||||||
|
# max time (min) of the DA market
|
||||||
|
max_time = sc.time * sc.time_step
|
||||||
|
# current time increments through the RT market list
|
||||||
|
current_time = 0
|
||||||
|
# DA market time slots in (min)
|
||||||
|
da_time_intervals = [sc.time_step * ts for ts in 1:sc.time]
|
||||||
|
|
||||||
|
# get the uc status and set each uc fixed
|
||||||
|
solution_rt = OrderedDict()
|
||||||
|
prev_initial_status = OrderedDict()
|
||||||
|
for rt_path in rt_paths
|
||||||
|
@info "Solving the real-time market with file $rt_path..."
|
||||||
|
instance_rt = UnitCommitment.read(rt_path)
|
||||||
|
# check instance time
|
||||||
|
sc = instance_rt.scenarios[1]
|
||||||
|
# check each time slot in the RT model
|
||||||
|
for ts in 1:sc.time
|
||||||
|
slot_t_end = current_time + ts * sc.time_step
|
||||||
|
# ensure this RT's slot time ub never exceeds max time of DA
|
||||||
|
slot_t_end <= max_time || error(
|
||||||
|
"The time of the real-time market cannot exceed the time of the day-ahead market.",
|
||||||
|
)
|
||||||
|
# get the slot start time to determine commitment status
|
||||||
|
slot_t_start = slot_t_end - sc.time_step
|
||||||
|
# find the index of the first DA time slot that covers slot_t_start
|
||||||
|
da_time_slot = findfirst(ti -> slot_t_start < ti, da_time_intervals)
|
||||||
|
# update thermal unit commitment status
|
||||||
|
for g in sc.thermal_units
|
||||||
|
g.commitment_status[ts] =
|
||||||
|
value(model_da[:is_on][g.name, da_time_slot]) == 1.0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# update current time by ONE slot only
|
||||||
|
current_time += sc.time_step
|
||||||
|
# set initial status for all generators in all scenarios
|
||||||
|
if !isempty(solution_rt) && !isempty(prev_initial_status)
|
||||||
|
for g in sc.thermal_units
|
||||||
|
g.initial_power =
|
||||||
|
solution_rt["Thermal production (MW)"][g.name][1]
|
||||||
|
g.initial_status = UnitCommitment._determine_initial_status(
|
||||||
|
prev_initial_status[g.name],
|
||||||
|
[solution_rt["Is on"][g.name][1]],
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# build and optimize the RT market
|
||||||
|
_, solution_rt = _build_and_optimize(
|
||||||
|
instance_rt,
|
||||||
|
settings,
|
||||||
|
optimizer = optimizer,
|
||||||
|
lp_optimizer = lp_optimizer,
|
||||||
|
after_build = after_build_rt,
|
||||||
|
after_optimize = after_optimize_rt,
|
||||||
|
)
|
||||||
|
prev_initial_status =
|
||||||
|
OrderedDict(g.name => g.initial_status for g in sc.thermal_units)
|
||||||
|
# rt_name = first(split(last(split(rt_path, "/")), "."))
|
||||||
|
solution["Real-time markets"][rt_path] = solution_rt
|
||||||
|
end # end of for-loop that checks each RT market
|
||||||
|
return solution
|
||||||
|
end
|
||||||
|
|
||||||
|
function _build_and_optimize(
|
||||||
|
instance::UnitCommitmentInstance,
|
||||||
|
settings::MarketSettings;
|
||||||
|
optimizer,
|
||||||
|
lp_optimizer,
|
||||||
|
after_build = nothing,
|
||||||
|
after_optimize = nothing,
|
||||||
|
)::Tuple{JuMP.Model,OrderedDict}
|
||||||
|
# build model with after build
|
||||||
|
model = UnitCommitment.build_model(
|
||||||
|
instance = instance,
|
||||||
|
optimizer = optimizer,
|
||||||
|
formulation = settings.formulation,
|
||||||
|
)
|
||||||
|
if after_build !== nothing
|
||||||
|
after_build(model, instance)
|
||||||
|
end
|
||||||
|
# optimize model
|
||||||
|
UnitCommitment.optimize!(model, settings.inner_method)
|
||||||
|
solution = UnitCommitment.solution(model)
|
||||||
|
# compute lmp and add to solution
|
||||||
|
if settings.lmp_method !== nothing
|
||||||
|
lmp = UnitCommitment.compute_lmp(
|
||||||
|
model,
|
||||||
|
settings.lmp_method,
|
||||||
|
optimizer = lp_optimizer,
|
||||||
|
)
|
||||||
|
if length(instance.scenarios) == 1
|
||||||
|
solution["Locational marginal price"] = lmp
|
||||||
|
else
|
||||||
|
for sc in instance.scenarios
|
||||||
|
solution[sc.name]["Locational marginal price"] = OrderedDict(
|
||||||
|
key => val for (key, val) in lmp if key[1] == sc.name
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# run after optimize with solution
|
||||||
|
if after_optimize !== nothing
|
||||||
|
after_optimize(solution, model, instance)
|
||||||
|
end
|
||||||
|
return model, solution
|
||||||
|
end
|
||||||
33
src/market/structs.jl
Normal file
33
src/market/structs.jl
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
|
||||||
|
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
||||||
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
|
|
||||||
|
import ..SolutionMethod
|
||||||
|
import ..PricingMethod
|
||||||
|
import ..Formulation
|
||||||
|
|
||||||
|
"""
|
||||||
|
struct MarketSettings
|
||||||
|
inner_method::SolutionMethod = XavQiuWanThi2019.Method()
|
||||||
|
lmp_method::Union{PricingMethod, Nothing} = ConventionalLMP()
|
||||||
|
formulation::Formulation = Formulation()
|
||||||
|
end
|
||||||
|
|
||||||
|
Market setting struct, typically used to map a day-ahead market to real-time markets.
|
||||||
|
|
||||||
|
Arguments
|
||||||
|
---------
|
||||||
|
|
||||||
|
- `inner_method`:
|
||||||
|
method to solve each marketing problem.
|
||||||
|
- `lmp_method`:
|
||||||
|
a PricingMethod method to calculate the locational marginal prices.
|
||||||
|
If it is set to `nothing`, the LMPs will not be calculated.
|
||||||
|
- `formulation`:
|
||||||
|
problem formulation.
|
||||||
|
"""
|
||||||
|
Base.@kwdef struct MarketSettings
|
||||||
|
inner_method::SolutionMethod = XavQiuWanThi2019.Method()
|
||||||
|
lmp_method::Union{PricingMethod,Nothing} = ConventionalLMP()
|
||||||
|
formulation::Formulation = Formulation()
|
||||||
|
end
|
||||||
BIN
src/model/.DS_Store
vendored
BIN
src/model/.DS_Store
vendored
Binary file not shown.
@@ -9,22 +9,59 @@ import JuMP: value, fix, set_name
|
|||||||
function build_model(;
|
function build_model(;
|
||||||
instance::UnitCommitmentInstance,
|
instance::UnitCommitmentInstance,
|
||||||
optimizer = nothing,
|
optimizer = nothing,
|
||||||
|
formulation = Formulation(),
|
||||||
variable_names::Bool = false,
|
variable_names::Bool = false,
|
||||||
)::JuMP.Model
|
)::JuMP.Model
|
||||||
|
|
||||||
Build the JuMP model corresponding to the given unit commitment instance.
|
Build the JuMP model corresponding to the given unit commitment instance.
|
||||||
|
|
||||||
Arguments
|
Arguments
|
||||||
=========
|
---------
|
||||||
|
|
||||||
- `instance`:
|
- `instance`:
|
||||||
the instance.
|
the instance.
|
||||||
- `optimizer`:
|
- `optimizer`:
|
||||||
the optimizer factory that should be attached to this model (e.g. Cbc.Optimizer).
|
the optimizer factory that should be attached to this model (e.g. Cbc.Optimizer).
|
||||||
If not provided, no optimizer will be attached.
|
If not provided, no optimizer will be attached.
|
||||||
|
- `formulation`:
|
||||||
|
the MIP formulation to use. By default, uses a formulation that combines
|
||||||
|
modeling components from different publications that provides good
|
||||||
|
performance across a wide variety of instances. An alternative formulation
|
||||||
|
may also be provided.
|
||||||
- `variable_names`:
|
- `variable_names`:
|
||||||
If true, set variable and constraint names. Important if the model is going
|
if true, set variable and constraint names. Important if the model is going
|
||||||
to be exported to an MPS file. For large models, this can take significant
|
to be exported to an MPS file. For large models, this can take significant
|
||||||
time, so it's disabled by default.
|
time, so it's disabled by default.
|
||||||
|
|
||||||
|
Examples
|
||||||
|
--------
|
||||||
|
|
||||||
|
```julia
|
||||||
|
# Read benchmark instance
|
||||||
|
instance = UnitCommitment.read_benchmark("matpower/case118/2017-02-01")
|
||||||
|
|
||||||
|
# Construct model (using state-of-the-art defaults)
|
||||||
|
model = UnitCommitment.build_model(
|
||||||
|
instance = instance,
|
||||||
|
optimizer = Cbc.Optimizer,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Construct model (using customized formulation)
|
||||||
|
model = UnitCommitment.build_model(
|
||||||
|
instance = instance,
|
||||||
|
optimizer = Cbc.Optimizer,
|
||||||
|
formulation = Formulation(
|
||||||
|
pwl_costs = KnuOstWat2018.PwlCosts(),
|
||||||
|
ramping = MorLatRam2013.Ramping(),
|
||||||
|
startup_costs = MorLatRam2013.StartupCosts(),
|
||||||
|
transmission = ShiftFactorsFormulation(
|
||||||
|
isf_cutoff = 0.005,
|
||||||
|
lodf_cutoff = 0.001,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
"""
|
"""
|
||||||
function build_model(;
|
function build_model(;
|
||||||
instance::UnitCommitmentInstance,
|
instance::UnitCommitmentInstance,
|
||||||
@@ -32,22 +69,6 @@ function build_model(;
|
|||||||
formulation = Formulation(),
|
formulation = Formulation(),
|
||||||
variable_names::Bool = false,
|
variable_names::Bool = false,
|
||||||
)::JuMP.Model
|
)::JuMP.Model
|
||||||
if formulation.ramping == WanHob2016.Ramping() &&
|
|
||||||
instance.reserves.spinning >= ones(instance.time) .* 1e-6
|
|
||||||
error(
|
|
||||||
"Spinning reserves are not supported by the WanHob2016 ramping formulation",
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
if formulation.ramping !== WanHob2016.Ramping() && (
|
|
||||||
instance.reserves.upflexiramp >= ones(instance.time) .* 1e-6 ||
|
|
||||||
instance.reserves.dwflexiramp >= ones(instance.time) .* 1e-6
|
|
||||||
)
|
|
||||||
error(
|
|
||||||
"Flexiramp is supported only by the WanHob2016 ramping formulation",
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
@info "Building model..."
|
@info "Building model..."
|
||||||
time_model = @elapsed begin
|
time_model = @elapsed begin
|
||||||
model = Model()
|
model = Model()
|
||||||
@@ -56,20 +77,33 @@ function build_model(;
|
|||||||
end
|
end
|
||||||
model[:obj] = AffExpr()
|
model[:obj] = AffExpr()
|
||||||
model[:instance] = instance
|
model[:instance] = instance
|
||||||
_setup_transmission(model, formulation.transmission)
|
for g in instance.scenarios[1].thermal_units
|
||||||
for l in instance.lines
|
_add_unit_commitment!(model, g, formulation)
|
||||||
_add_transmission_line!(model, l, formulation.transmission)
|
|
||||||
end
|
end
|
||||||
for b in instance.buses
|
for sc in instance.scenarios
|
||||||
_add_bus!(model, b)
|
@info "Building scenario $(sc.name) with " *
|
||||||
|
"probability $(sc.probability)"
|
||||||
|
_setup_transmission(formulation.transmission, sc)
|
||||||
|
for l in sc.lines
|
||||||
|
_add_transmission_line!(model, l, formulation.transmission, sc)
|
||||||
end
|
end
|
||||||
for g in instance.units
|
for b in sc.buses
|
||||||
_add_unit!(model, g, formulation)
|
_add_bus!(model, b, sc)
|
||||||
end
|
end
|
||||||
for ps in instance.price_sensitive_loads
|
for ps in sc.price_sensitive_loads
|
||||||
_add_price_sensitive_load!(model, ps)
|
_add_price_sensitive_load!(model, ps, sc)
|
||||||
|
end
|
||||||
|
for g in sc.thermal_units
|
||||||
|
_add_unit_dispatch!(model, g, formulation, sc)
|
||||||
|
end
|
||||||
|
for pu in sc.profiled_units
|
||||||
|
_add_profiled_unit!(model, pu, sc)
|
||||||
|
end
|
||||||
|
for su in sc.storage_units
|
||||||
|
_add_storage_unit!(model, su, sc)
|
||||||
|
end
|
||||||
|
_add_system_wide_eqs!(model, sc)
|
||||||
end
|
end
|
||||||
_add_system_wide_eqs!(model)
|
|
||||||
@objective(model, Min, model[:obj])
|
@objective(model, Min, model[:obj])
|
||||||
end
|
end
|
||||||
@info @sprintf("Built model in %.2f seconds", time_model)
|
@info @sprintf("Built model in %.2f seconds", time_model)
|
||||||
|
|||||||
@@ -4,10 +4,11 @@
|
|||||||
|
|
||||||
function _add_ramp_eqs!(
|
function _add_ramp_eqs!(
|
||||||
model::JuMP.Model,
|
model::JuMP.Model,
|
||||||
g::Unit,
|
g::ThermalUnit,
|
||||||
formulation_prod_vars::Gar1962.ProdVars,
|
formulation_prod_vars::Gar1962.ProdVars,
|
||||||
formulation_ramping::ArrCon2000.Ramping,
|
formulation_ramping::ArrCon2000.Ramping,
|
||||||
formulation_status_vars::Gar1962.StatusVars,
|
formulation_status_vars::Gar1962.StatusVars,
|
||||||
|
sc::UnitCommitmentScenario,
|
||||||
)::Nothing
|
)::Nothing
|
||||||
# TODO: Move upper case constants to model[:instance]
|
# TODO: Move upper case constants to model[:instance]
|
||||||
RESERVES_WHEN_START_UP = true
|
RESERVES_WHEN_START_UP = true
|
||||||
@@ -19,10 +20,10 @@ function _add_ramp_eqs!(
|
|||||||
RD = g.ramp_down_limit
|
RD = g.ramp_down_limit
|
||||||
SU = g.startup_limit
|
SU = g.startup_limit
|
||||||
SD = g.shutdown_limit
|
SD = g.shutdown_limit
|
||||||
reserve = model[:reserve]
|
|
||||||
eq_ramp_down = _init(model, :eq_ramp_down)
|
eq_ramp_down = _init(model, :eq_ramp_down)
|
||||||
eq_ramp_up = _init(model, :eq_ramp_up)
|
eq_ramp_up = _init(model, :eq_ramp_up)
|
||||||
is_initially_on = (g.initial_status > 0)
|
is_initially_on = (g.initial_status > 0)
|
||||||
|
reserve = _total_reserves(model, g, sc)
|
||||||
|
|
||||||
# Gar1962.ProdVars
|
# Gar1962.ProdVars
|
||||||
prod_above = model[:prod_above]
|
prod_above = model[:prod_above]
|
||||||
@@ -37,27 +38,27 @@ function _add_ramp_eqs!(
|
|||||||
if t == 1
|
if t == 1
|
||||||
if is_initially_on
|
if is_initially_on
|
||||||
# min power is _not_ multiplied by is_on because if !is_on, then ramp up is irrelevant
|
# min power is _not_ multiplied by is_on because if !is_on, then ramp up is irrelevant
|
||||||
eq_ramp_up[gn, t] = @constraint(
|
eq_ramp_up[sc.name, gn, t] = @constraint(
|
||||||
model,
|
model,
|
||||||
g.min_power[t] +
|
g.min_power[t] +
|
||||||
prod_above[gn, t] +
|
prod_above[sc.name, gn, t] +
|
||||||
(RESERVES_WHEN_RAMP_UP ? reserve[gn, t] : 0.0) <=
|
(RESERVES_WHEN_RAMP_UP ? reserve[t] : 0.0) <=
|
||||||
g.initial_power + RU
|
g.initial_power + RU
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
max_prod_this_period =
|
max_prod_this_period =
|
||||||
g.min_power[t] * is_on[gn, t] +
|
g.min_power[t] * is_on[gn, t] +
|
||||||
prod_above[gn, t] +
|
prod_above[sc.name, gn, t] +
|
||||||
(
|
(
|
||||||
RESERVES_WHEN_START_UP || RESERVES_WHEN_RAMP_UP ?
|
RESERVES_WHEN_START_UP || RESERVES_WHEN_RAMP_UP ?
|
||||||
reserve[gn, t] : 0.0
|
reserve[t] : 0.0
|
||||||
)
|
)
|
||||||
min_prod_last_period =
|
min_prod_last_period =
|
||||||
g.min_power[t-1] * is_on[gn, t-1] + prod_above[gn, t-1]
|
g.min_power[t-1] * is_on[gn, t-1] + prod_above[sc.name, gn, t-1]
|
||||||
|
|
||||||
# Equation (24) in Kneuven et al. (2020)
|
# Equation (24) in Kneuven et al. (2020)
|
||||||
eq_ramp_up[gn, t] = @constraint(
|
eq_ramp_up[sc.name, gn, t] = @constraint(
|
||||||
model,
|
model,
|
||||||
max_prod_this_period - min_prod_last_period <=
|
max_prod_this_period - min_prod_last_period <=
|
||||||
RU * is_on[gn, t-1] + SU * switch_on[gn, t]
|
RU * is_on[gn, t-1] + SU * switch_on[gn, t]
|
||||||
@@ -71,24 +72,25 @@ function _add_ramp_eqs!(
|
|||||||
# min_power + RD < initial_power < SD
|
# min_power + RD < initial_power < SD
|
||||||
# then the generator should be able to shut down at time t = 1,
|
# then the generator should be able to shut down at time t = 1,
|
||||||
# but the constraint below will force the unit to produce power
|
# but the constraint below will force the unit to produce power
|
||||||
eq_ramp_down[gn, t] = @constraint(
|
eq_ramp_down[sc.name, gn, t] = @constraint(
|
||||||
model,
|
model,
|
||||||
g.initial_power - (g.min_power[t] + prod_above[gn, t]) <= RD
|
g.initial_power -
|
||||||
|
(g.min_power[t] + prod_above[sc.name, gn, t]) <= RD
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
max_prod_last_period =
|
max_prod_last_period =
|
||||||
g.min_power[t-1] * is_on[gn, t-1] +
|
g.min_power[t-1] * is_on[gn, t-1] +
|
||||||
prod_above[gn, t-1] +
|
prod_above[sc.name, gn, t-1] +
|
||||||
(
|
(
|
||||||
RESERVES_WHEN_SHUT_DOWN || RESERVES_WHEN_RAMP_DOWN ?
|
RESERVES_WHEN_SHUT_DOWN || RESERVES_WHEN_RAMP_DOWN ?
|
||||||
reserve[gn, t-1] : 0.0
|
reserve[t-1] : 0.0
|
||||||
)
|
)
|
||||||
min_prod_this_period =
|
min_prod_this_period =
|
||||||
g.min_power[t] * is_on[gn, t] + prod_above[gn, t]
|
g.min_power[t] * is_on[gn, t] + prod_above[sc.name, gn, t]
|
||||||
|
|
||||||
# Equation (25) in Kneuven et al. (2020)
|
# Equation (25) in Kneuven et al. (2020)
|
||||||
eq_ramp_down[gn, t] = @constraint(
|
eq_ramp_down[sc.name, gn, t] = @constraint(
|
||||||
model,
|
model,
|
||||||
max_prod_last_period - min_prod_this_period <=
|
max_prod_last_period - min_prod_this_period <=
|
||||||
RD * is_on[gn, t] + SD * switch_off[gn, t]
|
RD * is_on[gn, t] + SD * switch_off[gn, t]
|
||||||
|
|||||||
@@ -4,10 +4,11 @@
|
|||||||
|
|
||||||
function _add_production_piecewise_linear_eqs!(
|
function _add_production_piecewise_linear_eqs!(
|
||||||
model::JuMP.Model,
|
model::JuMP.Model,
|
||||||
g::Unit,
|
g::ThermalUnit,
|
||||||
formulation_prod_vars::Gar1962.ProdVars,
|
formulation_prod_vars::Gar1962.ProdVars,
|
||||||
formulation_pwl_costs::CarArr2006.PwlCosts,
|
formulation_pwl_costs::CarArr2006.PwlCosts,
|
||||||
formulation_status_vars::StatusVarsFormulation,
|
formulation_status_vars::StatusVarsFormulation,
|
||||||
|
sc::UnitCommitmentScenario,
|
||||||
)::Nothing
|
)::Nothing
|
||||||
eq_prod_above_def = _init(model, :eq_prod_above_def)
|
eq_prod_above_def = _init(model, :eq_prod_above_def)
|
||||||
eq_segprod_limit = _init(model, :eq_segprod_limit)
|
eq_segprod_limit = _init(model, :eq_segprod_limit)
|
||||||
@@ -26,28 +27,32 @@ function _add_production_piecewise_linear_eqs!(
|
|||||||
# difference between max power for segments k and k-1 so the
|
# difference between max power for segments k and k-1 so the
|
||||||
# value of cost_segments[k].mw[t] is the max production *for
|
# value of cost_segments[k].mw[t] is the max production *for
|
||||||
# that segment*
|
# that segment*
|
||||||
eq_segprod_limit[gn, t, k] = @constraint(
|
eq_segprod_limit[sc.name, gn, t, k] = @constraint(
|
||||||
model,
|
model,
|
||||||
segprod[gn, t, k] <= g.cost_segments[k].mw[t]
|
segprod[sc.name, gn, t, k] <= g.cost_segments[k].mw[t]
|
||||||
)
|
)
|
||||||
|
|
||||||
# Also add this as an explicit upper bound on segprod to make the
|
# Also add this as an explicit upper bound on segprod to make the
|
||||||
# solver's work a bit easier
|
# solver's work a bit easier
|
||||||
set_upper_bound(segprod[gn, t, k], g.cost_segments[k].mw[t])
|
set_upper_bound(
|
||||||
|
segprod[sc.name, gn, t, k],
|
||||||
|
g.cost_segments[k].mw[t],
|
||||||
|
)
|
||||||
|
|
||||||
# Definition of production
|
# Definition of production
|
||||||
# Equation (43) in Kneuven et al. (2020)
|
# Equation (43) in Kneuven et al. (2020)
|
||||||
eq_prod_above_def[gn, t] = @constraint(
|
eq_prod_above_def[sc.name, gn, t] = @constraint(
|
||||||
model,
|
model,
|
||||||
prod_above[gn, t] == sum(segprod[gn, t, k] for k in 1:K)
|
prod_above[sc.name, gn, t] ==
|
||||||
|
sum(segprod[sc.name, gn, t, k] for k in 1:K)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Objective function
|
# Objective function
|
||||||
# Equation (44) in Kneuven et al. (2020)
|
# Equation (44) in Kneuven et al. (2020)
|
||||||
add_to_expression!(
|
add_to_expression!(
|
||||||
model[:obj],
|
model[:obj],
|
||||||
segprod[gn, t, k],
|
segprod[sc.name, gn, t, k],
|
||||||
g.cost_segments[k].cost[t],
|
sc.probability * g.cost_segments[k].cost[t],
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,10 +4,11 @@
|
|||||||
|
|
||||||
function _add_ramp_eqs!(
|
function _add_ramp_eqs!(
|
||||||
model::JuMP.Model,
|
model::JuMP.Model,
|
||||||
g::Unit,
|
g::ThermalUnit,
|
||||||
formulation_prod_vars::Gar1962.ProdVars,
|
formulation_prod_vars::Gar1962.ProdVars,
|
||||||
formulation_ramping::DamKucRajAta2016.Ramping,
|
formulation_ramping::DamKucRajAta2016.Ramping,
|
||||||
formulation_status_vars::Gar1962.StatusVars,
|
formulation_status_vars::Gar1962.StatusVars,
|
||||||
|
sc::UnitCommitmentScenario,
|
||||||
)::Nothing
|
)::Nothing
|
||||||
# TODO: Move upper case constants to model[:instance]
|
# TODO: Move upper case constants to model[:instance]
|
||||||
RESERVES_WHEN_START_UP = true
|
RESERVES_WHEN_START_UP = true
|
||||||
@@ -23,7 +24,7 @@ function _add_ramp_eqs!(
|
|||||||
gn = g.name
|
gn = g.name
|
||||||
eq_str_ramp_down = _init(model, :eq_str_ramp_down)
|
eq_str_ramp_down = _init(model, :eq_str_ramp_down)
|
||||||
eq_str_ramp_up = _init(model, :eq_str_ramp_up)
|
eq_str_ramp_up = _init(model, :eq_str_ramp_up)
|
||||||
reserve = model[:reserve]
|
reserve = _total_reserves(model, g, sc)
|
||||||
|
|
||||||
# Gar1962.ProdVars
|
# Gar1962.ProdVars
|
||||||
prod_above = model[:prod_above]
|
prod_above = model[:prod_above]
|
||||||
@@ -48,17 +49,15 @@ function _add_ramp_eqs!(
|
|||||||
# end
|
# end
|
||||||
|
|
||||||
max_prod_this_period =
|
max_prod_this_period =
|
||||||
prod_above[gn, t] + (
|
prod_above[sc.name, gn, t] +
|
||||||
RESERVES_WHEN_START_UP || RESERVES_WHEN_RAMP_UP ?
|
(RESERVES_WHEN_START_UP || RESERVES_WHEN_RAMP_UP ? reserve[t] : 0.0)
|
||||||
reserve[gn, t] : 0.0
|
|
||||||
)
|
|
||||||
min_prod_last_period = 0.0
|
min_prod_last_period = 0.0
|
||||||
if t > 1 && time_invariant
|
if t > 1 && time_invariant
|
||||||
min_prod_last_period = prod_above[gn, t-1]
|
min_prod_last_period = prod_above[sc.name, gn, t-1]
|
||||||
|
|
||||||
# Equation (35) in Kneuven et al. (2020)
|
# Equation (35) in Kneuven et al. (2020)
|
||||||
# Sparser version of (24)
|
# Sparser version of (24)
|
||||||
eq_str_ramp_up[gn, t] = @constraint(
|
eq_str_ramp_up[sc.name, gn, t] = @constraint(
|
||||||
model,
|
model,
|
||||||
max_prod_this_period - min_prod_last_period <=
|
max_prod_this_period - min_prod_last_period <=
|
||||||
(SU - g.min_power[t] - RU) * switch_on[gn, t] +
|
(SU - g.min_power[t] - RU) * switch_on[gn, t] +
|
||||||
@@ -67,7 +66,8 @@ function _add_ramp_eqs!(
|
|||||||
elseif (t == 1 && is_initially_on) || (t > 1 && !time_invariant)
|
elseif (t == 1 && is_initially_on) || (t > 1 && !time_invariant)
|
||||||
if t > 1
|
if t > 1
|
||||||
min_prod_last_period =
|
min_prod_last_period =
|
||||||
prod_above[gn, t-1] + g.min_power[t-1] * is_on[gn, t-1]
|
prod_above[sc.name, gn, t-1] +
|
||||||
|
g.min_power[t-1] * is_on[gn, t-1]
|
||||||
else
|
else
|
||||||
min_prod_last_period = max(g.initial_power, 0.0)
|
min_prod_last_period = max(g.initial_power, 0.0)
|
||||||
end
|
end
|
||||||
@@ -78,7 +78,7 @@ function _add_ramp_eqs!(
|
|||||||
|
|
||||||
# Modified version of equation (35) in Kneuven et al. (2020)
|
# Modified version of equation (35) in Kneuven et al. (2020)
|
||||||
# Equivalent to (24)
|
# Equivalent to (24)
|
||||||
eq_str_ramp_up[gn, t] = @constraint(
|
eq_str_ramp_up[sc.name, gn, t] = @constraint(
|
||||||
model,
|
model,
|
||||||
max_prod_this_period - min_prod_last_period <=
|
max_prod_this_period - min_prod_last_period <=
|
||||||
(SU - RU) * switch_on[gn, t] + RU * is_on[gn, t]
|
(SU - RU) * switch_on[gn, t] + RU * is_on[gn, t]
|
||||||
@@ -88,9 +88,9 @@ function _add_ramp_eqs!(
|
|||||||
max_prod_last_period =
|
max_prod_last_period =
|
||||||
min_prod_last_period + (
|
min_prod_last_period + (
|
||||||
t > 1 && (RESERVES_WHEN_SHUT_DOWN || RESERVES_WHEN_RAMP_DOWN) ?
|
t > 1 && (RESERVES_WHEN_SHUT_DOWN || RESERVES_WHEN_RAMP_DOWN) ?
|
||||||
reserve[gn, t-1] : 0.0
|
reserve[t-1] : 0.0
|
||||||
)
|
)
|
||||||
min_prod_this_period = prod_above[gn, t]
|
min_prod_this_period = prod_above[sc.name, gn, t]
|
||||||
on_last_period = 0.0
|
on_last_period = 0.0
|
||||||
if t > 1
|
if t > 1
|
||||||
on_last_period = is_on[gn, t-1]
|
on_last_period = is_on[gn, t-1]
|
||||||
@@ -100,7 +100,7 @@ function _add_ramp_eqs!(
|
|||||||
|
|
||||||
if t > 1 && time_invariant
|
if t > 1 && time_invariant
|
||||||
# Equation (36) in Kneuven et al. (2020)
|
# Equation (36) in Kneuven et al. (2020)
|
||||||
eq_str_ramp_down[gn, t] = @constraint(
|
eq_str_ramp_down[sc.name, gn, t] = @constraint(
|
||||||
model,
|
model,
|
||||||
max_prod_last_period - min_prod_this_period <=
|
max_prod_last_period - min_prod_this_period <=
|
||||||
(SD - g.min_power[t] - RD) * switch_off[gn, t] +
|
(SD - g.min_power[t] - RD) * switch_off[gn, t] +
|
||||||
@@ -112,7 +112,7 @@ function _add_ramp_eqs!(
|
|||||||
|
|
||||||
# Modified version of equation (36) in Kneuven et al. (2020)
|
# Modified version of equation (36) in Kneuven et al. (2020)
|
||||||
# Equivalent to (25)
|
# Equivalent to (25)
|
||||||
eq_str_ramp_down[gn, t] = @constraint(
|
eq_str_ramp_down[sc.name, gn, t] = @constraint(
|
||||||
model,
|
model,
|
||||||
max_prod_last_period - min_prod_this_period <=
|
max_prod_last_period - min_prod_this_period <=
|
||||||
(SD - RD) * switch_off[gn, t] + RD * on_last_period
|
(SD - RD) * switch_off[gn, t] + RD * on_last_period
|
||||||
|
|||||||
@@ -4,34 +4,35 @@
|
|||||||
|
|
||||||
function _add_production_vars!(
|
function _add_production_vars!(
|
||||||
model::JuMP.Model,
|
model::JuMP.Model,
|
||||||
g::Unit,
|
g::ThermalUnit,
|
||||||
formulation_prod_vars::Gar1962.ProdVars,
|
formulation_prod_vars::Gar1962.ProdVars,
|
||||||
|
sc::UnitCommitmentScenario,
|
||||||
)::Nothing
|
)::Nothing
|
||||||
prod_above = _init(model, :prod_above)
|
prod_above = _init(model, :prod_above)
|
||||||
segprod = _init(model, :segprod)
|
segprod = _init(model, :segprod)
|
||||||
for t in 1:model[:instance].time
|
for t in 1:model[:instance].time
|
||||||
for k in 1:length(g.cost_segments)
|
for k in 1:length(g.cost_segments)
|
||||||
segprod[g.name, t, k] = @variable(model, lower_bound = 0)
|
segprod[sc.name, g.name, t, k] = @variable(model, lower_bound = 0)
|
||||||
end
|
end
|
||||||
prod_above[g.name, t] = @variable(model, lower_bound = 0)
|
prod_above[sc.name, g.name, t] = @variable(model, lower_bound = 0)
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
function _add_production_limit_eqs!(
|
function _add_production_limit_eqs!(
|
||||||
model::JuMP.Model,
|
model::JuMP.Model,
|
||||||
g::Unit,
|
g::ThermalUnit,
|
||||||
formulation_prod_vars::Gar1962.ProdVars,
|
formulation_prod_vars::Gar1962.ProdVars,
|
||||||
|
sc::UnitCommitmentScenario,
|
||||||
)::Nothing
|
)::Nothing
|
||||||
eq_prod_limit = _init(model, :eq_prod_limit)
|
eq_prod_limit = _init(model, :eq_prod_limit)
|
||||||
is_on = model[:is_on]
|
is_on = model[:is_on]
|
||||||
prod_above = model[:prod_above]
|
prod_above = model[:prod_above]
|
||||||
reserve = model[:reserve]
|
reserve = _total_reserves(model, g, sc)
|
||||||
gn = g.name
|
gn = g.name
|
||||||
for t in 1:model[:instance].time
|
for t in 1:model[:instance].time
|
||||||
# Objective function terms for production costs
|
# Objective function terms for production costs
|
||||||
# Part of (69) of Kneuven et al. (2020) as C^R_g * u_g(t) term
|
# Part of (69) of Kneuven et al. (2020) as C^R_g * u_g(t) term
|
||||||
add_to_expression!(model[:obj], is_on[gn, t], g.min_power_cost[t])
|
|
||||||
|
|
||||||
# Production limit
|
# Production limit
|
||||||
# Equation (18) in Kneuven et al. (2020)
|
# Equation (18) in Kneuven et al. (2020)
|
||||||
@@ -42,9 +43,10 @@ function _add_production_limit_eqs!(
|
|||||||
if power_diff < 1e-7
|
if power_diff < 1e-7
|
||||||
power_diff = 0.0
|
power_diff = 0.0
|
||||||
end
|
end
|
||||||
eq_prod_limit[gn, t] = @constraint(
|
eq_prod_limit[sc.name, gn, t] = @constraint(
|
||||||
model,
|
model,
|
||||||
prod_above[gn, t] + reserve[gn, t] <= power_diff * is_on[gn, t]
|
prod_above[sc.name, gn, t] + reserve[t] <=
|
||||||
|
power_diff * is_on[gn, t]
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,10 +4,11 @@
|
|||||||
|
|
||||||
function _add_production_piecewise_linear_eqs!(
|
function _add_production_piecewise_linear_eqs!(
|
||||||
model::JuMP.Model,
|
model::JuMP.Model,
|
||||||
g::Unit,
|
g::ThermalUnit,
|
||||||
formulation_prod_vars::Gar1962.ProdVars,
|
formulation_prod_vars::Gar1962.ProdVars,
|
||||||
formulation_pwl_costs::Gar1962.PwlCosts,
|
formulation_pwl_costs::Gar1962.PwlCosts,
|
||||||
formulation_status_vars::Gar1962.StatusVars,
|
formulation_status_vars::Gar1962.StatusVars,
|
||||||
|
sc::UnitCommitmentScenario,
|
||||||
)::Nothing
|
)::Nothing
|
||||||
eq_prod_above_def = _init(model, :eq_prod_above_def)
|
eq_prod_above_def = _init(model, :eq_prod_above_def)
|
||||||
eq_segprod_limit = _init(model, :eq_segprod_limit)
|
eq_segprod_limit = _init(model, :eq_segprod_limit)
|
||||||
@@ -24,9 +25,10 @@ function _add_production_piecewise_linear_eqs!(
|
|||||||
for t in 1:model[:instance].time
|
for t in 1:model[:instance].time
|
||||||
# Definition of production
|
# Definition of production
|
||||||
# Equation (43) in Kneuven et al. (2020)
|
# Equation (43) in Kneuven et al. (2020)
|
||||||
eq_prod_above_def[gn, t] = @constraint(
|
eq_prod_above_def[sc.name, gn, t] = @constraint(
|
||||||
model,
|
model,
|
||||||
prod_above[gn, t] == sum(segprod[gn, t, k] for k in 1:K)
|
prod_above[sc.name, gn, t] ==
|
||||||
|
sum(segprod[sc.name, gn, t, k] for k in 1:K)
|
||||||
)
|
)
|
||||||
|
|
||||||
for k in 1:K
|
for k in 1:K
|
||||||
@@ -37,21 +39,25 @@ function _add_production_piecewise_linear_eqs!(
|
|||||||
# difference between max power for segments k and k-1 so the
|
# difference between max power for segments k and k-1 so the
|
||||||
# value of cost_segments[k].mw[t] is the max production *for
|
# value of cost_segments[k].mw[t] is the max production *for
|
||||||
# that segment*
|
# that segment*
|
||||||
eq_segprod_limit[gn, t, k] = @constraint(
|
eq_segprod_limit[sc.name, gn, t, k] = @constraint(
|
||||||
model,
|
model,
|
||||||
segprod[gn, t, k] <= g.cost_segments[k].mw[t] * is_on[gn, t]
|
segprod[sc.name, gn, t, k] <=
|
||||||
|
g.cost_segments[k].mw[t] * is_on[gn, t]
|
||||||
)
|
)
|
||||||
|
|
||||||
# Also add this as an explicit upper bound on segprod to make the
|
# Also add this as an explicit upper bound on segprod to make the
|
||||||
# solver's work a bit easier
|
# solver's work a bit easier
|
||||||
set_upper_bound(segprod[gn, t, k], g.cost_segments[k].mw[t])
|
set_upper_bound(
|
||||||
|
segprod[sc.name, gn, t, k],
|
||||||
|
g.cost_segments[k].mw[t],
|
||||||
|
)
|
||||||
|
|
||||||
# Objective function
|
# Objective function
|
||||||
# Equation (44) in Kneuven et al. (2020)
|
# Equation (44) in Kneuven et al. (2020)
|
||||||
add_to_expression!(
|
add_to_expression!(
|
||||||
model[:obj],
|
model[:obj],
|
||||||
segprod[gn, t, k],
|
segprod[sc.name, gn, t, k],
|
||||||
g.cost_segments[k].cost[t],
|
sc.probability * g.cost_segments[k].cost[t],
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
function _add_status_vars!(
|
function _add_status_vars!(
|
||||||
model::JuMP.Model,
|
model::JuMP.Model,
|
||||||
g::Unit,
|
g::ThermalUnit,
|
||||||
formulation_status_vars::Gar1962.StatusVars,
|
formulation_status_vars::Gar1962.StatusVars,
|
||||||
)::Nothing
|
)::Nothing
|
||||||
is_on = _init(model, :is_on)
|
is_on = _init(model, :is_on)
|
||||||
@@ -20,13 +20,14 @@ function _add_status_vars!(
|
|||||||
switch_on[g.name, t] = @variable(model, binary = true)
|
switch_on[g.name, t] = @variable(model, binary = true)
|
||||||
switch_off[g.name, t] = @variable(model, binary = true)
|
switch_off[g.name, t] = @variable(model, binary = true)
|
||||||
end
|
end
|
||||||
|
add_to_expression!(model[:obj], is_on[g.name, t], g.min_power_cost[t])
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
function _add_status_eqs!(
|
function _add_status_eqs!(
|
||||||
model::JuMP.Model,
|
model::JuMP.Model,
|
||||||
g::Unit,
|
g::ThermalUnit,
|
||||||
formulation_status_vars::Gar1962.StatusVars,
|
formulation_status_vars::Gar1962.StatusVars,
|
||||||
)::Nothing
|
)::Nothing
|
||||||
eq_binary_link = _init(model, :eq_binary_link)
|
eq_binary_link = _init(model, :eq_binary_link)
|
||||||
|
|||||||
@@ -4,10 +4,11 @@
|
|||||||
|
|
||||||
function _add_production_piecewise_linear_eqs!(
|
function _add_production_piecewise_linear_eqs!(
|
||||||
model::JuMP.Model,
|
model::JuMP.Model,
|
||||||
g::Unit,
|
g::ThermalUnit,
|
||||||
formulation_prod_vars::Gar1962.ProdVars,
|
formulation_prod_vars::Gar1962.ProdVars,
|
||||||
formulation_pwl_costs::KnuOstWat2018.PwlCosts,
|
formulation_pwl_costs::KnuOstWat2018.PwlCosts,
|
||||||
formulation_status_vars::Gar1962.StatusVars,
|
formulation_status_vars::Gar1962.StatusVars,
|
||||||
|
sc::UnitCommitmentScenario,
|
||||||
)::Nothing
|
)::Nothing
|
||||||
eq_prod_above_def = _init(model, :eq_prod_above_def)
|
eq_prod_above_def = _init(model, :eq_prod_above_def)
|
||||||
eq_segprod_limit_a = _init(model, :eq_segprod_limit_a)
|
eq_segprod_limit_a = _init(model, :eq_segprod_limit_a)
|
||||||
@@ -58,27 +59,27 @@ function _add_production_piecewise_linear_eqs!(
|
|||||||
|
|
||||||
if g.min_uptime > 1
|
if g.min_uptime > 1
|
||||||
# Equation (46) in Kneuven et al. (2020)
|
# Equation (46) in Kneuven et al. (2020)
|
||||||
eq_segprod_limit_a[gn, t, k] = @constraint(
|
eq_segprod_limit_a[sc.name, gn, t, k] = @constraint(
|
||||||
model,
|
model,
|
||||||
segprod[gn, t, k] <=
|
segprod[sc.name, gn, t, k] <=
|
||||||
g.cost_segments[k].mw[t] * is_on[gn, t] -
|
g.cost_segments[k].mw[t] * is_on[gn, t] -
|
||||||
Cv * switch_on[gn, t] -
|
Cv * switch_on[gn, t] -
|
||||||
(t < T ? Cw * switch_off[gn, t+1] : 0.0)
|
(t < T ? Cw * switch_off[gn, t+1] : 0.0)
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
# Equation (47a)/(48a) in Kneuven et al. (2020)
|
# Equation (47a)/(48a) in Kneuven et al. (2020)
|
||||||
eq_segprod_limit_b[gn, t, k] = @constraint(
|
eq_segprod_limit_b[sc.name, gn, t, k] = @constraint(
|
||||||
model,
|
model,
|
||||||
segprod[gn, t, k] <=
|
segprod[sc.name, gn, t, k] <=
|
||||||
g.cost_segments[k].mw[t] * is_on[gn, t] -
|
g.cost_segments[k].mw[t] * is_on[gn, t] -
|
||||||
Cv * switch_on[gn, t] -
|
Cv * switch_on[gn, t] -
|
||||||
(t < T ? max(0, Cv - Cw) * switch_off[gn, t+1] : 0.0)
|
(t < T ? max(0, Cv - Cw) * switch_off[gn, t+1] : 0.0)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Equation (47b)/(48b) in Kneuven et al. (2020)
|
# Equation (47b)/(48b) in Kneuven et al. (2020)
|
||||||
eq_segprod_limit_c[gn, t, k] = @constraint(
|
eq_segprod_limit_c[sc.name, gn, t, k] = @constraint(
|
||||||
model,
|
model,
|
||||||
segprod[gn, t, k] <=
|
segprod[sc.name, gn, t, k] <=
|
||||||
g.cost_segments[k].mw[t] * is_on[gn, t] -
|
g.cost_segments[k].mw[t] * is_on[gn, t] -
|
||||||
max(0, Cw - Cv) * switch_on[gn, t] -
|
max(0, Cw - Cv) * switch_on[gn, t] -
|
||||||
(t < T ? Cw * switch_off[gn, t+1] : 0.0)
|
(t < T ? Cw * switch_off[gn, t+1] : 0.0)
|
||||||
@@ -87,22 +88,26 @@ function _add_production_piecewise_linear_eqs!(
|
|||||||
|
|
||||||
# Definition of production
|
# Definition of production
|
||||||
# Equation (43) in Kneuven et al. (2020)
|
# Equation (43) in Kneuven et al. (2020)
|
||||||
eq_prod_above_def[gn, t] = @constraint(
|
eq_prod_above_def[sc.name, gn, t] = @constraint(
|
||||||
model,
|
model,
|
||||||
prod_above[gn, t] == sum(segprod[gn, t, k] for k in 1:K)
|
prod_above[sc.name, gn, t] ==
|
||||||
|
sum(segprod[sc.name, gn, t, k] for k in 1:K)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Objective function
|
# Objective function
|
||||||
# Equation (44) in Kneuven et al. (2020)
|
# Equation (44) in Kneuven et al. (2020)
|
||||||
add_to_expression!(
|
add_to_expression!(
|
||||||
model[:obj],
|
model[:obj],
|
||||||
segprod[gn, t, k],
|
segprod[sc.name, gn, t, k],
|
||||||
g.cost_segments[k].cost[t],
|
sc.probability * g.cost_segments[k].cost[t],
|
||||||
)
|
)
|
||||||
|
|
||||||
# Also add an explicit upper bound on segprod to make the solver's
|
# Also add an explicit upper bound on segprod to make the solver's
|
||||||
# work a bit easier
|
# work a bit easier
|
||||||
set_upper_bound(segprod[gn, t, k], g.cost_segments[k].mw[t])
|
set_upper_bound(
|
||||||
|
segprod[sc.name, gn, t, k],
|
||||||
|
g.cost_segments[k].mw[t],
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,10 +4,11 @@
|
|||||||
|
|
||||||
function _add_ramp_eqs!(
|
function _add_ramp_eqs!(
|
||||||
model::JuMP.Model,
|
model::JuMP.Model,
|
||||||
g::Unit,
|
g::ThermalUnit,
|
||||||
formulation_prod_vars::Gar1962.ProdVars,
|
formulation_prod_vars::Gar1962.ProdVars,
|
||||||
formulation_ramping::MorLatRam2013.Ramping,
|
formulation_ramping::MorLatRam2013.Ramping,
|
||||||
formulation_status_vars::Gar1962.StatusVars,
|
formulation_status_vars::Gar1962.StatusVars,
|
||||||
|
sc::UnitCommitmentScenario,
|
||||||
)::Nothing
|
)::Nothing
|
||||||
# TODO: Move upper case constants to model[:instance]
|
# TODO: Move upper case constants to model[:instance]
|
||||||
RESERVES_WHEN_START_UP = true
|
RESERVES_WHEN_START_UP = true
|
||||||
@@ -22,7 +23,7 @@ function _add_ramp_eqs!(
|
|||||||
gn = g.name
|
gn = g.name
|
||||||
eq_ramp_down = _init(model, :eq_ramp_down)
|
eq_ramp_down = _init(model, :eq_ramp_down)
|
||||||
eq_ramp_up = _init(model, :eq_str_ramp_up)
|
eq_ramp_up = _init(model, :eq_str_ramp_up)
|
||||||
reserve = model[:reserve]
|
reserve = _total_reserves(model, g, sc)
|
||||||
|
|
||||||
# Gar1962.ProdVars
|
# Gar1962.ProdVars
|
||||||
prod_above = model[:prod_above]
|
prod_above = model[:prod_above]
|
||||||
@@ -39,11 +40,11 @@ function _add_ramp_eqs!(
|
|||||||
# Ramp up limit
|
# Ramp up limit
|
||||||
if t == 1
|
if t == 1
|
||||||
if is_initially_on
|
if is_initially_on
|
||||||
eq_ramp_up[gn, t] = @constraint(
|
eq_ramp_up[sc.name, gn, t] = @constraint(
|
||||||
model,
|
model,
|
||||||
g.min_power[t] +
|
g.min_power[t] +
|
||||||
prod_above[gn, t] +
|
prod_above[sc.name, gn, t] +
|
||||||
(RESERVES_WHEN_RAMP_UP ? reserve[gn, t] : 0.0) <=
|
(RESERVES_WHEN_RAMP_UP ? reserve[t] : 0.0) <=
|
||||||
g.initial_power + RU
|
g.initial_power + RU
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
@@ -58,13 +59,14 @@ function _add_ramp_eqs!(
|
|||||||
SU = g.startup_limit
|
SU = g.startup_limit
|
||||||
max_prod_this_period =
|
max_prod_this_period =
|
||||||
g.min_power[t] * is_on[gn, t] +
|
g.min_power[t] * is_on[gn, t] +
|
||||||
prod_above[gn, t] +
|
prod_above[sc.name, gn, t] +
|
||||||
(
|
(
|
||||||
RESERVES_WHEN_START_UP || RESERVES_WHEN_RAMP_UP ?
|
RESERVES_WHEN_START_UP || RESERVES_WHEN_RAMP_UP ?
|
||||||
reserve[gn, t] : 0.0
|
reserve[t] : 0.0
|
||||||
)
|
)
|
||||||
min_prod_last_period =
|
min_prod_last_period =
|
||||||
g.min_power[t-1] * is_on[gn, t-1] + prod_above[gn, t-1]
|
g.min_power[t-1] * is_on[gn, t-1] +
|
||||||
|
prod_above[sc.name, gn, t-1]
|
||||||
eq_ramp_up[gn, t] = @constraint(
|
eq_ramp_up[gn, t] = @constraint(
|
||||||
model,
|
model,
|
||||||
max_prod_this_period - min_prod_last_period <=
|
max_prod_this_period - min_prod_last_period <=
|
||||||
@@ -74,11 +76,11 @@ function _add_ramp_eqs!(
|
|||||||
# Equation (26) in Kneuven et al. (2020)
|
# Equation (26) in Kneuven et al. (2020)
|
||||||
# TODO: what if RU < SU? places too stringent upper bound
|
# TODO: what if RU < SU? places too stringent upper bound
|
||||||
# prod_above[gn, t] when starting up, and creates diff with (24).
|
# prod_above[gn, t] when starting up, and creates diff with (24).
|
||||||
eq_ramp_up[gn, t] = @constraint(
|
eq_ramp_up[sc.name, gn, t] = @constraint(
|
||||||
model,
|
model,
|
||||||
prod_above[gn, t] +
|
prod_above[sc.name, gn, t] +
|
||||||
(RESERVES_WHEN_RAMP_UP ? reserve[gn, t] : 0.0) -
|
(RESERVES_WHEN_RAMP_UP ? reserve[t] : 0.0) -
|
||||||
prod_above[gn, t-1] <= RU
|
prod_above[sc.name, gn, t-1] <= RU
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -90,9 +92,10 @@ function _add_ramp_eqs!(
|
|||||||
# min_power + RD < initial_power < SD
|
# min_power + RD < initial_power < SD
|
||||||
# then the generator should be able to shut down at time t = 1,
|
# then the generator should be able to shut down at time t = 1,
|
||||||
# but the constraint below will force the unit to produce power
|
# but the constraint below will force the unit to produce power
|
||||||
eq_ramp_down[gn, t] = @constraint(
|
eq_ramp_down[sc.name, gn, t] = @constraint(
|
||||||
model,
|
model,
|
||||||
g.initial_power - (g.min_power[t] + prod_above[gn, t]) <= RD
|
g.initial_power -
|
||||||
|
(g.min_power[t] + prod_above[sc.name, gn, t]) <= RD
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@@ -102,13 +105,13 @@ function _add_ramp_eqs!(
|
|||||||
SD = g.shutdown_limit
|
SD = g.shutdown_limit
|
||||||
max_prod_last_period =
|
max_prod_last_period =
|
||||||
g.min_power[t-1] * is_on[gn, t-1] +
|
g.min_power[t-1] * is_on[gn, t-1] +
|
||||||
prod_above[gn, t-1] +
|
prod_above[sc.name, gn, t-1] +
|
||||||
(
|
(
|
||||||
RESERVES_WHEN_SHUT_DOWN || RESERVES_WHEN_RAMP_DOWN ?
|
RESERVES_WHEN_SHUT_DOWN || RESERVES_WHEN_RAMP_DOWN ?
|
||||||
reserve[gn, t-1] : 0.0
|
reserve[t-1] : 0.0
|
||||||
)
|
)
|
||||||
min_prod_this_period =
|
min_prod_this_period =
|
||||||
g.min_power[t] * is_on[gn, t] + prod_above[gn, t]
|
g.min_power[t] * is_on[gn, t] + prod_above[sc.name, gn, t]
|
||||||
eq_ramp_down[gn, t] = @constraint(
|
eq_ramp_down[gn, t] = @constraint(
|
||||||
model,
|
model,
|
||||||
max_prod_last_period - min_prod_this_period <=
|
max_prod_last_period - min_prod_this_period <=
|
||||||
@@ -118,11 +121,11 @@ function _add_ramp_eqs!(
|
|||||||
# Equation (27) in Kneuven et al. (2020)
|
# Equation (27) in Kneuven et al. (2020)
|
||||||
# TODO: Similar to above, what to do if shutting down in time t
|
# TODO: Similar to above, what to do if shutting down in time t
|
||||||
# and RD < SD? There is a difference with (25).
|
# and RD < SD? There is a difference with (25).
|
||||||
eq_ramp_down[gn, t] = @constraint(
|
eq_ramp_down[sc.name, gn, t] = @constraint(
|
||||||
model,
|
model,
|
||||||
prod_above[gn, t-1] +
|
prod_above[sc.name, gn, t-1] +
|
||||||
(RESERVES_WHEN_RAMP_DOWN ? reserve[gn, t-1] : 0.0) -
|
(RESERVES_WHEN_RAMP_DOWN ? reserve[t-1] : 0.0) -
|
||||||
prod_above[gn, t] <= RD
|
prod_above[sc.name, gn, t] <= RD
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
function _add_startup_cost_eqs!(
|
function _add_startup_cost_eqs!(
|
||||||
model::JuMP.Model,
|
model::JuMP.Model,
|
||||||
g::Unit,
|
g::ThermalUnit,
|
||||||
formulation::MorLatRam2013.StartupCosts,
|
formulation::MorLatRam2013.StartupCosts,
|
||||||
)::Nothing
|
)::Nothing
|
||||||
eq_startup_choose = _init(model, :eq_startup_choose)
|
eq_startup_choose = _init(model, :eq_startup_choose)
|
||||||
|
|||||||
@@ -4,15 +4,16 @@
|
|||||||
|
|
||||||
function _add_ramp_eqs!(
|
function _add_ramp_eqs!(
|
||||||
model::JuMP.Model,
|
model::JuMP.Model,
|
||||||
g::Unit,
|
g::ThermalUnit,
|
||||||
formulation_prod_vars::Gar1962.ProdVars,
|
formulation_prod_vars::Gar1962.ProdVars,
|
||||||
formulation_ramping::PanGua2016.Ramping,
|
formulation_ramping::PanGua2016.Ramping,
|
||||||
formulation_status_vars::Gar1962.StatusVars,
|
formulation_status_vars::Gar1962.StatusVars,
|
||||||
|
sc::UnitCommitmentScenario,
|
||||||
)::Nothing
|
)::Nothing
|
||||||
# TODO: Move upper case constants to model[:instance]
|
# TODO: Move upper case constants to model[:instance]
|
||||||
RESERVES_WHEN_SHUT_DOWN = true
|
RESERVES_WHEN_SHUT_DOWN = true
|
||||||
gn = g.name
|
gn = g.name
|
||||||
reserve = model[:reserve]
|
reserve = _total_reserves(model, g, sc)
|
||||||
eq_str_prod_limit = _init(model, :eq_str_prod_limit)
|
eq_str_prod_limit = _init(model, :eq_str_prod_limit)
|
||||||
eq_prod_limit_ramp_up_extra_period =
|
eq_prod_limit_ramp_up_extra_period =
|
||||||
_init(model, :eq_prod_limit_ramp_up_extra_period)
|
_init(model, :eq_prod_limit_ramp_up_extra_period)
|
||||||
@@ -52,11 +53,11 @@ function _add_ramp_eqs!(
|
|||||||
# Generalization of (20)
|
# Generalization of (20)
|
||||||
# Necessary that if any of the switch_on = 1 in the sum,
|
# Necessary that if any of the switch_on = 1 in the sum,
|
||||||
# then switch_off[gn, t+1] = 0
|
# then switch_off[gn, t+1] = 0
|
||||||
eq_str_prod_limit[gn, t] = @constraint(
|
eq_str_prod_limit[sc.name, gn, t] = @constraint(
|
||||||
model,
|
model,
|
||||||
prod_above[gn, t] +
|
prod_above[sc.name, gn, t] +
|
||||||
g.min_power[t] * is_on[gn, t] +
|
g.min_power[t] * is_on[gn, t] +
|
||||||
reserve[gn, t] <=
|
reserve[t] <=
|
||||||
Pbar * is_on[gn, t] -
|
Pbar * is_on[gn, t] -
|
||||||
(t < T ? (Pbar - SD) * switch_off[gn, t+1] : 0.0) - sum(
|
(t < T ? (Pbar - SD) * switch_off[gn, t+1] : 0.0) - sum(
|
||||||
(Pbar - (SU + i * RU)) * switch_on[gn, t-i] for
|
(Pbar - (SU + i * RU)) * switch_on[gn, t-i] for
|
||||||
@@ -67,11 +68,12 @@ function _add_ramp_eqs!(
|
|||||||
if UT - 2 < TRU
|
if UT - 2 < TRU
|
||||||
# Equation (40) in Kneuven et al. (2020)
|
# Equation (40) in Kneuven et al. (2020)
|
||||||
# Covers an additional time period of the ramp-up trajectory, compared to (38)
|
# Covers an additional time period of the ramp-up trajectory, compared to (38)
|
||||||
eq_prod_limit_ramp_up_extra_period[gn, t] = @constraint(
|
eq_prod_limit_ramp_up_extra_period[sc.name, gn, t] =
|
||||||
|
@constraint(
|
||||||
model,
|
model,
|
||||||
prod_above[gn, t] +
|
prod_above[sc.name, gn, t] +
|
||||||
g.min_power[t] * is_on[gn, t] +
|
g.min_power[t] * is_on[gn, t] +
|
||||||
reserve[gn, t] <=
|
reserve[t] <=
|
||||||
Pbar * is_on[gn, t] - sum(
|
Pbar * is_on[gn, t] - sum(
|
||||||
(Pbar - (SU + i * RU)) * switch_on[gn, t-i] for
|
(Pbar - (SU + i * RU)) * switch_on[gn, t-i] for
|
||||||
i in 0:min(UT - 1, TRU, t - 1)
|
i in 0:min(UT - 1, TRU, t - 1)
|
||||||
@@ -84,11 +86,11 @@ function _add_ramp_eqs!(
|
|||||||
if KSD > 0
|
if KSD > 0
|
||||||
KSU = min(TRU, UT - 2 - KSD, t - 1)
|
KSU = min(TRU, UT - 2 - KSD, t - 1)
|
||||||
# Equation (41) in Kneuven et al. (2020)
|
# Equation (41) in Kneuven et al. (2020)
|
||||||
eq_prod_limit_shutdown_trajectory[gn, t] = @constraint(
|
eq_prod_limit_shutdown_trajectory[sc.name, gn, t] = @constraint(
|
||||||
model,
|
model,
|
||||||
prod_above[gn, t] +
|
prod_above[sc.name, gn, t] +
|
||||||
g.min_power[t] * is_on[gn, t] +
|
g.min_power[t] * is_on[gn, t] +
|
||||||
(RESERVES_WHEN_SHUT_DOWN ? reserve[gn, t] : 0.0) <=
|
(RESERVES_WHEN_SHUT_DOWN ? reserve[t] : 0.0) <=
|
||||||
Pbar * is_on[gn, t] - sum(
|
Pbar * is_on[gn, t] - sum(
|
||||||
(Pbar - (SD + i * RD)) * switch_off[gn, t+1+i] for
|
(Pbar - (SD + i * RD)) * switch_off[gn, t+1+i] for
|
||||||
i in 0:KSD
|
i in 0:KSD
|
||||||
|
|||||||
@@ -2,38 +2,13 @@
|
|||||||
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
||||||
# Released under the modified BSD license. See COPYING.md for more details.
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
|
|
||||||
function _add_flexiramp_vars!(model::JuMP.Model, g::Unit)::Nothing
|
|
||||||
upflexiramp = _init(model, :upflexiramp)
|
|
||||||
upflexiramp_shortfall = _init(model, :upflexiramp_shortfall)
|
|
||||||
mfg = _init(model, :mfg)
|
|
||||||
dwflexiramp = _init(model, :dwflexiramp)
|
|
||||||
dwflexiramp_shortfall = _init(model, :dwflexiramp_shortfall)
|
|
||||||
for t in 1:model[:instance].time
|
|
||||||
# maximum feasible generation, \bar{g_{its}} in Wang & Hobbs (2016)
|
|
||||||
mfg[g.name, t] = @variable(model, lower_bound = 0)
|
|
||||||
if g.provides_flexiramp_reserves[t]
|
|
||||||
upflexiramp[g.name, t] = @variable(model) # up-flexiramp, ur_{it} in Wang & Hobbs (2016)
|
|
||||||
dwflexiramp[g.name, t] = @variable(model) # down-flexiramp, dr_{it} in Wang & Hobbs (2016)
|
|
||||||
else
|
|
||||||
upflexiramp[g.name, t] = 0.0
|
|
||||||
dwflexiramp[g.name, t] = 0.0
|
|
||||||
end
|
|
||||||
upflexiramp_shortfall[t] =
|
|
||||||
(model[:instance].flexiramp_shortfall_penalty[t] >= 0) ?
|
|
||||||
@variable(model, lower_bound = 0) : 0.0
|
|
||||||
dwflexiramp_shortfall[t] =
|
|
||||||
(model[:instance].flexiramp_shortfall_penalty[t] >= 0) ?
|
|
||||||
@variable(model, lower_bound = 0) : 0.0
|
|
||||||
end
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
function _add_ramp_eqs!(
|
function _add_ramp_eqs!(
|
||||||
model::JuMP.Model,
|
model::JuMP.Model,
|
||||||
g::Unit,
|
g::ThermalUnit,
|
||||||
formulation_prod_vars::Gar1962.ProdVars,
|
::Gar1962.ProdVars,
|
||||||
formulation_ramping::WanHob2016.Ramping,
|
::WanHob2016.Ramping,
|
||||||
formulation_status_vars::Gar1962.StatusVars,
|
::Gar1962.StatusVars,
|
||||||
|
sc::UnitCommitmentScenario,
|
||||||
)::Nothing
|
)::Nothing
|
||||||
is_initially_on = (g.initial_status > 0)
|
is_initially_on = (g.initial_status > 0)
|
||||||
SU = g.startup_limit
|
SU = g.startup_limit
|
||||||
@@ -51,44 +26,56 @@ function _add_ramp_eqs!(
|
|||||||
dwflexiramp = model[:dwflexiramp]
|
dwflexiramp = model[:dwflexiramp]
|
||||||
mfg = model[:mfg]
|
mfg = model[:mfg]
|
||||||
|
|
||||||
|
if length(g.reserves) > 1
|
||||||
|
error("Each generator may only provide one flexiramp reserve")
|
||||||
|
end
|
||||||
|
for r in g.reserves
|
||||||
|
if r.type !== "flexiramp"
|
||||||
|
error(
|
||||||
|
"This formulation only supports flexiramp reserves, not $(r.type)",
|
||||||
|
)
|
||||||
|
end
|
||||||
|
rn = r.name
|
||||||
for t in 1:model[:instance].time
|
for t in 1:model[:instance].time
|
||||||
@constraint(
|
@constraint(
|
||||||
model,
|
model,
|
||||||
prod_above[gn, t] + (is_on[gn, t] * minp[t]) <= mfg[gn, t]
|
prod_above[sc.name, gn, t] + (is_on[gn, t] * minp[t]) <=
|
||||||
|
mfg[sc.name, gn, t]
|
||||||
) # Eq. (19) in Wang & Hobbs (2016)
|
) # Eq. (19) in Wang & Hobbs (2016)
|
||||||
@constraint(model, mfg[gn, t] <= is_on[gn, t] * maxp[t]) # Eq. (22) in Wang & Hobbs (2016)
|
@constraint(model, mfg[sc.name, gn, t] <= is_on[gn, t] * maxp[t]) # Eq. (22) in Wang & Hobbs (2016)
|
||||||
if t != model[:instance].time
|
if t != model[:instance].time
|
||||||
@constraint(
|
@constraint(
|
||||||
model,
|
model,
|
||||||
minp[t] * (is_on[gn, t+1] + is_on[gn, t] - 1) <=
|
minp[t] * (is_on[gn, t+1] + is_on[gn, t] - 1) <=
|
||||||
prod_above[gn, t] - dwflexiramp[gn, t] +
|
prod_above[sc.name, gn, t] -
|
||||||
(is_on[gn, t] * minp[t])
|
dwflexiramp[sc.name, rn, gn, t] + (is_on[gn, t] * minp[t])
|
||||||
) # first inequality of Eq. (20) in Wang & Hobbs (2016)
|
) # first inequality of Eq. (20) in Wang & Hobbs (2016)
|
||||||
@constraint(
|
@constraint(
|
||||||
model,
|
model,
|
||||||
prod_above[gn, t] - dwflexiramp[gn, t] +
|
prod_above[sc.name, gn, t] -
|
||||||
|
dwflexiramp[sc.name, rn, gn, t] +
|
||||||
(is_on[gn, t] * minp[t]) <=
|
(is_on[gn, t] * minp[t]) <=
|
||||||
mfg[gn, t+1] + (maxp[t] * (1 - is_on[gn, t+1]))
|
mfg[sc.name, gn, t+1] + (maxp[t] * (1 - is_on[gn, t+1]))
|
||||||
) # second inequality of Eq. (20) in Wang & Hobbs (2016)
|
) # second inequality of Eq. (20) in Wang & Hobbs (2016)
|
||||||
@constraint(
|
@constraint(
|
||||||
model,
|
model,
|
||||||
minp[t] * (is_on[gn, t+1] + is_on[gn, t] - 1) <=
|
minp[t] * (is_on[gn, t+1] + is_on[gn, t] - 1) <=
|
||||||
prod_above[gn, t] +
|
prod_above[sc.name, gn, t] +
|
||||||
upflexiramp[gn, t] +
|
upflexiramp[sc.name, rn, gn, t] +
|
||||||
(is_on[gn, t] * minp[t])
|
(is_on[gn, t] * minp[t])
|
||||||
) # first inequality of Eq. (21) in Wang & Hobbs (2016)
|
) # first inequality of Eq. (21) in Wang & Hobbs (2016)
|
||||||
@constraint(
|
@constraint(
|
||||||
model,
|
model,
|
||||||
prod_above[gn, t] +
|
prod_above[sc.name, gn, t] +
|
||||||
upflexiramp[gn, t] +
|
upflexiramp[sc.name, rn, gn, t] +
|
||||||
(is_on[gn, t] * minp[t]) <=
|
(is_on[gn, t] * minp[t]) <=
|
||||||
mfg[gn, t+1] + (maxp[t] * (1 - is_on[gn, t+1]))
|
mfg[sc.name, gn, t+1] + (maxp[t] * (1 - is_on[gn, t+1]))
|
||||||
) # second inequality of Eq. (21) in Wang & Hobbs (2016)
|
) # second inequality of Eq. (21) in Wang & Hobbs (2016)
|
||||||
if t != 1
|
if t != 1
|
||||||
@constraint(
|
@constraint(
|
||||||
model,
|
model,
|
||||||
mfg[gn, t] <=
|
mfg[sc.name, gn, t] <=
|
||||||
prod_above[gn, t-1] +
|
prod_above[sc.name, gn, t-1] +
|
||||||
(is_on[gn, t-1] * minp[t]) +
|
(is_on[gn, t-1] * minp[t]) +
|
||||||
(RU * is_on[gn, t-1]) +
|
(RU * is_on[gn, t-1]) +
|
||||||
(SU * (is_on[gn, t] - is_on[gn, t-1])) +
|
(SU * (is_on[gn, t] - is_on[gn, t-1])) +
|
||||||
@@ -96,8 +83,13 @@ function _add_ramp_eqs!(
|
|||||||
) # Eq. (23) in Wang & Hobbs (2016)
|
) # Eq. (23) in Wang & Hobbs (2016)
|
||||||
@constraint(
|
@constraint(
|
||||||
model,
|
model,
|
||||||
(prod_above[gn, t-1] + (is_on[gn, t-1] * minp[t])) -
|
(
|
||||||
(prod_above[gn, t] + (is_on[gn, t] * minp[t])) <=
|
prod_above[sc.name, gn, t-1] +
|
||||||
|
(is_on[gn, t-1] * minp[t])
|
||||||
|
) - (
|
||||||
|
prod_above[sc.name, gn, t] +
|
||||||
|
(is_on[gn, t] * minp[t])
|
||||||
|
) <=
|
||||||
RD * is_on[gn, t] +
|
RD * is_on[gn, t] +
|
||||||
SD * (is_on[gn, t-1] - is_on[gn, t]) +
|
SD * (is_on[gn, t-1] - is_on[gn, t]) +
|
||||||
maxp[t] * (1 - is_on[gn, t-1])
|
maxp[t] * (1 - is_on[gn, t-1])
|
||||||
@@ -105,7 +97,7 @@ function _add_ramp_eqs!(
|
|||||||
else
|
else
|
||||||
@constraint(
|
@constraint(
|
||||||
model,
|
model,
|
||||||
mfg[gn, t] <=
|
mfg[sc.name, gn, t] <=
|
||||||
initial_power +
|
initial_power +
|
||||||
(RU * is_initially_on) +
|
(RU * is_initially_on) +
|
||||||
(SU * (is_on[gn, t] - is_initially_on)) +
|
(SU * (is_on[gn, t] - is_initially_on)) +
|
||||||
@@ -113,8 +105,10 @@ function _add_ramp_eqs!(
|
|||||||
) # Eq. (23) in Wang & Hobbs (2016) for the first time period
|
) # Eq. (23) in Wang & Hobbs (2016) for the first time period
|
||||||
@constraint(
|
@constraint(
|
||||||
model,
|
model,
|
||||||
initial_power -
|
initial_power - (
|
||||||
(prod_above[gn, t] + (is_on[gn, t] * minp[t])) <=
|
prod_above[sc.name, gn, t] +
|
||||||
|
(is_on[gn, t] * minp[t])
|
||||||
|
) <=
|
||||||
RD * is_on[gn, t] +
|
RD * is_on[gn, t] +
|
||||||
SD * (is_initially_on - is_on[gn, t]) +
|
SD * (is_initially_on - is_on[gn, t]) +
|
||||||
maxp[t] * (1 - is_initially_on)
|
maxp[t] * (1 - is_initially_on)
|
||||||
@@ -122,18 +116,20 @@ function _add_ramp_eqs!(
|
|||||||
end
|
end
|
||||||
@constraint(
|
@constraint(
|
||||||
model,
|
model,
|
||||||
mfg[gn, t] <=
|
mfg[sc.name, gn, t] <=
|
||||||
(SD * (is_on[gn, t] - is_on[gn, t+1])) +
|
(SD * (is_on[gn, t] - is_on[gn, t+1])) +
|
||||||
(maxp[t] * is_on[gn, t+1])
|
(maxp[t] * is_on[gn, t+1])
|
||||||
) # Eq. (24) in Wang & Hobbs (2016)
|
) # Eq. (24) in Wang & Hobbs (2016)
|
||||||
@constraint(
|
@constraint(
|
||||||
model,
|
model,
|
||||||
-RD * is_on[gn, t+1] - SD * (is_on[gn, t] - is_on[gn, t+1]) -
|
-RD * is_on[gn, t+1] -
|
||||||
maxp[t] * (1 - is_on[gn, t]) <= upflexiramp[gn, t]
|
SD * (is_on[gn, t] - is_on[gn, t+1]) -
|
||||||
|
maxp[t] * (1 - is_on[gn, t]) <=
|
||||||
|
upflexiramp[sc.name, rn, gn, t]
|
||||||
) # first inequality of Eq. (26) in Wang & Hobbs (2016)
|
) # first inequality of Eq. (26) in Wang & Hobbs (2016)
|
||||||
@constraint(
|
@constraint(
|
||||||
model,
|
model,
|
||||||
upflexiramp[gn, t] <=
|
upflexiramp[sc.name, rn, gn, t] <=
|
||||||
RU * is_on[gn, t] +
|
RU * is_on[gn, t] +
|
||||||
SU * (is_on[gn, t+1] - is_on[gn, t]) +
|
SU * (is_on[gn, t+1] - is_on[gn, t]) +
|
||||||
maxp[t] * (1 - is_on[gn, t+1])
|
maxp[t] * (1 - is_on[gn, t+1])
|
||||||
@@ -141,11 +137,12 @@ function _add_ramp_eqs!(
|
|||||||
@constraint(
|
@constraint(
|
||||||
model,
|
model,
|
||||||
-RU * is_on[gn, t] - SU * (is_on[gn, t+1] - is_on[gn, t]) -
|
-RU * is_on[gn, t] - SU * (is_on[gn, t+1] - is_on[gn, t]) -
|
||||||
maxp[t] * (1 - is_on[gn, t+1]) <= dwflexiramp[gn, t]
|
maxp[t] * (1 - is_on[gn, t+1]) <=
|
||||||
|
dwflexiramp[sc.name, rn, gn, t]
|
||||||
) # first inequality of Eq. (27) in Wang & Hobbs (2016)
|
) # first inequality of Eq. (27) in Wang & Hobbs (2016)
|
||||||
@constraint(
|
@constraint(
|
||||||
model,
|
model,
|
||||||
dwflexiramp[gn, t] <=
|
dwflexiramp[sc.name, rn, gn, t] <=
|
||||||
RD * is_on[gn, t+1] +
|
RD * is_on[gn, t+1] +
|
||||||
SD * (is_on[gn, t] - is_on[gn, t+1]) +
|
SD * (is_on[gn, t] - is_on[gn, t+1]) +
|
||||||
maxp[t] * (1 - is_on[gn, t])
|
maxp[t] * (1 - is_on[gn, t])
|
||||||
@@ -153,20 +150,27 @@ function _add_ramp_eqs!(
|
|||||||
@constraint(
|
@constraint(
|
||||||
model,
|
model,
|
||||||
-maxp[t] * is_on[gn, t] + minp[t] * is_on[gn, t+1] <=
|
-maxp[t] * is_on[gn, t] + minp[t] * is_on[gn, t+1] <=
|
||||||
upflexiramp[gn, t]
|
upflexiramp[sc.name, rn, gn, t]
|
||||||
) # first inequality of Eq. (28) in Wang & Hobbs (2016)
|
) # first inequality of Eq. (28) in Wang & Hobbs (2016)
|
||||||
@constraint(model, upflexiramp[gn, t] <= maxp[t] * is_on[gn, t+1]) # second inequality of Eq. (28) in Wang & Hobbs (2016)
|
|
||||||
@constraint(model, -maxp[t] * is_on[gn, t+1] <= dwflexiramp[gn, t]) # first inequality of Eq. (29) in Wang & Hobbs (2016)
|
|
||||||
@constraint(
|
@constraint(
|
||||||
model,
|
model,
|
||||||
dwflexiramp[gn, t] <=
|
upflexiramp[sc.name, rn, gn, t] <= maxp[t] * is_on[gn, t+1]
|
||||||
|
) # second inequality of Eq. (28) in Wang & Hobbs (2016)
|
||||||
|
@constraint(
|
||||||
|
model,
|
||||||
|
-maxp[t] * is_on[gn, t+1] <=
|
||||||
|
dwflexiramp[sc.name, rn, gn, t]
|
||||||
|
) # first inequality of Eq. (29) in Wang & Hobbs (2016)
|
||||||
|
@constraint(
|
||||||
|
model,
|
||||||
|
dwflexiramp[sc.name, rn, gn, t] <=
|
||||||
(maxp[t] * is_on[gn, t]) - (minp[t] * is_on[gn, t+1])
|
(maxp[t] * is_on[gn, t]) - (minp[t] * is_on[gn, t+1])
|
||||||
) # second inequality of Eq. (29) in Wang & Hobbs (2016)
|
) # second inequality of Eq. (29) in Wang & Hobbs (2016)
|
||||||
else
|
else
|
||||||
@constraint(
|
@constraint(
|
||||||
model,
|
model,
|
||||||
mfg[gn, t] <=
|
mfg[sc.name, gn, t] <=
|
||||||
prod_above[gn, t-1] +
|
prod_above[sc.name, gn, t-1] +
|
||||||
(is_on[gn, t-1] * minp[t]) +
|
(is_on[gn, t-1] * minp[t]) +
|
||||||
(RU * is_on[gn, t-1]) +
|
(RU * is_on[gn, t-1]) +
|
||||||
(SU * (is_on[gn, t] - is_on[gn, t-1])) +
|
(SU * (is_on[gn, t] - is_on[gn, t-1])) +
|
||||||
@@ -174,8 +178,11 @@ function _add_ramp_eqs!(
|
|||||||
) # Eq. (23) in Wang & Hobbs (2016) for the last time period
|
) # Eq. (23) in Wang & Hobbs (2016) for the last time period
|
||||||
@constraint(
|
@constraint(
|
||||||
model,
|
model,
|
||||||
(prod_above[gn, t-1] + (is_on[gn, t-1] * minp[t])) -
|
(
|
||||||
(prod_above[gn, t] + (is_on[gn, t] * minp[t])) <=
|
prod_above[sc.name, gn, t-1] +
|
||||||
|
(is_on[gn, t-1] * minp[t])
|
||||||
|
) -
|
||||||
|
(prod_above[sc.name, gn, t] + (is_on[gn, t] * minp[t])) <=
|
||||||
RD * is_on[gn, t] +
|
RD * is_on[gn, t] +
|
||||||
SD * (is_on[gn, t-1] - is_on[gn, t]) +
|
SD * (is_on[gn, t-1] - is_on[gn, t]) +
|
||||||
maxp[t] * (1 - is_on[gn, t-1])
|
maxp[t] * (1 - is_on[gn, t-1])
|
||||||
@@ -183,3 +190,4 @@ function _add_ramp_eqs!(
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
Formulation described in:
|
Formulation described in:
|
||||||
|
|
||||||
B. Wang and B. F. Hobbs, "Real-Time Markets for Flexiramp: A Stochastic
|
B. Wang and B. F. Hobbs, "Real-Time Markets for Flexiramp: A Stochastic
|
||||||
Unit Commitment-Based Analysis," in IEEE Transactions on Power Systems,
|
Unit Commitment-Based Analysis," in IEEE Transactions on Power Systems,
|
||||||
vol. 31, no. 2, pp. 846-860, March 2016, doi: 10.1109/TPWRS.2015.2411268.
|
vol. 31, no. 2, pp. 846-860, March 2016, doi: 10.1109/TPWRS.2015.2411268.
|
||||||
|
|||||||
@@ -2,22 +2,30 @@
|
|||||||
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
||||||
# Released under the modified BSD license. See COPYING.md for more details.
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
|
|
||||||
function _add_bus!(model::JuMP.Model, b::Bus)::Nothing
|
function _add_bus!(
|
||||||
|
model::JuMP.Model,
|
||||||
|
b::Bus,
|
||||||
|
sc::UnitCommitmentScenario,
|
||||||
|
)::Nothing
|
||||||
net_injection = _init(model, :expr_net_injection)
|
net_injection = _init(model, :expr_net_injection)
|
||||||
curtail = _init(model, :curtail)
|
curtail = _init(model, :curtail)
|
||||||
for t in 1:model[:instance].time
|
for t in 1:model[:instance].time
|
||||||
# Fixed load
|
# Fixed load
|
||||||
net_injection[b.name, t] = AffExpr(-b.load[t])
|
net_injection[sc.name, b.name, t] = AffExpr(-b.load[t])
|
||||||
|
|
||||||
# Load curtailment
|
# Load curtailment
|
||||||
curtail[b.name, t] =
|
curtail[sc.name, b.name, t] =
|
||||||
@variable(model, lower_bound = 0, upper_bound = b.load[t])
|
@variable(model, lower_bound = 0, upper_bound = b.load[t])
|
||||||
|
|
||||||
add_to_expression!(net_injection[b.name, t], curtail[b.name, t], 1.0)
|
add_to_expression!(
|
||||||
|
net_injection[sc.name, b.name, t],
|
||||||
|
curtail[sc.name, b.name, t],
|
||||||
|
1.0,
|
||||||
|
)
|
||||||
add_to_expression!(
|
add_to_expression!(
|
||||||
model[:obj],
|
model[:obj],
|
||||||
curtail[b.name, t],
|
curtail[sc.name, b.name, t],
|
||||||
model[:instance].power_balance_penalty[t],
|
sc.power_balance_penalty[t] * sc.probability,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -6,43 +6,43 @@ function _add_transmission_line!(
|
|||||||
model::JuMP.Model,
|
model::JuMP.Model,
|
||||||
lm::TransmissionLine,
|
lm::TransmissionLine,
|
||||||
f::ShiftFactorsFormulation,
|
f::ShiftFactorsFormulation,
|
||||||
|
sc::UnitCommitmentScenario,
|
||||||
)::Nothing
|
)::Nothing
|
||||||
overflow = _init(model, :overflow)
|
overflow = _init(model, :overflow)
|
||||||
for t in 1:model[:instance].time
|
for t in 1:model[:instance].time
|
||||||
overflow[lm.name, t] = @variable(model, lower_bound = 0)
|
overflow[sc.name, lm.name, t] = @variable(model, lower_bound = 0)
|
||||||
add_to_expression!(
|
add_to_expression!(
|
||||||
model[:obj],
|
model[:obj],
|
||||||
overflow[lm.name, t],
|
overflow[sc.name, lm.name, t],
|
||||||
lm.flow_limit_penalty[t],
|
lm.flow_limit_penalty[t] * sc.probability,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
function _setup_transmission(
|
function _setup_transmission(
|
||||||
model::JuMP.Model,
|
|
||||||
formulation::ShiftFactorsFormulation,
|
formulation::ShiftFactorsFormulation,
|
||||||
|
sc::UnitCommitmentScenario,
|
||||||
)::Nothing
|
)::Nothing
|
||||||
instance = model[:instance]
|
|
||||||
isf = formulation.precomputed_isf
|
isf = formulation.precomputed_isf
|
||||||
lodf = formulation.precomputed_lodf
|
lodf = formulation.precomputed_lodf
|
||||||
if length(instance.buses) == 1
|
if length(sc.buses) == 1
|
||||||
isf = zeros(0, 0)
|
isf = zeros(0, 0)
|
||||||
lodf = zeros(0, 0)
|
lodf = zeros(0, 0)
|
||||||
elseif isf === nothing
|
elseif isf === nothing
|
||||||
@info "Computing injection shift factors..."
|
@info "Computing injection shift factors..."
|
||||||
time_isf = @elapsed begin
|
time_isf = @elapsed begin
|
||||||
isf = UnitCommitment._injection_shift_factors(
|
isf = UnitCommitment._injection_shift_factors(
|
||||||
lines = instance.lines,
|
buses = sc.buses,
|
||||||
buses = instance.buses,
|
lines = sc.lines,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
@info @sprintf("Computed ISF in %.2f seconds", time_isf)
|
@info @sprintf("Computed ISF in %.2f seconds", time_isf)
|
||||||
@info "Computing line outage factors..."
|
@info "Computing line outage factors..."
|
||||||
time_lodf = @elapsed begin
|
time_lodf = @elapsed begin
|
||||||
lodf = UnitCommitment._line_outage_factors(
|
lodf = UnitCommitment._line_outage_factors(
|
||||||
lines = instance.lines,
|
buses = sc.buses,
|
||||||
buses = instance.buses,
|
lines = sc.lines,
|
||||||
isf = isf,
|
isf = isf,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
@@ -55,7 +55,7 @@ function _setup_transmission(
|
|||||||
isf[abs.(isf).<formulation.isf_cutoff] .= 0
|
isf[abs.(isf).<formulation.isf_cutoff] .= 0
|
||||||
lodf[abs.(lodf).<formulation.lodf_cutoff] .= 0
|
lodf[abs.(lodf).<formulation.lodf_cutoff] .= 0
|
||||||
end
|
end
|
||||||
model[:isf] = isf
|
sc.isf = isf
|
||||||
model[:lodf] = lodf
|
sc.lodf = lodf
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,21 +5,26 @@
|
|||||||
function _add_price_sensitive_load!(
|
function _add_price_sensitive_load!(
|
||||||
model::JuMP.Model,
|
model::JuMP.Model,
|
||||||
ps::PriceSensitiveLoad,
|
ps::PriceSensitiveLoad,
|
||||||
|
sc::UnitCommitmentScenario,
|
||||||
)::Nothing
|
)::Nothing
|
||||||
loads = _init(model, :loads)
|
loads = _init(model, :loads)
|
||||||
net_injection = _init(model, :expr_net_injection)
|
net_injection = _init(model, :expr_net_injection)
|
||||||
for t in 1:model[:instance].time
|
for t in 1:model[:instance].time
|
||||||
# Decision variable
|
# Decision variable
|
||||||
loads[ps.name, t] =
|
loads[sc.name, ps.name, t] =
|
||||||
@variable(model, lower_bound = 0, upper_bound = ps.demand[t])
|
@variable(model, lower_bound = 0, upper_bound = ps.demand[t])
|
||||||
|
|
||||||
# Objective function terms
|
# Objective function terms
|
||||||
add_to_expression!(model[:obj], loads[ps.name, t], -ps.revenue[t])
|
add_to_expression!(
|
||||||
|
model[:obj],
|
||||||
|
loads[sc.name, ps.name, t],
|
||||||
|
-ps.revenue[t] * sc.probability,
|
||||||
|
)
|
||||||
|
|
||||||
# Net injection
|
# Net injection
|
||||||
add_to_expression!(
|
add_to_expression!(
|
||||||
net_injection[ps.bus.name, t],
|
net_injection[sc.name, ps.bus.name, t],
|
||||||
loads[ps.name, t],
|
loads[sc.name, ps.name, t],
|
||||||
-1.0,
|
-1.0,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|||||||
35
src/model/formulations/base/punit.jl
Normal file
35
src/model/formulations/base/punit.jl
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
# UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
|
||||||
|
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
||||||
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
|
|
||||||
|
function _add_profiled_unit!(
|
||||||
|
model::JuMP.Model,
|
||||||
|
pu::ProfiledUnit,
|
||||||
|
sc::UnitCommitmentScenario,
|
||||||
|
)::Nothing
|
||||||
|
punits = _init(model, :prod_profiled)
|
||||||
|
net_injection = _init(model, :expr_net_injection)
|
||||||
|
for t in 1:model[:instance].time
|
||||||
|
# Decision variable
|
||||||
|
punits[sc.name, pu.name, t] = @variable(
|
||||||
|
model,
|
||||||
|
lower_bound = pu.min_power[t],
|
||||||
|
upper_bound = pu.max_power[t]
|
||||||
|
)
|
||||||
|
|
||||||
|
# Objective function terms
|
||||||
|
add_to_expression!(
|
||||||
|
model[:obj],
|
||||||
|
punits[sc.name, pu.name, t],
|
||||||
|
pu.cost[t] * sc.probability,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Net injection
|
||||||
|
add_to_expression!(
|
||||||
|
net_injection[sc.name, pu.bus.name, t],
|
||||||
|
punits[sc.name, pu.name, t],
|
||||||
|
1.0,
|
||||||
|
)
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
@@ -10,15 +10,15 @@ using SparseArrays, Base.Threads, LinearAlgebra, JuMP
|
|||||||
Returns a (B-1)xL matrix M, where B is the number of buses and L is the number
|
Returns a (B-1)xL matrix M, where B is the number of buses and L is the number
|
||||||
of transmission lines. For a given bus b and transmission line l, the entry
|
of transmission lines. For a given bus b and transmission line l, the entry
|
||||||
M[l.offset, b.offset] indicates the amount of power (in MW) that flows through
|
M[l.offset, b.offset] indicates the amount of power (in MW) that flows through
|
||||||
transmission line l when 1 MW of power is injected at the slack bus (the bus
|
transmission line l when 1 MW of power is injected at b and withdrawn from the
|
||||||
that has offset zero) and withdrawn from b.
|
slack bus (the bus that has offset zero).
|
||||||
"""
|
"""
|
||||||
function _injection_shift_factors(;
|
function _injection_shift_factors(;
|
||||||
buses::Array{Bus},
|
buses::Array{Bus},
|
||||||
lines::Array{TransmissionLine},
|
lines::Array{TransmissionLine},
|
||||||
)
|
)
|
||||||
susceptance = _susceptance_matrix(lines)
|
susceptance = _susceptance_matrix(lines)
|
||||||
incidence = _reduced_incidence_matrix(lines = lines, buses = buses)
|
incidence = _reduced_incidence_matrix(buses = buses, lines = lines)
|
||||||
laplacian = transpose(incidence) * susceptance * incidence
|
laplacian = transpose(incidence) * susceptance * incidence
|
||||||
isf = susceptance * incidence * inv(Array(laplacian))
|
isf = susceptance * incidence * inv(Array(laplacian))
|
||||||
return isf
|
return isf
|
||||||
|
|||||||
125
src/model/formulations/base/storage.jl
Normal file
125
src/model/formulations/base/storage.jl
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
# UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
|
||||||
|
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
||||||
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
|
|
||||||
|
function _add_storage_unit!(
|
||||||
|
model::JuMP.Model,
|
||||||
|
su::StorageUnit,
|
||||||
|
sc::UnitCommitmentScenario,
|
||||||
|
)::Nothing
|
||||||
|
# Initialize variables
|
||||||
|
storage_level = _init(model, :storage_level)
|
||||||
|
charge_rate = _init(model, :charge_rate)
|
||||||
|
discharge_rate = _init(model, :discharge_rate)
|
||||||
|
is_charging = _init(model, :is_charging)
|
||||||
|
is_discharging = _init(model, :is_discharging)
|
||||||
|
eq_min_charge_rate = _init(model, :eq_min_charge_rate)
|
||||||
|
eq_max_charge_rate = _init(model, :eq_max_charge_rate)
|
||||||
|
eq_min_discharge_rate = _init(model, :eq_min_discharge_rate)
|
||||||
|
eq_max_discharge_rate = _init(model, :eq_max_discharge_rate)
|
||||||
|
# Initialize constraints
|
||||||
|
net_injection = _init(model, :expr_net_injection)
|
||||||
|
eq_storage_transition = _init(model, :eq_storage_transition)
|
||||||
|
eq_ending_level = _init(model, :eq_ending_level)
|
||||||
|
# time in hours
|
||||||
|
time_step = sc.time_step / 60
|
||||||
|
|
||||||
|
for t in 1:model[:instance].time
|
||||||
|
# Decision variable
|
||||||
|
storage_level[sc.name, su.name, t] = @variable(
|
||||||
|
model,
|
||||||
|
lower_bound = su.min_level[t],
|
||||||
|
upper_bound = su.max_level[t]
|
||||||
|
)
|
||||||
|
charge_rate[sc.name, su.name, t] = @variable(model)
|
||||||
|
discharge_rate[sc.name, su.name, t] = @variable(model)
|
||||||
|
is_charging[sc.name, su.name, t] = @variable(model, binary = true)
|
||||||
|
is_discharging[sc.name, su.name, t] = @variable(model, binary = true)
|
||||||
|
|
||||||
|
# Objective function terms ##### CHECK & FIXME
|
||||||
|
add_to_expression!(
|
||||||
|
model[:obj],
|
||||||
|
charge_rate[sc.name, su.name, t],
|
||||||
|
su.charge_cost[t] * sc.probability,
|
||||||
|
)
|
||||||
|
|
||||||
|
add_to_expression!(
|
||||||
|
model[:obj],
|
||||||
|
discharge_rate[sc.name, su.name, t],
|
||||||
|
su.discharge_cost[t] * sc.probability,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Net injection
|
||||||
|
add_to_expression!(
|
||||||
|
net_injection[sc.name, su.bus.name, t],
|
||||||
|
discharge_rate[sc.name, su.name, t],
|
||||||
|
1.0,
|
||||||
|
)
|
||||||
|
add_to_expression!(
|
||||||
|
net_injection[sc.name, su.bus.name, t],
|
||||||
|
charge_rate[sc.name, su.name, t],
|
||||||
|
-1.0,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Simultaneous charging and discharging
|
||||||
|
if !su.simultaneous_charge_and_discharge[t]
|
||||||
|
# Initialize the model dictionary
|
||||||
|
eq_simultaneous_charge_and_discharge =
|
||||||
|
_init(model, :eq_simultaneous_charge_and_discharge)
|
||||||
|
# Constraints
|
||||||
|
eq_simultaneous_charge_and_discharge[sc.name, su.name, t] =
|
||||||
|
@constraint(
|
||||||
|
model,
|
||||||
|
is_charging[sc.name, su.name, t] +
|
||||||
|
is_discharging[sc.name, su.name, t] <= 1.0
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Charge and discharge constraints
|
||||||
|
eq_min_charge_rate[sc.name, su.name, t] = @constraint(
|
||||||
|
model,
|
||||||
|
charge_rate[sc.name, su.name, t] >=
|
||||||
|
is_charging[sc.name, su.name, t] * su.min_charge_rate[t]
|
||||||
|
)
|
||||||
|
eq_max_charge_rate[sc.name, su.name, t] = @constraint(
|
||||||
|
model,
|
||||||
|
charge_rate[sc.name, su.name, t] <=
|
||||||
|
is_charging[sc.name, su.name, t] * su.max_charge_rate[t]
|
||||||
|
)
|
||||||
|
eq_min_discharge_rate[sc.name, su.name, t] = @constraint(
|
||||||
|
model,
|
||||||
|
discharge_rate[sc.name, su.name, t] >=
|
||||||
|
is_discharging[sc.name, su.name, t] * su.min_discharge_rate[t]
|
||||||
|
)
|
||||||
|
eq_max_discharge_rate[sc.name, su.name, t] = @constraint(
|
||||||
|
model,
|
||||||
|
discharge_rate[sc.name, su.name, t] <=
|
||||||
|
is_discharging[sc.name, su.name, t] * su.max_discharge_rate[t]
|
||||||
|
)
|
||||||
|
|
||||||
|
# Storage energy transition constraint
|
||||||
|
prev_storage_level =
|
||||||
|
t == 1 ? su.initial_level : storage_level[sc.name, su.name, t-1]
|
||||||
|
eq_storage_transition[sc.name, su.name, t] = @constraint(
|
||||||
|
model,
|
||||||
|
storage_level[sc.name, su.name, t] ==
|
||||||
|
(1 - su.loss_factor[t]) * prev_storage_level +
|
||||||
|
charge_rate[sc.name, su.name, t] *
|
||||||
|
time_step *
|
||||||
|
su.charge_efficiency[t] -
|
||||||
|
discharge_rate[sc.name, su.name, t] * time_step /
|
||||||
|
su.discharge_efficiency[t]
|
||||||
|
)
|
||||||
|
|
||||||
|
# Storage ending level constraint
|
||||||
|
if t == sc.time
|
||||||
|
eq_ending_level[sc.name, su.name] = @constraint(
|
||||||
|
model,
|
||||||
|
su.min_ending_level <=
|
||||||
|
storage_level[sc.name, su.name, t] <=
|
||||||
|
su.max_ending_level
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
@@ -9,6 +9,27 @@ abstract type StartupCostsFormulation end
|
|||||||
abstract type StatusVarsFormulation end
|
abstract type StatusVarsFormulation end
|
||||||
abstract type ProductionVarsFormulation end
|
abstract type ProductionVarsFormulation end
|
||||||
|
|
||||||
|
"""
|
||||||
|
struct Formulation
|
||||||
|
prod_vars::ProductionVarsFormulation
|
||||||
|
pwl_costs::PiecewiseLinearCostsFormulation
|
||||||
|
ramping::RampingFormulation
|
||||||
|
startup_costs::StartupCostsFormulation
|
||||||
|
status_vars::StatusVarsFormulation
|
||||||
|
transmission::TransmissionFormulation
|
||||||
|
end
|
||||||
|
|
||||||
|
Struct provided to `build_model` that holds various formulation components.
|
||||||
|
|
||||||
|
# Fields
|
||||||
|
|
||||||
|
- `prod_vars`: Formulation for the production decision variables
|
||||||
|
- `pwl_costs`: Formulation for the piecewise linear costs
|
||||||
|
- `ramping`: Formulation for ramping constraints
|
||||||
|
- `startup_costs`: Formulation for time-dependent start-up costs
|
||||||
|
- `status_vars`: Formulation for the status variables (e.g. `is_on`, `is_off`)
|
||||||
|
- `transmission`: Formulation for transmission and N-1 security constraints
|
||||||
|
"""
|
||||||
struct Formulation
|
struct Formulation
|
||||||
prod_vars::ProductionVarsFormulation
|
prod_vars::ProductionVarsFormulation
|
||||||
pwl_costs::PiecewiseLinearCostsFormulation
|
pwl_costs::PiecewiseLinearCostsFormulation
|
||||||
@@ -38,10 +59,10 @@ end
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
struct ShiftFactorsFormulation <: TransmissionFormulation
|
struct ShiftFactorsFormulation <: TransmissionFormulation
|
||||||
isf_cutoff::Float64
|
isf_cutoff::Float64 = 0.005
|
||||||
lodf_cutoff::Float64
|
lodf_cutoff::Float64 = 0.001
|
||||||
precomputed_isf::Union{Nothing,Matrix{Float64}}
|
precomputed_isf=nothing
|
||||||
precomputed_lodf::Union{Nothing,Matrix{Float64}}
|
precomputed_lodf=nothing
|
||||||
end
|
end
|
||||||
|
|
||||||
Transmission formulation based on Injection Shift Factors (ISF) and Line
|
Transmission formulation based on Injection Shift Factors (ISF) and Line
|
||||||
@@ -49,15 +70,15 @@ Outage Distribution Factors (LODF). Constraints are enforced in a lazy way.
|
|||||||
|
|
||||||
Arguments
|
Arguments
|
||||||
---------
|
---------
|
||||||
- `precomputed_isf::Union{Matrix{Float64},Nothing} = nothing`:
|
- `precomputed_isf`:
|
||||||
the injection shift factors matrix. If not provided, it will be computed.
|
the injection shift factors matrix. If not provided, it will be computed.
|
||||||
- `precomputed_lodf::Union{Matrix{Float64},Nothing} = nothing`:
|
- `precomputed_lodf`:
|
||||||
the line outage distribution factors matrix. If not provided, it will be
|
the line outage distribution factors matrix. If not provided, it will be
|
||||||
computed.
|
computed.
|
||||||
- `isf_cutoff::Float64 = 0.005`:
|
- `isf_cutoff`:
|
||||||
the cutoff that should be applied to the ISF matrix. Entries with magnitude
|
the cutoff that should be applied to the ISF matrix. Entries with magnitude
|
||||||
smaller than this value will be set to zero.
|
smaller than this value will be set to zero.
|
||||||
- `lodf_cutoff::Float64 = 0.001`:
|
- `lodf_cutoff`:
|
||||||
the cutoff that should be applied to the LODF matrix. Entries with magnitude
|
the cutoff that should be applied to the LODF matrix. Entries with magnitude
|
||||||
smaller than this value will be set to zero.
|
smaller than this value will be set to zero.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -2,101 +2,121 @@
|
|||||||
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
||||||
# Released under the modified BSD license. See COPYING.md for more details.
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
|
|
||||||
function _add_system_wide_eqs!(model::JuMP.Model)::Nothing
|
function _add_system_wide_eqs!(
|
||||||
_add_net_injection_eqs!(model)
|
model::JuMP.Model,
|
||||||
_add_reserve_eqs!(model)
|
sc::UnitCommitmentScenario,
|
||||||
_add_flexiramp_eqs!(model)
|
)::Nothing
|
||||||
|
_add_net_injection_eqs!(model, sc)
|
||||||
|
_add_spinning_reserve_eqs!(model, sc)
|
||||||
|
_add_flexiramp_reserve_eqs!(model, sc)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
function _add_net_injection_eqs!(model::JuMP.Model)::Nothing
|
function _add_net_injection_eqs!(
|
||||||
|
model::JuMP.Model,
|
||||||
|
sc::UnitCommitmentScenario,
|
||||||
|
)::Nothing
|
||||||
T = model[:instance].time
|
T = model[:instance].time
|
||||||
net_injection = _init(model, :net_injection)
|
net_injection = _init(model, :net_injection)
|
||||||
eq_net_injection = _init(model, :eq_net_injection)
|
eq_net_injection = _init(model, :eq_net_injection)
|
||||||
eq_power_balance = _init(model, :eq_power_balance)
|
eq_power_balance = _init(model, :eq_power_balance)
|
||||||
for t in 1:T, b in model[:instance].buses
|
for t in 1:T, b in sc.buses
|
||||||
n = net_injection[b.name, t] = @variable(model)
|
n = net_injection[sc.name, b.name, t] = @variable(model)
|
||||||
eq_net_injection[b.name, t] =
|
eq_net_injection[sc.name, b.name, t] = @constraint(
|
||||||
@constraint(model, -n + model[:expr_net_injection][b.name, t] == 0)
|
model,
|
||||||
|
-n + model[:expr_net_injection][sc.name, b.name, t] == 0
|
||||||
|
)
|
||||||
end
|
end
|
||||||
for t in 1:T
|
for t in 1:T
|
||||||
eq_power_balance[t] = @constraint(
|
eq_power_balance[sc.name, t] = @constraint(
|
||||||
model,
|
model,
|
||||||
sum(net_injection[b.name, t] for b in model[:instance].buses) == 0
|
sum(net_injection[sc.name, b.name, t] for b in sc.buses) == 0
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
function _add_reserve_eqs!(model::JuMP.Model)::Nothing
|
function _add_spinning_reserve_eqs!(
|
||||||
eq_min_reserve = _init(model, :eq_min_reserve)
|
model::JuMP.Model,
|
||||||
instance = model[:instance]
|
sc::UnitCommitmentScenario,
|
||||||
for t in 1:instance.time
|
)::Nothing
|
||||||
|
T = model[:instance].time
|
||||||
|
eq_min_spinning_reserve = _init(model, :eq_min_spinning_reserve)
|
||||||
|
for r in sc.reserves
|
||||||
|
r.type == "spinning" || continue
|
||||||
|
for t in 1:T
|
||||||
# Equation (68) in Kneuven et al. (2020)
|
# Equation (68) in Kneuven et al. (2020)
|
||||||
# As in Morales-España et al. (2013a)
|
# As in Morales-España et al. (2013a)
|
||||||
# Akin to the alternative formulation with max_power_avail
|
# Akin to the alternative formulation with max_power_avail
|
||||||
# from Carrión and Arroyo (2006) and Ostrowski et al. (2012)
|
# from Carrión and Arroyo (2006) and Ostrowski et al. (2012)
|
||||||
shortfall_penalty = instance.shortfall_penalty[t]
|
eq_min_spinning_reserve[sc.name, r.name, t] = @constraint(
|
||||||
eq_min_reserve[t] = @constraint(
|
|
||||||
model,
|
model,
|
||||||
sum(model[:reserve][g.name, t] for g in instance.units) +
|
sum(
|
||||||
(shortfall_penalty >= 0 ? model[:reserve_shortfall][t] : 0.0) >=
|
model[:reserve][sc.name, r.name, g.name, t] for
|
||||||
instance.reserves.spinning[t]
|
g in r.thermal_units
|
||||||
|
) + model[:reserve_shortfall][sc.name, r.name, t] >=
|
||||||
|
r.amount[t]
|
||||||
)
|
)
|
||||||
|
|
||||||
# Account for shortfall contribution to objective
|
# Account for shortfall contribution to objective
|
||||||
if shortfall_penalty >= 0
|
if r.shortfall_penalty >= 0
|
||||||
add_to_expression!(
|
add_to_expression!(
|
||||||
model[:obj],
|
model[:obj],
|
||||||
shortfall_penalty,
|
r.shortfall_penalty * sc.probability,
|
||||||
model[:reserve_shortfall][t],
|
model[:reserve_shortfall][sc.name, r.name, t],
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
function _add_flexiramp_eqs!(model::JuMP.Model)::Nothing
|
function _add_flexiramp_reserve_eqs!(
|
||||||
|
model::JuMP.Model,
|
||||||
|
sc::UnitCommitmentScenario,
|
||||||
|
)::Nothing
|
||||||
# Note: The flexpramp requirements in Wang & Hobbs (2016) are imposed as hard constraints
|
# Note: The flexpramp requirements in Wang & Hobbs (2016) are imposed as hard constraints
|
||||||
# through Eq. (17) and Eq. (18). The constraints eq_min_upflexiramp[t] and eq_min_dwflexiramp[t]
|
# through Eq. (17) and Eq. (18). The constraints eq_min_upflexiramp and eq_min_dwflexiramp
|
||||||
# provided below are modified versions of Eq. (17) and Eq. (18), respectively, in that
|
# provided below are modified versions of Eq. (17) and Eq. (18), respectively, in that
|
||||||
# they include slack variables for flexiramp shortfall, which are penalized in the
|
# they include slack variables for flexiramp shortfall, which are penalized in the
|
||||||
# objective function.
|
# objective function.
|
||||||
eq_min_upflexiramp = _init(model, :eq_min_upflexiramp)
|
eq_min_upflexiramp = _init(model, :eq_min_upflexiramp)
|
||||||
eq_min_dwflexiramp = _init(model, :eq_min_dwflexiramp)
|
eq_min_dwflexiramp = _init(model, :eq_min_dwflexiramp)
|
||||||
instance = model[:instance]
|
T = model[:instance].time
|
||||||
for t in 1:instance.time
|
for r in sc.reserves
|
||||||
flexiramp_shortfall_penalty = instance.flexiramp_shortfall_penalty[t]
|
r.type == "flexiramp" || continue
|
||||||
|
for t in 1:T
|
||||||
# Eq. (17) in Wang & Hobbs (2016)
|
# Eq. (17) in Wang & Hobbs (2016)
|
||||||
eq_min_upflexiramp[t] = @constraint(
|
eq_min_upflexiramp[sc.name, r.name, t] = @constraint(
|
||||||
model,
|
model,
|
||||||
sum(model[:upflexiramp][g.name, t] for g in instance.units) +
|
sum(
|
||||||
(
|
model[:upflexiramp][sc.name, r.name, g.name, t] for
|
||||||
flexiramp_shortfall_penalty >= 0 ?
|
g in r.thermal_units
|
||||||
model[:upflexiramp_shortfall][t] : 0.0
|
) + model[:upflexiramp_shortfall][sc.name, r.name, t] >=
|
||||||
) >= instance.reserves.upflexiramp[t]
|
r.amount[t]
|
||||||
)
|
)
|
||||||
# Eq. (18) in Wang & Hobbs (2016)
|
# Eq. (18) in Wang & Hobbs (2016)
|
||||||
eq_min_dwflexiramp[t] = @constraint(
|
eq_min_dwflexiramp[sc.name, r.name, t] = @constraint(
|
||||||
model,
|
model,
|
||||||
sum(model[:dwflexiramp][g.name, t] for g in instance.units) +
|
sum(
|
||||||
(
|
model[:dwflexiramp][sc.name, r.name, g.name, t] for
|
||||||
flexiramp_shortfall_penalty >= 0 ?
|
g in r.thermal_units
|
||||||
model[:dwflexiramp_shortfall][t] : 0.0
|
) + model[:dwflexiramp_shortfall][sc.name, r.name, t] >=
|
||||||
) >= instance.reserves.dwflexiramp[t]
|
r.amount[t]
|
||||||
)
|
)
|
||||||
|
|
||||||
# Account for flexiramp shortfall contribution to objective
|
# Account for flexiramp shortfall contribution to objective
|
||||||
if flexiramp_shortfall_penalty >= 0
|
if r.shortfall_penalty >= 0
|
||||||
add_to_expression!(
|
add_to_expression!(
|
||||||
model[:obj],
|
model[:obj],
|
||||||
flexiramp_shortfall_penalty,
|
r.shortfall_penalty * sc.probability,
|
||||||
(
|
(
|
||||||
model[:upflexiramp_shortfall][t] +
|
model[:upflexiramp_shortfall][sc.name, r.name, t] +
|
||||||
model[:dwflexiramp_shortfall][t]
|
model[:dwflexiramp_shortfall][sc.name, r.name, t]
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,7 +2,13 @@
|
|||||||
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
||||||
# Released under the modified BSD license. See COPYING.md for more details.
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
|
|
||||||
function _add_unit!(model::JuMP.Model, g::Unit, formulation::Formulation)
|
# Function for adding variables, constraints, and objective function terms
|
||||||
|
# related to the binary commitment, startup and shutdown decisions of units
|
||||||
|
function _add_unit_commitment!(
|
||||||
|
model::JuMP.Model,
|
||||||
|
g::ThermalUnit,
|
||||||
|
formulation::Formulation,
|
||||||
|
)
|
||||||
if !all(g.must_run) && any(g.must_run)
|
if !all(g.must_run) && any(g.must_run)
|
||||||
error("Partially must-run units are not currently supported")
|
error("Partially must-run units are not currently supported")
|
||||||
end
|
end
|
||||||
@@ -11,22 +17,41 @@ function _add_unit!(model::JuMP.Model, g::Unit, formulation::Formulation)
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
_add_production_vars!(model, g, formulation.prod_vars)
|
|
||||||
_add_reserve_vars!(model, g)
|
|
||||||
_add_flexiramp_vars!(model, g)
|
|
||||||
_add_startup_shutdown_vars!(model, g)
|
_add_startup_shutdown_vars!(model, g)
|
||||||
_add_status_vars!(model, g, formulation.status_vars)
|
_add_status_vars!(model, g, formulation.status_vars)
|
||||||
|
|
||||||
# Constraints and objective function
|
# Constraints and objective function
|
||||||
_add_min_uptime_downtime_eqs!(model, g)
|
_add_min_uptime_downtime_eqs!(model, g)
|
||||||
_add_net_injection_eqs!(model, g)
|
_add_startup_cost_eqs!(model, g, formulation.startup_costs)
|
||||||
_add_production_limit_eqs!(model, g, formulation.prod_vars)
|
_add_status_eqs!(model, g, formulation.status_vars)
|
||||||
|
_add_commitment_status_eqs!(model, g)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
# Function for adding variables, constraints, and objective function terms
|
||||||
|
# related to the continuous dispatch decisions of units
|
||||||
|
function _add_unit_dispatch!(
|
||||||
|
model::JuMP.Model,
|
||||||
|
g::ThermalUnit,
|
||||||
|
formulation::Formulation,
|
||||||
|
sc::UnitCommitmentScenario,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Variables
|
||||||
|
_add_production_vars!(model, g, formulation.prod_vars, sc)
|
||||||
|
_add_spinning_reserve_vars!(model, g, sc)
|
||||||
|
_add_flexiramp_reserve_vars!(model, g, sc)
|
||||||
|
|
||||||
|
# Constraints and objective function
|
||||||
|
_add_net_injection_eqs!(model, g, sc)
|
||||||
|
_add_production_limit_eqs!(model, g, formulation.prod_vars, sc)
|
||||||
_add_production_piecewise_linear_eqs!(
|
_add_production_piecewise_linear_eqs!(
|
||||||
model,
|
model,
|
||||||
g,
|
g,
|
||||||
formulation.prod_vars,
|
formulation.prod_vars,
|
||||||
formulation.pwl_costs,
|
formulation.pwl_costs,
|
||||||
formulation.status_vars,
|
formulation.status_vars,
|
||||||
|
sc,
|
||||||
)
|
)
|
||||||
_add_ramp_eqs!(
|
_add_ramp_eqs!(
|
||||||
model,
|
model,
|
||||||
@@ -34,40 +59,77 @@ function _add_unit!(model::JuMP.Model, g::Unit, formulation::Formulation)
|
|||||||
formulation.prod_vars,
|
formulation.prod_vars,
|
||||||
formulation.ramping,
|
formulation.ramping,
|
||||||
formulation.status_vars,
|
formulation.status_vars,
|
||||||
|
sc,
|
||||||
)
|
)
|
||||||
_add_startup_cost_eqs!(model, g, formulation.startup_costs)
|
_add_startup_shutdown_limit_eqs!(model, g, sc)
|
||||||
_add_startup_shutdown_limit_eqs!(model, g)
|
|
||||||
_add_status_eqs!(model, g, formulation.status_vars)
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
_is_initially_on(g::Unit)::Float64 = (g.initial_status > 0 ? 1.0 : 0.0)
|
_is_initially_on(g::ThermalUnit)::Float64 = (g.initial_status > 0 ? 1.0 : 0.0)
|
||||||
|
|
||||||
function _add_reserve_vars!(model::JuMP.Model, g::Unit)::Nothing
|
function _add_spinning_reserve_vars!(
|
||||||
|
model::JuMP.Model,
|
||||||
|
g::ThermalUnit,
|
||||||
|
sc::UnitCommitmentScenario,
|
||||||
|
)::Nothing
|
||||||
reserve = _init(model, :reserve)
|
reserve = _init(model, :reserve)
|
||||||
reserve_shortfall = _init(model, :reserve_shortfall)
|
reserve_shortfall = _init(model, :reserve_shortfall)
|
||||||
|
for r in g.reserves
|
||||||
|
r.type == "spinning" || continue
|
||||||
for t in 1:model[:instance].time
|
for t in 1:model[:instance].time
|
||||||
if g.provides_spinning_reserves[t]
|
reserve[sc.name, r.name, g.name, t] =
|
||||||
reserve[g.name, t] = @variable(model, lower_bound = 0)
|
@variable(model, lower_bound = 0)
|
||||||
else
|
if (sc.name, r.name, t) ∉ keys(reserve_shortfall)
|
||||||
reserve[g.name, t] = 0.0
|
reserve_shortfall[sc.name, r.name, t] =
|
||||||
|
@variable(model, lower_bound = 0)
|
||||||
|
if r.shortfall_penalty < 0
|
||||||
|
set_upper_bound(reserve_shortfall[sc.name, r.name, t], 0.0)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
reserve_shortfall[t] =
|
|
||||||
(model[:instance].shortfall_penalty[t] >= 0) ?
|
|
||||||
@variable(model, lower_bound = 0) : 0.0
|
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
function _add_reserve_eqs!(model::JuMP.Model, g::Unit)::Nothing
|
function _add_flexiramp_reserve_vars!(
|
||||||
reserve = model[:reserve]
|
model::JuMP.Model,
|
||||||
|
g::ThermalUnit,
|
||||||
|
sc::UnitCommitmentScenario,
|
||||||
|
)::Nothing
|
||||||
|
upflexiramp = _init(model, :upflexiramp)
|
||||||
|
upflexiramp_shortfall = _init(model, :upflexiramp_shortfall)
|
||||||
|
mfg = _init(model, :mfg)
|
||||||
|
dwflexiramp = _init(model, :dwflexiramp)
|
||||||
|
dwflexiramp_shortfall = _init(model, :dwflexiramp_shortfall)
|
||||||
for t in 1:model[:instance].time
|
for t in 1:model[:instance].time
|
||||||
add_to_expression!(expr_reserve[g.bus.name, t], reserve[g.name, t], 1.0)
|
# maximum feasible generation, \bar{g_{its}} in Wang & Hobbs (2016)
|
||||||
|
mfg[sc.name, g.name, t] = @variable(model, lower_bound = 0)
|
||||||
|
for r in g.reserves
|
||||||
|
r.type == "flexiramp" || continue
|
||||||
|
upflexiramp[sc.name, r.name, g.name, t] = @variable(model) # up-flexiramp, ur_{it} in Wang & Hobbs (2016)
|
||||||
|
dwflexiramp[sc.name, r.name, g.name, t] = @variable(model) # down-flexiramp, dr_{it} in Wang & Hobbs (2016)
|
||||||
|
if (sc.name, r.name, t) ∉ keys(upflexiramp_shortfall)
|
||||||
|
upflexiramp_shortfall[sc.name, r.name, t] =
|
||||||
|
@variable(model, lower_bound = 0)
|
||||||
|
dwflexiramp_shortfall[sc.name, r.name, t] =
|
||||||
|
@variable(model, lower_bound = 0)
|
||||||
|
if r.shortfall_penalty < 0
|
||||||
|
set_upper_bound(
|
||||||
|
upflexiramp_shortfall[sc.name, r.name, t],
|
||||||
|
0.0,
|
||||||
|
)
|
||||||
|
set_upper_bound(
|
||||||
|
dwflexiramp_shortfall[sc.name, r.name, t],
|
||||||
|
0.0,
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
function _add_startup_shutdown_vars!(model::JuMP.Model, g::Unit)::Nothing
|
function _add_startup_shutdown_vars!(model::JuMP.Model, g::ThermalUnit)::Nothing
|
||||||
startup = _init(model, :startup)
|
startup = _init(model, :startup)
|
||||||
for t in 1:model[:instance].time
|
for t in 1:model[:instance].time
|
||||||
for s in 1:length(g.startup_categories)
|
for s in 1:length(g.startup_categories)
|
||||||
@@ -77,32 +139,36 @@ function _add_startup_shutdown_vars!(model::JuMP.Model, g::Unit)::Nothing
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
function _add_startup_shutdown_limit_eqs!(model::JuMP.Model, g::Unit)::Nothing
|
function _add_startup_shutdown_limit_eqs!(
|
||||||
|
model::JuMP.Model,
|
||||||
|
g::ThermalUnit,
|
||||||
|
sc::UnitCommitmentScenario,
|
||||||
|
)::Nothing
|
||||||
eq_shutdown_limit = _init(model, :eq_shutdown_limit)
|
eq_shutdown_limit = _init(model, :eq_shutdown_limit)
|
||||||
eq_startup_limit = _init(model, :eq_startup_limit)
|
eq_startup_limit = _init(model, :eq_startup_limit)
|
||||||
is_on = model[:is_on]
|
is_on = model[:is_on]
|
||||||
prod_above = model[:prod_above]
|
prod_above = model[:prod_above]
|
||||||
reserve = model[:reserve]
|
reserve = _total_reserves(model, g, sc)
|
||||||
switch_off = model[:switch_off]
|
switch_off = model[:switch_off]
|
||||||
switch_on = model[:switch_on]
|
switch_on = model[:switch_on]
|
||||||
T = model[:instance].time
|
T = model[:instance].time
|
||||||
for t in 1:T
|
for t in 1:T
|
||||||
# Startup limit
|
# Startup limit
|
||||||
eq_startup_limit[g.name, t] = @constraint(
|
eq_startup_limit[sc.name, g.name, t] = @constraint(
|
||||||
model,
|
model,
|
||||||
prod_above[g.name, t] + reserve[g.name, t] <=
|
prod_above[sc.name, g.name, t] + reserve[t] <=
|
||||||
(g.max_power[t] - g.min_power[t]) * is_on[g.name, t] -
|
(g.max_power[t] - g.min_power[t]) * is_on[g.name, t] -
|
||||||
max(0, g.max_power[t] - g.startup_limit) * switch_on[g.name, t]
|
max(0, g.max_power[t] - g.startup_limit) * switch_on[g.name, t]
|
||||||
)
|
)
|
||||||
# Shutdown limit
|
# Shutdown limit
|
||||||
if g.initial_power > g.shutdown_limit
|
if g.initial_power > g.shutdown_limit
|
||||||
eq_shutdown_limit[g.name, 0] =
|
eq_shutdown_limit[sc.name, g.name, 0] =
|
||||||
@constraint(model, switch_off[g.name, 1] <= 0)
|
@constraint(model, switch_off[g.name, 1] <= 0)
|
||||||
end
|
end
|
||||||
if t < T
|
if t < T
|
||||||
eq_shutdown_limit[g.name, t] = @constraint(
|
eq_shutdown_limit[sc.name, g.name, t] = @constraint(
|
||||||
model,
|
model,
|
||||||
prod_above[g.name, t] <=
|
prod_above[sc.name, g.name, t] <=
|
||||||
(g.max_power[t] - g.min_power[t]) * is_on[g.name, t] -
|
(g.max_power[t] - g.min_power[t]) * is_on[g.name, t] -
|
||||||
max(0, g.max_power[t] - g.shutdown_limit) *
|
max(0, g.max_power[t] - g.shutdown_limit) *
|
||||||
switch_off[g.name, t+1]
|
switch_off[g.name, t+1]
|
||||||
@@ -114,51 +180,55 @@ end
|
|||||||
|
|
||||||
function _add_ramp_eqs!(
|
function _add_ramp_eqs!(
|
||||||
model::JuMP.Model,
|
model::JuMP.Model,
|
||||||
g::Unit,
|
g::ThermalUnit,
|
||||||
formulation::RampingFormulation,
|
formulation::RampingFormulation,
|
||||||
|
sc::UnitCommitmentScenario,
|
||||||
)::Nothing
|
)::Nothing
|
||||||
prod_above = model[:prod_above]
|
prod_above = model[:prod_above]
|
||||||
reserve = model[:reserve]
|
reserve = _total_reserves(model, g, sc)
|
||||||
eq_ramp_up = _init(model, :eq_ramp_up)
|
eq_ramp_up = _init(model, :eq_ramp_up)
|
||||||
eq_ramp_down = _init(model, :eq_ramp_down)
|
eq_ramp_down = _init(model, :eq_ramp_down)
|
||||||
for t in 1:model[:instance].time
|
for t in 1:model[:instance].time
|
||||||
# Ramp up limit
|
# Ramp up limit
|
||||||
if t == 1
|
if t == 1
|
||||||
if _is_initially_on(g) == 1
|
if _is_initially_on(g) == 1
|
||||||
eq_ramp_up[g.name, t] = @constraint(
|
eq_ramp_up[sc.name, g.name, t] = @constraint(
|
||||||
model,
|
model,
|
||||||
prod_above[g.name, t] + reserve[g.name, t] <=
|
prod_above[sc.name, g.name, t] + reserve[t] <=
|
||||||
(g.initial_power - g.min_power[t]) + g.ramp_up_limit
|
(g.initial_power - g.min_power[t]) + g.ramp_up_limit
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
eq_ramp_up[g.name, t] = @constraint(
|
eq_ramp_up[sc.name, g.name, t] = @constraint(
|
||||||
model,
|
model,
|
||||||
prod_above[g.name, t] + reserve[g.name, t] <=
|
prod_above[sc.name, g.name, t] + reserve[t] <=
|
||||||
prod_above[g.name, t-1] + g.ramp_up_limit
|
prod_above[sc.name, g.name, t-1] + g.ramp_up_limit
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Ramp down limit
|
# Ramp down limit
|
||||||
if t == 1
|
if t == 1
|
||||||
if _is_initially_on(g) == 1
|
if _is_initially_on(g) == 1
|
||||||
eq_ramp_down[g.name, t] = @constraint(
|
eq_ramp_down[sc.name, g.name, t] = @constraint(
|
||||||
model,
|
model,
|
||||||
prod_above[g.name, t] >=
|
prod_above[sc.name, g.name, t] >=
|
||||||
(g.initial_power - g.min_power[t]) - g.ramp_down_limit
|
(g.initial_power - g.min_power[t]) - g.ramp_down_limit
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
eq_ramp_down[g.name, t] = @constraint(
|
eq_ramp_down[sc.name, g.name, t] = @constraint(
|
||||||
model,
|
model,
|
||||||
prod_above[g.name, t] >=
|
prod_above[sc.name, g.name, t] >=
|
||||||
prod_above[g.name, t-1] - g.ramp_down_limit
|
prod_above[sc.name, g.name, t-1] - g.ramp_down_limit
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function _add_min_uptime_downtime_eqs!(model::JuMP.Model, g::Unit)::Nothing
|
function _add_min_uptime_downtime_eqs!(
|
||||||
|
model::JuMP.Model,
|
||||||
|
g::ThermalUnit,
|
||||||
|
)::Nothing
|
||||||
is_on = model[:is_on]
|
is_on = model[:is_on]
|
||||||
switch_off = model[:switch_off]
|
switch_off = model[:switch_off]
|
||||||
switch_on = model[:switch_on]
|
switch_on = model[:switch_on]
|
||||||
@@ -201,19 +271,53 @@ function _add_min_uptime_downtime_eqs!(model::JuMP.Model, g::Unit)::Nothing
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function _add_net_injection_eqs!(model::JuMP.Model, g::Unit)::Nothing
|
function _add_commitment_status_eqs!(model::JuMP.Model, g::ThermalUnit)::Nothing
|
||||||
|
is_on = model[:is_on]
|
||||||
|
T = model[:instance].time
|
||||||
|
eq_commitment_status = _init(model, :eq_commitment_status)
|
||||||
|
for t in 1:T
|
||||||
|
if g.commitment_status[t] !== nothing
|
||||||
|
eq_commitment_status[g.name, t] = @constraint(
|
||||||
|
model,
|
||||||
|
is_on[g.name, t] == (g.commitment_status[t] ? 1.0 : 0.0)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
function _add_net_injection_eqs!(
|
||||||
|
model::JuMP.Model,
|
||||||
|
g::ThermalUnit,
|
||||||
|
sc::UnitCommitmentScenario,
|
||||||
|
)::Nothing
|
||||||
expr_net_injection = model[:expr_net_injection]
|
expr_net_injection = model[:expr_net_injection]
|
||||||
for t in 1:model[:instance].time
|
for t in 1:model[:instance].time
|
||||||
# Add to net injection expression
|
# Add to net injection expression
|
||||||
add_to_expression!(
|
add_to_expression!(
|
||||||
expr_net_injection[g.bus.name, t],
|
expr_net_injection[sc.name, g.bus.name, t],
|
||||||
model[:prod_above][g.name, t],
|
model[:prod_above][sc.name, g.name, t],
|
||||||
1.0,
|
1.0,
|
||||||
)
|
)
|
||||||
add_to_expression!(
|
add_to_expression!(
|
||||||
expr_net_injection[g.bus.name, t],
|
expr_net_injection[sc.name, g.bus.name, t],
|
||||||
model[:is_on][g.name, t],
|
model[:is_on][g.name, t],
|
||||||
g.min_power[t],
|
g.min_power[t],
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function _total_reserves(model, g, sc)::Vector
|
||||||
|
T = model[:instance].time
|
||||||
|
reserve = [0.0 for _ in 1:T]
|
||||||
|
spinning_reserves = [r for r in g.reserves if r.type == "spinning"]
|
||||||
|
if !isempty(spinning_reserves)
|
||||||
|
reserve += [
|
||||||
|
sum(
|
||||||
|
model[:reserve][sc.name, r.name, g.name, t] for
|
||||||
|
r in spinning_reserves
|
||||||
|
) for t in 1:model[:instance].time
|
||||||
|
]
|
||||||
|
end
|
||||||
|
return reserve
|
||||||
|
end
|
||||||
|
|||||||
@@ -10,23 +10,42 @@ solution. Useful for computing LMPs.
|
|||||||
"""
|
"""
|
||||||
function fix!(model::JuMP.Model, solution::AbstractDict)::Nothing
|
function fix!(model::JuMP.Model, solution::AbstractDict)::Nothing
|
||||||
instance, T = model[:instance], model[:instance].time
|
instance, T = model[:instance], model[:instance].time
|
||||||
|
"Thermal production (MW)" ∈ keys(solution) ?
|
||||||
|
solution = Dict("s1" => solution) : nothing
|
||||||
is_on = model[:is_on]
|
is_on = model[:is_on]
|
||||||
prod_above = model[:prod_above]
|
prod_above = model[:prod_above]
|
||||||
reserve = model[:reserve]
|
reserve = model[:reserve]
|
||||||
for g in instance.units
|
for sc in instance.scenarios
|
||||||
|
for g in sc.thermal_units
|
||||||
for t in 1:T
|
for t in 1:T
|
||||||
is_on_value = round(solution["Is on"][g.name][t])
|
is_on_value = round(solution[sc.name]["Is on"][g.name][t])
|
||||||
prod_value =
|
prod_value = round(
|
||||||
round(solution["Production (MW)"][g.name][t], digits = 5)
|
solution[sc.name]["Thermal production (MW)"][g.name][t],
|
||||||
reserve_value =
|
digits = 5,
|
||||||
round(solution["Reserve (MW)"][g.name][t], digits = 5)
|
)
|
||||||
JuMP.fix(is_on[g.name, t], is_on_value, force = true)
|
JuMP.fix(is_on[g.name, t], is_on_value, force = true)
|
||||||
JuMP.fix(
|
JuMP.fix(
|
||||||
prod_above[g.name, t],
|
prod_above[sc.name, g.name, t],
|
||||||
prod_value - is_on_value * g.min_power[t],
|
prod_value - is_on_value * g.min_power[t],
|
||||||
force = true,
|
force = true,
|
||||||
)
|
)
|
||||||
JuMP.fix(reserve[g.name, t], reserve_value, force = true)
|
end
|
||||||
|
end
|
||||||
|
for r in sc.reserves
|
||||||
|
r.type == "spinning" || continue
|
||||||
|
for g in r.thermal_units
|
||||||
|
for t in 1:T
|
||||||
|
reserve_value = round(
|
||||||
|
solution[sc.name]["Spinning reserve (MW)"][r.name][g.name][t],
|
||||||
|
digits = 5,
|
||||||
|
)
|
||||||
|
JuMP.fix(
|
||||||
|
reserve[sc.name, r.name, g.name, t],
|
||||||
|
reserve_value,
|
||||||
|
force = true,
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
|
|||||||
71
src/solution/methods/MIPLearn/miplearn.jl
Normal file
71
src/solution/methods/MIPLearn/miplearn.jl
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
# UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
|
||||||
|
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
||||||
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
|
|
||||||
|
using .MIPLearn
|
||||||
|
using Suppressor
|
||||||
|
using JuMP
|
||||||
|
|
||||||
|
function _build_ucjl_model(instance, method)
|
||||||
|
if instance isa String
|
||||||
|
instance = UnitCommitment.read(instance)
|
||||||
|
end
|
||||||
|
model = UnitCommitment.build_model(
|
||||||
|
instance = instance,
|
||||||
|
optimizer = method.optimizer,
|
||||||
|
variable_names = true,
|
||||||
|
)
|
||||||
|
write_to_file(model, "/tmp/model.lp")
|
||||||
|
return JumpModel(model)
|
||||||
|
end
|
||||||
|
|
||||||
|
function _set_default_collectors!(method::MIPLearnMethod)
|
||||||
|
method.collectors = [BasicCollector()]
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
function _set_default_solver!(method::MIPLearnMethod)
|
||||||
|
KNN = MIPLearn.pyimport("sklearn.neighbors").KNeighborsClassifier
|
||||||
|
method.solver = LearningSolver(
|
||||||
|
components = [
|
||||||
|
MemorizingPrimalComponent(
|
||||||
|
clf = KNN(n_neighbors = 30),
|
||||||
|
extractor = H5FieldsExtractor(
|
||||||
|
instance_fields = ["static_var_obj_coeffs"],
|
||||||
|
),
|
||||||
|
constructor = MergeTopSolutions(30, [0.0, 1.0]),
|
||||||
|
action = FixVariables(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
function collect!(filenames::Vector, method::MIPLearnMethod)
|
||||||
|
build(x) = _build_ucjl_model(x, method)
|
||||||
|
if method.collectors === nothing
|
||||||
|
_set_default_collectors!(method)
|
||||||
|
end
|
||||||
|
for c in method.collectors
|
||||||
|
c.collect(filenames, build)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function fit!(filenames::Vector, method::MIPLearnMethod)
|
||||||
|
if method.solver === nothing
|
||||||
|
_set_default_solver!(method)
|
||||||
|
end
|
||||||
|
return method.solver.fit(filenames)
|
||||||
|
end
|
||||||
|
|
||||||
|
function optimize!(filename::AbstractString, method::MIPLearnMethod)
|
||||||
|
build(x) = _build_ucjl_model(x, method)
|
||||||
|
method.solver.optimize(filename, build)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
function optimize!(instance::UnitCommitmentInstance, method::MIPLearnMethod)
|
||||||
|
model = _build_ucjl_model(instance, method)
|
||||||
|
method.solver.optimize(model)
|
||||||
|
return
|
||||||
|
end
|
||||||
11
src/solution/methods/MIPLearn/structs.jl
Normal file
11
src/solution/methods/MIPLearn/structs.jl
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
|
||||||
|
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
||||||
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
|
|
||||||
|
using Suppressor
|
||||||
|
|
||||||
|
Base.@kwdef mutable struct MIPLearnMethod
|
||||||
|
optimizer::Any
|
||||||
|
collectors::Any = nothing
|
||||||
|
solver::Any = nothing
|
||||||
|
end
|
||||||
230
src/solution/methods/ProgressiveHedging/optimize.jl
Normal file
230
src/solution/methods/ProgressiveHedging/optimize.jl
Normal file
@@ -0,0 +1,230 @@
|
|||||||
|
# UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
|
||||||
|
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
||||||
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
|
using MPI, Printf
|
||||||
|
using TimerOutputs
|
||||||
|
import JuMP
|
||||||
|
const to = TimerOutput()
|
||||||
|
|
||||||
|
function optimize!(model::JuMP.Model, method::ProgressiveHedging)::Nothing
|
||||||
|
mpi = MpiInfo(MPI.COMM_WORLD)
|
||||||
|
iterations = PHIterationInfo[]
|
||||||
|
consensus_vars = [var for var in all_variables(model) if is_binary(var)]
|
||||||
|
nvars = length(consensus_vars)
|
||||||
|
weights = ones(nvars)
|
||||||
|
if method.initial_weights !== nothing
|
||||||
|
weights = copy(method.initial_weights)
|
||||||
|
end
|
||||||
|
target = zeros(nvars)
|
||||||
|
if method.initial_target !== nothing
|
||||||
|
target = copy(method.initial_target)
|
||||||
|
end
|
||||||
|
params = PHSubProblemParams(
|
||||||
|
ρ = method.ρ,
|
||||||
|
λ = [method.λ for _ in 1:nvars],
|
||||||
|
target = target,
|
||||||
|
)
|
||||||
|
sp = PHSubProblem(model, model[:obj], consensus_vars, weights)
|
||||||
|
while true
|
||||||
|
iteration_time = @elapsed begin
|
||||||
|
solution = solve_subproblem(sp, params, method.inner_method)
|
||||||
|
MPI.Barrier(mpi.comm)
|
||||||
|
global_obj = compute_global_objective(mpi, solution)
|
||||||
|
target = compute_target(mpi, solution)
|
||||||
|
update_λ_and_residuals!(solution, params, target)
|
||||||
|
global_infeas = compute_global_infeasibility(solution, mpi)
|
||||||
|
global_residual = compute_global_residual(mpi, solution)
|
||||||
|
if has_numerical_issues(target)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
total_elapsed_time =
|
||||||
|
compute_total_elapsed_time(iteration_time, iterations)
|
||||||
|
current_iteration = PHIterationInfo(
|
||||||
|
global_infeas = global_infeas,
|
||||||
|
global_obj = global_obj,
|
||||||
|
global_residual = global_residual,
|
||||||
|
iteration_number = length(iterations) + 1,
|
||||||
|
iteration_time = iteration_time,
|
||||||
|
sp_vals = solution.vals,
|
||||||
|
sp_obj = solution.obj,
|
||||||
|
target = target,
|
||||||
|
total_elapsed_time = total_elapsed_time,
|
||||||
|
)
|
||||||
|
push!(iterations, current_iteration)
|
||||||
|
print_progress(mpi, current_iteration, method.print_interval)
|
||||||
|
if should_stop(mpi, iterations, method.termination)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
function compute_total_elapsed_time(
|
||||||
|
iteration_time::Float64,
|
||||||
|
iterations::Array{PHIterationInfo,1},
|
||||||
|
)::Float64
|
||||||
|
length(iterations) > 0 ?
|
||||||
|
current_total_time = last(iterations).total_elapsed_time :
|
||||||
|
current_total_time = 0
|
||||||
|
return current_total_time + iteration_time
|
||||||
|
end
|
||||||
|
|
||||||
|
function compute_global_objective(
|
||||||
|
mpi::MpiInfo,
|
||||||
|
s::PhSubProblemSolution,
|
||||||
|
)::Float64
|
||||||
|
global_obj = MPI.Allreduce(s.obj, MPI.SUM, mpi.comm)
|
||||||
|
global_obj /= mpi.nprocs
|
||||||
|
return global_obj
|
||||||
|
end
|
||||||
|
|
||||||
|
function compute_target(mpi::MpiInfo, s::PhSubProblemSolution)::Array{Float64,1}
|
||||||
|
sp_vals = s.vals
|
||||||
|
target = MPI.Allreduce(sp_vals, MPI.SUM, mpi.comm)
|
||||||
|
target = target / mpi.nprocs
|
||||||
|
return target
|
||||||
|
end
|
||||||
|
|
||||||
|
function compute_global_residual(mpi::MpiInfo, s::PhSubProblemSolution)::Float64
|
||||||
|
n_vars = length(s.vals)
|
||||||
|
local_residual_sum = abs.(s.residuals)
|
||||||
|
global_residual_sum = MPI.Allreduce(local_residual_sum, MPI.SUM, mpi.comm)
|
||||||
|
return sum(global_residual_sum) / n_vars
|
||||||
|
end
|
||||||
|
|
||||||
|
function compute_global_infeasibility(
|
||||||
|
solution::PhSubProblemSolution,
|
||||||
|
mpi::MpiInfo,
|
||||||
|
)::Float64
|
||||||
|
local_infeasibility = norm(solution.residuals)
|
||||||
|
global_infeas = MPI.Allreduce(local_infeasibility, MPI.SUM, mpi.comm)
|
||||||
|
return global_infeas
|
||||||
|
end
|
||||||
|
|
||||||
|
function solve_subproblem(
|
||||||
|
sp::PHSubProblem,
|
||||||
|
params::PHSubProblemParams,
|
||||||
|
method::SolutionMethod,
|
||||||
|
)::PhSubProblemSolution
|
||||||
|
G = length(sp.consensus_vars)
|
||||||
|
if norm(params.λ) < 1e-3
|
||||||
|
@objective(sp.mip, Min, sp.obj)
|
||||||
|
else
|
||||||
|
@objective(
|
||||||
|
sp.mip,
|
||||||
|
Min,
|
||||||
|
sp.obj +
|
||||||
|
sum(
|
||||||
|
sp.weights[g] *
|
||||||
|
params.λ[g] *
|
||||||
|
(sp.consensus_vars[g] - params.target[g]) for g in 1:G
|
||||||
|
) +
|
||||||
|
(params.ρ / 2) * sum(
|
||||||
|
sp.weights[g] * (sp.consensus_vars[g] - params.target[g])^2 for
|
||||||
|
g in 1:G
|
||||||
|
)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
optimize!(sp.mip, method)
|
||||||
|
obj = objective_value(sp.mip)
|
||||||
|
sp_vals = value.(sp.consensus_vars)
|
||||||
|
return PhSubProblemSolution(obj = obj, vals = sp_vals, residuals = zeros(G))
|
||||||
|
end
|
||||||
|
|
||||||
|
function update_λ_and_residuals!(
|
||||||
|
solution::PhSubProblemSolution,
|
||||||
|
params::PHSubProblemParams,
|
||||||
|
target::Array{Float64,1},
|
||||||
|
)::Nothing
|
||||||
|
n_vars = length(solution.vals)
|
||||||
|
params.target = target
|
||||||
|
for n in 1:n_vars
|
||||||
|
solution.residuals[n] = solution.vals[n] - params.target[n]
|
||||||
|
params.λ[n] += params.ρ * solution.residuals[n]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function print_header(mpi::MpiInfo)::Nothing
|
||||||
|
if !mpi.root
|
||||||
|
return
|
||||||
|
end
|
||||||
|
@info "Solving via Progressive Hedging:"
|
||||||
|
@info @sprintf(
|
||||||
|
"%8s %20s %20s %14s %8s %8s",
|
||||||
|
"iter",
|
||||||
|
"obj",
|
||||||
|
"infeas",
|
||||||
|
"consensus",
|
||||||
|
"time-it",
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
function print_progress(
|
||||||
|
mpi::MpiInfo,
|
||||||
|
iteration::PHIterationInfo,
|
||||||
|
print_interval,
|
||||||
|
)::Nothing
|
||||||
|
if !mpi.root
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if iteration.iteration_number % print_interval != 0
|
||||||
|
return
|
||||||
|
end
|
||||||
|
@info @sprintf(
|
||||||
|
"%8d %20.6e %20.6e %12.2f %% %8.2f %8.2f",
|
||||||
|
iteration.iteration_number,
|
||||||
|
iteration.global_obj,
|
||||||
|
iteration.global_infeas,
|
||||||
|
iteration.global_residual * 100,
|
||||||
|
iteration.iteration_time,
|
||||||
|
iteration.total_elapsed_time
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
function has_numerical_issues(target::Array{Float64,1})::Bool
|
||||||
|
if target == NaN
|
||||||
|
@warn "Numerical issues detected. Stopping."
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
function should_stop(
|
||||||
|
mpi::MpiInfo,
|
||||||
|
iterations::Array{PHIterationInfo,1},
|
||||||
|
termination::PHTermination,
|
||||||
|
)::Bool
|
||||||
|
if length(iterations) >= termination.max_iterations
|
||||||
|
if mpi.root
|
||||||
|
@info "Iteration limit reached. Stopping."
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
if length(iterations) < termination.min_iterations
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if last(iterations).total_elapsed_time > termination.max_time
|
||||||
|
if mpi.root
|
||||||
|
@info "Time limit reached. Stopping."
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
curr_it = last(iterations)
|
||||||
|
prev_it = iterations[length(iterations)-1]
|
||||||
|
|
||||||
|
if curr_it.global_infeas < termination.min_feasibility
|
||||||
|
obj_change = abs(prev_it.global_obj - curr_it.global_obj)
|
||||||
|
if obj_change < termination.min_improvement
|
||||||
|
if mpi.root
|
||||||
|
@info "Feasibility limit reached. Stopping."
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
18
src/solution/methods/ProgressiveHedging/read.jl
Normal file
18
src/solution/methods/ProgressiveHedging/read.jl
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
|
||||||
|
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
||||||
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
|
|
||||||
|
function read(
|
||||||
|
paths::Vector{String},
|
||||||
|
::ProgressiveHedging,
|
||||||
|
)::UnitCommitmentInstance
|
||||||
|
comm = MPI.COMM_WORLD
|
||||||
|
mpi = MpiInfo(comm)
|
||||||
|
(length(paths) % mpi.nprocs == 0) || error(
|
||||||
|
"Number of processes $(mpi.nprocs) is not a divisor of $(length(paths))",
|
||||||
|
)
|
||||||
|
bundled_scenarios = length(paths) ÷ mpi.nprocs
|
||||||
|
sc_num_start = (mpi.rank - 1) * bundled_scenarios + 1
|
||||||
|
sc_num_end = mpi.rank * bundled_scenarios
|
||||||
|
return read(paths[sc_num_start:sc_num_end])
|
||||||
|
end
|
||||||
83
src/solution/methods/ProgressiveHedging/solution.jl
Normal file
83
src/solution/methods/ProgressiveHedging/solution.jl
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
# UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
|
||||||
|
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
||||||
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
|
|
||||||
|
using MPI, DataStructures
|
||||||
|
const FIRST_STAGE_VARS = ["Is on", "Switch on", "Switch off"]
|
||||||
|
|
||||||
|
function solution(model::JuMP.Model, method::ProgressiveHedging)::OrderedDict
|
||||||
|
comm = MPI.COMM_WORLD
|
||||||
|
mpi = MpiInfo(comm)
|
||||||
|
sp_solution = UnitCommitment.solution(model)
|
||||||
|
gather_solution = OrderedDict()
|
||||||
|
for (solution_key, dict) in sp_solution
|
||||||
|
if solution_key !== "Spinning reserve (MW)" &&
|
||||||
|
solution_key ∉ FIRST_STAGE_VARS
|
||||||
|
push!(gather_solution, solution_key => OrderedDict())
|
||||||
|
for (gen_bus_key, values) in dict
|
||||||
|
global T = length(values)
|
||||||
|
receive_values =
|
||||||
|
MPI.UBuffer(Vector{Float64}(undef, T * mpi.nprocs), T)
|
||||||
|
MPI.Gather!(float.(values), receive_values, comm)
|
||||||
|
if mpi.root
|
||||||
|
push!(
|
||||||
|
gather_solution[solution_key],
|
||||||
|
gen_bus_key => receive_values.data,
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
push!(gather_solution, "Spinning reserve (MW)" => OrderedDict())
|
||||||
|
for (reserve_type, dict) in sp_solution["Spinning reserve (MW)"]
|
||||||
|
push!(
|
||||||
|
gather_solution["Spinning reserve (MW)"],
|
||||||
|
reserve_type => OrderedDict(),
|
||||||
|
)
|
||||||
|
for (gen_key, values) in dict
|
||||||
|
receive_values =
|
||||||
|
MPI.UBuffer(Vector{Float64}(undef, T * mpi.nprocs), T)
|
||||||
|
MPI.Gather!(float.(values), receive_values, comm)
|
||||||
|
if mpi.root
|
||||||
|
push!(
|
||||||
|
gather_solution["Spinning reserve (MW)"][reserve_type],
|
||||||
|
gen_key => receive_values.data,
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
aggregate_solution = OrderedDict()
|
||||||
|
if mpi.root
|
||||||
|
for first_stage_var in FIRST_STAGE_VARS
|
||||||
|
aggregate_solution[first_stage_var] = OrderedDict()
|
||||||
|
for gen_key in keys(sp_solution[first_stage_var])
|
||||||
|
aggregate_solution[first_stage_var][gen_key] =
|
||||||
|
sp_solution[first_stage_var][gen_key]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for i in 1:mpi.nprocs
|
||||||
|
push!(aggregate_solution, "s$i" => OrderedDict())
|
||||||
|
for (solution_key, solution_dict) in gather_solution
|
||||||
|
push!(aggregate_solution["s$i"], solution_key => OrderedDict())
|
||||||
|
if solution_key !== "Spinning reserve (MW)"
|
||||||
|
for (gen_bus_key, values) in solution_dict
|
||||||
|
aggregate_solution["s$i"][solution_key][gen_bus_key] =
|
||||||
|
gather_solution[solution_key][gen_bus_key][(i-1)*T+1:i*T]
|
||||||
|
end
|
||||||
|
else
|
||||||
|
for (reserve_name, reserve_dict) in solution_dict
|
||||||
|
push!(
|
||||||
|
aggregate_solution["s$i"][solution_key],
|
||||||
|
reserve_name => OrderedDict(),
|
||||||
|
)
|
||||||
|
for (gen_key, values) in reserve_dict
|
||||||
|
aggregate_solution["s$i"][solution_key][reserve_name][gen_key] =
|
||||||
|
gather_solution[solution_key][reserve_name][gen_key][(i-1)*T+1:i*T]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return aggregate_solution
|
||||||
|
end
|
||||||
73
src/solution/methods/ProgressiveHedging/structs.jl
Normal file
73
src/solution/methods/ProgressiveHedging/structs.jl
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
# UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
|
||||||
|
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
||||||
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
|
|
||||||
|
using JuMP, MPI, TimerOutputs
|
||||||
|
|
||||||
|
Base.@kwdef mutable struct PHTermination
|
||||||
|
max_iterations::Int = 1000
|
||||||
|
max_time::Float64 = 14400.0
|
||||||
|
min_feasibility::Float64 = 1e-3
|
||||||
|
min_improvement::Float64 = 1e-3
|
||||||
|
min_iterations::Int = 2
|
||||||
|
end
|
||||||
|
|
||||||
|
Base.@kwdef mutable struct PHIterationInfo
|
||||||
|
global_infeas::Float64
|
||||||
|
global_obj::Float64
|
||||||
|
global_residual::Float64
|
||||||
|
iteration_number::Int
|
||||||
|
iteration_time::Float64
|
||||||
|
sp_vals::Array{Float64,1}
|
||||||
|
sp_obj::Float64
|
||||||
|
target::Array{Float64,1}
|
||||||
|
total_elapsed_time::Float64
|
||||||
|
end
|
||||||
|
|
||||||
|
Base.@kwdef mutable struct ProgressiveHedging <: SolutionMethod
|
||||||
|
initial_weights::Union{Vector{Float64},Nothing} = nothing
|
||||||
|
initial_target::Union{Vector{Float64},Nothing} = nothing
|
||||||
|
ρ::Float64 = 1.0
|
||||||
|
λ::Float64 = 0.0
|
||||||
|
print_interval::Int = 1
|
||||||
|
termination::PHTermination = PHTermination()
|
||||||
|
inner_method::SolutionMethod = XavQiuWanThi2019.Method()
|
||||||
|
end
|
||||||
|
|
||||||
|
struct SpResult
|
||||||
|
obj::Float64
|
||||||
|
vals::Array{Float64,1}
|
||||||
|
end
|
||||||
|
|
||||||
|
Base.@kwdef mutable struct PHSubProblem
|
||||||
|
mip::JuMP.Model
|
||||||
|
obj::AffExpr
|
||||||
|
consensus_vars::Array{VariableRef,1}
|
||||||
|
weights::Array{Float64,1}
|
||||||
|
end
|
||||||
|
|
||||||
|
Base.@kwdef struct PhSubProblemSolution
|
||||||
|
obj::Float64
|
||||||
|
vals::Array{Float64,1}
|
||||||
|
residuals::Array{Float64,1}
|
||||||
|
end
|
||||||
|
|
||||||
|
Base.@kwdef mutable struct PHSubProblemParams
|
||||||
|
ρ::Float64
|
||||||
|
λ::Array{Float64,1}
|
||||||
|
target::Array{Float64,1}
|
||||||
|
end
|
||||||
|
|
||||||
|
struct MpiInfo
|
||||||
|
comm::Any
|
||||||
|
rank::Int
|
||||||
|
root::Bool
|
||||||
|
nprocs::Int
|
||||||
|
|
||||||
|
function MpiInfo(comm)
|
||||||
|
rank = MPI.Comm_rank(comm) + 1
|
||||||
|
is_root = (rank == 1)
|
||||||
|
nprocs = MPI.Comm_size(comm)
|
||||||
|
return new(comm, rank, is_root, nprocs)
|
||||||
|
end
|
||||||
|
end
|
||||||
259
src/solution/methods/TimeDecomposition/optimize.jl
Normal file
259
src/solution/methods/TimeDecomposition/optimize.jl
Normal file
@@ -0,0 +1,259 @@
|
|||||||
|
# UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
|
||||||
|
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
||||||
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
|
|
||||||
|
"""
|
||||||
|
optimize!(
|
||||||
|
instance::UnitCommitmentInstance,
|
||||||
|
method::TimeDecomposition;
|
||||||
|
optimizer,
|
||||||
|
after_build = nothing,
|
||||||
|
after_optimize = nothing,
|
||||||
|
)::OrderedDict
|
||||||
|
|
||||||
|
Solve the given unit commitment instance with time decomposition.
|
||||||
|
The model solves each sub-problem of a given time length specified by method.time_window,
|
||||||
|
and proceeds to the next sub-problem by incrementing the time length of `method.time_increment`.
|
||||||
|
|
||||||
|
Arguments
|
||||||
|
---------
|
||||||
|
|
||||||
|
- `instance`:
|
||||||
|
the UnitCommitment instance.
|
||||||
|
|
||||||
|
- `method`:
|
||||||
|
the `TimeDecomposition` method.
|
||||||
|
|
||||||
|
- `optimizer`:
|
||||||
|
the optimizer for solving the problem.
|
||||||
|
|
||||||
|
- `after_build`:
|
||||||
|
a user-defined function that allows modifying the model after building,
|
||||||
|
must have 2 arguments `model` and `instance` in order.
|
||||||
|
|
||||||
|
- `after_optimize`:
|
||||||
|
a user-defined function that allows handling additional steps after optimizing,
|
||||||
|
must have 3 arguments `solution`, `model` and `instance` in order.
|
||||||
|
|
||||||
|
|
||||||
|
Examples
|
||||||
|
--------
|
||||||
|
|
||||||
|
```julia
|
||||||
|
using UnitCommitment, JuMP, Cbc, HiGHS
|
||||||
|
|
||||||
|
import UnitCommitment:
|
||||||
|
TimeDecomposition,
|
||||||
|
ConventionalLMP,
|
||||||
|
XavQiuWanThi2019,
|
||||||
|
Formulation
|
||||||
|
|
||||||
|
# specifying the after_build and after_optimize functions
|
||||||
|
function after_build(model, instance)
|
||||||
|
@constraint(
|
||||||
|
model,
|
||||||
|
model[:is_on]["g3", 1] + model[:is_on]["g4", 1] <= 1,
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
lmps = []
|
||||||
|
function after_optimize(solution, model, instance)
|
||||||
|
lmp = UnitCommitment.compute_lmp(
|
||||||
|
model,
|
||||||
|
ConventionalLMP(),
|
||||||
|
optimizer = HiGHS.Optimizer,
|
||||||
|
)
|
||||||
|
return push!(lmps, lmp)
|
||||||
|
end
|
||||||
|
|
||||||
|
# assume the instance is given as a 120h problem
|
||||||
|
instance = UnitCommitment.read("instance.json")
|
||||||
|
|
||||||
|
solution = UnitCommitment.optimize!(
|
||||||
|
instance,
|
||||||
|
TimeDecomposition(
|
||||||
|
time_window = 36, # solve 36h problems
|
||||||
|
time_increment = 24, # advance by 24h each time
|
||||||
|
inner_method = XavQiuWanThi2019.Method(),
|
||||||
|
formulation = Formulation(),
|
||||||
|
),
|
||||||
|
optimizer = Cbc.Optimizer,
|
||||||
|
after_build = after_build,
|
||||||
|
after_optimize = after_optimize,
|
||||||
|
)
|
||||||
|
"""
|
||||||
|
|
||||||
|
function optimize!(
|
||||||
|
instance::UnitCommitmentInstance,
|
||||||
|
method::TimeDecomposition;
|
||||||
|
optimizer,
|
||||||
|
after_build = nothing,
|
||||||
|
after_optimize = nothing,
|
||||||
|
)::OrderedDict
|
||||||
|
# get instance total length
|
||||||
|
T = instance.time
|
||||||
|
solution = OrderedDict()
|
||||||
|
if length(instance.scenarios) > 1
|
||||||
|
for sc in instance.scenarios
|
||||||
|
solution[sc.name] = OrderedDict()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# for each iteration, time increment by method.time_increment
|
||||||
|
for t_start in 1:method.time_increment:T
|
||||||
|
t_end = t_start + method.time_window - 1
|
||||||
|
# if t_end exceed total T
|
||||||
|
t_end = t_end > T ? T : t_end
|
||||||
|
# slice the model
|
||||||
|
@info "Solving the sub-problem of time $t_start to $t_end..."
|
||||||
|
sub_instance = UnitCommitment.slice(instance, t_start:t_end)
|
||||||
|
# build and optimize the model
|
||||||
|
sub_model = UnitCommitment.build_model(
|
||||||
|
instance = sub_instance,
|
||||||
|
optimizer = optimizer,
|
||||||
|
formulation = method.formulation,
|
||||||
|
)
|
||||||
|
if after_build !== nothing
|
||||||
|
@info "Calling after build..."
|
||||||
|
after_build(sub_model, sub_instance)
|
||||||
|
end
|
||||||
|
UnitCommitment.optimize!(sub_model, method.inner_method)
|
||||||
|
# get the result of each time period
|
||||||
|
sub_solution = UnitCommitment.solution(sub_model)
|
||||||
|
if after_optimize !== nothing
|
||||||
|
@info "Calling after optimize..."
|
||||||
|
after_optimize(sub_solution, sub_model, sub_instance)
|
||||||
|
end
|
||||||
|
# merge solution
|
||||||
|
if length(instance.scenarios) == 1
|
||||||
|
_update_solution!(solution, sub_solution, method.time_increment)
|
||||||
|
else
|
||||||
|
for sc in instance.scenarios
|
||||||
|
_update_solution!(
|
||||||
|
solution[sc.name],
|
||||||
|
sub_solution[sc.name],
|
||||||
|
method.time_increment,
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# set the initial status for the next sub-problem
|
||||||
|
_set_initial_status!(instance, solution, method.time_increment)
|
||||||
|
end
|
||||||
|
return solution
|
||||||
|
end
|
||||||
|
|
||||||
|
"""
|
||||||
|
_set_initial_status!(
|
||||||
|
instance::UnitCommitmentInstance,
|
||||||
|
solution::OrderedDict,
|
||||||
|
time_increment::Int,
|
||||||
|
)
|
||||||
|
|
||||||
|
Set the thermal units' initial power levels and statuses based on the last bunch of time slots
|
||||||
|
specified by time_increment in the solution dictionary.
|
||||||
|
"""
|
||||||
|
function _set_initial_status!(
|
||||||
|
instance::UnitCommitmentInstance,
|
||||||
|
solution::OrderedDict,
|
||||||
|
time_increment::Int,
|
||||||
|
)
|
||||||
|
for sc in instance.scenarios
|
||||||
|
for thermal_unit in sc.thermal_units
|
||||||
|
if length(instance.scenarios) == 1
|
||||||
|
prod = solution["Thermal production (MW)"][thermal_unit.name]
|
||||||
|
is_on = solution["Is on"][thermal_unit.name]
|
||||||
|
else
|
||||||
|
prod =
|
||||||
|
solution[sc.name]["Thermal production (MW)"][thermal_unit.name]
|
||||||
|
is_on = solution[sc.name]["Is on"][thermal_unit.name]
|
||||||
|
end
|
||||||
|
thermal_unit.initial_power = prod[end]
|
||||||
|
thermal_unit.initial_status = _determine_initial_status(
|
||||||
|
thermal_unit.initial_status,
|
||||||
|
is_on[end-time_increment+1:end],
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
"""
|
||||||
|
_determine_initial_status(
|
||||||
|
prev_initial_status::Union{Float64,Int},
|
||||||
|
status_sequence::Vector{Float64},
|
||||||
|
)::Union{Float64,Int}
|
||||||
|
|
||||||
|
Determines a thermal unit's initial status based on its previous initial status, and
|
||||||
|
the on/off statuses in the last operation.
|
||||||
|
"""
|
||||||
|
function _determine_initial_status(
|
||||||
|
prev_initial_status::Union{Float64,Int},
|
||||||
|
status_sequence::Vector{Float64},
|
||||||
|
)::Union{Float64,Int}
|
||||||
|
# initialize the two flags
|
||||||
|
on_status = prev_initial_status
|
||||||
|
off_status = prev_initial_status
|
||||||
|
# read through the status sequence
|
||||||
|
# at each time if the unit is on, reset off_status, increment on_status
|
||||||
|
# if the on_status < 0, set it to 1.0
|
||||||
|
# at each time if the unit is off, reset on_status, decrement off_status
|
||||||
|
# if the off_status > 0, set it to -1.0
|
||||||
|
for status in status_sequence
|
||||||
|
if status == 1.0
|
||||||
|
on_status = on_status < 0.0 ? 1.0 : on_status + 1.0
|
||||||
|
off_status = 0.0
|
||||||
|
else
|
||||||
|
on_status = 0.0
|
||||||
|
off_status = off_status > 0.0 ? -1.0 : off_status - 1.0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# only one of them has non-zero value
|
||||||
|
return on_status + off_status
|
||||||
|
end
|
||||||
|
|
||||||
|
"""
|
||||||
|
_update_solution!(
|
||||||
|
solution::OrderedDict,
|
||||||
|
sub_solution::OrderedDict,
|
||||||
|
time_increment::Int,
|
||||||
|
)
|
||||||
|
|
||||||
|
Updates the solution (of each scenario) by concatenating the first bunch of
|
||||||
|
time slots of the newly generated sub-solution to the end of the final solution dictionary.
|
||||||
|
This function traverses through the dictionary keys, finds the vector and finally
|
||||||
|
does the concatenation. For now, the function is hardcoded to traverse at most 3 layers
|
||||||
|
of depth until it finds a vector object.
|
||||||
|
"""
|
||||||
|
function _update_solution!(
|
||||||
|
solution::OrderedDict,
|
||||||
|
sub_solution::OrderedDict,
|
||||||
|
time_increment::Int,
|
||||||
|
)
|
||||||
|
# the solution has at most 3 layers
|
||||||
|
for (l1_k, l1_v) in sub_solution
|
||||||
|
for (l2_k, l2_v) in l1_v
|
||||||
|
if l2_v isa Array
|
||||||
|
# slice the sub_solution
|
||||||
|
values_of_interest = l2_v[1:time_increment]
|
||||||
|
sub_solution[l1_k][l2_k] = values_of_interest
|
||||||
|
# append to the solution
|
||||||
|
if !isempty(solution)
|
||||||
|
append!(solution[l1_k][l2_k], values_of_interest)
|
||||||
|
end
|
||||||
|
elseif l2_v isa OrderedDict
|
||||||
|
for (l3_k, l3_v) in l2_v
|
||||||
|
# slice the sub_solution
|
||||||
|
values_of_interest = l3_v[1:time_increment]
|
||||||
|
sub_solution[l1_k][l2_k][l3_k] = values_of_interest
|
||||||
|
# append to the solution
|
||||||
|
if !isempty(solution)
|
||||||
|
append!(solution[l1_k][l2_k][l3_k], values_of_interest)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# if solution is never initialized, deep copy the sliced sub_solution
|
||||||
|
if isempty(solution)
|
||||||
|
merge!(solution, sub_solution)
|
||||||
|
end
|
||||||
|
end
|
||||||
35
src/solution/methods/TimeDecomposition/structs.jl
Normal file
35
src/solution/methods/TimeDecomposition/structs.jl
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
# UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
|
||||||
|
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
||||||
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
|
|
||||||
|
import ..SolutionMethod
|
||||||
|
import ..Formulation
|
||||||
|
"""
|
||||||
|
mutable struct TimeDecomposition <: SolutionMethod
|
||||||
|
time_window::Int
|
||||||
|
time_increment::Int
|
||||||
|
inner_method::SolutionMethod = XavQiuWanThi2019.Method()
|
||||||
|
formulation::Formulation = Formulation()
|
||||||
|
end
|
||||||
|
|
||||||
|
Time decomposition method to solve a problem with moving time window.
|
||||||
|
|
||||||
|
Fields
|
||||||
|
------
|
||||||
|
|
||||||
|
- `time_window`:
|
||||||
|
the time window of each sub-problem during the entire optimization procedure.
|
||||||
|
- `time_increment`:
|
||||||
|
the time incremented to the next sub-problem.
|
||||||
|
- `inner_method`:
|
||||||
|
method to solve each sub-problem.
|
||||||
|
- `formulation`:
|
||||||
|
problem formulation.
|
||||||
|
|
||||||
|
"""
|
||||||
|
Base.@kwdef mutable struct TimeDecomposition <: SolutionMethod
|
||||||
|
time_window::Int
|
||||||
|
time_increment::Int
|
||||||
|
inner_method::SolutionMethod = XavQiuWanThi2019.Method()
|
||||||
|
formulation::Formulation = Formulation()
|
||||||
|
end
|
||||||
@@ -5,13 +5,15 @@
|
|||||||
function _enforce_transmission(
|
function _enforce_transmission(
|
||||||
model::JuMP.Model,
|
model::JuMP.Model,
|
||||||
violations::Vector{_Violation},
|
violations::Vector{_Violation},
|
||||||
|
sc::UnitCommitmentScenario,
|
||||||
)::Nothing
|
)::Nothing
|
||||||
for v in violations
|
for v in violations
|
||||||
_enforce_transmission(
|
_enforce_transmission(
|
||||||
model = model,
|
model = model,
|
||||||
|
sc = sc,
|
||||||
violation = v,
|
violation = v,
|
||||||
isf = model[:isf],
|
isf = sc.isf,
|
||||||
lodf = model[:lodf],
|
lodf = sc.lodf,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
@@ -19,6 +21,7 @@ end
|
|||||||
|
|
||||||
function _enforce_transmission(;
|
function _enforce_transmission(;
|
||||||
model::JuMP.Model,
|
model::JuMP.Model,
|
||||||
|
sc::UnitCommitmentScenario,
|
||||||
violation::_Violation,
|
violation::_Violation,
|
||||||
isf::Matrix{Float64},
|
isf::Matrix{Float64},
|
||||||
lodf::Matrix{Float64},
|
lodf::Matrix{Float64},
|
||||||
@@ -31,19 +34,21 @@ function _enforce_transmission(;
|
|||||||
if violation.outage_line === nothing
|
if violation.outage_line === nothing
|
||||||
limit = violation.monitored_line.normal_flow_limit[violation.time]
|
limit = violation.monitored_line.normal_flow_limit[violation.time]
|
||||||
@info @sprintf(
|
@info @sprintf(
|
||||||
" %8.3f MW overflow in %-5s time %3d (pre-contingency)",
|
" %8.3f MW overflow in %-5s time %3d (pre-contingency, scenario %s)",
|
||||||
violation.amount,
|
violation.amount,
|
||||||
violation.monitored_line.name,
|
violation.monitored_line.name,
|
||||||
violation.time,
|
violation.time,
|
||||||
|
sc.name,
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
limit = violation.monitored_line.emergency_flow_limit[violation.time]
|
limit = violation.monitored_line.emergency_flow_limit[violation.time]
|
||||||
@info @sprintf(
|
@info @sprintf(
|
||||||
" %8.3f MW overflow in %-5s time %3d (outage: line %s)",
|
" %8.3f MW overflow in %-5s time %3d (outage: line %s, scenario %s)",
|
||||||
violation.amount,
|
violation.amount,
|
||||||
violation.monitored_line.name,
|
violation.monitored_line.name,
|
||||||
violation.time,
|
violation.time,
|
||||||
violation.outage_line.name,
|
violation.outage_line.name,
|
||||||
|
sc.name,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -51,7 +56,7 @@ function _enforce_transmission(;
|
|||||||
t = violation.time
|
t = violation.time
|
||||||
flow = @variable(model, base_name = "flow[$fm,$t]")
|
flow = @variable(model, base_name = "flow[$fm,$t]")
|
||||||
|
|
||||||
v = overflow[violation.monitored_line.name, violation.time]
|
v = overflow[sc.name, violation.monitored_line.name, violation.time]
|
||||||
@constraint(model, flow <= limit + v)
|
@constraint(model, flow <= limit + v)
|
||||||
@constraint(model, -flow <= limit + v)
|
@constraint(model, -flow <= limit + v)
|
||||||
|
|
||||||
@@ -59,23 +64,23 @@ function _enforce_transmission(;
|
|||||||
@constraint(
|
@constraint(
|
||||||
model,
|
model,
|
||||||
flow == sum(
|
flow == sum(
|
||||||
net_injection[b.name, violation.time] *
|
net_injection[sc.name, b.name, violation.time] *
|
||||||
isf[violation.monitored_line.offset, b.offset] for
|
isf[violation.monitored_line.offset, b.offset] for
|
||||||
b in instance.buses if b.offset > 0
|
b in sc.buses if b.offset > 0
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
@constraint(
|
@constraint(
|
||||||
model,
|
model,
|
||||||
flow == sum(
|
flow == sum(
|
||||||
net_injection[b.name, violation.time] * (
|
net_injection[sc.name, b.name, violation.time] * (
|
||||||
isf[violation.monitored_line.offset, b.offset] + (
|
isf[violation.monitored_line.offset, b.offset] + (
|
||||||
lodf[
|
lodf[
|
||||||
violation.monitored_line.offset,
|
violation.monitored_line.offset,
|
||||||
violation.outage_line.offset,
|
violation.outage_line.offset,
|
||||||
] * isf[violation.outage_line.offset, b.offset]
|
] * isf[violation.outage_line.offset, b.offset]
|
||||||
)
|
)
|
||||||
) for b in instance.buses if b.offset > 0
|
) for b in sc.buses if b.offset > 0
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,40 +5,36 @@
|
|||||||
import Base.Threads: @threads
|
import Base.Threads: @threads
|
||||||
|
|
||||||
function _find_violations(
|
function _find_violations(
|
||||||
model::JuMP.Model;
|
model::JuMP.Model,
|
||||||
|
sc::UnitCommitmentScenario;
|
||||||
max_per_line::Int,
|
max_per_line::Int,
|
||||||
max_per_period::Int,
|
max_per_period::Int,
|
||||||
)
|
)
|
||||||
instance = model[:instance]
|
instance = model[:instance]
|
||||||
net_injection = model[:net_injection]
|
net_injection = model[:net_injection]
|
||||||
overflow = model[:overflow]
|
overflow = model[:overflow]
|
||||||
length(instance.buses) > 1 || return []
|
length(sc.buses) > 1 || return []
|
||||||
violations = []
|
violations = []
|
||||||
@info "Verifying transmission limits..."
|
|
||||||
time_screening = @elapsed begin
|
non_slack_buses = [b for b in sc.buses if b.offset > 0]
|
||||||
non_slack_buses = [b for b in instance.buses if b.offset > 0]
|
|
||||||
net_injection_values = [
|
net_injection_values = [
|
||||||
value(net_injection[b.name, t]) for b in non_slack_buses,
|
value(net_injection[sc.name, b.name, t]) for b in non_slack_buses,
|
||||||
t in 1:instance.time
|
t in 1:instance.time
|
||||||
]
|
]
|
||||||
overflow_values = [
|
overflow_values = [
|
||||||
value(overflow[lm.name, t]) for lm in instance.lines,
|
value(overflow[sc.name, lm.name, t]) for lm in sc.lines,
|
||||||
t in 1:instance.time
|
t in 1:instance.time
|
||||||
]
|
]
|
||||||
violations = UnitCommitment._find_violations(
|
violations = UnitCommitment._find_violations(
|
||||||
instance = instance,
|
instance = instance,
|
||||||
|
sc = sc,
|
||||||
net_injections = net_injection_values,
|
net_injections = net_injection_values,
|
||||||
overflow = overflow_values,
|
overflow = overflow_values,
|
||||||
isf = model[:isf],
|
isf = sc.isf,
|
||||||
lodf = model[:lodf],
|
lodf = sc.lodf,
|
||||||
max_per_line = max_per_line,
|
max_per_line = max_per_line,
|
||||||
max_per_period = max_per_period,
|
max_per_period = max_per_period,
|
||||||
)
|
)
|
||||||
end
|
|
||||||
@info @sprintf(
|
|
||||||
"Verified transmission limits in %.2f seconds",
|
|
||||||
time_screening
|
|
||||||
)
|
|
||||||
return violations
|
return violations
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -64,6 +60,7 @@ matrix, where L is the number of transmission lines.
|
|||||||
"""
|
"""
|
||||||
function _find_violations(;
|
function _find_violations(;
|
||||||
instance::UnitCommitmentInstance,
|
instance::UnitCommitmentInstance,
|
||||||
|
sc::UnitCommitmentScenario,
|
||||||
net_injections::Array{Float64,2},
|
net_injections::Array{Float64,2},
|
||||||
overflow::Array{Float64,2},
|
overflow::Array{Float64,2},
|
||||||
isf::Array{Float64,2},
|
isf::Array{Float64,2},
|
||||||
@@ -71,8 +68,8 @@ function _find_violations(;
|
|||||||
max_per_line::Int,
|
max_per_line::Int,
|
||||||
max_per_period::Int,
|
max_per_period::Int,
|
||||||
)::Array{_Violation,1}
|
)::Array{_Violation,1}
|
||||||
B = length(instance.buses) - 1
|
B = length(sc.buses) - 1
|
||||||
L = length(instance.lines)
|
L = length(sc.lines)
|
||||||
T = instance.time
|
T = instance.time
|
||||||
K = nthreads()
|
K = nthreads()
|
||||||
|
|
||||||
@@ -93,17 +90,17 @@ function _find_violations(;
|
|||||||
post_v::Array{Float64} = zeros(L, L, K) # post_v[lm, lc, thread]
|
post_v::Array{Float64} = zeros(L, L, K) # post_v[lm, lc, thread]
|
||||||
|
|
||||||
normal_limits::Array{Float64,2} = [
|
normal_limits::Array{Float64,2} = [
|
||||||
l.normal_flow_limit[t] + overflow[l.offset, t] for
|
l.normal_flow_limit[t] + overflow[l.offset, t] for l in sc.lines,
|
||||||
l in instance.lines, t in 1:T
|
t in 1:T
|
||||||
]
|
]
|
||||||
|
|
||||||
emergency_limits::Array{Float64,2} = [
|
emergency_limits::Array{Float64,2} = [
|
||||||
l.emergency_flow_limit[t] + overflow[l.offset, t] for
|
l.emergency_flow_limit[t] + overflow[l.offset, t] for l in sc.lines,
|
||||||
l in instance.lines, t in 1:T
|
t in 1:T
|
||||||
]
|
]
|
||||||
|
|
||||||
is_vulnerable::Array{Bool} = zeros(Bool, L)
|
is_vulnerable::Array{Bool} = zeros(Bool, L)
|
||||||
for c in instance.contingencies
|
for c in sc.contingencies
|
||||||
is_vulnerable[c.lines[1].offset] = true
|
is_vulnerable[c.lines[1].offset] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -144,7 +141,7 @@ function _find_violations(;
|
|||||||
filters[t],
|
filters[t],
|
||||||
_Violation(
|
_Violation(
|
||||||
time = t,
|
time = t,
|
||||||
monitored_line = instance.lines[lm],
|
monitored_line = sc.lines[lm],
|
||||||
outage_line = nothing,
|
outage_line = nothing,
|
||||||
amount = pre_v[lm, k],
|
amount = pre_v[lm, k],
|
||||||
),
|
),
|
||||||
@@ -159,8 +156,8 @@ function _find_violations(;
|
|||||||
filters[t],
|
filters[t],
|
||||||
_Violation(
|
_Violation(
|
||||||
time = t,
|
time = t,
|
||||||
monitored_line = instance.lines[lm],
|
monitored_line = sc.lines[lm],
|
||||||
outage_line = instance.lines[lc],
|
outage_line = sc.lines[lc],
|
||||||
amount = post_v[lm, lc, k],
|
amount = post_v[lm, lc, k],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -12,11 +12,16 @@ function optimize!(model::JuMP.Model, method::XavQiuWanThi2019.Method)::Nothing
|
|||||||
end
|
end
|
||||||
initial_time = time()
|
initial_time = time()
|
||||||
large_gap = false
|
large_gap = false
|
||||||
has_transmission = (length(model[:isf]) > 0)
|
has_transmission = false
|
||||||
|
for sc in model[:instance].scenarios
|
||||||
|
if length(sc.isf) > 0
|
||||||
|
has_transmission = true
|
||||||
|
end
|
||||||
if has_transmission && method.two_phase_gap
|
if has_transmission && method.two_phase_gap
|
||||||
set_gap(1e-2)
|
set_gap(1e-2)
|
||||||
large_gap = true
|
large_gap = true
|
||||||
end
|
end
|
||||||
|
end
|
||||||
while true
|
while true
|
||||||
time_elapsed = time() - initial_time
|
time_elapsed = time() - initial_time
|
||||||
time_remaining = method.time_limit - time_elapsed
|
time_remaining = method.time_limit - time_elapsed
|
||||||
@@ -31,13 +36,41 @@ function optimize!(model::JuMP.Model, method::XavQiuWanThi2019.Method)::Nothing
|
|||||||
JuMP.set_time_limit_sec(model, time_remaining)
|
JuMP.set_time_limit_sec(model, time_remaining)
|
||||||
@info "Solving MILP..."
|
@info "Solving MILP..."
|
||||||
JuMP.optimize!(model)
|
JuMP.optimize!(model)
|
||||||
|
|
||||||
has_transmission || break
|
has_transmission || break
|
||||||
violations = _find_violations(
|
|
||||||
|
@info "Verifying transmission limits..."
|
||||||
|
time_screening = @elapsed begin
|
||||||
|
violations = []
|
||||||
|
for sc in model[:instance].scenarios
|
||||||
|
push!(
|
||||||
|
violations,
|
||||||
|
_find_violations(
|
||||||
model,
|
model,
|
||||||
|
sc,
|
||||||
max_per_line = method.max_violations_per_line,
|
max_per_line = method.max_violations_per_line,
|
||||||
max_per_period = method.max_violations_per_period,
|
max_per_period = method.max_violations_per_period,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
if isempty(violations)
|
end
|
||||||
|
end
|
||||||
|
@info @sprintf(
|
||||||
|
"Verified transmission limits in %.2f seconds",
|
||||||
|
time_screening
|
||||||
|
)
|
||||||
|
|
||||||
|
violations_found = false
|
||||||
|
for v in violations
|
||||||
|
if !isempty(v)
|
||||||
|
violations_found = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if violations_found
|
||||||
|
for (i, v) in enumerate(violations)
|
||||||
|
_enforce_transmission(model, v, model[:instance].scenarios[i])
|
||||||
|
end
|
||||||
|
else
|
||||||
@info "No violations found"
|
@info "No violations found"
|
||||||
if large_gap
|
if large_gap
|
||||||
large_gap = false
|
large_gap = false
|
||||||
@@ -45,8 +78,6 @@ function optimize!(model::JuMP.Model, method::XavQiuWanThi2019.Method)::Nothing
|
|||||||
else
|
else
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
else
|
|
||||||
_enforce_transmission(model, violations)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -2,14 +2,6 @@
|
|||||||
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
||||||
# Released under the modified BSD license. See COPYING.md for more details.
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
|
|
||||||
"""
|
|
||||||
Lazy constraint solution method described in:
|
|
||||||
|
|
||||||
Xavier, A. S., Qiu, F., Wang, F., & Thimmapuram, P. R. (2019). Transmission
|
|
||||||
constraint filtering in large-scale security-constrained unit commitment.
|
|
||||||
IEEE Transactions on Power Systems, 34(3), 2457-2460.
|
|
||||||
DOI: https://doi.org/10.1109/TPWRS.2019.2892620
|
|
||||||
"""
|
|
||||||
module XavQiuWanThi2019
|
module XavQiuWanThi2019
|
||||||
import ..SolutionMethod
|
import ..SolutionMethod
|
||||||
"""
|
"""
|
||||||
@@ -21,6 +13,13 @@ import ..SolutionMethod
|
|||||||
max_violations_per_period::Int
|
max_violations_per_period::Int
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Lazy constraint solution method described in:
|
||||||
|
|
||||||
|
Xavier, A. S., Qiu, F., Wang, F., & Thimmapuram, P. R. (2019). Transmission
|
||||||
|
constraint filtering in large-scale security-constrained unit commitment.
|
||||||
|
IEEE Transactions on Power Systems, 34(3), 2457-2460.
|
||||||
|
DOI: https://doi.org/10.1109/TPWRS.2019.2892620
|
||||||
|
|
||||||
Fields
|
Fields
|
||||||
------
|
------
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
# Released under the modified BSD license. See COPYING.md for more details.
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
function optimize!(model::JuMP.Model)::Nothing
|
optimize!(model::JuMP.Model)::Nothing
|
||||||
|
|
||||||
Solve the given unit commitment model. Unlike JuMP.optimize!, this uses more
|
Solve the given unit commitment model. Unlike `JuMP.optimize!`, this uses more
|
||||||
advanced methods to accelerate the solution process and to enforce transmission
|
advanced methods to accelerate the solution process and to enforce transmission
|
||||||
and N-1 security constraints.
|
and N-1 security constraints.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -2,36 +2,58 @@
|
|||||||
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
||||||
# Released under the modified BSD license. See COPYING.md for more details.
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
|
|
||||||
|
"""
|
||||||
|
solution(model::JuMP.Model)::OrderedDict
|
||||||
|
|
||||||
|
Extracts the optimal solution from the UC.jl model. The model must be solved beforehand.
|
||||||
|
|
||||||
|
# Example
|
||||||
|
|
||||||
|
```julia
|
||||||
|
UnitCommitment.optimize!(model)
|
||||||
|
solution = UnitCommitment.solution(model)
|
||||||
|
```
|
||||||
|
"""
|
||||||
function solution(model::JuMP.Model)::OrderedDict
|
function solution(model::JuMP.Model)::OrderedDict
|
||||||
instance, T = model[:instance], model[:instance].time
|
instance, T = model[:instance], model[:instance].time
|
||||||
function timeseries(vars, collection)
|
function timeseries(vars, collection; sc = nothing)
|
||||||
|
if sc === nothing
|
||||||
return OrderedDict(
|
return OrderedDict(
|
||||||
b.name => [round(value(vars[b.name, t]), digits = 5) for t in 1:T]
|
b.name =>
|
||||||
for b in collection
|
[round(value(vars[b.name, t]), digits = 5) for t in 1:T] for
|
||||||
|
b in collection
|
||||||
|
)
|
||||||
|
else
|
||||||
|
return OrderedDict(
|
||||||
|
b.name => [
|
||||||
|
round(value(vars[sc.name, b.name, t]), digits = 5) for
|
||||||
|
t in 1:T
|
||||||
|
] for b in collection
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
function production_cost(g)
|
end
|
||||||
|
function production_cost(g, sc)
|
||||||
return [
|
return [
|
||||||
value(model[:is_on][g.name, t]) * g.min_power_cost[t] + sum(
|
value(model[:is_on][g.name, t]) * g.min_power_cost[t] + sum(
|
||||||
Float64[
|
Float64[
|
||||||
value(model[:segprod][g.name, t, k]) *
|
value(model[:segprod][sc.name, g.name, t, k]) *
|
||||||
g.cost_segments[k].cost[t] for
|
g.cost_segments[k].cost[t] for
|
||||||
k in 1:length(g.cost_segments)
|
k in 1:length(g.cost_segments)
|
||||||
],
|
],
|
||||||
) for t in 1:T
|
) for t in 1:T
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
function production(g)
|
function production(g, sc)
|
||||||
return [
|
return [
|
||||||
value(model[:is_on][g.name, t]) * g.min_power[t] + sum(
|
value(model[:is_on][g.name, t]) * g.min_power[t] + sum(
|
||||||
Float64[
|
Float64[
|
||||||
value(model[:segprod][g.name, t, k]) for
|
value(model[:segprod][sc.name, g.name, t, k]) for
|
||||||
k in 1:length(g.cost_segments)
|
k in 1:length(g.cost_segments)
|
||||||
],
|
],
|
||||||
) for t in 1:T
|
) for t in 1:T
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
function startup_cost(g)
|
function startup_cost(g, sc)
|
||||||
S = length(g.startup_categories)
|
S = length(g.startup_categories)
|
||||||
return [
|
return [
|
||||||
sum(
|
sum(
|
||||||
@@ -41,55 +63,111 @@ function solution(model::JuMP.Model)::OrderedDict
|
|||||||
]
|
]
|
||||||
end
|
end
|
||||||
sol = OrderedDict()
|
sol = OrderedDict()
|
||||||
sol["Production (MW)"] =
|
for sc in instance.scenarios
|
||||||
OrderedDict(g.name => production(g) for g in instance.units)
|
sol[sc.name] = OrderedDict()
|
||||||
sol["Production cost (\$)"] =
|
if !isempty(sc.thermal_units)
|
||||||
OrderedDict(g.name => production_cost(g) for g in instance.units)
|
sol[sc.name]["Thermal production (MW)"] = OrderedDict(
|
||||||
sol["Startup cost (\$)"] =
|
g.name => production(g, sc) for g in sc.thermal_units
|
||||||
OrderedDict(g.name => startup_cost(g) for g in instance.units)
|
|
||||||
sol["Is on"] = timeseries(model[:is_on], instance.units)
|
|
||||||
sol["Switch on"] = timeseries(model[:switch_on], instance.units)
|
|
||||||
sol["Switch off"] = timeseries(model[:switch_off], instance.units)
|
|
||||||
if instance.reserves.upflexiramp != zeros(T) ||
|
|
||||||
instance.reserves.dwflexiramp != zeros(T)
|
|
||||||
# Report flexiramp solutions only if either of the up-flexiramp and
|
|
||||||
# down-flexiramp requirements is not a default array of zeros
|
|
||||||
sol["Up-flexiramp (MW)"] =
|
|
||||||
timeseries(model[:upflexiramp], instance.units)
|
|
||||||
sol["Up-flexiramp shortfall (MW)"] = OrderedDict(
|
|
||||||
t =>
|
|
||||||
(instance.flexiramp_shortfall_penalty[t] >= 0) ?
|
|
||||||
round(value(model[:upflexiramp_shortfall][t]), digits = 5) :
|
|
||||||
0.0 for t in 1:instance.time
|
|
||||||
)
|
)
|
||||||
sol["Down-flexiramp (MW)"] =
|
sol[sc.name]["Thermal production cost (\$)"] = OrderedDict(
|
||||||
timeseries(model[:dwflexiramp], instance.units)
|
g.name => production_cost(g, sc) for g in sc.thermal_units
|
||||||
sol["Down-flexiramp shortfall (MW)"] = OrderedDict(
|
|
||||||
t =>
|
|
||||||
(instance.flexiramp_shortfall_penalty[t] >= 0) ?
|
|
||||||
round(value(model[:dwflexiramp_shortfall][t]), digits = 5) :
|
|
||||||
0.0 for t in 1:instance.time
|
|
||||||
)
|
)
|
||||||
|
sol[sc.name]["Startup cost (\$)"] = OrderedDict(
|
||||||
|
g.name => startup_cost(g, sc) for g in sc.thermal_units
|
||||||
|
)
|
||||||
|
sol[sc.name]["Is on"] = timeseries(model[:is_on], sc.thermal_units)
|
||||||
|
sol[sc.name]["Switch on"] =
|
||||||
|
timeseries(model[:switch_on], sc.thermal_units)
|
||||||
|
sol[sc.name]["Switch off"] =
|
||||||
|
timeseries(model[:switch_off], sc.thermal_units)
|
||||||
|
sol[sc.name]["Net injection (MW)"] =
|
||||||
|
timeseries(model[:net_injection], sc.buses, sc = sc)
|
||||||
|
sol[sc.name]["Load curtail (MW)"] =
|
||||||
|
timeseries(model[:curtail], sc.buses, sc = sc)
|
||||||
|
end
|
||||||
|
if !isempty(sc.lines)
|
||||||
|
sol[sc.name]["Line overflow (MW)"] =
|
||||||
|
timeseries(model[:overflow], sc.lines, sc = sc)
|
||||||
|
end
|
||||||
|
if !isempty(sc.price_sensitive_loads)
|
||||||
|
sol[sc.name]["Price-sensitive loads (MW)"] =
|
||||||
|
timeseries(model[:loads], sc.price_sensitive_loads, sc = sc)
|
||||||
|
end
|
||||||
|
if !isempty(sc.profiled_units)
|
||||||
|
sol[sc.name]["Profiled production (MW)"] =
|
||||||
|
timeseries(model[:prod_profiled], sc.profiled_units, sc = sc)
|
||||||
|
sol[sc.name]["Profiled production cost (\$)"] = OrderedDict(
|
||||||
|
pu.name => [
|
||||||
|
value(model[:prod_profiled][sc.name, pu.name, t]) *
|
||||||
|
pu.cost[t] for t in 1:instance.time
|
||||||
|
] for pu in sc.profiled_units
|
||||||
|
)
|
||||||
|
end
|
||||||
|
if !isempty(sc.storage_units)
|
||||||
|
sol[sc.name]["Storage level (MWh)"] =
|
||||||
|
timeseries(model[:storage_level], sc.storage_units, sc = sc)
|
||||||
|
sol[sc.name]["Is charging"] =
|
||||||
|
timeseries(model[:is_charging], sc.storage_units, sc = sc)
|
||||||
|
sol[sc.name]["Storage charging rates (MW)"] =
|
||||||
|
timeseries(model[:charge_rate], sc.storage_units, sc = sc)
|
||||||
|
sol[sc.name]["Storage charging cost (\$)"] = OrderedDict(
|
||||||
|
su.name => [
|
||||||
|
value(model[:charge_rate][sc.name, su.name, t]) *
|
||||||
|
su.charge_cost[t] for t in 1:instance.time
|
||||||
|
] for su in sc.storage_units
|
||||||
|
)
|
||||||
|
sol[sc.name]["Is discharging"] =
|
||||||
|
timeseries(model[:is_discharging], sc.storage_units, sc = sc)
|
||||||
|
sol[sc.name]["Storage discharging rates (MW)"] =
|
||||||
|
timeseries(model[:discharge_rate], sc.storage_units, sc = sc)
|
||||||
|
sol[sc.name]["Storage discharging cost (\$)"] = OrderedDict(
|
||||||
|
su.name => [
|
||||||
|
value(model[:discharge_rate][sc.name, su.name, t]) *
|
||||||
|
su.discharge_cost[t] for t in 1:instance.time
|
||||||
|
] for su in sc.storage_units
|
||||||
|
)
|
||||||
|
end
|
||||||
|
sol[sc.name]["Spinning reserve (MW)"] = OrderedDict(
|
||||||
|
r.name => OrderedDict(
|
||||||
|
g.name => [
|
||||||
|
value(model[:reserve][sc.name, r.name, g.name, t]) for t in 1:instance.time
|
||||||
|
] for g in r.thermal_units
|
||||||
|
) for r in sc.reserves if r.type == "spinning"
|
||||||
|
)
|
||||||
|
sol[sc.name]["Spinning reserve shortfall (MW)"] = OrderedDict(
|
||||||
|
r.name => [
|
||||||
|
value(model[:reserve_shortfall][sc.name, r.name, t]) for
|
||||||
|
t in 1:instance.time
|
||||||
|
] for r in sc.reserves if r.type == "spinning"
|
||||||
|
)
|
||||||
|
sol[sc.name]["Up-flexiramp (MW)"] = OrderedDict(
|
||||||
|
r.name => OrderedDict(
|
||||||
|
g.name => [
|
||||||
|
value(model[:upflexiramp][sc.name, r.name, g.name, t]) for t in 1:instance.time
|
||||||
|
] for g in r.thermal_units
|
||||||
|
) for r in sc.reserves if r.type == "flexiramp"
|
||||||
|
)
|
||||||
|
sol[sc.name]["Up-flexiramp shortfall (MW)"] = OrderedDict(
|
||||||
|
r.name => [
|
||||||
|
value(model[:upflexiramp_shortfall][sc.name, r.name, t]) for t in 1:instance.time
|
||||||
|
] for r in sc.reserves if r.type == "flexiramp"
|
||||||
|
)
|
||||||
|
sol[sc.name]["Down-flexiramp (MW)"] = OrderedDict(
|
||||||
|
r.name => OrderedDict(
|
||||||
|
g.name => [
|
||||||
|
value(model[:dwflexiramp][sc.name, r.name, g.name, t]) for t in 1:instance.time
|
||||||
|
] for g in r.thermal_units
|
||||||
|
) for r in sc.reserves if r.type == "flexiramp"
|
||||||
|
)
|
||||||
|
sol[sc.name]["Down-flexiramp shortfall (MW)"] = OrderedDict(
|
||||||
|
r.name => [
|
||||||
|
value(model[:dwflexiramp_shortfall][sc.name, r.name, t]) for t in 1:instance.time
|
||||||
|
] for r in sc.reserves if r.type == "flexiramp"
|
||||||
|
)
|
||||||
|
end
|
||||||
|
if length(instance.scenarios) == 1
|
||||||
|
return first(values(sol))
|
||||||
else
|
else
|
||||||
# Report spinning reserve solutions only if both up-flexiramp and
|
|
||||||
# down-flexiramp requirements are arrays of zeros.
|
|
||||||
sol["Reserve (MW)"] = timeseries(model[:reserve], instance.units)
|
|
||||||
sol["Reserve shortfall (MW)"] = OrderedDict(
|
|
||||||
t =>
|
|
||||||
(instance.shortfall_penalty[t] >= 0) ?
|
|
||||||
round(value(model[:reserve_shortfall][t]), digits = 5) :
|
|
||||||
0.0 for t in 1:instance.time
|
|
||||||
)
|
|
||||||
end
|
|
||||||
sol["Net injection (MW)"] =
|
|
||||||
timeseries(model[:net_injection], instance.buses)
|
|
||||||
sol["Load curtail (MW)"] = timeseries(model[:curtail], instance.buses)
|
|
||||||
if !isempty(instance.lines)
|
|
||||||
sol["Line overflow (MW)"] = timeseries(model[:overflow], instance.lines)
|
|
||||||
end
|
|
||||||
if !isempty(instance.price_sensitive_loads)
|
|
||||||
sol["Price-sensitive loads (MW)"] =
|
|
||||||
timeseries(model[:loads], instance.price_sensitive_loads)
|
|
||||||
end
|
|
||||||
return sol
|
return sol
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
function set_warm_start!(model::JuMP.Model, solution::AbstractDict)::Nothing
|
function set_warm_start!(model::JuMP.Model, solution::AbstractDict)::Nothing
|
||||||
instance, T = model[:instance], model[:instance].time
|
instance, T = model[:instance], model[:instance].time
|
||||||
is_on = model[:is_on]
|
is_on = model[:is_on]
|
||||||
for g in instance.units
|
for g in instance.thermal_units
|
||||||
for t in 1:T
|
for t in 1:T
|
||||||
JuMP.set_start_value(is_on[g.name, t], solution["Is on"][g.name][t])
|
JuMP.set_start_value(is_on[g.name, t], solution["Is on"][g.name][t])
|
||||||
JuMP.set_start_value(
|
JuMP.set_start_value(
|
||||||
|
|||||||
@@ -2,6 +2,18 @@
|
|||||||
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
|
||||||
# Released under the modified BSD license. See COPYING.md for more details.
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
|
|
||||||
|
"""
|
||||||
|
write(filename::AbstractString, solution::AbstractDict)::Nothing
|
||||||
|
|
||||||
|
Write the given solution to a JSON file.
|
||||||
|
|
||||||
|
# Example
|
||||||
|
|
||||||
|
```julia
|
||||||
|
solution = UnitCommitment.solution(model)
|
||||||
|
UnitCommitment.write("/tmp/output.json", solution)
|
||||||
|
```
|
||||||
|
"""
|
||||||
function write(filename::AbstractString, solution::AbstractDict)::Nothing
|
function write(filename::AbstractString, solution::AbstractDict)::Nothing
|
||||||
open(filename, "w") do file
|
open(filename, "w") do file
|
||||||
return JSON.print(file, solution, 2)
|
return JSON.print(file, solution, 2)
|
||||||
|
|||||||
@@ -15,26 +15,49 @@ function generate_initial_conditions!(
|
|||||||
instance::UnitCommitmentInstance,
|
instance::UnitCommitmentInstance,
|
||||||
optimizer,
|
optimizer,
|
||||||
)::Nothing
|
)::Nothing
|
||||||
G = instance.units
|
# Process first scenario
|
||||||
B = instance.buses
|
_generate_initial_conditions!(instance.scenarios[1], optimizer)
|
||||||
|
|
||||||
|
# Copy initial conditions to remaining scenarios
|
||||||
|
for (si, sc) in enumerate(instance.scenarios)
|
||||||
|
si > 1 || continue
|
||||||
|
for (gi, g) in sc.thermal_units
|
||||||
|
g_ref = instance.scenarios[1].thermal_units[gi]
|
||||||
|
g.initial_power = g_ref.initial_power
|
||||||
|
g.initial_status = g_ref.initial_status
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function _generate_initial_conditions!(
|
||||||
|
sc::UnitCommitmentScenario,
|
||||||
|
optimizer,
|
||||||
|
)::Nothing
|
||||||
|
G = sc.thermal_units
|
||||||
|
B = sc.buses
|
||||||
|
PU = sc.profiled_units
|
||||||
t = 1
|
t = 1
|
||||||
mip = JuMP.Model(optimizer)
|
mip = JuMP.Model(optimizer)
|
||||||
|
|
||||||
# Decision variables
|
# Decision variables
|
||||||
@variable(mip, x[G], Bin)
|
@variable(mip, x[G], Bin)
|
||||||
@variable(mip, p[G] >= 0)
|
@variable(mip, p[G] >= 0)
|
||||||
|
@variable(mip, pu[PU])
|
||||||
|
|
||||||
# Constraint: Minimum power
|
# Constraint: Minimum power
|
||||||
@constraint(mip, min_power[g in G], p[g] >= g.min_power[t] * x[g])
|
@constraint(mip, min_power[g in G], p[g] >= g.min_power[t] * x[g])
|
||||||
|
@constraint(mip, pu_min_power[k in PU], pu[k] >= k.min_power[t])
|
||||||
|
|
||||||
# Constraint: Maximum power
|
# Constraint: Maximum power
|
||||||
@constraint(mip, max_power[g in G], p[g] <= g.max_power[t] * x[g])
|
@constraint(mip, max_power[g in G], p[g] <= g.max_power[t] * x[g])
|
||||||
|
@constraint(mip, pu_max_power[k in PU], pu[k] <= k.max_power[t])
|
||||||
|
|
||||||
# Constraint: Production equals demand
|
# Constraint: Production equals demand
|
||||||
@constraint(
|
@constraint(
|
||||||
mip,
|
mip,
|
||||||
power_balance,
|
power_balance,
|
||||||
sum(b.load[t] for b in B) == sum(p[g] for g in G)
|
sum(b.load[t] for b in B) ==
|
||||||
|
sum(p[g] for g in G) + sum(pu[k] for k in PU)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Constraint: Must run
|
# Constraint: Must run
|
||||||
@@ -58,7 +81,12 @@ function generate_initial_conditions!(
|
|||||||
return c / mw
|
return c / mw
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@objective(mip, Min, sum(p[g] * cost_slope(g) for g in G))
|
@objective(
|
||||||
|
mip,
|
||||||
|
Min,
|
||||||
|
sum(p[g] * cost_slope(g) for g in G) +
|
||||||
|
sum(pu[k] * k.cost[t] for k in PU)
|
||||||
|
)
|
||||||
|
|
||||||
JuMP.optimize!(mip)
|
JuMP.optimize!(mip)
|
||||||
|
|
||||||
|
|||||||
@@ -2,17 +2,11 @@
|
|||||||
# Copyright (C) 2020-2021, UChicago Argonne, LLC. All rights reserved.
|
# Copyright (C) 2020-2021, UChicago Argonne, LLC. All rights reserved.
|
||||||
# Released under the modified BSD license. See COPYING.md for more details.
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
|
|
||||||
"""
|
|
||||||
Methods described in:
|
|
||||||
|
|
||||||
Xavier, Álinson S., Feng Qiu, and Shabbir Ahmed. "Learning to solve
|
|
||||||
large-scale security-constrained unit commitment problems." INFORMS
|
|
||||||
Journal on Computing 33.2 (2021): 739-756. DOI: 10.1287/ijoc.2020.0976
|
|
||||||
"""
|
|
||||||
module XavQiuAhm2021
|
module XavQiuAhm2021
|
||||||
|
|
||||||
using Distributions
|
using Distributions
|
||||||
import ..UnitCommitmentInstance
|
import ..UnitCommitmentInstance
|
||||||
|
import ..UnitCommitmentScenario
|
||||||
|
|
||||||
"""
|
"""
|
||||||
struct Randomization
|
struct Randomization
|
||||||
@@ -55,6 +49,13 @@ load profile, as follows:
|
|||||||
The default parameters were obtained based on an analysis of publicly available
|
The default parameters were obtained based on an analysis of publicly available
|
||||||
bid and hourly data from PJM, corresponding to the month of January, 2017. For
|
bid and hourly data from PJM, corresponding to the month of January, 2017. For
|
||||||
more details, see Section 4.2 of the paper.
|
more details, see Section 4.2 of the paper.
|
||||||
|
|
||||||
|
# References
|
||||||
|
|
||||||
|
- **Xavier, Álinson S., Feng Qiu, and Shabbir Ahmed.** *"Learning to solve
|
||||||
|
large-scale security-constrained unit commitment problems."* INFORMS Journal
|
||||||
|
on Computing 33.2 (2021): 739-756. DOI: 10.1287/ijoc.2020.0976
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Base.@kwdef struct Randomization
|
Base.@kwdef struct Randomization
|
||||||
cost = Uniform(0.95, 1.05)
|
cost = Uniform(0.95, 1.05)
|
||||||
@@ -119,10 +120,10 @@ end
|
|||||||
|
|
||||||
function _randomize_costs(
|
function _randomize_costs(
|
||||||
rng,
|
rng,
|
||||||
instance::UnitCommitmentInstance,
|
sc::UnitCommitmentScenario,
|
||||||
distribution,
|
distribution,
|
||||||
)::Nothing
|
)::Nothing
|
||||||
for unit in instance.units
|
for unit in sc.thermal_units
|
||||||
α = rand(rng, distribution)
|
α = rand(rng, distribution)
|
||||||
unit.min_power_cost *= α
|
unit.min_power_cost *= α
|
||||||
for k in unit.cost_segments
|
for k in unit.cost_segments
|
||||||
@@ -132,22 +133,29 @@ function _randomize_costs(
|
|||||||
s.cost *= α
|
s.cost *= α
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
for pu in sc.profiled_units
|
||||||
|
α = rand(rng, distribution)
|
||||||
|
pu.cost *= α
|
||||||
|
end
|
||||||
|
for su in sc.storage_units
|
||||||
|
α = rand(rng, distribution)
|
||||||
|
su.charge_cost *= α
|
||||||
|
su.discharge_cost *= α
|
||||||
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
function _randomize_load_share(
|
function _randomize_load_share(
|
||||||
rng,
|
rng,
|
||||||
instance::UnitCommitmentInstance,
|
sc::UnitCommitmentScenario,
|
||||||
distribution,
|
distribution,
|
||||||
)::Nothing
|
)::Nothing
|
||||||
α = rand(rng, distribution, length(instance.buses))
|
α = rand(rng, distribution, length(sc.buses))
|
||||||
for t in 1:instance.time
|
for t in 1:sc.time
|
||||||
total = sum(bus.load[t] for bus in instance.buses)
|
total = sum(bus.load[t] for bus in sc.buses)
|
||||||
den = sum(
|
den =
|
||||||
bus.load[t] / total * α[i] for
|
sum(bus.load[t] / total * α[i] for (i, bus) in enumerate(sc.buses))
|
||||||
(i, bus) in enumerate(instance.buses)
|
for (i, bus) in enumerate(sc.buses)
|
||||||
)
|
|
||||||
for (i, bus) in enumerate(instance.buses)
|
|
||||||
bus.load[t] *= α[i] / den
|
bus.load[t] *= α[i] / den
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -156,12 +164,12 @@ end
|
|||||||
|
|
||||||
function _randomize_load_profile(
|
function _randomize_load_profile(
|
||||||
rng,
|
rng,
|
||||||
instance::UnitCommitmentInstance,
|
sc::UnitCommitmentScenario,
|
||||||
params::Randomization,
|
params::Randomization,
|
||||||
)::Nothing
|
)::Nothing
|
||||||
# Generate new system load
|
# Generate new system load
|
||||||
system_load = [1.0]
|
system_load = [1.0]
|
||||||
for t in 2:instance.time
|
for t in 2:sc.time
|
||||||
idx = (t - 1) % length(params.load_profile_mu) + 1
|
idx = (t - 1) % length(params.load_profile_mu) + 1
|
||||||
gamma = rand(
|
gamma = rand(
|
||||||
rng,
|
rng,
|
||||||
@@ -169,14 +177,14 @@ function _randomize_load_profile(
|
|||||||
)
|
)
|
||||||
push!(system_load, system_load[t-1] * gamma)
|
push!(system_load, system_load[t-1] * gamma)
|
||||||
end
|
end
|
||||||
capacity = sum(maximum(u.max_power) for u in instance.units)
|
capacity = sum(maximum(u.max_power) for u in sc.thermal_units)
|
||||||
peak_load = rand(rng, params.peak_load) * capacity
|
peak_load = rand(rng, params.peak_load) * capacity
|
||||||
system_load = system_load ./ maximum(system_load) .* peak_load
|
system_load = system_load ./ maximum(system_load) .* peak_load
|
||||||
|
|
||||||
# Scale bus loads to match the new system load
|
# Scale bus loads to match the new system load
|
||||||
prev_system_load = sum(b.load for b in instance.buses)
|
prev_system_load = sum(b.load for b in sc.buses)
|
||||||
for b in instance.buses
|
for b in sc.buses
|
||||||
for t in 1:instance.time
|
for t in 1:sc.time
|
||||||
b.load[t] *= system_load[t] / prev_system_load[t]
|
b.load[t] *= system_load[t] / prev_system_load[t]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -200,16 +208,54 @@ function randomize!(
|
|||||||
method::XavQiuAhm2021.Randomization;
|
method::XavQiuAhm2021.Randomization;
|
||||||
rng = MersenneTwister(),
|
rng = MersenneTwister(),
|
||||||
)::Nothing
|
)::Nothing
|
||||||
if method.randomize_costs
|
for sc in instance.scenarios
|
||||||
XavQiuAhm2021._randomize_costs(rng, instance, method.cost)
|
randomize!(sc, method; rng)
|
||||||
end
|
|
||||||
if method.randomize_load_share
|
|
||||||
XavQiuAhm2021._randomize_load_share(rng, instance, method.load_share)
|
|
||||||
end
|
|
||||||
if method.randomize_load_profile
|
|
||||||
XavQiuAhm2021._randomize_load_profile(rng, instance, method)
|
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function randomize!(
|
||||||
|
sc::UnitCommitment.UnitCommitmentScenario,
|
||||||
|
method::XavQiuAhm2021.Randomization;
|
||||||
|
rng = MersenneTwister(),
|
||||||
|
)::Nothing
|
||||||
|
if method.randomize_costs
|
||||||
|
XavQiuAhm2021._randomize_costs(rng, sc, method.cost)
|
||||||
|
end
|
||||||
|
if method.randomize_load_share
|
||||||
|
XavQiuAhm2021._randomize_load_share(rng, sc, method.load_share)
|
||||||
|
end
|
||||||
|
if method.randomize_load_profile
|
||||||
|
XavQiuAhm2021._randomize_load_profile(rng, sc, method)
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
"""
|
||||||
|
function randomize!(
|
||||||
|
instance::UnitCommitmentInstance;
|
||||||
|
method = UnitCommitment.XavQiuAhm2021.Randomization();
|
||||||
|
rng = MersenneTwister(),
|
||||||
|
)::Nothing
|
||||||
|
|
||||||
|
Randomizes instance parameters according to the provided randomization method.
|
||||||
|
|
||||||
|
# Example
|
||||||
|
|
||||||
|
```julia
|
||||||
|
instance = UnitCommitment.read_benchmark("matpower/case118/2017-02-01")
|
||||||
|
UnitCommitment.randomize!(instance)
|
||||||
|
model = UnitCommitment.build_model(; instance)
|
||||||
|
```
|
||||||
|
|
||||||
|
"""
|
||||||
|
function randomize!(
|
||||||
|
instance::UnitCommitment.UnitCommitmentInstance;
|
||||||
|
method = XavQiuAhm2021.Randomization(),
|
||||||
|
rng = MersenneTwister(),
|
||||||
|
)::Nothing
|
||||||
|
randomize!(instance, method; rng)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
export randomize!
|
export randomize!
|
||||||
|
|||||||
@@ -12,10 +12,11 @@ conditions are also not modified.
|
|||||||
Example
|
Example
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
```julia
|
||||||
# Build a 2-hour UC instance
|
# Build a 2-hour UC instance
|
||||||
instance = UnitCommitment.read_benchmark("test/case14")
|
instance = UnitCommitment.read_benchmark("matpower/case118/2017-02-01")
|
||||||
modified = UnitCommitment.slice(instance, 1:2)
|
modified = UnitCommitment.slice(instance, 1:2)
|
||||||
|
```
|
||||||
"""
|
"""
|
||||||
function slice(
|
function slice(
|
||||||
instance::UnitCommitmentInstance,
|
instance::UnitCommitmentInstance,
|
||||||
@@ -23,30 +24,53 @@ function slice(
|
|||||||
)::UnitCommitmentInstance
|
)::UnitCommitmentInstance
|
||||||
modified = deepcopy(instance)
|
modified = deepcopy(instance)
|
||||||
modified.time = length(range)
|
modified.time = length(range)
|
||||||
modified.power_balance_penalty = modified.power_balance_penalty[range]
|
for sc in modified.scenarios
|
||||||
modified.reserves.spinning = modified.reserves.spinning[range]
|
sc.power_balance_penalty = sc.power_balance_penalty[range]
|
||||||
for u in modified.units
|
for r in sc.reserves
|
||||||
|
r.amount = r.amount[range]
|
||||||
|
end
|
||||||
|
for u in sc.thermal_units
|
||||||
u.max_power = u.max_power[range]
|
u.max_power = u.max_power[range]
|
||||||
u.min_power = u.min_power[range]
|
u.min_power = u.min_power[range]
|
||||||
u.must_run = u.must_run[range]
|
u.must_run = u.must_run[range]
|
||||||
u.min_power_cost = u.min_power_cost[range]
|
u.min_power_cost = u.min_power_cost[range]
|
||||||
u.provides_spinning_reserves = u.provides_spinning_reserves[range]
|
|
||||||
for s in u.cost_segments
|
for s in u.cost_segments
|
||||||
s.mw = s.mw[range]
|
s.mw = s.mw[range]
|
||||||
s.cost = s.cost[range]
|
s.cost = s.cost[range]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for b in modified.buses
|
for pu in sc.profiled_units
|
||||||
|
pu.max_power = pu.max_power[range]
|
||||||
|
pu.min_power = pu.min_power[range]
|
||||||
|
pu.cost = pu.cost[range]
|
||||||
|
end
|
||||||
|
for b in sc.buses
|
||||||
b.load = b.load[range]
|
b.load = b.load[range]
|
||||||
end
|
end
|
||||||
for l in modified.lines
|
for l in sc.lines
|
||||||
l.normal_flow_limit = l.normal_flow_limit[range]
|
l.normal_flow_limit = l.normal_flow_limit[range]
|
||||||
l.emergency_flow_limit = l.emergency_flow_limit[range]
|
l.emergency_flow_limit = l.emergency_flow_limit[range]
|
||||||
l.flow_limit_penalty = l.flow_limit_penalty[range]
|
l.flow_limit_penalty = l.flow_limit_penalty[range]
|
||||||
end
|
end
|
||||||
for ps in modified.price_sensitive_loads
|
for ps in sc.price_sensitive_loads
|
||||||
ps.demand = ps.demand[range]
|
ps.demand = ps.demand[range]
|
||||||
ps.revenue = ps.revenue[range]
|
ps.revenue = ps.revenue[range]
|
||||||
end
|
end
|
||||||
|
for su in sc.storage_units
|
||||||
|
su.min_level = su.min_level[range]
|
||||||
|
su.max_level = su.max_level[range]
|
||||||
|
su.simultaneous_charge_and_discharge =
|
||||||
|
su.simultaneous_charge_and_discharge[range]
|
||||||
|
su.charge_cost = su.charge_cost[range]
|
||||||
|
su.discharge_cost = su.discharge_cost[range]
|
||||||
|
su.charge_efficiency = su.charge_efficiency[range]
|
||||||
|
su.discharge_efficiency = su.discharge_efficiency[range]
|
||||||
|
su.loss_factor = su.loss_factor[range]
|
||||||
|
su.min_charge_rate = su.min_charge_rate[range]
|
||||||
|
su.max_charge_rate = su.max_charge_rate[range]
|
||||||
|
su.min_discharge_rate = su.min_discharge_rate[range]
|
||||||
|
su.max_discharge_rate = su.max_discharge_rate[range]
|
||||||
|
end
|
||||||
|
end
|
||||||
return modified
|
return modified
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,19 +3,19 @@
|
|||||||
# Released under the modified BSD license. See COPYING.md for more details.
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
repair!(instance)
|
repair!(sc)
|
||||||
|
|
||||||
Verifies that the given unit commitment instance is valid and automatically
|
Verifies that the given unit commitment scenario is valid and automatically
|
||||||
fixes some validation errors if possible, issuing a warning for each error
|
fixes some validation errors if possible, issuing a warning for each error
|
||||||
found. If a validation error cannot be automatically fixed, issues an
|
found. If a validation error cannot be automatically fixed, issues an
|
||||||
exception.
|
exception.
|
||||||
|
|
||||||
Returns the number of validation errors found.
|
Returns the number of validation errors found.
|
||||||
"""
|
"""
|
||||||
function repair!(instance::UnitCommitmentInstance)::Int
|
function repair!(sc::UnitCommitmentScenario)::Int
|
||||||
n_errors = 0
|
n_errors = 0
|
||||||
|
|
||||||
for g in instance.units
|
for g in sc.thermal_units
|
||||||
|
|
||||||
# Startup costs and delays must be increasing
|
# Startup costs and delays must be increasing
|
||||||
for s in 2:length(g.startup_categories)
|
for s in 2:length(g.startup_categories)
|
||||||
@@ -38,7 +38,7 @@ function repair!(instance::UnitCommitmentInstance)::Int
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for t in 1:instance.time
|
for t in 1:sc.time
|
||||||
# Production cost curve should be convex
|
# Production cost curve should be convex
|
||||||
for k in 2:length(g.cost_segments)
|
for k in 2:length(g.cost_segments)
|
||||||
cost = g.cost_segments[k].cost[t]
|
cost = g.cost_segments[k].cost[t]
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ function validate(
|
|||||||
instance::UnitCommitmentInstance,
|
instance::UnitCommitmentInstance,
|
||||||
solution::Union{Dict,OrderedDict},
|
solution::Union{Dict,OrderedDict},
|
||||||
)::Bool
|
)::Bool
|
||||||
|
"Thermal production (MW)" ∈ keys(solution) ?
|
||||||
|
solution = Dict("s1" => solution) : nothing
|
||||||
err_count = 0
|
err_count = 0
|
||||||
err_count += _validate_units(instance, solution)
|
err_count += _validate_units(instance, solution)
|
||||||
err_count += _validate_reserve_and_demand(instance, solution)
|
err_count += _validate_reserve_and_demand(instance, solution)
|
||||||
@@ -40,15 +42,25 @@ function validate(
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
function _validate_units(instance, solution; tol = 0.01)
|
function _validate_units(instance::UnitCommitmentInstance, solution; tol = 0.01)
|
||||||
err_count = 0
|
err_count = 0
|
||||||
|
for sc in instance.scenarios
|
||||||
for unit in instance.units
|
for unit in sc.thermal_units
|
||||||
production = solution["Production (MW)"][unit.name]
|
production = solution[sc.name]["Thermal production (MW)"][unit.name]
|
||||||
reserve = solution["Reserve (MW)"][unit.name]
|
reserve = [0.0 for _ in 1:instance.time]
|
||||||
actual_production_cost = solution["Production cost (\$)"][unit.name]
|
spinning_reserves =
|
||||||
actual_startup_cost = solution["Startup cost (\$)"][unit.name]
|
[r for r in unit.reserves if r.type == "spinning"]
|
||||||
is_on = bin(solution["Is on"][unit.name])
|
if !isempty(spinning_reserves)
|
||||||
|
reserve += sum(
|
||||||
|
solution[sc.name]["Spinning reserve (MW)"][r.name][unit.name]
|
||||||
|
for r in spinning_reserves
|
||||||
|
)
|
||||||
|
end
|
||||||
|
actual_production_cost =
|
||||||
|
solution[sc.name]["Thermal production cost (\$)"][unit.name]
|
||||||
|
actual_startup_cost =
|
||||||
|
solution[sc.name]["Startup cost (\$)"][unit.name]
|
||||||
|
is_on = bin(solution[sc.name]["Is on"][unit.name])
|
||||||
|
|
||||||
for t in 1:instance.time
|
for t in 1:instance.time
|
||||||
# Auxiliary variables
|
# Auxiliary variables
|
||||||
@@ -61,7 +73,8 @@ function _validate_units(instance, solution; tol = 0.01)
|
|||||||
else
|
else
|
||||||
is_starting_up = !is_on[t-1] && is_on[t]
|
is_starting_up = !is_on[t-1] && is_on[t]
|
||||||
is_shutting_down = is_on[t-1] && !is_on[t]
|
is_shutting_down = is_on[t-1] && !is_on[t]
|
||||||
ramp_up = max(0, production[t] + reserve[t] - production[t-1])
|
ramp_up =
|
||||||
|
max(0, production[t] + reserve[t] - production[t-1])
|
||||||
ramp_down = max(0, production[t-1] - production[t])
|
ramp_down = max(0, production[t-1] - production[t])
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -99,14 +112,22 @@ function _validate_units(instance, solution; tol = 0.01)
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Verify reserve eligibility
|
# Verify reserve eligibility
|
||||||
if !unit.provides_spinning_reserves[t] && reserve[t] > tol
|
for r in sc.reserves
|
||||||
|
if r.type == "spinning"
|
||||||
|
if unit ∉ r.thermal_units && (
|
||||||
|
unit in keys(
|
||||||
|
solution[sc.name]["Spinning reserve (MW)"][r.name],
|
||||||
|
)
|
||||||
|
)
|
||||||
@error @sprintf(
|
@error @sprintf(
|
||||||
"Unit %s is not eligible to provide spinning reserves at time %d",
|
"Unit %s is not eligible to provide reserve %s",
|
||||||
unit.name,
|
unit.name,
|
||||||
t
|
r.name,
|
||||||
)
|
)
|
||||||
err_count += 1
|
err_count += 1
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# If unit is on, must produce at least its minimum power
|
# If unit is on, must produce at least its minimum power
|
||||||
if is_on[t] && (production[t] < unit.min_power[t] - tol)
|
if is_on[t] && (production[t] < unit.min_power[t] - tol)
|
||||||
@@ -137,9 +158,11 @@ function _validate_units(instance, solution; tol = 0.01)
|
|||||||
# If unit is off, must produce zero
|
# If unit is off, must produce zero
|
||||||
if !is_on[t] && production[t] + reserve[t] > tol
|
if !is_on[t] && production[t] + reserve[t] > tol
|
||||||
@error @sprintf(
|
@error @sprintf(
|
||||||
"Unit %s produces power at time %d while off",
|
"Unit %s produces power at time %d while off (%.2f + %.2f > 0)",
|
||||||
unit.name,
|
unit.name,
|
||||||
t
|
t,
|
||||||
|
production[t],
|
||||||
|
reserve[t],
|
||||||
)
|
)
|
||||||
err_count += 1
|
err_count += 1
|
||||||
end
|
end
|
||||||
@@ -282,106 +305,352 @@ function _validate_units(instance, solution; tol = 0.01)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
for pu in sc.profiled_units
|
||||||
|
production = solution[sc.name]["Profiled production (MW)"][pu.name]
|
||||||
|
|
||||||
|
for t in 1:instance.time
|
||||||
|
# Unit must produce at least its minimum power
|
||||||
|
if production[t] < pu.min_power[t] - tol
|
||||||
|
@error @sprintf(
|
||||||
|
"Profiled unit %s produces below its minimum limit at time %d (%.2f < %.2f)",
|
||||||
|
pu.name,
|
||||||
|
t,
|
||||||
|
production[t],
|
||||||
|
pu.min_power[t]
|
||||||
|
)
|
||||||
|
err_count += 1
|
||||||
|
end
|
||||||
|
|
||||||
|
# Unit must produce at most its maximum power
|
||||||
|
if production[t] > pu.max_power[t] + tol
|
||||||
|
@error @sprintf(
|
||||||
|
"Profiled unit %s produces above its maximum limit at time %d (%.2f > %.2f)",
|
||||||
|
pu.name,
|
||||||
|
t,
|
||||||
|
production[t],
|
||||||
|
pu.max_power[t]
|
||||||
|
)
|
||||||
|
err_count += 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for su in sc.storage_units
|
||||||
|
storage_level = solution[sc.name]["Storage level (MWh)"][su.name]
|
||||||
|
charge_rate =
|
||||||
|
solution[sc.name]["Storage charging rates (MW)"][su.name]
|
||||||
|
discharge_rate =
|
||||||
|
solution[sc.name]["Storage discharging rates (MW)"][su.name]
|
||||||
|
actual_charge_cost =
|
||||||
|
solution[sc.name]["Storage charging cost (\$)"][su.name]
|
||||||
|
actual_discharge_cost =
|
||||||
|
solution[sc.name]["Storage discharging cost (\$)"][su.name]
|
||||||
|
is_charging = bin(solution[sc.name]["Is charging"][su.name])
|
||||||
|
is_discharging = bin(solution[sc.name]["Is discharging"][su.name])
|
||||||
|
# time in hours
|
||||||
|
time_step = sc.time_step / 60
|
||||||
|
|
||||||
|
for t in 1:instance.time
|
||||||
|
# Unit must store at least its minimum level
|
||||||
|
if storage_level[t] < su.min_level[t] - tol
|
||||||
|
@error @sprintf(
|
||||||
|
"Storage unit %s stores below its minimum level at time %d (%.2f < %.2f)",
|
||||||
|
su.name,
|
||||||
|
t,
|
||||||
|
storage_level[t],
|
||||||
|
su.min_level[t]
|
||||||
|
)
|
||||||
|
err_count += 1
|
||||||
|
end
|
||||||
|
# Unit must store at most its maximum level
|
||||||
|
if storage_level[t] > su.max_level[t] + tol
|
||||||
|
@error @sprintf(
|
||||||
|
"Storage unit %s stores above its maximum level at time %d (%.2f > %.2f)",
|
||||||
|
su.name,
|
||||||
|
t,
|
||||||
|
storage_level[t],
|
||||||
|
su.max_level[t]
|
||||||
|
)
|
||||||
|
err_count += 1
|
||||||
|
end
|
||||||
|
|
||||||
|
if t == instance.time
|
||||||
|
# Unit must store at least its minimum level at last time period
|
||||||
|
if storage_level[t] < su.min_ending_level - tol
|
||||||
|
@error @sprintf(
|
||||||
|
"Storage unit %s stores below its minimum ending level (%.2f < %.2f)",
|
||||||
|
su.name,
|
||||||
|
storage_level[t],
|
||||||
|
su.min_ending_level
|
||||||
|
)
|
||||||
|
err_count += 1
|
||||||
|
end
|
||||||
|
# Unit must store at most its maximum level at last time period
|
||||||
|
if storage_level[t] > su.max_ending_level + tol
|
||||||
|
@error @sprintf(
|
||||||
|
"Storage unit %s stores above its maximum ending level (%.2f > %.2f)",
|
||||||
|
su.name,
|
||||||
|
storage_level[t],
|
||||||
|
su.max_ending_level
|
||||||
|
)
|
||||||
|
err_count += 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Unit must follow the energy transition constraint
|
||||||
|
prev_level = t == 1 ? su.initial_level : storage_level[t-1]
|
||||||
|
current_level =
|
||||||
|
(1 - su.loss_factor[t]) * prev_level +
|
||||||
|
time_step * (
|
||||||
|
charge_rate[t] * su.charge_efficiency[t] -
|
||||||
|
discharge_rate[t] / su.discharge_efficiency[t]
|
||||||
|
)
|
||||||
|
if abs(storage_level[t] - current_level) > tol
|
||||||
|
@error @sprintf(
|
||||||
|
"Storage unit %s has unexpected level at time %d (%.2f should be %.2f)",
|
||||||
|
unit.name,
|
||||||
|
t,
|
||||||
|
storage_level[t],
|
||||||
|
current_level
|
||||||
|
)
|
||||||
|
err_count += 1
|
||||||
|
end
|
||||||
|
|
||||||
|
# Unit cannot simultaneous charge and discharge if it is not allowed
|
||||||
|
if !su.simultaneous_charge_and_discharge[t] &&
|
||||||
|
is_charging[t] &&
|
||||||
|
is_discharging[t]
|
||||||
|
@error @sprintf(
|
||||||
|
"Storage unit %s is charging and discharging simultaneous at time %d",
|
||||||
|
su.name,
|
||||||
|
t
|
||||||
|
)
|
||||||
|
err_count += 1
|
||||||
|
end
|
||||||
|
|
||||||
|
# Unit must charge at least its minimum rate
|
||||||
|
if is_charging[t] &&
|
||||||
|
(charge_rate[t] < su.min_charge_rate[t] - tol)
|
||||||
|
@error @sprintf(
|
||||||
|
"Storage unit %s charges below its minimum limit at time %d (%.2f < %.2f)",
|
||||||
|
unit.name,
|
||||||
|
t,
|
||||||
|
charge_rate[t],
|
||||||
|
su.min_charge_rate[t]
|
||||||
|
)
|
||||||
|
err_count += 1
|
||||||
|
end
|
||||||
|
# Unit must charge at most its maximum rate
|
||||||
|
if is_charging[t] &&
|
||||||
|
(charge_rate[t] > su.max_charge_rate[t] + tol)
|
||||||
|
@error @sprintf(
|
||||||
|
"Storage unit %s charges above its maximum limit at time %d (%.2f > %.2f)",
|
||||||
|
unit.name,
|
||||||
|
t,
|
||||||
|
charge_rate[t],
|
||||||
|
su.max_charge_rate[t]
|
||||||
|
)
|
||||||
|
err_count += 1
|
||||||
|
end
|
||||||
|
# Unit must have zero charge when it is not charging
|
||||||
|
if !is_charging[t] && (charge_rate[t] > tol)
|
||||||
|
@error @sprintf(
|
||||||
|
"Storage unit %s charges power at time %d while not charging (%.2f > 0)",
|
||||||
|
unit.name,
|
||||||
|
t,
|
||||||
|
charge_rate[t]
|
||||||
|
)
|
||||||
|
err_count += 1
|
||||||
|
end
|
||||||
|
|
||||||
|
# Unit must discharge at least its minimum rate
|
||||||
|
if is_discharging[t] &&
|
||||||
|
(discharge_rate[t] < su.min_discharge_rate[t] - tol)
|
||||||
|
@error @sprintf(
|
||||||
|
"Storage unit %s discharges below its minimum limit at time %d (%.2f < %.2f)",
|
||||||
|
unit.name,
|
||||||
|
t,
|
||||||
|
discharge_rate[t],
|
||||||
|
su.min_discharge_rate[t]
|
||||||
|
)
|
||||||
|
err_count += 1
|
||||||
|
end
|
||||||
|
# Unit must discharge at most its maximum rate
|
||||||
|
if is_discharging[t] &&
|
||||||
|
(discharge_rate[t] > su.max_discharge_rate[t] + tol)
|
||||||
|
@error @sprintf(
|
||||||
|
"Storage unit %s discharges above its maximum limit at time %d (%.2f > %.2f)",
|
||||||
|
unit.name,
|
||||||
|
t,
|
||||||
|
discharge_rate[t],
|
||||||
|
su.max_discharge_rate[t]
|
||||||
|
)
|
||||||
|
err_count += 1
|
||||||
|
end
|
||||||
|
# Unit must have zero discharge when it is not charging
|
||||||
|
if !is_discharging[t] && (discharge_rate[t] > tol)
|
||||||
|
@error @sprintf(
|
||||||
|
"Storage unit %s discharges power at time %d while not discharging (%.2f > 0)",
|
||||||
|
unit.name,
|
||||||
|
t,
|
||||||
|
discharge_rate[t]
|
||||||
|
)
|
||||||
|
err_count += 1
|
||||||
|
end
|
||||||
|
|
||||||
|
# Compute storage costs
|
||||||
|
charge_cost = su.charge_cost[t] * charge_rate[t]
|
||||||
|
discharge_cost = su.discharge_cost[t] * discharge_rate[t]
|
||||||
|
# Compare costs
|
||||||
|
if abs(actual_charge_cost[t] - charge_cost) > tol
|
||||||
|
@error @sprintf(
|
||||||
|
"Storage unit %s has unexpected charge cost at time %d (%.2f should be %.2f)",
|
||||||
|
unit.name,
|
||||||
|
t,
|
||||||
|
actual_charge_cost[t],
|
||||||
|
charge_cost
|
||||||
|
)
|
||||||
|
err_count += 1
|
||||||
|
end
|
||||||
|
if abs(actual_discharge_cost[t] - discharge_cost) > tol
|
||||||
|
@error @sprintf(
|
||||||
|
"Storage unit %s has unexpected discharge cost at time %d (%.2f should be %.2f)",
|
||||||
|
unit.name,
|
||||||
|
t,
|
||||||
|
actual_discharge_cost[t],
|
||||||
|
discharge_cost
|
||||||
|
)
|
||||||
|
err_count += 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
return err_count
|
return err_count
|
||||||
end
|
end
|
||||||
|
|
||||||
function _validate_reserve_and_demand(instance, solution, tol = 0.01)
|
function _validate_reserve_and_demand(instance, solution, tol = 0.01)
|
||||||
err_count = 0
|
err_count = 0
|
||||||
|
for sc in instance.scenarios
|
||||||
for t in 1:instance.time
|
for t in 1:instance.time
|
||||||
load_curtail = 0
|
load_curtail = 0
|
||||||
fixed_load = sum(b.load[t] for b in instance.buses)
|
fixed_load = sum(b.load[t] for b in sc.buses)
|
||||||
ps_load = 0
|
ps_load = 0
|
||||||
if length(instance.price_sensitive_loads) > 0
|
production = 0
|
||||||
|
storage_charge = 0
|
||||||
|
storage_discharge = 0
|
||||||
|
if length(sc.price_sensitive_loads) > 0
|
||||||
ps_load = sum(
|
ps_load = sum(
|
||||||
solution["Price-sensitive loads (MW)"][ps.name][t] for
|
solution[sc.name]["Price-sensitive loads (MW)"][ps.name][t]
|
||||||
ps in instance.price_sensitive_loads
|
for ps in sc.price_sensitive_loads
|
||||||
|
)
|
||||||
|
end
|
||||||
|
if length(sc.thermal_units) > 0
|
||||||
|
production = sum(
|
||||||
|
solution[sc.name]["Thermal production (MW)"][g.name][t]
|
||||||
|
for g in sc.thermal_units
|
||||||
|
)
|
||||||
|
end
|
||||||
|
if length(sc.profiled_units) > 0
|
||||||
|
production += sum(
|
||||||
|
solution[sc.name]["Profiled production (MW)"][pu.name][t]
|
||||||
|
for pu in sc.profiled_units
|
||||||
|
)
|
||||||
|
end
|
||||||
|
if length(sc.storage_units) > 0
|
||||||
|
storage_charge += sum(
|
||||||
|
solution[sc.name]["Storage charging rates (MW)"][su.name][t]
|
||||||
|
for su in sc.storage_units
|
||||||
|
)
|
||||||
|
storage_discharge += sum(
|
||||||
|
solution[sc.name]["Storage discharging rates (MW)"][su.name][t]
|
||||||
|
for su in sc.storage_units
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
production =
|
|
||||||
sum(solution["Production (MW)"][g.name][t] for g in instance.units)
|
|
||||||
if "Load curtail (MW)" in keys(solution)
|
if "Load curtail (MW)" in keys(solution)
|
||||||
load_curtail = sum(
|
load_curtail = sum(
|
||||||
solution["Load curtail (MW)"][b.name][t] for
|
solution[sc.name]["Load curtail (MW)"][b.name][t] for
|
||||||
b in instance.buses
|
b in sc.buses
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
balance = fixed_load - load_curtail - production + ps_load
|
balance =
|
||||||
|
fixed_load - load_curtail - production +
|
||||||
|
ps_load +
|
||||||
|
storage_charge - storage_discharge
|
||||||
|
|
||||||
# Verify that production equals demand
|
# Verify that production equals demand
|
||||||
if abs(balance) > tol
|
if abs(balance) > tol
|
||||||
@error @sprintf(
|
@error @sprintf(
|
||||||
"Non-zero power balance at time %d (%.2f + %.2f - %.2f - %.2f != 0)",
|
"Non-zero power balance at time %d (%.2f + %.2f - %.2f - %.2f + %.2f - %.2f != 0)",
|
||||||
t,
|
t,
|
||||||
fixed_load,
|
fixed_load,
|
||||||
ps_load,
|
ps_load,
|
||||||
load_curtail,
|
load_curtail,
|
||||||
production,
|
production,
|
||||||
|
storage_charge,
|
||||||
|
storage_discharge,
|
||||||
)
|
)
|
||||||
err_count += 1
|
err_count += 1
|
||||||
end
|
end
|
||||||
|
|
||||||
# Verify flexiramp solutions only if either of the up-flexiramp and
|
# Verify reserves
|
||||||
# down-flexiramp requirements is not a default array of zeros
|
for r in sc.reserves
|
||||||
if instance.reserves.upflexiramp != zeros(instance.time) ||
|
if r.type == "spinning"
|
||||||
instance.reserves.dwflexiramp != zeros(instance.time)
|
provided = sum(
|
||||||
|
solution[sc.name]["Spinning reserve (MW)"][r.name][g.name][t]
|
||||||
|
for g in r.thermal_units
|
||||||
|
)
|
||||||
|
shortfall =
|
||||||
|
solution[sc.name]["Spinning reserve shortfall (MW)"][r.name][t]
|
||||||
|
required = r.amount[t]
|
||||||
|
|
||||||
|
if provided + shortfall < required - tol
|
||||||
|
@error @sprintf(
|
||||||
|
"Insufficient reserve %s at time %d (%.2f + %.2f < %.2f)",
|
||||||
|
r.name,
|
||||||
|
t,
|
||||||
|
provided,
|
||||||
|
shortfall,
|
||||||
|
required,
|
||||||
|
)
|
||||||
|
end
|
||||||
|
elseif r.type == "flexiramp"
|
||||||
upflexiramp = sum(
|
upflexiramp = sum(
|
||||||
solution["Up-flexiramp (MW)"][g.name][t] for
|
solution[sc.name]["Up-flexiramp (MW)"][r.name][g.name][t]
|
||||||
g in instance.units
|
for g in r.thermal_units
|
||||||
)
|
)
|
||||||
upflexiramp_shortfall =
|
upflexiramp_shortfall =
|
||||||
(instance.flexiramp_shortfall_penalty[t] >= 0) ?
|
solution[sc.name]["Up-flexiramp shortfall (MW)"][r.name][t]
|
||||||
solution["Up-flexiramp shortfall (MW)"][t] : 0
|
|
||||||
|
|
||||||
if upflexiramp + upflexiramp_shortfall <
|
if upflexiramp + upflexiramp_shortfall < r.amount[t] - tol
|
||||||
instance.reserves.upflexiramp[t] - tol
|
|
||||||
@error @sprintf(
|
@error @sprintf(
|
||||||
"Insufficient up-flexiramp at time %d (%.2f + %.2f should be %.2f)",
|
"Insufficient up-flexiramp at time %d (%.2f + %.2f < %.2f)",
|
||||||
t,
|
t,
|
||||||
upflexiramp,
|
upflexiramp,
|
||||||
upflexiramp_shortfall,
|
upflexiramp_shortfall,
|
||||||
instance.reserves.upflexiramp[t],
|
r.amount[t],
|
||||||
)
|
)
|
||||||
err_count += 1
|
err_count += 1
|
||||||
end
|
end
|
||||||
|
|
||||||
dwflexiramp = sum(
|
dwflexiramp = sum(
|
||||||
solution["Down-flexiramp (MW)"][g.name][t] for
|
solution[sc.name]["Down-flexiramp (MW)"][r.name][g.name][t]
|
||||||
g in instance.units
|
for g in r.thermal_units
|
||||||
)
|
)
|
||||||
dwflexiramp_shortfall =
|
dwflexiramp_shortfall =
|
||||||
(instance.flexiramp_shortfall_penalty[t] >= 0) ?
|
solution[sc.name]["Down-flexiramp shortfall (MW)"][r.name][t]
|
||||||
solution["Down-flexiramp shortfall (MW)"][t] : 0
|
|
||||||
|
|
||||||
if dwflexiramp + dwflexiramp_shortfall <
|
if dwflexiramp + dwflexiramp_shortfall < r.amount[t] - tol
|
||||||
instance.reserves.dwflexiramp[t] - tol
|
|
||||||
@error @sprintf(
|
@error @sprintf(
|
||||||
"Insufficient down-flexiramp at time %d (%.2f + %.2f should be %.2f)",
|
"Insufficient down-flexiramp at time %d (%.2f + %.2f < %.2f)",
|
||||||
t,
|
t,
|
||||||
dwflexiramp,
|
dwflexiramp,
|
||||||
dwflexiramp_shortfall,
|
dwflexiramp_shortfall,
|
||||||
instance.reserves.dwflexiramp[t],
|
r.amount[t],
|
||||||
)
|
)
|
||||||
err_count += 1
|
err_count += 1
|
||||||
end
|
end
|
||||||
# Verify spinning reserve solutions only if both up-flexiramp and
|
|
||||||
# down-flexiramp requirements are arrays of zeros.
|
|
||||||
else
|
else
|
||||||
reserve =
|
error("Unknown reserve type: $(r.type)")
|
||||||
sum(solution["Reserve (MW)"][g.name][t] for g in instance.units)
|
end
|
||||||
reserve_shortfall =
|
|
||||||
(instance.shortfall_penalty[t] >= 0) ?
|
|
||||||
solution["Reserve shortfall (MW)"][t] : 0
|
|
||||||
|
|
||||||
if reserve + reserve_shortfall < instance.reserves.spinning[t] - tol
|
|
||||||
@error @sprintf(
|
|
||||||
"Insufficient spinning reserves at time %d (%.2f + %.2f should be %.2f)",
|
|
||||||
t,
|
|
||||||
reserve,
|
|
||||||
reserve_shortfall,
|
|
||||||
instance.reserves.spinning[t],
|
|
||||||
)
|
|
||||||
err_count += 1
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,25 +1,22 @@
|
|||||||
|
name = "UnitCommitmentT"
|
||||||
|
uuid = "a3b7a17a-ab64-45e4-a924-cd5ae7dc644e"
|
||||||
|
authors = ["Alinson S. Xavier <git@axavier.org>"]
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
Cbc = "9961bab8-2fa3-5c5a-9d89-47fab24efd76"
|
Cbc = "9961bab8-2fa3-5c5a-9d89-47fab24efd76"
|
||||||
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
|
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
|
||||||
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
|
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
|
||||||
GZip = "92fee26a-97fe-5a0c-ad85-20a5f3185b63"
|
GZip = "92fee26a-97fe-5a0c-ad85-20a5f3185b63"
|
||||||
|
HiGHS = "87dc4568-4c63-4d18-b0c0-bb2238e4078b"
|
||||||
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
|
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
|
||||||
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
|
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
|
||||||
|
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
|
||||||
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
|
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
|
||||||
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
|
MIPLearn = "2b1277c3-b477-4c49-a15e-7ba350325c68"
|
||||||
|
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
|
||||||
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
|
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
|
||||||
PackageCompiler = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d"
|
|
||||||
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
|
|
||||||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
|
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
|
||||||
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
|
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
|
||||||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
|
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
|
||||||
|
UnitCommitment = "64606440-39ea-11e9-0f29-3303a1d3d877"
|
||||||
[compat]
|
|
||||||
DataStructures = "0.18"
|
|
||||||
Distributions = "0.25"
|
|
||||||
GZip = "0.5"
|
|
||||||
JSON = "0.21"
|
|
||||||
JuMP = "1"
|
|
||||||
MathOptInterface = "1"
|
|
||||||
PackageCompiler = "1"
|
|
||||||
julia = "1"
|
|
||||||
|
|||||||
BIN
test/fixtures/aelmp_simple.json.gz
vendored
Normal file
BIN
test/fixtures/aelmp_simple.json.gz
vendored
Normal file
Binary file not shown.
BIN
test/fixtures/case118-initcond.json.gz
vendored
BIN
test/fixtures/case118-initcond.json.gz
vendored
Binary file not shown.
BIN
test/fixtures/case14-fixed-status.json.gz
vendored
Normal file
BIN
test/fixtures/case14-fixed-status.json.gz
vendored
Normal file
Binary file not shown.
BIN
test/fixtures/case14-flex.json.gz
vendored
Normal file
BIN
test/fixtures/case14-flex.json.gz
vendored
Normal file
Binary file not shown.
BIN
test/fixtures/case14-profiled.json.gz
vendored
Normal file
BIN
test/fixtures/case14-profiled.json.gz
vendored
Normal file
Binary file not shown.
BIN
test/fixtures/case14-storage.json.gz
vendored
Normal file
BIN
test/fixtures/case14-storage.json.gz
vendored
Normal file
Binary file not shown.
BIN
test/fixtures/case14-sub-hourly.json.gz
vendored
Normal file
BIN
test/fixtures/case14-sub-hourly.json.gz
vendored
Normal file
Binary file not shown.
BIN
test/fixtures/case14.json.gz
vendored
Normal file
BIN
test/fixtures/case14.json.gz
vendored
Normal file
Binary file not shown.
BIN
test/fixtures/case14.json.gz.h5
vendored
Normal file
BIN
test/fixtures/case14.json.gz.h5
vendored
Normal file
Binary file not shown.
BIN
test/fixtures/lmp_simple_test_1.json.gz
vendored
Normal file
BIN
test/fixtures/lmp_simple_test_1.json.gz
vendored
Normal file
Binary file not shown.
BIN
test/fixtures/lmp_simple_test_2.json.gz
vendored
Normal file
BIN
test/fixtures/lmp_simple_test_2.json.gz
vendored
Normal file
Binary file not shown.
BIN
test/fixtures/lmp_simple_test_3.json.gz
vendored
Normal file
BIN
test/fixtures/lmp_simple_test_3.json.gz
vendored
Normal file
Binary file not shown.
BIN
test/fixtures/lmp_simple_test_4.json.gz
vendored
Normal file
BIN
test/fixtures/lmp_simple_test_4.json.gz
vendored
Normal file
Binary file not shown.
BIN
test/fixtures/market_da_scenario.json.gz
vendored
Normal file
BIN
test/fixtures/market_da_scenario.json.gz
vendored
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user