From f44d7bcfdf557ec2e18ebf4d79c44477dae5c4ba Mon Sep 17 00:00:00 2001 From: Aleksandr Kazachkov Date: Fri, 23 Jul 2021 18:48:03 -0400 Subject: [PATCH] Fix _validate_reserve_and_demand --- src/solution/solution.jl | 1 + src/validation/validate.jl | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/solution/solution.jl b/src/solution/solution.jl index 6240d9a..9e346bb 100644 --- a/src/solution/solution.jl +++ b/src/solution/solution.jl @@ -51,6 +51,7 @@ function solution(model::JuMP.Model)::OrderedDict sol["Switch on"] = timeseries(model[:switch_on], instance.units) sol["Switch off"] = timeseries(model[:switch_off], instance.units) sol["Reserve (MW)"] = timeseries(model[:reserve], instance.units) + sol["Reserve shortfall (MW)"] = model[:reserve_shortfall] sol["Net injection (MW)"] = timeseries(model[:net_injection], instance.buses) sol["Load curtail (MW)"] = timeseries(model[:curtail], instance.buses) diff --git a/src/validation/validate.jl b/src/validation/validate.jl index fb0c8b2..269bab3 100644 --- a/src/validation/validate.jl +++ b/src/validation/validate.jl @@ -324,11 +324,13 @@ function _validate_reserve_and_demand(instance, solution, tol = 0.01) # Verify spinning reserves reserve = sum(solution["Reserve (MW)"][g.name][t] for g in instance.units) - if reserve < instance.reserves.spinning[t] - tol + reserve_shortfall = solution["Reserve shortfall (MW)"][t] + if reserve + reserve_shortfall < instance.reserves.spinning[t] - tol @error @sprintf( - "Insufficient spinning reserves at time %d (%.2f should be %.2f)", + "Insufficient spinning reserves at time %d (%.2f + %.2f should be %.2f)", t, reserve, + reserve_shortfall, instance.reserves.spinning[t], ) err_count += 1