mirror of
https://github.com/ANL-CEEESA/UnitCommitment.jl.git
synced 2025-12-06 00:08:52 -06:00
Fix failing tests due to use of non-binary value and improper invocation of variable
This commit is contained in:
@@ -40,10 +40,12 @@ function _add_ramp_eqs!(
|
||||
switch_off = model[:switch_off]
|
||||
switch_on = model[:switch_on]
|
||||
|
||||
is_initially_on = _is_initially_on(g) > 0
|
||||
|
||||
for t in 1:model[:instance].time
|
||||
# Ramp up limit
|
||||
if t == 1
|
||||
if _is_initially_on(g)
|
||||
if is_initially_on
|
||||
# min power is _not_ multiplied by is_on because if !is_on, then ramp up is irrelevant
|
||||
eq_ramp_up[gn, t] = @constraint(
|
||||
model,
|
||||
@@ -74,7 +76,7 @@ function _add_ramp_eqs!(
|
||||
|
||||
# Ramp down limit
|
||||
if t == 1
|
||||
if _is_initially_on(g)
|
||||
if is_initially_on
|
||||
# TODO If RD < SD, or more specifically if
|
||||
# min_power + RD < initial_power < SD
|
||||
# then the generator should be able to shut down at time t = 1,
|
||||
|
||||
@@ -45,7 +45,7 @@ function _add_unit!(model::JuMP.Model, g::Unit, formulation::Formulation)
|
||||
)
|
||||
_add_startup_cost_eqs!(model, g, formulation.startup_costs)
|
||||
_add_shutdown_cost_eqs!(model, g)
|
||||
_add_startup_shutdown_limit_eqs!(model, g)
|
||||
_add_startup_shutdown_limit_eqs!(model, g, formulation.status_vars, formulation.prod_vars)
|
||||
_add_status_eqs!(model, g, formulation.status_vars)
|
||||
return
|
||||
end
|
||||
@@ -105,27 +105,28 @@ end
|
||||
"""
|
||||
_add_startup_shutdown_limit_eqs!(model::JuMP.Model, g::Unit)::Nothing
|
||||
|
||||
Variables
|
||||
---
|
||||
* :is_on
|
||||
* :prod_above
|
||||
* :reserve
|
||||
* :switch_on
|
||||
* :switch_off
|
||||
Creates startup/shutdown limit constraints below based on variables `Gar1962.StatusVars`, `prod_above` from `Gar1962.ProdVars`, and `reserve`.
|
||||
|
||||
Constraints
|
||||
---
|
||||
* :eq_startup_limit
|
||||
* :eq_shutdown_limit
|
||||
"""
|
||||
function _add_startup_shutdown_limit_eqs!(model::JuMP.Model, g::Unit)::Nothing
|
||||
function _add_startup_shutdown_limit_eqs!(
|
||||
model::JuMP.Model,
|
||||
g::Unit,
|
||||
formulation_status_vars::Gar1962.StatusVars,
|
||||
formulation_prod_vars::Gar1962.ProdVars
|
||||
)::Nothing
|
||||
eq_shutdown_limit = _init(model, :eq_shutdown_limit)
|
||||
eq_startup_limit = _init(model, :eq_startup_limit)
|
||||
|
||||
is_on = model[:is_on]
|
||||
prod_above = model[:prod_above]
|
||||
reserve = model[:reserve]
|
||||
switch_off = model[:switch_off]
|
||||
switch_on = model[:switch_on]
|
||||
prod_above = model[:prod_above]
|
||||
reserve = model[:reserve]
|
||||
|
||||
T = model[:instance].time
|
||||
for t in 1:T
|
||||
# Startup limit
|
||||
@@ -140,10 +141,11 @@ function _add_startup_shutdown_limit_eqs!(model::JuMP.Model, g::Unit)::Nothing
|
||||
# TODO check what happens with these variables when exporting the model
|
||||
# Generator producing too much to be turned off in the first time period
|
||||
# (can a binary variable have bounds x = 0?)
|
||||
#eqs.shutdown_limit[gi, 0] = @constraint(mip, vars.switch_off[gi, 1] <= 0)
|
||||
fix(model.vars.switch_off[gi, 1], 0.0; force = true)
|
||||
#eq_shutdown_limit[g.name, 0] =
|
||||
#@constraint(model, switch_off[g.name, 1] <= 0)
|
||||
if formulation_status_vars.fix_vars_via_constraint
|
||||
eq_shutdown_limit[g.name, 0] = @constraint(model, model[:switch_off][g.name, 1] <= 0.0)
|
||||
else
|
||||
fix(model[:switch_off][g.name, 1], 0.0; force = true)
|
||||
end
|
||||
end
|
||||
if t < T
|
||||
eq_shutdown_limit[g.name, t] = @constraint(
|
||||
@@ -243,7 +245,6 @@ Variables
|
||||
* `switch_off`
|
||||
* `switch_on`
|
||||
|
||||
|
||||
Constraints
|
||||
---
|
||||
* `eq_min_uptime`
|
||||
|
||||
Reference in New Issue
Block a user