Compare commits

..

2 Commits

12 changed files with 58 additions and 52 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:

11
.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,11 +32,12 @@ 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
notebooks
docs/src/tutorials/usage.md
docs/src/tutorials/customizing.md
docs/src/tutorials/market.md
docs/src/tutorials/lmp.md
*-off.md

View File

@@ -11,13 +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

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.4.0"
[deps]
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
@@ -30,5 +30,5 @@ JuMP = "1"
MathOptInterface = "1"
MPI = "0.20"
PackageCompiler = "1"
julia = "1.10"
julia = "1"
TimerOutputs = "0.5"

View File

@@ -108,7 +108,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.4)". Zenodo (2024). [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.

View File

@@ -107,7 +107,7 @@ Note that this curve also specifies the production limits. Specifically, the fir
```@raw html
<center>
<img src="../../assets/cost_curve.png" style="max-width: 500px"/>
<img src="../assets/cost_curve.png" style="max-width: 500px"/>
<div><b>Figure 1.</b> Piecewise-linear production cost curve.</div>
<br/>
</center>

View File

@@ -26,59 +26,67 @@ function _enforce_transmission(;
isf::Matrix{Float64},
lodf::Matrix{Float64},
)::Nothing
instance = model[:instance]
limit::Float64 = 0.0
overflow = model[:overflow]
net_injection = model[:net_injection]
lm = violation.monitored_line
lc = violation.outage_line
t = violation.time
eq_flow_ub = _init(model, :eq_flow_ub)
eq_flow_lb = _init(model, :eq_flow_lb)
eq_flow_def = _init(model, :eq_flow_def)
eq_idx = (
sc.name,
lm.name,
lc === nothing ? "Base" : lc.name,
t,
)
if violation.outage_line === nothing
limit = violation.monitored_line.normal_flow_limit[violation.time]
if lc === nothing
limit = lm.normal_flow_limit[t]
@info @sprintf(
" %8.3f MW overflow in %-5s time %3d (pre-contingency, scenario %s)",
violation.amount,
violation.monitored_line.name,
violation.time,
lm.name,
t,
sc.name,
)
else
limit = violation.monitored_line.emergency_flow_limit[violation.time]
limit = lm.emergency_flow_limit[t]
@info @sprintf(
" %8.3f MW overflow in %-5s time %3d (outage: line %s, scenario %s)",
violation.amount,
violation.monitored_line.name,
violation.time,
violation.outage_line.name,
lm.name,
t,
lc.name,
sc.name,
)
end
fm = violation.monitored_line.name
t = violation.time
flow = @variable(model, base_name = "flow[$fm,$t]")
v = overflow[sc.name, lm.name, t]
flow = @variable(model, base_name = "flow[$eq_idx]")
eq_flow_ub[eq_idx] = @constraint(model, flow <= limit + v)
eq_flow_lb[eq_idx] = @constraint(model, -flow <= limit + v)
v = overflow[sc.name, violation.monitored_line.name, violation.time]
@constraint(model, flow <= limit + v)
@constraint(model, -flow <= limit + v)
if violation.outage_line === nothing
@constraint(
if lc === nothing
eq_flow_def[eq_idx] = @constraint(
model,
flow == sum(
net_injection[sc.name, b.name, violation.time] *
isf[violation.monitored_line.offset, b.offset] for
net_injection[sc.name, b.name, t] *
isf[lm.offset, b.offset] for
b in sc.buses if b.offset > 0
)
)
else
@constraint(
eq_flow_def[eq_idx] = @constraint(
model,
flow == sum(
net_injection[sc.name, b.name, violation.time] * (
isf[violation.monitored_line.offset, b.offset] + (
net_injection[sc.name, b.name, t] * (
isf[lm.offset, b.offset] + (
lodf[
violation.monitored_line.offset,
violation.outage_line.offset,
] * isf[violation.outage_line.offset, b.offset]
lm.offset,
lc.offset,
] * isf[lc.offset, b.offset]
)
) for b in sc.buses if b.offset > 0
)

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

@@ -2,7 +2,9 @@
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
# Released under the modified BSD license. See COPYING.md for more details.
function optimize!(model::JuMP.Model, method::XavQiuWanThi2019.Method)::Nothing
using DataStructures
function optimize!(model::JuMP.Model, method::XavQiuWanThi2019.Method)::Dict
if !occursin("Gurobi", JuMP.solver_name(model))
method.two_phase_gap = false
end
@@ -22,6 +24,9 @@ function optimize!(model::JuMP.Model, method::XavQiuWanThi2019.Method)::Nothing
large_gap = true
end
end
stats = Dict(
"violations" => []
)
while true
time_elapsed = time() - initial_time
time_remaining = method.time_limit - time_elapsed
@@ -68,6 +73,7 @@ function optimize!(model::JuMP.Model, method::XavQiuWanThi2019.Method)::Nothing
if violations_found
for (i, v) in enumerate(violations)
append!(stats["violations"], v)
_enforce_transmission(model, v, model[:instance].scenarios[i])
end
else
@@ -80,5 +86,5 @@ function optimize!(model::JuMP.Model, method::XavQiuWanThi2019.Method)::Nothing
end
end
end
return
return stats
end

View File

@@ -3,12 +3,12 @@
# Released under the modified BSD license. See COPYING.md for more details.
"""
optimize!(model::JuMP.Model)::Nothing
optimize!(model::JuMP.Model)::Dict
Solve the given unit commitment model. Unlike `JuMP.optimize!`, this uses more
advanced methods to accelerate the solution process and to enforce transmission
and N-1 security constraints.
"""
function optimize!(model::JuMP.Model)::Nothing
function optimize!(model::JuMP.Model)::Dict
return UnitCommitment.optimize!(model, XavQiuWanThi2019.Method())
end

Binary file not shown.

View File

@@ -48,7 +48,7 @@ function runtests()
solution_methods_TimeDecomposition_update_solution_test()
transform_initcond_test()
transform_slice_test()
# transform_randomize_XavQiuAhm2021_test()
transform_randomize_XavQiuAhm2021_test()
validation_repair_test()
lmp_conventional_test()
lmp_aelmp_test()