Properly validate solutions with price-sensitive loads

bugfix/formulations
Alinson S. Xavier 4 years ago
parent 7eb1019410
commit fb9221b8fb

@ -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

@ -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

Loading…
Cancel
Save