Compare commits

...

18 Commits

Author SHA1 Message Date
6573bb7ea2 Update README.md 2022-07-18 09:54:15 -06:00
1769f2a932 Project.toml: Remove Revise.jl 2022-07-18 09:42:00 -06:00
4dc39363e8 Update references, copyright notices, links 2022-07-18 09:40:52 -06:00
5fef01cd99 Improve docs 2022-07-17 15:50:42 -06:00
18daaf5358 Switch to Documenter.jl 2022-07-17 14:44:58 -06:00
b68b4ff9e4 Update CHANGELOG and docs 2022-07-13 10:14:42 -05:00
6e30645084 Allow v0.3 to read v0.2 instance files 2022-07-12 11:57:55 -05:00
678e6aa2f5 Update docs 2022-07-11 12:16:06 -05:00
fd25580967 Reformat source code 2022-07-11 10:58:42 -05:00
dc693896a3 Merge branch 'dev' into feature/reserves 2022-06-20 17:17:27 -05:00
ddebcc6ddb Merge branch 'dev' into feature/reserves 2022-06-20 14:31:02 -05:00
3282e5bc3a Fix all tests 2022-06-20 14:21:02 -05:00
15de1901c8 Remove temporary files 2022-06-14 14:55:59 -05:00
bf2dc4ddc4 Remove instances from repository; download on the fly 2022-06-14 14:38:44 -05:00
5ca566f147 Remove old reserves 2022-01-20 16:23:22 -06:00
3220650e39 Implement new reserves 2022-01-20 10:18:19 -06:00
ca0d250dfa Parse new reserves 2022-01-19 10:03:22 -06:00
2bd68b49a5 Reserves: Update docs 2022-01-19 09:23:21 -06:00
62 changed files with 973 additions and 799 deletions

View File

@@ -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

View File

@@ -1,4 +1,4 @@
Copyright © 2020, UChicago Argonne, LLC Copyright © 2020-2022, UChicago Argonne, LLC
All Rights Reserved All Rights Reserved

View File

@@ -2,14 +2,14 @@
# 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: clean:
rm -rfv build Manifest.toml test/Manifest.toml deps/formatter/build deps/formatter/Manifest.toml 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: format:
cd deps/formatter; ../../juliaw format.jl cd deps/formatter; ../../juliaw format.jl

View File

@@ -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"

View File

@@ -87,10 +87,11 @@ 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)
@@ -110,15 +111,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:

View File

@@ -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)

4
docs/Project.toml Normal file
View File

@@ -0,0 +1,4 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
UnitCommitment = "64606440-39ea-11e9-0f29-3303a1d3d877"

View File

@@ -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;
}

View File

@@ -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>"

16
docs/make.jl Normal file
View File

@@ -0,0 +1,16 @@
using Documenter, UnitCommitment
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"],
)
)

48
docs/src/api.md Normal file
View File

@@ -0,0 +1,48 @@
# API Reference
## Read data, build model & optimize
```@docs
UnitCommitment.read
UnitCommitment.read_benchmark
UnitCommitment.build_model
UnitCommitment.optimize!
UnitCommitment.solution
UnitCommitment.validate
UnitCommitment.write
```
## 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
```

View File

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

View 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);
}

View File

@@ -1,52 +1,40 @@
```{sectnum}
---
start: 2
depth: 2
suffix: .
---
```
Data Format Data Format
=========== ===========
Input Data Format Input Data Format
----------------- -----------------
Instances are specified by JSON files containing the following main sections: Instances are specified by JSON files containing the following main sections:
* Parameters * [Parameters](#Parameters)
* Buses * [Buses](#Buses)
* Generators * [Generators](#Generators)
* Price-sensitive loads * [Price-sensitive loads](#Price-sensitive-loads)
* Transmission lines * [Transmission lines](#Transmission-lines)
* Reserves * [Reserves](#Reserves)
* Contingencies * [Contingencies](#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). 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 ### 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. 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? | Key | Description | Default | Time series?
| :----------------------------- | :------------------------------------------------ | :------: | :------------: | :----------------------------- | :------------------------------------------------ | :------: | :------------:
| `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.3`. | Required | N
| `Time horizon (h)` | Length of the planning horizon (in hours). | Required | N | `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 | `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 | `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 #### Example
```json ```json
{ {
"Parameters": { "Parameters": {
"Version": "0.3",
"Time horizon (h)": 4, "Time horizon (h)": 4,
"Power balance penalty ($/MW)": 1000.0, "Power balance penalty ($/MW)": 1000.0
"Reserve shortfall penalty ($/MW)": -1.0,
"Flexiramp penalty ($/MW)": 100.0
} }
} }
``` ```
@@ -98,20 +86,20 @@ This section describes all generators in the system, including thermal units, re
| `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 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 | `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 | `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 | `Reserve eligibility` | List of reserve products this generator is eligibe to provide. By default, the generator is not eligible to provide any reserves. | `[]` | N
| `Provides flexible capacity?` | If `true`, this generator may provide flexible ramping product (Boolean). | `true` | Y
#### Production costs and limits #### 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]`. 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. 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> <center>
<img src="../_static/cost_curve.png" style="max-width: 500px"/> <img src="../assets/cost_curve.png" style="max-width: 500px"/>
<div><b>Figure 1.</b> Piecewise-linear production cost curve.</div> <div><b>Figure 1.</b> Piecewise-linear production cost curve.</div>
<br/> <br/>
</center> </center>
```
#### Additional remarks: #### Additional remarks:
@@ -139,14 +127,13 @@ Note that this curve also specifies the production limits. Specifically, the fir
"Minimum uptime (h)": 4, "Minimum uptime (h)": 4,
"Initial status (h)": 12, "Initial status (h)": 12,
"Must run?": false, "Must run?": false,
"Provides spinning reserves?": true, "Reserve eligibility": ["r1"],
"Provides flexible capacity?": false,
}, },
"gen2": { "gen2": {
"Bus": "b5", "Bus": "b5",
"Production cost curve (MW)": [0.0, [10.0, 8.0, 0.0, 3.0]], "Production cost curve (MW)": [0.0, [10.0, 8.0, 0.0, 3.0]],
"Production cost curve ($)": [0.0, 0.0], "Production cost curve ($)": [0.0, 0.0],
"Provides spinning reserves?": true, "Reserve eligibility": ["r1", "r2"],
} }
} }
} }
@@ -176,7 +163,7 @@ This section describes components in the system which may increase or reduce the
} }
``` ```
### Transmission Lines ### Transmission lines
This section describes the characteristics of transmission system, such as its topology and the susceptance of each transmission line. This section describes the characteristics of transmission system, such as its topology and the susceptance of each transmission line.
@@ -216,42 +203,34 @@ This section describes the hourly amount of reserves required.
| Key | Description | Default | Time series? | 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 | `Type` | Type of reserve product. Must be either "spinning" or "flexiramp". | Required | N
| `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 | `Amount (MW)` | Amount of reserves required. | Required | 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 | `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` | Y
#### Example 1 #### Example 1
```json ```json
{ {
"Reserves": { "Reserves": {
"Spinning (MW)": [ "r1": {
57.30552, "Type": "spinning",
53.88429, "Amount (MW)": [
51.31838, 57.30552,
50.46307 53.88429,
] 51.31838,
} 50.46307
} ],
``` "Shortfall penalty ($/MW)": 5.0
},
#### Example 2 "r2": {
"Type": "flexiramp",
```json "Amount (MW)": [
{ 20.31042,
"Reserves": { 23.65273,
"Up-flexiramp (MW)": [ 27.41784,
20.31042, 25.34057
23.65273, ],
27.41784, }
25.34057
],
"Down-flexiramp (MW)": [
19.41546,
21.45377,
23.53402,
24.80973
]
} }
} }
``` ```
@@ -314,10 +293,8 @@ The output data format is also JSON-based, but it is not currently documented si
Current limitations 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 * Network topology remains the same for all time periods
* Only N-1 transmission contingencies are supported. Generator contingencies are not currently supported. * 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. * 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.

View File

@@ -6,24 +6,23 @@
* **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 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.
* **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 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)), multiple 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)) and contingency screening methods ([XavQiuWanThi2019](https://doi.org/10.1109/TPWRS.2019.2892620)). 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)
* **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 +30,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, 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](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-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:
@@ -67,16 +66,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
```

View File

@@ -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)

View File

@@ -1,11 +1,3 @@
```{sectnum}
---
start: 4
depth: 2
suffix: .
---
```
JuMP Model JuMP Model
========== ==========
@@ -17,20 +9,20 @@ Decision variables
### Generators ### Generators
Name | Symbol | Description | Unit Name | Symbol | Description | Unit
-----|:--------:|-------------|:------: :-----|:--------:|:-------------|:------:
`is_on[g,t]` | $u_{g}(t)$ | True if generator `g` is on at time `t`. | Binary `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_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 `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 `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 `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 `reserve[r,g,t]` | $r_g(t)$ | Amount of reserve `r` provided by unit `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 `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 ### Buses
Name | Symbol | Description | Unit Name | Symbol | Description | Unit
-----|:------:|-------------|:------: :-----|:------:|:-------------|:------:
`net_injection[b,t]` | $n_b(t)$ | Net injection at bus `b` at time `t`. | MW `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 `curtail[b,t]` | $s^+_b(t)$ | Amount of load curtailed at bus `b` at time `t` | MW
@@ -38,69 +30,24 @@ Name | Symbol | Description | Unit
### Price-sensitive loads ### Price-sensitive loads
Name | Symbol | Description | Unit Name | Symbol | Description | Unit
-----|:------:|-------------|:------: :-----|:------:|:-------------|:------:
`loads[s,t]` | $d_{s}(t)$ | Amount of power served to price-sensitive load `s` at time `t`. | MW `loads[s,t]` | $d_{s}(t)$ | Amount of power served to price-sensitive load `s` at time `t`. | MW
### Transmission lines ### Transmission lines
Name | Symbol | Description | Unit Name | Symbol | Description | Unit
-----|:------:|-------------|:------: :-----|:------:|:-------------|:------:
`flow[l,t]` | $f_l(t)$ | Power flow on line `l` at time `t`. | MW `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 `overflow[l,t]` | $f^+_l(t)$ | Amount of flow above the limit for line `l` at time `t`. | MW
```{warning} !!! 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. 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 Objective function
------------------ ------------------
$$ TODO
\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 Constraints
----------- -----------

View File

@@ -1,21 +1,13 @@
```{sectnum}
---
start: 1
depth: 2
suffix: .
---
```
Usage Usage
===== =====
Installation 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: UnitCommitment.jl was tested and developed with [Julia 1.7](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 ```text
pkg> add UnitCommitment@0.2 pkg> add UnitCommitment@0.3
``` ```
To test that the package has been correctly installed, run: To test that the package has been correctly installed, run:
@@ -126,9 +118,9 @@ model = UnitCommitment.build_model(
UnitCommitment.optimize!(model) UnitCommitment.optimize!(model)
``` ```
```{warning} !!! 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.
``` 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 ### Verifying solutions

Binary file not shown.

View File

@@ -20,6 +20,7 @@ include("model/formulations/WanHob2016/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")

38
src/instance/migrate.jl Normal file
View File

@@ -0,0 +1,38 @@
# 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)
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

View File

@@ -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
instance = UnitCommitment.read_benchmark("matpower/case3375wp/2017-02-01")
import UnitCommitment ```
instance = UnitCommitment.read_benchmark("matpower/case3375wp/2017-02-01")
""" """
function read_benchmark( function read_benchmark(
name::AbstractString; name::AbstractString;
@@ -48,13 +46,13 @@ end
""" """
read(path::AbstractString)::UnitCommitmentInstance read(path::AbstractString)::UnitCommitmentInstance
Read a unit commitment instance from a file. The file may be gzipped. Read instance from a file. The file may be gzipped.
Example # Example
-------
import UnitCommitment ```julia
instance = UnitCommitment.read("/path/to/input.json.gz") instance = UnitCommitment.read("/path/to/input.json.gz")
```
""" """
function read(path::AbstractString)::UnitCommitmentInstance function read(path::AbstractString)::UnitCommitmentInstance
if endswith(path, ".gz") if endswith(path, ".gz")
@@ -80,11 +78,13 @@ function _read_json(path::String)::OrderedDict
end end
function _from_json(json; repair = true) function _from_json(json; repair = true)
_migrate(json)
units = Unit[] units = Unit[]
buses = Bus[] buses = Bus[]
contingencies = Contingency[] contingencies = Contingency[]
lines = TransmissionLine[] lines = TransmissionLine[]
loads = PriceSensitiveLoad[] loads = PriceSensitiveLoad[]
reserves = Reserve[]
function scalar(x; default = nothing) function scalar(x; default = nothing)
x !== nothing || return default x !== nothing || return default
@@ -105,6 +105,7 @@ function _from_json(json; repair = true)
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,Unit}()
name_to_reserve = Dict{String,Reserve}()
function timeseries(x; default = nothing) function timeseries(x; default = nothing)
x !== nothing || return default x !== nothing || return default
@@ -140,6 +141,24 @@ function _from_json(json; repair = true)
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)"]),
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"]
bus = name_to_bus[dict["Bus"]] bus = name_to_bus[dict["Bus"]]
@@ -177,6 +196,13 @@ 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 = scalar(dict["Initial power (MW)"], default = nothing)
initial_status = scalar(dict["Initial status (h)"], default = nothing) initial_status = scalar(dict["Initial status (h)"], default = nothing)
@@ -210,36 +236,17 @@ function _from_json(json; repair = true)
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,
) )
push!(bus.units, unit) push!(bus.units, unit)
for r in unit_reserves
push!(r.units, unit)
end
name_to_unit[unit_name] = unit name_to_unit[unit_name] = unit
push!(units, unit) push!(units, unit)
end end
# Read spinning, up-flexiramp, and down-flexiramp reserve requirements
reserves = Reserves(zeros(T), zeros(T), zeros(T))
if "Reserves" in keys(json)
reserves.spinning =
timeseries(json["Reserves"]["Spinning (MW)"], default = zeros(T))
reserves.upflexiramp = timeseries(
json["Reserves"]["Up-flexiramp (MW)"],
default = zeros(T),
)
reserves.dwflexiramp = timeseries(
json["Reserves"]["Down-flexiramp (MW)"],
default = zeros(T),
)
end
# Read transmission lines # Read transmission lines
if "Transmission lines" in keys(json) if "Transmission lines" in keys(json)
for (line_name, dict) in json["Transmission lines"] for (line_name, dict) in json["Transmission lines"]
@@ -312,6 +319,7 @@ 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,
reserves_by_name = name_to_reserve,
shortfall_penalty = shortfall_penalty, shortfall_penalty = shortfall_penalty,
flexiramp_shortfall_penalty = flexiramp_shortfall_penalty, flexiramp_shortfall_penalty = flexiramp_shortfall_penalty,
time = T, time = T,

View File

@@ -20,6 +20,14 @@ mutable struct StartupCategory
cost::Float64 cost::Float64
end end
Base.@kwdef mutable struct Reserve
name::String
type::String
amount::Vector{Float64}
units::Vector
shortfall_penalty::Float64
end
mutable struct Unit mutable struct Unit
name::String name::String
bus::Bus bus::Bus
@@ -36,9 +44,8 @@ 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}
end end
mutable struct TransmissionLine mutable struct TransmissionLine
@@ -53,12 +60,6 @@ mutable struct TransmissionLine
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}
@@ -82,7 +83,8 @@ Base.@kwdef mutable struct UnitCommitmentInstance
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 reserves::Vector{Reserve}
reserves_by_name::Dict{AbstractString,Reserve}
shortfall_penalty::Vector{Float64} shortfall_penalty::Vector{Float64}
flexiramp_shortfall_penalty::Vector{Float64} flexiramp_shortfall_penalty::Vector{Float64}
time::Int time::Int

BIN
src/model/.DS_Store vendored

Binary file not shown.

View File

@@ -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()

View File

@@ -19,10 +19,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)
# Gar1962.ProdVars # Gar1962.ProdVars
prod_above = model[:prod_above] prod_above = model[:prod_above]
@@ -41,7 +41,7 @@ function _add_ramp_eqs!(
model, model,
g.min_power[t] + g.min_power[t] +
prod_above[gn, t] + prod_above[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
@@ -51,7 +51,7 @@ function _add_ramp_eqs!(
prod_above[gn, t] + prod_above[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[gn, t-1]
@@ -82,7 +82,7 @@ function _add_ramp_eqs!(
prod_above[gn, t-1] + prod_above[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[gn, t]

View File

@@ -23,7 +23,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)
# Gar1962.ProdVars # Gar1962.ProdVars
prod_above = model[:prod_above] prod_above = model[:prod_above]
@@ -48,10 +48,8 @@ function _add_ramp_eqs!(
# end # end
max_prod_this_period = max_prod_this_period =
prod_above[gn, t] + ( prod_above[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[gn, t-1]
@@ -88,7 +86,7 @@ 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[gn, t]
on_last_period = 0.0 on_last_period = 0.0

View File

@@ -26,7 +26,7 @@ function _add_production_limit_eqs!(
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)
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
@@ -44,7 +44,7 @@ function _add_production_limit_eqs!(
end end
eq_prod_limit[gn, t] = @constraint( eq_prod_limit[gn, t] = @constraint(
model, model,
prod_above[gn, t] + reserve[gn, t] <= power_diff * is_on[gn, t] prod_above[gn, t] + reserve[t] <= power_diff * is_on[gn, t]
) )
end end
end end

View File

@@ -22,7 +22,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)
# Gar1962.ProdVars # Gar1962.ProdVars
prod_above = model[:prod_above] prod_above = model[:prod_above]
@@ -43,7 +43,7 @@ function _add_ramp_eqs!(
model, model,
g.min_power[t] + g.min_power[t] +
prod_above[gn, t] + prod_above[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
@@ -61,7 +61,7 @@ function _add_ramp_eqs!(
prod_above[gn, t] + prod_above[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[gn, t-1]
@@ -77,7 +77,7 @@ function _add_ramp_eqs!(
eq_ramp_up[gn, t] = @constraint( eq_ramp_up[gn, t] = @constraint(
model, model,
prod_above[gn, t] + prod_above[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[gn, t-1] <= RU
) )
end end
@@ -105,7 +105,7 @@ function _add_ramp_eqs!(
prod_above[gn, t-1] + prod_above[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[gn, t]
@@ -121,7 +121,7 @@ function _add_ramp_eqs!(
eq_ramp_down[gn, t] = @constraint( eq_ramp_down[gn, t] = @constraint(
model, model,
prod_above[gn, t-1] + prod_above[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[gn, t] <= RD
) )
end end

View File

@@ -12,7 +12,7 @@ function _add_ramp_eqs!(
# 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)
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)
@@ -56,7 +56,7 @@ function _add_ramp_eqs!(
model, model,
prod_above[gn, t] + prod_above[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
@@ -71,7 +71,7 @@ function _add_ramp_eqs!(
model, model,
prod_above[gn, t] + prod_above[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)
@@ -88,7 +88,7 @@ function _add_ramp_eqs!(
model, model,
prod_above[gn, t] + prod_above[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

View File

@@ -2,38 +2,12 @@
# 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::Unit,
formulation_prod_vars::Gar1962.ProdVars, ::Gar1962.ProdVars,
formulation_ramping::WanHob2016.Ramping, ::WanHob2016.Ramping,
formulation_status_vars::Gar1962.StatusVars, ::Gar1962.StatusVars,
)::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,49 +25,144 @@ function _add_ramp_eqs!(
dwflexiramp = model[:dwflexiramp] dwflexiramp = model[:dwflexiramp]
mfg = model[:mfg] mfg = model[:mfg]
for t in 1:model[:instance].time if length(g.reserves) > 1
@constraint( error("Each generator may only provide one flexiramp reserve")
model, end
prod_above[gn, t] + (is_on[gn, t] * minp[t]) <= mfg[gn, t] for r in g.reserves
) # Eq. (19) in Wang & Hobbs (2016) if r.type !== "flexiramp"
@constraint(model, mfg[gn, t] <= is_on[gn, t] * maxp[t]) # Eq. (22) in Wang & Hobbs (2016) error(
if t != model[:instance].time "This formulation only supports flexiramp reserves, not $(r.type)",
)
end
rn = r.name
for t in 1:model[:instance].time
@constraint( @constraint(
model, model,
minp[t] * (is_on[gn, t+1] + is_on[gn, t] - 1) <= prod_above[gn, t] + (is_on[gn, t] * minp[t]) <= mfg[rn, gn, t]
prod_above[gn, t] - dwflexiramp[gn, t] + ) # Eq. (19) in Wang & Hobbs (2016)
(is_on[gn, t] * minp[t]) @constraint(model, mfg[rn, gn, t] <= is_on[gn, t] * maxp[t]) # Eq. (22) in Wang & Hobbs (2016)
) # first inequality of Eq. (20) in Wang & Hobbs (2016) if t != model[:instance].time
@constraint(
model,
prod_above[gn, t] - dwflexiramp[gn, t] +
(is_on[gn, t] * minp[t]) <=
mfg[gn, t+1] + (maxp[t] * (1 - is_on[gn, t+1]))
) # second inequality of Eq. (20) in Wang & Hobbs (2016)
@constraint(
model,
minp[t] * (is_on[gn, t+1] + is_on[gn, t] - 1) <=
prod_above[gn, t] +
upflexiramp[gn, t] +
(is_on[gn, t] * minp[t])
) # first inequality of Eq. (21) in Wang & Hobbs (2016)
@constraint(
model,
prod_above[gn, t] +
upflexiramp[gn, t] +
(is_on[gn, t] * minp[t]) <=
mfg[gn, t+1] + (maxp[t] * (1 - is_on[gn, t+1]))
) # second inequality of Eq. (21) in Wang & Hobbs (2016)
if t != 1
@constraint( @constraint(
model, model,
mfg[gn, t] <= minp[t] * (is_on[gn, t+1] + is_on[gn, t] - 1) <=
prod_above[gn, t] - dwflexiramp[rn, gn, t] +
(is_on[gn, t] * minp[t])
) # first inequality of Eq. (20) in Wang & Hobbs (2016)
@constraint(
model,
prod_above[gn, t] - dwflexiramp[rn, gn, t] +
(is_on[gn, t] * minp[t]) <=
mfg[rn, gn, t+1] + (maxp[t] * (1 - is_on[gn, t+1]))
) # second inequality of Eq. (20) in Wang & Hobbs (2016)
@constraint(
model,
minp[t] * (is_on[gn, t+1] + is_on[gn, t] - 1) <=
prod_above[gn, t] +
upflexiramp[rn, gn, t] +
(is_on[gn, t] * minp[t])
) # first inequality of Eq. (21) in Wang & Hobbs (2016)
@constraint(
model,
prod_above[gn, t] +
upflexiramp[rn, gn, t] +
(is_on[gn, t] * minp[t]) <=
mfg[rn, gn, t+1] + (maxp[t] * (1 - is_on[gn, t+1]))
) # second inequality of Eq. (21) in Wang & Hobbs (2016)
if t != 1
@constraint(
model,
mfg[rn, gn, t] <=
prod_above[gn, t-1] +
(is_on[gn, t-1] * minp[t]) +
(RU * is_on[gn, t-1]) +
(SU * (is_on[gn, t] - is_on[gn, t-1])) +
maxp[t] * (1 - is_on[gn, t])
) # Eq. (23) in Wang & Hobbs (2016)
@constraint(
model,
(prod_above[gn, t-1] + (is_on[gn, t-1] * minp[t])) -
(prod_above[gn, t] + (is_on[gn, t] * minp[t])) <=
RD * is_on[gn, t] +
SD * (is_on[gn, t-1] - is_on[gn, t]) +
maxp[t] * (1 - is_on[gn, t-1])
) # Eq. (25) in Wang & Hobbs (2016)
else
@constraint(
model,
mfg[rn, gn, t] <=
initial_power +
(RU * is_initially_on) +
(SU * (is_on[gn, t] - is_initially_on)) +
maxp[t] * (1 - is_on[gn, t])
) # Eq. (23) in Wang & Hobbs (2016) for the first time period
@constraint(
model,
initial_power -
(prod_above[gn, t] + (is_on[gn, t] * minp[t])) <=
RD * is_on[gn, t] +
SD * (is_initially_on - is_on[gn, t]) +
maxp[t] * (1 - is_initially_on)
) # Eq. (25) in Wang & Hobbs (2016) for the first time period
end
@constraint(
model,
mfg[rn, gn, t] <=
(SD * (is_on[gn, t] - is_on[gn, t+1])) +
(maxp[t] * is_on[gn, t+1])
) # Eq. (24) in Wang & Hobbs (2016)
@constraint(
model,
-RD * is_on[gn, t+1] -
SD * (is_on[gn, t] - is_on[gn, t+1]) -
maxp[t] * (1 - is_on[gn, t]) <= upflexiramp[rn, gn, t]
) # first inequality of Eq. (26) in Wang & Hobbs (2016)
@constraint(
model,
upflexiramp[rn, 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])
) # second inequality of Eq. (26) in Wang & Hobbs (2016)
@constraint(
model,
-RU * is_on[gn, t] - SU * (is_on[gn, t+1] - is_on[gn, t]) -
maxp[t] * (1 - is_on[gn, t+1]) <= dwflexiramp[rn, gn, t]
) # first inequality of Eq. (27) in Wang & Hobbs (2016)
@constraint(
model,
dwflexiramp[rn, gn, t] <=
RD * is_on[gn, t+1] +
SD * (is_on[gn, t] - is_on[gn, t+1]) +
maxp[t] * (1 - is_on[gn, t])
) # second inequality of Eq. (27) in Wang & Hobbs (2016)
@constraint(
model,
-maxp[t] * is_on[gn, t] + minp[t] * is_on[gn, t+1] <=
upflexiramp[rn, gn, t]
) # first inequality of Eq. (28) in Wang & Hobbs (2016)
@constraint(
model,
upflexiramp[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[rn, gn, t]
) # first inequality of Eq. (29) in Wang & Hobbs (2016)
@constraint(
model,
dwflexiramp[rn, gn, t] <=
(maxp[t] * is_on[gn, t]) - (minp[t] * is_on[gn, t+1])
) # second inequality of Eq. (29) in Wang & Hobbs (2016)
else
@constraint(
model,
mfg[rn, gn, t] <=
prod_above[gn, t-1] + prod_above[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])) +
maxp[t] * (1 - is_on[gn, t]) maxp[t] * (1 - is_on[gn, t])
) # Eq. (23) in Wang & Hobbs (2016) ) # 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-1] + (is_on[gn, t-1] * minp[t])) -
@@ -101,85 +170,8 @@ function _add_ramp_eqs!(
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])
) # Eq. (25) in Wang & Hobbs (2016) ) # Eq. (25) in Wang & Hobbs (2016) for the last time period
else
@constraint(
model,
mfg[gn, t] <=
initial_power +
(RU * is_initially_on) +
(SU * (is_on[gn, t] - is_initially_on)) +
maxp[t] * (1 - is_on[gn, t])
) # Eq. (23) in Wang & Hobbs (2016) for the first time period
@constraint(
model,
initial_power -
(prod_above[gn, t] + (is_on[gn, t] * minp[t])) <=
RD * is_on[gn, t] +
SD * (is_initially_on - is_on[gn, t]) +
maxp[t] * (1 - is_initially_on)
) # Eq. (25) in Wang & Hobbs (2016) for the first time period
end end
@constraint(
model,
mfg[gn, t] <=
(SD * (is_on[gn, t] - is_on[gn, t+1])) +
(maxp[t] * is_on[gn, t+1])
) # Eq. (24) in Wang & Hobbs (2016)
@constraint(
model,
-RD * is_on[gn, t+1] - SD * (is_on[gn, t] - is_on[gn, t+1]) -
maxp[t] * (1 - is_on[gn, t]) <= upflexiramp[gn, t]
) # first inequality of Eq. (26) in Wang & Hobbs (2016)
@constraint(
model,
upflexiramp[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])
) # second inequality of Eq. (26) in Wang & Hobbs (2016)
@constraint(
model,
-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]
) # first inequality of Eq. (27) in Wang & Hobbs (2016)
@constraint(
model,
dwflexiramp[gn, t] <=
RD * is_on[gn, t+1] +
SD * (is_on[gn, t] - is_on[gn, t+1]) +
maxp[t] * (1 - is_on[gn, t])
) # second inequality of Eq. (27) in Wang & Hobbs (2016)
@constraint(
model,
-maxp[t] * is_on[gn, t] + minp[t] * is_on[gn, t+1] <=
upflexiramp[gn, t]
) # 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(
model,
dwflexiramp[gn, t] <=
(maxp[t] * is_on[gn, t]) - (minp[t] * is_on[gn, t+1])
) # second inequality of Eq. (29) in Wang & Hobbs (2016)
else
@constraint(
model,
mfg[gn, t] <=
prod_above[gn, t-1] +
(is_on[gn, t-1] * minp[t]) +
(RU * is_on[gn, t-1]) +
(SU * (is_on[gn, t] - is_on[gn, t-1])) +
maxp[t] * (1 - is_on[gn, t])
) # Eq. (23) in Wang & Hobbs (2016) for the last time period
@constraint(
model,
(prod_above[gn, t-1] + (is_on[gn, t-1] * minp[t])) -
(prod_above[gn, t] + (is_on[gn, t] * minp[t])) <=
RD * is_on[gn, t] +
SD * (is_on[gn, t-1] - is_on[gn, t]) +
maxp[t] * (1 - is_on[gn, t-1])
) # Eq. (25) in Wang & Hobbs (2016) for the last time period
end end
end end
end end

View File

@@ -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.

View File

@@ -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.
""" """

View File

@@ -4,8 +4,8 @@
function _add_system_wide_eqs!(model::JuMP.Model)::Nothing function _add_system_wide_eqs!(model::JuMP.Model)::Nothing
_add_net_injection_eqs!(model) _add_net_injection_eqs!(model)
_add_reserve_eqs!(model) _add_spinning_reserve_eqs!(model)
_add_flexiramp_eqs!(model) _add_flexiramp_reserve_eqs!(model)
return return
end end
@@ -28,74 +28,69 @@ function _add_net_injection_eqs!(model::JuMP.Model)::Nothing
return return
end end
function _add_reserve_eqs!(model::JuMP.Model)::Nothing function _add_spinning_reserve_eqs!(model::JuMP.Model)::Nothing
eq_min_reserve = _init(model, :eq_min_reserve)
instance = model[:instance] instance = model[:instance]
for t in 1:instance.time eq_min_spinning_reserve = _init(model, :eq_min_spinning_reserve)
# Equation (68) in Kneuven et al. (2020) for r in instance.reserves
# As in Morales-España et al. (2013a) r.type == "spinning" || continue
# Akin to the alternative formulation with max_power_avail for t in 1:instance.time
# from Carrión and Arroyo (2006) and Ostrowski et al. (2012) # Equation (68) in Kneuven et al. (2020)
shortfall_penalty = instance.shortfall_penalty[t] # As in Morales-España et al. (2013a)
eq_min_reserve[t] = @constraint( # Akin to the alternative formulation with max_power_avail
model, # from Carrión and Arroyo (2006) and Ostrowski et al. (2012)
sum(model[:reserve][g.name, t] for g in instance.units) + eq_min_spinning_reserve[r.name, t] = @constraint(
(shortfall_penalty >= 0 ? model[:reserve_shortfall][t] : 0.0) >= model,
instance.reserves.spinning[t] sum(model[:reserve][r.name, g.name, t] for g in r.units) +
) model[:reserve_shortfall][r.name, t] >= r.amount[t]
# Account for shortfall contribution to objective
if shortfall_penalty >= 0
add_to_expression!(
model[:obj],
shortfall_penalty,
model[:reserve_shortfall][t],
) )
# Account for shortfall contribution to objective
if r.shortfall_penalty >= 0
add_to_expression!(
model[:obj],
r.shortfall_penalty,
model[:reserve_shortfall][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)::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] instance = model[:instance]
for t in 1:instance.time for r in instance.reserves
flexiramp_shortfall_penalty = instance.flexiramp_shortfall_penalty[t] r.type == "flexiramp" || continue
# Eq. (17) in Wang & Hobbs (2016) for t in 1:instance.time
eq_min_upflexiramp[t] = @constraint( # Eq. (17) in Wang & Hobbs (2016)
model, eq_min_upflexiramp[r.name, t] = @constraint(
sum(model[:upflexiramp][g.name, t] for g in instance.units) + model,
( sum(model[:upflexiramp][r.name, g.name, t] for g in r.units) + model[:upflexiramp_shortfall][r.name, t] >= r.amount[t]
flexiramp_shortfall_penalty >= 0 ?
model[:upflexiramp_shortfall][t] : 0.0
) >= instance.reserves.upflexiramp[t]
)
# Eq. (18) in Wang & Hobbs (2016)
eq_min_dwflexiramp[t] = @constraint(
model,
sum(model[:dwflexiramp][g.name, t] for g in instance.units) +
(
flexiramp_shortfall_penalty >= 0 ?
model[:dwflexiramp_shortfall][t] : 0.0
) >= instance.reserves.dwflexiramp[t]
)
# Account for flexiramp shortfall contribution to objective
if flexiramp_shortfall_penalty >= 0
add_to_expression!(
model[:obj],
flexiramp_shortfall_penalty,
(
model[:upflexiramp_shortfall][t] +
model[:dwflexiramp_shortfall][t]
),
) )
# Eq. (18) in Wang & Hobbs (2016)
eq_min_dwflexiramp[r.name, t] = @constraint(
model,
sum(model[:dwflexiramp][r.name, g.name, t] for g in r.units) + model[:dwflexiramp_shortfall][r.name, t] >= r.amount[t]
)
# Account for flexiramp shortfall contribution to objective
if r.shortfall_penalty >= 0
add_to_expression!(
model[:obj],
r.shortfall_penalty,
(
model[:upflexiramp_shortfall][r.name, t] +
model[:dwflexiramp_shortfall][r.name, t]
),
)
end
end end
end end
return return

View File

@@ -12,8 +12,8 @@ function _add_unit!(model::JuMP.Model, g::Unit, formulation::Formulation)
# Variables # Variables
_add_production_vars!(model, g, formulation.prod_vars) _add_production_vars!(model, g, formulation.prod_vars)
_add_reserve_vars!(model, g) _add_spinning_reserve_vars!(model, g)
_add_flexiramp_vars!(model, g) _add_flexiramp_reserve_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)
@@ -43,26 +43,48 @@ end
_is_initially_on(g::Unit)::Float64 = (g.initial_status > 0 ? 1.0 : 0.0) _is_initially_on(g::Unit)::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::Unit)::Nothing
reserve = _init(model, :reserve) reserve = _init(model, :reserve)
reserve_shortfall = _init(model, :reserve_shortfall) reserve_shortfall = _init(model, :reserve_shortfall)
for t in 1:model[:instance].time for r in g.reserves
if g.provides_spinning_reserves[t] r.type == "spinning" || continue
reserve[g.name, t] = @variable(model, lower_bound = 0) for t in 1:model[:instance].time
else reserve[r.name, g.name, t] = @variable(model, lower_bound = 0)
reserve[g.name, t] = 0.0 if (r.name, t) keys(reserve_shortfall)
reserve_shortfall[r.name, t] = @variable(model, lower_bound = 0)
if r.shortfall_penalty < 0
set_upper_bound(reserve_shortfall[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!(model::JuMP.Model, g::Unit)::Nothing
reserve = model[:reserve] upflexiramp = _init(model, :upflexiramp)
for t in 1:model[:instance].time upflexiramp_shortfall = _init(model, :upflexiramp_shortfall)
add_to_expression!(expr_reserve[g.bus.name, t], reserve[g.name, t], 1.0) mfg = _init(model, :mfg)
dwflexiramp = _init(model, :dwflexiramp)
dwflexiramp_shortfall = _init(model, :dwflexiramp_shortfall)
for r in g.reserves
r.type == "flexiramp" || continue
for t in 1:model[:instance].time
# maximum feasible generation, \bar{g_{its}} in Wang & Hobbs (2016)
mfg[r.name, g.name, t] = @variable(model, lower_bound = 0)
upflexiramp[r.name, g.name, t] = @variable(model) # up-flexiramp, ur_{it} in Wang & Hobbs (2016)
dwflexiramp[r.name, g.name, t] = @variable(model) # down-flexiramp, dr_{it} in Wang & Hobbs (2016)
if (r.name, t) keys(upflexiramp_shortfall)
upflexiramp_shortfall[r.name, t] =
@variable(model, lower_bound = 0)
dwflexiramp_shortfall[r.name, t] =
@variable(model, lower_bound = 0)
if r.shortfall_penalty < 0
set_upper_bound(upflexiramp_shortfall[r.name, t], 0.0)
set_upper_bound(dwflexiramp_shortfall[r.name, t], 0.0)
end
end
end
end end
return return
end end
@@ -82,7 +104,7 @@ function _add_startup_shutdown_limit_eqs!(model::JuMP.Model, g::Unit)::Nothing
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)
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
@@ -90,7 +112,7 @@ function _add_startup_shutdown_limit_eqs!(model::JuMP.Model, g::Unit)::Nothing
# Startup limit # Startup limit
eq_startup_limit[g.name, t] = @constraint( eq_startup_limit[g.name, t] = @constraint(
model, model,
prod_above[g.name, t] + reserve[g.name, t] <= prod_above[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]
) )
@@ -118,7 +140,7 @@ function _add_ramp_eqs!(
formulation::RampingFormulation, formulation::RampingFormulation,
)::Nothing )::Nothing
prod_above = model[:prod_above] prod_above = model[:prod_above]
reserve = model[:reserve] reserve = _total_reserves(model, g)
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
@@ -127,14 +149,14 @@ function _add_ramp_eqs!(
if _is_initially_on(g) == 1 if _is_initially_on(g) == 1
eq_ramp_up[g.name, t] = @constraint( eq_ramp_up[g.name, t] = @constraint(
model, model,
prod_above[g.name, t] + reserve[g.name, t] <= prod_above[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[g.name, t] = @constraint(
model, model,
prod_above[g.name, t] + reserve[g.name, t] <= prod_above[g.name, t] + reserve[t] <=
prod_above[g.name, t-1] + g.ramp_up_limit prod_above[g.name, t-1] + g.ramp_up_limit
) )
end end
@@ -217,3 +239,15 @@ function _add_net_injection_eqs!(model::JuMP.Model, g::Unit)::Nothing
) )
end end
end end
function _total_reserves(model, g)::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][r.name, g.name, t] for r in spinning_reserves) for t in 1:model[:instance].time
]
end
return reserve
end

View File

@@ -18,15 +18,28 @@ function fix!(model::JuMP.Model, solution::AbstractDict)::Nothing
is_on_value = round(solution["Is on"][g.name][t]) is_on_value = round(solution["Is on"][g.name][t])
prod_value = prod_value =
round(solution["Production (MW)"][g.name][t], digits = 5) round(solution["Production (MW)"][g.name][t], digits = 5)
reserve_value =
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[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 instance.reserves
r.type == "spinning" || continue
for g in r.units
for t in 1:T
reserve_value = round(
solution["Spinning reserve (MW)"][r.name][g.name][t],
digits = 5,
)
JuMP.fix(
reserve[r.name, g.name, t],
reserve_value,
force = true,
)
end
end end
end end
return return

View File

@@ -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
------ ------

View File

@@ -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.
""" """

View File

@@ -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.
"""
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)
@@ -50,37 +62,6 @@ function solution(model::JuMP.Model)::OrderedDict
sol["Is on"] = timeseries(model[:is_on], instance.units) sol["Is on"] = timeseries(model[:is_on], instance.units)
sol["Switch on"] = timeseries(model[:switch_on], instance.units) sol["Switch on"] = timeseries(model[:switch_on], instance.units)
sol["Switch off"] = timeseries(model[:switch_off], 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)"] =
timeseries(model[:dwflexiramp], instance.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
)
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)"] = sol["Net injection (MW)"] =
timeseries(model[:net_injection], instance.buses) timeseries(model[:net_injection], instance.buses)
sol["Load curtail (MW)"] = timeseries(model[:curtail], instance.buses) sol["Load curtail (MW)"] = timeseries(model[:curtail], instance.buses)
@@ -91,5 +72,47 @@ function solution(model::JuMP.Model)::OrderedDict
sol["Price-sensitive loads (MW)"] = sol["Price-sensitive loads (MW)"] =
timeseries(model[:loads], instance.price_sensitive_loads) timeseries(model[:loads], instance.price_sensitive_loads)
end end
sol["Spinning reserve (MW)"] = OrderedDict(
r.name => OrderedDict(
g.name => [
value(model[:reserve][r.name, g.name, t]) for
t in 1:instance.time
] for g in r.units
) for r in instance.reserves if r.type == "spinning"
)
sol["Spinning reserve shortfall (MW)"] = OrderedDict(
r.name => [
value(model[:reserve_shortfall][r.name, t]) for
t in 1:instance.time
] for r in instance.reserves if r.type == "spinning"
)
sol["Up-flexiramp (MW)"] = OrderedDict(
r.name => OrderedDict(
g.name => [
value(model[:upflexiramp][r.name, g.name, t]) for
t in 1:instance.time
] for g in r.units
) for r in instance.reserves if r.type == "flexiramp"
)
sol["Up-flexiramp shortfall (MW)"] = OrderedDict(
r.name => [
value(model[:upflexiramp_shortfall][r.name, t]) for
t in 1:instance.time
] for r in instance.reserves if r.type == "flexiramp"
)
sol["Down-flexiramp (MW)"] = OrderedDict(
r.name => OrderedDict(
g.name => [
value(model[:dwflexiramp][r.name, g.name, t]) for
t in 1:instance.time
] for g in r.units
) for r in instance.reserves if r.type == "flexiramp"
)
sol["Down-flexiramp shortfall (MW)"] = OrderedDict(
r.name => [
value(model[:upflexiramp_shortfall][r.name, t]) for
t in 1:instance.time
] for r in instance.reserves if r.type == "flexiramp"
)
return sol return sol
end end

View File

@@ -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)

View File

@@ -2,13 +2,6 @@
# 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
@@ -55,6 +48,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)
@@ -212,4 +212,31 @@ function randomize!(
return return
end 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!

View File

@@ -12,10 +12,11 @@ conditions are also not modified.
Example Example
------- -------
# Build a 2-hour UC instance ```julia
instance = UnitCommitment.read_benchmark("test/case14") # Build a 2-hour UC instance
modified = UnitCommitment.slice(instance, 1:2) instance = UnitCommitment.read_benchmark("matpower/case118/2017-02-01")
modified = UnitCommitment.slice(instance, 1:2)
```
""" """
function slice( function slice(
instance::UnitCommitmentInstance, instance::UnitCommitmentInstance,
@@ -24,13 +25,14 @@ function slice(
modified = deepcopy(instance) modified = deepcopy(instance)
modified.time = length(range) modified.time = length(range)
modified.power_balance_penalty = modified.power_balance_penalty[range] modified.power_balance_penalty = modified.power_balance_penalty[range]
modified.reserves.spinning = modified.reserves.spinning[range] for r in modified.reserves
r.amount = r.amount[range]
end
for u in modified.units for u in modified.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]

View File

@@ -40,12 +40,19 @@ 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 unit in instance.units for unit in instance.units
production = solution["Production (MW)"][unit.name] production = solution["Production (MW)"][unit.name]
reserve = solution["Reserve (MW)"][unit.name] reserve = [0.0 for _ in 1:instance.time]
spinning_reserves = [r for r in unit.reserves if r.type == "spinning"]
if !isempty(spinning_reserves)
reserve += sum(
solution["Spinning reserve (MW)"][r.name][unit.name] for
r in spinning_reserves
)
end
actual_production_cost = solution["Production cost (\$)"][unit.name] actual_production_cost = solution["Production cost (\$)"][unit.name]
actual_startup_cost = solution["Startup cost (\$)"][unit.name] actual_startup_cost = solution["Startup cost (\$)"][unit.name]
is_on = bin(solution["Is on"][unit.name]) is_on = bin(solution["Is on"][unit.name])
@@ -99,13 +106,18 @@ 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 instance.reserves
@error @sprintf( if r.type == "spinning"
"Unit %s is not eligible to provide spinning reserves at time %d", if unit r.units &&
unit.name, (unit in keys(solution["Spinning reserve (MW)"][r.name]))
t @error @sprintf(
) "Unit %s is not eligible to provide reserve %s",
err_count += 1 unit.name,
r.name,
)
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
@@ -137,9 +149,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
@@ -321,67 +335,65 @@ function _validate_reserve_and_demand(instance, solution, tol = 0.01)
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 instance.reserves
if instance.reserves.upflexiramp != zeros(instance.time) || if r.type == "spinning"
instance.reserves.dwflexiramp != zeros(instance.time) provided = sum(
upflexiramp = sum( solution["Spinning reserve (MW)"][r.name][g.name][t] for
solution["Up-flexiramp (MW)"][g.name][t] for g in r.units
g in instance.units
)
upflexiramp_shortfall =
(instance.flexiramp_shortfall_penalty[t] >= 0) ?
solution["Up-flexiramp shortfall (MW)"][t] : 0
if upflexiramp + upflexiramp_shortfall <
instance.reserves.upflexiramp[t] - tol
@error @sprintf(
"Insufficient up-flexiramp at time %d (%.2f + %.2f should be %.2f)",
t,
upflexiramp,
upflexiramp_shortfall,
instance.reserves.upflexiramp[t],
) )
err_count += 1 shortfall =
end solution["Spinning reserve shortfall (MW)"][r.name][t]
required = r.amount[t]
dwflexiramp = sum( if provided + shortfall < required - tol
solution["Down-flexiramp (MW)"][g.name][t] for @error @sprintf(
g in instance.units "Insufficient reserve %s at time %d (%.2f + %.2f < %.2f)",
) r.name,
dwflexiramp_shortfall = t,
(instance.flexiramp_shortfall_penalty[t] >= 0) ? provided,
solution["Down-flexiramp shortfall (MW)"][t] : 0 shortfall,
required,
if dwflexiramp + dwflexiramp_shortfall < )
instance.reserves.dwflexiramp[t] - tol end
@error @sprintf( elseif r.type == "flexiramp"
"Insufficient down-flexiramp at time %d (%.2f + %.2f should be %.2f)", upflexiramp = sum(
t, solution["Up-flexiramp (MW)"][r.name][g.name][t] for
dwflexiramp, g in r.units
dwflexiramp_shortfall,
instance.reserves.dwflexiramp[t],
) )
err_count += 1 upflexiramp_shortfall =
end solution["Up-flexiramp shortfall (MW)"][r.name][t]
# Verify spinning reserve solutions only if both up-flexiramp and
# down-flexiramp requirements are arrays of zeros.
else
reserve =
sum(solution["Reserve (MW)"][g.name][t] for g in instance.units)
reserve_shortfall =
(instance.shortfall_penalty[t] >= 0) ?
solution["Reserve shortfall (MW)"][t] : 0
if reserve + reserve_shortfall < instance.reserves.spinning[t] - tol if upflexiramp + upflexiramp_shortfall < r.amount[t] - tol
@error @sprintf( @error @sprintf(
"Insufficient spinning reserves at time %d (%.2f + %.2f should be %.2f)", "Insufficient up-flexiramp at time %d (%.2f + %.2f < %.2f)",
t, t,
reserve, upflexiramp,
reserve_shortfall, upflexiramp_shortfall,
instance.reserves.spinning[t], r.amount[t],
)
err_count += 1
end
dwflexiramp = sum(
solution["Down-flexiramp (MW)"][r.name][g.name][t] for
g in r.units
) )
err_count += 1 dwflexiramp_shortfall =
solution["Down-flexiramp shortfall (MW)"][r.name][t]
if dwflexiramp + dwflexiramp_shortfall < r.amount[t] - tol
@error @sprintf(
"Insufficient down-flexiramp at time %d (%.2f + %.2f < %.2f)",
t,
dwflexiramp,
dwflexiramp_shortfall,
r.amount[t],
)
err_count += 1
end
else
error("Unknown reserve type: $(r.type)")
end end
end end
end end

Binary file not shown.

BIN
test/fixtures/case14-flex.json.gz vendored Normal file

Binary file not shown.

BIN
test/fixtures/case14-sub-hourly.json.gz vendored Normal file

Binary file not shown.

BIN
test/fixtures/case14.json.gz vendored Normal file

Binary file not shown.

BIN
test/fixtures/ucjl-0.2.json.gz vendored Normal file

Binary file not shown.

BIN
test/fixtures/ucjl-0.3.json.gz vendored Normal file

Binary file not shown.

View File

@@ -4,12 +4,9 @@
using UnitCommitment using UnitCommitment
basedir = @__DIR__
@testset "read_egret_solution" begin @testset "read_egret_solution" begin
solution = UnitCommitment.read_egret_solution( solution =
"$basedir/../fixtures/egret_output.json.gz", UnitCommitment.read_egret_solution("$FIXTURES/egret_output.json.gz")
)
for attr in ["Is on", "Production (MW)", "Production cost (\$)"] for attr in ["Is on", "Production (MW)", "Production cost (\$)"]
@test attr in keys(solution) @test attr in keys(solution)
@test "115_STEAM_1" in keys(solution[attr]) @test "115_STEAM_1" in keys(solution[attr])

View 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.
using UnitCommitment, LinearAlgebra, Cbc, JuMP, JSON, GZip
@testset "read v0.2" begin
instance = UnitCommitment.read("$FIXTURES/ucjl-0.2.json.gz")
@test length(instance.reserves_by_name["r1"].amount) == 4
@test instance.units_by_name["g2"].reserves[1].name == "r1"
end
@testset "read v0.3" begin
instance = UnitCommitment.read("$FIXTURES/ucjl-0.3.json.gz")
@test length(instance.units) == 6
@test length(instance.buses) == 14
@test length(instance.lines) == 20
end

View File

@@ -5,7 +5,7 @@
using UnitCommitment, LinearAlgebra, Cbc, JuMP, JSON, GZip using UnitCommitment, LinearAlgebra, Cbc, JuMP, JSON, GZip
@testset "read_benchmark" begin @testset "read_benchmark" begin
instance = UnitCommitment.read_benchmark("test/case14") instance = UnitCommitment.read("$FIXTURES/case14.json.gz")
@test length(instance.lines) == 20 @test length(instance.lines) == 20
@test length(instance.buses) == 14 @test length(instance.buses) == 14
@@ -37,6 +37,11 @@ using UnitCommitment, LinearAlgebra, Cbc, JuMP, JSON, GZip
@test instance.buses[9].load == [35.36638, 33.25495, 31.67138, 31.14353] @test instance.buses[9].load == [35.36638, 33.25495, 31.67138, 31.14353]
@test instance.buses_by_name["b9"].name == "b9" @test instance.buses_by_name["b9"].name == "b9"
@test instance.reserves[1].name == "r1"
@test instance.reserves[1].type == "spinning"
@test instance.reserves[1].amount == [100.0, 100.0, 100.0, 100.0]
@test instance.reserves_by_name["r1"].name == "r1"
unit = instance.units[1] unit = instance.units[1]
@test unit.name == "g1" @test unit.name == "g1"
@test unit.bus.name == "b1" @test unit.bus.name == "b1"
@@ -48,7 +53,6 @@ using UnitCommitment, LinearAlgebra, Cbc, JuMP, JSON, GZip
@test unit.min_power_cost == [1400.0 for t in 1:4] @test unit.min_power_cost == [1400.0 for t in 1:4]
@test unit.min_uptime == 1 @test unit.min_uptime == 1
@test unit.min_downtime == 1 @test unit.min_downtime == 1
@test unit.provides_spinning_reserves == [true for t in 1:4]
for t in 1:1 for t in 1:1
@test unit.cost_segments[1].mw[t] == 10.0 @test unit.cost_segments[1].mw[t] == 10.0
@test unit.cost_segments[2].mw[t] == 20.0 @test unit.cost_segments[2].mw[t] == 20.0
@@ -64,11 +68,13 @@ using UnitCommitment, LinearAlgebra, Cbc, JuMP, JSON, GZip
@test unit.startup_categories[1].cost == 1000.0 @test unit.startup_categories[1].cost == 1000.0
@test unit.startup_categories[2].cost == 1500.0 @test unit.startup_categories[2].cost == 1500.0
@test unit.startup_categories[3].cost == 2000.0 @test unit.startup_categories[3].cost == 2000.0
@test length(unit.reserves) == 0
@test instance.units_by_name["g1"].name == "g1" @test instance.units_by_name["g1"].name == "g1"
unit = instance.units[2] unit = instance.units[2]
@test unit.name == "g2" @test unit.name == "g2"
@test unit.must_run == [false for t in 1:4] @test unit.must_run == [false for t in 1:4]
@test length(unit.reserves) == 1
unit = instance.units[3] unit = instance.units[3]
@test unit.name == "g3" @test unit.name == "g3"
@@ -81,7 +87,6 @@ using UnitCommitment, LinearAlgebra, Cbc, JuMP, JSON, GZip
@test unit.min_power_cost == [0.0 for t in 1:4] @test unit.min_power_cost == [0.0 for t in 1:4]
@test unit.min_uptime == 1 @test unit.min_uptime == 1
@test unit.min_downtime == 1 @test unit.min_downtime == 1
@test unit.provides_spinning_reserves == [true for t in 1:4]
for t in 1:4 for t in 1:4
@test unit.cost_segments[1].mw[t] 33 @test unit.cost_segments[1].mw[t] 33
@test unit.cost_segments[2].mw[t] 33 @test unit.cost_segments[2].mw[t] 33
@@ -90,8 +95,8 @@ using UnitCommitment, LinearAlgebra, Cbc, JuMP, JSON, GZip
@test unit.cost_segments[2].cost[t] 38.04 @test unit.cost_segments[2].cost[t] 38.04
@test unit.cost_segments[3].cost[t] 44.77853 @test unit.cost_segments[3].cost[t] 44.77853
end end
@test length(unit.reserves) == 1
@test instance.reserves.spinning == zeros(4) @test unit.reserves[1].name == "r1"
@test instance.contingencies[1].lines == [instance.lines[1]] @test instance.contingencies[1].lines == [instance.lines[1]]
@test instance.contingencies[1].units == [] @test instance.contingencies[1].units == []
@@ -107,7 +112,7 @@ using UnitCommitment, LinearAlgebra, Cbc, JuMP, JSON, GZip
end end
@testset "read_benchmark sub-hourly" begin @testset "read_benchmark sub-hourly" begin
instance = UnitCommitment.read_benchmark("test/case14-sub-hourly") instance = UnitCommitment.read("$FIXTURES/case14-sub-hourly.json.gz")
@test instance.time == 4 @test instance.time == 4
unit = instance.units[1] unit = instance.units[1]
@test unit.name == "g1" @test unit.name == "g1"

View File

@@ -5,6 +5,7 @@
using UnitCommitment using UnitCommitment
using JuMP using JuMP
using Cbc using Cbc
using JSON
import UnitCommitment: import UnitCommitment:
ArrCon2000, ArrCon2000,
CarArr2006, CarArr2006,
@@ -19,42 +20,65 @@ import UnitCommitment:
function _test( function _test(
formulation::Formulation; formulation::Formulation;
instances::Array{String} = ["test/case14"], instances = ["case14"],
optimizer = optimizer_with_attributes(Cbc.Optimizer, "logLevel" => 0), dump::Bool = false,
)::Nothing )::Nothing
for instance_name in instances for instance_name in instances
instance = UnitCommitment.read_benchmark(instance_name) instance = UnitCommitment.read("$(FIXTURES)/$(instance_name).json.gz")
model = UnitCommitment.build_model( model = UnitCommitment.build_model(
instance = instance, instance = instance,
formulation = formulation, formulation = formulation,
optimizer = optimizer, optimizer = Cbc.Optimizer,
) variable_names = true,
UnitCommitment.optimize!(
model,
XavQiuWanThi2019.Method(two_phase_gap = false, gap_limit = 0.1),
) )
set_silent(model)
UnitCommitment.optimize!(model)
solution = UnitCommitment.solution(model) solution = UnitCommitment.solution(model)
if dump
open("/tmp/ucjl.json", "w") do f
return write(f, JSON.json(solution, 2))
end
write_to_file(model, "/tmp/ucjl.lp")
end
@test UnitCommitment.validate(instance, solution) @test UnitCommitment.validate(instance, solution)
end end
return
end end
@testset "formulations" begin @testset "formulations" begin
_test(Formulation()) @testset "default" begin
_test(Formulation(ramping = ArrCon2000.Ramping())) _test(Formulation())
end
# _test(Formulation(ramping = DamKucRajAta2016.Ramping())) @testset "ArrCon2000" begin
_test( _test(Formulation(ramping = ArrCon2000.Ramping()))
Formulation( end
ramping = MorLatRam2013.Ramping(), @testset "DamKucRajAta2016" begin
startup_costs = MorLatRam2013.StartupCosts(), _test(Formulation(ramping = DamKucRajAta2016.Ramping()))
), end
) @testset "MorLatRam2013" begin
_test(Formulation(ramping = PanGua2016.Ramping())) _test(
_test(Formulation(pwl_costs = Gar1962.PwlCosts())) Formulation(
_test(Formulation(pwl_costs = CarArr2006.PwlCosts())) ramping = MorLatRam2013.Ramping(),
_test(Formulation(pwl_costs = KnuOstWat2018.PwlCosts())) startup_costs = MorLatRam2013.StartupCosts(),
_test( ),
Formulation(ramping = WanHob2016.Ramping()), )
instances = ["test/case14-flex"], end
) @testset "PanGua2016" begin
_test(Formulation(ramping = PanGua2016.Ramping()))
end
@testset "Gar1962" begin
_test(Formulation(pwl_costs = Gar1962.PwlCosts()))
end
@testset "CarArr2006" begin
_test(Formulation(pwl_costs = CarArr2006.PwlCosts()))
end
@testset "KnuOstWat2018" begin
_test(Formulation(pwl_costs = KnuOstWat2018.PwlCosts()))
end
@testset "WanHob2016" begin
_test(
Formulation(ramping = WanHob2016.Ramping()),
instances = ["case14-flex"],
)
end
end end

View File

@@ -8,6 +8,8 @@ using UnitCommitment
push!(Base.LOAD_PATH, @__DIR__) push!(Base.LOAD_PATH, @__DIR__)
UnitCommitment._setup_logger(level = Base.CoreLogging.Error) UnitCommitment._setup_logger(level = Base.CoreLogging.Error)
FIXTURES = "$(@__DIR__)/fixtures"
@testset "UnitCommitment" begin @testset "UnitCommitment" begin
include("usage.jl") include("usage.jl")
@testset "import" begin @testset "import" begin
@@ -15,14 +17,17 @@ UnitCommitment._setup_logger(level = Base.CoreLogging.Error)
end end
@testset "instance" begin @testset "instance" begin
include("instance/read_test.jl") include("instance/read_test.jl")
include("instance/migrate_test.jl")
end end
@testset "model" begin @testset "model" begin
include("model/formulations_test.jl") include("model/formulations_test.jl")
end end
@testset "XavQiuWanThi19" begin @testset "solution" begin
include("solution/methods/XavQiuWanThi19/filter_test.jl") @testset "XavQiuWanThi19" begin
include("solution/methods/XavQiuWanThi19/find_test.jl") include("solution/methods/XavQiuWanThi19/filter_test.jl")
include("solution/methods/XavQiuWanThi19/sensitivity_test.jl") include("solution/methods/XavQiuWanThi19/find_test.jl")
include("solution/methods/XavQiuWanThi19/sensitivity_test.jl")
end
end end
@testset "transform" begin @testset "transform" begin
include("transform/initcond_test.jl") include("transform/initcond_test.jl")

View File

@@ -6,7 +6,7 @@ using UnitCommitment, Test, LinearAlgebra
import UnitCommitment: _Violation, _offer, _query import UnitCommitment: _Violation, _offer, _query
@testset "_ViolationFilter" begin @testset "_ViolationFilter" begin
instance = UnitCommitment.read_benchmark("test/case14") instance = UnitCommitment.read("$FIXTURES/case14.json.gz")
filter = UnitCommitment._ViolationFilter(max_per_line = 1, max_total = 2) filter = UnitCommitment._ViolationFilter(max_per_line = 1, max_total = 2)
_offer( _offer(

View File

@@ -6,7 +6,7 @@ using UnitCommitment, Test, LinearAlgebra
import UnitCommitment: _Violation, _offer, _query import UnitCommitment: _Violation, _offer, _query
@testset "find_violations" begin @testset "find_violations" begin
instance = UnitCommitment.read_benchmark("test/case14") instance = UnitCommitment.read("$FIXTURES/case14.json.gz")
for line in instance.lines, t in 1:instance.time for line in instance.lines, t in 1:instance.time
line.normal_flow_limit[t] = 1.0 line.normal_flow_limit[t] = 1.0
line.emergency_flow_limit[t] = 1.0 line.emergency_flow_limit[t] = 1.0

View File

@@ -5,7 +5,7 @@
using UnitCommitment, Test, LinearAlgebra using UnitCommitment, Test, LinearAlgebra
@testset "_susceptance_matrix" begin @testset "_susceptance_matrix" begin
instance = UnitCommitment.read_benchmark("test/case14") instance = UnitCommitment.read("$FIXTURES/case14.json.gz")
actual = UnitCommitment._susceptance_matrix(instance.lines) actual = UnitCommitment._susceptance_matrix(instance.lines)
@test size(actual) == (20, 20) @test size(actual) == (20, 20)
expected = Diagonal([ expected = Diagonal([
@@ -34,7 +34,7 @@ using UnitCommitment, Test, LinearAlgebra
end end
@testset "_reduced_incidence_matrix" begin @testset "_reduced_incidence_matrix" begin
instance = UnitCommitment.read_benchmark("test/case14") instance = UnitCommitment.read("$FIXTURES/case14.json.gz")
actual = UnitCommitment._reduced_incidence_matrix( actual = UnitCommitment._reduced_incidence_matrix(
lines = instance.lines, lines = instance.lines,
buses = instance.buses, buses = instance.buses,
@@ -81,7 +81,7 @@ end
end end
@testset "_injection_shift_factors" begin @testset "_injection_shift_factors" begin
instance = UnitCommitment.read_benchmark("test/case14") instance = UnitCommitment.read("$FIXTURES/case14.json.gz")
actual = UnitCommitment._injection_shift_factors( actual = UnitCommitment._injection_shift_factors(
lines = instance.lines, lines = instance.lines,
buses = instance.buses, buses = instance.buses,
@@ -112,7 +112,7 @@ end
end end
@testset "_line_outage_factors" begin @testset "_line_outage_factors" begin
instance = UnitCommitment.read_benchmark("test/case14") instance = UnitCommitment.read("$FIXTURES/case14.json.gz")
isf_before = UnitCommitment._injection_shift_factors( isf_before = UnitCommitment._injection_shift_factors(
lines = instance.lines, lines = instance.lines,
buses = instance.buses, buses = instance.buses,

View File

@@ -4,12 +4,9 @@
using UnitCommitment, Cbc, JuMP using UnitCommitment, Cbc, JuMP
basedir = @__DIR__
@testset "generate_initial_conditions!" begin @testset "generate_initial_conditions!" begin
# Load instance # Load instance
instance = instance = UnitCommitment.read("$FIXTURES/case118-initcond.json.gz")
UnitCommitment.read("$basedir/../fixtures/case118-initcond.json.gz")
optimizer = optimizer_with_attributes(Cbc.Optimizer, "logLevel" => 0) optimizer = optimizer_with_attributes(Cbc.Optimizer, "logLevel" => 0)
# All units should have unknown initial conditions # All units should have unknown initial conditions

View File

@@ -30,7 +30,9 @@ test_approx(x, y) = @test isapprox(x, y, atol = 1e-3)
randomize!( randomize!(
instance, instance,
XavQiuAhm2021.Randomization(randomize_load_profile = false), method = XavQiuAhm2021.Randomization(
randomize_load_profile = false,
),
rng = MersenneTwister(42), rng = MersenneTwister(42),
) )

View File

@@ -5,19 +5,18 @@
using UnitCommitment, LinearAlgebra, Cbc, JuMP, JSON, GZip using UnitCommitment, LinearAlgebra, Cbc, JuMP, JSON, GZip
@testset "slice" begin @testset "slice" begin
instance = UnitCommitment.read_benchmark("test/case14") instance = UnitCommitment.read("$FIXTURES/case14.json.gz")
modified = UnitCommitment.slice(instance, 1:2) modified = UnitCommitment.slice(instance, 1:2)
# Should update all time-dependent fields # Should update all time-dependent fields
@test modified.time == 2 @test modified.time == 2
@test length(modified.power_balance_penalty) == 2 @test length(modified.power_balance_penalty) == 2
@test length(modified.reserves.spinning) == 2 @test length(modified.reserves_by_name["r1"].amount) == 2
for u in modified.units for u in modified.units
@test length(u.max_power) == 2 @test length(u.max_power) == 2
@test length(u.min_power) == 2 @test length(u.min_power) == 2
@test length(u.must_run) == 2 @test length(u.must_run) == 2
@test length(u.min_power_cost) == 2 @test length(u.min_power_cost) == 2
@test length(u.provides_spinning_reserves) == 2
for s in u.cost_segments for s in u.cost_segments
@test length(s.mw) == 2 @test length(s.mw) == 2
@test length(s.cost) == 2 @test length(s.cost) == 2

View File

@@ -4,8 +4,8 @@
using UnitCommitment, LinearAlgebra, Cbc, JuMP, JSON using UnitCommitment, LinearAlgebra, Cbc, JuMP, JSON
@testset "build_model" begin @testset "usage" begin
instance = UnitCommitment.read_benchmark("test/case14") instance = UnitCommitment.read("$FIXTURES/case14.json.gz")
for line in instance.lines, t in 1:4 for line in instance.lines, t in 1:4
line.normal_flow_limit[t] = 10.0 line.normal_flow_limit[t] = 10.0
end end

View File

@@ -4,11 +4,9 @@
using UnitCommitment, JSON, GZip, DataStructures using UnitCommitment, JSON, GZip, DataStructures
basedir = @__DIR__
function parse_case14() function parse_case14()
return JSON.parse( return JSON.parse(
GZip.gzopen("$basedir/../../instances/test/case14.json.gz"), GZip.gzopen("$FIXTURES/case14.json.gz"),
dicttype = () -> DefaultOrderedDict(nothing), dicttype = () -> DefaultOrderedDict(nothing),
) )
end end