Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update UC and ramping constraints with accumulated units #804

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 5 additions & 32 deletions src/constraints/capacity.jl
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
export add_capacity_constraints!

"""
add_capacity_constraints!(model,
graph,
dataframes,
df_flows,
flow,
Ai,
investable_assets_using_simple_method,
Asb,
assets_investment,
accumulated_units_simple_method,
outgoing_flow_highest_out_resolution,
incoming_flow_highest_in_resolution
)
add_capacity_constraints!(model, graph,...)

Adds the capacity constraints for all asset types to the model
"""
Expand All @@ -28,10 +16,11 @@ function add_capacity_constraints!(
decommissionable_assets_using_simple_method,
decommissionable_assets_using_compact_method,
V_all,
accumulated_units_lookup,
accumulated_set_using_compact_method_lookup,
Asb,
assets_investment,
accumulated_units_simple_method,
accumulated_units,
accumulated_units_compact_method,
accumulated_set_using_compact_method,
outgoing_flow_highest_out_resolution,
Expand All @@ -42,23 +31,7 @@ function add_capacity_constraints!(
# - Create capacity limit for outgoing flows
assets_profile_times_capacity_out =
model[:assets_profile_times_capacity_out] = [
if row.asset ∈ decommissionable_assets_using_simple_method
@expression(
model,
profile_aggregation(
Statistics.mean,
graph[row.asset].rep_periods_profiles,
row.year,
row.year,
("availability", row.rep_period),
row.timesteps_block,
1.0,
) * (
graph[row.asset].capacity *
accumulated_units_simple_method[row.year, row.asset]
)
)
elseif row.asset ∈ decommissionable_assets_using_compact_method
if row.asset ∈ decommissionable_assets_using_compact_method
@expression(
model,
graph[row.asset].capacity * sum(
Expand Down Expand Up @@ -92,7 +65,7 @@ function add_capacity_constraints!(
1.0,
) *
graph[row.asset].capacity *
graph[row.asset].initial_units[row.year][row.year]
accumulated_units[accumulated_units_lookup[(row.asset, row.year)]]
)
end for row in eachrow(dataframes[:highest_out])
]
Expand Down
26 changes: 8 additions & 18 deletions src/constraints/ramping-and-unit-commitment.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export add_ramping_and_unit_commitment_constraints!

"""
add_ramping_and_unit_commitment_constraints!(graph, ...)
add_ramping_and_unit_commitment_constraints!(model, graph, ...)

Adds the ramping constraints for producer and conversion assets where ramping = true in assets_data
"""
Expand All @@ -12,7 +12,8 @@ function add_ramping_constraints!(
df_units_on,
df_highest_out,
outgoing_flow_highest_out_resolution,
assets_investment,
accumulated_units_lookup,
accumulated_units,
Ai,
Auc,
Auc_basic,
Expand Down Expand Up @@ -50,24 +51,13 @@ function add_ramping_constraints!(
]

## Unit Commitment Constraints (basic implementation - more advanced will be added in 2025)
# - Limit to the units on (i.e. commitment) variable with investment
model[:limit_units_on_with_investment] = [
# - Limit to the units on (i.e. commitment)
model[:limit_units_on] = [
@constraint(
model,
row.units_on ≤
graph[row.asset].initial_units[row.year][row.year] +
assets_investment[row.year, row.asset],
base_name = "limit_units_on_with_investment[$(row.asset),$(row.year),$(row.rep_period),$(row.timesteps_block)]"
) for row in eachrow(df_units_on) if row.asset in Ai[row.year]
]

# - Limit to the units on (i.e. commitment) variable without investment (TODO: depending on the input parameter definition, this could be a bound)
model[:limit_units_on_without_investment] = [
@constraint(
model,
row.units_on ≤ graph[row.asset].initial_units[row.year][row.year],
base_name = "limit_units_on_without_investment[$(row.asset),$(row.year),$(row.rep_period),$(row.timesteps_block)]"
) for row in eachrow(df_units_on) if !(row.asset in Ai[row.year])
row.units_on ≤ accumulated_units[accumulated_units_lookup[(row.asset, row.year)]],
base_name = "limit_units_on[$(row.asset),$(row.year),$(row.rep_period),$(row.timesteps_block)]"
) for row in eachrow(df_units_on)
]

# - Minimum output flow above the minimum operating point
Expand Down
49 changes: 29 additions & 20 deletions src/create-model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1032,24 +1032,31 @@ function create_model(
@expression(model, 0.0)
end for (a, y, v) in accumulated_set_using_compact_method
]
@expression(
model,
accumulated_units[
y ∈ Y,
a ∈ decommissionable_assets_using_simple_method∪decommissionable_assets_using_compact_method,
],
if a in decommissionable_assets_using_simple_method
accumulated_units_simple_method[y, a]
else
sum(
accumulated_units_compact_method[accumulated_set_using_compact_method_lookup[(
a,
y,
v,
)]] for v in V_all if (a, y, v) in accumulated_set_using_compact_method
)
end
)

# Create a lookup set for accumulated units
accumulated_units_lookup =
Dict((a, y) => idx for (idx, (a, y)) in enumerate((aa, yy) for aa in A for yy in Y))

accumulated_units =
model[:accumulated_units] = JuMP.AffExpr[
if a in decommissionable_assets_using_simple_method
@expression(model, accumulated_units_simple_method[y, a])
elseif a in decommissionable_assets_using_compact_method
@expression(
model,
sum(
accumulated_units_compact_method[accumulated_set_using_compact_method_lookup[(
a,
y,
v,
)]] for
v in V_all if (a, y, v) in accumulated_set_using_compact_method
)
)
else
@expression(model, sum(values(graph[a].initial_units[y])))
end for a in A for y in Y
]
end

## Expressions for the objective function
Expand Down Expand Up @@ -1134,10 +1141,11 @@ function create_model(
decommissionable_assets_using_simple_method,
decommissionable_assets_using_compact_method,
V_all,
accumulated_units_lookup,
accumulated_set_using_compact_method_lookup,
Asb,
assets_investment,
accumulated_units_simple_method,
accumulated_units,
accumulated_units_compact_method,
accumulated_set_using_compact_method,
outgoing_flow_highest_out_resolution,
Expand Down Expand Up @@ -1224,7 +1232,8 @@ function create_model(
df_units_on,
dataframes[:highest_out],
outgoing_flow_highest_out_resolution,
assets_investment,
accumulated_units_lookup,
accumulated_units,
Ai,
Auc,
Auc_basic,
Expand Down
Loading