new formatting

This commit is contained in:
oyurdakul
2022-04-01 15:17:14 +02:00
parent 8988b00b07
commit febb4f1aad
45 changed files with 274 additions and 487 deletions

View File

@@ -7,9 +7,8 @@ using UnitCommitment
basedir = @__DIR__
@testset "read_egret_solution" begin
solution = UnitCommitment.read_egret_solution(
"$basedir/../fixtures/egret_output.json.gz",
)
solution =
UnitCommitment.read_egret_solution("$basedir/../fixtures/egret_output.json.gz")
for attr in ["Is on", "Production (MW)", "Production cost (\$)"]
@test attr in keys(solution)
@test "115_STEAM_1" in keys(solution[attr])

View File

@@ -19,9 +19,9 @@ using UnitCommitment, LinearAlgebra, Cbc, JuMP, JSON, GZip
@test instance.lines[5].target.name == "b5"
@test instance.lines[5].reactance 0.17388
@test instance.lines[5].susceptance 10.037550333
@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].flow_limit_penalty == [5e3 for t in 1:4]
@test instance.lines[5].normal_flow_limit == [1e8 for t = 1:4]
@test instance.lines[5].emergency_flow_limit == [1e8 for t = 1:4]
@test instance.lines[5].flow_limit_penalty == [5e3 for t = 1:4]
@test instance.lines_by_name["l5"].name == "l5"
@test instance.lines[1].name == "l1"
@@ -29,9 +29,9 @@ using UnitCommitment, LinearAlgebra, Cbc, JuMP, JSON, GZip
@test instance.lines[1].target.name == "b2"
@test instance.lines[1].reactance 0.059170
@test instance.lines[1].susceptance 29.496860773945
@test instance.lines[1].normal_flow_limit == [300.0 for t in 1:4]
@test instance.lines[1].emergency_flow_limit == [400.0 for t in 1:4]
@test instance.lines[1].flow_limit_penalty == [1e3 for t in 1:4]
@test instance.lines[1].normal_flow_limit == [300.0 for t = 1:4]
@test instance.lines[1].emergency_flow_limit == [400.0 for t = 1:4]
@test instance.lines[1].flow_limit_penalty == [1e3 for t = 1:4]
@test instance.buses[9].name == "b9"
@test instance.buses[9].load == [35.36638, 33.25495, 31.67138, 31.14353]
@@ -44,12 +44,12 @@ using UnitCommitment, LinearAlgebra, Cbc, JuMP, JSON, GZip
@test unit.ramp_down_limit == 1e6
@test unit.startup_limit == 1e6
@test unit.shutdown_limit == 1e6
@test unit.must_run == [false for t in 1:4]
@test unit.min_power_cost == [1400.0 for t in 1:4]
@test unit.must_run == [false for t = 1:4]
@test unit.min_power_cost == [1400.0 for t = 1:4]
@test unit.min_uptime == 1
@test unit.min_downtime == 1
@test unit.provides_spinning_reserves == [true for t in 1:4]
for t in 1:1
@test unit.provides_spinning_reserves == [true for t = 1:4]
for t = 1:1
@test unit.cost_segments[1].mw[t] == 10.0
@test unit.cost_segments[2].mw[t] == 20.0
@test unit.cost_segments[3].mw[t] == 5.0
@@ -68,7 +68,7 @@ using UnitCommitment, LinearAlgebra, Cbc, JuMP, JSON, GZip
unit = instance.units[2]
@test unit.name == "g2"
@test unit.must_run == [false for t in 1:4]
@test unit.must_run == [false for t = 1:4]
unit = instance.units[3]
@test unit.name == "g3"
@@ -77,12 +77,12 @@ using UnitCommitment, LinearAlgebra, Cbc, JuMP, JSON, GZip
@test unit.ramp_down_limit == 70.0
@test unit.startup_limit == 70.0
@test unit.shutdown_limit == 70.0
@test unit.must_run == [true for t in 1:4]
@test unit.min_power_cost == [0.0 for t in 1:4]
@test unit.must_run == [true for t = 1:4]
@test unit.min_power_cost == [0.0 for t = 1:4]
@test unit.min_uptime == 1
@test unit.min_downtime == 1
@test unit.provides_spinning_reserves == [true for t in 1:4]
for t in 1:4
@test unit.provides_spinning_reserves == [true for t = 1:4]
for t = 1:4
@test unit.cost_segments[1].mw[t] 33
@test unit.cost_segments[2].mw[t] 33
@test unit.cost_segments[3].mw[t] 34
@@ -101,8 +101,8 @@ using UnitCommitment, LinearAlgebra, Cbc, JuMP, JSON, GZip
load = instance.price_sensitive_loads[1]
@test load.name == "ps1"
@test load.bus.name == "b3"
@test load.revenue == [100.0 for t in 1:4]
@test load.demand == [50.0 for t in 1:4]
@test load.revenue == [100.0 for t = 1:4]
@test load.demand == [50.0 for t = 1:4]
@test instance.price_sensitive_loads_by_name["ps1"].name == "ps1"
end

View File

@@ -23,6 +23,7 @@ function _small_test(formulation::Formulation)::Nothing
instances = ["matpower/case118/2017-02-01", "test/case14"]
for instance in instances
# Should not crash
@show "$(instance)"
UnitCommitment.build_model(
instance = UnitCommitment.read_benchmark(instance),
formulation = formulation,
@@ -58,17 +59,26 @@ function _test(formulation::Formulation)::Nothing
end
@testset "formulations" begin
@show "testset formulations"
_test(Formulation())
@show "ArrCon2000 ramping"
_test(Formulation(ramping = ArrCon2000.Ramping()))
# _test(Formulation(ramping = DamKucRajAta2016.Ramping()))
@show "MorLatRam2013 ramping"
_test(
Formulation(
ramping = MorLatRam2013.Ramping(),
startup_costs = MorLatRam2013.StartupCosts(),
),
)
@show "PanGua2016 ramping"
_test(Formulation(ramping = PanGua2016.Ramping()))
@show "Gar1962 PwlCosts"
_test(Formulation(pwl_costs = Gar1962.PwlCosts()))
@show "CarArr2006 PwlCosts"
_test(Formulation(pwl_costs = CarArr2006.PwlCosts()))
@show "KnuOstWat2018 PwlCosts"
_test(Formulation(pwl_costs = KnuOstWat2018.PwlCosts()))
@show "formulations completed"
end

View File

@@ -11,6 +11,7 @@ UnitCommitment._setup_logger()
const ENABLE_LARGE_TESTS = ("UCJL_LARGE_TESTS" in keys(ENV))
@testset "UnitCommitment" begin
@show "running runtests.jl"
include("usage.jl")
@testset "import" begin
include("import/egret_test.jl")
@@ -27,6 +28,7 @@ const ENABLE_LARGE_TESTS = ("UCJL_LARGE_TESTS" in keys(ENV))
include("solution/methods/XavQiuWanThi19/sensitivity_test.jl")
end
@testset "transform" begin
@show "beginning transform"
include("transform/initcond_test.jl")
include("transform/slice_test.jl")
@testset "randomize" begin

View File

@@ -7,7 +7,7 @@ import UnitCommitment: _Violation, _offer, _query
@testset "find_violations" begin
instance = UnitCommitment.read_benchmark("test/case14")
for line in instance.lines, t in 1:instance.time
for line in instance.lines, t = 1:instance.time
line.normal_flow_limit[t] = 1.0
line.emergency_flow_limit[t] = 1.0
end
@@ -20,8 +20,8 @@ import UnitCommitment: _Violation, _offer, _query
buses = instance.buses,
isf = isf,
)
inj = [1000.0 for b in 1:13, t in 1:instance.time]
overflow = [0.0 for l in instance.lines, t in 1:instance.time]
inj = [1000.0 for b = 1:13, t = 1:instance.time]
overflow = [0.0 for l in instance.lines, t = 1:instance.time]
violations = UnitCommitment._find_violations(
instance = instance,
net_injections = inj,

View File

@@ -8,8 +8,7 @@ basedir = @__DIR__
@testset "generate_initial_conditions!" begin
# Load instance
instance =
UnitCommitment.read("$basedir/../fixtures/case118-initcond.json.gz")
instance = UnitCommitment.read("$basedir/../fixtures/case118-initcond.json.gz")
optimizer = optimizer_with_attributes(Cbc.Optimizer, "logLevel" => 0)
# All units should have unknown initial conditions

View File

@@ -28,10 +28,7 @@ test_approx(x, y) = @test isapprox(x, y, atol = 1e-3)
test_approx(bus.load[1] / prev_system_load[1], 0.012)
Random.seed!(42)
randomize!(
instance,
XavQiuAhm2021.Randomization(randomize_load_profile = false),
)
randomize!(instance, XavQiuAhm2021.Randomization(randomize_load_profile = false))
# Check randomized costs
test_approx(unit.min_power_cost[1], 831.977)

View File

@@ -5,6 +5,7 @@
using UnitCommitment, LinearAlgebra, Cbc, JuMP, JSON, GZip
@testset "slice" begin
@show "beginning slice"
instance = UnitCommitment.read_benchmark("test/case14")
modified = UnitCommitment.slice(instance, 1:2)
@@ -35,7 +36,8 @@ using UnitCommitment, LinearAlgebra, Cbc, JuMP, JSON, GZip
@test length(ps.demand) == 2
@test length(ps.revenue) == 2
end
@show "beginning building model under slice"
@show instance.reserves
# Should be able to build model without errors
optimizer = optimizer_with_attributes(Cbc.Optimizer, "logLevel" => 0)
model = UnitCommitment.build_model(

View File

@@ -6,7 +6,7 @@ using UnitCommitment, LinearAlgebra, Cbc, JuMP, JSON
@testset "build_model" begin
instance = UnitCommitment.read_benchmark("test/case14")
for line in instance.lines, t in 1:4
for line in instance.lines, t = 1:4
line.normal_flow_limit[t] = 10.0
end
optimizer = optimizer_with_attributes(Cbc.Optimizer, "logLevel" => 0)