modified the tests for LMP and AELMP

pull/27/head
Jun He 3 years ago
parent 415732f0ec
commit bc3aee38f8

@ -3,6 +3,7 @@ Cbc = "9961bab8-2fa3-5c5a-9d89-47fab24efd76"
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
GZip = "92fee26a-97fe-5a0c-ad85-20a5f3185b63"
HiGHS = "87dc4568-4c63-4d18-b0c0-bb2238e4078b"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1,39 @@
# UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
# Released under the modified BSD license. See COPYING.md for more details.
using UnitCommitment, Cbc, HiGHS, JuMP
import UnitCommitment:
AELMP
@testset "aelmp" begin
path = "$FIXTURES/aelmp_simple.json.gz"
# model has to be solved first
instance = UnitCommitment.read(path)
model = UnitCommitment.build_model(
instance=instance,
optimizer=Cbc.Optimizer,
variable_names = true,
)
JuMP.set_silent(model)
UnitCommitment.optimize!(model)
# policy 1: allow offlines; consider startups
aelmp_1 = UnitCommitment.compute_lmp(
model,
AELMP.Method(),
optimizer=HiGHS.Optimizer
)
@test aelmp_1["B1", 1] 231.7 atol = 0.1
# policy 2: do not allow offlines; but consider startups
aelmp_2 = UnitCommitment.compute_lmp(
model,
AELMP.Method(
allow_offline_participation=false,
consider_startup_costs=true
),
optimizer=HiGHS.Optimizer
)
@test aelmp_2["B1", 1] 274.3 atol = 0.1
end

@ -0,0 +1,54 @@
# UnitCommitment.jl: Optimization Package for Security-Constrained Unit Commitment
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
# Released under the modified BSD license. See COPYING.md for more details.
using UnitCommitment, Cbc, HiGHS, JuMP
import UnitCommitment:
LMP
function solve_lmp_testcase(path::String)
instance = UnitCommitment.read(path)
model = UnitCommitment.build_model(
instance = instance,
optimizer = Cbc.Optimizer,
variable_names = true,
)
# set silent, solve the UC
JuMP.set_silent(model)
UnitCommitment.optimize!(model)
# get the lmp
lmp = UnitCommitment.compute_lmp(
model,
LMP.Method(),
optimizer=HiGHS.Optimizer,
)
return lmp
end
@testset "lmp" begin
# instance 1
path = "$FIXTURES/lmp_simple_test_1.json.gz"
lmp = solve_lmp_testcase(path)
@test lmp["A", 1] == 50.0
@test lmp["B", 1] == 50.0
# instance 2
path = "$FIXTURES/lmp_simple_test_2.json.gz"
lmp = solve_lmp_testcase(path)
@test lmp["A", 1] == 50.0
@test lmp["B", 1] == 60.0
# instance 3
path = "$FIXTURES/lmp_simple_test_3.json.gz"
lmp = solve_lmp_testcase(path)
@test lmp["A", 1] == 50.0
@test lmp["B", 1] == 70.0
@test lmp["C", 1] == 100.0
# instance 4
path = "$FIXTURES/lmp_simple_test_4.json.gz"
lmp = solve_lmp_testcase(path)
@test lmp["A", 1] == 50.0
@test lmp["B", 1] == 70.0
@test lmp["C", 1] == 90.0
end

@ -39,4 +39,8 @@ FIXTURES = "$(@__DIR__)/fixtures"
@testset "validation" begin
include("validation/repair_test.jl")
end
@testset "lmp" begin
include("lmp/lmp_test.jl")
include("lmp/aelmp_test.jl")
end
end

Loading…
Cancel
Save