added profiled units in slice

pull/28/head
Jun He 2 years ago
parent 33f8ec26d5
commit 316d0bdf5a

@ -39,6 +39,11 @@ function slice(
s.cost = s.cost[range] s.cost = s.cost[range]
end end
end end
for pu in sc.profiled_units
pu.max_power = pu.max_power[range]
pu.min_power = pu.min_power[range]
pu.cost = pu.cost[range]
end
for b in sc.buses for b in sc.buses
b.load = b.load[range] b.load = b.load[range]
end end

@ -44,3 +44,23 @@ using UnitCommitment, LinearAlgebra, Cbc, JuMP, JSON, GZip
variable_names = true, variable_names = true,
) )
end end
@testset "slice profiled units" begin
instance = UnitCommitment.read("$FIXTURES/case14-profiled.json.gz")
modified = UnitCommitment.slice(instance, 1:2)
sc = modified.scenarios[1]
# Should update all time-dependent fields
for pu in sc.profiled_units
@test length(pu.max_power) == 2
@test length(pu.min_power) == 2
end
# Should be able to build model without errors
optimizer = optimizer_with_attributes(Cbc.Optimizer, "logLevel" => 0)
model = UnitCommitment.build_model(
instance = modified,
optimizer = optimizer,
variable_names = true,
)
end

Loading…
Cancel
Save