change the validation of reserves

pull/21/head
oyurdakul 4 years ago
parent 72f659b9ff
commit 0046c4ca2a

@ -321,33 +321,17 @@ function _validate_reserve_and_demand(instance, solution, tol = 0.01)
err_count += 1 err_count += 1
end end
# Verify spinning reserves
reserve =
sum(solution["Reserve (MW)"][g.name][t] for g in instance.units)
reserve_shortfall =
(instance.shortfall_penalty[t] >= 0) ?
solution["Reserve shortfall (MW)"][t] : 0
if reserve + reserve_shortfall < instance.reserves.spinning[t] - tol # Verify flexiramp solutions only if either of the up-flexiramp and
@error @sprintf( # down-flexiramp requirements is not a default array of zeros
"Insufficient spinning reserves at time %d (%.2f + %.2f should be %.2f)", if instance.reserves.upflexiramp != zeros(T) || instance.reserves.dwflexiramp != zeros(T)
t, upflexiramp =
reserve, sum(solution["Up-flexiramp (MW)"][g.name][t] for g in instance.units)
reserve_shortfall,
instance.reserves.spinning[t],
)
err_count += 1
end
upflexiramp = sum(
solution["Up-flexiramp (MW)"][g.name][t] for g in instance.units
)
upflexiramp_shortfall = upflexiramp_shortfall =
(instance.flexiramp_shortfall_penalty[t] >= 0) ? (instance.flexiramp_shortfall_penalty[t] >= 0) ?
solution["Up-flexiramp shortfall (MW)"][t] : 0 solution["Up-flexiramp shortfall (MW)"][t] : 0
if upflexiramp + upflexiramp_shortfall < if upflexiramp + upflexiramp_shortfall < instance.reserves.upflexiramp[t] - tol
instance.reserves.upflexiramp[t] - tol
@error @sprintf( @error @sprintf(
"Insufficient up-flexiramp at time %d (%.2f + %.2f should be %.2f)", "Insufficient up-flexiramp at time %d (%.2f + %.2f should be %.2f)",
t, t,
@ -358,15 +342,13 @@ function _validate_reserve_and_demand(instance, solution, tol = 0.01)
err_count += 1 err_count += 1
end end
dwflexiramp = sum( dwflexiramp =
solution["Down-flexiramp (MW)"][g.name][t] for g in instance.units sum(solution["Down-flexiramp (MW)"][g.name][t] for g in instance.units)
)
dwflexiramp_shortfall = dwflexiramp_shortfall =
(instance.flexiramp_shortfall_penalty[t] >= 0) ? (instance.flexiramp_shortfall_penalty[t] >= 0) ?
solution["Down-flexiramp shortfall (MW)"][t] : 0 solution["Down-flexiramp shortfall (MW)"][t] : 0
if dwflexiramp + dwflexiramp_shortfall < if dwflexiramp + dwflexiramp_shortfall < instance.reserves.dwflexiramp[t] - tol
instance.reserves.dwflexiramp[t] - tol
@error @sprintf( @error @sprintf(
"Insufficient down-flexiramp at time %d (%.2f + %.2f should be %.2f)", "Insufficient down-flexiramp at time %d (%.2f + %.2f should be %.2f)",
t, t,
@ -376,7 +358,27 @@ function _validate_reserve_and_demand(instance, solution, tol = 0.01)
) )
err_count += 1 err_count += 1
end end
# Verify spinning reserve solutions only if both up-flexiramp and
# down-flexiramp requirements are arrays of zeros.
else
reserve =
sum(solution["Reserve (MW)"][g.name][t] for g in instance.units)
reserve_shortfall =
(instance.shortfall_penalty[t] >= 0) ?
solution["Reserve shortfall (MW)"][t] : 0
if reserve + reserve_shortfall < instance.reserves.spinning[t] - tol
@error @sprintf(
"Insufficient spinning reserves at time %d (%.2f + %.2f should be %.2f)",
t,
reserve,
reserve_shortfall,
instance.reserves.spinning[t],
)
err_count += 1
end
end end
return err_count return err_count
end end

Loading…
Cancel
Save