EridanusQ
init
35f2452
<h1 align="center">UnitCommitment.jl (Modified Trajectory Version)</h1>
> **NOTA BENE**
> This is a customized version of the original `UnitCommitment.jl` package.
>
> **主要修改与新增功能 (Modified Features):**
> 1. **启停轨迹约束 (Power Trajectories)**: 新增了 `xxx2005` 文件夹及其对应的模型实现,支持机组的 Startup / Shutdown 启停轨迹约束 (`xxx2005.PowerTrajectories()`)。
> 2. **预处理修正 (Preprocessing)**: 增加了 `pmax-preprocessing.jl` 脚本,针对特定机组的 Minimum uptime 等参数进行数据筛选与修正逻辑。
>
> *(有关如何运行本次修改的专项测试,请直接查看本文档底部的[**专项测试运行指南**](#专项测试运行指南-testing-the-modified-features) 部分。)*
<p align="center">
<a href="https://doi.org/10.5281/zenodo.4269874">
<img src="https://zenodo.org/badge/doi/10.5281/zenodo.4269874.svg" alt="DOI"></img>
</a>
</p>
**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.
## Package Components
* **Data Format:** Extensible and fully-documented JSON-based data format for SCUC.
* **Benchmark Instances:** A diverse collection of large-scale benchmark instances collected from the literature.
* **Model Implementation:** Julia/JuMP implementations of state-of-the-art formulations. **(Modified: Now includes `xxx2005` formulation for Power Trajectories).**
## Sample Usage (Including Trajectory Formulation)
```julia
using HiGHS
using JuMP
using UnitCommitment
# Read benchmark instance
instance = UnitCommitment.read("test-case2383wp/2017-07-28.json.gz")
# Construct model (using customized formulation with Trajectories)
model = UnitCommitment.build_model(
instance = instance,
optimizer = HiGHS.Optimizer,
formulation = UnitCommitment.Formulation(
# 激活新增的启停轨迹约束
power_trajectories = UnitCommitment.xxx2005.PowerTrajectories()
),
)
# Solve model
JuMP.optimize!(model)
```
---
## 专项测试运行指南 (Testing the Modified Features)
为了验证本次加入的启停轨迹约束与 Minimum uptime 修正,本文件夹内附带了自动化测试主程序 `test_main.jl` 以及对应的测试算例集(位于 `testdata` 文件夹下)。
### 1. 环境与依赖安装
请确保您的电脑上已经安装了 [Julia](https://julialang.org/downloads/) (建议版本 v1.8 及以上)。
请按照以下步骤配置独立环境:
1. 解压收到的测试压缩包,进入该文件夹(即包含 `test_main.jl` 以及 `src/` 源码的根目录)。
2. 在该文件夹下打开命令行(或终端),输入 `julia` 进入交互模式。
3. 按下 `]` 键进入 Pkg 包管理模式(提示符会变为 `pkg>`)。
4. 依次执行以下命令:
```julia
# 激活当前目录的独立环境
pkg> activate .
# 实例化安装原项目自带的依赖
pkg> instantiate
# 安装本次测试脚本额外需要的依赖包
pkg> add JuMP HiGHS GZip
pkg> update GZip
```
5. 按下 `Backspace` (退格键) 退出 Pkg 模式,回到 `julia>` 提示符,或直接关闭窗口。
### 2. 算例配置 (CASES 选择)
`test_main.jl` 的顶部定义了一个 `CASES` 数组,列出了需要进行对比测试的数据集。
如果您想缩短测试时间,可以打开 `test_main.jl`,利用 `#` 号注释掉暂不需要测试的算例:
```julia
CASES =[
("testdata/case2383wp/2017-07-28.json.gz", "case2383wp"),
# ("testdata/case2736sp/2017-07-21.json.gz", "case2736sp"), # 使用 # 号注释即可跳过该算例
]
```
### 3. 运行测试
在命令行中(确保路径为当前文件夹),直接运行:
```bash
julia test_main.jl
```
测试脚本将自动针对每个算例依序运行以下三种情况:
* **Base**: 基础模型(未添加启停轨迹的原版逻辑)
* **v1 (Part 1)**: 添加 Startup / Shutdown 启停曲线的模型
* **v2 (Part 2)**: 在 v1 基础上筛选并修正 Minimum uptime 的模型
### 4. 测试输出结果说明
测试完毕后,您可以在 `./test/` 目录下找到所有独立生成的算例结果文件夹(例如 `./test/case2383wp-2017-07-28/`)。
每个文件夹内包含:
1. **中间 JSON 数据集**
* `*-part1.json`:动态添加了 Startup/Shutdown curve 的实例。
* `*-part2.json`:在 part1 基础上修正了 Minimum uptime 的实例。
2. **`*_summary.csv` (宏观指标汇总)**:
* 记录了 `Base`, `v1`, `v2` 模型的总目标函数值 (objective)、求解耗时、MIP Gap 以及与 Base 模型的差异比例。
3. **`*_combined.csv` (微观机组出力与状态核对表)**:
* 细致记录了每一个时段 $t$ 下,各个机组的实际出力对比 (`p_base`, `p_v1`, `p_v2`)。
* 提供物理状态标签 (`Startup_traj`, `Shutdown_traj`, `Normal`) 以便排查。
* 输出该时段机组的爬坡与上下界限制 (`ub`, `lb`) 以及机组核心参数校验。
---
## Original 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)
*(Modifications related to `xxx2005` power trajectories and minimum uptime preprocessing added by xpw).*
## License
```text
UnitCommitment.jl: A Julia/JuMP Optimization Package for Security-Constrained Unit Commitment
Copyright © 2020-2024, 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:
1. Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of
conditions and the following disclaimer in the documentation and/or other materials provided
with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to
endorse or promote products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
```