Skip to content

Commit

Permalink
Rename res into gen
Browse files Browse the repository at this point in the history
  • Loading branch information
lbonaldo committed Dec 14, 2023
1 parent b5d9ff6 commit a76c3d2
Show file tree
Hide file tree
Showing 48 changed files with 301 additions and 303 deletions.
8 changes: 4 additions & 4 deletions src/additional_tools/modeling_to_generate_alternatives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ function mga(EP::Model, path::AbstractString, setup::Dict, inputs::Dict, outpath
Least_System_Cost = objective_value(EP)

# Read sets
res = inputs["RESOURCES"]
gen = inputs["RESOURCES"]
T = inputs["T"] # Number of time steps (hours)
Z = inputs["Z"] # Number of zonests
zones = unique(inputs["R_ZONES"])

# Create a set of unique technology types
resources_with_mga = resources_with_mga(res)
resources_with_mga = resources_with_mga(gen)
TechTypes = unique(resource_type.(resources_with_mga))

# Read slack parameter representing desired increase in budget from the least cost solution
Expand All @@ -52,8 +52,8 @@ function mga(EP::Model, path::AbstractString, setup::Dict, inputs::Dict, outpath

# Constraint to compute total generation in each zone from a given Technology Type
function resource_in_zone_with_TechType(tt::Int64, z::Int64)
condition::BitVector = (resource_type.(res) .== TechTypes[tt]) .& (zone_id.(res) .== z)
return resource_id.(res[condition])
condition::BitVector = (resource_type.(gen) .== TechTypes[tt]) .& (zone_id.(gen) .== z)
return resource_id.(gen[condition])
end
@constraint(EP,cGeneration[tt = 1:length(TechTypes), z = 1:Z], vSumvP[tt,z] == sum(EP[:vP][y,t] * inputs["omega"][t] for y in resource_in_zone_with_TechType(tt,z), t in 1:T))

Expand Down
6 changes: 3 additions & 3 deletions src/load_inputs/load_reserves.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function load_reserves!(setup::Dict, path::AbstractString, inputs::Dict)
filename = "Reserves.csv"
res_in = load_dataframe(joinpath(path, filename))

res = inputs["RESOURCES"]
gen = inputs["RESOURCES"]

function load_field_with_deprecated_symbol(df::DataFrame, columns::Vector{Symbol})
best = popfirst!(columns)
Expand Down Expand Up @@ -52,11 +52,11 @@ function load_reserves!(setup::Dict, path::AbstractString, inputs::Dict)
if inputs["pDynamic_Contingency"] > 0
inputs["pContingency_BigM"] = zeros(Float64, inputs["G"])
for y in inputs["COMMIT"]
inputs["pContingency_BigM"][y] = max_capacity_mw(res[y])
inputs["pContingency_BigM"][y] = max_capacity_mw(gen[y])
# When Max_Cap_MW == -1, there is no limit on capacity size
if inputs["pContingency_BigM"][y] < 0
# NOTE: this effectively acts as a maximum cluster size when not otherwise specified, adjust accordingly
inputs["pContingency_BigM"][y] = 5000 * cap_size(res[y])
inputs["pContingency_BigM"][y] = 5000 * cap_size(gen[y])
end
end
end
Expand Down
20 changes: 10 additions & 10 deletions src/model/core/co2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function co2!(EP::Model, inputs::Dict)

println("CO2 Module")

res = inputs["RESOURCES"]
gen = inputs["RESOURCES"]
G = inputs["G"] # Number of resources (generators, storage, DR, and DERs)
T = inputs["T"] # Number of time steps (hours)
Z = inputs["Z"] # Number of zones
Expand All @@ -63,21 +63,21 @@ function co2!(EP::Model, inputs::Dict)
### Expressions ###
# CO2 emissions from power plants in "Generators_data.csv"
# If all the CO2 capture fractions from Generators_data are zeros, the CO2 emissions from thermal generators are determined by fuel consumption times CO2 content per MMBTU
if all(co2_capture_fraction.(res) .==0)
if all(co2_capture_fraction.(gen) .==0)
@expression(EP, eEmissionsByPlant[y=1:G, t=1:T],
((1-biomass(res[y])) *(EP[:vFuel][y, t] + EP[:eStartFuel][y, t]) * fuel_CO2[fuel(res[y])]))
((1-biomass(gen[y])) *(EP[:vFuel][y, t] + EP[:eStartFuel][y, t]) * fuel_CO2[fuel(gen[y])]))
else
@info "Using the CO2 module to determine the CO2 emissions of CCS-equipped plants"
# CO2_Capture_Fraction refers to the CO2 capture rate of CCS equiped power plants at a steady state
# CO2_Capture_Fraction_Startup refers to the CO2 capture rate of CCS equiped power plants during startup events
@expression(EP, eEmissionsByPlant[y=1:G, t=1:T],
(1-biomass(res[y]) - co2_capture_fraction(res[y])) * EP[:vFuel][y, t] * fuel_CO2[fuel(res[y])]+
(1-biomass(res[y]) - co2_capture_fraction_startup(res[y])) * EP[:eStartFuel][y, t] * fuel_CO2[fuel(res[y])])
(1-biomass(gen[y]) - co2_capture_fraction(gen[y])) * EP[:vFuel][y, t] * fuel_CO2[fuel(gen[y])]+
(1-biomass(gen[y]) - co2_capture_fraction_startup(gen[y])) * EP[:eStartFuel][y, t] * fuel_CO2[fuel(gen[y])])

# CO2 captured from power plants in "Generators_data.csv"
@expression(EP, eEmissionsCaptureByPlant[y=1:G, t=1:T],
co2_capture_fraction(res[y]) * EP[:vFuel][y, t] * fuel_CO2[fuel(res[y])]+
co2_capture_fraction_startup(res[y]) * EP[:eStartFuel][y, t] * fuel_CO2[fuel(res[y])])
co2_capture_fraction(gen[y]) * EP[:vFuel][y, t] * fuel_CO2[fuel(gen[y])]+
co2_capture_fraction_startup(gen[y]) * EP[:eStartFuel][y, t] * fuel_CO2[fuel(gen[y])])

@expression(EP, eEmissionsCaptureByPlantYear[y=1:G],
sum(inputs["omega"][t] * eEmissionsCaptureByPlant[y, t]
Expand All @@ -86,10 +86,10 @@ function co2!(EP::Model, inputs::Dict)
# when scale factor is on tCO2/MWh = > kt CO2/GWh
@expression(EP, ePlantCCO2Sequestration[y=1:G],
sum(inputs["omega"][t] * eEmissionsCaptureByPlant[y, t] *
ccs_disposal_cost_per_metric_ton(res[y]) for t in 1:T))
ccs_disposal_cost_per_metric_ton(gen[y]) for t in 1:T))

@expression(EP, eZonalCCO2Sequestration[z=1:Z],
sum(ePlantCCO2Sequestration[y] for y in resources_in_zone_by_rid(res,z)))
sum(ePlantCCO2Sequestration[y] for y in resources_in_zone_by_rid(gen,z)))

@expression(EP, eTotaleCCO2Sequestration,
sum(eZonalCCO2Sequestration[z] for z in 1:Z))
Expand All @@ -99,7 +99,7 @@ function co2!(EP::Model, inputs::Dict)

# emissions by zone
@expression(EP, eEmissionsByZone[z = 1:Z, t = 1:T],
sum(eEmissionsByPlant[y, t] for y in resources_in_zone_by_rid(res,z)))
sum(eEmissionsByPlant[y, t] for y in resources_in_zone_by_rid(gen,z)))
return EP

end
6 changes: 3 additions & 3 deletions src/model/core/discharge/discharge.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function discharge!(EP::Model, inputs::Dict, setup::Dict)

println("Discharge Module")

res = inputs["RESOURCES"]
gen = inputs["RESOURCES"]

G = inputs["G"] # Number of resources (generators, storage, DR, and DERs)
T = inputs["T"] # Number of time steps
Expand All @@ -28,7 +28,7 @@ function discharge!(EP::Model, inputs::Dict, setup::Dict)
## Objective Function Expressions ##

# Variable costs of "generation" for resource "y" during hour "t" = variable O&M
@expression(EP, eCVar_out[y=1:G,t=1:T], (inputs["omega"][t]*(var_om_cost_per_mwh(res[y])*vP[y,t])))
@expression(EP, eCVar_out[y=1:G,t=1:T], (inputs["omega"][t]*(var_om_cost_per_mwh(gen[y])*vP[y,t])))
# Sum individual resource contributions to variable discharging costs to get total variable discharging costs
@expression(EP, eTotalCVarOutT[t=1:T], sum(eCVar_out[y,t] for y in 1:G))
@expression(EP, eTotalCVarOut, sum(eTotalCVarOutT[t] for t in 1:T))
Expand All @@ -40,7 +40,7 @@ function discharge!(EP::Model, inputs::Dict, setup::Dict)
if setup["EnergyShareRequirement"] >= 1

@expression(EP, eESRDischarge[ESR=1:inputs["nESR"]],
+ sum(inputs["omega"][t] * esr(res[y],tag=ESR) * EP[:vP][y,t] for y=has_esr(res,tag=ESR), t=1:T)
+ sum(inputs["omega"][t] * esr(gen[y],tag=ESR) * EP[:vP][y,t] for y=has_esr(gen,tag=ESR), t=1:T)
- sum(inputs["dfESR"][z,ESR]*inputs["omega"][t]*inputs["pD"][t,z] for t=1:T, z=findall(x->x>0,inputs["dfESR"][:,ESR]))
)
add_similar_to_expression!(EP[:eESR], eESRDischarge)
Expand Down
36 changes: 18 additions & 18 deletions src/model/core/discharge/investment_discharge.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function investment_discharge!(EP::Model, inputs::Dict, setup::Dict)
println("Investment Discharge Module")
MultiStage = setup["MultiStage"]

res = inputs["RESOURCES"]
gen = inputs["RESOURCES"]

G = inputs["G"] # Number of resources (generators, storage, DR, and DERs)

Expand Down Expand Up @@ -80,27 +80,27 @@ function investment_discharge!(EP::Model, inputs::Dict, setup::Dict)
if MultiStage == 1
@expression(EP, eExistingCap[y in 1:G], vEXISTINGCAP[y])
else
@expression(EP, eExistingCap[y in 1:G], existing_capacity_mw(res[y]))
@expression(EP, eExistingCap[y in 1:G], existing_capacity_mw(gen[y]))
end

# Cap_Size is set to 1 for all variables when unit UCommit == 0
# When UCommit > 0, Cap_Size is set to 1 for all variables except those where THERM == 1
@expression(EP, eTotalCap[y in 1:G],
if y in intersect(NEW_CAP, RET_CAP) # Resources eligible for new capacity and retirements
if y in COMMIT
eExistingCap[y] + cap_size(res[y])*(EP[:vCAP][y] - EP[:vRETCAP][y])
eExistingCap[y] + cap_size(gen[y])*(EP[:vCAP][y] - EP[:vRETCAP][y])
else
eExistingCap[y] + EP[:vCAP][y] - EP[:vRETCAP][y]
end
elseif y in setdiff(NEW_CAP, RET_CAP) # Resources eligible for only new capacity
if y in COMMIT
eExistingCap[y] + cap_size(res[y])*EP[:vCAP][y]
eExistingCap[y] + cap_size(gen[y])*EP[:vCAP][y]
else
eExistingCap[y] + EP[:vCAP][y]
end
elseif y in setdiff(RET_CAP, NEW_CAP) # Resources eligible for only capacity retirements
if y in COMMIT
eExistingCap[y] - cap_size(res[y])*EP[:vRETCAP][y]
eExistingCap[y] - cap_size(gen[y])*EP[:vRETCAP][y]
else
eExistingCap[y] - EP[:vRETCAP][y]
end
Expand All @@ -116,18 +116,18 @@ function investment_discharge!(EP::Model, inputs::Dict, setup::Dict)
@expression(EP, eCFix[y in 1:G],
if y in setdiff(NEW_CAP, RETRO) # Resources eligible for new capacity (Non-Retrofit)
if y in COMMIT
inv_cost_per_mwyr(res[y])*cap_size(res[y])*vCAP[y] + fixed_om_cost_per_mwyr(res[y])*eTotalCap[y]
inv_cost_per_mwyr(gen[y])*cap_size(gen[y])*vCAP[y] + fixed_om_cost_per_mwyr(gen[y])*eTotalCap[y]
else
inv_cost_per_mwyr(res[y])*vCAP[y] + fixed_om_cost_per_mwyr(res[y])*eTotalCap[y]
inv_cost_per_mwyr(gen[y])*vCAP[y] + fixed_om_cost_per_mwyr(gen[y])*eTotalCap[y]
end
elseif y in intersect(NEW_CAP, RETRO) # Resources eligible for new capacity (Retrofit yr -> y)
if y in COMMIT
sum( RETRO_SOURCE_IDS[y][i] in RET_CAP ? RETRO_INV_CAP_COSTS[y][i]*cap_size(res[y])*vRETROFIT[RETRO_SOURCE_IDS[y][i],y]*RETRO_EFFICIENCY[y][i] : 0 for i in 1:NUM_RETRO_SOURCES[y]) + fixed_om_cost_per_mwyr(res[y])*eTotalCap[y]
sum( RETRO_SOURCE_IDS[y][i] in RET_CAP ? RETRO_INV_CAP_COSTS[y][i]*cap_size(gen[y])*vRETROFIT[RETRO_SOURCE_IDS[y][i],y]*RETRO_EFFICIENCY[y][i] : 0 for i in 1:NUM_RETRO_SOURCES[y]) + fixed_om_cost_per_mwyr(gen[y])*eTotalCap[y]
else
sum( RETRO_SOURCE_IDS[y][i] in RET_CAP ? RETRO_INV_CAP_COSTS[y][i]*vRETROFIT[RETRO_SOURCE_IDS[y][i],y]*RETRO_EFFICIENCY[y][i] : 0 for i in 1:NUM_RETRO_SOURCES[y]) + fixed_om_cost_per_mwyr(res[y])*eTotalCap[y]
sum( RETRO_SOURCE_IDS[y][i] in RET_CAP ? RETRO_INV_CAP_COSTS[y][i]*vRETROFIT[RETRO_SOURCE_IDS[y][i],y]*RETRO_EFFICIENCY[y][i] : 0 for i in 1:NUM_RETRO_SOURCES[y]) + fixed_om_cost_per_mwyr(gen[y])*eTotalCap[y]
end
else
fixed_om_cost_per_mwyr(res[y])*eTotalCap[y]
fixed_om_cost_per_mwyr(gen[y])*eTotalCap[y]
end
)

Expand All @@ -148,32 +148,32 @@ function investment_discharge!(EP::Model, inputs::Dict, setup::Dict)

if MultiStage == 1
# Existing capacity variable is equal to existing capacity specified in the input file
@constraint(EP, cExistingCap[y in 1:G], EP[:vEXISTINGCAP][y] == existing_capacity_mw(res[y]))
@constraint(EP, cExistingCap[y in 1:G], EP[:vEXISTINGCAP][y] == existing_capacity_mw(gen[y]))
end

## Constraints on retirements and capacity additions
# Cannot retire more capacity than existing capacity
@constraint(EP, cMaxRetNoCommit[y in setdiff(RET_CAP,COMMIT)], vRETCAP[y] <= eExistingCap[y])
@constraint(EP, cMaxRetCommit[y in intersect(RET_CAP,COMMIT)], cap_size(res[y])*vRETCAP[y] <= eExistingCap[y])
@constraint(EP, cMaxRetCommit[y in intersect(RET_CAP,COMMIT)], cap_size(gen[y])*vRETCAP[y] <= eExistingCap[y])

## Constraints on new built capacity
# Constraint on maximum capacity (if applicable) [set input to -1 if no constraint on maximum capacity]
# DEV NOTE: This constraint may be violated in some cases where Existing_Cap_MW is >= Max_Cap_MW and lead to infeasabilty
MAX_CAP = has_positive_max_capacity_mw(res)
@constraint(EP, cMaxCap[y in MAX_CAP], eTotalCap[y] <= max_capacity_mw(res[y]))
MAX_CAP = has_positive_max_capacity_mw(gen)
@constraint(EP, cMaxCap[y in MAX_CAP], eTotalCap[y] <= max_capacity_mw(gen[y]))

# Constraint on minimum capacity (if applicable) [set input to -1 if no constraint on minimum capacity]
# DEV NOTE: This constraint may be violated in some cases where Existing_Cap_MW is <= Min_Cap_MW and lead to infeasabilty
MIN_CAP = has_positive_min_capacity_mw(res)
@constraint(EP, cMinCap[y in MIN_CAP], eTotalCap[y] >= min_capacity_mw(res[y]))
MIN_CAP = has_positive_min_capacity_mw(gen)
@constraint(EP, cMinCap[y in MIN_CAP], eTotalCap[y] >= min_capacity_mw(gen[y]))

if setup["MinCapReq"] == 1
@expression(EP, eMinCapResInvest[mincap = 1:inputs["NumberOfMinCapReqs"]], sum(EP[:eTotalCap][y] for y in has_min_cap(res, tag=mincap)))
@expression(EP, eMinCapResInvest[mincap = 1:inputs["NumberOfMinCapReqs"]], sum(EP[:eTotalCap][y] for y in has_min_cap(gen, tag=mincap)))
add_similar_to_expression!(EP[:eMinCapRes], eMinCapResInvest)
end

if setup["MaxCapReq"] == 1
@expression(EP, eMaxCapResInvest[maxcap = 1:inputs["NumberOfMaxCapReqs"]], sum(EP[:eTotalCap][y] for y in has_max_cap(res, tag=maxcap)))
@expression(EP, eMaxCapResInvest[maxcap = 1:inputs["NumberOfMaxCapReqs"]], sum(EP[:eTotalCap][y] for y in has_max_cap(gen, tag=maxcap)))
add_similar_to_expression!(EP[:eMaxCapRes], eMaxCapResInvest)
end
end
20 changes: 10 additions & 10 deletions src/model/core/fuel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ PWFU_Intercept_* for at least one segment.

function fuel!(EP::Model, inputs::Dict, setup::Dict)
println("Fuel Module")
res = inputs["RESOURCES"]
gen = inputs["RESOURCES"]

T = inputs["T"] # Number of time steps (hours)
Z = inputs["Z"] # Number of zones
Expand All @@ -72,8 +72,8 @@ function fuel!(EP::Model, inputs::Dict, setup::Dict)
# if unit commitment is modelled
@expression(EP, eStartFuel[y in 1:G, t = 1:T],
if y in THERM_COMMIT
(cap_size(res[y]) * EP[:vSTART][y, t] *
start_fuel_mmbtu_per_mw(res[y]))
(cap_size(gen[y]) * EP[:vSTART][y, t] *
start_fuel_mmbtu_per_mw(gen[y]))
else
0
end)
Expand All @@ -83,23 +83,23 @@ function fuel!(EP::Model, inputs::Dict, setup::Dict)
# eCFuel_start or eCFuel_out is $ or Million$
# Start up fuel cost
@expression(EP, eCFuelStart[y = 1:G, t = 1:T],
(inputs["fuel_costs"][fuel(res[y])][t] * EP[:eStartFuel][y, t]))
(inputs["fuel_costs"][fuel(gen[y])][t] * EP[:eStartFuel][y, t]))
# plant level start-up fuel cost for output
@expression(EP, ePlantCFuelStart[y = 1:G],
sum(inputs["omega"][t] * EP[:eCFuelStart][y, t] for t in 1:T))
# zonal level total fuel cost for output
@expression(EP, eZonalCFuelStart[z = 1:Z],
sum(EP[:ePlantCFuelStart][y] for y in resources_in_zone_by_rid(res,z)))
sum(EP[:ePlantCFuelStart][y] for y in resources_in_zone_by_rid(gen,z)))

# Fuel cost for power generation
@expression(EP, eCFuelOut[y = 1:G, t = 1:T],
(inputs["fuel_costs"][fuel(res[y])][t] * EP[:vFuel][y, t]))
(inputs["fuel_costs"][fuel(gen[y])][t] * EP[:vFuel][y, t]))
# plant level start-up fuel cost for output
@expression(EP, ePlantCFuelOut[y = 1:G],
sum(inputs["omega"][t] * EP[:eCFuelOut][y, t] for t in 1:T))
# zonal level total fuel cost for output
@expression(EP, eZonalCFuelOut[z = 1:Z],
sum(EP[:ePlantCFuelOut][y] for y in resources_in_zone_by_rid(res,z)))
sum(EP[:ePlantCFuelOut][y] for y in resources_in_zone_by_rid(gen,z)))


# system level total fuel cost for output
Expand All @@ -112,7 +112,7 @@ function fuel!(EP::Model, inputs::Dict, setup::Dict)
#fuel consumption (MMBTU or Billion BTU)
@expression(EP, eFuelConsumption[f in 1:NUM_FUEL, t in 1:T],
sum(EP[:vFuel][y, t] + EP[:eStartFuel][y,t]
for y in resources_with_fuel(res, fuels[f])))
for y in resources_with_fuel(gen, fuels[f])))

@expression(EP, eFuelConsumptionYear[f in 1:NUM_FUEL],
sum(inputs["omega"][t] * EP[:eFuelConsumption][f, t] for t in 1:T))
Expand All @@ -121,7 +121,7 @@ function fuel!(EP::Model, inputs::Dict, setup::Dict)
### Constraint ###
### only apply constraint to generators with fuel type other than None
@constraint(EP, FuelCalculation[y in setdiff(HAS_FUEL, THERM_COMMIT), t = 1:T],
EP[:vFuel][y, t] - EP[:vP][y, t] * heat_rate_mmbtu_per_mwh(res[y]) == 0)
EP[:vFuel][y, t] - EP[:vP][y, t] * heat_rate_mmbtu_per_mwh(gen[y]) == 0)

if !isempty(THERM_COMMIT)
# Only apply piecewise fuel consumption to thermal generators in THERM_COMMIT_PWFU set
Expand All @@ -141,7 +141,7 @@ function fuel!(EP::Model, inputs::Dict, setup::Dict)
end
# constraint for fuel consumption at a constant heat rate
@constraint(EP, FuelCalculationCommit[y in setdiff(THERM_COMMIT,THERM_COMMIT_PWFU), t = 1:T],
EP[:vFuel][y, t] - EP[:vP][y, t] * heat_rate_mmbtu_per_mwh(res[y]) == 0)
EP[:vFuel][y, t] - EP[:vP][y, t] * heat_rate_mmbtu_per_mwh(gen[y]) == 0)
end

return EP
Expand Down
12 changes: 6 additions & 6 deletions src/model/core/reserves.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function reserves_contingency!(EP::Model, inputs::Dict, setup::Dict)

println("Reserves Contingency Module")

res = inputs["RESOURCES"]
gen = inputs["RESOURCES"]

T = inputs["T"] # Number of time steps (hours)
UCommit = setup["UCommit"]
Expand Down Expand Up @@ -116,15 +116,15 @@ function reserves_contingency!(EP::Model, inputs::Dict, setup::Dict)
# Dynamic contingency related constraints
# option 1: ensures vLARGEST_CONTINGENCY is greater than the capacity of the largest installed generator
if UCommit == 1 && pDynamic_Contingency == 1
@constraint(EP, cContingency[y in COMMIT], vLARGEST_CONTINGENCY >= cap_size(res[y])*vCONTINGENCY_AUX[y] )
@constraint(EP, cContingency[y in COMMIT], vLARGEST_CONTINGENCY >= cap_size(gen[y])*vCONTINGENCY_AUX[y] )
# Ensure vCONTINGENCY_AUX = 0 if total capacity = 0
@constraint(EP, cContAux1[y in COMMIT], vCONTINGENCY_AUX[y] <= EP[:eTotalCap][y])
# Ensure vCONTINGENCY_AUX = 1 if total capacity > 0
@constraint(EP, cContAux2[y in COMMIT], EP[:eTotalCap][y] <= inputs["pContingency_BigM"][y]*vCONTINGENCY_AUX[y])

# option 2: ensures vLARGEST_CONTINGENCY is greater than the capacity of the largest commited generator in each hour
elseif UCommit == 1 && pDynamic_Contingency == 2
@constraint(EP, cContingency[y in COMMIT, t=1:T], vLARGEST_CONTINGENCY[t] >= cap_size(res[y])*vCONTINGENCY_AUX[y,t] )
@constraint(EP, cContingency[y in COMMIT, t=1:T], vLARGEST_CONTINGENCY[t] >= cap_size(gen[y])*vCONTINGENCY_AUX[y,t] )
# Ensure vCONTINGENCY_AUX = 0 if vCOMMIT = 0
@constraint(EP, cContAux[y in COMMIT, t=1:T], vCONTINGENCY_AUX[y,t] <= EP[:vCOMMIT][y,t])
# Ensure vCONTINGENCY_AUX = 1 if vCOMMIT > 0
Expand Down Expand Up @@ -207,7 +207,7 @@ function reserves_core!(EP::Model, inputs::Dict, setup::Dict)

println("Reserves Core Module")

res = inputs["RESOURCES"]
gen = inputs["RESOURCES"]

UCommit = setup["UCommit"]

Expand Down Expand Up @@ -262,8 +262,8 @@ function reserves_core!(EP::Model, inputs::Dict, setup::Dict)
# TODO: check these expressions
@expression(EP, eCRsvPen[t=1:T], inputs["omega"][t]*inputs["pC_Rsv_Penalty"]*vUNMET_RSV[t])
@expression(EP, eTotalCRsvPen, sum(eCRsvPen[t] for t=1:T) +
sum(reg_cost(res[y])*vRSV[y,t] for y in RSV, t=1:T) +
sum(rsv_cost(res[y])*vREG[y,t] for y in REG, t=1:T) )
sum(reg_cost(gen[y])*vRSV[y,t] for y in RSV, t=1:T) +
sum(rsv_cost(gen[y])*vREG[y,t] for y in REG, t=1:T) )
add_to_expression!(EP[:eObj], eTotalCRsvPen)
end

Expand Down
Loading

0 comments on commit a76c3d2

Please sign in to comment.