Fix all tests

This commit is contained in:
2022-06-20 14:14:37 -05:00
parent bf2dc4ddc4
commit 3282e5bc3a
8 changed files with 38 additions and 26 deletions

View File

@@ -212,7 +212,7 @@ end
function _total_reserves(model, g)::Vector
T = model[:instance].time
reserve = 0.0
reserve = [0.0 for _ in 1:T]
if !isempty(g.reserves)
reserve += [
sum(model[:reserve][r.name, g.name, t] for r in g.reserves) for

View File

@@ -18,15 +18,27 @@ function fix!(model::JuMP.Model, solution::AbstractDict)::Nothing
is_on_value = round(solution["Is on"][g.name][t])
prod_value =
round(solution["Production (MW)"][g.name][t], digits = 5)
reserve_value =
round(solution["Reserve (MW)"][g.name][t], digits = 5)
JuMP.fix(is_on[g.name, t], is_on_value, force = true)
JuMP.fix(
prod_above[g.name, t],
prod_value - is_on_value * g.min_power[t],
force = true,
)
JuMP.fix(reserve[g.name, t], reserve_value, force = true)
end
end
for r in instance.reserves
for g in r.units
for t in 1:T
reserve_value = round(
solution["Reserve (MW)"][r.name][g.name][t],
digits = 5,
)
JuMP.fix(
reserve[r.name, g.name, t],
reserve_value,
force = true,
)
end
end
end
return

View File

@@ -24,13 +24,14 @@ function slice(
modified = deepcopy(instance)
modified.time = length(range)
modified.power_balance_penalty = modified.power_balance_penalty[range]
modified.reserves.spinning = modified.reserves.spinning[range]
for r in modified.reserves
r.amount = r.amount[range]
end
for u in modified.units
u.max_power = u.max_power[range]
u.min_power = u.min_power[range]
u.must_run = u.must_run[range]
u.min_power_cost = u.min_power_cost[range]
u.provides_spinning_reserves = u.provides_spinning_reserves[range]
for s in u.cost_segments
s.mw = s.mw[range]
s.cost = s.cost[range]

View File

@@ -40,15 +40,15 @@ function validate(
return true
end
function _validate_units(instance, solution; tol = 0.01)
function _validate_units(instance::UnitCommitmentInstance, solution; tol = 0.01)
err_count = 0
for unit in instance.units
production = solution["Production (MW)"][unit.name]
reserve = solution["Reserve (MW)"][unit.name]
reserve = [0.0 for _ in 1:instance.time]
if !isempty(unit.reserves)
reserve += sum(
solution["Reserve 2 (MW)"][r.name][unit.name] for
solution["Reserve (MW)"][r.name][unit.name] for
r in unit.reserves
)
end
@@ -105,13 +105,16 @@ function _validate_units(instance, solution; tol = 0.01)
end
# Verify reserve eligibility
if !unit.provides_spinning_reserves[t] && reserve[t] > tol
@error @sprintf(
"Unit %s is not eligible to provide spinning reserves at time %d",
unit.name,
t
)
err_count += 1
for r in instance.reserves
if unit r.units &&
(unit in keys(solution["Reserve (MW)"][r.name]))
@error @sprintf(
"Unit %s is not eligible to provide reserve %s",
unit.name,
r.name,
)
err_count += 1
end
end
# If unit is on, must produce at least its minimum power