Skip to content

Commit

Permalink
Simplify formulation
Browse files Browse the repository at this point in the history
  • Loading branch information
cfe316 committed Oct 3, 2023
1 parent 0027091 commit c623d83
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
17 changes: 8 additions & 9 deletions src/model/resources/maintenance.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const MAINTENANCE_DOWN_VARS = "MaintenanceDownVariables"
const MAINTENANCE_SHUT_VARS = "MaintenanceShutVariables"
const HAS_MAINT = "HAS_MAINTENANCE"

@doc raw"""
resources_with_maintenance(df::DataFrame)::Vector{Int}
Expand Down Expand Up @@ -58,7 +57,7 @@ function controlling_maintenance_start_hours(
end

@doc raw"""
maintenance_constraints!(EP::Model,
maintenance_formulation!(EP::Model,
inputs::Dict,
resource_component::AbstractString,
r_id::Int,
Expand All @@ -84,12 +83,15 @@ end
maint_freq_years: 1 is maintenannce every year,
2 is maintenance every other year, etc. Must be at least 1.
cap: Plant electrical capacity.
vcommit: symbol of vCOMMIT-like variable.
ecap: symbol of eTotalCap-like variable.
vcommit: Symbol of vCOMMIT-like variable.
ecap: Symbol of eTotalCap-like variable.
integer_operational_unit_committment: whether this plant has integer unit
committment for operational variables.
Creates maintenance-tracking variables and adds their Symbols to two Sets in `inputs`.
Adds constraints which act on the vCOMMIT-like variable.
"""
function maintenance_constraints!(
function maintenance_formulation!(
EP::Model,
inputs::Dict,
resource_component::AbstractString,
Expand Down Expand Up @@ -158,12 +160,9 @@ function maintenance_constraints!(
EP,
sum(vMSHUT[t] for t in maintenance_begin_hours) >= ecap[y] / cap / maint_freq_years
)

return down, shut
end

function ensure_maintenance_variable_records!(inputs::Dict)
inputs[HAS_MAINT] = true
for var in (MAINTENANCE_DOWN_VARS, MAINTENANCE_SHUT_VARS)
if var keys(inputs)
inputs[var] = Set{Symbol}()
Expand All @@ -173,7 +172,7 @@ end

function has_maintenance(inputs::Dict)::Bool
rep_periods = inputs["REP_PERIOD"]
HAS_MAINT in keys(inputs) && rep_periods == 1
MAINTENANCE_DOWN_VARS in keys(inputs) && rep_periods == 1
end

function get_maintenance_down_variables(inputs::Dict)::Set{Symbol}
Expand Down
6 changes: 3 additions & 3 deletions src/model/resources/thermal/thermal_commit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ function thermal_commit!(EP::Model, inputs::Dict, setup::Dict)

## END Constraints for thermal units subject to integer (discrete) unit commitment decisions
if !isempty(resources_with_maintenance(dfGen))
maintenance_constraints_thermal!(EP, inputs, setup)
maintenance_formulation_thermal!(EP, inputs, setup)
end
end

Expand Down Expand Up @@ -339,7 +339,7 @@ function thermal_commit_reserves!(EP::Model, inputs::Dict)
end


function maintenance_constraints_thermal!(EP::Model, inputs::Dict, setup::Dict)
function maintenance_formulation_thermal!(EP::Model, inputs::Dict, setup::Dict)

@info "Maintenance Module for Thermal plants"

Expand All @@ -362,7 +362,7 @@ function maintenance_constraints_thermal!(EP::Model, inputs::Dict, setup::Dict)
sanity_check_maintenance(MAINT, inputs)

for y in MAINT
maintenance_constraints!(EP,
maintenance_formulation!(EP,
inputs,
resource_component(y),
y,
Expand Down

0 comments on commit c623d83

Please sign in to comment.