From fb9221b8fb05bfbd6897c72a5d3b18441d709060 Mon Sep 17 00:00:00 2001 From: Alinson S Xavier Date: Thu, 27 May 2021 21:13:21 -0500 Subject: [PATCH] Properly validate solutions with price-sensitive loads --- CHANGELOG.md | 6 ++++++ src/validate.jl | 36 +++++++++++++++++++++++++++--------- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2c584e..dcfb707 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,11 +3,13 @@ ## [0.2.0] - [Unreleased] ### Added + - Sub-hourly unit commitment - Added function `UnitCommitment.write(filename, solution)` - Added mathematical formulation to the documentation ### Changed + - Renamed "Time (h)" parameter to "Time horizon (h)" - The function `UnitCommitment.build_model` now returns a plain JuMP model. The struct `UnitCommitmentModel` has been completely removed. Accessing model elements can now be accomplished as follows: @@ -21,6 +23,10 @@ - All function that do not appear in the documentation have been renamed to `_something`. These functions are not part of the public API and may change without notice. +### Fixed + +- Properly validate solutions with price-sensitive loads. + ## [0.1.1] - 2020-11-16 * Fixes to MATLAB and PGLIB-UC instances diff --git a/src/validate.jl b/src/validate.jl index 8574a7f..989fcbf 100644 --- a/src/validate.jl +++ b/src/validate.jl @@ -307,26 +307,44 @@ function _validate_reserve_and_demand(instance, solution, tol=0.01) for t in 1:instance.time load_curtail = 0 fixed_load = sum(b.load[t] for b in instance.buses) - production = sum(solution["Production (MW)"][g.name][t] - for g in instance.units) + ps_load = sum( + solution["Price-sensitive loads (MW)"][ps.name][t] + for ps in instance.price_sensitive_loads + ) + production = sum( + solution["Production (MW)"][g.name][t] + for g in instance.units + ) if "Load curtail (MW)" in keys(solution) - load_curtail = sum(solution["Load curtail (MW)"][b.name][t] - for b in instance.buses) + load_curtail = sum( + solution["Load curtail (MW)"][b.name][t] + for b in instance.buses + ) end - balance = fixed_load - load_curtail - production + balance = fixed_load - load_curtail - production + ps_load # Verify that production equals demand if abs(balance) > tol - @error @sprintf("Non-zero power balance at time %d (%.2f - %.2f - %.2f != 0)", - t, fixed_load, load_curtail, production) + @error @sprintf( + "Non-zero power balance at time %d (%.2f + %.2f - %.2f - %.2f != 0)", + t, + fixed_load, + ps_load, + load_curtail, + production, + ) err_count += 1 end # Verify spinning reserves reserve = sum(solution["Reserve (MW)"][g.name][t] for g in instance.units) if reserve < instance.reserves.spinning[t] - tol - @error @sprintf("Insufficient spinning reserves at time %d (%.2f should be %.2f)", - t, reserve, instance.reserves.spinning[t]) + @error @sprintf( + "Insufficient spinning reserves at time %d (%.2f should be %.2f)", + t, + reserve, + instance.reserves.spinning[t], + ) err_count += 1 end end