Skip to content

Commit

Permalink
Change expression to make codecov happy
Browse files Browse the repository at this point in the history
  • Loading branch information
datejada committed Sep 18, 2024
1 parent 1e92902 commit 053daaf
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 33 deletions.
17 changes: 3 additions & 14 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,
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,6 +16,7 @@ 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,
Expand Down Expand Up @@ -76,7 +65,7 @@ function add_capacity_constraints!(
1.0,
) *
graph[row.asset].capacity *
accumulated_units[row.year, row.asset]
accumulated_units[accumulated_units_lookup[(row.asset, row.year)]]
)
end for row in eachrow(dataframes[:highest_out])
]
Expand Down
5 changes: 3 additions & 2 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,6 +12,7 @@ function add_ramping_constraints!(
df_units_on,
df_highest_out,
outgoing_flow_highest_out_resolution,
accumulated_units_lookup,
accumulated_units,
Ai,
Auc,
Expand Down Expand Up @@ -54,7 +55,7 @@ function add_ramping_constraints!(
model[:limit_units_on] = [
@constraint(
model,
row.units_on accumulated_units[row.year, row.asset],
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)
]
Expand Down
44 changes: 27 additions & 17 deletions src/create-model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1032,23 +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 A],
if a in decommissionable_assets_using_simple_method
accumulated_units_simple_method[y, a]
elseif a in decommissionable_assets_using_compact_method
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
sum(values(graph[a].initial_units[y]))
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 @@ -1133,6 +1141,7 @@ 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,
Expand Down Expand Up @@ -1223,6 +1232,7 @@ function create_model(
df_units_on,
dataframes[:highest_out],
outgoing_flow_highest_out_resolution,
accumulated_units_lookup,
accumulated_units,
Ai,
Auc,
Expand Down

0 comments on commit 053daaf

Please sign in to comment.