mirror of
https://github.com/ANL-CEEESA/UnitCommitment.jl.git
synced 2025-12-07 00:38:51 -06:00
Compare commits
3 Commits
feature/ra
...
feature/sy
| Author | SHA1 | Date | |
|---|---|---|---|
| 6c566e0e79 | |||
| 5c3f7b15d3 | |||
| 7c907a6eb5 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -18,3 +18,4 @@ TODO.md
|
|||||||
docs/_build
|
docs/_build
|
||||||
.vscode
|
.vscode
|
||||||
Manifest.toml
|
Manifest.toml
|
||||||
|
*/Manifest.toml
|
||||||
|
|||||||
15
Makefile
15
Makefile
@@ -5,23 +5,20 @@
|
|||||||
JULIA := julia --color=yes --project=@.
|
JULIA := julia --color=yes --project=@.
|
||||||
VERSION := 0.2
|
VERSION := 0.2
|
||||||
|
|
||||||
build/sysimage.so: src/utils/sysimage.jl Project.toml Manifest.toml
|
build/sysimage.so: src/utils/sysimage.jl Project.toml
|
||||||
mkdir -p build
|
julia --project=. -e "using Pkg; Pkg.instantiate()"
|
||||||
mkdir -p benchmark/results/test
|
julia --project=test -e "using Pkg; Pkg.instantiate()"
|
||||||
cd benchmark; $(JULIA) --trace-compile=../build/precompile.jl benchmark.jl test/case14
|
$(JULIA) src/utils/sysimage.jl test/runtests.jl
|
||||||
$(JULIA) src/utils/sysimage.jl
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf build/*
|
rm -rfv build
|
||||||
|
|
||||||
docs:
|
docs:
|
||||||
cd docs; make clean; make dirhtml
|
cd docs; make clean; make dirhtml
|
||||||
rsync -avP --delete-after docs/_build/dirhtml/ ../docs/$(VERSION)/
|
rsync -avP --delete-after docs/_build/dirhtml/ ../docs/$(VERSION)/
|
||||||
|
|
||||||
test: build/sysimage.so
|
test: build/sysimage.so
|
||||||
@echo Running tests...
|
$(JULIA) --sysimage build/sysimage.so test/runtests.jl
|
||||||
$(JULIA) --sysimage build/sysimage.so -e 'using Pkg; Pkg.test("UnitCommitment")' | tee build/test.log
|
|
||||||
|
|
||||||
|
|
||||||
format:
|
format:
|
||||||
julia -e 'using JuliaFormatter; format(["src", "test", "benchmark"], verbose=true);'
|
julia -e 'using JuliaFormatter; format(["src", "test", "benchmark"], verbose=true);'
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
|
|||||||
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
|
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
|
||||||
|
|
||||||
[compat]
|
[compat]
|
||||||
Cbc = "0.7"
|
|
||||||
DataStructures = "0.18"
|
DataStructures = "0.18"
|
||||||
Distributions = "0.25"
|
Distributions = "0.25"
|
||||||
GZip = "0.5"
|
GZip = "0.5"
|
||||||
@@ -28,11 +27,3 @@ JuMP = "0.21"
|
|||||||
MathOptInterface = "0.9"
|
MathOptInterface = "0.9"
|
||||||
PackageCompiler = "1"
|
PackageCompiler = "1"
|
||||||
julia = "1"
|
julia = "1"
|
||||||
|
|
||||||
[extras]
|
|
||||||
Cbc = "9961bab8-2fa3-5c5a-9d89-47fab24efd76"
|
|
||||||
Gurobi = "2e9cd046-0924-5485-92f1-d5272153d98b"
|
|
||||||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
|
|
||||||
|
|
||||||
[targets]
|
|
||||||
test = ["Cbc", "Test", "Gurobi"]
|
|
||||||
|
|||||||
@@ -266,15 +266,20 @@ function _from_json(json; repair = true)
|
|||||||
end
|
end
|
||||||
|
|
||||||
instance = UnitCommitmentInstance(
|
instance = UnitCommitmentInstance(
|
||||||
T,
|
buses_by_name = Dict(b.name => b for b in buses),
|
||||||
power_balance_penalty,
|
buses = buses,
|
||||||
shortfall_penalty,
|
contingencies_by_name = Dict(c.name => c for c in contingencies),
|
||||||
units,
|
contingencies = contingencies,
|
||||||
buses,
|
lines_by_name = Dict(l.name => l for l in lines),
|
||||||
lines,
|
lines = lines,
|
||||||
reserves,
|
power_balance_penalty = power_balance_penalty,
|
||||||
contingencies,
|
price_sensitive_loads_by_name = Dict(ps.name => ps for ps in loads),
|
||||||
loads,
|
price_sensitive_loads = loads,
|
||||||
|
reserves = reserves,
|
||||||
|
shortfall_penalty = shortfall_penalty,
|
||||||
|
time = T,
|
||||||
|
units_by_name = Dict(g.name => g for g in units),
|
||||||
|
units = units,
|
||||||
)
|
)
|
||||||
if repair
|
if repair
|
||||||
UnitCommitment.repair!(instance)
|
UnitCommitment.repair!(instance)
|
||||||
|
|||||||
@@ -69,17 +69,21 @@ mutable struct PriceSensitiveLoad
|
|||||||
revenue::Vector{Float64}
|
revenue::Vector{Float64}
|
||||||
end
|
end
|
||||||
|
|
||||||
mutable struct UnitCommitmentInstance
|
Base.@kwdef mutable struct UnitCommitmentInstance
|
||||||
time::Int
|
buses_by_name::Dict{AbstractString,Bus}
|
||||||
power_balance_penalty::Vector{Float64}
|
|
||||||
"Penalty for failing to meet reserve requirement."
|
|
||||||
shortfall_penalty::Vector{Float64}
|
|
||||||
units::Vector{Unit}
|
|
||||||
buses::Vector{Bus}
|
buses::Vector{Bus}
|
||||||
lines::Vector{TransmissionLine}
|
contingencies_by_name::Dict{AbstractString,Contingency}
|
||||||
reserves::Reserves
|
|
||||||
contingencies::Vector{Contingency}
|
contingencies::Vector{Contingency}
|
||||||
|
lines_by_name::Dict{AbstractString,TransmissionLine}
|
||||||
|
lines::Vector{TransmissionLine}
|
||||||
|
power_balance_penalty::Vector{Float64}
|
||||||
|
price_sensitive_loads_by_name::Dict{AbstractString,PriceSensitiveLoad}
|
||||||
price_sensitive_loads::Vector{PriceSensitiveLoad}
|
price_sensitive_loads::Vector{PriceSensitiveLoad}
|
||||||
|
reserves::Reserves
|
||||||
|
shortfall_penalty::Vector{Float64}
|
||||||
|
time::Int
|
||||||
|
units_by_name::Dict{AbstractString,Unit}
|
||||||
|
units::Vector{Unit}
|
||||||
end
|
end
|
||||||
|
|
||||||
function Base.show(io::IO, instance::UnitCommitmentInstance)
|
function Base.show(io::IO, instance::UnitCommitmentInstance)
|
||||||
|
|||||||
@@ -3,26 +3,31 @@
|
|||||||
# Released under the modified BSD license. See COPYING.md for more details.
|
# Released under the modified BSD license. See COPYING.md for more details.
|
||||||
|
|
||||||
using PackageCompiler
|
using PackageCompiler
|
||||||
|
using TOML
|
||||||
|
using Logging
|
||||||
|
|
||||||
using DataStructures
|
Logging.disable_logging(Logging.Info)
|
||||||
using Distributions
|
mkpath("build")
|
||||||
using JSON
|
|
||||||
using JuMP
|
|
||||||
using MathOptInterface
|
|
||||||
using SparseArrays
|
|
||||||
|
|
||||||
pkg = [
|
println("Generating precompilation statements...")
|
||||||
:DataStructures,
|
run(`julia --project=. --trace-compile=build/precompile.jl $(ARGS)`)
|
||||||
:Distributions,
|
|
||||||
:JSON,
|
|
||||||
:JuMP,
|
|
||||||
:MathOptInterface,
|
|
||||||
:SparseArrays,
|
|
||||||
]
|
|
||||||
|
|
||||||
@info "Building system image..."
|
println("Finding dependencies...")
|
||||||
|
project = TOML.parsefile("Project.toml")
|
||||||
|
manifest = TOML.parsefile("Manifest.toml")
|
||||||
|
deps = Symbol[]
|
||||||
|
for dep in keys(project["deps"])
|
||||||
|
if "path" in keys(manifest[dep][1])
|
||||||
|
println(" - $(dep) [skip]")
|
||||||
|
else
|
||||||
|
println(" - $(dep)")
|
||||||
|
push!(deps, Symbol(dep))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
println("Building system image...")
|
||||||
create_sysimage(
|
create_sysimage(
|
||||||
pkg,
|
deps,
|
||||||
precompile_statements_file = "build/precompile.jl",
|
precompile_statements_file = "build/precompile.jl",
|
||||||
sysimage_path = "build/sysimage.so",
|
sysimage_path = "build/sysimage.so",
|
||||||
)
|
)
|
||||||
|
|||||||
26
test/Project.toml
Normal file
26
test/Project.toml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
[deps]
|
||||||
|
Cbc = "9961bab8-2fa3-5c5a-9d89-47fab24efd76"
|
||||||
|
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
|
||||||
|
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
|
||||||
|
GZip = "92fee26a-97fe-5a0c-ad85-20a5f3185b63"
|
||||||
|
Gurobi = "2e9cd046-0924-5485-92f1-d5272153d98b"
|
||||||
|
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
|
||||||
|
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
|
||||||
|
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
|
||||||
|
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
|
||||||
|
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
|
||||||
|
PackageCompiler = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d"
|
||||||
|
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
|
||||||
|
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
|
||||||
|
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
|
||||||
|
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
|
||||||
|
|
||||||
|
[compat]
|
||||||
|
DataStructures = "0.18"
|
||||||
|
Distributions = "0.25"
|
||||||
|
GZip = "0.5"
|
||||||
|
JSON = "0.21"
|
||||||
|
JuMP = "0.21"
|
||||||
|
MathOptInterface = "0.9"
|
||||||
|
PackageCompiler = "1"
|
||||||
|
julia = "1"
|
||||||
@@ -4,9 +4,12 @@
|
|||||||
|
|
||||||
using UnitCommitment
|
using UnitCommitment
|
||||||
|
|
||||||
|
basedir = @__DIR__
|
||||||
|
|
||||||
@testset "read_egret_solution" begin
|
@testset "read_egret_solution" begin
|
||||||
solution =
|
solution = UnitCommitment.read_egret_solution(
|
||||||
UnitCommitment.read_egret_solution("fixtures/egret_output.json.gz")
|
"$basedir/../fixtures/egret_output.json.gz",
|
||||||
|
)
|
||||||
for attr in ["Is on", "Production (MW)", "Production cost (\$)"]
|
for attr in ["Is on", "Production (MW)", "Production cost (\$)"]
|
||||||
@test attr in keys(solution)
|
@test attr in keys(solution)
|
||||||
@test "115_STEAM_1" in keys(solution[attr])
|
@test "115_STEAM_1" in keys(solution[attr])
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ using UnitCommitment, LinearAlgebra, Cbc, JuMP, JSON, GZip
|
|||||||
@test instance.lines[5].normal_flow_limit == [1e8 for t in 1:4]
|
@test instance.lines[5].normal_flow_limit == [1e8 for t in 1:4]
|
||||||
@test instance.lines[5].emergency_flow_limit == [1e8 for t in 1:4]
|
@test instance.lines[5].emergency_flow_limit == [1e8 for t in 1:4]
|
||||||
@test instance.lines[5].flow_limit_penalty == [5e3 for t in 1:4]
|
@test instance.lines[5].flow_limit_penalty == [5e3 for t in 1:4]
|
||||||
|
@test instance.lines_by_name["l5"].name == "l5"
|
||||||
|
|
||||||
@test instance.lines[1].name == "l1"
|
@test instance.lines[1].name == "l1"
|
||||||
@test instance.lines[1].source.name == "b1"
|
@test instance.lines[1].source.name == "b1"
|
||||||
@@ -34,6 +35,7 @@ using UnitCommitment, LinearAlgebra, Cbc, JuMP, JSON, GZip
|
|||||||
|
|
||||||
@test instance.buses[9].name == "b9"
|
@test instance.buses[9].name == "b9"
|
||||||
@test instance.buses[9].load == [35.36638, 33.25495, 31.67138, 31.14353]
|
@test instance.buses[9].load == [35.36638, 33.25495, 31.67138, 31.14353]
|
||||||
|
@test instance.buses_by_name["b9"].name == "b9"
|
||||||
|
|
||||||
unit = instance.units[1]
|
unit = instance.units[1]
|
||||||
@test unit.name == "g1"
|
@test unit.name == "g1"
|
||||||
@@ -62,6 +64,7 @@ using UnitCommitment, LinearAlgebra, Cbc, JuMP, JSON, GZip
|
|||||||
@test unit.startup_categories[1].cost == 1000.0
|
@test unit.startup_categories[1].cost == 1000.0
|
||||||
@test unit.startup_categories[2].cost == 1500.0
|
@test unit.startup_categories[2].cost == 1500.0
|
||||||
@test unit.startup_categories[3].cost == 2000.0
|
@test unit.startup_categories[3].cost == 2000.0
|
||||||
|
@test instance.units_by_name["g1"].name == "g1"
|
||||||
|
|
||||||
unit = instance.units[2]
|
unit = instance.units[2]
|
||||||
@test unit.name == "g2"
|
@test unit.name == "g2"
|
||||||
@@ -92,12 +95,15 @@ using UnitCommitment, LinearAlgebra, Cbc, JuMP, JSON, GZip
|
|||||||
|
|
||||||
@test instance.contingencies[1].lines == [instance.lines[1]]
|
@test instance.contingencies[1].lines == [instance.lines[1]]
|
||||||
@test instance.contingencies[1].units == []
|
@test instance.contingencies[1].units == []
|
||||||
|
@test instance.contingencies[1].name == "c1"
|
||||||
|
@test instance.contingencies_by_name["c1"].name == "c1"
|
||||||
|
|
||||||
load = instance.price_sensitive_loads[1]
|
load = instance.price_sensitive_loads[1]
|
||||||
@test load.name == "ps1"
|
@test load.name == "ps1"
|
||||||
@test load.bus.name == "b3"
|
@test load.bus.name == "b3"
|
||||||
@test load.revenue == [100.0 for t in 1:4]
|
@test load.revenue == [100.0 for t in 1:4]
|
||||||
@test load.demand == [50.0 for t in 1:4]
|
@test load.demand == [50.0 for t in 1:4]
|
||||||
|
@test instance.price_sensitive_loads_by_name["ps1"].name == "ps1"
|
||||||
end
|
end
|
||||||
|
|
||||||
@testset "read_benchmark sub-hourly" begin
|
@testset "read_benchmark sub-hourly" begin
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
using Test
|
using Test
|
||||||
using UnitCommitment
|
using UnitCommitment
|
||||||
|
|
||||||
|
push!(Base.LOAD_PATH, @__DIR__)
|
||||||
UnitCommitment._setup_logger()
|
UnitCommitment._setup_logger()
|
||||||
|
|
||||||
const ENABLE_LARGE_TESTS = ("UCJL_LARGE_TESTS" in keys(ENV))
|
const ENABLE_LARGE_TESTS = ("UCJL_LARGE_TESTS" in keys(ENV))
|
||||||
|
|||||||
@@ -4,9 +4,12 @@
|
|||||||
|
|
||||||
using UnitCommitment, Cbc, JuMP
|
using UnitCommitment, Cbc, JuMP
|
||||||
|
|
||||||
|
basedir = @__DIR__
|
||||||
|
|
||||||
@testset "generate_initial_conditions!" begin
|
@testset "generate_initial_conditions!" begin
|
||||||
# Load instance
|
# Load instance
|
||||||
instance = UnitCommitment.read("$(pwd())/fixtures/case118-initcond.json.gz")
|
instance =
|
||||||
|
UnitCommitment.read("$basedir/../fixtures/case118-initcond.json.gz")
|
||||||
optimizer = optimizer_with_attributes(Cbc.Optimizer, "logLevel" => 0)
|
optimizer = optimizer_with_attributes(Cbc.Optimizer, "logLevel" => 0)
|
||||||
|
|
||||||
# All units should have unknown initial conditions
|
# All units should have unknown initial conditions
|
||||||
|
|||||||
@@ -4,9 +4,11 @@
|
|||||||
|
|
||||||
using UnitCommitment, JSON, GZip, DataStructures
|
using UnitCommitment, JSON, GZip, DataStructures
|
||||||
|
|
||||||
|
basedir = @__DIR__
|
||||||
|
|
||||||
function parse_case14()
|
function parse_case14()
|
||||||
return JSON.parse(
|
return JSON.parse(
|
||||||
GZip.gzopen("../instances/test/case14.json.gz"),
|
GZip.gzopen("$basedir/../../instances/test/case14.json.gz"),
|
||||||
dicttype = () -> DefaultOrderedDict(nothing),
|
dicttype = () -> DefaultOrderedDict(nothing),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user