read and repair scenario

pull/25/head
oyurdakul 3 years ago
parent 481f5a904c
commit ad4a754d63

@ -58,7 +58,7 @@ instance = UnitCommitment.read("/path/to/input.json.gz")
function _repair_scenario_name_and_probability(
scenarios::Vector{UnitCommitmentScenario},
path::Vector{String}
path::Vector{String},
)::Vector{UnitCommitmentScenario}
number_of_scenarios = length(scenarios)
probs = [sc.probability for sc in scenarios]
@ -68,7 +68,9 @@ function _repair_scenario_name_and_probability(
total_weight = sum(probs)
catch e
if isa(e, MethodError)
error("If any of the scenarios is assigned a weight, then all scenarios must be assigned weights.")
error(
"If any of the scenarios is assigned a weight, then all scenarios must be assigned weights.",
)
end
end
else
@ -76,7 +78,8 @@ function _repair_scenario_name_and_probability(
end
for (sc_path, sc) in zip(path, scenarios)
sc.name !== "" || (sc.name = first(split(last(split(sc_path, "/")), ".")))
sc.name !== "" ||
(sc.name = first(split(last(split(sc_path, "/")), ".")))
sc.probability = (sc.probability / total_weight)
end
return scenarios

@ -30,9 +30,7 @@ test_approx(x, y) = @test isapprox(x, y, atol = 1e-3)
randomize!(
sc,
XavQiuAhm2021.Randomization(
randomize_load_profile = false,
),
XavQiuAhm2021.Randomization(randomize_load_profile = false),
rng = MersenneTwister(42),
)

Loading…
Cancel
Save