Compare commits

..

1 Commits

Author SHA1 Message Date
b0b6b9b2dc Implement MIPLearn solution method 2024-01-09 14:27:46 -06:00
121 changed files with 1543 additions and 26225 deletions

View File

@@ -10,7 +10,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
version: ['1.10', '1.12']
version: ['1.6', '1.7', '1.8', '1.9']
os:
- ubuntu-latest
arch:

6
.gitignore vendored
View File

@@ -1,4 +1,3 @@
*-off.md
*.bak
*.gz
*.ipynb
@@ -20,7 +19,6 @@
.apdisk
.com.apple.timemachine.donotpresent
.fseventsd
.idea
.ipy*
.vscode
Icon
@@ -34,10 +32,6 @@ benchmark/tables
benchmark/tmp.json
build
docs/_build
docs/src/tutorials/customizing.md
docs/src/tutorials/lmp.md
docs/src/tutorials/market.md
docs/src/tutorials/usage.md
instances/**/*.json
instances/_source
local

View File

@@ -11,22 +11,6 @@ All notable changes to this project will be documented in this file.
[semver]: https://semver.org/spec/v2.0.0.html
[pkjjl]: https://pkgdocs.julialang.org/v1/compatibility/#compat-pre-1.0
## [0.4.1] - 2025-11-05
### Fixed
- Fix multi-threading issues in Julia 1.12
### Changed
- The package now requires Julia 1.10 or newer
## [0.4.0] - 2024-05-21
### Added
- Add support for two-stage stochastic problems
- Add support for day-ahead and real-time market clearing simulation
- Add time decomposition methods
- Add scenario decomposition methods (progressive hedging)
- Add support for energy storage units
- Rewrite documentation with runnable examples
## [0.3.0] - 2022-07-18
### Added
- Add support for multiple reserve products and zonal reserves.

View File

@@ -2,10 +2,10 @@
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
# Released under the modified BSD license. See COPYING.md for more details.
VERSION := 0.4
VERSION := 0.3
docs:
cd docs; julia --project=. -e 'include("make.jl"); make()'; cd ..
cd docs; julia --project=. make.jl; cd ..
rsync -avP --delete-after docs/build/ ../docs/$(VERSION)/
.PHONY: docs

View File

@@ -2,7 +2,7 @@ name = "UnitCommitment"
uuid = "64606440-39ea-11e9-0f29-3303a1d3d877"
authors = ["Santos Xavier, Alinson <axavier@anl.gov>"]
repo = "https://github.com/ANL-CEEESA/UnitCommitment.jl"
version = "0.4.1"
version = "0.3.0"
[deps]
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
@@ -13,13 +13,15 @@ JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
PackageCompiler = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f"
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
[compat]
DataStructures = "0.18"
@@ -27,8 +29,8 @@ Distributions = "0.25"
GZip = "0.5"
JSON = "0.21"
JuMP = "1"
MathOptInterface = "1"
MPI = "0.20"
MathOptInterface = "1"
PackageCompiler = "1"
julia = "1.10"
TimerOutputs = "0.5"
julia = "1"

View File

@@ -87,7 +87,11 @@ UnitCommitment.write("/tmp/output.json", solution)
## Documentation
See official documentation at: https://anl-ceeesa.github.io/UnitCommitment.jl/
1. [Usage](https://anl-ceeesa.github.io/UnitCommitment.jl/0.3/usage/)
2. [Data Format](https://anl-ceeesa.github.io/UnitCommitment.jl/0.3/format/)
3. [Instances](https://anl-ceeesa.github.io/UnitCommitment.jl/0.3/instances/)
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
* **Alinson S. Xavier** (Argonne National Laboratory)
@@ -108,7 +112,7 @@ See official documentation at: https://anl-ceeesa.github.io/UnitCommitment.jl/
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, Ogün Yurdakul, Jun He, Feng Qiu**. "UnitCommitment.jl: A Julia/JuMP Optimization Package for Security-Constrained Unit Commitment (Version 0.4)". Zenodo (2024). [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 documentation.
@@ -116,7 +120,7 @@ If you use the instances, we additionally request that you cite the original sou
```text
UnitCommitment.jl: A Julia/JuMP Optimization Package for Security-Constrained Unit Commitment
Copyright © 2020-2024, 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
provided that the following conditions are met:

View File

@@ -4,7 +4,6 @@ Glob = "c27321d9-0574-5035-807b-f59d2c89b15c"
HiGHS = "87dc4568-4c63-4d18-b0c0-bb2238e4078b"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
UnitCommitment = "64606440-39ea-11e9-0f29-3303a1d3d877"

View File

@@ -1,43 +1,18 @@
using Documenter
using UnitCommitment
using JuMP
using Literate
using Documenter, UnitCommitment, JuMP
function make()
literate_sources = [
"src/tutorials/usage.jl",
"src/tutorials/customizing.jl",
"src/tutorials/lmp.jl",
"src/tutorials/market.jl",
]
for src in literate_sources
Literate.markdown(
src,
dirname(src);
documenter = true,
credit = false,
)
end
return makedocs(
sitename = "UnitCommitment.jl",
pages = [
makedocs(
sitename="UnitCommitment.jl",
pages=[
"Home" => "index.md",
"Tutorials" => [
"tutorials/usage.md",
"tutorials/customizing.md",
"tutorials/lmp.md",
"tutorials/market.md",
"tutorials/decomposition.md",
],
"User guide" => [
"guides/problem.md",
"guides/format.md",
"guides/instances.md",
],
"usage.md",
"format.md",
"instances.md",
"model.md",
"api.md",
],
format = Documenter.HTML(assets = ["assets/custom.css"]),
format = Documenter.HTML(
assets=["assets/custom.css"],
)
)
end

View File

@@ -15,18 +15,17 @@ UnitCommitment.write
## Locational Marginal Prices
### Conventional LMPs
```@docs
UnitCommitment.compute_lmp(::JuMP.Model,::UnitCommitment.ConventionalLMP)
```
### Approximated Extended LMPs
```@docs
UnitCommitment.AELMP
UnitCommitment.compute_lmp(::JuMP.Model,::UnitCommitment.AELMP)
```
## Modify instance
```@docs

View File

@@ -1,6 +1,6 @@
@media screen and (min-width: 1056px) {
#documenter .docs-main {
max-width: 50rem !important;
max-width: 65rem !important;
}
}

408
docs/src/format.md Normal file
View File

@@ -0,0 +1,408 @@
Data Format
===========
Input Data Format
-----------------
An instance of the stochastic security-constrained unit commitment (SCUC) problem is composed multiple scenarios. Each scenario should be described in an individual JSON file containing the main section belows. For deterministic instances, a single scenario file, following the same format below, may also be provided. Fields that are allowed to differ among scenarios are marked as "uncertain". Fields that are allowed to be time-dependent are marked as "time series".
* [Parameters](#Parameters)
* [Buses](#Buses)
* [Generators](#Generators)
* [Storage units](#Storage-units)
* [Price-sensitive loads](#Price-sensitive-loads)
* [Transmission lines](#Transmission-lines)
* [Reserves](#Reserves)
* [Contingencies](#Contingencies)
Each section is described in detail below. See [case118/2017-01-01.json.gz](https://axavier.org/UnitCommitment.jl/0.3/instances/matpower/case118/2017-01-01.json.gz) for a complete example.
### Parameters
This section describes system-wide parameters, such as power balance penalty, and optimization parameters, such as the length of the planning horizon and the time.
| Key | Description | Default | Time series? | Uncertain?
| :----------------------------- | :------------------------------------------------ | :------: | :------------:| :----------:
| `Version` | Version of UnitCommitment.jl this file was written for. Required to ensure that the file remains readable in future versions of the package. If you are following this page to construct the file, this field should equal `0.4`. | Required | No | No
| `Time horizon (min)` or `Time horizon (h)` | Length of the planning horizon (in minutes or hours). Either `Time horizon (min)` or `Time horizon (h)` is required, but not both. | Required | No | No
| `Time step (min)` | Length of each time step (in minutes). Must be a divisor of 60 (e.g. 60, 30, 20, 15, etc). | `60` | No | No
| `Power balance penalty ($/MW)` | Penalty for system-wide shortage or surplus in production (in $/MW). This is charged per time step. For example, if there is a shortage of 1 MW for three time steps, three times this amount will be charged. | `1000.0` | No | Yes
| `Scenario name` | Name of the scenario. | `"s1"` | No | ---
| `Scenario weight` | Weight of the scenario. The scenario weight can be any positive real number, that is, it does not have to be between zero and one. The package normalizes the weights to ensure that the probability of all scenarios sum up to one. | 1.0 | No | ---
#### Example
```json
{
"Parameters": {
"Version": "0.3",
"Time horizon (h)": 4,
"Power balance penalty ($/MW)": 1000.0,
"Scenario name": "s1",
"Scenario weight": 0.5
}
}
```
### Buses
This section describes the characteristics of each bus in the system.
| Key | Description | Default | Time series? | Uncertain?
| :----------------- | :------------------------------------------------------------ | ------- | :-----------: | :---:
| `Load (MW)` | Fixed load connected to the bus (in MW). | Required | Yes | Yes
#### Example
```json
{
"Buses": {
"b1": {
"Load (MW)": 0.0
},
"b2": {
"Load (MW)": [
26.01527,
24.46212,
23.29725,
22.90897
]
}
}
}
```
### Generators
This section describes all generators in the system. Two types of units can be specified:
- **Thermal units:** Units that produce power by converting heat into electrical energy, such as coal and oil power plants. These units use a more complex model, with binary decision variables, and various constraints to enforce ramp rates and minimum up/down time.
- **Profiled units:** Simplified model for units that do not require the constraints mentioned above, only a maximum and minimum power output for each time period. Typically used for renewables and hydro.
#### Thermal Units
| Key | Description | Default | Time series? | Uncertain?
| :------------------------ | :------------------------------------------------| ------- | :-----------: | :---:
| `Bus` | Identifier of the bus where this generator is located (string). | Required | No | Yes
| `Type` | Type of the generator (string). For thermal generators, this must be `Thermal`. | Required | No | No
| `Production cost curve (MW)` and `Production cost curve ($)` | Parameters describing the piecewise-linear production costs. See below for more details. | Required | Yes | Yes
| `Startup costs ($)` and `Startup delays (h)` | Parameters describing how much it costs to start the generator after it has been shut down for a certain amount of time. If `Startup costs ($)` and `Startup delays (h)` are set to `[300.0, 400.0]` and `[1, 4]`, for example, and the generator is shut down at time `00:00` (h:min), then it costs \$300 to start up the generator at any time between `01:00` and `03:59`, and \$400 to start the generator at time `04:00` or any time after that. The number of startup cost points is unlimited, and may be different for each generator. Startup delays must be strictly increasing and the first entry must equal `Minimum downtime (h)`. | `[0.0]` and `[1]` | No | Yes
| `Minimum uptime (h)` | Minimum amount of time the generator must stay operational after starting up (in hours). For example, if the generator starts up at time `00:00` (h:min) and `Minimum uptime (h)` is set to 4, then the generator can only shut down at time `04:00`. | `1` | No | Yes
| `Minimum downtime (h)` | Minimum amount of time the generator must stay offline after shutting down (in hours). For example, if the generator shuts down at time `00:00` (h:min) and `Minimum downtime (h)` is set to 4, then the generator can only start producing power again at time `04:00`. | `1` | No | Yes
| `Ramp up limit (MW)` | Maximum increase in production from one time step to the next (in MW). For example, if the generator is producing 100 MW at time step 1 and if this parameter is set to 40 MW, then the generator will produce at most 140 MW at time step 2. | `+inf` | No | Yes
| `Ramp down limit (MW)` | Maximum decrease in production from one time step to the next (in MW). For example, if the generator is producing 100 MW at time step 1 and this parameter is set to 40 MW, then the generator will produce at least 60 MW at time step 2. | `+inf` | No | Yes
| `Startup limit (MW)` | Maximum amount of power a generator can produce immediately after starting up (in MW). For example, if `Startup limit (MW)` is set to 100 MW and the unit is off at time step 1, then it may produce at most 100 MW at time step 2.| `+inf` | No | Yes
| `Shutdown limit (MW)` | Maximum amount of power a generator can produce immediately before shutting down (in MW). Specifically, the generator can only shut down at time step `t+1` if its production at time step `t` is below this limit. | `+inf` | No | Yes
| `Initial status (h)` | If set to a positive number, indicates the amount of time (in hours) the generator has been on at the beginning of the simulation, and if set to a negative number, the amount of time the generator has been off. For example, if `Initial status (h)` is `-2`, this means that the generator was off since `-02:00` (h:min). The simulation starts at time `00:00`. If `Initial status (h)` is `3`, this means that the generator was on since `-03:00`. A value of zero is not acceptable. | Required | No | No
| `Initial power (MW)` | Amount of power the generator at time step `-1`, immediately before the planning horizon starts. | Required | No | No
| `Must run?` | If `true`, the generator should be committed, even if that is not economical (Boolean). | `false` | Yes | Yes
| `Reserve eligibility` | List of reserve products this generator is eligibe to provide. By default, the generator is not eligible to provide any reserves. | `[]` | No | Yes
| `Commitment status` | List of commitment status over the time horizon. At time `t`, if `true`, the generator must be commited at that time period; if `false`, the generator must not be commited at that time period. If `null` at time `t`, the generator's commitment status is then decided by the model. By default, the status is a list of `null` values. | `null` | Yes | Yes
#### Profiled Units
| Key | Description | Default | Time series? | Uncertain?
| :---------------- | :------------------------------------------------ | :------: | :------------: | :---:
| `Bus` | Identifier of the bus where this generator is located (string). | Required | No | Yes
| `Type` | Type of the generator (string). For profiled generators, this must be `Profiled`. | Required | No | No
| `Cost ($/MW)` | Cost incurred for serving each MW of power by this generator. | Required | Yes | Yes
| `Minimum power (MW)` | Minimum amount of power this generator may supply. | `0.0` | Yes | Yes
| `Maximum power (MW)` | Maximum amount of power this generator may supply. | Required | Yes | Yes
#### Production costs and limits
Production costs are represented as piecewise-linear curves. Figure 1 shows an example cost curve with three segments, where it costs \$1400, \$1600, \$2200 and \$2400 to generate, respectively, 100, 110, 130 and 135 MW of power. To model this generator, `Production cost curve (MW)` should be set to `[100, 110, 130, 135]`, and `Production cost curve ($)` should be set to `[1400, 1600, 2200, 2400]`.
Note that this curve also specifies the production limits. Specifically, the first point identifies the minimum power output when the unit is operational, while the last point identifies the maximum power output.
```@raw html
<center>
<img src="../assets/cost_curve.png" style="max-width: 500px"/>
<div><b>Figure 1.</b> Piecewise-linear production cost curve.</div>
<br/>
</center>
```
#### Additional remarks:
* For time-dependent production limits or time-dependent production costs, the usage of nested arrays is allowed. For example, if `Production cost curve (MW)` is set to `[5.0, [10.0, 12.0, 15.0, 20.0]]`, then the unit may generate at most 10, 12, 15 and 20 MW of power during time steps 1, 2, 3 and 4, respectively. The minimum output for all time periods is fixed to at 5 MW.
* There is no limit to the number of piecewise-linear segments, and different generators may have a different number of segments.
* If `Production cost curve (MW)` and `Production cost curve ($)` both contain a single element, then the generator must produce exactly that amount of power when operational. To specify that the generator may produce any amount of power up to a certain limit `P`, the parameter `Production cost curve (MW)` should be set to `[0, P]`.
* Production cost curves must be convex.
#### Example
```json
{
"Generators": {
"gen1": {
"Bus": "b1",
"Type": "Thermal",
"Production cost curve (MW)": [100.0, 110.0, 130.0, 135.0],
"Production cost curve ($)": [1400.0, 1600.0, 2200.0, 2400.0],
"Startup costs ($)": [300.0, 400.0],
"Startup delays (h)": [1, 4],
"Ramp up limit (MW)": 232.68,
"Ramp down limit (MW)": 232.68,
"Startup limit (MW)": 232.68,
"Shutdown limit (MW)": 232.68,
"Minimum downtime (h)": 4,
"Minimum uptime (h)": 4,
"Initial status (h)": 12,
"Initial power (MW)": 115,
"Must run?": false,
"Reserve eligibility": ["r1"]
},
"gen2": {
"Bus": "b5",
"Type": "Thermal",
"Production cost curve (MW)": [0.0, [10.0, 8.0, 0.0, 3.0]],
"Production cost curve ($)": [0.0, 0.0],
"Initial status (h)": -100,
"Initial power (MW)": 0,
"Reserve eligibility": ["r1", "r2"],
"Commitment status": [true, false, null, true]
},
"gen3": {
"Bus": "b6",
"Type": "Profiled",
"Minimum power (MW)": 10.0,
"Maximum power (MW)": 120.0,
"Cost ($/MW)": 100.0
}
}
}
```
### Storage units
This section describes energy storage units in the system which charge and discharge power. The storage units consume power while charging, and generate power while discharging.
| Key | Description | Default | Time series? | Uncertain?
| :---------------- | :------------------------------------------------ | :------: | :------------: | :----:
| `Bus` | Bus where the storage unit is located. Multiple storage units may be placed at the same bus. | Required | No | Yes
| `Minimum level (MWh)` | Minimum of energy level this storage unit may contain. | `0.0` | Yes | Yes
| `Maximum level (MWh)` | Maximum of energy level this storage unit may contain. | Required | Yes | Yes
| `Allow simultaneous charging and discharging` | If `false`, the storage unit is not allowed to charge and discharge at the same time (Boolean). | `true` | Yes | Yes
| `Charge cost ($/MW)` | Cost incurred for charging each MW of power into this storage unit. | Required | Yes | Yes
| `Discharge cost ($/MW)` | Cost incurred for discharging each MW of power from this storage unit. | Required | Yes | Yes
| `Charge efficiency` | Efficiency rate to charge power into this storage unit. This value must be greater than or equal to `0.0`, and less than or equal to `1.0`. | `1.0` | Yes | Yes
| `Discharge efficiency` | Efficiency rate to discharge power from this storage unit. This value must be greater than or equal to `0.0`, and less than or equal to `1.0`. | `1.0` | Yes | Yes
| `Loss factor` | The energy dissipation rate of this storage unit. This value must be greater than or equal to `0.0`, and less than or equal to `1.0`. | `0.0` | Yes | Yes
| `Minimum charge rate (MW)` | Minimum amount of power rate this storage unit may charge. | `0.0` | Yes | Yes
| `Maximum charge rate (MW)` | Maximum amount of power rate this storage unit may charge. | Required | Yes | Yes
| `Minimum discharge rate (MW)` | Minimum amount of power rate this storage unit may discharge. | `0.0` | Yes | Yes
| `Maximum discharge rate (MW)` | Maximum amount of power rate this storage unit may discharge. | Required | Yes | Yes
| `Initial level (MWh)` | Amount of energy this storage unit at time step `-1`, immediately before the planning horizon starts. | `0.0` | No | Yes
| `Last period minimum level (MWh)` | Minimum of energy level this storage unit may contain in the last time step. By default, this value is the same as the last value of `Minimum level (MWh)`. | `Minimum level (MWh)` | No | Yes
| `Last period maximum level (MWh)` | Maximum of energy level this storage unit may contain in the last time step. By default, this value is the same as the last value of `Maximum level (MWh)`. | `Maximum level (MWh)` | No | Yes
#### Example
```json
{
"Storage units": {
"su1": {
"Bus": "b2",
"Maximum level (MWh)": 100.0,
"Charge cost ($/MW)": 2.0,
"Discharge cost ($/MW)": 2.5,
"Maximum charge rate (MW)": 10.0,
"Maximum discharge rate (MW)": 8.0
},
"su2": {
"Bus": "b2",
"Minimum level (MWh)": 10.0,
"Maximum level (MWh)": 100.0,
"Allow simultaneous charging and discharging": false,
"Charge cost ($/MW)": 3.0,
"Discharge cost ($/MW)": 3.5,
"Charge efficiency": 0.8,
"Discharge efficiency": 0.85,
"Loss factor": 0.01,
"Minimum charge rate (MW)": 5.0,
"Maximum charge rate (MW)": 10.0,
"Minimum discharge rate (MW)": 2.0,
"Maximum discharge rate (MW)": 10.0,
"Initial level (MWh)": 70.0,
"Last period minimum level (MWh)": 80.0,
"Last period maximum level (MWh)": 85.0
},
"su3": {
"Bus": "b9",
"Minimum level (MWh)": [10.0, 11.0, 12.0, 13.0],
"Maximum level (MWh)": [100.0, 110.0, 120.0, 130.0],
"Allow simultaneous charging and discharging": [false, false, true, true],
"Charge cost ($/MW)": [2.0, 2.1, 2.2, 2.3],
"Discharge cost ($/MW)": [1.0, 1.1, 1.2, 1.3],
"Charge efficiency": [0.8, 0.81, 0.82, 0.82],
"Discharge efficiency": [0.85, 0.86, 0.87, 0.88],
"Loss factor": [0.01, 0.01, 0.02, 0.02],
"Minimum charge rate (MW)": [5.0, 5.1, 5.2, 5.3],
"Maximum charge rate (MW)": [10.0, 10.1, 10.2, 10.3],
"Minimum discharge rate (MW)": [4.0, 4.1, 4.2, 4.3],
"Maximum discharge rate (MW)": [8.0, 8.1, 8.2, 8.3],
"Initial level (MWh)": 20.0,
"Last period minimum level (MWh)": 21.0,
"Last period maximum level (MWh)": 22.0
}
}
}
```
### Price-sensitive loads
This section describes components in the system which may increase or reduce their energy consumption according to the energy prices. Fixed loads (as described in the `buses` section) are always served, regardless of the price, unless there is significant congestion in the system or insufficient production capacity. Price-sensitive loads, on the other hand, are only served if it is economical to do so.
| Key | Description | Default | Time series? | Uncertain?
| :---------------- | :------------------------------------------------ | :------: | :------------: | :----:
| `Bus` | Bus where the load is located. Multiple price-sensitive loads may be placed at the same bus. | Required | No | Yes
| `Revenue ($/MW)` | Revenue obtained for serving each MW of power to this load. | Required | Yes | Yes
| `Demand (MW)` | Maximum amount of power required by this load. Any amount lower than this may be served. | Required | Yes | Yes
#### Example
```json
{
"Price-sensitive loads": {
"p1": {
"Bus": "b3",
"Revenue ($/MW)": 23.0,
"Demand (MW)": 50.0
}
}
}
```
### Transmission lines
This section describes the characteristics of transmission system, such as its topology and the susceptance of each transmission line.
| Key | Description | Default | Time series? | Uncertain?
| :--------------------- | :----------------------------------------------- | ------- | :------------: | :---:
| `Source bus` | Identifier of the bus where the transmission line originates. | Required | No | Yes
| `Target bus` | Identifier of the bus where the transmission line reaches. | Required | No | Yes
| `Susceptance (S)` | Susceptance of the transmission line (in siemens). | Required | No | Yes
| `Normal flow limit (MW)` | Maximum amount of power (in MW) allowed to flow through the line when the system is in its regular, fully-operational state. | `+inf` | Yes | Yes
| `Emergency flow limit (MW)` | Maximum amount of power (in MW) allowed to flow through the line when the system is in degraded state (for example, after the failure of another transmission line). | `+inf` | Y | Yes
| `Flow limit penalty ($/MW)` | Penalty for violating the flow limits of the transmission line (in $/MW). This is charged per time step. For example, if there is a thermal violation of 1 MW for three time steps, then three times this amount will be charged. | `5000.0` | Yes | Yes
#### Example
```json
{
"Transmission lines": {
"l1": {
"Source bus": "b1",
"Target bus": "b2",
"Susceptance (S)": 29.49686,
"Normal flow limit (MW)": 15000.0,
"Emergency flow limit (MW)": 20000.0,
"Flow limit penalty ($/MW)": 5000.0
}
}
}
```
### Reserves
This section describes the hourly amount of reserves required.
| Key | Description | Default | Time series? | Uncertain?
| :-------------------- | :------------------------------------------------- | --------- | :----: | :---:
| `Type` | Type of reserve product. Must be either "spinning" or "flexiramp". | Required | No | No
| `Amount (MW)` | Amount of reserves required. | Required | Yes | Yes
| `Shortfall penalty ($/MW)` | Penalty for shortage in meeting the reserve requirements (in $/MW). This is charged per time step. Negative value implies reserve constraints must always be satisfied. | `-1` | Yes | Yes
#### Example 1
```json
{
"Reserves": {
"r1": {
"Type": "spinning",
"Amount (MW)": [
57.30552,
53.88429,
51.31838,
50.46307
],
"Shortfall penalty ($/MW)": 5.0
},
"r2": {
"Type": "flexiramp",
"Amount (MW)": [
20.31042,
23.65273,
27.41784,
25.34057
],
}
}
}
```
### Contingencies
This section describes credible contingency scenarios in the optimization, such as the loss of a transmission line or generator.
| Key | Description | Default | Uncertain?
| :-------------------- | :----------------------------------------------- | :--------: | :---:
| `Affected generators` | List of generators affected by this contingency. May be omitted if no generators are affected. | `[]` | Yes
| `Affected lines` | List of transmission lines affected by this contingency. May be omitted if no lines are affected. | `[]` | Yes
#### Example
```json
{
"Contingencies": {
"c1": {
"Affected lines": ["l1", "l2", "l3"],
"Affected generators": ["g1"]
},
"c2": {
"Affected lines": ["l4"]
},
}
}
```
### Additional remarks
#### Time series parameters
Many numerical properties in the JSON file can be specified either as a single floating point number if they are time-independent, or as an array containing exactly `T` elements, if they are time-dependent, where `T` is the number of time steps in the planning horizon. For example, both formats below are valid when `T=3`:
```json
{
"Load (MW)": 800.0,
"Load (MW)": [800.0, 850.0, 730.0]
}
```
The value `T` depends on both `Time horizon (h)` and `Time step (min)`, as the table below illustrates.
Time horizon (h) | Time step (min) | T
:---------------:|:---------------:|:----:
24 | 60 | 24
24 | 15 | 96
24 | 5 | 288
36 | 60 | 36
36 | 15 | 144
36 | 5 | 432
Output Data Format
------------------
The output data format is also JSON-based, but it is not currently documented since we expect it to change significantly in a future version of the package.
Current limitations
-------------------
* Network topology must remain the same for all time periods.
* Only N-1 transmission contingencies are supported. Generator contingencies are not currently supported.
* Time-varying minimum production amounts are not currently compatible with ramp/startup/shutdown limits.
* Flexible ramping products can only be acquired under the `WanHob2016` formulation, which does not support spinning reserves.
* The set of generators must be the same in all scenarios.

View File

@@ -1,380 +0,0 @@
# JSON data format
An instance of the stochastic security-constrained unit commitment (SCUC) problem is composed multiple scenarios. Each scenario should be described in an individual JSON file containing the main section belows. For deterministic instances, a single scenario file, following the same format below, may also be provided. Fields that are allowed to differ among scenarios are marked as "uncertain". Fields that are allowed to be time-dependent are marked as "time series".
- [Parameters](#Parameters)
- [Buses](#Buses)
- [Generators](#Generators)
- [Storage units](#Storage-units)
- [Price-sensitive loads](#Price-sensitive-loads)
- [Transmission lines](#Transmission-lines)
- [Reserves](#Reserves)
- [Contingencies](#Contingencies)
Each section is described in detail below. See [case118/2017-01-01.json.gz](https://axavier.org/UnitCommitment.jl/0.4/instances/matpower/case118/2017-01-01.json.gz) for a complete example.
### Parameters
This section describes system-wide parameters, such as power balance penalty, and optimization parameters, such as the length of the planning horizon and the time.
| Key | Description | Default | Time series? | Uncertain? |
| :----------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------: | :----------: | :--------: |
| `Version` | Version of UnitCommitment.jl this file was written for. Required to ensure that the file remains readable in future versions of the package. If you are following this page to construct the file, this field should equal `0.4`. | Required | No | No |
| `Time horizon (min)` or `Time horizon (h)` | Length of the planning horizon (in minutes or hours). Either `Time horizon (min)` or `Time horizon (h)` is required, but not both. | Required | No | No |
| `Time step (min)` | Length of each time step (in minutes). Must be a divisor of 60 (e.g. 60, 30, 20, 15, etc). | `60` | No | No |
| `Power balance penalty ($/MW)` | Penalty for system-wide shortage or surplus in production (in $/MW). This is charged per time step. For example, if there is a shortage of 1 MW for three time steps, three times this amount will be charged. | `1000.0` | No | Yes |
| `Scenario name` | Name of the scenario. | `"s1"` | No | --- |
| `Scenario weight` | Weight of the scenario. The scenario weight can be any positive real number, that is, it does not have to be between zero and one. The package normalizes the weights to ensure that the probability of all scenarios sum up to one. | 1.0 | No | --- |
#### Example
```json
{
"Parameters": {
"Version": "0.4",
"Time horizon (h)": 4,
"Power balance penalty ($/MW)": 1000.0,
"Scenario name": "s1",
"Scenario weight": 0.5
}
}
```
### Buses
This section describes the characteristics of each bus in the system.
| Key | Description | Default | Time series? | Uncertain? |
| :---------- | :--------------------------------------- | -------- | :----------: | :--------: |
| `Load (MW)` | Fixed load connected to the bus (in MW). | Required | Yes | Yes |
#### Example
```json
{
"Buses": {
"b1": {
"Load (MW)": 0.0
},
"b2": {
"Load (MW)": [26.01527, 24.46212, 23.29725, 22.90897]
}
}
}
```
### Generators
This section describes all generators in the system. Two types of units can be specified:
- **Thermal units:** Units that produce power by converting heat into electrical energy, such as coal and oil power plants. These units use a more complex model, with binary decision variables, and various constraints to enforce ramp rates and minimum up/down time.
- **Profiled units:** Simplified model for units that do not require the constraints mentioned above, only a maximum and minimum power output for each time period. Typically used for renewables and hydro.
#### Thermal Units
| Key | Description | Default | Time series? | Uncertain? |
| :----------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- | :----------: | :--------: |
| `Bus` | Identifier of the bus where this generator is located (string). | Required | No | Yes |
| `Type` | Type of the generator (string). For thermal generators, this must be `Thermal`. | Required | No | No |
| `Production cost curve (MW)` and `Production cost curve ($)` | Parameters describing the piecewise-linear production costs. See below for more details. | Required | Yes | Yes |
| `Startup costs ($)` and `Startup delays (h)` | Parameters describing how much it costs to start the generator after it has been shut down for a certain amount of time. If `Startup costs ($)` and `Startup delays (h)` are set to `[300.0, 400.0]` and `[1, 4]`, for example, and the generator is shut down at time `00:00` (h:min), then it costs \$300 to start up the generator at any time between `01:00` and `03:59`, and \$400 to start the generator at time `04:00` or any time after that. The number of startup cost points is unlimited, and may be different for each generator. Startup delays must be strictly increasing and the first entry must equal `Minimum downtime (h)`. | `[0.0]` and `[1]` | No | Yes |
| `Minimum uptime (h)` | Minimum amount of time the generator must stay operational after starting up (in hours). For example, if the generator starts up at time `00:00` (h:min) and `Minimum uptime (h)` is set to 4, then the generator can only shut down at time `04:00`. | `1` | No | Yes |
| `Minimum downtime (h)` | Minimum amount of time the generator must stay offline after shutting down (in hours). For example, if the generator shuts down at time `00:00` (h:min) and `Minimum downtime (h)` is set to 4, then the generator can only start producing power again at time `04:00`. | `1` | No | Yes |
| `Ramp up limit (MW)` | Maximum increase in production from one time step to the next (in MW). For example, if the generator is producing 100 MW at time step 1 and if this parameter is set to 40 MW, then the generator will produce at most 140 MW at time step 2. | `+inf` | No | Yes |
| `Ramp down limit (MW)` | Maximum decrease in production from one time step to the next (in MW). For example, if the generator is producing 100 MW at time step 1 and this parameter is set to 40 MW, then the generator will produce at least 60 MW at time step 2. | `+inf` | No | Yes |
| `Startup limit (MW)` | Maximum amount of power a generator can produce immediately after starting up (in MW). For example, if `Startup limit (MW)` is set to 100 MW and the unit is off at time step 1, then it may produce at most 100 MW at time step 2. | `+inf` | No | Yes |
| `Shutdown limit (MW)` | Maximum amount of power a generator can produce immediately before shutting down (in MW). Specifically, the generator can only shut down at time step `t+1` if its production at time step `t` is below this limit. | `+inf` | No | Yes |
| `Initial status (h)` | If set to a positive number, indicates the amount of time (in hours) the generator has been on at the beginning of the simulation, and if set to a negative number, the amount of time the generator has been off. For example, if `Initial status (h)` is `-2`, this means that the generator was off since `-02:00` (h:min). The simulation starts at time `00:00`. If `Initial status (h)` is `3`, this means that the generator was on since `-03:00`. A value of zero is not acceptable. | Required | No | No |
| `Initial power (MW)` | Amount of power the generator at time step `-1`, immediately before the planning horizon starts. | Required | No | No |
| `Must run?` | If `true`, the generator should be committed, even if that is not economical (Boolean). | `false` | Yes | Yes |
| `Reserve eligibility` | List of reserve products this generator is eligibe to provide. By default, the generator is not eligible to provide any reserves. | `[]` | No | Yes |
| `Commitment status` | List of commitment status over the time horizon. At time `t`, if `true`, the generator must be commited at that time period; if `false`, the generator must not be commited at that time period. If `null` at time `t`, the generator's commitment status is then decided by the model. By default, the status is a list of `null` values. | `null` | Yes | Yes |
#### Profiled Units
| Key | Description | Default | Time series? | Uncertain? |
| :------------------- | :-------------------------------------------------------------------------------- | :------: | :----------: | :--------: |
| `Bus` | Identifier of the bus where this generator is located (string). | Required | No | Yes |
| `Type` | Type of the generator (string). For profiled generators, this must be `Profiled`. | Required | No | No |
| `Cost ($/MW)` | Cost incurred for serving each MW of power by this generator. | Required | Yes | Yes |
| `Minimum power (MW)` | Minimum amount of power this generator may supply. | `0.0` | Yes | Yes |
| `Maximum power (MW)` | Maximum amount of power this generator may supply. | Required | Yes | Yes |
#### Production costs and limits
Production costs are represented as piecewise-linear curves. Figure 1 shows an example cost curve with three segments, where it costs \$1400, \$1600, \$2200 and \$2400 to generate, respectively, 100, 110, 130 and 135 MW of power. To model this generator, `Production cost curve (MW)` should be set to `[100, 110, 130, 135]`, and `Production cost curve ($)` should be set to `[1400, 1600, 2200, 2400]`.
Note that this curve also specifies the production limits. Specifically, the first point identifies the minimum power output when the unit is operational, while the last point identifies the maximum power output.
```@raw html
<center>
<img src="../../assets/cost_curve.png" style="max-width: 500px"/>
<div><b>Figure 1.</b> Piecewise-linear production cost curve.</div>
<br/>
</center>
```
#### Additional remarks:
- For time-dependent production limits or time-dependent production costs, the usage of nested arrays is allowed. For example, if `Production cost curve (MW)` is set to `[5.0, [10.0, 12.0, 15.0, 20.0]]`, then the unit may generate at most 10, 12, 15 and 20 MW of power during time steps 1, 2, 3 and 4, respectively. The minimum output for all time periods is fixed to at 5 MW.
- There is no limit to the number of piecewise-linear segments, and different generators may have a different number of segments.
- If `Production cost curve (MW)` and `Production cost curve ($)` both contain a single element, then the generator must produce exactly that amount of power when operational. To specify that the generator may produce any amount of power up to a certain limit `P`, the parameter `Production cost curve (MW)` should be set to `[0, P]`.
- Production cost curves must be convex.
#### Example
```json
{
"Generators": {
"gen1": {
"Bus": "b1",
"Type": "Thermal",
"Production cost curve (MW)": [100.0, 110.0, 130.0, 135.0],
"Production cost curve ($)": [1400.0, 1600.0, 2200.0, 2400.0],
"Startup costs ($)": [300.0, 400.0],
"Startup delays (h)": [1, 4],
"Ramp up limit (MW)": 232.68,
"Ramp down limit (MW)": 232.68,
"Startup limit (MW)": 232.68,
"Shutdown limit (MW)": 232.68,
"Minimum downtime (h)": 4,
"Minimum uptime (h)": 4,
"Initial status (h)": 12,
"Initial power (MW)": 115,
"Must run?": false,
"Reserve eligibility": ["r1"]
},
"gen2": {
"Bus": "b5",
"Type": "Thermal",
"Production cost curve (MW)": [0.0, [10.0, 8.0, 0.0, 3.0]],
"Production cost curve ($)": [0.0, 0.0],
"Initial status (h)": -100,
"Initial power (MW)": 0,
"Reserve eligibility": ["r1", "r2"],
"Commitment status": [true, false, null, true]
},
"gen3": {
"Bus": "b6",
"Type": "Profiled",
"Minimum power (MW)": 10.0,
"Maximum power (MW)": 120.0,
"Cost ($/MW)": 100.0
}
}
}
```
### Storage units
This section describes energy storage units in the system which charge and discharge power. The storage units consume power while charging, and generate power while discharging.
| Key | Description | Default | Time series? | Uncertain? |
| :-------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------: | :----------: | :--------: |
| `Bus` | Bus where the storage unit is located. Multiple storage units may be placed at the same bus. | Required | No | Yes |
| `Minimum level (MWh)` | Minimum of energy level this storage unit may contain. | `0.0` | Yes | Yes |
| `Maximum level (MWh)` | Maximum of energy level this storage unit may contain. | Required | Yes | Yes |
| `Allow simultaneous charging and discharging` | If `false`, the storage unit is not allowed to charge and discharge at the same time (Boolean). | `true` | Yes | Yes |
| `Charge cost ($/MW)` | Cost incurred for charging each MW of power into this storage unit. | Required | Yes | Yes |
| `Discharge cost ($/MW)` | Cost incurred for discharging each MW of power from this storage unit. | Required | Yes | Yes |
| `Charge efficiency` | Efficiency rate to charge power into this storage unit. This value must be greater than or equal to `0.0`, and less than or equal to `1.0`. | `1.0` | Yes | Yes |
| `Discharge efficiency` | Efficiency rate to discharge power from this storage unit. This value must be greater than or equal to `0.0`, and less than or equal to `1.0`. | `1.0` | Yes | Yes |
| `Loss factor` | The energy dissipation rate of this storage unit. This value must be greater than or equal to `0.0`, and less than or equal to `1.0`. | `0.0` | Yes | Yes |
| `Minimum charge rate (MW)` | Minimum amount of power rate this storage unit may charge. | `0.0` | Yes | Yes |
| `Maximum charge rate (MW)` | Maximum amount of power rate this storage unit may charge. | Required | Yes | Yes |
| `Minimum discharge rate (MW)` | Minimum amount of power rate this storage unit may discharge. | `0.0` | Yes | Yes |
| `Maximum discharge rate (MW)` | Maximum amount of power rate this storage unit may discharge. | Required | Yes | Yes |
| `Initial level (MWh)` | Amount of energy this storage unit at time step `-1`, immediately before the planning horizon starts. | `0.0` | No | Yes |
| `Last period minimum level (MWh)` | Minimum of energy level this storage unit may contain in the last time step. By default, this value is the same as the last value of `Minimum level (MWh)`. | `Minimum level (MWh)` | No | Yes |
| `Last period maximum level (MWh)` | Maximum of energy level this storage unit may contain in the last time step. By default, this value is the same as the last value of `Maximum level (MWh)`. | `Maximum level (MWh)` | No | Yes |
#### Example
```json
{
"Storage units": {
"su1": {
"Bus": "b2",
"Maximum level (MWh)": 100.0,
"Charge cost ($/MW)": 2.0,
"Discharge cost ($/MW)": 2.5,
"Maximum charge rate (MW)": 10.0,
"Maximum discharge rate (MW)": 8.0
},
"su2": {
"Bus": "b2",
"Minimum level (MWh)": 10.0,
"Maximum level (MWh)": 100.0,
"Allow simultaneous charging and discharging": false,
"Charge cost ($/MW)": 3.0,
"Discharge cost ($/MW)": 3.5,
"Charge efficiency": 0.8,
"Discharge efficiency": 0.85,
"Loss factor": 0.01,
"Minimum charge rate (MW)": 5.0,
"Maximum charge rate (MW)": 10.0,
"Minimum discharge rate (MW)": 2.0,
"Maximum discharge rate (MW)": 10.0,
"Initial level (MWh)": 70.0,
"Last period minimum level (MWh)": 80.0,
"Last period maximum level (MWh)": 85.0
},
"su3": {
"Bus": "b9",
"Minimum level (MWh)": [10.0, 11.0, 12.0, 13.0],
"Maximum level (MWh)": [100.0, 110.0, 120.0, 130.0],
"Allow simultaneous charging and discharging": [false, false, true, true],
"Charge cost ($/MW)": [2.0, 2.1, 2.2, 2.3],
"Discharge cost ($/MW)": [1.0, 1.1, 1.2, 1.3],
"Charge efficiency": [0.8, 0.81, 0.82, 0.82],
"Discharge efficiency": [0.85, 0.86, 0.87, 0.88],
"Loss factor": [0.01, 0.01, 0.02, 0.02],
"Minimum charge rate (MW)": [5.0, 5.1, 5.2, 5.3],
"Maximum charge rate (MW)": [10.0, 10.1, 10.2, 10.3],
"Minimum discharge rate (MW)": [4.0, 4.1, 4.2, 4.3],
"Maximum discharge rate (MW)": [8.0, 8.1, 8.2, 8.3],
"Initial level (MWh)": 20.0,
"Last period minimum level (MWh)": 21.0,
"Last period maximum level (MWh)": 22.0
}
}
}
```
### Price-sensitive loads
This section describes components in the system which may increase or reduce their energy consumption according to the energy prices. Fixed loads (as described in the `buses` section) are always served, regardless of the price, unless there is significant congestion in the system or insufficient production capacity. Price-sensitive loads, on the other hand, are only served if it is economical to do so.
| Key | Description | Default | Time series? | Uncertain? |
| :--------------- | :------------------------------------------------------------------------------------------- | :------: | :----------: | :--------: |
| `Bus` | Bus where the load is located. Multiple price-sensitive loads may be placed at the same bus. | Required | No | Yes |
| `Revenue ($/MW)` | Revenue obtained for serving each MW of power to this load. | Required | Yes | Yes |
| `Demand (MW)` | Maximum amount of power required by this load. Any amount lower than this may be served. | Required | Yes | Yes |
#### Example
```json
{
"Price-sensitive loads": {
"p1": {
"Bus": "b3",
"Revenue ($/MW)": 23.0,
"Demand (MW)": 50.0
}
}
}
```
### Transmission lines
This section describes the characteristics of transmission system, such as its topology and the susceptance of each transmission line.
| Key | Description | Default | Time series? | Uncertain? |
| :-------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | :----------: | :--------: |
| `Source bus` | Identifier of the bus where the transmission line originates. | Required | No | Yes |
| `Target bus` | Identifier of the bus where the transmission line reaches. | Required | No | Yes |
| `Susceptance (S)` | Susceptance of the transmission line (in siemens). | Required | No | Yes |
| `Normal flow limit (MW)` | Maximum amount of power (in MW) allowed to flow through the line when the system is in its regular, fully-operational state. | `+inf` | Yes | Yes |
| `Emergency flow limit (MW)` | Maximum amount of power (in MW) allowed to flow through the line when the system is in degraded state (for example, after the failure of another transmission line). | `+inf` | Y | Yes |
| `Flow limit penalty ($/MW)` | Penalty for violating the flow limits of the transmission line (in $/MW). This is charged per time step. For example, if there is a thermal violation of 1 MW for three time steps, then three times this amount will be charged. | `5000.0` | Yes | Yes |
#### Example
```json
{
"Transmission lines": {
"l1": {
"Source bus": "b1",
"Target bus": "b2",
"Susceptance (S)": 29.49686,
"Normal flow limit (MW)": 15000.0,
"Emergency flow limit (MW)": 20000.0,
"Flow limit penalty ($/MW)": 5000.0
}
}
}
```
### Reserves
This section describes the hourly amount of reserves required.
| Key | Description | Default | Time series? | Uncertain? |
| :------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | :----------: | :--------: |
| `Type` | Type of reserve product. Must be either "spinning" or "flexiramp". | Required | No | No |
| `Amount (MW)` | Amount of reserves required. | Required | Yes | Yes |
| `Shortfall penalty ($/MW)` | Penalty for shortage in meeting the reserve requirements (in $/MW). This is charged per time step. Negative value implies reserve constraints must always be satisfied. | `-1` | Yes | Yes |
#### Example 1
```json
{
"Reserves": {
"r1": {
"Type": "spinning",
"Amount (MW)": [57.30552, 53.88429, 51.31838, 50.46307],
"Shortfall penalty ($/MW)": 5.0
},
"r2": {
"Type": "flexiramp",
"Amount (MW)": [20.31042, 23.65273, 27.41784, 25.34057]
}
}
}
```
### Contingencies
This section describes credible contingency scenarios in the optimization, such as the loss of a transmission line or generator.
| Key | Description | Default | Uncertain? |
| :-------------------- | :------------------------------------------------------------------------------------------------ | :-----: | :--------: |
| `Affected generators` | List of generators affected by this contingency. May be omitted if no generators are affected. | `[]` | Yes |
| `Affected lines` | List of transmission lines affected by this contingency. May be omitted if no lines are affected. | `[]` | Yes |
#### Example
```json
{
"Contingencies": {
"c1": {
"Affected lines": ["l1", "l2", "l3"],
"Affected generators": ["g1"]
},
"c2": {
"Affected lines": ["l4"]
}
}
}
```
### Additional remarks
#### Time series parameters
Many numerical properties in the JSON file can be specified either as a single floating point number if they are time-independent, or as an array containing exactly `T` elements, if they are time-dependent, where `T` is the number of time steps in the planning horizon. For example, both formats below are valid when `T=3`:
```json
{
"Load (MW)": 800.0,
"Load (MW)": [800.0, 850.0, 730.0]
}
```
The value `T` depends on both `Time horizon (h)` and `Time step (min)`, as the table below illustrates.
| Time horizon (h) | Time step (min) | T |
| :--------------: | :-------------: | :-: |
| 24 | 60 | 24 |
| 24 | 15 | 96 |
| 24 | 5 | 288 |
| 36 | 60 | 36 |
| 36 | 15 | 144 |
| 36 | 5 | 432 |
## Current limitations
- Network topology must remain the same for all time periods.
- Only N-1 transmission contingencies are supported. Generator contingencies are not currently supported.
- Time-varying minimum production amounts are not currently compatible with ramp/startup/shutdown limits.
- Flexible ramping products can only be acquired under the `WanHob2016` formulation, which does not support spinning reserves.
- The set of generators must be the same in all scenarios.

View File

@@ -1,289 +0,0 @@
# Benchmark instances
UnitCommitment.jl provides a large collection of benchmark instances collected from the literature and converted to a [common data format](../guides/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 [tutorials](../tutorials/usage.md). Instance files can also be [directly downloaded from our website](https://axavier.org/UnitCommitment.jl/0.4/instances/).
!!! 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.
## MATPOWER
[MATPOWER](https://github.com/MATPOWER/matpower) is an open-source package for solving power flow problems in MATLAB and Octave. It contains a number of power flow test cases, which have been widely used in the power systems literature.
Because most MATPOWER test cases were originally designed for power flow studies, they lack a number of important unit commitment parameters, such as time-varying loads, production cost curves, ramp limits, reserves and initial conditions. The test cases included in UnitCommitment.jl are extended versions of the original MATPOWER test cases, modified as following:
- **Production cost** curves were generated using a data-driven approach, based on publicly available data. More specifically, machine learning models were trained to predict typical production cost curves, for each day of the year, based on a generator's maximum and minimum power output.
- **Load profiles** were generated using a similar data-driven approach.
- **Ramp-up, ramp-down, startup and shutdown rates** were set to a fixed proportion of the generator's maximum output.
- **Minimum reserves** were set to a fixed proportion of the total demand.
- **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 365 variations (`2017-01-01` to `2017-12-31`) corresponding different days of the year.
### MATPOWER/UW-PSTCA
A variety of smaller IEEE test cases, [compiled by University of Washington](http://labs.ece.uw.edu/pstca/), corresponding mostly to small portions of the American Electric Power System in the 1960s.
| Name | Buses | Generators | Lines | Contingencies | References |
| ----------------------------- | ----- | ---------- | ----- | ------------- | -------------- |
| `matpower/case14/2017-01-01` | 14 | 5 | 20 | 19 | [MTPWR, PSTCA] |
| `matpower/case30/2017-01-01` | 30 | 6 | 41 | 38 | [MTPWR, PSTCA] |
| `matpower/case57/2017-01-01` | 57 | 7 | 80 | 79 | [MTPWR, PSTCA] |
| `matpower/case118/2017-01-01` | 118 | 54 | 186 | 177 | [MTPWR, PSTCA] |
| `matpower/case300/2017-01-01` | 300 | 69 | 411 | 320 | [MTPWR, PSTCA] |
### MATPOWER/Polish
Test cases based on the Polish 400, 220 and 110 kV networks, originally provided by **Roman Korab** (Politechnika Śląska) and corrected by the MATPOWER team.
| Name | Buses | Generators | Lines | Contingencies | References |
| --------------------------------- | ----- | ---------- | ----- | ------------- | ---------- |
| `matpower/case2383wp/2017-01-01` | 2383 | 323 | 2896 | 2240 | [MTPWR] |
| `matpower/case2736sp/2017-01-01` | 2736 | 289 | 3504 | 3159 | [MTPWR] |
| `matpower/case2737sop/2017-01-01` | 2737 | 267 | 3506 | 3161 | [MTPWR] |
| `matpower/case2746wop/2017-01-01` | 2746 | 443 | 3514 | 3155 | [MTPWR] |
| `matpower/case2746wp/2017-01-01` | 2746 | 457 | 3514 | 3156 | [MTPWR] |
| `matpower/case3012wp/2017-01-01` | 3012 | 496 | 3572 | 2854 | [MTPWR] |
| `matpower/case3120sp/2017-01-01` | 3120 | 483 | 3693 | 2950 | [MTPWR] |
| `matpower/case3375wp/2017-01-01` | 3374 | 590 | 4161 | 3245 | [MTPWR] |
### MATPOWER/PEGASE
Test cases from the [Pan European Grid Advanced Simulation and State Estimation (PEGASE) project](https://cordis.europa.eu/project/id/211407), describing part of the European high voltage transmission network.
| Name | Buses | Generators | Lines | Contingencies | References |
| ------------------------------------- | ----- | ---------- | ----- | ------------- | --------------------------- |
| `matpower/case89pegase/2017-01-01` | 89 | 12 | 210 | 192 | [JoFlMa16, FlPaCa13, MTPWR] |
| `matpower/case1354pegase/2017-01-01` | 1354 | 260 | 1991 | 1288 | [JoFlMa16, FlPaCa13, MTPWR] |
| `matpower/case2869pegase/2017-01-01` | 2869 | 510 | 4582 | 3579 | [JoFlMa16, FlPaCa13, MTPWR] |
| `matpower/case9241pegase/2017-01-01` | 9241 | 1445 | 16049 | 13932 | [JoFlMa16, FlPaCa13, MTPWR] |
| `matpower/case13659pegase/2017-01-01` | 13659 | 4092 | 20467 | 13932 | [JoFlMa16, FlPaCa13, MTPWR] |
### MATPOWER/RTE
Test cases from the R&D Division at [Reseau de Transport d'Electricite](https://www.rte-france.com) representing the size and complexity of the French very high voltage transmission network.
| Name | Buses | Generators | Lines | Contingencies | References |
| --------------------------------- | ----- | ---------- | ----- | ------------- | ----------------- |
| `matpower/case1888rte/2017-01-01` | 1888 | 296 | 2531 | 1484 | [MTPWR, JoFlMa16] |
| `matpower/case1951rte/2017-01-01` | 1951 | 390 | 2596 | 1497 | [MTPWR, JoFlMa16] |
| `matpower/case2848rte/2017-01-01` | 2848 | 544 | 3776 | 2242 | [MTPWR, JoFlMa16] |
| `matpower/case2868rte/2017-01-01` | 2868 | 596 | 3808 | 2260 | [MTPWR, JoFlMa16] |
| `matpower/case6468rte/2017-01-01` | 6468 | 1262 | 9000 | 6094 | [MTPWR, JoFlMa16] |
| `matpower/case6470rte/2017-01-01` | 6470 | 1306 | 9005 | 6085 | [MTPWR, JoFlMa16] |
| `matpower/case6495rte/2017-01-01` | 6495 | 1352 | 9019 | 6060 | [MTPWR, JoFlMa16] |
| `matpower/case6515rte/2017-01-01` | 6515 | 1368 | 9037 | 6063 | [MTPWR, JoFlMa16] |
## PGLIB-UC Instances
[PGLIB-UC](https://github.com/power-grid-lib/pglib-uc) is a benchmark library curated and maintained by the [IEEE PES Task Force on Benchmarks for Validation of Emerging Power System Algorithms](https://power-grid-lib.github.io/). These test cases have been used in [KnOsWa20].
### PGLIB-UC/California
Test cases based on publicly available data from the California ISO. For more details, see [PGLIB-UC case file overview](https://github.com/power-grid-lib/pglib-uc).
| Name | Buses | Generators | Lines | Contingencies | References |
| ------------------------------------ | ----- | ---------- | ----- | ------------- | ---------- |
| `pglib-uc/ca/2014-09-01_reserves_0` | 1 | 610 | 0 | 0 | [KnOsWa20] |
| `pglib-uc/ca/2014-09-01_reserves_1` | 1 | 610 | 0 | 0 | [KnOsWa20] |
| `pglib-uc/ca/2014-09-01_reserves_3` | 1 | 610 | 0 | 0 | [KnOsWa20] |
| `pglib-uc/ca/2014-09-01_reserves_5` | 1 | 610 | 0 | 0 | [KnOsWa20] |
| `pglib-uc/ca/2014-12-01_reserves_0` | 1 | 610 | 0 | 0 | [KnOsWa20] |
| `pglib-uc/ca/2014-12-01_reserves_1` | 1 | 610 | 0 | 0 | [KnOsWa20] |
| `pglib-uc/ca/2014-12-01_reserves_3` | 1 | 610 | 0 | 0 | [KnOsWa20] |
| `pglib-uc/ca/2014-12-01_reserves_5` | 1 | 610 | 0 | 0 | [KnOsWa20] |
| `pglib-uc/ca/2015-03-01_reserves_0` | 1 | 610 | 0 | 0 | [KnOsWa20] |
| `pglib-uc/ca/2015-03-01_reserves_1` | 1 | 610 | 0 | 0 | [KnOsWa20] |
| `pglib-uc/ca/2015-03-01_reserves_3` | 1 | 610 | 0 | 0 | [KnOsWa20] |
| `pglib-uc/ca/2015-03-01_reserves_5` | 1 | 610 | 0 | 0 | [KnOsWa20] |
| `pglib-uc/ca/2015-06-01_reserves_0` | 1 | 610 | 0 | 0 | [KnOsWa20] |
| `pglib-uc/ca/2015-06-01_reserves_1` | 1 | 610 | 0 | 0 | [KnOsWa20] |
| `pglib-uc/ca/2015-06-01_reserves_3` | 1 | 610 | 0 | 0 | [KnOsWa20] |
| `pglib-uc/ca/2015-06-01_reserves_5` | 1 | 610 | 0 | 0 | [KnOsWa20] |
| `pglib-uc/ca/Scenario400_reserves_0` | 1 | 611 | 0 | 0 | [KnOsWa20] |
| `pglib-uc/ca/Scenario400_reserves_1` | 1 | 611 | 0 | 0 | [KnOsWa20] |
| `pglib-uc/ca/Scenario400_reserves_3` | 1 | 611 | 0 | 0 | [KnOsWa20] |
| `pglib-uc/ca/Scenario400_reserves_5` | 1 | 611 | 0 | 0 | [KnOsWa20] |
### PGLIB-UC/FERC
Test cases based on a publicly available [unit commitment test case produced by the Federal Energy Regulatory Commission](https://www.ferc.gov/industries-data/electric/power-sales-and-markets/increasing-efficiency-through-improved-software-1). For more details, see [PGLIB-UC case file overview](https://github.com/power-grid-lib/pglib-uc).
| Name | Buses | Generators | Lines | Contingencies | References |
| ----------------------------- | ----- | ---------- | ----- | ------------- | -------------------- |
| `pglib-uc/ferc/2015-01-01_hw` | 1 | 935 | 0 | 0 | [KnOsWa20, KrHiOn12] |
| `pglib-uc/ferc/2015-01-01_lw` | 1 | 935 | 0 | 0 | [KnOsWa20, KrHiOn12] |
| `pglib-uc/ferc/2015-02-01_hw` | 1 | 935 | 0 | 0 | [KnOsWa20, KrHiOn12] |
| `pglib-uc/ferc/2015-02-01_lw` | 1 | 935 | 0 | 0 | [KnOsWa20, KrHiOn12] |
| `pglib-uc/ferc/2015-03-01_hw` | 1 | 935 | 0 | 0 | [KnOsWa20, KrHiOn12] |
| `pglib-uc/ferc/2015-03-01_lw` | 1 | 935 | 0 | 0 | [KnOsWa20, KrHiOn12] |
| `pglib-uc/ferc/2015-04-01_hw` | 1 | 979 | 0 | 0 | [KnOsWa20, KrHiOn12] |
| `pglib-uc/ferc/2015-04-01_lw` | 1 | 979 | 0 | 0 | [KnOsWa20, KrHiOn12] |
| `pglib-uc/ferc/2015-05-01_hw` | 1 | 979 | 0 | 0 | [KnOsWa20, KrHiOn12] |
| `pglib-uc/ferc/2015-05-01_lw` | 1 | 979 | 0 | 0 | [KnOsWa20, KrHiOn12] |
| `pglib-uc/ferc/2015-06-01_hw` | 1 | 979 | 0 | 0 | [KnOsWa20, KrHiOn12] |
| `pglib-uc/ferc/2015-06-01_lw` | 1 | 979 | 0 | 0 | [KnOsWa20, KrHiOn12] |
| `pglib-uc/ferc/2015-07-01_hw` | 1 | 979 | 0 | 0 | [KnOsWa20, KrHiOn12] |
| `pglib-uc/ferc/2015-07-01_lw` | 1 | 979 | 0 | 0 | [KnOsWa20, KrHiOn12] |
| `pglib-uc/ferc/2015-08-01_hw` | 1 | 979 | 0 | 0 | [KnOsWa20, KrHiOn12] |
| `pglib-uc/ferc/2015-08-01_lw` | 1 | 979 | 0 | 0 | [KnOsWa20, KrHiOn12] |
| `pglib-uc/ferc/2015-09-01_hw` | 1 | 979 | 0 | 0 | [KnOsWa20, KrHiOn12] |
| `pglib-uc/ferc/2015-09-01_lw` | 1 | 979 | 0 | 0 | [KnOsWa20, KrHiOn12] |
| `pglib-uc/ferc/2015-10-01_hw` | 1 | 935 | 0 | 0 | [KnOsWa20, KrHiOn12] |
| `pglib-uc/ferc/2015-10-01_lw` | 1 | 935 | 0 | 0 | [KnOsWa20, KrHiOn12] |
| `pglib-uc/ferc/2015-11-02_hw` | 1 | 935 | 0 | 0 | [KnOsWa20, KrHiOn12] |
| `pglib-uc/ferc/2015-11-02_lw` | 1 | 935 | 0 | 0 | [KnOsWa20, KrHiOn12] |
| `pglib-uc/ferc/2015-12-01_hw` | 1 | 935 | 0 | 0 | [KnOsWa20, KrHiOn12] |
| `pglib-uc/ferc/2015-12-01_lw` | 1 | 935 | 0 | 0 | [KnOsWa20, KrHiOn12] |
### PGLIB-UC/RTS-GMLC
[RTS-GMLC](https://github.com/GridMod/RTS-GMLC) is an updated version of the RTS-96 test system produced by the United States Department of Energy's [Grid Modernization Laboratory Consortium](https://gmlc.doe.gov/). The PGLIB-UC/RTS-GMLC instances are modified versions of the original RTS-GMLC instances, with modified ramp-rates and without a transmission network. For more details, see [PGLIB-UC case file overview](https://github.com/power-grid-lib/pglib-uc).
| Name | Buses | Generators | Lines | Contingencies | References |
| ------------------------------ | ----- | ---------- | ----- | ------------- | ---------- |
| `pglib-uc/rts_gmlc/2020-01-27` | 1 | 154 | 0 | 0 | [BaBlEh19] |
| `pglib-uc/rts_gmlc/2020-02-09` | 1 | 154 | 0 | 0 | [BaBlEh19] |
| `pglib-uc/rts_gmlc/2020-03-05` | 1 | 154 | 0 | 0 | [BaBlEh19] |
| `pglib-uc/rts_gmlc/2020-04-03` | 1 | 154 | 0 | 0 | [BaBlEh19] |
| `pglib-uc/rts_gmlc/2020-05-05` | 1 | 154 | 0 | 0 | [BaBlEh19] |
| `pglib-uc/rts_gmlc/2020-06-09` | 1 | 154 | 0 | 0 | [BaBlEh19] |
| `pglib-uc/rts_gmlc/2020-07-06` | 1 | 154 | 0 | 0 | [BaBlEh19] |
| `pglib-uc/rts_gmlc/2020-08-12` | 1 | 154 | 0 | 0 | [BaBlEh19] |
| `pglib-uc/rts_gmlc/2020-09-20` | 1 | 154 | 0 | 0 | [BaBlEh19] |
| `pglib-uc/rts_gmlc/2020-10-27` | 1 | 154 | 0 | 0 | [BaBlEh19] |
| `pglib-uc/rts_gmlc/2020-11-25` | 1 | 154 | 0 | 0 | [BaBlEh19] |
| `pglib-uc/rts_gmlc/2020-12-23` | 1 | 154 | 0 | 0 | [BaBlEh19] |
## OR-LIB/UC
[OR-LIB](http://people.brunel.ac.uk/~mastjjb/jeb/info.html) is a collection of test data sets for a variety of operations research problems, including unit commitment. The UC instances in OR-LIB are synthetic instances generated by a [random problem generator](http://groups.di.unipi.it/optimize/Data/UC.html) developed by the [Operations Research Group at University of Pisa](http://groups.di.unipi.it/optimize/). These test cases have been used in [FrGe06] and many other publications.
| Name | Hours | Buses | Generators | Lines | Contingencies | References |
| ------------------- | ----- | ----- | ---------- | ----- | ------------- | --------------- |
| `or-lib/10_0_1_w` | 24 | 1 | 10 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/10_0_2_w` | 24 | 1 | 10 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/10_0_3_w` | 24 | 1 | 10 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/10_0_4_w` | 24 | 1 | 10 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/10_0_5_w` | 24 | 1 | 10 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/20_0_1_w` | 24 | 1 | 20 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/20_0_2_w` | 24 | 1 | 20 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/20_0_3_w` | 24 | 1 | 20 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/20_0_4_w` | 24 | 1 | 20 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/20_0_5_w` | 24 | 1 | 20 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/50_0_1_w` | 24 | 1 | 50 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/50_0_2_w` | 24 | 1 | 50 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/50_0_3_w` | 24 | 1 | 50 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/50_0_4_w` | 24 | 1 | 50 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/50_0_5_w` | 24 | 1 | 50 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/75_0_1_w` | 24 | 1 | 75 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/75_0_2_w` | 24 | 1 | 75 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/75_0_3_w` | 24 | 1 | 75 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/75_0_4_w` | 24 | 1 | 75 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/75_0_5_w` | 24 | 1 | 75 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/100_0_1_w` | 24 | 1 | 100 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/100_0_2_w` | 24 | 1 | 100 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/100_0_3_w` | 24 | 1 | 100 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/100_0_4_w` | 24 | 1 | 100 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/100_0_5_w` | 24 | 1 | 100 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/150_0_1_w` | 24 | 1 | 150 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/150_0_2_w` | 24 | 1 | 150 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/150_0_3_w` | 24 | 1 | 150 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/150_0_4_w` | 24 | 1 | 150 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/150_0_5_w` | 24 | 1 | 150 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/200_0_10_w` | 24 | 1 | 200 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/200_0_11_w` | 24 | 1 | 200 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/200_0_12_w` | 24 | 1 | 200 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/200_0_1_w` | 24 | 1 | 200 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/200_0_2_w` | 24 | 1 | 200 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/200_0_3_w` | 24 | 1 | 200 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/200_0_4_w` | 24 | 1 | 200 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/200_0_5_w` | 24 | 1 | 200 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/200_0_6_w` | 24 | 1 | 200 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/200_0_7_w` | 24 | 1 | 200 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/200_0_8_w` | 24 | 1 | 200 | 0 | 0 | [ORLIB, FrGe06] |
| `or-lib/200_0_9_w` | 24 | 1 | 200 | 0 | 0 | [ORLIB, FrGe06] |
## Tejada19
Test cases used in [TeLuSa19]. These instances are similar to OR-LIB/UC, in the sense that they use the same random problem generator, but are much larger.
| Name | Hours | Buses | Generators | Lines | Contingencies | References |
| ----------------------- | ----- | ----- | ---------- | ----- | ------------- | ---------- |
| `tejada19/UC_24h_214g` | 24 | 1 | 214 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_24h_250g` | 24 | 1 | 250 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_24h_290g` | 24 | 1 | 290 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_24h_480g` | 24 | 1 | 480 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_24h_505g` | 24 | 1 | 505 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_24h_623g` | 24 | 1 | 623 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_24h_647g` | 24 | 1 | 647 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_24h_836g` | 24 | 1 | 836 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_24h_850g` | 24 | 1 | 850 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_24h_918g` | 24 | 1 | 918 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_24h_931g` | 24 | 1 | 931 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_24h_940g` | 24 | 1 | 940 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_24h_957g` | 24 | 1 | 957 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_24h_959g` | 24 | 1 | 959 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_24h_1069g` | 24 | 1 | 1069 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_24h_1130g` | 24 | 1 | 1130 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_24h_1376g` | 24 | 1 | 1376 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_24h_1393g` | 24 | 1 | 1393 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_24h_1577g` | 24 | 1 | 1577 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_24h_1615g` | 24 | 1 | 1615 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_24h_1632g` | 24 | 1 | 1632 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_24h_1768g` | 24 | 1 | 1768 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_24h_1804g` | 24 | 1 | 1804 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_24h_1820g` | 24 | 1 | 1820 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_24h_1823g` | 24 | 1 | 1823 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_24h_1888g` | 24 | 1 | 1888 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_168h_36g` | 168 | 1 | 36 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_168h_38g` | 168 | 1 | 38 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_168h_40g` | 168 | 1 | 40 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_168h_53g` | 168 | 1 | 53 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_168h_58g` | 168 | 1 | 58 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_168h_59g` | 168 | 1 | 59 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_168h_72g` | 168 | 1 | 72 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_168h_84g` | 168 | 1 | 84 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_168h_86g` | 168 | 1 | 86 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_168h_88g` | 168 | 1 | 88 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_168h_93g` | 168 | 1 | 93 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_168h_105g` | 168 | 1 | 105 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_168h_110g` | 168 | 1 | 110 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_168h_125g` | 168 | 1 | 125 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_168h_130g` | 168 | 1 | 130 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_168h_131g` | 168 | 1 | 131 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_168h_140g` | 168 | 1 | 140 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_168h_165g` | 168 | 1 | 165 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_168h_175g` | 168 | 1 | 175 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_168h_179g` | 168 | 1 | 179 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_168h_188g` | 168 | 1 | 188 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_168h_192g` | 168 | 1 | 192 | 0 | 0 | [TeLuSa19] |
| `tejada19/UC_168h_199g` | 168 | 1 | 199 | 0 | 0 | [TeLuSa19] |
## References
- [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)
- [KrHiOn12] **Eric Krall, Michael Higgins and Richard P. ONeill.** "RTO unit commitment test system." Federal Energy Regulatory Commission. Available at: <https://www.ferc.gov/industries-data/electric/power-sales-and-markets/increasing-efficiency-through-improved-software-1> (Accessed: Nov 14, 2020)
- [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 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.** "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)
- [PSTCA] **University of Washington, Dept. of Electrical Engineering.** "Power Systems Test Case Archive". Available at: <http://www.ee.washington.edu/research/pstca/> (Accessed: Nov 14, 2020)
- [ORLIB] **J.E.Beasley.** "OR-Library: distributing test problems by electronic mail", Journal of the Operational Research Society 41(11) (1990). [DOI: 10.2307/2582903](https://doi.org/10.2307/2582903)
- [FrGe06] **A. Frangioni, C. Gentile.** "Solving nonlinear single-unit commitment problems with ramping constraints" Operations Research 54(4), p. 767 - 775, 2006. [DOI: 10.1287/opre.1060.0309](https://doi.org/10.1287/opre.1060.0309)
- [TeLuSa19] **D. A. Tejada-Arango, S. Lumbreras, P. Sanchez-Martin and A. Ramos.** "Which Unit-Commitment Formulation is Best? A Systematic Comparison," in IEEE Transactions on Power Systems. [DOI: 10.1109/TPWRS.2019.2962024](https://ieeexplore.ieee.org/document/8941313/).

View File

@@ -1,78 +0,0 @@
JuMP Model
==========
In this page, we describe the JuMP optimization model produced by the function `build_model`. A detailed understanding of this model is not necessary if you are just interested in using the package to solve some standard unit commitment cases, but it may be useful, for example, if you need to solve a slightly different problem, with additional variables and constraints. The notation in this page generally follows [KnOsWa20].
Decision variables
------------------
UC.jl models the security-constrained unit commitment problem as a two-stage stochastic program. In this approach, some of the decision variables are *first-stage decisions*, which are taken before the uncertainty is realized and must therefore be the same across all scenarios, while the remaining variables are *second-stage decisions*, which can attain a different values in each scenario. In the current version of the package, all binary variables (which model commitment decisions of thermal units) are first-stage decisions and all continuous variables are second-stage decisions.
!!! note
UC.jl treats deterministic SCUC instances as a special case of the stochastic problem in which there is only one scenario, named `"s1"` by default. To access second-stage decisions, therefore, you must provide this scenario name as the value for `sn`. For example, `model[:prod_above]["s1", g, t]`.
### Generators
In this section, we describe the decision variables associated with the generators, which include both thermal units (e.g., natural gas-fired power plant) and profiled units (e.g., wind turbine).
#### Thermal Units
Name | Description | Unit | Stage
:-----|:-------------|:------: | :------:
`is_on[g,t]` | True if generator `g` is on at time `t`. | Binary | 1
`switch_on[g,t]` | True is generator `g` switches on at time `t`. | Binary| 1
`switch_off[g,t]` | True if generator `g` switches off at time `t`. | Binary| 1
`startup[g,t,s]` | True if generator `g` switches on at time `t` incurring start-up costs from start-up category `s`. | Binary| 1
`prod_above[sn,g,t]` | Amount of power produced by generator `g` above its minimum power output at time `t` in scenario `sn`. For example, if the minimum power of generator `g` is 100 MW and `g` is producing 115 MW of power at time `t` in scenario `sn`, then `prod_above[sn,g,t]` equals `15.0`. | MW | 2
`segprod[sn,g,t,k]` | Amount of power from piecewise linear segment `k` produced by generator `g` at time `t` in scenario `sn`. For example, if cost curve for generator `g` is defined by the points `(100, 1400)`, `(110, 1600)`, `(130, 2200)` and `(135, 2400)`, and if the generator is producing 115 MW of power at time `t` in scenario `sn`, then `segprod[sn,g,t,:]` equals `[10.0, 5.0, 0.0]`.| MW | 2
`reserve[sn,r,g,t]` | Amount of reserve `r` provided by unit `g` at time `t` in scenario `sn`. | MW | 2
!!! warning
The first-stage decision variables of the JuMP model are `is_on[g,t]`, `switch_on[g,t]`, `switch_off[g,t]`, and `startup[g,t,s]`. As such, the dictionaries corresponding to these variables do not include the scenario index in their keys. In contrast, all other variables of the created JuMP model are allowed to obtain a different value in each scenario and are thus modeled as second-stage decision variables. Accordingly, the dictionaries of all second-stage decision variables have the scenario index in their keys. This is true even if the model is created to solve the deterministic SCUC, in which case the default scenario index `s1` is included in the dictionary key.
#### Profiled Units
Name | Description | Unit | Stage
:-----|:-------------|:------: | :------:
`prod_profiled[s,t]` | Amount of power produced by profiled unit `g` at time `t`. | MW | 2
### Buses
Name | Description | Unit | Stage
:-----|:-------------|:------:| :------:
`net_injection[sn,b,t]` | Net injection at bus `b` at time `t` in scenario `sn`. | MW | 2
`curtail[sn,b,t]` | Amount of load curtailed at bus `b` at time `t` in scenario `sn`. | MW | 2
### Price-sensitive loads
Name | Description | Unit | Stage
:-----|:-------------|:------:| :------:
`loads[sn,s,t]` | Amount of power served to price-sensitive load `s` at time `t` in scenario `sn`. | MW | 2
### Transmission lines
Name | Description | Unit | Stage
:-----|:-------------|:------:| :------:
`flow[sn,l,t]` | Power flow on line `l` at time `t` in scenario `sn`. | MW | 2
`overflow[sn,l,t]` | Amount of flow above the limit for line `l` at time `t` in scenario `sn`. | MW | 2
!!! warning
Since transmission and N-1 security constraints are enforced in a lazy way, most of the `flow[l,t]` variables are never added to the model. Accessing `model[:flow][sn,l,t]` without first checking that the variable exists will likely generate an error.
Objective function
------------------
TODO
Constraints
-----------
TODO

View File

@@ -1,618 +0,0 @@
# Problem definition
The **Security-Constrained Unit Commitment Problem** (SCUC) is formulated in
UC.jl as a two-stage stochastic mixed-integer linear optimization problem that
aims to find the minimum-cost schedule for electricity generation while
satisfying various physical, operational and economic constraints. In its most
basic form, the problem is composed by:
- A set of generators, which produce power, at a given cost;
- A set of loads, which consume power;
- A transmission network, which delivers power from generators to the loads.
In addition to the basic components above, SCUC also include a wide variety of
additional components, such as _energy storage devices_, _reserves_ and _network
interfaces_, to name a few. On this page, we present a complete definition of
the problem, as modeled in UC.jl. Please note that different sources in the
literature may have significantly different definitions and assumptions.
!!! note
UC.jl treats deterministic SCUC instances as a special case of the stochastic problem in which there is only one scenario, named `"s1"` by default. To access second-stage decisions, therefore, you must provide this scenario name as the value for `s`. For example, `model[:prod_above]["s1", g, t]`.
!!! warning
The problem definition presented in this page is mathematically equivalent to the one solved by UC.jl. However, some constraints (ramping, piecewise-linear costs and start-up costs) have been simplified in this page for clarity. The set of constraints actually enforced by UC.jl better describes the convex hull of the problem and leads to better computational performance, but it is much more complex to describe. For further details, we refer to the package's source code and associated references.
## 1. General modeling assumptions
- **Time discretization:** SCUC is a multi-period problem, with decisions
typically covering a 24-hour or 36-hour time window. UC.jl assumes that this
time window is discretized into time steps of fixed length. The number of time
steps, as well as the duration of each time step, are configurable. In the
equations below, the set of time steps is denoted by $T=\{1,2,\ldots,|T|\}$.
- **Decision under uncertainty:** SCUC is a two-stage stochastic problem. In the
first stage, we must decide the _commitment status_ of all thermal generators.
In the second stage, we determine the remaining decision variables, such power
output of all generators, the operation of energy storage devices and load
shedding. Stochasticity is modeled through a discrete number of scenarios
$s \in S$, each with given probability $p(S)$. The goal is to minimize the
minimum expected cost.
## 2. Thermal generators
A _thermal generator_ is a power generation unit that converts thermal energy,
typically from the combustion of coal, natural gas or oil, into electrical
energy. Scheduling thermal generators is particularly complex due to their
operational characteristics, including minimum up and down times, ramping rates,
and start-up and shutdown limits.
### Important concepts
- **Commitment, power output and startup costs:** Thermal generators can either
be online (on) or offline (off). When a thermal generator is on, it can
produce between a minimum and a maximum amount of power; when it is off, it
cannot produce any power. Switching a generator on incurs a startup cost,
which depends on how long the unit has been offline. More precisely, each
thermal generator $g$ has a number $K^{start}_g$ of startup categories (e.g.,
cold, warm and hot). Each category $k$ has a corresponding startup cost
$Z^{\text{start}}_{gk}$, and is available only if the unit has spent at most
$M^{\text{delay}}_{gk}$ time steps offline.
- **Piecewise-linear production cost curve:** Besides startup costs, thermal
generators also incur production costs based on their power output. The
relationship between production cost and power output is not a linear, but a
convex curve, which is simplified using a piecewise-linear approximation. For
this purpose, each thermal generator $g$ has a number $K^{\text{cost}}_g$ of
piecewise-linear segments and its power output $y^{\text{prod-above}}_{gts}$
are broken down into
$\sum_{k=1}^{K^{\text{cost}}_g} y^{\text{seg-prod}}_{gtks}$, so that
production costs can be more easily calculated.
- **Ramping, minimum up/down:** Due to physical and operational limits, such as
thermal inertia and mechanical stress, thermal generators cannot vary their
power output too dramatically from one time period to the next. Similarly,
thermal generators cannot switch on and off too frequently; after switching on
or off, units must remain at that state for a minimum specified number of time
steps.
- **Startup and shutdown limit:** A thermal generator cannot shut off if its
output power level in the immediately preceding time step is very high (above
a specified value); the unit must first ramp down, over potentially multiple
time steps, and only then shut off. Similarly, the unit cannot produce a very
large amount of power (above a specified limit) immediately after starting up;
it must ramp up over potentially multiple time steps.
- **Initial status:** The optimization process finds optimal commitment status
and power output level for all thermal generators starting at time period 1.
Many constraints, however, require knowledge of previous time periods (0, -1,
-2, ...) which are not part of the optimization model. For this reason, part
of the input data is the initial power output $M^{\text{init-power}}_{g}$ of
unit $g$ (that is, the output at time 0) and the initial status
$M^{\text{init-status}}_{g}$ of unit g (how many time steps has it been
online/offline at time time 0). If $M^{\text{init-status}}_{g}$ is positive,
its magnitude indicates how many time periods has the unit been online; and if
negative, how has it been offline.
- **Must-run:** Due to various factors, including reliability considerations,
some units must remain operational regardless of whether it is economical for
them to do so. Must-run constraints are used to enforce such requirements.
### Sets and constants
| Symbol | Unit | Description |
| :------------------------------ | :----- | :----------------------------------------------------------------------------------------- |
| $K^{cost}_g$ | | Number of piecewise linear segments in the production cost curve. |
| $K^{start}_g$ | | Number of startup categories (e.g. cold, warm, hot). |
| $M^{\text{delay}}_{gk}$ | | Delay for startup category $k$. |
| $M^{\text{init-power}}_{g}$ | MW | Initial power output of unit $g$. |
| $M^{\text{init-status}}_{g}$ | | Initial status of unit $g$. |
| $M^{\text{min-up}}_{g}$ | | Minimum amount of time $g$ must stay on after switching on. |
| $M^{\text{must-run}}_{gt}$ | Binary | One if unit $g$ must be on at time $t$. |
| $M^{\text{pmax}}_{gt}$ | MW | Maximum power output at time $t$. |
| $M^{\text{pmin}}_{gt}$ | MW | Minimum power output at time $t$. |
| $M^{\text{ramp-down}}_{g}$ | MW | Ramp down limit. |
| $M^{\text{ramp-up}}_{g}$ | MW | Ramp up limit. |
| $M^{\text{seg-pmax}}_{gtks}$ | MW | Maximum power output for piecewise-linear segment $k$ at time $t$ and scenario $s$. |
| $M^{\text{shutdown-limit}}_{g}$ | MW | Maximum power unit $g$ produces immediately before shutting down |
| $M^{\text{startup-limit}}_{g}$ | MW | Maximum power unit $g$ produces immediately after starting up |
| $R_g$ | | Set of spinning reserves that may be served by $g$. |
| $Z^{\text{pmin}}_{gt}$ | \$ | Cost to keep $g$ operational at time $t$ generating at minimum power. |
| $Z^{\text{pvar}}_{gtks}$ | \$/MW | Cost for unit $g$ to produce 1 MW of power under piecewise-linear segment $k$ at time $t$. |
| $Z^{\text{start}}_{gk}$ | \$ | Cost to start unit $g$ at startup category $k$. |
| $G^\text{therm}$ | | Set of thermal generators. |
### Decision variables
| Symbol | JuMP name | Description | Unit | Stage |
| :---------------------------- | :------------------ | :-------------------------------------------------------------------------------------------- | :----- | :---- |
| $x^{\text{is-on}}_{gt}$ | `is_on[g,t]` | One if generator $g$ is on at time $t$. | Binary | 1 |
| $x^{\text{switch-on}}_{gt}$ | `switch_on[g,t]` | One if generator $g$ switches on at time $t$. | Binary | 1 |
| $x^{\text{switch-off}}_{gt}$ | `switch_off[g,t]` | One if generator $g$ switches off at time $t$. | Binary | 1 |
| $x^{\text{start}}_{gtk}$ | `startup[g,t,s]` | One if generator $g$ starts up at time $t$ under startup category $k$. | Binary | 1 |
| $y^{\text{prod-above}}_{gts}$ | `prod_above[s,g,t]` | Amount of power produced by $g$ at time $t$ in scenario $s$ above the minimum power. | MW | 2 |
| $y^{\text{seg-prod}}_{gtks}$ | `segprod[s,g,t,k]` | Amount of power produced by $g$ at time $t$ in piecewise-linear segment $k$ and scenario $s$. | MW | 2 |
| $y^{\text{res}}_{grts}$ | `reserve[s,r,g,t]` | Amount of spinning reserve $r$ supplied by $g$ at time $t$ in scenario $s$. | MW | 2 |
### Objective function terms
- Production costs:
```math
\sum_{g \in G^\text{therm}} \sum_{t \in T} x^{\text{is-on}}_{gt} Z^{\text{pmin}}_{gt}
+ \sum_{s \in S} p(s) \left[
\sum_{g \in G^\text{therm}} \sum_{t \in T} \sum_{k=1}^{K^{cost}_g}
y^{\text{seg-prod}}_{gtks} Z^{\text{pvar}}_{gtks}
\right]
```
- Start-up costs:
```math
\sum_{g \in G} \sum_{t \in T} \sum_{k=1}^{K^{start}_g} x^{\text{start}}_{gtk} Z^{\text{start}}_{gk}
```
### Constraints
- Some units must remain on, even if it is not economical for them to do so:
```math
x^{\text{is-on}}_{gt} \geq M^{\text{must-run}}_{gt}
```
- After switching on, unit must remain on for some amount of time
(`eq_min_uptime[g,t]`):
```math
\sum_{i=max(1,t-M^{\text{min-up}}_{g}+1)}^t x^{\text{switch-on}}_{gi} \leq x^{\text{is-on}}_{gt}
```
- Same as above, but covering the initial time steps (`eq_min_uptime[g,0]`):
```math
\sum_{i=1}^{min(T,M^{\text{min-up}}_{g}-M^{\text{init-status}}_{g})} x^{\text{switch-off}}_{gi} = 0 \; \text{ if } \; M^{\text{init-status}}_{g} > 0
```
- After switching off, unit must remain offline for some amount of time
(`eq_min_downtime[g,t]`):
```math
\sum_{i=max(1,t-M^{\text{min-down}}_{g}+1)}^t x^{\text{switch-off}}_{gi} \leq 1 - x^{\text{is-on}}_{gt}
```
- Same as above, but covering the initial time steps (`eq_min_downtime[g,0]`):
```math
\sum_{i=1}^{min(T,M^{\text{min-down}}_{g}+M^{\text{init-status}}_{g})} x^{\text{switch-on}}_{gi} = 0 \; \text{ if } \; M^{\text{init-status}}_{g} < 0
```
- If the unit switches on, it must choose exactly one startup category
(`eq_startup_choose[g,t]`):
```math
x^{\text{switch-on}}_{gt} = \sum_{k=1}^{K^{start}_g} x^{\text{start}}_{gtk}
```
- If unit has not switched off in the last "delay" time periods, then startup
category is forbidden (`eq_startup_restrict[g,t,s]`). The last startup
category is always allowed. In the equation below, $L^{\text{start}}_{gtk}=1$
if category should be allowed based on initial status.
```math
x^{\text{start}}_{gtk} \leq L^{\text{start}}_{gtk} + \sum_{i=min\left(1,t - M^{\text{delay}}_{g,k+1} + 1\right)}^{t - M^{\text{delay}}_{kg}} x^{\text{switch-off}}_{gi}
```
- Link the binary variables together (`eq_binary_link[g,t]`):
```math
\begin{align*}
& x^{\text{is-on}}_{gt} - x^{\text{is-on}}_{g,t-1} = x^{\text{switch-on}}_{gt} - x^{\text{switch-off}}_{gt} & \forall t > 1 \\
\end{align*}
```
- Cannot switch on and off at the same time (`eq_switch_on_off[g,t]`):
```math
x^{\text{switch-on}}_{gt} + x^{\text{switch-off}}_{gt} \leq 1
```
- If the unit is off, it cannot produce power or provide reserves. If it is on,
it must to so within the specified production limits (`eq_prod_limit[s,g,t]`):
```math
y^{\text{prod-above}}_{gts} + \sum_{r \in R_g} y^{\text{res}}_{grts} \leq
(M^{\text{pmax}}_{gt} - M^{\text{pmin}}_{gt}) x^{\text{is-on}}_{gt}
```
- Break down the "production above" variable into smaller "segment production"
variables, to simplify the objective function (`eq_prod_above_def[s,g,t]`):
```math
y^{\text{prod-above}}_{gts} = \sum_{k=1}^{K^{cost}_g} y^{\text{seg-prod}}_{gtks}
```
- Impose upper limit on segment production variables
(`eq_segprod_limit[s,g,t,k]`):
```math
0 \leq y^{\text{seg-prod}}_{gtks} \leq M^{\text{seg-pmax}}_{gtks}
```
- Unit cannot increase its production too quickly (`eq_ramp_up[s,g,t]`):
```math
y^{\text{prod-above}}_{gts} + \sum_{r \in R_g} y^{\text{res}}_{grts} \leq
y^{\text{prod-above}}_{g,t-1,s} + M^{\text{ramp-up}}_{g}
```
- Same as above, for initial time (`eq_ramp_up[s,g,1]`):
```math
y^{\text{prod-above}}_{g,1,s} + \sum_{r \in R_g} y^{\text{res}}_{gr,1,s} \leq
\left(M^{\text{init-power}}_{g} - M^{\text{pmin}}_{gt}\right) + M^{\text{ramp-up}}_{g}
```
- Unit cannot decrease its production too quickly (`eq_ramp_down[s,g,t]`):
```math
y^{\text{prod-above}}_{gts} \geq
y^{\text{prod-above}}_{g,t-1,s} - M^{\text{ramp-down}}_{g}
```
- Same as above, for initial time (`eq_ramp_down[s,g,1]`):
```math
y^{\text{prod-above}}_{g,1,s} \geq
\left(M^{\text{init-power}}_{g} - M^{\text{pmin}}_{gt}\right) - M^{\text{ramp-down}}_{g}
```
- Unit cannot produce excessive amount of power immediately after starting up
(`eq_startup_limit[s,g,t]`):
```math
y^{\text{prod-above}}_{gts} + \sum_{r \in R_g} y^{\text{res}}_{grts} \leq
(M^{\text{pmax}}_{gt} - M^{\text{pmin}}_{gt}) x^{\text{is-on}}_{gt} -
max\left\{0,M^{\text{pmax}}_{gt} - M^{\text{startup-limit}}_{g}\right\}
x^{\text{switch-on}}_{gt}
```
- Unit cannot shutoff it it's producing too much power
(`eq_shutdown_limit[s,g,t]`):
```math
y^{\text{prod-above}}_{gts} \leq
(M^{\text{pmax}}_{gt} - M^{\text{pmin}}_{gt}) x^{\text{is-on}}_{gt} -
max\left\{0,M^{\text{pmax}}_{gt} - M^{\text{shutdown-limit}}_{g}\right\}
x^{\text{switch-off}}_{g,t+1}
```
## 3. Profiled generators
A _profiled generator_ is a simplified generator model that can be used to
represent renewable energy resources, including wind, solar and hydro. Unlike
thermal generators, which can be either on or off, profiled generators do not
have status variables; the only optimization decision is on their power output
level, which must remain between minimum and maximum time-varying amounts.
Production cost curves for profiled generators are linear, making them again
much simpler than thermal units.
### Constants
| Symbol | Unit | Description |
| :---------------------- | :---- | :------------------------------------------------- |
| $M^{\text{pmax}}_{sgt}$ | MW | Maximum power output at time $t$ and scenario $s$. |
| $M^{\text{pmin}}_{sgt}$ | MW | Minimum power output at time $t$ and scenario $s$. |
| $Z^{\text{pvar}}_{sgt}$ | \$/MW | Generation cost at time $t$ and scenario $s$. |
### Decision variables
| Symbol | JuMP name | Unit | Description | Stage |
| :-------------------- | :--------------------- | :--- | :------------------------------------------------------------ | :---- |
| $y^\text{prod}_{sgt}$ | `prod_profiled[s,g,t]` | MW | Amount of power produced by $g$ in time $t$ and scenario $s$. | 2 |
### Objective function terms
- Production cost:
```math
\sum_{s \in S} p(s) \left[
\sum_{t \in T} y^\text{prod}_{sgt} Z^{\text{pvar}}_{sgt}
\right]
```
### Constraints
- Variable bounds:
```math
M^{\text{pmin}}_{sgt} \leq y^\text{prod}_{sgt} \leq M^{\text{pmax}}_{sgt}
```
## 4. Conventional loads
Loads represent the demand for electrical power by consumers and devices
connected to the system. This section describes _conventional_ (or inelastic)
loads, which are not sensitive to changes in electricity prices, and must always
be served. Each bus in the transmission network has exactly one load; multiple
loads in the same bus can be modelled by aggregating them. If there is not
enough production or transmission capacity to serve all loads, some load can be
curtailed, at a penalty.
### Constants
| Symbol | Unit | Description |
| :---------------------- | :---- | :--------------------------------------------------------- |
| $M^\text{load}_{sbt}$ | MW | Conventional load on bus $b$ at time $s$ and scenario $s$. |
| $Z^\text{curtail}_{st}$ | \$/MW | Load curtailment penalty at time $t$ in scenario $s$. |
### Decision variables
| Symbol | JuMP name | Unit | Description | Stage |
| :----------------------- | :--------------- | :--- | :--------------------------------------------------------------- | :---- |
| $y^\text{curtail}_{sbt}$ | `curtail[s,b,t]` | MW | Amount of load curtailed at bus $b$ in time $t$ and scenario $s$ | 2 |
### Objective function terms
- Load curtailment penalty:
```math
\sum_{s \in S} p(s) \left[
\sum_{b \in B} \sum_{t \in T} y^\text{curtail}_{sbt} Z^\text{curtail}_{ts}
\right]
```
### Constraints
- Variable bounds:
```math
0 \leq y^\text{curtail}_{sbt} \leq M^\text{load}_{bts}
```
## 5. Price-sensitive loads
_Price-sensitive loads_ refer to components in the system which may increase or
reduce their power consumption according to energy prices. Unlike conventional
loads, described above, price-sensitive loads are only served if it is
economical to do so. More specifically, there are no constraints forcing these
loads to be served; instead, there is a term in the objective function rewarding
each MW served. Unlike conventional loads, there may be multiple price-sensitive
loads per bus.
!!! note
Some unit commitment models allow price-sensitive loads to have a piecewise-linear convex revenue curves, similar to thermal generators. This can be achieved in UC.jl by adding multiple price-sensitive loads to the bus, one for each piecewise-linear segment.
### Sets and constants
| Symbol | Unit | Description |
| :--------------------------- | :---- | :--------------------------------------------------------------- |
| $M^\text{psl-demand}_{spt}$ | MW | Demand of price-sensitive load $p$ at time $t$ and scenario $s$. |
| $Z^\text{psl-revenue}_{spt}$ | \$/MW | Revenue from serving load $p$ at $t$ in scenario $s$. |
| $\text{PSL}$ | | Set of price-sensitive loads. |
### Decision variables
| Symbol | JuMP name | Unit | Description | Stage |
| :------------------- | :------------- | :--- | :------------------------------------------------ | :---- |
| $y^\text{psl}_{spt}$ | `loads[s,p,t]` | MW | Amount served to $p$ in time $t$ and scenario $s$ | 2 |
### Objective function terms
- Revenue from serving price-sensitive loads:
```math
- \sum_{s \in S} p(s) \left[
\sum_{p \in \text{PSL}} \sum_{t \in T} y^\text{psl}_{spt} Z^\text{psl-revenue}_{spt}
\right]
```
### Constraints
- Variable bounds:
```math
0 \leq y^\text{psl}_{spt} \leq M^\text{psl-demand}_{spt}
```
## 6. Energy storage
_Energy storage_ units are able to store energy during periods of low demand,
then release energy back to the grid during periods of high demand. These
devices include _batteries_, _pumped hydroelectric storage_, _compressed air
energy storage_ and _flywheels_. They are becoming increasingly important in the
modern power grid, and can help to enhance grid reliability, efficiency and
integration of renewable energy resources.
### Concepts
- **Min/max energy level and charge rate:** Energy storage units can only store
a limited amount of energy (in MWh). To maintain the operational safety and
longevity of these devices, a minimum energy level may also be imposed. The
rate (in MW) at which these units can charge and discharge is also limited,
due to chemical, physical and operational considerations.
- **Operational costs:** Charging and discharging energy storage units may incur
a cost/revenue. We assume that this cost/revenue is linear on the
charge/discharte rate ($/MW).
- **Efficiency:** Charging an energy storage unit for one hour with an input of
1 MW might not result in an increase of the energy level in the device by
exactly 1 MWh, due to various inneficiencies in the charging process,
including coversion losses and heat generation. For similar reasons,
discharging a storage unit for one hour at 1 MW might reduce the energy level
by more than 1 MWh. Furthermore, even when the unit is not charging or
discharging, some energy level may be gradually lost over time, due to
unwanted chemical reactions, thermal effects of mechanical losses.
- **Myopic effect:** Because the optimization process considers a fixed time
window, there is an inherent bias towards exploiting energy storage units to
their maximum within the window, completely ignoring their operation just
beyond this horizon. For instance, without further constraints, the
optimization algorithm will often ensure that all storage units are fully
discharged at the end of the last time step, which may not be desirable. To
mitigate this myopic effect, a minimum and maximum energy level may be imposed
at the last time step.
- **Simultaneous charging and discharging:** Depending on charge and discharge
costs/revenue, it may make sense mathematically to simultaneously charge and
discharge the storage unit, thus keeping its energy level unchanged while
potentially collecting revenue. Additional binary variables and constraints
are required to prevent this incorrect model behavior.
### Sets and constants
| Symbol | Unit | Description |
| :------------------------------------ | :---- | :---------------------------------------------------------------------------------------------------- |
| $\text{SU}$ | | Set of storage units |
| $Z^\text{charge}_{sut}$ | \$/MW | Linear charge cost/revenue for unit $u$ at time $t$ in scenario $s$. |
| $Z^\text{discharge}_{sut}$ | \$/MW | Linear discharge cost/revenue for unit $u$ at time $t$ in scenario $s$. |
| $M^\text{discharge-max}_{sut}$ | \$/MW | Maximum discharge rate for unit $u$ at time $t$ in scenario $s$. |
| $M^\text{discharge-min}_{sut}$ | \$/MW | Minimum discharge rate for unit $u$ at time $t$ in scenario $s$. |
| $M^\text{charge-max}_{sut}$ | \$/MW | Maximum charge rate for unit $u$ at time $t$ in scenario $s$. |
| $M^\text{charge-min}_{sut}$ | \$/MW | Minimum charge rate for unit $u$ at time $t$ in scenario $s$. |
| $M^\text{max-end-level}_{su}$ | MWh | Maximum storage level of unit $u$ at the last time step in scenario $s$ |
| $M^\text{min-end-level}_{su}$ | MWh | Minimum storage level of unit $u$ at the last time step in scenario $s$ |
| $\gamma^\text{loss}_{s,u,t}$ | | Self-discharge factor. |
| $\gamma^\text{charge-eff}_{s,u,t}$ | | Charging efficiency factor. |
| $\gamma^\text{discharge-eff}_{s,u,t}$ | | Discharging efficiency factor. |
| $\gamma^\text{time-step}$ | | Length of a time step, in hours. Should be 1.0 for hourly time steps, 0.5 for 30-min half steps, etc. |
### Decision variables
| Symbol | JuMP name | Unit | Description | Stage |
| :------------------------------ | :---------------------- | :----- | :----------------------------------------------------------- | :---- |
| $y^\text{level}_{sut}$ | `storage_level[s,u,t]` | MWh | Storage level of unit $u$ at time $t$ in scenario $s$. | 2 |
| $y^\text{charge}_{sut}$ | `charge_rate[s,u,t]` | MW | Charge rate of unit $u$ at time $t$ in scenario $s$. | 2 |
| $y^\text{discharge}_{sut}$ | `discharge_rate[s,u,t]` | MW | Discharge rate of unit $u$ at time $t$ in scenario $s$. | 2 |
| $x^\text{is-charging}_{sut}$ | `is_charging[s,u,t]` | Binary | True if unit $u$ is charging at time $t$ in scenario $s$. | 2 |
| $x^\text{is-discharging}_{sut}$ | `is_discharging[s,u,t]` | Binary | True if unit $u$ is discharging at time $t$ in scenario $s$. | 2 |
### Objective function terms
- Charge and discharge cost/revenue:
```math
\sum_{s \in S} p(s) \left[
\sum_{u \in \text{SU}} \sum_{t \in T} \left(
y^\text{charge}_{sut} Z^\text{charge}_{sut} +
y^\text{discharge}_{sut} Z^\text{discharge}_{sut}
\right)
\right]
```
### Constraints
- Prevent simultaneous charge and discharge
(`eq_simultaneous_charge_and_discharge[s,u,t]`):
```math
x^\text{is-charging}_{sut} + x^\text{is-discharging}_{sut} \leq 1
```
- Limit charge/discharge rate (`eq_min_charge_rate[s,u,t]`,
`eq_max_charge_rate[s,u,t]`, `eq_min_discharge_rate[s,u,t]` and
`eq_max_discharge_rate[s,u,t]`):
```math
\begin{align*}
y^\text{charge}_{sut} \leq x^\text{is-charging}_{sut} M^\text{charge-max}_{sut} \\
y^\text{charge}_{sut} \geq x^\text{is-charging}_{sut} M^\text{charge-min}_{sut} \\
y^\text{discharge}_{sut} \leq x^\text{is-discharging}_{sut} M^\text{discharge-max}_{sut} \\
y^\text{discharge}_{sut} \geq x^\text{is-discharging}_{sut} M^\text{discharge-min}_{sut} \\
\end{align*}
```
- Calculate current storage level (`eq_storage_transition[s,u,t]`):
```math
y^\text{level}_{sut} =
(1 - \gamma^\text{loss}_{s,u,t}) y^\text{level}_{su,t-1} +
\gamma^\text{time-step} \gamma^\text{charge-eff}_{s,u,t} y^\text{charge}_{sut} -
\frac{\gamma^\text{time-step}}{\gamma^\text{discharge-eff}_{s,u,t}} y^\text{charge}_{sut}
```
- Enforce storage level at last time step (`eq_ending_level[s,u]`):
```math
M^\text{min-end-level}_{su} \leq y^\text{level}_{sut} \leq M^\text{max-end-level}_{su}
```
## 7. Buses and transmission lines
So far, we have described generators, which produce power, loads, which consume
power, and storage units, which store energy for later use. Another important
element is the transmission network, which delivers the power produced by the
generators to the loads and storage units. Mathematically, the network is
represented as a graph $(B,L)$ where $B$ is the set of **buses** and $L$ is the
set of **transmission lines**. Each generator, load and storage unit is located
at a bus. The **net injection** at the bus is the sum of all power injected
minus withdrawn at the bus. To balance production and consumption, we must
enforce that the sum of all net injections over the entire network equal to
zero.
Besides the net balance equations, we must also enforce flow limits on the
transmission lines. Unlike flows in other optimization problems, power flows are
directly determined by net injections and transmission line parameters, and must
follow physical laws. UC.jl uses the DC linearization of AC power flow
equations. Under this linearization, the flow $f_l$ in transmission line $l$ is
given by $\sum_{b \in B} \delta_{bl} n_b$, where $\delta_{bl}$ is a constant
known as _injection shift factor_ (also commonly called _power transfer
distribution factor_), computed from the line parameters, and $n_b$ is the net
injection at bus $b$.
!!! warning
To improve computational performance, power flow variables and constraints are generated on-the-fly, during `UnitCommitment.optimize!`; they are **not** added by `UnitCommitment.build_model`.
### Sets and constants
| Symbol | Unit | Description |
| :------------------------ | :---- | :---------------------------------------------------------- |
| $M^\text{limit}_{slt}$ | MW | Flow limit for line $l$ at time $t$ and scenario $s$. |
| $Z^\text{overflow}_{slt}$ | \$/MW | Overflow penalty for line $l$ at time $t$ and scenario $s$. |
| $L$ | | Set of transmission lines. |
| $B$ | | Set of buses. |
### Decision variables
| Symbol | JuMP name | Unit | Description | Stage |
| :------------------------ | :--------------------- | :--- | :-------------------------------------------------------------------- | :---- |
| $y^\text{flow}_{slt}$ | _(added on-the-fly)_ | MW | Flow in line $l$ at time $t$ and scenario $s$. | 2 |
| $y^\text{inj}_{sbt}$ | `net_injection[s,b,t]` | MW | Total net injection at bus $b$, time $t$ and scenario $s$. | 2 |
| $y^\text{overflow}_{slt}$ | `overflow[s,l,t]` | MW | Amount of flow above limit for line $l$ at time $t$ and scenario $s$. | 2 |
### Objective function terms
- Penalty for exceeding line limits:
```math
\sum_{s \in S} p(s) \left[
\sum_{l \in L} \sum_{t \in T} y^\text{overflow}_{slt} Z^\text{overflow}_{slt}
\right]
```
### Constraints
- Power produced equal power consumed (`eq_power_balance[s,t]`):
```math
\sum_{b \in B} \sum_{t \in T} y^\text{inj}_{sbt} = 0
```
- Definition of flow (_enforced on-the-fly_):
```math
y^\text{flow}_{slt} = \sum_{b \in B} \delta_{sbl} y^\text{inj}_{sbt}
```
- Flow limits (_enforced on-the-fly_):
```math
\begin{align*}
y^\text{flow}_{slt} & \leq M^\text{limit}_{slt} + y^\text{overflow}_{slt} \\
-y^\text{flow}_{slt} & \leq M^\text{limit}_{slt} + y^\text{overflow}_{slt}
\end{align*}
```

View File

@@ -1,43 +1,49 @@
# UnitCommitment.jl
**UnitCommitment.jl** (UC.jl) is an optimization package for the Security-Constrained Unit Commitment Problem (SCUC), a fundamental optimization problem in power systems used, for example, to clear the electricity markets. Both deterministic and two-stage stochastic versions of the problem are supported. The package provides benchmark instances for the problem, a flexible and well-documented data format for the problem, as well as Julia/JuMP implementations of state-of-the-art mixed-integer programming formulations and solution methods.
**UnitCommitment.jl** (UC.jl) is an optimization package for the Security-Constrained Unit Commitment Problem (SCUC), a fundamental optimization problem in power systems used, for example, to clear the day-ahead electricity markets. Both deterministic and two-stage stochastic versions of the problem are supported. The package provides benchmark instances for the problem, a flexible and well-documented data format for the problem, as well as Julia/JuMP implementations of state-of-the-art mixed-integer programming formulations and solution methods.
## Package Components
- **Data Format:** The package proposes an extensible and fully-documented JSON-based data specification format for SCUC, developed in collaboration with Independent System Operators (ISOs), which describes the most important aspects of the problem. The format supports all the most common thermal generator characteristics (including ramping, piecewise-linear production cost curves and time-dependent startup costs), as well as profiled generators, reserves, price-sensitive loads, battery storage, transmission, and contingencies.
- **Benchmark Instances:** The package provides a diverse collection of large-scale benchmark instances collected from the literature, converted into a common data format, and extended using data-driven methods to make them more challenging and realistic.
- **Model Implementation**: The package provides a Julia/JuMP implementations of state-of-the-art formulations and solution methods for the deterministic and stochastic SCUC, including multiple ramping formulations ([ArrCon2000](https://doi.org/10.1109/59.871739), [MorLatRam2013](https://doi.org/10.1109/TPWRS.2013.2251373), [DamKucRajAta2016](https://doi.org/10.1007/s10107-015-0919-9), [PanGua2016](https://doi.org/10.1287/opre.2016.1520)), piecewise-linear costs formulations ([Gar1962](https://doi.org/10.1109/AIEEPAS.1962.4501405), [CarArr2006](https://doi.org/10.1109/TPWRS.2006.876672), [KnuOstWat2018](https://doi.org/10.1109/TPWRS.2017.2783850)), contingency screening methods ([XavQiuWanThi2019](https://doi.org/10.1109/TPWRS.2019.2892620)) and decomposition methods. Our goal is to keep these implementations up-to-date as new methods are proposed in the literature.
- **Benchmark Tools:** The package provides automated benchmark scripts to accurately evaluate the performance impact of proposed code changes.
* **Data Format:** The package proposes an extensible and fully-documented JSON-based data specification format for SCUC, developed in collaboration with Independent System Operators (ISOs), which describes the most important aspects of the problem. The format supports all the most common thermal generator characteristics (including ramping, piecewise-linear production cost curves and time-dependent startup costs), as well as profiled generators, reserves, price-sensitive loads, battery storage, transmission, and contingencies.
* **Benchmark Instances:** The package provides a diverse collection of large-scale benchmark instances collected from the literature, converted into a common data format, and extended using data-driven methods to make them more challenging and realistic.
* **Model Implementation**: The package provides a Julia/JuMP implementations of state-of-the-art formulations and solution methods for the deterministic and stochastic SCUC, including multiple ramping formulations ([ArrCon2000](https://doi.org/10.1109/59.871739), [MorLatRam2013](https://doi.org/10.1109/TPWRS.2013.2251373), [DamKucRajAta2016](https://doi.org/10.1007/s10107-015-0919-9), [PanGua2016](https://doi.org/10.1287/opre.2016.1520)), piecewise-linear costs formulations ([Gar1962](https://doi.org/10.1109/AIEEPAS.1962.4501405), [CarArr2006](https://doi.org/10.1109/TPWRS.2006.876672), [KnuOstWat2018](https://doi.org/10.1109/TPWRS.2017.2783850)), contingency screening methods ([XavQiuWanThi2019](https://doi.org/10.1109/TPWRS.2019.2892620)) and decomposition methods. Our goal is to keep these implementations up-to-date as new methods are proposed in the literature.
* **Benchmark Tools:** The package provides automated benchmark scripts to accurately evaluate the performance impact of proposed code changes.
## Table of Contents
```@contents
Pages = ["usage.md", "format.md", "instances.md", "model.md", "api.md"]
Depth = 3
```
## Authors
- **Alinson S. Xavier** (Argonne National Laboratory)
- **Aleksandr M. Kazachkov** (University of Florida)
- **Ogün Yurdakul** (Technische Universität Berlin)
- **Jun He** (Purdue University)
- **Feng Qiu** (Argonne National Laboratory)
* **Alinson S. Xavier** (Argonne National Laboratory)
* **Aleksandr M. Kazachkov** (University of Florida)
* **Ogün Yurdakul** (Technische Universität Berlin)
* **Jun He** (Purdue University)
* **Feng Qiu** (Argonne National Laboratory)
## 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.
- Based upon work supported by **Laboratory Directed Research and Development** (LDRD) funding from Argonne National Laboratory, provided by the Director, Office of Science, of the U.S. Department of Energy under Contract No. DE-AC02-06CH11357
* Based upon work supported by **Laboratory Directed Research and Development** (LDRD) funding from Argonne National Laboratory, provided by the Director, Office of Science, of the U.S. Department of Energy under Contract No. DE-AC02-06CH11357
- 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
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, Ogün Yurdakul, Jun He, Feng Qiu**, "UnitCommitment.jl: A Julia/JuMP Optimization Package for Security-Constrained Unit Commitment (Version 0.4)". Zenodo (2024). [DOI: 10.5281/zenodo.4269874](https://doi.org/10.5281/zenodo.4269874).
* **Alinson S. Xavier, Aleksandr M. Kazachkov, Ogün Yurdakul, Jun He, Feng Qiu**, "UnitCommitment.jl: A Julia/JuMP Optimization Package for Security-Constrained Unit Commitment (Version 0.4)". Zenodo (2023). [DOI: 10.5281/zenodo.4269874](https://doi.org/10.5281/zenodo.4269874).
If you use the instances, we additionally request that you cite the original sources, as described in the [instances page](guides/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
```text
UnitCommitment.jl: A Julia/JuMP Optimization Package for Security-Constrained Unit Commitment
Copyright © 2020-2024, UChicago Argonne, LLC. All Rights Reserved.
Copyright © 2020-2023, UChicago Argonne, LLC. All Rights Reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted
provided that the following conditions are met:

303
docs/src/instances.md Normal file
View File

@@ -0,0 +1,303 @@
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). Instance files can also be [directly downloaded from our website](https://axavier.org/UnitCommitment.jl/0.3/instances/).
!!! 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.
MATPOWER
--------
[MATPOWER](https://github.com/MATPOWER/matpower) is an open-source package for solving power flow problems in MATLAB and Octave. It contains a number of power flow test cases, which have been widely used in the power systems literature.
Because most MATPOWER test cases were originally designed for power flow studies, they lack a number of important unit commitment parameters, such as time-varying loads, production cost curves, ramp limits, reserves and initial conditions. The test cases included in UnitCommitment.jl are extended versions of the original MATPOWER test cases, modified as following:
* **Production cost** curves were generated using a data-driven approach, based on publicly available data. More specifically, machine learning models were trained to predict typical production cost curves, for each day of the year, based on a generator's maximum and minimum power output.
* **Load profiles** were generated using a similar data-driven approach.
* **Ramp-up, ramp-down, startup and shutdown rates** were set to a fixed proportion of the generator's maximum output.
* **Minimum reserves** were set to a fixed proportion of the total demand.
* **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 365 variations (`2017-01-01` to `2017-12-31`) corresponding different days of the year.
### MATPOWER/UW-PSTCA
A variety of smaller IEEE test cases, [compiled by University of Washington](http://labs.ece.uw.edu/pstca/), corresponding mostly to small portions of the American Electric Power System in the 1960s.
| Name | Buses | Generators | Lines | Contingencies | References |
|------|-------|------------|-------|---------------|--------|
| `matpower/case14/2017-01-01` | 14 | 5 | 20 | 19 | [MTPWR, PSTCA]
| `matpower/case30/2017-01-01` | 30 | 6 | 41 | 38 | [MTPWR, PSTCA]
| `matpower/case57/2017-01-01` | 57 | 7 | 80 | 79 | [MTPWR, PSTCA]
| `matpower/case118/2017-01-01` | 118 | 54 | 186 | 177 | [MTPWR, PSTCA]
| `matpower/case300/2017-01-01` | 300 | 69 | 411 | 320 | [MTPWR, PSTCA]
### MATPOWER/Polish
Test cases based on the Polish 400, 220 and 110 kV networks, originally provided by **Roman Korab** (Politechnika Śląska) and corrected by the MATPOWER team.
| Name | Buses | Generators | Lines | Contingencies | References |
|------|-------|------------|-------|---------------|--------|
| `matpower/case2383wp/2017-01-01` | 2383 | 323 | 2896 | 2240 | [MTPWR]
| `matpower/case2736sp/2017-01-01` | 2736 | 289 | 3504 | 3159 | [MTPWR]
| `matpower/case2737sop/2017-01-01` | 2737 | 267 | 3506 | 3161 | [MTPWR]
| `matpower/case2746wop/2017-01-01` | 2746 | 443 | 3514 | 3155 | [MTPWR]
| `matpower/case2746wp/2017-01-01` | 2746 | 457 | 3514 | 3156 | [MTPWR]
| `matpower/case3012wp/2017-01-01` | 3012 | 496 | 3572 | 2854 | [MTPWR]
| `matpower/case3120sp/2017-01-01` | 3120 | 483 | 3693 | 2950 | [MTPWR]
| `matpower/case3375wp/2017-01-01` | 3374 | 590 | 4161 | 3245 | [MTPWR]
### MATPOWER/PEGASE
Test cases from the [Pan European Grid Advanced Simulation and State Estimation (PEGASE) project](https://cordis.europa.eu/project/id/211407), describing part of the European high voltage transmission network.
| Name | Buses | Generators | Lines | Contingencies | References |
|------|-------|------------|-------|---------------|--------|
| `matpower/case89pegase/2017-01-01` | 89 | 12 | 210 | 192 | [JoFlMa16, FlPaCa13, MTPWR]
| `matpower/case1354pegase/2017-01-01` | 1354 | 260 | 1991 | 1288 | [JoFlMa16, FlPaCa13, MTPWR]
| `matpower/case2869pegase/2017-01-01` | 2869 | 510 | 4582 | 3579 | [JoFlMa16, FlPaCa13, MTPWR]
| `matpower/case9241pegase/2017-01-01` | 9241 | 1445 | 16049 | 13932 | [JoFlMa16, FlPaCa13, MTPWR]
| `matpower/case13659pegase/2017-01-01` | 13659 | 4092 | 20467 | 13932 | [JoFlMa16, FlPaCa13, MTPWR]
### MATPOWER/RTE
Test cases from the R&D Division at [Reseau de Transport d'Electricite](https://www.rte-france.com) representing the size and complexity of the French very high voltage transmission network.
| Name | Buses | Generators | Lines | Contingencies | References |
|------|-------|------------|-------|---------------|--------|
| `matpower/case1888rte/2017-01-01` | 1888 | 296 | 2531 | 1484 | [MTPWR, JoFlMa16]
| `matpower/case1951rte/2017-01-01` | 1951 | 390 | 2596 | 1497 | [MTPWR, JoFlMa16]
| `matpower/case2848rte/2017-01-01` | 2848 | 544 | 3776 | 2242 | [MTPWR, JoFlMa16]
| `matpower/case2868rte/2017-01-01` | 2868 | 596 | 3808 | 2260 | [MTPWR, JoFlMa16]
| `matpower/case6468rte/2017-01-01` | 6468 | 1262 | 9000 | 6094 | [MTPWR, JoFlMa16]
| `matpower/case6470rte/2017-01-01` | 6470 | 1306 | 9005 | 6085 | [MTPWR, JoFlMa16]
| `matpower/case6495rte/2017-01-01` | 6495 | 1352 | 9019 | 6060 | [MTPWR, JoFlMa16]
| `matpower/case6515rte/2017-01-01` | 6515 | 1368 | 9037 | 6063 | [MTPWR, JoFlMa16]
PGLIB-UC Instances
------------------
[PGLIB-UC](https://github.com/power-grid-lib/pglib-uc) is a benchmark library curated and maintained by the [IEEE PES Task Force on Benchmarks for Validation of Emerging Power System Algorithms](https://power-grid-lib.github.io/). These test cases have been used in [KnOsWa20].
### PGLIB-UC/California
Test cases based on publicly available data from the California ISO. For more details, see [PGLIB-UC case file overview](https://github.com/power-grid-lib/pglib-uc).
| Name | Buses | Generators | Lines | Contingencies | References |
|------|-------|------------|-------|---------------|--------|
| `pglib-uc/ca/2014-09-01_reserves_0` | 1 | 610 | 0 | 0 | [KnOsWa20]
| `pglib-uc/ca/2014-09-01_reserves_1` | 1 | 610 | 0 | 0 | [KnOsWa20]
| `pglib-uc/ca/2014-09-01_reserves_3` | 1 | 610 | 0 | 0 | [KnOsWa20]
| `pglib-uc/ca/2014-09-01_reserves_5` | 1 | 610 | 0 | 0 | [KnOsWa20]
| `pglib-uc/ca/2014-12-01_reserves_0` | 1 | 610 | 0 | 0 | [KnOsWa20]
| `pglib-uc/ca/2014-12-01_reserves_1` | 1 | 610 | 0 | 0 | [KnOsWa20]
| `pglib-uc/ca/2014-12-01_reserves_3` | 1 | 610 | 0 | 0 | [KnOsWa20]
| `pglib-uc/ca/2014-12-01_reserves_5` | 1 | 610 | 0 | 0 | [KnOsWa20]
| `pglib-uc/ca/2015-03-01_reserves_0` | 1 | 610 | 0 | 0 | [KnOsWa20]
| `pglib-uc/ca/2015-03-01_reserves_1` | 1 | 610 | 0 | 0 | [KnOsWa20]
| `pglib-uc/ca/2015-03-01_reserves_3` | 1 | 610 | 0 | 0 | [KnOsWa20]
| `pglib-uc/ca/2015-03-01_reserves_5` | 1 | 610 | 0 | 0 | [KnOsWa20]
| `pglib-uc/ca/2015-06-01_reserves_0` | 1 | 610 | 0 | 0 | [KnOsWa20]
| `pglib-uc/ca/2015-06-01_reserves_1` | 1 | 610 | 0 | 0 | [KnOsWa20]
| `pglib-uc/ca/2015-06-01_reserves_3` | 1 | 610 | 0 | 0 | [KnOsWa20]
| `pglib-uc/ca/2015-06-01_reserves_5` | 1 | 610 | 0 | 0 | [KnOsWa20]
| `pglib-uc/ca/Scenario400_reserves_0` | 1 | 611 | 0 | 0 | [KnOsWa20]
| `pglib-uc/ca/Scenario400_reserves_1` | 1 | 611 | 0 | 0 | [KnOsWa20]
| `pglib-uc/ca/Scenario400_reserves_3` | 1 | 611 | 0 | 0 | [KnOsWa20]
| `pglib-uc/ca/Scenario400_reserves_5` | 1 | 611 | 0 | 0 | [KnOsWa20]
### PGLIB-UC/FERC
Test cases based on a publicly available [unit commitment test case produced by the Federal Energy Regulatory Commission](https://www.ferc.gov/industries-data/electric/power-sales-and-markets/increasing-efficiency-through-improved-software-1). For more details, see [PGLIB-UC case file overview](https://github.com/power-grid-lib/pglib-uc).
| Name | Buses | Generators | Lines | Contingencies | References |
|------|-------|------------|-------|---------------|--------|
| `pglib-uc/ferc/2015-01-01_hw` | 1 | 935 | 0 | 0 | [KnOsWa20, KrHiOn12]
| `pglib-uc/ferc/2015-01-01_lw` | 1 | 935 | 0 | 0 | [KnOsWa20, KrHiOn12]
| `pglib-uc/ferc/2015-02-01_hw` | 1 | 935 | 0 | 0 | [KnOsWa20, KrHiOn12]
| `pglib-uc/ferc/2015-02-01_lw` | 1 | 935 | 0 | 0 | [KnOsWa20, KrHiOn12]
| `pglib-uc/ferc/2015-03-01_hw` | 1 | 935 | 0 | 0 | [KnOsWa20, KrHiOn12]
| `pglib-uc/ferc/2015-03-01_lw` | 1 | 935 | 0 | 0 | [KnOsWa20, KrHiOn12]
| `pglib-uc/ferc/2015-04-01_hw` | 1 | 979 | 0 | 0 | [KnOsWa20, KrHiOn12]
| `pglib-uc/ferc/2015-04-01_lw` | 1 | 979 | 0 | 0 | [KnOsWa20, KrHiOn12]
| `pglib-uc/ferc/2015-05-01_hw` | 1 | 979 | 0 | 0 | [KnOsWa20, KrHiOn12]
| `pglib-uc/ferc/2015-05-01_lw` | 1 | 979 | 0 | 0 | [KnOsWa20, KrHiOn12]
| `pglib-uc/ferc/2015-06-01_hw` | 1 | 979 | 0 | 0 | [KnOsWa20, KrHiOn12]
| `pglib-uc/ferc/2015-06-01_lw` | 1 | 979 | 0 | 0 | [KnOsWa20, KrHiOn12]
| `pglib-uc/ferc/2015-07-01_hw` | 1 | 979 | 0 | 0 | [KnOsWa20, KrHiOn12]
| `pglib-uc/ferc/2015-07-01_lw` | 1 | 979 | 0 | 0 | [KnOsWa20, KrHiOn12]
| `pglib-uc/ferc/2015-08-01_hw` | 1 | 979 | 0 | 0 | [KnOsWa20, KrHiOn12]
| `pglib-uc/ferc/2015-08-01_lw` | 1 | 979 | 0 | 0 | [KnOsWa20, KrHiOn12]
| `pglib-uc/ferc/2015-09-01_hw` | 1 | 979 | 0 | 0 | [KnOsWa20, KrHiOn12]
| `pglib-uc/ferc/2015-09-01_lw` | 1 | 979 | 0 | 0 | [KnOsWa20, KrHiOn12]
| `pglib-uc/ferc/2015-10-01_hw` | 1 | 935 | 0 | 0 | [KnOsWa20, KrHiOn12]
| `pglib-uc/ferc/2015-10-01_lw` | 1 | 935 | 0 | 0 | [KnOsWa20, KrHiOn12]
| `pglib-uc/ferc/2015-11-02_hw` | 1 | 935 | 0 | 0 | [KnOsWa20, KrHiOn12]
| `pglib-uc/ferc/2015-11-02_lw` | 1 | 935 | 0 | 0 | [KnOsWa20, KrHiOn12]
| `pglib-uc/ferc/2015-12-01_hw` | 1 | 935 | 0 | 0 | [KnOsWa20, KrHiOn12]
| `pglib-uc/ferc/2015-12-01_lw` | 1 | 935 | 0 | 0 | [KnOsWa20, KrHiOn12]
### PGLIB-UC/RTS-GMLC
[RTS-GMLC](https://github.com/GridMod/RTS-GMLC) is an updated version of the RTS-96 test system produced by the United States Department of Energy's [Grid Modernization Laboratory Consortium](https://gmlc.doe.gov/). The PGLIB-UC/RTS-GMLC instances are modified versions of the original RTS-GMLC instances, with modified ramp-rates and without a transmission network. For more details, see [PGLIB-UC case file overview](https://github.com/power-grid-lib/pglib-uc).
| Name | Buses | Generators | Lines | Contingencies | References |
|------|-------|------------|-------|---------------|--------|
| `pglib-uc/rts_gmlc/2020-01-27` | 1 | 154 | 0 | 0 | [BaBlEh19]
| `pglib-uc/rts_gmlc/2020-02-09` | 1 | 154 | 0 | 0 | [BaBlEh19]
| `pglib-uc/rts_gmlc/2020-03-05` | 1 | 154 | 0 | 0 | [BaBlEh19]
| `pglib-uc/rts_gmlc/2020-04-03` | 1 | 154 | 0 | 0 | [BaBlEh19]
| `pglib-uc/rts_gmlc/2020-05-05` | 1 | 154 | 0 | 0 | [BaBlEh19]
| `pglib-uc/rts_gmlc/2020-06-09` | 1 | 154 | 0 | 0 | [BaBlEh19]
| `pglib-uc/rts_gmlc/2020-07-06` | 1 | 154 | 0 | 0 | [BaBlEh19]
| `pglib-uc/rts_gmlc/2020-08-12` | 1 | 154 | 0 | 0 | [BaBlEh19]
| `pglib-uc/rts_gmlc/2020-09-20` | 1 | 154 | 0 | 0 | [BaBlEh19]
| `pglib-uc/rts_gmlc/2020-10-27` | 1 | 154 | 0 | 0 | [BaBlEh19]
| `pglib-uc/rts_gmlc/2020-11-25` | 1 | 154 | 0 | 0 | [BaBlEh19]
| `pglib-uc/rts_gmlc/2020-12-23` | 1 | 154 | 0 | 0 | [BaBlEh19]
OR-LIB/UC
---------
[OR-LIB](http://people.brunel.ac.uk/~mastjjb/jeb/info.html) is a collection of test data sets for a variety of operations research problems, including unit commitment. The UC instances in OR-LIB are synthetic instances generated by a [random problem generator](http://groups.di.unipi.it/optimize/Data/UC.html) developed by the [Operations Research Group at University of Pisa](http://groups.di.unipi.it/optimize/). These test cases have been used in [FrGe06] and many other publications.
| Name | Hours | Buses | Generators | Lines | Contingencies | References |
|------|-------|-------|------------|-------|---------------|------------|
| `or-lib/10_0_1_w` | 24 | 1 | 10 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/10_0_2_w` | 24 | 1 | 10 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/10_0_3_w` | 24 | 1 | 10 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/10_0_4_w` | 24 | 1 | 10 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/10_0_5_w` | 24 | 1 | 10 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/20_0_1_w` | 24 | 1 | 20 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/20_0_2_w` | 24 | 1 | 20 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/20_0_3_w` | 24 | 1 | 20 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/20_0_4_w` | 24 | 1 | 20 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/20_0_5_w` | 24 | 1 | 20 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/50_0_1_w` | 24 | 1 | 50 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/50_0_2_w` | 24 | 1 | 50 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/50_0_3_w` | 24 | 1 | 50 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/50_0_4_w` | 24 | 1 | 50 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/50_0_5_w` | 24 | 1 | 50 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/75_0_1_w` | 24 | 1 | 75 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/75_0_2_w` | 24 | 1 | 75 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/75_0_3_w` | 24 | 1 | 75 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/75_0_4_w` | 24 | 1 | 75 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/75_0_5_w` | 24 | 1 | 75 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/100_0_1_w` | 24 | 1 | 100 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/100_0_2_w` | 24 | 1 | 100 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/100_0_3_w` | 24 | 1 | 100 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/100_0_4_w` | 24 | 1 | 100 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/100_0_5_w` | 24 | 1 | 100 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/150_0_1_w` | 24 | 1 | 150 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/150_0_2_w` | 24 | 1 | 150 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/150_0_3_w` | 24 | 1 | 150 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/150_0_4_w` | 24 | 1 | 150 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/150_0_5_w` | 24 | 1 | 150 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/200_0_10_w` | 24 | 1 | 200 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/200_0_11_w` | 24 | 1 | 200 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/200_0_12_w` | 24 | 1 | 200 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/200_0_1_w` | 24 | 1 | 200 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/200_0_2_w` | 24 | 1 | 200 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/200_0_3_w` | 24 | 1 | 200 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/200_0_4_w` | 24 | 1 | 200 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/200_0_5_w` | 24 | 1 | 200 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/200_0_6_w` | 24 | 1 | 200 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/200_0_7_w` | 24 | 1 | 200 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/200_0_8_w` | 24 | 1 | 200 | 0 | 0 | [ORLIB, FrGe06]
| `or-lib/200_0_9_w` | 24 | 1 | 200 | 0 | 0 | [ORLIB, FrGe06]
Tejada19
--------
Test cases used in [TeLuSa19]. These instances are similar to OR-LIB/UC, in the sense that they use the same random problem generator, but are much larger.
| Name | Hours | Buses | Generators | Lines | Contingencies | References |
|------|-------|-------|------------|-------|---------------|------------|
| `tejada19/UC_24h_214g` | 24 | 1 | 214 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_24h_250g` | 24 | 1 | 250 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_24h_290g` | 24 | 1 | 290 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_24h_480g` | 24 | 1 | 480 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_24h_505g` | 24 | 1 | 505 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_24h_623g` | 24 | 1 | 623 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_24h_647g` | 24 | 1 | 647 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_24h_836g` | 24 | 1 | 836 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_24h_850g` | 24 | 1 | 850 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_24h_918g` | 24 | 1 | 918 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_24h_931g` | 24 | 1 | 931 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_24h_940g` | 24 | 1 | 940 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_24h_957g` | 24 | 1 | 957 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_24h_959g` | 24 | 1 | 959 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_24h_1069g` | 24 | 1 | 1069 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_24h_1130g` | 24 | 1 | 1130 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_24h_1376g` | 24 | 1 | 1376 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_24h_1393g` | 24 | 1 | 1393 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_24h_1577g` | 24 | 1 | 1577 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_24h_1615g` | 24 | 1 | 1615 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_24h_1632g` | 24 | 1 | 1632 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_24h_1768g` | 24 | 1 | 1768 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_24h_1804g` | 24 | 1 | 1804 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_24h_1820g` | 24 | 1 | 1820 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_24h_1823g` | 24 | 1 | 1823 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_24h_1888g` | 24 | 1 | 1888 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_168h_36g` | 168 | 1 | 36 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_168h_38g` | 168 | 1 | 38 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_168h_40g` | 168 | 1 | 40 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_168h_53g` | 168 | 1 | 53 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_168h_58g` | 168 | 1 | 58 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_168h_59g` | 168 | 1 | 59 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_168h_72g` | 168 | 1 | 72 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_168h_84g` | 168 | 1 | 84 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_168h_86g` | 168 | 1 | 86 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_168h_88g` | 168 | 1 | 88 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_168h_93g` | 168 | 1 | 93 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_168h_105g` | 168 | 1 | 105 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_168h_110g` | 168 | 1 | 110 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_168h_125g` | 168 | 1 | 125 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_168h_130g` | 168 | 1 | 130 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_168h_131g` | 168 | 1 | 131 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_168h_140g` | 168 | 1 | 140 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_168h_165g` | 168 | 1 | 165 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_168h_175g` | 168 | 1 | 175 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_168h_179g` | 168 | 1 | 179 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_168h_188g` | 168 | 1 | 188 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_168h_192g` | 168 | 1 | 192 | 0 | 0 | [TeLuSa19]
| `tejada19/UC_168h_199g` | 168 | 1 | 199 | 0 | 0 | [TeLuSa19]
References
----------
* [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)
* [KrHiOn12] **Eric Krall, Michael Higgins and Richard P. ONeill.** "RTO unit commitment test system." Federal Energy Regulatory Commission. Available at: <https://www.ferc.gov/industries-data/electric/power-sales-and-markets/increasing-efficiency-through-improved-software-1> (Accessed: Nov 14, 2020)
* [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 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.** "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)
* [PSTCA] **University of Washington, Dept. of Electrical Engineering.** "Power Systems Test Case Archive". Available at: <http://www.ee.washington.edu/research/pstca/> (Accessed: Nov 14, 2020)
* [ORLIB] **J.E.Beasley.** "OR-Library: distributing test problems by electronic mail", Journal of the Operational Research Society 41(11) (1990). [DOI: 10.2307/2582903](https://doi.org/10.2307/2582903)
* [FrGe06] **A. Frangioni, C. Gentile.** "Solving nonlinear single-unit commitment problems with ramping constraints" Operations Research 54(4), p. 767 - 775, 2006. [DOI: 10.1287/opre.1060.0309](https://doi.org/10.1287/opre.1060.0309)
* [TeLuSa19] **D. A. Tejada-Arango, S. Lumbreras, P. Sanchez-Martin and A. Ramos.** "Which Unit-Commitment Formulation is Best? A Systematic Comparison," in IEEE Transactions on Power Systems. [DOI: 10.1109/TPWRS.2019.2962024](https://ieeexplore.ieee.org/document/8941313/).

233
docs/src/model.md Normal file
View File

@@ -0,0 +1,233 @@
JuMP Model
==========
In this page, we describe the JuMP optimization model produced by the function `build_model`. A detailed understanding of this model is not necessary if you are just interested in using the package to solve some standard unit commitment cases, but it may be useful, for example, if you need to solve a slightly different problem, with additional variables and constraints. The notation in this page generally follows [KnOsWa20].
Decision variables
------------------
UC.jl models the security-constrained unit commitment problem as a two-stage stochastic program. In this approach, some of the decision variables are *first-stage decisions*, which are taken before the uncertainty is realized and must therefore be the same across all scenarios, while the remaining variables are *second-stage decisions*, which can attain a different values in each scenario. In the current version of the package, all binary variables (which model commitment decisions of thermal units) are first-stage decisions and all continuous variables are second-stage decisions.
!!! note
UC.jl treats deterministic SCUC instances as a special case of the stochastic problem in which there is only one scenario, named `"s1"` by default. To access second-stage decisions, therefore, you must provide this scenario name as the value for `sn`. For example, `model[:prod_above]["s1", g, t]`.
### Generators
In this section, we describe the decision variables associated with the generators, which include both thermal units (e.g., natural gas-fired power plant) and profiled units (e.g., wind turbine).
#### Thermal Units
Name | Description | Unit | Stage
:-----|:-------------|:------: | :------:
`is_on[g,t]` | True if generator `g` is on at time `t`. | Binary | 1
`switch_on[g,t]` | True is generator `g` switches on at time `t`. | Binary| 1
`switch_off[g,t]` | True if generator `g` switches off at time `t`. | Binary| 1
`startup[g,t,s]` | True if generator `g` switches on at time `t` incurring start-up costs from start-up category `s`. | Binary| 1
`prod_above[sn,g,t]` | Amount of power produced by generator `g` above its minimum power output at time `t` in scenario `sn`. For example, if the minimum power of generator `g` is 100 MW and `g` is producing 115 MW of power at time `t` in scenario `sn`, then `prod_above[sn,g,t]` equals `15.0`. | MW | 2
`segprod[sn,g,t,k]` | Amount of power from piecewise linear segment `k` produced by generator `g` at time `t` in scenario `sn`. For example, if cost curve for generator `g` is defined by the points `(100, 1400)`, `(110, 1600)`, `(130, 2200)` and `(135, 2400)`, and if the generator is producing 115 MW of power at time `t` in scenario `sn`, then `segprod[sn,g,t,:]` equals `[10.0, 5.0, 0.0]`.| MW | 2
`reserve[sn,r,g,t]` | Amount of reserve `r` provided by unit `g` at time `t` in scenario `sn`. | MW | 2
!!! warning
The first-stage decision variables of the JuMP model are `is_on[g,t]`, `switch_on[g,t]`, `switch_off[g,t]`, and `startup[g,t,s]`. As such, the dictionaries corresponding to these variables do not include the scenario index in their keys. In contrast, all other variables of the created JuMP model are allowed to obtain a different value in each scenario and are thus modeled as second-stage decision variables. Accordingly, the dictionaries of all second-stage decision variables have the scenario index in their keys. This is true even if the model is created to solve the deterministic SCUC, in which case the default scenario index `s1` is included in the dictionary key.
#### Profiled Units
Name | Description | Unit | Stage
:-----|:-------------|:------: | :------:
`prod_profiled[s,t]` | Amount of power produced by profiled unit `g` at time `t`. | MW | 2
### Buses
Name | Description | Unit | Stage
:-----|:-------------|:------:| :------:
`net_injection[sn,b,t]` | Net injection at bus `b` at time `t` in scenario `sn`. | MW | 2
`curtail[sn,b,t]` | Amount of load curtailed at bus `b` at time `t` in scenario `sn`. | MW | 2
### Price-sensitive loads
Name | Description | Unit | Stage
:-----|:-------------|:------:| :------:
`loads[sn,s,t]` | Amount of power served to price-sensitive load `s` at time `t` in scenario `sn`. | MW | 2
### Transmission lines
Name | Description | Unit | Stage
:-----|:-------------|:------:| :------:
`flow[sn,l,t]` | Power flow on line `l` at time `t` in scenario `sn`. | MW | 2
`overflow[sn,l,t]` | Amount of flow above the limit for line `l` at time `t` in scenario `sn`. | MW | 2
!!! warning
Since transmission and N-1 security constraints are enforced in a lazy way, most of the `flow[l,t]` variables are never added to the model. Accessing `model[:flow][sn,l,t]` without first checking that the variable exists will likely generate an error.
Objective function
------------------
TODO
Constraints
-----------
TODO
Inspecting and modifying the model
----------------------------------
### Accessing decision variables
After building a model using `UnitCommitment.build_model`, it is possible to obtain a reference to the decision variables by calling `model[:varname][index]`. For example, `model[:is_on]["g1",1]` returns a direct reference to the JuMP variable indicating whether generator named "g1" is on at time 1. The script below illustrates how to build a model, solve it and display the solution without using the function `UnitCommitment.solution`.
```julia
using Cbc
using Printf
using JuMP
using UnitCommitment
# Load benchmark instance
instance = UnitCommitment.read_benchmark("matpower/case118/2017-02-01")
# Build JuMP model
model = UnitCommitment.build_model(
instance=instance,
optimizer=Cbc.Optimizer,
)
# Solve the model
UnitCommitment.optimize!(model)
# Display commitment status
for g in instance.units
for t in 1:instance.time
@printf(
"%-10s %5d %5.1f %5.1f %5.1f\n",
g.name,
t,
value(model[:is_on][g.name, t]),
value(model[:switch_on][g.name, t]),
value(model[:switch_off][g.name, t]),
)
end
end
```
### Fixing variables, modifying objective function and adding constraints
Since we now have a direct reference to the JuMP decision variables, it is possible to fix variables, change the coefficients in the objective function, or even add new constraints to the model before solving it.
!!! warning
It is important to take into account the stage of the decision variables in modifying the optimization model. In changing a deterministic SCUC model, modifying the second-stage decision variables requires adding the term `s1`, which is the default scenario name assigned to the second-stage decision variables in the SCUC model. For an SUC model, the package permits the modification of the second-stage decision variables individually for each scenario.
The script below shows how the JuMP model can be modified after it is created. For more information on modifying an existing model, [see the JuMP documentation](https://jump.dev/JuMP.jl/stable/manual/variables/).
```julia
using Cbc
using JuMP
using UnitCommitment
# Load benchmark instance
instance = UnitCommitment.read_benchmark("matpower/case118/2017-02-01")
# Construct JuMP model
model = UnitCommitment.build_model(
instance=instance,
optimizer=Cbc.Optimizer,
)
# Fix the commitment status of the generator "g1" in time period 1 to 1.0
JuMP.fix(
model[:is_on]["g1",1],
1.0,
force=true,
)
# Fix the production level of the generator "g1" above its minimum level in time period 1 and
# in scenario "s1" to 20.0 MW. Observe that the three-tuple dictionary key involves the scenario
# index "s1", as production above minimum is a second-stage decision variable.
JuMP.fix(
model[:prod_above]["s1", "g1", 1],
20.0,
force=true,
)
# Enforce the curtailment of 20.0 MW of load at bus "b2" in time period 4 in scenario "s1".
JuMP.fix(
curtail["s1", "b2", 4] =
20.0,
force=true,
)
# Change the objective function
JuMP.set_objective_coefficient(
model,
model[:switch_on]["g2",1],
1000.0,
)
# Create a new constraint
@constraint(
model,
model[:is_on]["g3",1] + model[:is_on]["g4",1] <= 1,
)
# Solve the model
UnitCommitment.optimize!(model)
```
### Adding new component to a bus
The following snippet shows how to add a new grid component to a particular bus. For each time step, we create decision variables for the new grid component, add these variables to the objective function, then attach the component to a particular bus by modifying some existing model constraints.
```julia
using Cbc
using JuMP
using UnitCommitment
# Load instance and build base model
instance = UnitCommitment.read_benchmark("matpower/case118/2017-02-01")
model = UnitCommitment.build_model(
instance=instance,
optimizer=Cbc.Optimizer,
)
# Get the number of time steps in the original instance
T = instance.time
# Create decision variables for the new grid component.
# In this example, we assume that the new component can
# inject up to 10 MW of power at each time step, so we
# create new continuous variables 0 ≤ x[t] ≤ 10.
@variable(model, x[1:T], lower_bound=0.0, upper_bound=10.0)
# For each time step
for t in 1:T
# Add production costs to the objective function.
# In this example, we assume a cost of $5/MW.
set_objective_coefficient(model, x[t], 5.0)
# Attach the new component to bus b1 in scenario s1, by modifying the
# constraint `eq_net_injection`.
set_normalized_coefficient(
model[:eq_net_injection]["s1", "b1", t],
x[t],
1.0,
)
end
# Solve the model
UnitCommitment.optimize!(model)
# Show optimal values for the x variables
@show value.(x)
```
References
----------
* [KnOsWa20] **Bernard Knueven, James Ostrowski and Jean-Paul Watson.** "On Mixed-Integer Programming Formulations for the Unit Commitment Problem". INFORMS Journal on Computing (2020). [DOI: 10.1287/ijoc.2019.0944](https://doi.org/10.1287/ijoc.2019.0944)

View File

@@ -1,122 +0,0 @@
# # Model customization
# In the previous tutorial, we used UnitCommitment.jl to solve benchmark and user-provided instances using a default mathematical formulation for the problem. In this tutorial, we will explore how to customize this formulation.
# !!! warning
# This tutorial is not required for using UnitCommitment.jl, unless you plan to make changes to the problem formulation. In this page, we assume familiarity with the JuMP modeling language. Please see [JuMP's official documentation](https://jump.dev/JuMP.jl/stable/) for resources on getting started with JuMP.
# ## Selecting modeling components
# By default, `UnitCommitment.build_model` uses a formulation that combines modeling components from different publications, and that has been carefully tested, using our own benchmark scripts, to provide good performance across a wide variety of instances. This default formulation is expected to change over time, as new methods are proposed in the literature. You can, however, construct your own formulation, based on the modeling components that you choose, as shown in the next example.
# We start by importing the necessary packages and reading a benchmark instance:
using HiGHS
using JuMP
using UnitCommitment
instance = UnitCommitment.read_benchmark("matpower/case14/2017-01-01");
# Next, instead of calling `UnitCommitment.build_model` with default arguments, we can provide a `UnitCommitment.Formulation` object, which describes what modeling components to use, and how should they be configured. For a complete list of modeling components available in UnitCommitment.jl, see the [API docs](../api.md).
# In the example below, we switch to piecewise-linear cost modeling as defined in [KnuOstWat2018](https://doi.org/10.1109/TPWRS.2017.2783850), as well as ramping and startup costs formulation as defined in [MorLatRam2013](https://doi.org/10.1109/TPWRS.2013.2251373). In addition, we specify custom cutoffs for the shift factors formulation.
model = UnitCommitment.build_model(
instance = instance,
optimizer = HiGHS.Optimizer,
formulation = UnitCommitment.Formulation(
pwl_costs = UnitCommitment.KnuOstWat2018.PwlCosts(),
ramping = UnitCommitment.MorLatRam2013.Ramping(),
startup_costs = UnitCommitment.MorLatRam2013.StartupCosts(),
transmission = UnitCommitment.ShiftFactorsFormulation(
isf_cutoff = 0.008,
lodf_cutoff = 0.003,
),
),
);
# ## Accessing decision variables
# In the previous tutorial, we saw how to access the optimal solution through `UnitCommitment.solution`. While this approach works well for basic usage, it is also possible to get a direct reference to the JuMP decision variables and query their values, as the next example illustrates.
# First, we load a benchmark instance and solve it, as before.
instance = UnitCommitment.read_benchmark("matpower/case14/2017-01-01");
model =
UnitCommitment.build_model(instance = instance, optimizer = HiGHS.Optimizer);
UnitCommitment.optimize!(model)
# At this point, it is possible to obtain a reference to the decision variables by calling `model[:varname][index]`. For example, `model[:is_on]["g1",1]` returns a direct reference to the JuMP variable indicating whether generator named "g1" is on at time 1. For a complete list of decision variables available, and how are they indexed, see the [problem definition](../guides/problem.md).
@show JuMP.value(model[:is_on]["g1", 1])
# To access second-stage decisions, it is necessary to specify the scenario name. UnitCommitment.jl models deterministic instances as a particular case in which there is a single scenario named "s1", so we need to use this key.
@show JuMP.value(model[:prod_above]["s1", "g1", 1])
# ## Modifying variables and constraints
# When testing variations of the unit commitment problem, it is often necessary to modify the objective function, variables and constraints of the formulation. UnitCommitment.jl makes this process relatively easy. The first step is to construct the standard model using `UnitCommitment.build_model`:
instance = UnitCommitment.read_benchmark("matpower/case14/2017-01-01");
model =
UnitCommitment.build_model(instance = instance, optimizer = HiGHS.Optimizer);
# Now, before calling `UnitCommitment.optimize`, we can make any desired changes to the formulation. In the previous section, we saw how to obtain a direct reference to the decision variables. It is possible to modify them by using standard JuMP methods. For example, to fix the commitment status of a particular generator, we can use `JuMP.fix`:
JuMP.fix(model[:is_on]["g1", 1], 1.0, force = true)
# To modify the cost coefficient of a particular variable, we can use `JuMP.set_objective_coefficient`:
JuMP.set_objective_coefficient(model, model[:switch_on]["g1", 1], 1000.0)
# It is also possible to make changes to the set of constraints. For example, we can add a custom constraint, using the `JuMP.@constraint` macro:
@constraint(model, model[:is_on]["g3", 1] + model[:is_on]["g4", 1] <= 1,);
# We can also remove an existing model constraint using `JuMP.delete`. See the [problem definition](../guides/problem.md) for a list of constraint names and indices.
JuMP.delete(model, model[:eq_min_uptime]["g1", 1])
# After we are done with all changes, we can call `UnitCommitment.optimize` and extract the optimal solution:
UnitCommitment.optimize!(model)
@show UnitCommitment.solution(model)
# ## Modeling new grid components
# In this section we demonstrate how to add a new grid component to a particular bus in the network. This is useful, for example, when developing formulations for a new type of generator, energy storage, or any other grid device. We start by reading the instance data and buliding a standard model:
instance = UnitCommitment.read_benchmark("matpower/case118/2017-02-01")
model =
UnitCommitment.build_model(instance = instance, optimizer = HiGHS.Optimizer);
# Next, we create decision variables for the new grid component. In this example, we assume that the new component can inject up to 10 MW of power at each time step, so we create new continuous variables $0 \leq x_t \leq 10$.
T = instance.time
@variable(model, x[1:T], lower_bound = 0.0, upper_bound = 10.0);
# Next, we add the production costs to the objective function. In this example, we assume a generation cost of \$5/MW:
for t in 1:T
set_objective_coefficient(model, x[t], 5.0)
end
# We then attach the new component to bus `b1` by modifying the net injection constraint (`eq_net_injection`):
for t in 1:T
set_normalized_coefficient(
model[:eq_net_injection]["s1", "b1", t],
x[t],
1.0,
)
end
# Next, we solve the model:
UnitCommitment.optimize!(model)
# We then finally extract the optimal value of the $x$ variables:
@show value.(x)

View File

@@ -1,105 +0,0 @@
# Decomposition methods
## 1. Time decomposition for production cost modeling
Solving unit commitment instances that have long time horizons (for example, year-long 8760-hour instances in production cost modeling) requires a substantial amount of computational power. To address this issue, UC.jl offers a time decomposition method, which breaks the instance down into multiple overlapping subproblems, solves them sequentially, then reassembles the solution.
When solving a unit commitment instance with a dense time slot structure, computational complexity can become a significant challenge. For instance, if the instance contains hourly data for an entire year (8760 hours), solving such a model can require a substantial amount of computational power. To address this issue, UC.jl provides a time_decomposition method within the `optimize!` function. This method decomposes the problem into multiple sub-problems, solving them sequentially.
The `optimize!` function takes 5 parameters: a unit commitment instance, a `TimeDecomposition` method, an optimizer, and two optional functions `after_build` and `after_optimize`. It returns a solution dictionary. The `TimeDecomposition` method itself requires four arguments: `time_window`, `time_increment`, `inner_method` (optional), and `formulation` (optional). These arguments define the time window for each sub-problem, the time increment to move to the next sub-problem, the method used to solve each sub-problem, and the formulation employed, respectively. The two functions, namely `after_build` and `after_optimize`, are invoked subsequent to the construction and optimization of each sub-model, respectively. It is imperative that the `after_build` function requires its two arguments to be consistently mapped to `model` and `instance`, while the `after_optimize` function necessitates its three arguments to be consistently mapped to `solution`, `model`, and `instance`.
The code snippet below illustrates an example of solving an instance by decomposing the model into multiple 36-hour sub-problems using the `XavQiuWanThi2019` method. Each sub-problem advances 24 hours at a time. The first sub-problem covers time steps 1 to 36, the second covers time steps 25 to 60, the third covers time steps 49 to 84, and so on. The initial power levels and statuses of the second and subsequent sub-problems are set based on the results of the first 24 hours from each of their immediate prior sub-problems. In essence, this approach addresses the complexity of solving a large problem by tackling it in 24-hour intervals, while incorporating an additional 12-hour buffer to mitigate the closing window effect for each sub-problem. Furthermore, the `after_build` function imposes the restriction that `g3` and `g4` cannot be activated simultaneously during the initial time slot of each sub-problem. On the other hand, the `after_optimize` function is invoked to calculate the conventional Locational Marginal Prices (LMPs) for each sub-problem, and subsequently appends the computed values to the `lmps` vector.
> **Warning**
> Specifying `TimeDecomposition` as the value of the `inner_method` field of another `TimeDecomposition` causes errors when calling the `optimize!` function due to the different argument structures between the two `optimize!` functions.
```julia
using UnitCommitment, JuMP, Cbc, HiGHS
import UnitCommitment:
TimeDecomposition,
ConventionalLMP,
XavQiuWanThi2019,
Formulation
# specifying the after_build and after_optimize functions
function after_build(model, instance)
@constraint(
model,
model[:is_on]["g3", 1] + model[:is_on]["g4", 1] <= 1,
)
end
lmps = []
function after_optimize(solution, model, instance)
lmp = UnitCommitment.compute_lmp(
model,
ConventionalLMP(),
optimizer = HiGHS.Optimizer,
)
return push!(lmps, lmp)
end
# assume the instance is given as a 120h problem
instance = UnitCommitment.read("instance.json")
solution = UnitCommitment.optimize!(
instance,
TimeDecomposition(
time_window = 36, # solve 36h problems
time_increment = 24, # advance by 24h each time
inner_method = XavQiuWanThi2019.Method(),
formulation = Formulation(),
),
optimizer = Cbc.Optimizer,
after_build = after_build,
after_optimize = after_optimize,
)
```
## 2. Scenario decomposition with Progressive Hedging for stochstic UC
By default, UC.jl uses the Extensive Form (EF) when solving stochastic instances. This approach involves constructing a single JuMP model that contains data and decision variables for all scenarios. Although EF has optimality guarantees and performs well with small test cases, it can become computationally intractable for large instances or substantial number of scenarios.
Progressive Hedging (PH) is an alternative (heuristic) solution method provided by UC.jl in which the problem is decomposed into smaller scenario-based subproblems, which are then solved in parallel in separate Julia processes, potentially across multiple machines. Quadratic penalty terms are used to enforce convergence of first-stage decision variables. The method is closely related to the Alternative Direction Method of Multipliers (ADMM) and can handle larger instances, although it is not guaranteed to converge to the optimal solution. Our implementation of PH relies on Message Passing Interface (MPI) for communication. We refer to [MPI.jl Documentation](https://github.com/JuliaParallel/MPI.jl) for more details on installing MPI.
The following example shows how to solve SCUC instances using progressive hedging. The script should be saved in a file, say `ph.jl`, and executed using `mpiexec -n <num-scenarios> julia ph.jl`.
```julia
using HiGHS
using MPI
using UnitCommitment
using Glob
# 1. Initialize MPI
MPI.Init()
# 2. Configure progressive hedging method
ph = UnitCommitment.ProgressiveHedging()
# 3. Read problem instance
instance = UnitCommitment.read(["example/s1.json", "example/s2.json"], ph)
# 4. Build JuMP model
model = UnitCommitment.build_model(
instance = instance,
optimizer = HiGHS.Optimizer,
)
# 5. Run the decentralized optimization algorithm
UnitCommitment.optimize!(model, ph)
# 6. Fetch the solution
solution = UnitCommitment.solution(model, ph)
# 7. Close MPI
MPI.Finalize()
```
When using PH, the model can be customized as usual, with different formulations or additional user-provided constraints. Note that `read`, in this case, takes `ph` as an argument. This allows each Julia process to read only the instance files that are relevant to it. Similarly, the `solution` function gathers the optimal solution of each processes and returns a combined dictionary.
Each process solves a sub-problem with $\frac{s}{p}$ scenarios, where $s$ is the total number of scenarios and $p$ is the number of MPI processes. For instance, if we have 15 scenario files and 5 processes, then each process will solve a JuMP model that contains data for 3 scenarios. If the total number of scenarios is not divisible by the number of processes, then an error will be thrown.
!!! warning
Currently, PH can handle only equiprobable scenarios. Further, `solution(model, ph)` can only handle cases where only one scenario is modeled in each process.

View File

@@ -1,57 +0,0 @@
# # Locational Marginal Prices
# Locational Marginal Prices (LMPs) refer to the cost of supplying electricity at specific locations of the network. LMPs are crucial for the operation of electricity markets and have many other applications, such as indicating what areas of the network may require additional generation or transmission capacity. UnitCommitment.jl implements two methods for calculating LMPS: Conventional LMPs and Approximated Extended LMPs (AELMPs). In this tutorial, we introduce each method and illustrate their usage.
# ### Conventional LMPs
# Conventional LMPs work by (1) solving the original SCUC problem, (2) fixing all binary variables to their optimal values, and (3) re-solving the resulting linear programming model. In this approach, the LMPs are defined as the values of the dual variables associated with the net injection constraints.
# The first step to use this method is to load and optimize an instance, as explained in previous tutorials:
using UnitCommitment
using HiGHS
instance = UnitCommitment.read_benchmark("matpower/case14/2017-01-01")
model =
UnitCommitment.build_model(instance = instance, optimizer = HiGHS.Optimizer)
UnitCommitment.optimize!(model)
# Next, we call `UnitCommitment.compute_lmp`, as shown below. The function accepts three arguments -- a solved SCUC model, the LMP method, and a linear optimizer -- and it returns a dictionary mapping `(scenario_name, bus_name, time)` to the marginal price.
lmp = UnitCommitment.compute_lmp(
model,
UnitCommitment.ConventionalLMP(),
optimizer = HiGHS.Optimizer,
)
# For example, the following code queries the LMP of bus `b1` in scenario `s1` at time 1:
@show lmp["s1", "b1", 1]
# ### Approximate Extended LMPs
# Approximate Extended LMPs (AELMPs) are an alternative method to calculate locational marginal prices which attemps to minimize uplift payments. The method internally works by modifying the instance data in three ways: (1) it sets the minimum power output of each generator to zero, (2) it averages the start-up cost over the offer blocks for each generator, and (3) it relaxes all integrality constraints. To compute AELMPs, as shown in the example below, we call `compute_lmp` and provide `UnitCommitment.AELMP()` as the second argument.
# This method has two configurable parameters: `allow_offline_participation` and `consider_startup_costs`. If `allow_offline_participation = true`, then offline generators are allowed to participate in the pricing. If instead `allow_offline_participation = false`, offline generators are not allowed and therefore are excluded from the system. A solved UC model is optional if offline participation is allowed, but is required if not allowed. The method forces offline participation to be allowed if the UC model supplied by the user is not solved. For the second field, If `consider_startup_costs = true`, then start-up costs are integrated and averaged over each unit production; otherwise the production costs stay the same. By default, both fields are set to `true`.
# !!! warning
# This method is still under active research, and has several limitations. The implementation provided in the package is based on MISO Phase I only. It only supports fast start resources. More specifically, the minimum up/down time of all generators must be 1, the initial power of all generators must be 0, and the initial status of all generators must be negative. The method does not support time-varying start-up costs, and only currently works for deterministic instances. If offline participation is not allowed, AELMPs treats an asset to be offline if it is never on throughout all time periods.
instance = UnitCommitment.read_benchmark("test/aelmp_simple")
model =
UnitCommitment.build_model(instance = instance, optimizer = HiGHS.Optimizer)
UnitCommitment.optimize!(model)
lmp = UnitCommitment.compute_lmp(
model,
UnitCommitment.AELMP(
allow_offline_participation = false,
consider_startup_costs = true,
),
optimizer = HiGHS.Optimizer,
)
@show lmp["s1", "B1", 1]

View File

@@ -1,183 +0,0 @@
# # Market Clearing
# In North America, electricity markets are structured around two primary types of markets: the day-ahead (DA) market and the real-time (RT) market. The DA market schedules electricity generation and consumption for the next day, based on forecasts and bids from electricity suppliers and consumers. The RT market, on the other hand, operates continuously throughout the day, addressing the discrepancies between the DA schedule and actual demand, typically every five minutes. UnitCommitment.jl is able to simulate the DA and RT market clearing process. Specifically, the package provides the function `UnitCommitment.solve_market` which performs the following steps:
# 1. Solve the DA market problem.
# 2. Extract commitment status of all generators.
# 3. Solve a sequence of RT market problems, fixing the commitment status of each generator to the corresponding optimal solution of the DA problem.
# To use this function, we need to prepare an instance file corresponding to the DA market problem and multiple instance files corresponding to the RT market problems. The number of required files depends on the time granularity and window. For example, suppose that the DA problem is solved at hourly granularity and has 24 time periods, whereas the RT problems are solved at 5-minute granularity and have a single time period. Then we would need to prepare one files for the DA problem and 288 files $\left(24 \times \frac{60}{5}\right)$ for the RT market problems.
# ## A small example
# For simplicity, in this tutorial we illustate the usage of `UnitCommitment.solve_market` with a very small example, in which the DA problem has only two time periods. We start by creating the DA instance file:
da_contents = """
{
"Parameters": {
"Version": "0.4",
"Time horizon (h)": 2
},
"Buses": {
"b1": {
"Load (MW)": [200, 400]
}
},
"Generators": {
"g1": {
"Bus": "b1",
"Type": "Thermal",
"Production cost curve (MW)": [0, 200],
"Production cost curve (\$)": [0, 1000],
"Initial status (h)": -24,
"Initial power (MW)": 0
},
"g2": {
"Bus": "b1",
"Type": "Thermal",
"Production cost curve (MW)": [0, 300],
"Production cost curve (\$)": [0, 3000],
"Initial status (h)": -24,
"Initial power (MW)": 0
}
}
}
""";
open("da.json", "w") do file
return write(file, da_contents)
end;
# Next, we create eight single-period RT market problems, each one with a 15-minute time granularity:
for i in 1:8
rt_contents = """
{
"Parameters": {
"Version": "0.4",
"Time horizon (min)": 15,
"Time step (min)": 15
},
"Buses": {
"b1": {
"Load (MW)": [$(150 + 50 * i)]
}
},
"Generators": {
"g1": {
"Bus": "b1",
"Type": "Thermal",
"Production cost curve (MW)": [0, 200],
"Production cost curve (\$)": [0, 1000],
"Initial status (h)": -24,
"Initial power (MW)": 0
},
"g2": {
"Bus": "b1",
"Type": "Thermal",
"Production cost curve (MW)": [0, 300],
"Production cost curve (\$)": [0, 3000],
"Initial status (h)": -24,
"Initial power (MW)": 0
}
}
}
"""
open("rt_$i.json", "w") do file
return write(file, rt_contents)
end
end
# Finally, we call `UnitCommitment.solve_market`, providing as arguments (1) the path to the DA problem; (2) a list of paths to the RT problems; (3) the mixed-integer linear optimizer.
using UnitCommitment
using HiGHS
solution = UnitCommitment.solve_market(
"da.json",
[
"rt_1.json",
"rt_2.json",
"rt_3.json",
"rt_4.json",
"rt_5.json",
"rt_6.json",
"rt_7.json",
"rt_8.json",
],
optimizer = HiGHS.Optimizer,
)
# To retrieve the day-ahead market solution, we can query `solution["DA"]`:
@show solution["DA"]
# To query each real-time market solution, we can query `solution["RT"][i]`. Note that LMPs are automativally calculated.
@show solution["RT"][1]
# ## Customizing the model and LMPs
# When using the `solve_market` function it is still possible to customize the problem formulation and the LMP calculation method. In the next example, we use a custom formulation and explicitly specify the LMP method through the `settings` keyword argument:
UnitCommitment.solve_market(
"da.json",
[
"rt_1.json",
"rt_2.json",
"rt_3.json",
"rt_4.json",
"rt_5.json",
"rt_6.json",
"rt_7.json",
"rt_8.json",
],
settings = UnitCommitment.MarketSettings(
lmp_method = UnitCommitment.ConventionalLMP(),
formulation = UnitCommitment.Formulation(
pwl_costs = UnitCommitment.KnuOstWat2018.PwlCosts(),
ramping = UnitCommitment.MorLatRam2013.Ramping(),
startup_costs = UnitCommitment.MorLatRam2013.StartupCosts(),
transmission = UnitCommitment.ShiftFactorsFormulation(
isf_cutoff = 0.008,
lodf_cutoff = 0.003,
),
),
),
optimizer = HiGHS.Optimizer,
)
# It is also possible to add custom variables and constraints to either the DA or RT market problems, through the usage of `after_build_da` and `after_build_rt` callback functions. Similarly, the `after_optimize_da` and `after_optimize_rt` can be used to directly analyze the JuMP models, after they have been optimized:
using JuMP
function after_build_da(model, instance)
@constraint(model, model[:is_on]["g1", 1] <= model[:is_on]["g2", 1])
end
function after_optimize_da(solution, model, instance)
@show value(model[:is_on]["g1", 1])
end
UnitCommitment.solve_market(
"da.json",
[
"rt_1.json",
"rt_2.json",
"rt_3.json",
"rt_4.json",
"rt_5.json",
"rt_6.json",
"rt_7.json",
"rt_8.json",
],
after_build_da = after_build_da,
after_optimize_da = after_optimize_da,
optimizer = HiGHS.Optimizer,
)
# ## Additional considerations
# - UC.jl supports two-stage stochastic DA market problems. In this case, we need one file for each DA market scenario. All RT market problems must be deterministic.
# - UC.jl also supports multi-period RT market problems. Assume, for example, that the DA market problem is an hourly problem with 24 time periods, whereas the RT market problem uses 5-minute granularity with 4 time periods. UC.jl assumes that the first RT file covers period `0:00` to `0:20`, the second covers `0:05` to `0:25` and so on. We therefore still need 288 RT market files. To avoid going beyond the 24-hour period covered by the DA market solution, however, the last few RT market problems must have only 3, 2, and 1 time periods, covering `23:45` to `24:00`, `23:50` to `24:00` and `23:55` to `24:00`, respectively.
# - Some MILP solvers (such as Cbc) have issues handling linear programming problems, which are required for the RT market. In this case, a separate linear programming solver can be provided to `solve_market` using the `lp_optimizer` argument. For example, `solve_market(da_file, rt_files, optimizer=Cbc.Optimizer, lp_optimizer=Clp.Optimizer)`.

View File

@@ -1,211 +0,0 @@
# # Getting started
# ## Installing the package
# UnitCommitment.jl was tested and developed with [Julia 1.10](https://julialang.org/). To install Julia, please follow the [installation guide on the official Julia website](https://julialang.org/downloads/). To install UnitCommitment.jl, run the Julia interpreter, type `]` to open the package manager, then type:
# ```text
# pkg> add UnitCommitment@0.4
# ```
# To solve the optimization models, a mixed-integer linear programming (MILP) solver is also required. Please see the [JuMP installation guide](https://jump.dev/JuMP.jl/stable/installation/) for more instructions on installing a solver. Typical open-source choices are [HiGHS](https://github.com/jump-dev/HiGHS.jl), [Cbc](https://github.com/JuliaOpt/Cbc.jl) and [GLPK](https://github.com/JuliaOpt/GLPK.jl). In the instructions below, HiGHS will be used, but any other MILP solver should also be compatible.
# ## Solving a benchmark instance
# We start this tutorial by illustrating how to use UnitCommitment.jl to solve one of the provided benchmark instances. The package contains a large number of deterministic benchmark instances collected from the literature and converted into a common data format, which can be used to evaluate the performance of different solution methods. See [Instances](../guides/instances.md) for more details. The first step is to import `UnitCommitment` and HiGHS.
using HiGHS
using UnitCommitment
# Next, we use the function `UnitCommitment.read_benchmark` to read the instance.
instance = UnitCommitment.read_benchmark("matpower/case14/2017-01-01");
# Now that we have the instance loaded in memory, we build the JuMP optimization model using `UnitCommitment.build_model`:
model =
UnitCommitment.build_model(instance = instance, optimizer = HiGHS.Optimizer);
# Next, we run the optimization process, with `UnitCommitment.optimize!`:
UnitCommitment.optimize!(model)
# Finally, we extract the optimal solution from the model:
solution = UnitCommitment.solution(model)
# We can then explore the solution using Julia:
@show solution["Thermal production (MW)"]["g1"]
# Or export the entire solution to a JSON file:
UnitCommitment.write("solution.json", solution)
# ## Solving a custom deterministic instance
# In the previous example, we solved a benchmark instance provided by the package. To solve a custom instance, the first step is to create an input file describing the list of elements (generators, loads and transmission lines) in the network. See [Data Format](../guides/format.md) for a complete description of the data format UC.jl expects. To keep this tutorial self-contained, we will create the input JSON file using Julia; however, this step can also be done with a simple text editor. First, we define the contents of the file:
json_contents = """
{
"Parameters": {
"Version": "0.4",
"Time horizon (h)": 4
},
"Buses": {
"b1": {
"Load (MW)": [100, 150, 200, 250]
}
},
"Generators": {
"g1": {
"Bus": "b1",
"Type": "Thermal",
"Production cost curve (MW)": [0, 200],
"Production cost curve (\$)": [0, 1000],
"Initial status (h)": -24,
"Initial power (MW)": 0
},
"g2": {
"Bus": "b1",
"Type": "Thermal",
"Production cost curve (MW)": [0, 300],
"Production cost curve (\$)": [0, 3000],
"Initial status (h)": -24,
"Initial power (MW)": 0
}
}
}
""";
# Next, we write it to `example.json`.
open("example.json", "w") do file
return write(file, json_contents)
end;
# Now that we have the input file, we can proceed as before, but using `UnitCommitment.read` instead of `UnitCommitment.read_benchmark`:
instance = UnitCommitment.read("example.json");
model =
UnitCommitment.build_model(instance = instance, optimizer = HiGHS.Optimizer);
UnitCommitment.optimize!(model)
# Finally, we extract and display the solution:
solution = UnitCommitment.solution(model)
#
@show solution["Thermal production (MW)"]["g1"]
#
@show solution["Thermal production (MW)"]["g2"]
# ## Solving a custom stochastic instance
# In addition to deterministic test cases, UnitCommitment.jl can also solve two-stage stochastic instances of the problem. In this section, we demonstrate the most simple form, which builds a single (extensive form) model containing information for all scenarios. See [Decomposition](../tutorials/decomposition.md) for more advanced methods.
# First, we need to create one JSON input file for each scenario. Parameters that are allowed to change across scenarios are marked as "uncertain" in the [JSON data format](../guides/format.md) page. It is also possible to specify the name and weight of each scenario, as shown below.
# We start by creating `example_s1.json`, the first scenario file:
json_contents_s1 = """
{
"Parameters": {
"Version": "0.4",
"Time horizon (h)": 4,
"Scenario name": "s1",
"Scenario weight": 3.0
},
"Buses": {
"b1": {
"Load (MW)": [100, 150, 200, 250]
}
},
"Generators": {
"g1": {
"Bus": "b1",
"Type": "Thermal",
"Production cost curve (MW)": [0, 200],
"Production cost curve (\$)": [0, 1000],
"Initial status (h)": -24,
"Initial power (MW)": 0
},
"g2": {
"Bus": "b1",
"Type": "Thermal",
"Production cost curve (MW)": [0, 300],
"Production cost curve (\$)": [0, 3000],
"Initial status (h)": -24,
"Initial power (MW)": 0
}
}
}
"""
open("example_s1.json", "w") do file
return write(file, json_contents_s1)
end;
# Next, we create `example_s2.json`, the second scenario file:
json_contents_s2 = """
{
"Parameters": {
"Version": "0.4",
"Time horizon (h)": 4,
"Scenario name": "s2",
"Scenario weight": 1.0
},
"Buses": {
"b1": {
"Load (MW)": [200, 300, 400, 500]
}
},
"Generators": {
"g1": {
"Bus": "b1",
"Type": "Thermal",
"Production cost curve (MW)": [0, 200],
"Production cost curve (\$)": [0, 1000],
"Initial status (h)": -24,
"Initial power (MW)": 0
},
"g2": {
"Bus": "b1",
"Type": "Thermal",
"Production cost curve (MW)": [0, 300],
"Production cost curve (\$)": [0, 3000],
"Initial status (h)": -24,
"Initial power (MW)": 0
}
}
}
""";
open("example_s2.json", "w") do file
return write(file, json_contents_s2)
end;
# Now that we have our two scenario files, we can read them using `UnitCommitment.read`. Note that, instead of a single file, we now provide a list.
instance = UnitCommitment.read(["example_s1.json", "example_s2.json"])
# If we have a large number of scenario files, the [Glob](https://github.com/vtjnash/Glob.jl) package can also be used to avoid having to list them individually:
using Glob
instance = UnitCommitment.read(glob("example_s*.json"))
# Finally, we build the model and optimize as before:
model =
UnitCommitment.build_model(instance = instance, optimizer = HiGHS.Optimizer);
UnitCommitment.optimize!(model)
# The solution to stochastic instances follows a slightly different format, as shown below:
solution = UnitCommitment.solution(model)
# The solution for each scenario can be accessed through `solution[scenario_name]`. For conveniance, this includes both first- and second-stage optimal decisions:
solution["s1"]

View File

@@ -1,74 +0,0 @@
# ## Generating initial conditions
# When creating random unit commitment instances for benchmark purposes, it is often hard to compute, in advance, sensible initial conditions for all thermal generators. Setting initial conditions naively (for example, making all generators initially off and producing no power) can easily cause the instance to become infeasible due to excessive ramping. Initial conditions can also make it hard to modify existing instances. For example, increasing the system load without carefully modifying the initial conditions may make the problem infeasible or unrealistically challenging to solve.
# To help with this issue, UC.jl provides a utility function which can generate feasible initial conditions by solving a single-period optimization problem. To illustrate its usage, we first generate a JSON file without initial conditions:
json_contents = """
{
"Parameters": {
"Version": "0.4",
"Time horizon (h)": 4
},
"Buses": {
"b1": {
"Load (MW)": [100, 150, 200, 250]
}
},
"Generators": {
"g1": {
"Bus": "b1",
"Type": "Thermal",
"Production cost curve (MW)": [0, 200],
"Production cost curve (\$)": [0, 1000]
},
"g2": {
"Bus": "b1",
"Type": "Thermal",
"Production cost curve (MW)": [0, 300],
"Production cost curve (\$)": [0, 3000]
}
}
}
""";
open("example_initial.json", "w") do file
return write(file, json_contents)
end;
# Next, we read the instance and generate the initial conditions (in-place):
instance = UnitCommitment.read("example_initial.json")
UnitCommitment.generate_initial_conditions!(instance, HiGHS.Optimizer)
# Finally, we optimize the resulting problem:
model =
UnitCommitment.build_model(instance = instance, optimizer = HiGHS.Optimizer)
UnitCommitment.optimize!(model)
# !!! warning
# The function `generate_initial_conditions!` may return different initial conditions after each call, even if the same instance and the same optimizer is provided. The particular algorithm may also change in a future version of UC.jl. For these reasons, it is recommended that you generate initial conditions exactly once for each instance and store them for later use.
# ## 6. Verifying solutions
# When developing new formulations, it is very easy to introduce subtle errors in the model that result in incorrect solutions. To help avoiding this, UC.jl includes a utility function that verifies if a given solution is feasible, and, if not, prints all the validation errors it found. The implementation of this function is completely independent from the implementation of the optimization model, and therefore can be used to validate it.
# ```jldoctest; output = false
# using JSON
# using UnitCommitment
# # Read instance
# instance = UnitCommitment.read("example/s1.json")
# # Read solution (potentially produced by other packages)
# solution = JSON.parsefile("example/out.json")
# # Validate solution and print validation errors
# UnitCommitment.validate(instance, solution)
# # output
# true
# ```

381
docs/src/usage.md Normal file
View File

@@ -0,0 +1,381 @@
Usage
=====
Installation
------------
UnitCommitment.jl was tested and developed with [Julia 1.9](https://julialang.org/). To install Julia, please follow the [installation guide on the official Julia website](https://julialang.org/downloads/). To install UnitCommitment.jl, run the Julia interpreter, type `]` to open the package manager, then type:
```text
pkg> add UnitCommitment@0.4
```
To solve the optimization models, a mixed-integer linear programming (MILP) solver is also required. Please see the [JuMP installation guide](https://jump.dev/JuMP.jl/stable/installation/) for more instructions on installing a solver. Typical open-source choices are [HiGHS](https://github.com/jump-dev/HiGHS.jl), [Cbc](https://github.com/JuliaOpt/Cbc.jl) and [GLPK](https://github.com/JuliaOpt/GLPK.jl). In the instructions below, HiGHS will be used, but any other MILP solver listed in JuMP installation guide should also be compatible.
Typical Usage
-------------
### Solving user-provided instances
The first step to use UC.jl is to construct JSON files that describe each scenario of your deterministic or stochastic unit commitment instance. See [Data Format](format.md) for a complete description of the data format UC.jl expects. The next steps, as shown below, are to: (1) read the scenario files; (2) build the optimization model; (3) run the optimization; and (4) extract the optimal solution.
```julia
using HiGHS
using JuMP
using UnitCommitment
# 1. Read instance
instance = UnitCommitment.read(["example/s1.json", "example/s2.json"])
# 2. Construct optimization model
model = UnitCommitment.build_model(
instance=instance,
optimizer=HiGHS.Optimizer,
)
# 3. Solve model
UnitCommitment.optimize!(model)
# 4. Write solution to a file
solution = UnitCommitment.solution(model)
UnitCommitment.write("example/out.json", solution)
```
To read multiple files from a given folder, the [Glob](https://github.com/vtjnash/Glob.jl) package can be used:
```jldoctest usage1; output = false
using Glob
using UnitCommitment
instance = UnitCommitment.read(glob("s*.json", "example/"))
# output
UnitCommitmentInstance(2 scenarios, 6 thermal units, 0 profiled units, 14 buses, 20 lines, 19 contingencies, 1 price sensitive loads, 4 time steps)
```
To solve deterministic instances, a single scenario file may be provided.
```jldoctest usage1; output = false
instance = UnitCommitment.read("example/s1.json")
# output
UnitCommitmentInstance(1 scenarios, 6 thermal units, 0 profiled units, 14 buses, 20 lines, 19 contingencies, 1 price sensitive loads, 4 time steps)
```
### Solving benchmark instances
UnitCommitment.jl contains a large number of deterministic benchmark instances collected from the literature and converted into a common data format. To solve one of these instances individually, instead of constructing your own, the function `read_benchmark` can be used, as shown below. See [Instances](instances.md) for the complete list of available instances.
```jldoctest usage1; output = false
instance = UnitCommitment.read_benchmark("matpower/case3375wp/2017-02-01")
# output
UnitCommitmentInstance(1 scenarios, 590 thermal units, 0 profiled units, 3374 buses, 4161 lines, 3245 contingencies, 0 price sensitive loads, 36 time steps)
```
## Customizing the formulation
By default, `build_model` uses a formulation that combines modeling components from different publications, and that has been carefully tested, using our own benchmark scripts, to provide good performance across a wide variety of instances. This default formulation is expected to change over time, as new methods are proposed in the literature. You can, however, construct your own formulation, based on the modeling components that you choose, as shown in the next example.
```julia
using HiGHS
using UnitCommitment
import UnitCommitment:
Formulation,
KnuOstWat2018,
MorLatRam2013,
ShiftFactorsFormulation
instance = UnitCommitment.read_benchmark(
"matpower/case118/2017-02-01",
)
model = UnitCommitment.build_model(
instance = instance,
optimizer = HiGHS.Optimizer,
formulation = Formulation(
pwl_costs = KnuOstWat2018.PwlCosts(),
ramping = MorLatRam2013.Ramping(),
startup_costs = MorLatRam2013.StartupCosts(),
transmission = ShiftFactorsFormulation(
isf_cutoff = 0.005,
lodf_cutoff = 0.001,
),
),
)
```
## Generating initial conditions
When creating random unit commitment instances for benchmark purposes, it is often hard to compute, in advance, sensible initial conditions for all thermal generators. Setting initial conditions naively (for example, making all generators initially off and producing no power) can easily cause the instance to become infeasible due to excessive ramping. Initial conditions can also make it hard to modify existing instances. For example, increasing the system load without carefully modifying the initial conditions may make the problem infeasible or unrealistically challenging to solve.
To help with this issue, UC.jl provides a utility function which can generate feasible initial conditions by solving a single-period optimization problem, as shown below:
```julia
using HiGHS
using UnitCommitment
# Read original instance
instance = UnitCommitment.read("example/s1.json")
# Generate initial conditions (in-place)
UnitCommitment.generate_initial_conditions!(instance, HiGHS.Optimizer)
# Construct and solve optimization model
model = UnitCommitment.build_model(
instance=instance,
optimizer=HiGHS.Optimizer,
)
UnitCommitment.optimize!(model)
```
!!! warning
The function `generate_initial_conditions!` may return different initial conditions after each call, even if the same instance and the same optimizer is provided. The particular algorithm may also change in a future version of UC.jl. For these reasons, it is recommended that you generate initial conditions exactly once for each instance and store them for later use.
## Verifying solutions
When developing new formulations, it is very easy to introduce subtle errors in the model that result in incorrect solutions. To help avoiding this, UC.jl includes a utility function that verifies if a given solution is feasible, and, if not, prints all the validation errors it found. The implementation of this function is completely independent from the implementation of the optimization model, and therefore can be used to validate it.
```jldoctest; output = false
using JSON
using UnitCommitment
# Read instance
instance = UnitCommitment.read("example/s1.json")
# Read solution (potentially produced by other packages)
solution = JSON.parsefile("example/out.json")
# Validate solution and print validation errors
UnitCommitment.validate(instance, solution)
# output
true
```
## Progressive Hedging
By default, UC.jl uses the Extensive Form (EF) when solving stochastic instances. This approach involves constructing a single JuMP model that contains data and decision variables for all scenarios. Although EF has optimality guarantees and performs well with small test cases, it can become computationally intractable for large instances or substantial number of scenarios.
Progressive Hedging (PH) is an alternative (heuristic) solution method provided by UC.jl in which the problem is decomposed into smaller scenario-based subproblems, which are then solved in parallel in separate Julia processes, potentially across multiple machines. Quadratic penalty terms are used to enforce convergence of first-stage decision variables. The method is closely related to the Alternative Direction Method of Multipliers (ADMM) and can handle larger instances, although it is not guaranteed to converge to the optimal solution. Our implementation of PH relies on Message Passing Interface (MPI) for communication. We refer to [MPI.jl Documentation](https://github.com/JuliaParallel/MPI.jl) for more details on installing MPI.
The following example shows how to solve SCUC instances using progressive hedging. The script should be saved in a file, say `ph.jl`, and executed using `mpiexec -n <num-scenarios> julia ph.jl`.
```julia
using HiGHS
using MPI
using UnitCommitment
using Glob
# 1. Initialize MPI
MPI.Init()
# 2. Configure progressive hedging method
ph = UnitCommitment.ProgressiveHedging()
# 3. Read problem instance
instance = UnitCommitment.read(["example/s1.json", "example/s2.json"], ph)
# 4. Build JuMP model
model = UnitCommitment.build_model(
instance = instance,
optimizer = HiGHS.Optimizer,
)
# 5. Run the decentralized optimization algorithm
UnitCommitment.optimize!(model, ph)
# 6. Fetch the solution
solution = UnitCommitment.solution(model, ph)
# 7. Close MPI
MPI.Finalize()
```
When using PH, the model can be customized as usual, with different formulations or additional user-provided constraints. Note that `read`, in this case, takes `ph` as an argument. This allows each Julia process to read only the instance files that are relevant to it. Similarly, the `solution` function gathers the optimal solution of each processes and returns a combined dictionary.
Each process solves a sub-problem with $\frac{s}{p}$ scenarios, where $s$ is the total number of scenarios and $p$ is the number of MPI processes. For instance, if we have 15 scenario files and 5 processes, then each process will solve a JuMP model that contains data for 3 scenarios. If the total number of scenarios is not divisible by the number of processes, then an error will be thrown.
!!! warning
Currently, PH can handle only equiprobable scenarios. Further, `solution(model, ph)` can only handle cases where only one scenario is modeled in each process.
## Computing Locational Marginal Prices
Locational marginal prices (LMPs) refer to the cost of supplying electricity at a particular location of the network. Multiple methods for computing LMPs have been proposed in the literature. UnitCommitment.jl implements two commonly-used methods: conventional LMPs and Approximated Extended LMPs (AELMPs). To compute LMPs for a given unit commitment instance, the `compute_lmp` function can be used, as shown in the examples below. The function accepts three arguments -- a solved SCUC model, an LMP method, and a linear optimizer -- and it returns a dictionary mapping `(bus_name, time)` to the marginal price.
!!! warning
Most mixed-integer linear optimizers, such as `HiGHS`, `Gurobi` and `CPLEX` can be used with `compute_lmp`, with the notable exception of `Cbc`, which does not support dual value evaluations. If using `Cbc`, please provide `Clp` as the linear optimizer.
### Conventional LMPs
LMPs are conventionally computed by: (1) solving the SCUC model, (2) fixing all binary variables to their optimal values, and (3) re-solving the resulting linear programming model. In this approach, the LMPs are defined as the dual variables' values associated with the net injection constraints. The example below shows how to compute conventional LMPs for a given unit commitment instance. First, we build and optimize the SCUC model. Then, we call the `compute_lmp` function, providing as the second argument `ConventionalLMP()`.
```julia
using UnitCommitment
using HiGHS
import UnitCommitment: ConventionalLMP
# Read benchmark instance
instance = UnitCommitment.read_benchmark("matpower/case118/2018-01-01")
# Build the model
model = UnitCommitment.build_model(
instance = instance,
optimizer = HiGHS.Optimizer,
)
# Optimize the model
UnitCommitment.optimize!(model)
# Compute the LMPs using the conventional method
lmp = UnitCommitment.compute_lmp(
model,
ConventionalLMP(),
optimizer = HiGHS.Optimizer,
)
# Access the LMPs
# Example: "s1" is the scenario name, "b1" is the bus name, 1 is the first time slot
@show lmp["s1","b1", 1]
```
### Approximate Extended LMPs
Approximate Extended LMPs (AELMPs) are an alternative method to calculate locational marginal prices which attemps to minimize uplift payments. The method internally works by modifying the instance data in three ways: (1) it sets the minimum power output of each generator to zero, (2) it averages the start-up cost over the offer blocks for each generator, and (3) it relaxes all integrality constraints. To compute AELMPs, as shown in the example below, we call `compute_lmp` and provide `AELMP()` as the second argument.
This method has two configurable parameters: `allow_offline_participation` and `consider_startup_costs`. If `allow_offline_participation = true`, then offline generators are allowed to participate in the pricing. If instead `allow_offline_participation = false`, offline generators are not allowed and therefore are excluded from the system. A solved UC model is optional if offline participation is allowed, but is required if not allowed. The method forces offline participation to be allowed if the UC model supplied by the user is not solved. For the second field, If `consider_startup_costs = true`, then start-up costs are integrated and averaged over each unit production; otherwise the production costs stay the same. By default, both fields are set to `true`.
!!! warning
This approximation method is still under active research, and has several limitations. The implementation provided in the package is based on MISO Phase I only. It only supports fast start resources. More specifically, the minimum up/down time of all generators must be 1, the initial power of all generators must be 0, and the initial status of all generators must be negative. The method does not support time-varying start-up costs. The method does not support multiple scenarios. If offline participation is not allowed, AELMPs treats an asset to be offline if it is never on throughout all time periods.
```julia
using UnitCommitment
using HiGHS
import UnitCommitment: AELMP
# Read benchmark instance
instance = UnitCommitment.read_benchmark("matpower/case118/2017-02-01")
# Build the model
model = UnitCommitment.build_model(
instance = instance,
optimizer = HiGHS.Optimizer,
)
# Optimize the model
UnitCommitment.optimize!(model)
# Compute the AELMPs
aelmp = UnitCommitment.compute_lmp(
model,
AELMP(
allow_offline_participation = false,
consider_startup_costs = true
),
optimizer = HiGHS.Optimizer
)
# Access the AELMPs
# Example: "s1" is the scenario name, "b1" is the bus name, 1 is the first time slot
# Note: although scenario is supported, the query still keeps the scenario keys for consistency.
@show aelmp["s1", "b1", 1]
```
## Time Decomposition
Solving unit commitment instances that have long time horizons (for example, year-long 8760-hour instances) requires a substantial amount of computational power. To address this issue, UC.jl offers a time decomposition method, which breaks the instance down into multiple overlapping subproblems, solves them sequentially, then reassembles the solution.
When solving a unit commitment instance with a dense time slot structure, computational complexity can become a significant challenge. For instance, if the instance contains hourly data for an entire year (8760 hours), solving such a model can require a substantial amount of computational power. To address this issue, UC.jl provides a time_decomposition method within the `optimize!` function. This method decomposes the problem into multiple sub-problems, solving them sequentially.
The `optimize!` function takes 5 parameters: a unit commitment instance, a `TimeDecomposition` method, an optimizer, and two optional functions `after_build` and `after_optimize`. It returns a solution dictionary. The `TimeDecomposition` method itself requires four arguments: `time_window`, `time_increment`, `inner_method` (optional), and `formulation` (optional). These arguments define the time window for each sub-problem, the time increment to move to the next sub-problem, the method used to solve each sub-problem, and the formulation employed, respectively. The two functions, namely `after_build` and `after_optimize`, are invoked subsequent to the construction and optimization of each sub-model, respectively. It is imperative that the `after_build` function requires its two arguments to be consistently mapped to `model` and `instance`, while the `after_optimize` function necessitates its three arguments to be consistently mapped to `solution`, `model`, and `instance`.
The code snippet below illustrates an example of solving an instance by decomposing the model into multiple 36-hour sub-problems using the `XavQiuWanThi2019` method. Each sub-problem advances 24 hours at a time. The first sub-problem covers time steps 1 to 36, the second covers time steps 25 to 60, the third covers time steps 49 to 84, and so on. The initial power levels and statuses of the second and subsequent sub-problems are set based on the results of the first 24 hours from each of their immediate prior sub-problems. In essence, this approach addresses the complexity of solving a large problem by tackling it in 24-hour intervals, while incorporating an additional 12-hour buffer to mitigate the closing window effect for each sub-problem. Furthermore, the `after_build` function imposes the restriction that `g3` and `g4` cannot be activated simultaneously during the initial time slot of each sub-problem. On the other hand, the `after_optimize` function is invoked to calculate the conventional Locational Marginal Prices (LMPs) for each sub-problem, and subsequently appends the computed values to the `lmps` vector.
> **Warning**
> Specifying `TimeDecomposition` as the value of the `inner_method` field of another `TimeDecomposition` causes errors when calling the `optimize!` function due to the different argument structures between the two `optimize!` functions.
```julia
using UnitCommitment, JuMP, Cbc, HiGHS
import UnitCommitment:
TimeDecomposition,
ConventionalLMP,
XavQiuWanThi2019,
Formulation
# specifying the after_build and after_optimize functions
function after_build(model, instance)
@constraint(
model,
model[:is_on]["g3", 1] + model[:is_on]["g4", 1] <= 1,
)
end
lmps = []
function after_optimize(solution, model, instance)
lmp = UnitCommitment.compute_lmp(
model,
ConventionalLMP(),
optimizer = HiGHS.Optimizer,
)
return push!(lmps, lmp)
end
# assume the instance is given as a 120h problem
instance = UnitCommitment.read("instance.json")
solution = UnitCommitment.optimize!(
instance,
TimeDecomposition(
time_window = 36, # solve 36h problems
time_increment = 24, # advance by 24h each time
inner_method = XavQiuWanThi2019.Method(),
formulation = Formulation(),
),
optimizer = Cbc.Optimizer,
after_build = after_build,
after_optimize = after_optimize,
)
```
## Day-ahead (DA) Market to Real-time (RT) Markets
The UC.jl package offers a comprehensive set of functions for solving marketing problems. The primary function, `solve_market`, facilitates the solution of day-ahead (DA) markets, which can be either deterministic or stochastic in nature. Subsequently, it sequentially maps the commitment status obtained from the DA market to all the real-time (RT) markets, which are deterministic instances. It is essential to ensure that the time span of the DA market encompasses all the RT markets, and the file paths for the RT markets must be specified in chronological order. Each RT market should represent a single time slot, and it is recommended to include a few additional time slots to mitigate the closing window effect.
The `solve_market` function accepts several parameters, including the file path (or a list of file paths in the case of stochastic markets) for the DA market, a list of file paths for the RT markets, the market settings specified by the `MarketSettings` structure, and an optimizer. The `MarketSettings` structure itself requires three optional arguments: `inner_method`, `lmp_method`, and `formulation`. If the computation of Locational Marginal Prices (LMPs) is not desired, the `lmp_method` can be set to `nothing`. Additional optional parameters include a linear programming optimizer for solving LMPs (if a different optimizer than the required one is desired), callback functions `after_build_da` and `after_optimize_da`, which are invoked after the construction and optimization of the DA market, and callback functions `after_build_rt` and `after_optimize_rt`, which are invoked after the construction and optimization of each RT market. It is crucial to note that the `after_build` function requires its two arguments to consistently correspond to `model` and `instance`, while the `after_optimize` function requires its three arguments to consistently correspond to `solution`, `model`, and `instance`.
As an illustrative example, suppose the DA market predicts hourly data for a 24-hour period, while the RT markets represent 5-minute intervals. In this scenario, each RT market file corresponds to a specific 5-minute interval, with the first RT market representing the initial 5 minutes, the second RT market representing the subsequent 5 minutes, and so on. Consequently, there should be 12 RT market files for each hour. To mitigate the closing window effect, except for the last few RT markets, each RT market should contain three time slots, resulting in a total time span of 15 minutes. However, only the first time slot is considered in the final solution. The last two RT markets should only contain 2 and 1 time slot(s), respectively, to ensure that the total time covered by all RT markets does not exceed the time span of the DA market. The code snippet below demonstrates a simplified example of how to utilize the `solve_market` function. Please note that it only serves as a simplified example and may require further customization based on the specific requirements of your use case.
```julia
using UnitCommitment, Cbc, HiGHS
import UnitCommitment:
MarketSettings,
XavQiuWanThi2019,
ConventionalLMP,
Formulation
solution = UnitCommitment.solve_market(
"da_instance.json",
["rt_instance_1.json", "rt_instance_2.json", "rt_instance_3.json"],
MarketSettings(
inner_method = XavQiuWanThi2019.Method(),
lmp_method = ConventionalLMP(),
formulation = Formulation(),
),
optimizer = Cbc.Optimizer,
lp_optimizer = HiGHS.Optimizer,
)
```

View File

@@ -4,6 +4,8 @@
module UnitCommitment
using Requires
using Base: String
include("instance/structs.jl")
@@ -72,4 +74,11 @@ include("lmp/conventional.jl")
include("lmp/aelmp.jl")
include("market/market.jl")
function __init__()
@require MIPLearn = "2b1277c3-b477-4c49-a15e-7ba350325c68" begin
include("solution/methods/MIPLearn/structs.jl")
include("solution/methods/MIPLearn/miplearn.jl")
end
end
end

View File

@@ -8,13 +8,13 @@ using DataStructures
using GZip
import Base: getindex, time
const INSTANCES_URL = "https://axavier.org/UnitCommitment.jl/0.4/instances"
const INSTANCES_URL = "https://axavier.org/UnitCommitment.jl/0.3/instances"
"""
read_benchmark(name::AbstractString)::UnitCommitmentInstance
Read one of the benchmark instances included in the package. See
[Instances](guides/instances.md) for the entire list of benchmark instances available.
[Instances](instances.md) for the entire list of benchmark instances available.
# Example
```julia

View File

@@ -82,8 +82,8 @@ solution = UnitCommitment.solve_market(
function solve_market(
da_path::Union{String,Vector{String}},
rt_paths::Vector{String};
settings::MarketSettings = MarketSettings(),
rt_paths::Vector{String},
settings::MarketSettings;
optimizer,
lp_optimizer = nothing,
after_build_da = nothing,
@@ -107,8 +107,8 @@ function solve_market(
)
# prepare the final solution
solution = OrderedDict()
solution["DA"] = solution_da
solution["RT"] = []
solution["Day-ahead market"] = solution_da
solution["Real-time markets"] = OrderedDict()
# count the time, sc.time = n-slots, sc.time_step = slot-interval
# sufficient to look at only one scenario
@@ -169,7 +169,8 @@ function solve_market(
)
prev_initial_status =
OrderedDict(g.name => g.initial_status for g in sc.thermal_units)
push!(solution["RT"], solution_rt)
# rt_name = first(split(last(split(rt_path, "/")), "."))
solution["Real-time markets"][rt_path] = solution_rt
end # end of for-loop that checks each RT market
return solution
end
@@ -202,10 +203,10 @@ function _build_and_optimize(
optimizer = lp_optimizer,
)
if length(instance.scenarios) == 1
solution["LMP (\$/MW)"] = lmp
solution["Locational marginal price"] = lmp
else
for sc in instance.scenarios
solution[sc.name]["LMP (\$/MW)"] = OrderedDict(
solution[sc.name]["Locational marginal price"] = OrderedDict(
key => val for (key, val) in lmp if key[1] == sc.name
)
end

View File

@@ -36,7 +36,7 @@ function _add_storage_unit!(
is_charging[sc.name, su.name, t] = @variable(model, binary = true)
is_discharging[sc.name, su.name, t] = @variable(model, binary = true)
# Objective function terms
# Objective function terms ##### CHECK & FIXME
add_to_expression!(
model[:obj],
charge_rate[sc.name, su.name, t],

View File

@@ -0,0 +1,71 @@
# UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
# Released under the modified BSD license. See COPYING.md for more details.
using .MIPLearn
using Suppressor
using JuMP
function _build_ucjl_model(instance, method)
if instance isa String
instance = UnitCommitment.read(instance)
end
model = UnitCommitment.build_model(
instance = instance,
optimizer = method.optimizer,
variable_names = true,
)
write_to_file(model, "/tmp/model.lp")
return JumpModel(model)
end
function _set_default_collectors!(method::MIPLearnMethod)
method.collectors = [BasicCollector()]
return
end
function _set_default_solver!(method::MIPLearnMethod)
KNN = MIPLearn.pyimport("sklearn.neighbors").KNeighborsClassifier
method.solver = LearningSolver(
components = [
MemorizingPrimalComponent(
clf = KNN(n_neighbors = 30),
extractor = H5FieldsExtractor(
instance_fields = ["static_var_obj_coeffs"],
),
constructor = MergeTopSolutions(30, [0.0, 1.0]),
action = FixVariables(),
),
],
)
return
end
function collect!(filenames::Vector, method::MIPLearnMethod)
build(x) = _build_ucjl_model(x, method)
if method.collectors === nothing
_set_default_collectors!(method)
end
for c in method.collectors
c.collect(filenames, build)
end
end
function fit!(filenames::Vector, method::MIPLearnMethod)
if method.solver === nothing
_set_default_solver!(method)
end
return method.solver.fit(filenames)
end
function optimize!(filename::AbstractString, method::MIPLearnMethod)
build(x) = _build_ucjl_model(x, method)
method.solver.optimize(filename, build)
return
end
function optimize!(instance::UnitCommitmentInstance, method::MIPLearnMethod)
model = _build_ucjl_model(instance, method)
method.solver.optimize(model)
return
end

View File

@@ -0,0 +1,11 @@
# UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
# Released under the modified BSD license. See COPYING.md for more details.
using Suppressor
Base.@kwdef mutable struct MIPLearnMethod
optimizer::Any
collectors::Any = nothing
solver::Any = nothing
end

View File

@@ -2,7 +2,7 @@
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
# Released under the modified BSD license. See COPYING.md for more details.
import Base.Threads: @threads, maxthreadid
import Base.Threads: @threads
function _find_violations(
model::JuMP.Model,
@@ -71,7 +71,7 @@ function _find_violations(;
B = length(sc.buses) - 1
L = length(sc.lines)
T = instance.time
K = maxthreadid()
K = nthreads()
size(net_injections) == (B, T) || error("net_injections has incorrect size")
size(isf) == (L, B) || error("isf has incorrect size")
@@ -104,7 +104,7 @@ function _find_violations(;
is_vulnerable[c.lines[1].offset] = true
end
@threads :static for t in 1:T
@threads for t in 1:T
k = threadid()
# Pre-contingency flows

View File

@@ -13,6 +13,7 @@ JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MIPLearn = "2b1277c3-b477-4c49-a15e-7ba350325c68"
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

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

Binary file not shown.

Binary file not shown.

View File

@@ -1,6 +1,7 @@
module UnitCommitmentT
using JuliaFormatter
using MIPLearn
using UnitCommitment
using Test
@@ -16,6 +17,7 @@ include("solution/methods/ProgressiveHedging/usage_test.jl")
include("solution/methods/TimeDecomposition/initial_status_test.jl")
include("solution/methods/TimeDecomposition/optimize_test.jl")
include("solution/methods/TimeDecomposition/update_solution_test.jl")
include("solution/methods/MIPLearn/usage_test.jl")
include("transform/initcond_test.jl")
include("transform/slice_test.jl")
include("transform/randomize/XavQiuAhm2021_test.jl")
@@ -46,9 +48,10 @@ function runtests()
solution_methods_TimeDecomposition_initial_status_test()
solution_methods_TimeDecomposition_optimize_test()
solution_methods_TimeDecomposition_update_solution_test()
solution_methods_MIPLearn_usage_test()
transform_initcond_test()
transform_slice_test()
# transform_randomize_XavQiuAhm2021_test()
transform_randomize_XavQiuAhm2021_test()
validation_repair_test()
lmp_conventional_test()
lmp_aelmp_test()
@@ -61,7 +64,6 @@ end
function format()
JuliaFormatter.format(basedir, verbose = true)
JuliaFormatter.format("$basedir/../../src", verbose = true)
JuliaFormatter.format("$basedir/../../docs/src", verbose = true)
return
end

View File

@@ -18,7 +18,7 @@ function simple_market_test()
solution = UnitCommitment.solve_market(
da_path,
rt_paths,
settings = MarketSettings(), # keep everything default
MarketSettings(), # keep everything default
optimizer = optimizer_with_attributes(
Cbc.Optimizer,
"logLevel" => 0,
@@ -30,27 +30,27 @@ function simple_market_test()
)
# the commitment status must agree with DA market
da_solution = solution["DA"]
da_solution = solution["Day-ahead market"]
@test da_solution["Is on"]["GenY"] == [0.0, 1.0]
@test da_solution["LMP (\$/MW)"][("s1", "B1", 1)] == 50.0
@test da_solution["LMP (\$/MW)"][("s1", "B1", 2)] == 56.0
@test da_solution["Locational marginal price"][("s1", "B1", 1)] == 50.0
@test da_solution["Locational marginal price"][("s1", "B1", 2)] == 56.0
rt_solution = solution["RT"]
rt_solution = solution["Real-time markets"]
@test length(rt_solution) == 4
@test rt_solution[1]["Is on"]["GenY"] == [0.0, 0.0]
@test rt_solution[2]["Is on"]["GenY"] == [0.0, 1.0]
@test rt_solution[3]["Is on"]["GenY"] == [1.0, 1.0]
@test rt_solution[4]["Is on"]["GenY"] == [1.0]
@test length(rt_solution[1]["LMP (\$/MW)"]) == 2
@test length(rt_solution[2]["LMP (\$/MW)"]) == 2
@test length(rt_solution[3]["LMP (\$/MW)"]) == 2
@test length(rt_solution[4]["LMP (\$/MW)"]) == 1
@test rt_solution[rt_paths[1]]["Is on"]["GenY"] == [0.0, 0.0]
@test rt_solution[rt_paths[2]]["Is on"]["GenY"] == [0.0, 1.0]
@test rt_solution[rt_paths[3]]["Is on"]["GenY"] == [1.0, 1.0]
@test rt_solution[rt_paths[4]]["Is on"]["GenY"] == [1.0]
@test length(rt_solution[rt_paths[1]]["Locational marginal price"]) == 2
@test length(rt_solution[rt_paths[2]]["Locational marginal price"]) == 2
@test length(rt_solution[rt_paths[3]]["Locational marginal price"]) == 2
@test length(rt_solution[rt_paths[4]]["Locational marginal price"]) == 1
# solve market with no lmp method
solution_no_lmp = UnitCommitment.solve_market(
da_path,
rt_paths,
settings = MarketSettings(lmp_method = nothing), # no lmp
MarketSettings(lmp_method = nothing), # no lmp
optimizer = optimizer_with_attributes(
Cbc.Optimizer,
"logLevel" => 0,
@@ -58,10 +58,10 @@ function simple_market_test()
)
# the commitment status must agree with DA market
da_solution = solution_no_lmp["DA"]
@test haskey(da_solution, "LMP (\$/MW)") == false
rt_solution = solution_no_lmp["RT"][1]
@test haskey(rt_solution, "LMP (\$/MW)") == false
da_solution = solution_no_lmp["Day-ahead market"]
@test haskey(da_solution, "Locational marginal price") == false
rt_solution = solution_no_lmp["Real-time markets"]
@test haskey(rt_solution, "Locational marginal price") == false
end
end
@@ -113,7 +113,7 @@ function stochastic_market_test()
solution = UnitCommitment.solve_market(
da_path,
rt_paths,
settings = MarketSettings(), # keep everything default
MarketSettings(), # keep everything default
optimizer = optimizer_with_attributes(
Cbc.Optimizer,
"logLevel" => 0,
@@ -127,19 +127,25 @@ function stochastic_market_test()
after_optimize_rt = after_optimize_rt,
)
# the commitment status must agree with DA market
da_solution_sp = solution["DA"]["market_da_simple"]
da_solution_sc = solution["DA"]["market_da_scenario"]
da_solution_sp = solution["Day-ahead market"]["market_da_simple"]
da_solution_sc = solution["Day-ahead market"]["market_da_scenario"]
@test da_solution_sc["Is on"]["GenY"] == [1.0, 1.0]
@test da_solution_sp["LMP (\$/MW)"][("market_da_simple", "B1", 1)] ==
25.0
@test da_solution_sc["LMP (\$/MW)"][("market_da_scenario", "B1", 2)] ==
0.0
@test da_solution_sp["Locational marginal price"][(
"market_da_simple",
"B1",
1,
)] == 25.0
@test da_solution_sc["Locational marginal price"][(
"market_da_scenario",
"B1",
2,
)] == 0.0
rt_solution = solution["RT"]
@test rt_solution[1]["Is on"]["GenY"] == [1.0, 1.0]
@test rt_solution[2]["Is on"]["GenY"] == [1.0, 1.0]
@test rt_solution[3]["Is on"]["GenY"] == [1.0, 1.0]
@test rt_solution[4]["Is on"]["GenY"] == [1.0]
rt_solution = solution["Real-time markets"]
@test rt_solution[rt_paths[1]]["Is on"]["GenY"] == [1.0, 1.0]
@test rt_solution[rt_paths[2]]["Is on"]["GenY"] == [1.0, 1.0]
@test rt_solution[rt_paths[3]]["Is on"]["GenY"] == [1.0, 1.0]
@test rt_solution[rt_paths[4]]["Is on"]["GenY"] == [1.0]
@test length(lmps_rt) == 4
end
end

View File

@@ -0,0 +1,20 @@
# 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 HiGHS
function solution_methods_MIPLearn_usage_test()
dirname = mktempdir()
cp(fixture("case14.json.gz"), "$dirname/case14.json.gz")
train_data = ["$dirname/case14.json.gz"]
method = UnitCommitment.MIPLearnMethod(optimizer = HiGHS.Optimizer)
UnitCommitment.collect!(train_data, method)
UnitCommitment.fit!(train_data, method)
UnitCommitment.optimize!(train_data[1], method)
instance = UnitCommitment.read(train_data[1])
UnitCommitment.optimize!(instance, method)
return
end

View File

@@ -1 +0,0 @@
jobs

View File

@@ -1,17 +0,0 @@
name = "Backend"
uuid = "948642ed-e3f9-4642-9296-0f1eaf40c938"
version = "0.1.0"
authors = ["Alinson S. Xavier <git@axavier.org>"]
[deps]
CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193"
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
UnitCommitment = "64606440-39ea-11e9-0f29-3303a1d3d877"
[compat]
CodecZlib = "0.7.8"
HTTP = "1.10.19"
JSON = "0.21.4"
Random = "1.11.0"

View File

@@ -1,12 +0,0 @@
# UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
# Copyright (C) 2025, UChicago Argonne, LLC. All rights reserved.
# Released under the modified BSD license. See COPYING.md for more details.
module Backend
basedir = joinpath(dirname(@__FILE__), "..")
include("jobs.jl")
include("server.jl")
end

View File

@@ -1,99 +0,0 @@
# UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
# Copyright (C) 2025, UChicago Argonne, LLC. All rights reserved.
# Released under the modified BSD license. See COPYING.md for more details.
using UnitCommitment
import Base: put!
Base.@kwdef mutable struct JobProcessor
pending::Channel{String} = Channel{String}(Inf)
processing::Channel{String} = Channel{String}(Inf)
shutdown::Channel{Bool} = Channel{Bool}(1)
worker_task::Union{Task,Nothing} = nothing
optimizer = nothing
end
function Base.put!(processor::JobProcessor, job_id::String)
@info "New job received: $job_id"
return put!(processor.pending, job_id)
end
function isbusy(processor::JobProcessor)
return isready(processor.pending) || isready(processor.processing)
end
function run!(processor::JobProcessor)
while true
# Check for shutdown signal
if isready(processor.shutdown)
break
end
# Wait for a job with timeout
if !isready(processor.pending)
sleep(0.1)
continue
end
# Move job from pending to processing queue
job_id = take!(processor.pending)
@info "Processing job: $job_id"
job_dir = joinpath(basedir, "jobs", job_id)
log_path = joinpath(job_dir, "output.log")
put!(processor.processing, job_id)
# Run optimization
try
open(log_path, "w") do io
redirect_stdout(io) do
redirect_stderr(io) do
json_path = joinpath(job_dir, "input.json.gz")
instance = UnitCommitment.read(json_path)
model = UnitCommitment.build_model(;
instance,
optimizer = processor.optimizer,
)
UnitCommitment.optimize!(model)
solution = UnitCommitment.solution(model)
return UnitCommitment.write(
joinpath(job_dir, "output.json"),
solution,
)
end
end
end
# Remove job from processing queue
take!(processor.processing)
catch e
open(log_path, "a") do io
println(io, "\nError: ", e)
println(io, "\nStacktrace:")
return Base.show_backtrace(io, catch_backtrace())
end
end
end
end
function start(processor::JobProcessor)
processor.worker_task = @async run!(processor)
return
end
function stop(processor::JobProcessor)
# Signal worker to stop
put!(processor.shutdown, true)
# Wait for worker to finish
if processor.worker_task !== nothing
try
wait(processor.worker_task)
catch
# Worker may have already exited
end
end
return
end
export JobProcessor, start, stop, put!, isbusy

View File

@@ -1,73 +0,0 @@
using HTTP
using Random
using JSON
using CodecZlib
using UnitCommitment
struct ServerHandle
server::HTTP.Server
processor::JobProcessor
end
function submit(req, processor::JobProcessor)
# Check if request body is empty
compressed_body = HTTP.payload(req)
if isempty(compressed_body)
return HTTP.Response(400, "Error: No file provided")
end
# Validate compressed JSON by decompressing and parsing
try
decompressed_data = transcode(GzipDecompressor, compressed_body)
JSON.parse(String(decompressed_data))
catch e
return HTTP.Response(400, "Error: Invalid compressed JSON")
end
# Generate random job ID (lowercase letters and numbers)
job_id = randstring(['a':'z'; '0':'9'], 16)
# Create job directory
job_dir = joinpath(basedir, "jobs", job_id)
mkpath(job_dir)
# Save input file
json_path = joinpath(job_dir, "input.json.gz")
write(json_path, compressed_body)
# Add job to queue
put!(processor, job_id)
# Return job ID as JSON
response_body = JSON.json(Dict("job_id" => job_id))
return HTTP.Response(200, response_body)
end
function jobs_view(req)
return HTTP.Response(200, "OK")
end
function start_server(port::Int = 8080; optimizer)
Random.seed!()
# Create and start job processor
processor = JobProcessor(optimizer = optimizer)
start(processor)
router = HTTP.Router()
# Register /submit endpoint
HTTP.register!(router, "POST", "/submit", req -> submit(req, processor))
# Register job/*/view endpoint
HTTP.register!(router, "GET", "/jobs/*/view", jobs_view)
server = HTTP.serve!(router, port; verbose = false)
return ServerHandle(server, processor)
end
function stop(handle::ServerHandle)
stop(handle.processor)
close(handle.server)
return nothing
end

View File

@@ -1,23 +0,0 @@
name = "BackendT"
uuid = "27da795e-16fd-43bd-a2ba-f77bdecaf977"
version = "0.1.0"
authors = ["Alinson S. Xavier <git@axavier.org>"]
[deps]
Backend = "948642ed-e3f9-4642-9296-0f1eaf40c938"
CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193"
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
HiGHS = "87dc4568-4c63-4d18-b0c0-bb2238e4078b"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[compat]
CodecZlib = "0.7.8"
HTTP = "1.10.19"
HiGHS = "1.20.1"
JSON = "0.21.4"
JuliaFormatter = "2.2.0"
Revise = "3.12.0"
Test = "1.11.0"

View File

@@ -1,40 +0,0 @@
# UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
# Copyright (C) 2025, UChicago Argonne, LLC. All rights reserved.
# Released under the modified BSD license. See COPYING.md for more details.
module BackendT
using Test
using HTTP
using JSON
using CodecZlib
import Backend
import JuliaFormatter
using HiGHS
BASEDIR = dirname(@__FILE__)
include("jobs_test.jl")
include("server_test.jl")
function fixture(path::String)::String
return "$BASEDIR/../fixtures/$path"
end
function runtests()
@testset "UCJL Backend" begin
server_test_usage()
# jobs_test_usage()
end
return
end
function format()
JuliaFormatter.format(BASEDIR, verbose = true)
JuliaFormatter.format("$BASEDIR/../../src", verbose = true)
return
end
export runtests, format
end

View File

@@ -1,43 +0,0 @@
# UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
# Copyright (C) 2025, UChicago Argonne, LLC. All rights reserved.
# Released under the modified BSD license. See COPYING.md for more details.
using Backend
using Test
using HiGHS
function jobs_test_usage()
@testset "JobProcessor" begin
# Setup job directory
job_id = "qwe123"
job_dir = joinpath(Backend.basedir, "jobs", job_id)
mkpath(job_dir)
cp(fixture("case14.json.gz"), joinpath(job_dir, "input.json.gz"))
try
# Create processor with HiGHS optimizer
processor = JobProcessor(optimizer = HiGHS.Optimizer)
# Start the worker
start(processor)
# Push job to queue
put!(processor, job_id)
# Wait until all jobs are processed
while isbusy(processor)
sleep(0.1)
end
# Check that solution file exists
output_path = joinpath(job_dir, "output.json")
@test isfile(output_path)
# Stop the worker
stop(processor)
finally
# Cleanup
rm(job_dir, recursive = true, force = true)
end
end
end

View File

@@ -1,44 +0,0 @@
# UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
# Copyright (C) 2025, UChicago Argonne, LLC. All rights reserved.
# Released under the modified BSD license. See COPYING.md for more details.
const PORT = 32617
function server_test_usage()
server = Backend.start_server(PORT; optimizer = HiGHS.Optimizer)
# Read the compressed fixture file
compressed_data = read(fixture("case14.json.gz"))
# Submit test case
response = HTTP.post(
"http://localhost:$PORT/submit",
["Content-Type" => "application/gzip"],
compressed_data,
)
@test response.status == 200
# Check response
response_data = JSON.parse(String(response.body))
@test haskey(response_data, "job_id")
job_id = response_data["job_id"]
@test length(job_id) == 16
# Wait for jobs to finish and stop server
sleep(0.1)
stop(server)
# Verify the compressed file was saved correctly
job_dir = joinpath(Backend.basedir, "jobs", job_id)
saved_input_path = joinpath(job_dir, "input.json.gz")
saved_log_path = joinpath(job_dir, "output.log")
saved_output_path = joinpath(job_dir, "output.json")
@test isfile(saved_input_path)
@test isfile(saved_log_path)
@test isfile(saved_output_path)
saved_data = read(saved_input_path)
@test saved_data == compressed_data
# Clean up: remove the job directory
# rm(job_dir, recursive=true)
end

View File

@@ -1,7 +0,0 @@
node_modules
npm-debug.log
Dockerfile
.dockerignore
.git
.gitignore
.env

View File

@@ -1 +0,0 @@
FAST_REFRESH=false

View File

@@ -1,25 +0,0 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
assets

View File

@@ -1 +0,0 @@
{}

View File

@@ -1,13 +0,0 @@
# Build Stage
FROM node:18-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
# Production Stage
FROM nginx:stable-alpine AS production
COPY --from=build /app/build /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

File diff suppressed because it is too large Load Diff

View File

@@ -1,65 +0,0 @@
{
"name": "web",
"version": "0.1.0",
"private": true,
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.7.2",
"@fortawesome/free-regular-svg-icons": "^6.7.2",
"@fortawesome/free-solid-svg-icons": "^6.7.2",
"@fortawesome/react-fontawesome": "^0.2.2",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.3.0",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.5.2",
"@types/node": "^16.18.126",
"@types/pako": "^2.0.3",
"@types/papaparse": "^5.3.16",
"@types/react": "^19.1.3",
"@types/react-dom": "^19.1.3",
"ajv": "^8.17.1",
"eslint": "^8.57.1",
"pako": "^2.1.0",
"papaparse": "^5.5.2",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"react-scripts": "^5.0.1",
"tabulator-tables": "^6.3.1",
"typescript": "^4.9.5",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
],
"rules": {
"semi": [
"error",
"always"
]
}
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@types/tabulator-tables": "^6.2.6",
"prettier": "3.5.3"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -1,43 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="UnitCommitment.jl Case Builder" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<title>Case Builder - UnitCommitment.jl</title>
<style>
:root {
--site-max-width: 1500px;
--site-min-width: 900px;
--box-border: 1px solid rgba(0, 0, 0, 0.2);
--box-shadow: 0px 2px 4px -3px rgba(0, 0, 0, 0.2);
--border-radius: 4px;
--primary: #0d6efd;
--contrast-100: #202020;
--contrast-80: #606060;
--contrast-60: #909090;
--contrast-20: #d6d6d6;
--contrast-10: #f6f6f6;
--contrast-0: #fefefe;
}
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
background-color: #333;
}
.content {
background-color: var(--contrast-10);
padding-bottom: 36px;
}
</style>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

View File

@@ -1,25 +0,0 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}

View File

@@ -1,3 +0,0 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

View File

@@ -1,48 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
import assert from "node:assert";
import { BusesColumnSpec, generateBusesData } from "./Buses";
import { generateCsv, parseCsv } from "../Common/Forms/DataTable";
import { TEST_DATA_1 } from "../../core/Data/fixtures.test";
test("generate CSV", () => {
const [data, columns] = generateBusesData(TEST_DATA_1);
const actualCsv = generateCsv(data, columns);
const expectedCsv =
"Name,Load (MW) 00:00,Load (MW) 01:00,Load (MW) 02:00,Load (MW) 03:00,Load (MW) 04:00\n" +
"b1,35.79534,34.38835,33.45083,32.89729,33.25044\n" +
"b2,14.03739,13.48563,13.11797,12.9009,13.03939\n" +
"b3,27.3729,26.29698,25.58005,25.15675,25.4268";
assert.strictEqual(actualCsv, expectedCsv);
});
test("parse CSV", () => {
const csvContents =
"Name,Load (MW) 00:00,Load (MW) 01:00,Load (MW) 02:00,Load (MW) 03:00,Load (MW) 04:00\n" +
"b1,0,1,2,3,4\n" +
"b3,27.3729,26.29698,25.58005,25.15675,25.4268";
const [newBuses, err] = parseCsv(csvContents, BusesColumnSpec, TEST_DATA_1);
assert(err === null);
assert.deepEqual(newBuses, {
b1: {
"Load (MW)": [0, 1, 2, 3, 4],
},
b3: {
"Load (MW)": [27.3729, 26.29698, 25.58005, 25.15675, 25.4268],
},
});
});
test("parse CSV with duplicated names", () => {
const csvContents =
"Name,Load (MW) 00:00,Load (MW) 01:00,Load (MW) 02:00,Load (MW) 03:00,Load (MW) 04:00\n" +
"b1,0,0,0,0,0\n" +
"b1,0,0,0,0,0";
const [, err] = parseCsv(csvContents, BusesColumnSpec, TEST_DATA_1);
assert(err !== null);
assert.equal(err.message, `Name "b1" is duplicated (row 2)`);
});

View File

@@ -1,150 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
import SectionHeader from "../Common/SectionHeader/SectionHeader";
import SectionButton from "../Common/Buttons/SectionButton";
import {
faDownload,
faPlus,
faUpload,
} from "@fortawesome/free-solid-svg-icons";
import { offerDownload } from "../Common/io";
import FileUploadElement from "../Common/Buttons/FileUploadElement";
import { useRef } from "react";
import { ValidationError } from "../../core/Data/validate";
import DataTable, {
ColumnSpec,
generateCsv,
generateTableColumns,
generateTableData,
parseCsv,
} from "../Common/Forms/DataTable";
import { ColumnDefinition } from "tabulator-tables";
import {
changeBusData,
createBus,
deleteBus,
renameBus,
} from "../../core/Operations/busOps";
import { CaseBuilderSectionProps } from "./CaseBuilder";
import { UnitCommitmentScenario } from "../../core/Data/types";
export const BusesColumnSpec: ColumnSpec[] = [
{
title: "Name",
type: "string",
width: 100,
},
{
title: "Load (MW)",
type: "number[T]",
width: 60,
},
];
export const generateBusesData = (
scenario: UnitCommitmentScenario,
): [any[], ColumnDefinition[]] => {
const columns = generateTableColumns(scenario, BusesColumnSpec);
const data = generateTableData(scenario.Buses, BusesColumnSpec, scenario);
return [data, columns];
};
function BusesComponent(props: CaseBuilderSectionProps) {
const fileUploadElem = useRef<FileUploadElement>(null);
const onDownload = () => {
const [data, columns] = generateBusesData(props.scenario);
const csvContents = generateCsv(data, columns);
offerDownload(csvContents, "text/csv", "buses.csv");
};
const onUpload = () => {
fileUploadElem.current!.showFilePicker((csvContents: any) => {
const [newBuses, err] = parseCsv(
csvContents,
BusesColumnSpec,
props.scenario,
);
if (err) {
props.onError(err.message);
return;
}
const newScenario = {
...props.scenario,
Buses: newBuses,
};
props.onDataChanged(newScenario);
});
};
const onAdd = () => {
const newScenario = createBus(props.scenario);
props.onDataChanged(newScenario);
};
const onDataChanged = (
bus: string,
field: string,
newValue: string,
): ValidationError | null => {
const [newScenario, err] = changeBusData(
bus,
field,
newValue,
props.scenario,
);
if (err) {
props.onError(err.message);
return err;
}
props.onDataChanged(newScenario);
return null;
};
const onDelete = (bus: string): ValidationError | null => {
const newScenario = deleteBus(bus, props.scenario);
props.onDataChanged(newScenario);
return null;
};
const onRename = (
oldName: string,
newName: string,
): ValidationError | null => {
const [newScenario, err] = renameBus(oldName, newName, props.scenario);
if (err) {
props.onError(err.message);
return err;
}
props.onDataChanged(newScenario);
return null;
};
return (
<div>
<SectionHeader title="Buses">
<SectionButton icon={faPlus} tooltip="Add" onClick={onAdd} />
<SectionButton
icon={faDownload}
tooltip="Download"
onClick={onDownload}
/>
<SectionButton icon={faUpload} tooltip="Upload" onClick={onUpload} />
</SectionHeader>
<DataTable
onRowDeleted={onDelete}
onRowRenamed={onRename}
onDataChanged={onDataChanged}
generateData={() => generateBusesData(props.scenario)}
/>
<FileUploadElement ref={fileUploadElem} accept=".csv" />
</div>
);
}
export default BusesComponent;

View File

@@ -1,145 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
import Header from "./Header";
import Parameters from "./Parameters";
import BusesComponent from "./Buses";
import { BLANK_SCENARIO } from "../../core/Data/fixtures";
import "tabulator-tables/dist/css/tabulator.min.css";
import "../Common/Forms/Tables.css";
import { useState } from "react";
import Footer from "./Footer";
import { offerDownload } from "../Common/io";
import { preprocess } from "../../core/Operations/preprocessing";
import Toast from "../Common/Forms/Toast";
import ProfiledUnitsComponent from "./ProfiledUnits";
import ThermalUnitsComponent from "./ThermalUnits";
import TransmissionLinesComponent from "./TransmissionLines";
import { UnitCommitmentScenario } from "../../core/Data/types";
import StorageComponent from "./StorageUnits";
import PriceSensitiveLoadsComponent from "./Psload";
export interface CaseBuilderSectionProps {
scenario: UnitCommitmentScenario;
onDataChanged: (scenario: UnitCommitmentScenario) => void;
onError: (msg: string) => void;
}
const CaseBuilder = () => {
const [scenario, setScenario] = useState(() => {
const savedScenario = localStorage.getItem("scenario");
if (!savedScenario) return BLANK_SCENARIO;
const [processedScenario, err] = preprocess(JSON.parse(savedScenario));
if (err) {
console.log(err);
return BLANK_SCENARIO;
}
return processedScenario!!;
});
const [undoStack, setUndoStack] = useState<UnitCommitmentScenario[]>([]);
const [toastMessage, setToastMessage] = useState<string>("");
const setAndSaveScenario = (
newScenario: UnitCommitmentScenario,
updateUndoStack = true,
) => {
if (updateUndoStack) {
const newUndoStack = [...undoStack, scenario];
if (newUndoStack.length > 25) {
newUndoStack.splice(0, newUndoStack.length - 25);
}
setUndoStack(newUndoStack);
}
setScenario(newScenario);
localStorage.setItem("scenario", JSON.stringify(newScenario));
};
const onClear = () => {
setAndSaveScenario(BLANK_SCENARIO);
};
const onSave = () => {
offerDownload(
JSON.stringify(scenario, null, 2),
"application/json",
"case.json",
);
};
const onDataChanged = (newScenario: UnitCommitmentScenario) => {
setAndSaveScenario(newScenario);
};
const onLoad = (data: any) => {
const json = JSON.parse(data);
const [scenario, err] = preprocess(json);
if (err) {
setToastMessage(err.message);
return;
}
setAndSaveScenario(scenario!);
setToastMessage("Data loaded successfully");
};
const onUndo = () => {
if (undoStack.length === 0) return;
setUndoStack(undoStack.slice(0, -1));
setAndSaveScenario(undoStack[undoStack.length - 1]!, false);
};
return (
<div>
<Header
onClear={onClear}
onSave={onSave}
onLoad={onLoad}
onUndo={onUndo}
/>
<div className="content">
<Parameters
scenario={scenario}
onDataChanged={onDataChanged}
onError={setToastMessage}
/>
<BusesComponent
scenario={scenario}
onDataChanged={onDataChanged}
onError={setToastMessage}
/>
<ThermalUnitsComponent
scenario={scenario}
onDataChanged={onDataChanged}
onError={setToastMessage}
/>
<ProfiledUnitsComponent
scenario={scenario}
onDataChanged={onDataChanged}
onError={setToastMessage}
/>
<StorageComponent
scenario={scenario}
onDataChanged={onDataChanged}
onError={setToastMessage}
/>
<PriceSensitiveLoadsComponent
scenario={scenario}
onDataChanged={onDataChanged}
onError={setToastMessage}
/>
<TransmissionLinesComponent
scenario={scenario}
onDataChanged={onDataChanged}
onError={setToastMessage}
/>
<Toast message={toastMessage} />
</div>
<Footer />
</div>
);
};
export default CaseBuilder;

View File

@@ -1,14 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
.Footer {
background-color: #333;
text-align: center;
color: #aaa;
font-size: 14px;
padding: 16px;
line-height: 24px;
}

View File

@@ -1,19 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
import styles from "./Footer.module.css";
function Footer() {
return (
<div className={styles.Footer}>
UnitCommitment.jl: Optimization Package for Security-Constrained Unit
Commitment <br />
Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
</div>
);
}
export default Footer;

View File

@@ -1,41 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
.HeaderBox {
background-color: var(--contrast-0);
border-bottom: var(--box-border);
box-shadow: var(--box-shadow);
padding: 0;
margin: 0;
}
.HeaderContent {
margin: 0 auto;
max-width: var(--site-max-width);
min-width: var(--site-min-width);
}
.HeaderContent h1,
h2 {
color: var(--contrast-100);
display: inline-block;
line-height: 48px;
font-size: 28px;
margin: 0;
padding: 12px 24px;
}
.HeaderContent h2 {
display: inline-block;
font-size: 22px;
color: var(--contrast-80);
font-weight: normal;
}
.buttonContainer {
float: right;
padding: 16px 12px;
}

View File

@@ -1,46 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
import styles from "./Header.module.css";
import SiteHeaderButton from "../Common/Buttons/SiteHeaderButton";
import { useRef } from "react";
import FileUploadElement from "../Common/Buttons/FileUploadElement";
import { UnitCommitmentScenario } from "../../core/Data/types";
interface HeaderProps {
onClear: () => void;
onSave: () => void;
onUndo: () => void;
onLoad: (data: UnitCommitmentScenario) => void;
}
function Header(props: HeaderProps) {
const fileElem = useRef<FileUploadElement>(null);
function onLoad() {
fileElem.current!.showFilePicker((data: any) => {
props.onLoad(data);
});
}
return (
<div className={styles.HeaderBox}>
<div className={styles.HeaderContent}>
<h1>UnitCommitment.jl</h1>
<h2>Case Builder</h2>
<div className={styles.buttonContainer}>
<SiteHeaderButton title="Undo" onClick={props.onUndo} />
<SiteHeaderButton title="Clear" onClick={props.onClear} />
<SiteHeaderButton title="Load" onClick={onLoad} />
<SiteHeaderButton title="Save" onClick={props.onSave} />
</div>
<FileUploadElement ref={fileElem} accept=".json,.json.gz" />
</div>
</div>
);
}
export default Header;

View File

@@ -1,71 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
import SectionHeader from "../Common/SectionHeader/SectionHeader";
import Form from "../Common/Forms/Form";
import TextInputRow from "../Common/Forms/TextInputRow";
import {
changeParameter,
changeTimeHorizon,
changeTimeStep,
} from "../../core/Operations/parameterOps";
import { UnitCommitmentScenario } from "../../core/Data/types";
interface ParametersProps {
scenario: UnitCommitmentScenario;
onError: (msg: string) => void;
onDataChanged: (scenario: UnitCommitmentScenario) => void;
}
function Parameters(props: ParametersProps) {
const onDataChanged = (key: string, value: string) => {
let newScenario, err;
if (key === "Time horizon (h)") {
[newScenario, err] = changeTimeHorizon(props.scenario, value);
} else if (key === "Time step (min)") {
[newScenario, err] = changeTimeStep(props.scenario, value);
} else {
[newScenario, err] = changeParameter(props.scenario, key, value);
}
if (err) {
props.onError(err.message);
return err;
}
props.onDataChanged(newScenario);
return null;
};
return (
<div>
<SectionHeader title="Parameters"></SectionHeader>
<Form>
<TextInputRow
label="Time horizon"
unit="h"
tooltip="Length of the planning horizon (in hours)."
initialValue={`${props.scenario.Parameters["Time horizon (h)"]}`}
onChange={(v) => onDataChanged("Time horizon (h)", v)}
/>
<TextInputRow
label="Time step"
unit="min"
tooltip="Length of each time step (in minutes). Must be a divisor of 60 (e.g. 60, 30, 20, 15, etc)."
initialValue={`${props.scenario.Parameters["Time step (min)"]}`}
onChange={(v) => onDataChanged("Time step (min)", v)}
/>
<TextInputRow
label="Power balance penalty"
unit="$/MW"
tooltip="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."
initialValue={`${props.scenario.Parameters["Power balance penalty ($/MW)"]}`}
onChange={(v) => onDataChanged("Power balance penalty ($/MW)", v)}
/>
</Form>
</div>
);
}
export default Parameters;

View File

@@ -1,111 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
import {
floatFormatter,
generateTableColumns,
parseCsv,
} from "../Common/Forms/DataTable";
import {
parseProfiledUnitsCsv,
ProfiledUnitsColumnSpec,
} from "./ProfiledUnits";
import { TEST_DATA_1 } from "../../core/Data/fixtures.test";
import assert from "node:assert";
import {
getProfiledGenerators,
getThermalGenerators,
} from "../../core/Data/types";
test("parse CSV", () => {
const csvContents =
"Name,Bus,Cost ($/MW),Maximum power (MW) 00:00,Maximum power (MW) 01:00," +
"Maximum power (MW) 02:00,Maximum power (MW) 03:00," +
"Maximum power (MW) 04:00,Minimum power (MW) 00:00," +
"Minimum power (MW) 01:00,Minimum power (MW) 02:00," +
"Minimum power (MW) 03:00,Minimum power (MW) 04:00\n" +
"pu1,b1,50,260.25384545,72.89148068,377.17886108,336.66732361," +
"376.82781758,52.05076909,14.57829614,75.43577222,67.33346472,75.36556352\n" +
"pu2,b1,0,0,0,0,0,0,0,0,0,0,0";
const [scenario, err] = parseProfiledUnitsCsv(csvContents, TEST_DATA_1);
assert(err === null);
const thermalGens = getThermalGenerators(scenario);
const profGens = getProfiledGenerators(scenario);
assert.equal(Object.keys(thermalGens).length, 1);
assert.equal(Object.keys(profGens).length, 2);
assert.deepEqual(profGens, {
pu1: {
Bus: "b1",
"Minimum power (MW)": [
52.05076909, 14.57829614, 75.43577222, 67.33346472, 75.36556352,
],
"Maximum power (MW)": [
260.25384545, 72.89148068, 377.17886108, 336.66732361, 376.82781758,
],
"Cost ($/MW)": 50.0,
Type: "Profiled",
},
pu2: {
Bus: "b1",
"Minimum power (MW)": [0, 0, 0, 0, 0],
"Maximum power (MW)": [0, 0, 0, 0, 0],
"Cost ($/MW)": 0.0,
Type: "Profiled",
},
});
});
test("parse CSV with invalid bus", () => {
const csvContents =
"Name,Bus,Cost ($/MW),Maximum power (MW) 00:00,Maximum power (MW) 01:00," +
"Maximum power (MW) 02:00,Maximum power (MW) 03:00," +
"Maximum power (MW) 04:00,Minimum power (MW) 00:00," +
"Minimum power (MW) 01:00,Minimum power (MW) 02:00," +
"Minimum power (MW) 03:00,Minimum power (MW) 04:00\n" +
"pu1,b99,50,260.25384545,72.89148068,377.17886108,336.66732361," +
"376.82781758,52.05076909,14.57829614,75.43577222,67.33346472,75.36556352\n" +
"pu2,b1,0,0,0,0,0,0,0,0,0,0,0";
const [, err] = parseCsv(csvContents, ProfiledUnitsColumnSpec, TEST_DATA_1);
assert(err !== null);
assert.equal(err.message, 'Bus "b99" does not exist (row 1)');
});
test("generateTableColumns", () => {
const columns = generateTableColumns(TEST_DATA_1, ProfiledUnitsColumnSpec);
assert.equal(columns.length, 5);
assert.deepEqual(columns[0], {
editor: "input",
editorParams: {
selectContents: true,
},
field: "Name",
formatter: "plaintext",
headerHozAlign: "left",
headerSort: false,
headerWordWrap: true,
hozAlign: "left",
minWidth: 100,
resizable: false,
title: "Name",
});
assert.equal(columns[3]!["columns"]!.length, 5);
assert.deepEqual(columns[3]!["columns"]![0], {
editor: "input",
editorParams: {
selectContents: true,
},
field: "Maximum power (MW) 00:00",
formatter: floatFormatter,
headerHozAlign: "left",
headerSort: false,
headerWordWrap: true,
hozAlign: "left",
minWidth: 75,
resizable: false,
title: "00:00",
});
});

View File

@@ -1,197 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
import SectionHeader from "../Common/SectionHeader/SectionHeader";
import SectionButton from "../Common/Buttons/SectionButton";
import {
faDownload,
faPlus,
faUpload,
} from "@fortawesome/free-solid-svg-icons";
import DataTable, {
ColumnSpec,
generateCsv,
generateTableColumns,
generateTableData,
parseCsv,
} from "../Common/Forms/DataTable";
import { ColumnDefinition } from "tabulator-tables";
import { offerDownload } from "../Common/io";
import FileUploadElement from "../Common/Buttons/FileUploadElement";
import { useRef } from "react";
import {
changeProfiledUnitData,
createProfiledUnit,
deleteGenerator,
renameGenerator,
} from "../../core/Operations/generatorOps";
import { ValidationError } from "../../core/Data/validate";
import { CaseBuilderSectionProps } from "./CaseBuilder";
import {
getProfiledGenerators,
getThermalGenerators,
UnitCommitmentScenario,
} from "../../core/Data/types";
export const ProfiledUnitsColumnSpec: ColumnSpec[] = [
{
title: "Name",
type: "string",
width: 100,
},
{
title: "Bus",
type: "busRef",
width: 100,
},
{
title: "Cost ($/MW)",
type: "number",
width: 100,
},
{
title: "Maximum power (MW)",
type: "number[T]",
width: 75,
},
{
title: "Minimum power (MW)",
type: "number[T]",
width: 75,
},
];
const generateProfiledUnitsData = (
scenario: UnitCommitmentScenario,
): [any[], ColumnDefinition[]] => {
const columns = generateTableColumns(scenario, ProfiledUnitsColumnSpec);
const data = generateTableData(
getProfiledGenerators(scenario),
ProfiledUnitsColumnSpec,
scenario,
);
return [data, columns];
};
export const parseProfiledUnitsCsv = (
csvContents: string,
scenario: UnitCommitmentScenario,
): [UnitCommitmentScenario, ValidationError | null] => {
const [profGens, err] = parseCsv(
csvContents,
ProfiledUnitsColumnSpec,
scenario,
);
if (err) return [scenario, err];
// Process imported generators
for (const gen in profGens) {
profGens[gen]["Type"] = "Profiled";
}
// Merge with existing data
const thermalGens = getThermalGenerators(scenario);
const newScenario = {
...scenario,
Generators: { ...thermalGens, ...profGens },
};
return [newScenario, null];
};
const ProfiledUnitsComponent = (props: CaseBuilderSectionProps) => {
const fileUploadElem = useRef<FileUploadElement>(null);
const onDownload = () => {
const [data, columns] = generateProfiledUnitsData(props.scenario);
const csvContents = generateCsv(data, columns);
offerDownload(csvContents, "text/csv", "profiled_units.csv");
};
const onUpload = () => {
fileUploadElem.current!.showFilePicker((csv: any) => {
const [newScenario, err] = parseProfiledUnitsCsv(csv, props.scenario);
if (err) {
props.onError(err.message);
return;
}
props.onDataChanged(newScenario);
});
};
const onAdd = () => {
const [newScenario, err] = createProfiledUnit(props.scenario);
if (err) {
props.onError(err.message);
return;
}
props.onDataChanged(newScenario);
};
const onDelete = (name: string): ValidationError | null => {
const newScenario = deleteGenerator(name, props.scenario);
props.onDataChanged(newScenario);
return null;
};
const onDataChanged = (
name: string,
field: string,
newValue: string,
): ValidationError | null => {
const [newScenario, err] = changeProfiledUnitData(
name,
field,
newValue,
props.scenario,
);
if (err) {
props.onError(err.message);
return err;
}
props.onDataChanged(newScenario);
return null;
};
const onRename = (
oldName: string,
newName: string,
): ValidationError | null => {
const [newScenario, err] = renameGenerator(
oldName,
newName,
props.scenario,
);
if (err) {
props.onError(err.message);
return err;
}
props.onDataChanged(newScenario);
return null;
};
return (
<div>
<SectionHeader title="Profiled units">
<SectionButton icon={faPlus} tooltip="Add" onClick={onAdd} />
<SectionButton
icon={faDownload}
tooltip="Download"
onClick={onDownload}
/>
<SectionButton icon={faUpload} tooltip="Upload" onClick={onUpload} />
</SectionHeader>
<DataTable
onRowDeleted={onDelete}
onRowRenamed={onRename}
onDataChanged={onDataChanged}
generateData={() => generateProfiledUnitsData(props.scenario)}
/>
<FileUploadElement ref={fileUploadElem} accept=".csv" />
</div>
);
};
export default ProfiledUnitsComponent;

View File

@@ -1,175 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
import DataTable, {
ColumnSpec,
generateCsv,
generateTableColumns,
generateTableData,
parseCsv,
} from "../Common/Forms/DataTable";
import { CaseBuilderSectionProps } from "./CaseBuilder";
import { useRef } from "react";
import FileUploadElement from "../Common/Buttons/FileUploadElement";
import { ValidationError } from "../../core/Data/validate";
import SectionHeader from "../Common/SectionHeader/SectionHeader";
import SectionButton from "../Common/Buttons/SectionButton";
import {
faDownload,
faPlus,
faUpload,
} from "@fortawesome/free-solid-svg-icons";
import { UnitCommitmentScenario } from "../../core/Data/types";
import { ColumnDefinition } from "tabulator-tables";
import {
changePriceSensitiveLoadData,
createPriceSensitiveLoad,
deletePriceSensitiveLoad,
renamePriceSensitiveLoad,
} from "../../core/Operations/psloadOps";
import { offerDownload } from "../Common/io";
export const PriceSensitiveLoadsColumnSpec: ColumnSpec[] = [
{
title: "Name",
type: "string",
width: 100,
},
{
title: "Bus",
type: "busRef",
width: 100,
},
{
title: "Revenue ($/MW)",
type: "number",
width: 100,
},
{
title: "Demand (MW)",
type: "number[T]",
width: 70,
},
];
export const generatePriceSensitiveLoadsData = (
scenario: UnitCommitmentScenario,
): [any[], ColumnDefinition[]] => {
const columns = generateTableColumns(scenario, PriceSensitiveLoadsColumnSpec);
const data = generateTableData(
scenario["Price-sensitive loads"],
PriceSensitiveLoadsColumnSpec,
scenario,
);
return [data, columns];
};
const PriceSensitiveLoadsComponent = (props: CaseBuilderSectionProps) => {
const fileUploadElem = useRef<FileUploadElement>(null);
const onDownload = () => {
const [data, columns] = generatePriceSensitiveLoadsData(props.scenario);
const csvContents = generateCsv(data, columns);
offerDownload(csvContents, "text/csv", "psloads.csv");
};
const onUpload = () => {
fileUploadElem.current!.showFilePicker((csv: any) => {
// Parse provided CSV file
const [psloads, err] = parseCsv(
csv,
PriceSensitiveLoadsColumnSpec,
props.scenario,
);
// Handle validation errors
if (err) {
props.onError(err.message);
return;
}
// Generate new scenario
props.onDataChanged({
...props.scenario,
"Price-sensitive loads": psloads,
});
});
};
const onAdd = () => {
const [newScenario, err] = createPriceSensitiveLoad(props.scenario);
if (err) {
props.onError(err.message);
return;
}
props.onDataChanged(newScenario);
};
const onDelete = (name: string): ValidationError | null => {
const newScenario = deletePriceSensitiveLoad(name, props.scenario);
props.onDataChanged(newScenario);
return null;
};
const onDataChanged = (
name: string,
field: string,
newValue: string,
): ValidationError | null => {
const [newScenario, err] = changePriceSensitiveLoadData(
name,
field,
newValue,
props.scenario,
);
if (err) {
props.onError(err.message);
return err;
}
props.onDataChanged(newScenario);
return null;
};
const onRename = (
oldName: string,
newName: string,
): ValidationError | null => {
const [newScenario, err] = renamePriceSensitiveLoad(
oldName,
newName,
props.scenario,
);
if (err) {
props.onError(err.message);
return err;
}
props.onDataChanged(newScenario);
return null;
};
return (
<div>
<SectionHeader title="Price-sensitive loads">
<SectionButton icon={faPlus} tooltip="Add" onClick={onAdd} />
<SectionButton
icon={faDownload}
tooltip="Download"
onClick={onDownload}
/>
<SectionButton icon={faUpload} tooltip="Upload" onClick={onUpload} />
</SectionHeader>
<DataTable
onRowDeleted={onDelete}
onRowRenamed={onRename}
onDataChanged={onDataChanged}
generateData={() => generatePriceSensitiveLoadsData(props.scenario)}
/>
<FileUploadElement ref={fileUploadElem} accept=".csv" />
</div>
);
};
export default PriceSensitiveLoadsComponent;

View File

@@ -1,235 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
import DataTable, {
ColumnSpec,
generateCsv,
generateTableColumns,
generateTableData,
parseCsv,
} from "../Common/Forms/DataTable";
import { CaseBuilderSectionProps } from "./CaseBuilder";
import { useRef } from "react";
import FileUploadElement from "../Common/Buttons/FileUploadElement";
import { ValidationError } from "../../core/Data/validate";
import SectionHeader from "../Common/SectionHeader/SectionHeader";
import SectionButton from "../Common/Buttons/SectionButton";
import {
faDownload,
faPlus,
faUpload,
} from "@fortawesome/free-solid-svg-icons";
import { UnitCommitmentScenario } from "../../core/Data/types";
import { ColumnDefinition } from "tabulator-tables";
import {
changeStorageUnitData,
createStorageUnit,
deleteStorageUnit,
renameStorageUnit,
} from "../../core/Operations/storageOps";
import { offerDownload } from "../Common/io";
export const StorageUnitsColumnSpec: ColumnSpec[] = [
{
title: "Name",
type: "string",
width: 100,
},
{
title: "Bus",
type: "busRef",
width: 100,
},
{
title: "Minimum level (MWh)",
type: "number",
width: 100,
},
{
title: "Maximum level (MWh)",
type: "number",
width: 100,
},
{
title: "Charge cost ($/MW)",
type: "number",
width: 100,
},
{
title: "Discharge cost ($/MW)",
type: "number",
width: 100,
},
{
title: "Charge efficiency",
type: "number",
width: 100,
},
{
title: "Discharge efficiency",
type: "number",
width: 100,
},
{
title: "Loss factor",
type: "number",
width: 80,
},
{
title: "Minimum charge rate (MW)",
type: "number",
width: 140,
},
{
title: "Maximum charge rate (MW)",
type: "number",
width: 140,
},
{
title: "Minimum discharge rate (MW)",
type: "number",
width: 140,
},
{
title: "Maximum discharge rate (MW)",
type: "number",
width: 150,
},
{
title: "Initial level (MWh)",
type: "number",
width: 100,
},
{
title: "Last period minimum level (MWh)",
type: "number",
width: 160,
},
{
title: "Last period maximum level (MWh)",
type: "number",
width: 160,
},
];
export const generateStorageUnitsData = (
scenario: UnitCommitmentScenario,
): [any[], ColumnDefinition[]] => {
const columns = generateTableColumns(scenario, StorageUnitsColumnSpec);
const data = generateTableData(
scenario["Storage units"],
StorageUnitsColumnSpec,
scenario,
);
return [data, columns];
};
const StorageUnitsComponent = (props: CaseBuilderSectionProps) => {
const fileUploadElem = useRef<FileUploadElement>(null);
const onDownload = () => {
const [data, columns] = generateStorageUnitsData(props.scenario);
const csvContents = generateCsv(data, columns);
offerDownload(csvContents, "text/csv", "storage_units.csv");
};
const onUpload = () => {
fileUploadElem.current!.showFilePicker((csv: any) => {
// Parse provided CSV file
const [storageUnits, err] = parseCsv(
csv,
StorageUnitsColumnSpec,
props.scenario,
);
// Handle validation errors
if (err) {
props.onError(err.message);
return;
}
// Generate new scenario
props.onDataChanged({
...props.scenario,
"Storage units": storageUnits,
});
});
};
const onAdd = () => {
const [newScenario, err] = createStorageUnit(props.scenario);
if (err) {
props.onError(err.message);
return;
}
props.onDataChanged(newScenario);
};
const onDelete = (name: string): ValidationError | null => {
const newScenario = deleteStorageUnit(name, props.scenario);
props.onDataChanged(newScenario);
return null;
};
const onDataChanged = (
name: string,
field: string,
newValue: string,
): ValidationError | null => {
const [newScenario, err] = changeStorageUnitData(
name,
field,
newValue,
props.scenario,
);
if (err) {
props.onError(err.message);
return err;
}
props.onDataChanged(newScenario);
return null;
};
const onRename = (
oldName: string,
newName: string,
): ValidationError | null => {
const [newScenario, err] = renameStorageUnit(
oldName,
newName,
props.scenario,
);
if (err) {
props.onError(err.message);
return err;
}
props.onDataChanged(newScenario);
return null;
};
return (
<div>
<SectionHeader title="Storage units">
<SectionButton icon={faPlus} tooltip="Add" onClick={onAdd} />
<SectionButton
icon={faDownload}
tooltip="Download"
onClick={onDownload}
/>
<SectionButton icon={faUpload} tooltip="Upload" onClick={onUpload} />
</SectionHeader>
<DataTable
onRowDeleted={onDelete}
onRowRenamed={onRename}
onDataChanged={onDataChanged}
generateData={() => generateStorageUnitsData(props.scenario)}
/>
<FileUploadElement ref={fileUploadElem} accept=".csv" />
</div>
);
};
export default StorageUnitsComponent;

View File

@@ -1,209 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
import {
floatFormatter,
generateCsv,
generateTableColumns,
generateTableData,
} from "../Common/Forms/DataTable";
import { TEST_DATA_1 } from "../../core/Data/fixtures.test";
import {
generateThermalUnitsData,
parseThermalUnitsCsv,
ThermalUnitsColumnSpec,
} from "./ThermalUnits";
import assert from "node:assert";
import {
getProfiledGenerators,
getThermalGenerators,
} from "../../core/Data/types";
test("generateTableColumns", () => {
const columns = generateTableColumns(TEST_DATA_1, ThermalUnitsColumnSpec);
assert.equal(columns[2]!["columns"]!.length, 10);
assert.deepEqual(columns[2]!["columns"]![0], {
editor: "input",
editorParams: {
selectContents: true,
},
field: "Production cost curve (MW) 1",
formatter: floatFormatter,
headerHozAlign: "left",
headerSort: false,
headerWordWrap: true,
hozAlign: "left",
minWidth: 80,
resizable: false,
title: "1",
});
});
test("generateTableData", () => {
const data = generateTableData(
getThermalGenerators(TEST_DATA_1),
ThermalUnitsColumnSpec,
TEST_DATA_1,
);
assert.deepEqual(data[0], {
Name: "g1",
Bus: "b1",
"Initial power (MW)": 115,
"Initial status (h)": 12,
"Minimum downtime (h)": 4,
"Minimum uptime (h)": 4,
"Ramp down limit (MW)": 232.68,
"Ramp up limit (MW)": 232.68,
"Shutdown limit (MW)": 232.68,
"Startup limit (MW)": 232.68,
"Production cost curve ($) 1": 1400,
"Production cost curve ($) 2": 1600,
"Production cost curve ($) 3": 2200,
"Production cost curve ($) 4": 2400,
"Production cost curve ($) 5": "",
"Production cost curve ($) 6": "",
"Production cost curve ($) 7": "",
"Production cost curve ($) 8": "",
"Production cost curve ($) 9": "",
"Production cost curve ($) 10": "",
"Production cost curve (MW) 1": 100,
"Production cost curve (MW) 2": 110,
"Production cost curve (MW) 3": 130,
"Production cost curve (MW) 4": 135,
"Production cost curve (MW) 5": "",
"Production cost curve (MW) 6": "",
"Production cost curve (MW) 7": "",
"Production cost curve (MW) 8": "",
"Production cost curve (MW) 9": "",
"Production cost curve (MW) 10": "",
"Startup costs ($) 1": 300,
"Startup costs ($) 2": 400,
"Startup costs ($) 3": "",
"Startup costs ($) 4": "",
"Startup costs ($) 5": "",
"Startup delays (h) 1": 1,
"Startup delays (h) 2": 4,
"Startup delays (h) 3": "",
"Startup delays (h) 4": "",
"Startup delays (h) 5": "",
"Must run?": false,
});
});
const expectedCsvContents =
"Name,Bus," +
"Production cost curve (MW) 1," +
"Production cost curve (MW) 2," +
"Production cost curve (MW) 3," +
"Production cost curve (MW) 4," +
"Production cost curve (MW) 5," +
"Production cost curve (MW) 6," +
"Production cost curve (MW) 7," +
"Production cost curve (MW) 8," +
"Production cost curve (MW) 9," +
"Production cost curve (MW) 10," +
"Production cost curve ($) 1," +
"Production cost curve ($) 2," +
"Production cost curve ($) 3," +
"Production cost curve ($) 4," +
"Production cost curve ($) 5," +
"Production cost curve ($) 6," +
"Production cost curve ($) 7," +
"Production cost curve ($) 8," +
"Production cost curve ($) 9," +
"Production cost curve ($) 10," +
"Startup costs ($) 1," +
"Startup costs ($) 2," +
"Startup costs ($) 3," +
"Startup costs ($) 4," +
"Startup costs ($) 5," +
"Startup delays (h) 1," +
"Startup delays (h) 2," +
"Startup delays (h) 3," +
"Startup delays (h) 4," +
"Startup delays (h) 5," +
"Minimum uptime (h),Minimum downtime (h),Ramp up limit (MW)," +
"Ramp down limit (MW),Startup limit (MW),Shutdown limit (MW)," +
"Initial status (h),Initial power (MW),Must run?\n" +
"g1,b1,100,110,130,135,,,,,,,1400,1600,2200,2400,,,,,,,300,400,,,,1,4,,,,4,4,232.68,232.68,232.68,232.68,12,115,false";
const invalidCsv =
"Name,Bus," +
"Production cost curve (MW) 1," +
"Production cost curve (MW) 2," +
"Production cost curve (MW) 3," +
"Production cost curve (MW) 4," +
"Production cost curve (MW) 5," +
"Production cost curve (MW) 6," +
"Production cost curve (MW) 7," +
"Production cost curve (MW) 8," +
"Production cost curve (MW) 9," +
"Production cost curve (MW) 10," +
"Production cost curve ($) 1," +
"Production cost curve ($) 2," +
"Production cost curve ($) 3," +
"Production cost curve ($) 4," +
"Production cost curve ($) 5," +
"Production cost curve ($) 6," +
"Production cost curve ($) 7," +
"Production cost curve ($) 8," +
"Production cost curve ($) 9," +
"Production cost curve ($) 10," +
"Startup costs ($) 1," +
"Startup costs ($) 2," +
"Startup costs ($) 3," +
"Startup costs ($) 4," +
"Startup costs ($) 5," +
"Startup delays (h) 1," +
"Startup delays (h) 2," +
"Startup delays (h) 3," +
"Startup delays (h) 4," +
"Startup delays (h) 5," +
"Minimum uptime (h),Minimum downtime (h),Ramp up limit (MW)," +
"Ramp down limit (MW),Startup limit (MW),Shutdown limit (MW)," +
"Initial status (h),Initial power (MW),Must run?\n" +
"g1,b1,100,110,130,x,,,,,,,1400,1600,2200,2400,,,,,,,300,400,,,,1,4,,,,4,4,232.68,232.68,232.68,232.68,12,115,false";
test("generateCSV", () => {
const [data, columns] = generateThermalUnitsData(TEST_DATA_1);
const actualCsvContents = generateCsv(data, columns);
assert.equal(actualCsvContents, expectedCsvContents);
});
test("parseCSV", () => {
const [scenario, err] = parseThermalUnitsCsv(
expectedCsvContents,
TEST_DATA_1,
);
assert(!err);
const thermalGens = getThermalGenerators(scenario);
const profGens = getProfiledGenerators(scenario);
assert.equal(Object.keys(thermalGens).length, 1);
assert.equal(Object.keys(profGens).length, 2);
assert.deepEqual(thermalGens["g1"], {
Bus: "b1",
Type: "Thermal",
"Production cost curve (MW)": [100.0, 110.0, 130.0, 135.0],
"Production cost curve ($)": [1400.0, 1600.0, 2200.0, 2400.0],
"Startup costs ($)": [300.0, 400.0],
"Startup delays (h)": [1, 4],
"Ramp up limit (MW)": 232.68,
"Ramp down limit (MW)": 232.68,
"Startup limit (MW)": 232.68,
"Shutdown limit (MW)": 232.68,
"Minimum downtime (h)": 4,
"Minimum uptime (h)": 4,
"Initial status (h)": 12,
"Initial power (MW)": 115,
"Must run?": false,
});
});
test("parseCSV with invalid number[T]", () => {
const [, err] = parseThermalUnitsCsv(invalidCsv, TEST_DATA_1);
assert(err);
assert.equal(err.message, '"x" is not a valid number (row 1)');
});

View File

@@ -1,251 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
import DataTable, {
ColumnSpec,
generateCsv,
generateTableColumns,
generateTableData,
parseCsv,
} from "../Common/Forms/DataTable";
import { CaseBuilderSectionProps } from "./CaseBuilder";
import { useRef } from "react";
import FileUploadElement from "../Common/Buttons/FileUploadElement";
import { ValidationError } from "../../core/Data/validate";
import SectionHeader from "../Common/SectionHeader/SectionHeader";
import SectionButton from "../Common/Buttons/SectionButton";
import {
faDownload,
faPlus,
faUpload,
} from "@fortawesome/free-solid-svg-icons";
import { ColumnDefinition } from "tabulator-tables";
import { offerDownload } from "../Common/io";
import {
changeThermalUnitData,
createThermalUnit,
deleteGenerator,
renameGenerator,
} from "../../core/Operations/generatorOps";
import {
getProfiledGenerators,
getThermalGenerators,
UnitCommitmentScenario,
} from "../../core/Data/types";
export const ThermalUnitsColumnSpec: ColumnSpec[] = [
{
title: "Name",
type: "string",
width: 100,
},
{
title: "Bus",
type: "busRef",
width: 100,
},
{
title: "Production cost curve (MW)",
type: "number[N]",
length: 10,
width: 80,
},
{
title: "Production cost curve ($)",
type: "number[N]",
length: 10,
width: 80,
},
{
title: "Startup costs ($)",
type: "number[N]",
length: 5,
width: 75,
},
{
title: "Startup delays (h)",
type: "number[N]",
length: 5,
width: 60,
},
{
title: "Minimum uptime (h)",
type: "number",
width: 80,
},
{
title: "Minimum downtime (h)",
type: "number",
width: 100,
},
{
title: "Ramp up limit (MW)",
type: "number?",
width: 100,
},
{
title: "Ramp down limit (MW)",
type: "number?",
width: 100,
},
{
title: "Startup limit (MW)",
type: "number?",
width: 80,
},
{
title: "Shutdown limit (MW)",
type: "number?",
width: 100,
},
{
title: "Initial status (h)",
type: "number",
width: 80,
},
{
title: "Initial power (MW)",
type: "number",
width: 100,
},
{
title: "Must run?",
type: "boolean",
width: 80,
},
];
export const generateThermalUnitsData = (
scenario: UnitCommitmentScenario,
): [any[], ColumnDefinition[]] => {
const columns = generateTableColumns(scenario, ThermalUnitsColumnSpec);
const data = generateTableData(
getThermalGenerators(scenario),
ThermalUnitsColumnSpec,
scenario,
);
return [data, columns];
};
export const parseThermalUnitsCsv = (
csvContents: string,
scenario: UnitCommitmentScenario,
): [UnitCommitmentScenario, ValidationError | null] => {
const [thermalGens, err] = parseCsv(
csvContents,
ThermalUnitsColumnSpec,
scenario,
);
if (err) return [scenario, err];
// Process imported generators
for (const gen in thermalGens) {
thermalGens[gen]["Type"] = "Thermal";
}
// Merge with existing data
const profGens = getProfiledGenerators(scenario);
const newScenario = {
...scenario,
Generators: { ...thermalGens, ...profGens },
};
return [newScenario, null];
};
const ThermalUnitsComponent = (props: CaseBuilderSectionProps) => {
const fileUploadElem = useRef<FileUploadElement>(null);
const onDownload = () => {
const [data, columns] = generateThermalUnitsData(props.scenario);
const csvContents = generateCsv(data, columns);
offerDownload(csvContents, "text/csv", "thermal_units.csv");
};
const onUpload = () => {
fileUploadElem.current!.showFilePicker((csv: any) => {
const [newScenario, err] = parseThermalUnitsCsv(csv, props.scenario);
if (err) {
props.onError(err.message);
return;
}
props.onDataChanged(newScenario);
});
};
const onAdd = () => {
const [newScenario, err] = createThermalUnit(props.scenario);
if (err) {
props.onError(err.message);
return;
}
props.onDataChanged(newScenario);
};
const onDelete = (name: string): ValidationError | null => {
const newScenario = deleteGenerator(name, props.scenario);
props.onDataChanged(newScenario);
return null;
};
const onDataChanged = (
name: string,
field: string,
newValue: string,
): ValidationError | null => {
const [newScenario, err] = changeThermalUnitData(
name,
field,
newValue,
props.scenario,
);
if (err) {
props.onError(err.message);
return err;
}
props.onDataChanged(newScenario);
return null;
};
const onRename = (
oldName: string,
newName: string,
): ValidationError | null => {
const [newScenario, err] = renameGenerator(
oldName,
newName,
props.scenario,
);
if (err) {
props.onError(err.message);
return err;
}
props.onDataChanged(newScenario);
return null;
};
return (
<div>
<SectionHeader title="Thermal units">
<SectionButton icon={faPlus} tooltip="Add" onClick={onAdd} />
<SectionButton
icon={faDownload}
tooltip="Download"
onClick={onDownload}
/>
<SectionButton icon={faUpload} tooltip="Upload" onClick={onUpload} />
</SectionHeader>
<DataTable
onRowDeleted={onDelete}
onRowRenamed={onRename}
onDataChanged={onDataChanged}
generateData={() => generateThermalUnitsData(props.scenario)}
/>
<FileUploadElement ref={fileUploadElem} accept=".csv" />
</div>
);
};
export default ThermalUnitsComponent;

View File

@@ -1,203 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
import SectionHeader from "../Common/SectionHeader/SectionHeader";
import SectionButton from "../Common/Buttons/SectionButton";
import {
faDownload,
faPlus,
faUpload,
} from "@fortawesome/free-solid-svg-icons";
import DataTable, {
ColumnSpec,
generateCsv,
generateTableColumns,
generateTableData,
parseCsv,
} from "../Common/Forms/DataTable";
import { ColumnDefinition } from "tabulator-tables";
import FileUploadElement from "../Common/Buttons/FileUploadElement";
import { useRef } from "react";
import { ValidationError } from "../../core/Data/validate";
import { CaseBuilderSectionProps } from "./CaseBuilder";
import {
changeTransmissionLineData,
createTransmissionLine,
deleteTransmissionLine,
rebuildContingencies,
renameTransmissionLine,
} from "../../core/Operations/transmissionOps";
import { offerDownload } from "../Common/io";
import { UnitCommitmentScenario } from "../../core/Data/types";
export const TransmissionLinesColumnSpec: ColumnSpec[] = [
{
title: "Name",
type: "string",
width: 100,
},
{
title: "Source bus",
type: "busRef",
width: 100,
},
{
title: "Target bus",
type: "busRef",
width: 100,
},
{
title: "Susceptance (S)",
type: "number",
width: 60,
},
{
title: "Normal flow limit (MW)",
type: "number?",
width: 60,
},
{
title: "Emergency flow limit (MW)",
type: "number?",
width: 60,
},
{
title: "Flow limit penalty ($/MW)",
type: "number",
width: 60,
},
{
title: "Contingency?",
type: "lineContingency",
width: 50,
},
];
const generateTransmissionLinesData = (
scenario: UnitCommitmentScenario,
): [any[], ColumnDefinition[]] => {
const columns = generateTableColumns(scenario, TransmissionLinesColumnSpec);
const data = generateTableData(
scenario["Transmission lines"],
TransmissionLinesColumnSpec,
scenario,
);
return [data, columns];
};
const TransmissionLinesComponent = (props: CaseBuilderSectionProps) => {
const fileUploadElem = useRef<FileUploadElement>(null);
const onDownload = () => {
const [data, columns] = generateTransmissionLinesData(props.scenario);
const csvContents = generateCsv(data, columns);
offerDownload(csvContents, "text/csv", "transmission.csv");
};
const onUpload = () => {
fileUploadElem.current!.showFilePicker((csv: any) => {
// Parse the CSV data
const [newLines, err] = parseCsv(
csv,
TransmissionLinesColumnSpec,
props.scenario,
);
if (err) {
props.onError(err.message);
return;
}
// Remove contingency field from line and rebuild the contingencies section
const lineContingencies = new Set<String>();
Object.entries(newLines).forEach(([lineName, line]: [string, any]) => {
if (line["Contingency?"]) lineContingencies.add(lineName);
delete line["Contingency?"];
});
const contingencies = rebuildContingencies(lineContingencies);
const newScenario = {
...props.scenario,
"Transmission lines": newLines,
Contingencies: contingencies,
};
props.onDataChanged(newScenario);
});
};
const onAdd = () => {
const [newScenario, err] = createTransmissionLine(props.scenario);
if (err) {
props.onError(err.message);
return;
}
props.onDataChanged(newScenario);
};
const onDelete = (name: string): ValidationError | null => {
const newScenario = deleteTransmissionLine(name, props.scenario);
props.onDataChanged(newScenario);
return null;
};
const onDataChanged = (
name: string,
field: string,
newValue: string,
): ValidationError | null => {
const [newScenario, err] = changeTransmissionLineData(
name,
field,
newValue,
props.scenario,
);
if (err) {
props.onError(err.message);
return err;
}
props.onDataChanged(newScenario);
return null;
};
const onRename = (
oldName: string,
newName: string,
): ValidationError | null => {
const [newScenario, err] = renameTransmissionLine(
oldName,
newName,
props.scenario,
);
if (err) {
props.onError(err.message);
return err;
}
props.onDataChanged(newScenario);
return null;
};
return (
<div>
<SectionHeader title="Transmission lines">
<SectionButton icon={faPlus} tooltip="Add" onClick={onAdd} />
<SectionButton
icon={faDownload}
tooltip="Download"
onClick={onDownload}
/>
<SectionButton icon={faUpload} tooltip="Upload" onClick={onUpload} />
</SectionHeader>
<DataTable
onRowDeleted={onDelete}
onRowRenamed={onRename}
onDataChanged={onDataChanged}
generateData={() => generateTransmissionLinesData(props.scenario)}
/>
<FileUploadElement ref={fileUploadElem} accept=".csv" />
</div>
);
};
export default TransmissionLinesComponent;

View File

@@ -1,58 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
import pako from "pako";
import React, { Component } from "react";
class FileUploadElement extends Component<any> {
private inputRef = React.createRef<HTMLInputElement>();
private callback: (data: any) => void = () => {};
showFilePicker = (callback: (data: any) => void) => {
this.callback = callback;
this.inputRef.current?.click();
};
onFileSelected = (event: React.ChangeEvent<HTMLInputElement>) => {
const file = event.target.files![0]!;
let isCompressed = file.name.endsWith(".gz");
if (file) {
const reader = new FileReader();
reader.onload = async (e) => {
let content = e.target?.result;
if (isCompressed) {
const compressed = new Uint8Array(content as ArrayBuffer);
const decompressed = pako.inflate(compressed);
content = new TextDecoder().decode(decompressed);
}
this.callback(content as string);
this.callback = () => {};
};
if (isCompressed) {
reader.readAsArrayBuffer(file);
} else {
reader.readAsText(file);
}
}
event.target.value = "";
};
override render() {
return (
<input
ref={this.inputRef}
type="file"
accept={this.props.accept}
style={{ display: "none" }}
onChange={this.onFileSelected}
/>
);
}
}
export default FileUploadElement;

View File

@@ -1,43 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
.tooltip {
visibility: hidden;
background-color: var(--contrast-80);
color: var(--contrast-10);
opacity: 0;
width: 250px;
margin-top: 36px;
margin-left: -250px;
position: absolute;
z-index: 100;
font-size: 14px;
border-radius: var(--border-radius);
box-shadow: var(--box-shadow);
line-height: 20px;
transition: opacity 0.5s;
font-weight: normal;
text-align: left;
padding: 6px 12px;
}
.icon {
color: var(--contrast-60);
font-size: 16px;
padding: 8px 8px 8px 0;
}
.HelpButton {
border: 0;
background-color: transparent;
cursor: pointer;
}
.HelpButton:hover .tooltip {
visibility: visible;
opacity: 100%;
transition: opacity 0.5s;
}

View File

@@ -1,22 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
import styles from "./HelpButton.module.css";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faCircleQuestion } from "@fortawesome/free-regular-svg-icons";
function HelpButton({ text }: { text: String }) {
return (
<button className={styles.HelpButton}>
<span className={styles.tooltip}>{text}</span>
<span className={styles.icon}>
<FontAwesomeIcon icon={faCircleQuestion} />
</span>
</button>
);
}
export default HelpButton;

View File

@@ -1,26 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
.SectionButton {
height: 48px;
width: 48px;
font-size: 16px;
border: 0;
background-color: transparent;
margin: 8px 0 8px 0px;
cursor: pointer;
color: var(--contrast-60);
}
.SectionButton:hover {
color: var(--contrast-100);
background-color: var(--contrast-20);
border-radius: var(--border-radius);
}
.SectionButton:active {
background-color: var(--contrast-60);
}

View File

@@ -1,29 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
import { IconDefinition } from "@fortawesome/fontawesome-svg-core";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import styles from "./SectionButton.module.css";
interface SectionButtonProps {
icon: IconDefinition;
tooltip: string;
onClick?: () => void;
}
function SectionButton(props: SectionButtonProps) {
return (
<button
className={styles.SectionButton}
title={props.tooltip}
onClick={props.onClick}
>
<FontAwesomeIcon icon={props.icon} />
</button>
);
}
export default SectionButton;

View File

@@ -1,28 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
.SiteHeaderButton {
padding: 6px 24px;
margin: 0 0 0 8px;
line-height: 24px;
border: var(--box-border);
box-shadow: var(--box-shadow);
border-radius: var(--border-radius);
cursor: pointer;
color: var(--contrast-80);
text-transform: uppercase;
font-weight: bold;
font-size: 12px;
background: linear-gradient(var(--contrast-0) 25%, var(--contrast-10) 100%);
}
.SiteHeaderButton:hover {
background: rgb(245, 245, 245);
}
.SiteHeaderButton:active {
background: rgba(220, 220, 220);
}

View File

@@ -1,23 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
import styles from "./SiteHeaderButton.module.css";
function SiteHeaderButton({
title,
onClick,
}: {
title: string;
onClick?: () => void;
}) {
return (
<button className={styles.SiteHeaderButton} onClick={onClick}>
{title}
</button>
);
}
export default SiteHeaderButton;

View File

@@ -1,531 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
import { useEffect, useRef, useState } from "react";
import {
CellComponent,
ColumnDefinition,
TabulatorFull as Tabulator,
} from "tabulator-tables";
import { ValidationError } from "../../../core/Data/validate";
import Papa from "papaparse";
import {
parseBool,
parseNullableNumber,
parseNumber,
} from "../../../core/Operations/commonOps";
import { UnitCommitmentScenario } from "../../../core/Data/types";
import { getContingencyTransmissionLines } from "../../../core/Operations/transmissionOps";
export interface ColumnSpec {
title: string;
type:
| "string"
| "number"
| "number?"
| "number[N]"
| "number[T]"
| "busRef"
| "boolean"
| "lineContingency";
length?: number;
width: number;
}
export const generateTableColumns = (
scenario: UnitCommitmentScenario,
colSpecs: ColumnSpec[],
) => {
const timeSlots = generateTimeslots(scenario);
const columns: ColumnDefinition[] = [];
colSpecs.forEach((spec) => {
const subColumns: ColumnDefinition[] = [];
switch (spec.type) {
case "string":
case "busRef":
columns.push({
...columnsCommonAttrs,
title: spec.title,
field: spec.title,
minWidth: spec.width,
});
break;
case "boolean":
case "lineContingency":
columns.push({
...columnsCommonAttrs,
title: spec.title,
field: spec.title,
minWidth: spec.width,
editor: "list",
editorParams: {
values: [true, false],
},
});
break;
case "number":
case "number?":
columns.push({
...columnsCommonAttrs,
title: spec.title,
field: spec.title,
minWidth: spec.width,
formatter: floatFormatter,
});
break;
case "number[T]":
timeSlots.forEach((t) => {
subColumns.push({
...columnsCommonAttrs,
title: `${t}`,
field: `${spec.title} ${t}`,
minWidth: spec.width,
formatter: floatFormatter,
});
});
columns.push({
title: spec.title,
columns: subColumns,
});
break;
case "number[N]":
for (let i = 1; i <= spec.length!; i++) {
subColumns.push({
...columnsCommonAttrs,
title: `${i}`,
field: `${spec.title} ${i}`,
minWidth: spec.width,
formatter: floatFormatter,
});
}
columns.push({
title: spec.title,
columns: subColumns,
});
break;
default:
throw Error(`Unknown type: ${spec.type}`);
}
});
return columns;
};
export const generateTableData = (
container: any,
colSpecs: ColumnSpec[],
scenario: UnitCommitmentScenario,
): any[] => {
const data: any[] = [];
const timeslots = generateTimeslots(scenario);
let contingencyLines = null;
for (const [entryName, entryData] of Object.entries(container) as [
string,
any,
]) {
const entry: any = {};
for (const spec of colSpecs) {
if (spec.title === "Name") {
entry["Name"] = entryName;
continue;
}
switch (spec.type) {
case "string":
case "number":
case "number?":
case "boolean":
case "busRef":
entry[spec.title] = entryData[spec.title];
break;
case "lineContingency":
if (contingencyLines === null) {
contingencyLines = getContingencyTransmissionLines(scenario);
console.log(contingencyLines);
}
entry[spec.title] = contingencyLines.has(entryName);
break;
case "number[T]":
for (let i = 0; i < timeslots.length; i++) {
entry[`${spec.title} ${timeslots[i]}`] = entryData[spec.title][i];
}
break;
case "number[N]":
for (let i = 0; i < spec.length!; i++) {
let v = entryData[spec.title][i];
if (v === undefined || v === null) v = "";
entry[`${spec.title} ${i + 1}`] = v;
}
break;
default:
throw Error(`Unknown type: ${spec.type}`);
}
}
data.push(entry);
}
return data;
};
export const generateCsv = (data: any[], columns: ColumnDefinition[]) => {
const header: string[] = [];
const body: string[][] = data.map(() => []);
columns.forEach((column) => {
if (column.columns) {
column.columns.forEach((subcolumn) => {
header.push(subcolumn.field!);
for (let i = 0; i < data.length; i++) {
body[i]!.push(data[i]![subcolumn["field"]!]);
}
});
} else {
header.push(column.field!);
for (let i = 0; i < data.length; i++) {
body[i]!.push(data[i]![column["field"]!]);
}
}
});
const csvHeader = header.join(",");
const csvBody = body.map((row) => row.join(",")).join("\n");
return `${csvHeader}\n${csvBody}`;
};
export const parseCsv = (
csvContents: string,
colSpecs: ColumnSpec[],
scenario: UnitCommitmentScenario,
): [any, ValidationError | null] => {
// Parse contents
const csv = Papa.parse(csvContents, {
header: true,
skipEmptyLines: true,
transformHeader: (header) => header.trim(),
transform: (value) => value.trim(),
});
// Check for parsing errors
if (csv.errors.length > 0) {
console.error(csv.errors);
return [null, { message: "Could not parse CSV file" }];
}
// Check CSV headers
const columns = generateTableColumns(scenario, colSpecs);
const expectedHeader: string[] = [];
columns.forEach((column) => {
if (column.columns) {
column.columns.forEach((subcolumn) => {
expectedHeader.push(subcolumn.field!);
});
} else {
expectedHeader.push(column.field!);
}
});
const actualHeader = csv.meta.fields!;
for (let i = 0; i < expectedHeader.length; i++) {
if (expectedHeader[i] !== actualHeader[i]) {
return [
null,
{
message: `Invalid CSV: Header mismatch at column ${i + 1}.
Expected "${expectedHeader[i]}", found "${actualHeader[i]}"`,
},
];
}
}
// Parse each row
const timeslots = generateTimeslots(scenario);
const data: { [key: string]: any } = {};
for (let i = 0; i < csv.data.length; i++) {
const row = csv.data[i] as { [key: string]: any };
const rowRef = ` (row ${i + 1})`;
const name = row["Name"] as string;
if (name in data) {
return [null, { message: `Name "${name}" is duplicated` + rowRef }];
}
data[name] = {};
for (const spec of colSpecs) {
if (spec.title === "Name") continue;
switch (spec.type) {
case "string":
data[name][spec.title] = row[spec.title];
break;
case "number": {
const [val, err] = parseNumber(row[spec.title]);
if (err) return [null, { message: err.message + rowRef }];
data[name][spec.title] = val;
break;
}
case "number?": {
const [val, err] = parseNullableNumber(row[spec.title]);
if (err) return [null, { message: err.message + rowRef }];
data[name][spec.title] = val;
break;
}
case "busRef":
const busName = row[spec.title];
if (!(busName in scenario.Buses)) {
return [
null,
{ message: `Bus "${busName}" does not exist` + rowRef },
];
}
data[name][spec.title] = row[spec.title];
break;
case "number[T]": {
data[name][spec.title] = Array(timeslots.length);
for (let i = 0; i < timeslots.length; i++) {
const [vf, err] = parseNumber(row[`${spec.title} ${timeslots[i]}`]);
if (err) return [data, { message: err.message + rowRef }];
data[name][spec.title][i] = vf;
}
break;
}
case "number[N]": {
data[name][spec.title] = Array(spec.length).fill(0);
for (let i = 0; i < spec.length!; i++) {
let v = row[`${spec.title} ${i + 1}`];
if (v.trim() === "") {
data[name][spec.title].splice(i, spec.length! - i);
break;
} else {
const [vf, err] = parseNumber(row[`${spec.title} ${i + 1}`]);
if (err) return [data, { message: err.message + rowRef }];
data[name][spec.title][i] = vf;
}
}
break;
}
case "boolean":
case "lineContingency":
const [val, err] = parseBool(row[spec.title]);
if (err) return [data, { message: err.message + rowRef }];
data[name][spec.title] = val;
break;
default:
throw Error(`Unknown type: ${spec.type}`);
}
}
}
return [data, null];
};
export const floatFormatter = (cell: CellComponent) => {
const v = cell.getValue();
if (v === "" || v === null) {
return "&mdash;";
} else {
return parseFloat(cell.getValue()).toLocaleString("en-US", {
minimumFractionDigits: 1,
maximumFractionDigits: 1,
});
}
};
export const generateTimeslots = (scenario: UnitCommitmentScenario) => {
const timeHorizonHours = scenario["Parameters"]["Time horizon (h)"];
const timeStepMin = scenario["Parameters"]["Time step (min)"];
const timeslots: string[] = [];
for (
let m = 0, offset = 0;
m < timeHorizonHours * 60;
m += timeStepMin, offset += 1
) {
const hours = Math.floor(m / 60);
const mins = m % 60;
const formattedTime = `${String(hours).padStart(2, "0")}:${String(mins).padStart(2, "0")}`;
timeslots.push(formattedTime);
}
return timeslots;
};
export const columnsCommonAttrs: ColumnDefinition = {
headerHozAlign: "left",
hozAlign: "left",
title: "",
editor: "input",
editorParams: {
selectContents: true,
},
headerWordWrap: true,
formatter: "plaintext",
headerSort: false,
resizable: false,
};
interface DataTableProps {
onRowDeleted: (rowName: string) => ValidationError | null;
onRowRenamed: (
oldRowName: string,
newRowName: string,
) => ValidationError | null;
onDataChanged: (
rowName: string,
key: string,
newValue: string,
) => ValidationError | null;
generateData: () => [any[], ColumnDefinition[]];
}
function computeTableHeight(data: any[]): string {
const numRows = data.length;
const height = 70 + Math.max(Math.min(numRows, 15), 1) * 28;
return `${height}px`;
}
const DataTable = (props: DataTableProps) => {
const tableContainerRef = useRef<HTMLDivElement | null>(null);
const tableRef = useRef<Tabulator | null>(null);
const [isTableBuilt, setTableBuilt] = useState<Boolean>(false);
const [activeCell, setActiveCell] = useState<CellComponent | null>(null);
const [currentTableData, setCurrentTableData] = useState<any[]>([]);
useEffect(() => {
const onCellEdited = (cell: CellComponent) => {
let newValue = `${cell.getValue()}`;
let oldValue = `${cell.getOldValue()}`;
if (newValue === oldValue) return;
if (cell.getField() === "Name") {
if (newValue === "") {
const err = props.onRowDeleted(oldValue);
if (err) {
cell.restoreOldValue();
} else {
cell
.getRow()
.delete()
.then((r) => {});
}
} else {
const err = props.onRowRenamed(oldValue, newValue);
if (err) {
cell.restoreOldValue();
}
}
} else {
const row = cell.getRow().getData();
const bus = row["Name"];
const err = props.onDataChanged(bus, cell.getField(), newValue);
if (err) {
cell.restoreOldValue();
}
}
};
if (tableContainerRef.current === null) return;
const [data, columns] = props.generateData();
const height = computeTableHeight(data);
if (tableRef.current === null) {
tableRef.current = new Tabulator(tableContainerRef.current, {
layout: "fitColumns",
data: data,
columns: columns,
height: height,
index: "Name",
placeholder: "No data",
});
tableRef.current.on("tableBuilt", () => {
setTableBuilt(true);
});
}
if (isTableBuilt) {
const newHeight = height;
const newColumns = columns;
const newTableData = data;
const oldRows = tableRef.current.getRows();
const activeRowPosition = activeCell?.getRow().getPosition() as number;
const activeField = activeCell?.getField();
// Update data
if (newTableData.length === currentTableData.length) {
const updatedRows = newTableData.filter((_, i) => {
return (
JSON.stringify(newTableData[i]) !==
JSON.stringify(currentTableData[i])
);
});
if (updatedRows.length > 0) {
tableRef.current
.updateData(updatedRows)
.then(() => {})
.catch((e) => {
// WORKAROUND: Updating the same row twice triggers an exception.
// In that case, we just update the whole table.
console.log(e);
tableRef.current!!.replaceData(newTableData).then(() => {});
});
}
} else {
tableRef.current.replaceData(newTableData).then(() => {});
}
setCurrentTableData(newTableData);
// Restore active cell selection
if (activeCell) {
tableRef.current
?.getRowFromPosition(activeRowPosition!!)
?.getCell(activeField!!)
?.edit();
}
// Update columns
let newColCount = 0;
newColumns.forEach((col) => {
if (col.columns) newColCount += col.columns.length;
else newColCount += 1;
});
if (newColCount !== tableRef.current.getColumns().length) {
tableRef.current.setColumns(newColumns);
const rows = tableRef.current!.getRows()!;
const firstRow = rows[0];
if (firstRow) firstRow.scrollTo().then((r) => {});
}
// Update height
if (tableRef.current.options.height !== newHeight) {
tableRef.current.setHeight(newHeight);
}
// Scroll to bottom
if (tableRef.current.getRows().length === oldRows.length + 1) {
setTimeout(() => {
const rows = tableRef.current!.getRows()!;
const lastRow = rows[rows.length - 1]!;
lastRow.scrollTo().then((r) => {});
lastRow.getCell("Name").edit();
}, 10);
}
// Remove old callbacks
tableRef.current.off("cellEdited");
tableRef.current.off("cellEditing");
tableRef.current.off("cellEditCancelled");
// Set new callbacks
tableRef.current.on("cellEditing", (cell) => {
setActiveCell(cell);
});
tableRef.current.on("cellEditCancelled", (cell) => {
setActiveCell(null);
});
tableRef.current.on("cellEdited", (cell) => {
setActiveCell(null);
onCellEdited(cell);
});
}
}, [props, isTableBuilt]);
return (
<div className="tableWrapper">
<div ref={tableContainerRef} />
</div>
);
};
export default DataTable;

View File

@@ -1,46 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
.FormWrapper {
margin: 0 auto;
max-width: var(--site-max-width);
}
.Form {
background-color: var(--contrast-0);
border: var(--box-border);
border-radius: var(--border-radius);
box-shadow: var(--box-shadow);
min-height: 48px;
margin: 0 12px;
min-width: var(--site-min-width);
max-height: 500px;
padding: 12px;
}
.FormRow {
display: flex;
line-height: 24px;
}
.FormRow label {
width: 350px;
padding: 6px 12px;
text-align: right;
}
.FormRow input {
flex: 1;
font-family: monospace;
border: var(--box-border);
border-radius: var(--border-radius);
padding: 4px;
margin: 2px 3px;
}
.FormRow_unit {
color: rgba(0, 0, 0, 0.4);
}

View File

@@ -1,18 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
import { ReactNode } from "react";
import styles from "./Form.module.css";
function Form({ children }: { children: ReactNode }) {
return (
<div className={styles.FormWrapper}>
<div className={styles.Form}>{children}</div>
</div>
);
}
export default Form;

View File

@@ -1,96 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
.tableWrapper {
margin: 0 auto;
max-width: var(--site-max-width);
}
.tabulator {
background-color: var(--contrast-0);
border: var(--box-border) !important;
border-radius: var(--border-radius);
box-shadow: var(--box-shadow);
min-height: 48px;
min-width: var(--site-min-width);
padding: 0;
margin: 0 12px;
}
.tabulator .tabulator-header {
border-bottom: 1px solid #ccc;
font-size: 13px;
font-weight: bold;
color: var(--contrast-100);
line-height: 18px;
}
.tabulator .tabulator-header .subtitle {
color: var(--contrast-80);
font-weight: normal;
}
.tabulator .tabulator-header .tabulator-col {
border-right: 1px solid rgba(0, 0, 0, 0.1) !important;
vertical-align: middle !important;
}
.tabulator .tabulator-header .tabulator-col .tabulator-col-content {
text-align: left;
padding: 0 8px;
line-height: 24px;
}
.tabulator .tabulator-header .tabulator-col:last-child {
border-right: 1px solid rgba(0, 0, 0, 0.1) !important;
}
.tabulator-row .tabulator-cell {
font-family: monospace;
font-size: 12px;
line-height: 28px;
height: 28px;
text-align: right;
vertical-align: middle !important;
border-right: 1px solid rgba(0, 0, 0, 0.1) !important;
border-bottom: 1px solid rgba(0, 0, 0, 0.1) !important;
padding: 0 8px;
}
.tabulator-row-even {
background-color: rgba(0, 0, 0, 0.03) !important;
}
.tabulator-row-odd {
background-color: rgba(0, 0, 0, 0) !important;
}
.tabulator-row .tabulator-cell.tabulator-editing {
border: 0;
padding: 0 4px;
background-color: #cee;
}
.tabulator-row .tabulator-cell.tabulator-editing input {
font-family: monospace;
text-align: left;
font-size: 12px;
}
.tabulator-col-group-cols {
font-size: 12px;
}
.tabulator-placeholder {
width: 100px !important;
}
.tabulator-placeholder * {
font-weight: normal !important;
font-size: 14px !important;
color: var(--contrast-60) !important;
}

View File

@@ -1,58 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
import formStyles from "./Form.module.css";
import HelpButton from "../Buttons/HelpButton";
import React, { useEffect, useRef, useState } from "react";
import { ValidationError } from "../../../core/Data/validate";
interface TextInputRowProps {
label: string;
unit: string;
tooltip: string;
initialValue: string;
onChange: (newValue: string) => ValidationError | null;
}
function TextInputRow(props: TextInputRowProps) {
const [savedValue, setSavedValue] = useState(props.initialValue);
const inputRef = useRef<HTMLInputElement>(null);
useEffect(() => {
if (inputRef.current) {
inputRef.current.value = props.initialValue;
}
setSavedValue(props.initialValue);
}, [props.initialValue]);
const onBlur = (event: React.FocusEvent<HTMLInputElement>) => {
const newValue = event.target.value;
if (newValue === savedValue) return;
const err = props.onChange(newValue);
if (err) {
inputRef.current!.value = savedValue;
return;
}
};
return (
<div className={formStyles.FormRow}>
<label>
{props.label}
<span className={formStyles.FormRow_unit}> ({props.unit})</span>
</label>
<input
ref={inputRef}
type="text"
defaultValue={savedValue}
onBlur={onBlur}
/>
<HelpButton text={props.tooltip} />
</div>
);
}
export default TextInputRow;

View File

@@ -1,23 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
.Toast {
width: 600px;
border-radius: var(--border-radius);
box-shadow: 4px 4px 16px -2px rgba(0, 0, 0, 0.5);
margin: 0 auto;
background-color: #424242;
color: white;
padding: 0 16px;
position: fixed;
top: 48px;
left: 50%;
transform: translate(-50%, 0);
transition: opacity 0.5s ease;
cursor: default;
font-size: 15px;
line-height: 48px;
}

View File

@@ -1,35 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
import styles from "./Toast.module.css";
import { useEffect, useState } from "react";
interface ToastProps {
message: string;
}
const Toast = (props: ToastProps) => {
const [isVisible, setVisible] = useState(true);
useEffect(() => {
if (props.message.length === 0) return;
setVisible(true);
const timer = setTimeout(() => {
setVisible(false);
}, 5000);
return () => clearTimeout(timer);
}, [props.message]);
return (
<div>
<div className={styles.Toast} style={{ opacity: isVisible ? 1 : 0 }}>
{props.message}
</div>
</div>
);
};
export default Toast;

View File

@@ -1,25 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
.SectionHeader {
max-width: var(--site-max-width);
min-width: var(--site-min-width);
margin: 0 auto;
color: var(--contrast-100);
}
.SectionHeader h1 {
margin: 0;
padding: 0 24px;
font-size: 16px;
line-height: 64px;
}
.SectionButtonsContainer {
float: right;
height: 64px;
margin-right: 12px;
}

View File

@@ -1,24 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
import styles from "./SectionHeader.module.css";
import { ReactNode } from "react";
interface SectionHeaderProps {
title: string;
children?: ReactNode;
}
function SectionHeader({ title, children }: SectionHeaderProps) {
return (
<div className={styles.SectionHeader}>
<div className={styles.SectionButtonsContainer}>{children}</div>
<h1>{title}</h1>
</div>
);
}
export default SectionHeader;

View File

@@ -1,17 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
export function offerDownload(data: string, type: string, filename: string) {
const dataBlob = new Blob([data], { type: type });
const url = URL.createObjectURL(dataBlob);
const link = document.createElement("a");
link.href = url;
link.download = filename;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
URL.revokeObjectURL(url);
}

View File

@@ -1,132 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
import { UnitCommitmentScenario } from "./types";
export const TEST_DATA_1: UnitCommitmentScenario = {
Parameters: {
Version: "0.4",
"Power balance penalty ($/MW)": 1000.0,
"Time horizon (h)": 5,
"Time step (min)": 60,
},
Buses: {
b1: { "Load (MW)": [35.79534, 34.38835, 33.45083, 32.89729, 33.25044] },
b2: { "Load (MW)": [14.03739, 13.48563, 13.11797, 12.9009, 13.03939] },
b3: { "Load (MW)": [27.3729, 26.29698, 25.58005, 25.15675, 25.4268] },
},
Generators: {
g1: {
Bus: "b1",
Type: "Thermal",
"Production cost curve (MW)": [100.0, 110.0, 130.0, 135.0],
"Production cost curve ($)": [1400.0, 1600.0, 2200.0, 2400.0],
"Startup costs ($)": [300.0, 400.0],
"Startup delays (h)": [1, 4],
"Ramp up limit (MW)": 232.68,
"Ramp down limit (MW)": 232.68,
"Startup limit (MW)": 232.68,
"Shutdown limit (MW)": 232.68,
"Minimum downtime (h)": 4,
"Minimum uptime (h)": 4,
"Initial status (h)": 12,
"Initial power (MW)": 115,
"Must run?": false,
},
pu1: {
Bus: "b1",
Type: "Profiled",
"Cost ($/MW)": 12.5,
"Maximum power (MW)": [10, 12, 13, 15, 20],
"Minimum power (MW)": [0, 0, 0, 0, 0],
},
pu2: {
Bus: "b1",
Type: "Profiled",
"Cost ($/MW)": 120,
"Maximum power (MW)": [50, 50, 50, 50, 50],
"Minimum power (MW)": [0, 0, 0, 0, 0],
},
},
"Transmission lines": {
l1: {
"Source bus": "b1",
"Target bus": "b2",
"Susceptance (S)": 29.49686,
"Normal flow limit (MW)": 15000.0,
"Emergency flow limit (MW)": 20000.0,
"Flow limit penalty ($/MW)": 5000.0,
},
},
"Storage units": {
su1: {
Bus: "b1",
"Minimum level (MWh)": 10.0,
"Maximum level (MWh)": 100.0,
"Charge cost ($/MW)": 2.0,
"Discharge cost ($/MW)": 1.0,
"Charge efficiency": 0.8,
"Discharge efficiency": 0.85,
"Loss factor": 0.01,
"Minimum charge rate (MW)": 5.0,
"Maximum charge rate (MW)": 10.0,
"Minimum discharge rate (MW)": 4.0,
"Maximum discharge rate (MW)": 8.0,
"Initial level (MWh)": 20.0,
"Last period minimum level (MWh)": 21.0,
"Last period maximum level (MWh)": 22.0,
},
},
"Price-sensitive loads": {
ps1: {
Bus: "b3",
"Revenue ($/MW)": 23.0,
"Demand (MW)": [50, 50, 50, 50, 50],
},
},
Contingencies: {
l1: {
"Affected generators": [],
"Affected lines": ["l1"],
},
},
};
export const TEST_DATA_2: UnitCommitmentScenario = {
Parameters: {
Version: "0.4",
"Power balance penalty ($/MW)": 1000.0,
"Time horizon (h)": 2,
"Time step (min)": 30,
},
Buses: {
b1: { "Load (MW)": [30, 30, 30, 30] },
b2: { "Load (MW)": [10, 20, 30, 40] },
b3: { "Load (MW)": [0, 30, 0, 40] },
},
Contingencies: {},
Generators: {},
"Transmission lines": {},
"Storage units": {},
"Price-sensitive loads": {},
};
export const TEST_DATA_BLANK: UnitCommitmentScenario = {
Parameters: {
Version: "0.4",
"Power balance penalty ($/MW)": 1000.0,
"Time horizon (h)": 5,
"Time step (min)": 60,
},
Buses: {},
Contingencies: {},
Generators: {},
"Transmission lines": {},
"Storage units": {},
"Price-sensitive loads": {},
};
test("fixtures", () => {});

View File

@@ -1,26 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
import { UnitCommitmentScenario } from "./types";
export interface Buses {
[busName: string]: { "Load (MW)": number[] };
}
export const BLANK_SCENARIO: UnitCommitmentScenario = {
Parameters: {
Version: "0.4",
"Power balance penalty ($/MW)": 1000.0,
"Time horizon (h)": 24,
"Time step (min)": 60,
},
Buses: {},
Generators: {},
"Transmission lines": {},
"Storage units": {},
"Price-sensitive loads": {},
Contingencies: {},
};

View File

@@ -1,34 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
import assert from "node:assert";
import fs from "node:fs";
import pako from "pako";
import { migrateToV03, migrateToV04 } from "./migrate";
function readJsonGz(filename: string) {
const compressedData = fs.readFileSync(filename);
const decompressedData = pako.inflate(compressedData, { to: "string" });
return JSON.parse(decompressedData);
}
test("migrateToV03", () => {
const jsonData = readJsonGz("../test/fixtures/ucjl-0.2.json.gz");
migrateToV03(jsonData);
assert.deepEqual(jsonData.Reserves, {
r1: {
"Amount (MW)": 100,
"Shortfall penalty ($/MW)": 1000,
Type: "spinning",
},
});
});
test("migrateToV04", () => {
const jsonData = readJsonGz("../test/fixtures/ucjl-0.3.json.gz");
migrateToV04(jsonData);
assert.equal(jsonData.Generators["g1"].Type, "Thermal");
});

View File

@@ -1,56 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
import { ValidationError } from "./validate";
export const migrate = (json: any): ValidationError | null => {
const version = json.Parameters?.Version;
if (!version) {
return {
message:
"The provided input file cannot be loaded because it does not " +
"specify what version of UnitCommitment.jl it was written for.",
};
}
if (!["0.2", "0.3", "0.4"].includes(version)) {
return { message: `Unsupported file version: ${version}` };
}
if (version < "0.3") migrateToV03(json);
if (version < "0.4") migrateToV04(json);
json.Parameters.Version = "0.4";
return null;
};
export const migrateToV03 = (json: any): void => {
if (json.Reserves && json.Reserves["Spinning (MW)"] != null) {
const amount = json.Reserves["Spinning (MW)"];
json.Reserves = {
r1: {
Type: "spinning",
"Amount (MW)": amount,
},
};
if (json.Generators) {
for (const genName in json.Generators) {
const gen = json.Generators[genName];
if (gen["Provides spinning reserves?"] === true) {
gen["Reserve eligibility"] = ["r1"];
}
}
}
}
};
export const migrateToV04 = (json: any): void => {
if (json.Generators) {
for (const genName in json.Generators) {
const gen = json.Generators[genName];
if (gen.Type == null) {
gen.Type = "Thermal";
}
}
}
};

View File

@@ -1,373 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
export const schema = {
$schema: "http://json-schema.org/draft-07/schema#",
title: "Schema for Unit Commitment Input File",
definitions: {
Parameters: {
type: "object",
properties: {
Version: {
type: "string",
const: "0.4",
description: "Version of UnitCommitment.jl",
},
"Time horizon (min)": {
type: "number",
exclusiveMinimum: 0,
description: "Length of the planning horizon in minutes",
},
"Time horizon (h)": {
type: "number",
exclusiveMinimum: 0,
description: "Length of the planning horizon in hours",
},
"Time step (min)": {
type: "number",
default: 60,
enum: [60, 30, 20, 15, 12, 10, 6, 5, 4, 3, 2, 1],
description: "Must be a divisor of 60",
},
"Power balance penalty ($/MW)": {
type: "number",
default: 1000.0,
minimum: 0,
description: "Penalty for system-wide shortage or surplus",
},
"Scenario name": {
type: "string",
default: "s1",
description: "Name of the scenario",
},
"Scenario weight": {
type: "number",
default: 1.0,
exclusiveMinimum: 0,
description: "Weight of the scenario",
},
},
required: ["Time step (min)", "Power balance penalty ($/MW)"],
oneOf: [
{ required: ["Time horizon (min)"] },
{ required: ["Time horizon (h)"] },
],
not: {
required: ["Time horizon (min)", "Time horizon (h)"],
},
},
Bus: {
type: "object",
additionalProperties: {
type: "object",
properties: {
"Load (MW)": {
oneOf: [
{ type: "null" },
{ type: "number" },
{
type: "array",
items: {
oneOf: [{ type: "number" }, { type: "null" }],
},
},
],
},
},
},
},
TransmissionLines: {
type: "object",
additionalProperties: {
type: "object",
properties: {
"Source bus": {
type: "string",
minLength: 1,
},
"Target bus": {
type: "string",
minLength: 1,
not: {
const: { $data: "1/Source bus" },
},
},
"Susceptance (S)": {
type: "number",
},
"Normal flow limit (MW)": {
type: "number",
minimum: 0,
nullable: true,
default: null,
},
"Emergency flow limit (MW)": {
type: "number",
minimum: 0,
nullable: true,
default: null,
},
"Flow limit penalty ($/MW)": {
type: "number",
minimum: 0,
default: 5000.0,
},
},
required: ["Source bus", "Target bus", "Susceptance (S)"],
},
},
StorageUnits: {
type: "object",
additionalProperties: {
type: "object",
properties: {
Bus: {
type: "string",
minLength: 1,
},
"Minimum level (MWh)": {
type: "number",
},
"Maximum level (MWh)": {
type: "number",
minimum: 0,
},
"Allow simultaneous charging and discharging": {
type: "boolean",
default: true,
},
"Charge cost ($/MW)": {
type: "number",
minimum: 0,
},
"Discharge cost ($/MW)": {
type: "number",
minimum: 0,
},
"Charge efficiency": {
type: "number",
minimum: 0,
maximum: 1,
},
"Discharge efficiency": {
type: "number",
minimum: 0,
maximum: 1,
},
"Loss factor": {
type: "number",
minimum: 0,
},
"Minimum charge rate (MW)": {
type: "number",
minimum: 0,
},
"Maximum charge rate (MW)": {
type: "number",
minimum: 0,
},
"Minimum discharge rate (MW)": {
type: "number",
minimum: 0,
},
"Maximum discharge rate (MW)": {
type: "number",
minimum: 0,
},
"Initial level (MWh)": {
type: "number",
minimum: 0,
},
"Last period minimum level (MWh)": {
type: "number",
minimum: 0,
},
"Last period maximum level (MWh)": {
type: "number",
minimum: 0,
},
},
required: ["Bus"],
},
},
Generators: {
type: "object",
additionalProperties: {
type: "object",
if: {
properties: {
Type: { const: "Thermal" },
},
},
then: {
properties: {
Bus: {
type: "string",
minLength: 1,
},
Type: {
type: "string",
const: "Thermal",
},
"Production cost curve (MW)": {
type: "array",
items: {
type: "number",
minimum: 0,
},
minItems: 1,
},
"Production cost curve ($)": {
type: "array",
items: {
type: "number",
minimum: 0,
},
minItems: 1,
},
"Startup costs ($)": {
type: "array",
items: {
type: "number",
minimum: 0,
},
default: [0.0],
},
"Startup delays (h)": {
type: "array",
items: {
type: "integer",
minimum: 1,
},
default: [1],
},
"Minimum uptime (h)": {
type: "integer",
default: 1,
minimum: 0,
},
"Minimum downtime (h)": {
type: "integer",
default: 1,
minimum: 0,
},
"Ramp up limit (MW)": {
type: "number",
minimum: 0,
nullable: true,
default: null,
},
"Ramp down limit (MW)": {
type: "number",
minimum: 0,
nullable: true,
default: null,
},
"Startup limit (MW)": {
type: "number",
minimum: 0,
nullable: true,
default: null,
},
"Shutdown limit (MW)": {
type: "number",
minimum: 0,
nullable: true,
default: null,
},
"Initial status (h)": {
type: "integer",
default: 1,
not: { const: 0 },
},
"Initial power (MW)": {
type: "number",
minimum: 0,
},
"Must run?": {
type: "boolean",
default: false,
},
},
required: [
"Bus",
"Type",
"Production cost curve (MW)",
"Production cost curve ($)",
"Initial status (h)",
"Initial power (MW)",
],
},
else: {
properties: {
Type: { const: "Profiled" },
Bus: {
type: "string",
minLength: 1,
},
"Maximum power (MW)": {
oneOf: [
{
type: "number",
},
{
type: "array",
items: {
type: "number",
},
},
],
},
"Cost ($/MW)": {
type: "number",
minimum: 0,
},
},
required: ["Type", "Bus", "Maximum power (MW)", "Cost ($/MW)"],
},
},
},
Contingencies: {
type: "object",
additionalProperties: {
type: "object",
properties: {
"Affected lines": {
type: "array",
items: {
type: "string",
},
maxItems: 1,
minItems: 1,
},
},
required: ["Affected lines"],
},
},
},
type: "object",
properties: {
Parameters: {
$ref: "#/definitions/Parameters",
},
Buses: {
$ref: "#/definitions/Bus",
},
"Transmission lines": {
$ref: "#/definitions/TransmissionLines",
},
"Storage units": {
$ref: "#/definitions/StorageUnits",
},
Generators: {
$ref: "#/definitions/Generators",
},
Contingencies: {
$ref: "#/definitions/Contingencies",
},
},
required: ["Parameters"],
};

View File

@@ -1,119 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
import { Buses } from "./fixtures";
export interface Generators {
[name: string]: ProfiledUnit | ThermalUnit;
}
export interface ProfiledUnit {
Bus: string;
Type: "Profiled";
"Minimum power (MW)": number[];
"Maximum power (MW)": number[];
"Cost ($/MW)": number;
}
export interface ThermalUnit {
Bus: string;
Type: "Thermal";
"Production cost curve (MW)": number[];
"Production cost curve ($)": number[];
"Startup costs ($)": number[];
"Startup delays (h)": number[];
"Ramp up limit (MW)": number | null;
"Ramp down limit (MW)": number | null;
"Startup limit (MW)": number | null;
"Shutdown limit (MW)": number | null;
"Minimum downtime (h)": number;
"Minimum uptime (h)": number;
"Initial status (h)": number;
"Initial power (MW)": number;
"Must run?": boolean;
}
export interface TransmissionLine {
"Source bus": string;
"Target bus": string;
"Susceptance (S)": number;
"Normal flow limit (MW)": number | null;
"Emergency flow limit (MW)": number | null;
"Flow limit penalty ($/MW)": number;
}
export interface StorageUnit {
Bus: string;
"Minimum level (MWh)": number;
"Maximum level (MWh)": number;
"Charge cost ($/MW)": number;
"Discharge cost ($/MW)": number;
"Charge efficiency": number;
"Discharge efficiency": number;
"Loss factor": number;
"Minimum charge rate (MW)": number;
"Maximum charge rate (MW)": number;
"Minimum discharge rate (MW)": number;
"Maximum discharge rate (MW)": number;
"Initial level (MWh)": number;
"Last period minimum level (MWh)": number;
"Last period maximum level (MWh)": number;
}
export interface PriceSensitiveLoad {
Bus: string;
"Revenue ($/MW)": number;
"Demand (MW)": number[];
}
export interface Contingency {
"Affected lines": string[];
"Affected generators": string[];
}
export interface UnitCommitmentScenario {
Parameters: {
Version: string;
"Power balance penalty ($/MW)": number;
"Time horizon (h)": number;
"Time step (min)": number;
};
Buses: Buses;
Generators: Generators;
"Transmission lines": {
[name: string]: TransmissionLine;
};
"Storage units": {
[name: string]: StorageUnit;
};
"Price-sensitive loads": {
[name: string]: PriceSensitiveLoad;
};
Contingencies: {
[name: string]: Contingency;
};
}
const getTypedGenerators = <T extends any>(
scenario: UnitCommitmentScenario,
type: string,
): {
[key: string]: T;
} => {
const selected: { [key: string]: T } = {};
for (const [name, gen] of Object.entries(scenario.Generators)) {
if (gen["Type"] === type) selected[name] = gen as T;
}
return selected;
};
export const getProfiledGenerators = (
scenario: UnitCommitmentScenario,
): { [key: string]: ProfiledUnit } =>
getTypedGenerators<ProfiledUnit>(scenario, "Profiled");
export const getThermalGenerators = (
scenario: UnitCommitmentScenario,
): { [key: string]: ThermalUnit } =>
getTypedGenerators<ThermalUnit>(scenario, "Thermal");

View File

@@ -1,22 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
import { schema } from "./schema";
import Ajv from "ajv";
// Create Ajv instance with detailed debug options
const ajv = new Ajv({
useDefaults: true,
verbose: true,
allErrors: true,
$data: true,
});
export interface ValidationError {
message: string;
}
export const validate = ajv.compile(schema);

View File

@@ -1,71 +0,0 @@
/*
* UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
* Copyright (C) 2020-2025, UChicago Argonne, LLC. All rights reserved.
* Released under the modified BSD license. See COPYING.md for more details.
*/
import { changeBusData, createBus, deleteBus, renameBus } from "./busOps";
import assert from "node:assert";
import { TEST_DATA_1 } from "../Data/fixtures.test";
test("createBus", () => {
const newScenario = createBus(TEST_DATA_1);
assert.deepEqual(Object.keys(newScenario.Buses), ["b1", "b2", "b3", "b4"]);
});
test("changeBusData", () => {
let scenario = TEST_DATA_1;
let err = null;
[scenario, err] = changeBusData("b1", "Load (MW) 00:00", "99", scenario);
assert.equal(err, null);
[scenario, err] = changeBusData("b1", "Load (MW) 03:00", "99", scenario);
assert.equal(err, null);
[scenario, err] = changeBusData("b3", "Load (MW) 04:00", "99", scenario);
assert.equal(err, null);
assert.deepEqual(scenario.Buses, {
b1: { "Load (MW)": [99, 34.38835, 33.45083, 99, 33.25044] },
b2: { "Load (MW)": [14.03739, 13.48563, 13.11797, 12.9009, 13.03939] },
b3: { "Load (MW)": [27.3729, 26.29698, 25.58005, 25.15675, 99] },
});
});
test("changeBusData with invalid numbers", () => {
let [, err] = changeBusData("b1", "Load (MW) 00:00", "xx", TEST_DATA_1);
assert(err !== null);
assert.equal(err.message, '"xx" is not a valid number');
});
test("deleteBus", () => {
let scenario = TEST_DATA_1;
scenario = deleteBus("b2", scenario);
assert.deepEqual(scenario.Buses, {
b1: { "Load (MW)": [35.79534, 34.38835, 33.45083, 32.89729, 33.25044] },
b3: { "Load (MW)": [27.3729, 26.29698, 25.58005, 25.15675, 25.4268] },
});
});
test("renameBus", () => {
let [scenario, err] = renameBus("b1", "b99", TEST_DATA_1);
assert(err === null);
assert.deepEqual(scenario.Buses, {
b99: { "Load (MW)": [35.79534, 34.38835, 33.45083, 32.89729, 33.25044] },
b2: { "Load (MW)": [14.03739, 13.48563, 13.11797, 12.9009, 13.03939] },
b3: { "Load (MW)": [27.3729, 26.29698, 25.58005, 25.15675, 25.4268] },
});
assert.deepEqual(scenario.Generators["pu1"], {
Bus: "b99",
Type: "Profiled",
"Cost ($/MW)": 12.5,
"Maximum power (MW)": [10, 12, 13, 15, 20],
"Minimum power (MW)": [0, 0, 0, 0, 0],
});
});
test("renameBus with duplicated name", () => {
let [, err] = renameBus("b3", "b1", TEST_DATA_1);
assert(err != null);
assert.equal(err.message, `b1 already exists`);
});

Some files were not shown because too many files have changed in this diff Show More