Skip to content

Commit

Permalink
Add an expression that covers both simple and compact methods (#800)
Browse files Browse the repository at this point in the history
  • Loading branch information
gnawin authored Sep 18, 2024
1 parent 4990590 commit 0fe4d8f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 24 deletions.
15 changes: 7 additions & 8 deletions src/constraints/capacity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ add_capacity_constraints!(model,
investable_assets_using_simple_method,
Asb,
assets_investment,
accumulate_capacity_simple_method,
accumulated_units_simple_method,
outgoing_flow_highest_out_resolution,
incoming_flow_highest_in_resolution
)
Expand All @@ -28,17 +28,15 @@ function add_capacity_constraints!(
decommissionable_assets_using_simple_method,
decommissionable_assets_using_compact_method,
V_all,
accumulated_set_using_compact_method_lookup,
Asb,
assets_investment,
accumulate_capacity_simple_method,
accumulate_capacity_compact_method,
accumulated_units_simple_method,
accumulated_units_compact_method,
accumulated_set_using_compact_method,
outgoing_flow_highest_out_resolution,
incoming_flow_highest_in_resolution,
)
compact_set_lookup = Dict(
(a, y, v) => idx for (idx, (a, y, v)) in enumerate(accumulated_set_using_compact_method)
)

## Expressions used by capacity constraints
# - Create capacity limit for outgoing flows
Expand All @@ -57,7 +55,7 @@ function add_capacity_constraints!(
1.0,
) * (
graph[row.asset].capacity *
accumulate_capacity_simple_method[row.year, row.asset]
accumulated_units_simple_method[row.year, row.asset]
)
)
elseif row.asset decommissionable_assets_using_compact_method
Expand All @@ -72,7 +70,8 @@ function add_capacity_constraints!(
("availability", row.rep_period),
row.timesteps_block,
1.0,
) * accumulate_capacity_compact_method[compact_set_lookup[(
) *
accumulated_units_compact_method[accumulated_set_using_compact_method_lookup[(
row.asset,
row.year,
v,
Expand Down
46 changes: 33 additions & 13 deletions src/create-model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,12 @@ function create_model(
))
]

# Create a lookup set for compact method
accumulated_set_using_compact_method_lookup = Dict(
(a, y, v) => idx for
(idx, (a, y, v)) in enumerate(accumulated_set_using_compact_method)
)

# Create subsets of storage assets
Ase = Dict(y => As filter_graph(graph, A, true, :storage_method_energy, y) for y in Y)
Asb = Dict(
Expand Down Expand Up @@ -984,11 +990,8 @@ function create_model(
@timeit to "multi-year investment" begin
@expression(
model,
accumulate_capacity_simple_method[
y Y,
a decommissionable_assets_using_simple_method,
],
graph[a].initial_units[y][y] + sum(
accumulated_units_simple_method[y Y, a decommissionable_assets_using_simple_method],
sum(values(graph[a].initial_units[y])) + sum(
assets_investment[yy, a] for
yy in Y if a investable_assets_using_simple_method[yy] &&
starting_year_using_simple_method[(y, a)] yy y
Expand All @@ -999,8 +1002,8 @@ function create_model(
)
cond1(a, y, v) = a in existing_assets_by_year_using_compact_method[v]
cond2(a, y, v) = v in Y && a in investable_assets_using_compact_method[v]
accumulate_capacity_compact_method =
model[:accumulate_capacity_compact_method] = JuMP.AffExpr[
accumulated_units_compact_method =
model[:accumulated_units_compact_method] = JuMP.AffExpr[
if cond1(a, y, v) && cond2(a, y, v)
@expression(
model,
Expand Down Expand Up @@ -1029,6 +1032,24 @@ 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_methoddecommissionable_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
)
end

## Expressions for the objective function
Expand All @@ -1044,13 +1065,11 @@ function create_model(
assets_fixed_cost = @expression(
model,
sum(
graph[a].fixed_cost[y] *
graph[a].capacity *
accumulate_capacity_simple_method[y, a] for y in Y for
graph[a].fixed_cost[y] * graph[a].capacity * accumulated_units_simple_method[y, a] for y in Y for
a in decommissionable_assets_using_simple_method
) + sum(
graph[a].fixed_cost[v] * graph[a].capacity * accm for (accm, (a, y, v)) in
zip(accumulate_capacity_compact_method, accumulated_set_using_compact_method)
zip(accumulated_units_compact_method, accumulated_set_using_compact_method)
)
)

Expand Down Expand Up @@ -1115,10 +1134,11 @@ function create_model(
decommissionable_assets_using_simple_method,
decommissionable_assets_using_compact_method,
V_all,
accumulated_set_using_compact_method_lookup,
Asb,
assets_investment,
accumulate_capacity_simple_method,
accumulate_capacity_compact_method,
accumulated_units_simple_method,
accumulated_units_compact_method,
accumulated_set_using_compact_method,
outgoing_flow_highest_out_resolution,
incoming_flow_highest_in_resolution,
Expand Down
6 changes: 3 additions & 3 deletions test/inputs/Multi-year Investments/graph-assets-data.csv
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
,{producer;consumer},{group name},{none;simple;compact},MW,year,
name,type,group,investment_method,capacity,technical_lifetime,discount_rate
ocgt,producer,,compact,100,15,0.05
ccgt,producer,,compact,400,25,0.05
ocgt,producer,,simple,100,15,0.05
ccgt,producer,,simple,400,25,0.05
wind,producer,,compact,50,30,0.05
solar,producer,,compact,10,15,0.05
solar,producer,,simple,10,15,0.05
ens,producer,,none,1115,15,0.05
demand,consumer,,none,0,15,0.05

0 comments on commit 0fe4d8f

Please sign in to comment.