mirror of
https://github.com/ANL-CEEESA/UnitCommitment.jl.git
synced 2025-12-06 08:18:51 -06:00
Documented reserve shortfall, soved comments on variables/constraints to structs.jl files, simplified loops, removed extra comments, started replacement of constant-subsitution with @constraint (with option to use fix).
This commit is contained in:
@@ -12,7 +12,6 @@ function _add_status_vars!(
|
|||||||
model::JuMP.Model,
|
model::JuMP.Model,
|
||||||
g::Unit,
|
g::Unit,
|
||||||
formulation_status_vars::Gar1962.StatusVars,
|
formulation_status_vars::Gar1962.StatusVars,
|
||||||
ALWAYS_CREATE_VARS = false
|
|
||||||
)::Nothing
|
)::Nothing
|
||||||
is_on = _init(model, :is_on)
|
is_on = _init(model, :is_on)
|
||||||
switch_on = _init(model, :switch_on)
|
switch_on = _init(model, :switch_on)
|
||||||
@@ -65,9 +64,17 @@ function _add_status_vars!(
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if ALWAYS_CREATE_VARS
|
# Use initial conditions and whether a unit must run to fix variables
|
||||||
# If variables are created, use initial conditions to fix some values
|
if FIX_VARS
|
||||||
if t == 1
|
# Fix variables using fix function
|
||||||
|
if g.must_run[t]
|
||||||
|
# If the generator _must_ run, then it is obviously on and cannot be switched off
|
||||||
|
# In the first time period, force unit to switch on if was off before
|
||||||
|
# Otherwise, unit is on, and will never turn off, so will never need to turn on
|
||||||
|
fix(is_on[g.name, t], 1.0; force = true)
|
||||||
|
fix(switch_on[g.name, t], (t == 1 ? 1.0 - _is_initially_on(g) : 0.0); force = true)
|
||||||
|
fix(switch_off[g.name, t], 0.0; force = true)
|
||||||
|
elseif t == 1
|
||||||
if _is_initially_on(g)
|
if _is_initially_on(g)
|
||||||
# Generator was on (for g.initial_status time periods),
|
# Generator was on (for g.initial_status time periods),
|
||||||
# so cannot be more switched on until the period after the first time it can be turned off
|
# so cannot be more switched on until the period after the first time it can be turned off
|
||||||
@@ -78,30 +85,20 @@ function _add_status_vars!(
|
|||||||
fix(switch_off[g.name, 1], 0.0; force = true)
|
fix(switch_off[g.name, 1], 0.0; force = true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if g.must_run[t]
|
|
||||||
# If the generator _must_ run, then it is obviously on and cannot be switched off
|
|
||||||
# In the first time period, force unit to switch on if was off before
|
|
||||||
# Otherwise, unit is on, and will never turn off, so will never need to turn on
|
|
||||||
fix(is_on[g.name, t], 1.0; force = true)
|
|
||||||
fix(switch_on[g.name, t], (t == 1 ? 1.0 - _is_initially_on(g) : 0.0); force = true)
|
|
||||||
fix(switch_off[g.name, t], 0.0; force = true)
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
# If vars are not created, then replace them by a constant
|
# Add explicit constraint if !FIX_VARS
|
||||||
if t == 1
|
if g.must_run[t]
|
||||||
|
is_on[g.name, t] = 1.0
|
||||||
|
switch_on[g.name, t] = (t == 1 ? 1.0 - _is_initially_on(g) : 0.0)
|
||||||
|
switch_off[g.name, t] = 0.0
|
||||||
|
elseif t == 1
|
||||||
if _is_initially_on(g)
|
if _is_initially_on(g)
|
||||||
switch_on[g.name, t] = 0.0
|
switch_on[g.name, t] = 0.0
|
||||||
else
|
else
|
||||||
switch_off[g.name, t] = 0.0
|
switch_off[g.name, t] = 0.0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if g.must_run[t]
|
|
||||||
is_on[g.name, t] = 1.0
|
|
||||||
switch_on[g.name, t] = (t == 1 ? 1.0 - _is_initially_on(g) : 0.0)
|
|
||||||
switch_off[g.name, t] = 0.0
|
|
||||||
end
|
end
|
||||||
end # check if ALWAYS_CREATE_VARS
|
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ function _add_reserve_eqs!(model::JuMP.Model)::Nothing
|
|||||||
eq_min_reserve = _init(model, :eq_min_reserve)
|
eq_min_reserve = _init(model, :eq_min_reserve)
|
||||||
instance = model[:instance]
|
instance = model[:instance]
|
||||||
for t in 1:instance.time
|
for t in 1:instance.time
|
||||||
# Equation (68) in Kneuven et al. (2020)
|
# Equation (68) in Knueven et al. (2020)
|
||||||
# As in Morales-España et al. (2013a)
|
# As in Morales-España et al. (2013a)
|
||||||
# Akin to the alternative formulation with max_power_avail
|
# Akin to the alternative formulation with max_power_avail
|
||||||
# from Carrión and Arroyo (2006) and Ostrowski et al. (2012)
|
# from Carrión and Arroyo (2006) and Ostrowski et al. (2012)
|
||||||
|
|||||||
@@ -247,6 +247,10 @@ Variables
|
|||||||
* `is_on`
|
* `is_on`
|
||||||
* `switch_off`
|
* `switch_off`
|
||||||
* `switch_on`
|
* `switch_on`
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
|
||||||
|
>>>>>>> c8bf25f (Documented reserve shortfall, soved comments on variables/constraints to structs.jl files, simplified loops, removed extra comments, started replacement of constant-subsitution with @constraint (with option to use fix).)
|
||||||
|
|
||||||
Constraints
|
Constraints
|
||||||
---
|
---
|
||||||
|
|||||||
Reference in New Issue
Block a user