mirror of
https://github.com/ANL-CEEESA/UnitCommitment.jl.git
synced 2025-12-09 01:28:51 -06:00
storage units
This commit is contained in:
@@ -102,5 +102,28 @@ function transform_randomize_XavQiuAhm2021_test()
|
||||
test_approx(pu1.cost[1], 98.039)
|
||||
test_approx(pu2.cost[1], 48.385)
|
||||
end
|
||||
|
||||
@testset "storage unit cost" begin
|
||||
sc = UnitCommitment.read(
|
||||
fixture("case14-storage.json.gz"),
|
||||
).scenarios[1]
|
||||
# Check original costs
|
||||
su1 = sc.storage_units[1]
|
||||
su3 = sc.storage_units[3]
|
||||
test_approx(su1.charge_cost[4], 2.0)
|
||||
test_approx(su1.discharge_cost[1], 2.5)
|
||||
test_approx(su3.charge_cost[2], 2.1)
|
||||
test_approx(su3.discharge_cost[3], 1.2)
|
||||
randomize!(
|
||||
sc,
|
||||
XavQiuAhm2021.Randomization(randomize_load_profile = false),
|
||||
rng = MersenneTwister(42),
|
||||
)
|
||||
# Check randomized costs
|
||||
test_approx(su1.charge_cost[4], 1.961)
|
||||
test_approx(su1.discharge_cost[1], 2.451)
|
||||
test_approx(su3.charge_cost[2], 2.196)
|
||||
test_approx(su3.discharge_cost[3], 1.255)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -65,4 +65,34 @@ function transform_slice_test()
|
||||
variable_names = true,
|
||||
)
|
||||
end
|
||||
|
||||
@testset "slice storage units" begin
|
||||
instance = UnitCommitment.read(fixture("case14-storage.json.gz"))
|
||||
modified = UnitCommitment.slice(instance, 2:4)
|
||||
sc = modified.scenarios[1]
|
||||
|
||||
# Should update all time-dependent fields
|
||||
for su in sc.storage_units
|
||||
@test length(su.min_level) == 3
|
||||
@test length(su.max_level) == 3
|
||||
@test length(su.simultaneous_charge_and_discharge) == 3
|
||||
@test length(su.charge_cost) == 3
|
||||
@test length(su.discharge_cost) == 3
|
||||
@test length(su.charge_efficiency) == 3
|
||||
@test length(su.discharge_efficiency) == 3
|
||||
@test length(su.loss_factor) == 3
|
||||
@test length(su.min_charge_rate) == 3
|
||||
@test length(su.max_charge_rate) == 3
|
||||
@test length(su.min_discharge_rate) == 3
|
||||
@test length(su.max_discharge_rate) == 3
|
||||
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
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user