initcond: Apply to instance instead of scenario

This commit is contained in:
2023-07-27 11:49:47 -05:00
parent beaf0b785f
commit d49712f41b
2 changed files with 36 additions and 13 deletions

View File

@@ -2,27 +2,32 @@
# Copyright (C) 2020, UChicago Argonne, LLC. All rights reserved.
# Released under the modified BSD license. See COPYING.md for more details.
using UnitCommitment, Cbc, JuMP
using UnitCommitment, HiGHS, JuMP
function transform_initcond_test()
@testset "generate_initial_conditions!" begin
# Load instance
instance = UnitCommitment.read(fixture("case118-initcond.json.gz"))
optimizer = optimizer_with_attributes(Cbc.Optimizer, "logLevel" => 0)
sc = instance.scenarios[1]
optimizer =
optimizer_with_attributes(HiGHS.Optimizer, MOI.Silent() => true)
# All units should have unknown initial conditions
for g in sc.thermal_units
@test g.initial_power === nothing
@test g.initial_status === nothing
for sc in instance.scenarios
for g in sc.thermal_units
@test g.initial_power === nothing
@test g.initial_status === nothing
end
end
# Generate initial conditions
UnitCommitment.generate_initial_conditions!(sc, optimizer)
UnitCommitment.generate_initial_conditions!(instance, optimizer)
# All units should now have known initial conditions
for g in sc.thermal_units
@test g.initial_power !== nothing
@test g.initial_status !== nothing
for sc in instance.scenarios
for g in sc.thermal_units
@test g.initial_power !== nothing
@test g.initial_status !== nothing
end
end
# TODO: Check that initial conditions are feasible