Skip to content

Commit 73a5ddc

Browse files
committed
Add lower bound for incoming transport flows
1 parent 9aa7ce9 commit 73a5ddc

File tree

4 files changed

+56
-1
lines changed

4 files changed

+56
-1
lines changed

src/constraints/capacity.jl

+23-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,9 @@ function add_capacity_constraints!(connection, model, expressions, constraints,
356356
cons_name = Symbol("min_output_flows_limit_for_transport_flows_without_unit_commitment")
357357
table_name = :min_outgoing_flow_for_transport_flows_without_unit_commitment
358358

359-
# - Maximum input flows limit
359+
# - Minmum output flows limit if any of the flows is transport flow
360+
# - This allows negative flows but not all negative flows, so flows can pass through this asset
361+
# - Holds for producers, conversion and storage assets
360362
attach_constraint!(
361363
model,
362364
constraints[table_name],
@@ -371,6 +373,26 @@ function add_capacity_constraints!(connection, model, expressions, constraints,
371373
],
372374
)
373375

376+
# - Minmum input flows limit if any of the flows is transport flow
377+
# - This allows negative flows but not all negative flows, so flows can pass through this asset
378+
# - Holds for onversion and storage assets
379+
cons_name = Symbol("min_input_flows_limit_for_transport_flows")
380+
table_name = :min_incoming_flow_for_transport_flows
381+
382+
attach_constraint!(
383+
model,
384+
constraints[table_name],
385+
cons_name,
386+
[
387+
@constraint(
388+
model,
389+
incoming_flow 0,
390+
base_name = "$cons_name[$(row.asset),$(row.year),$(row.rep_period),$(row.time_block_start):$(row.time_block_end)]"
391+
) for (row, incoming_flow) in
392+
zip(constraints[table_name].indices, constraints[table_name].expressions[:incoming])
393+
],
394+
)
395+
374396
return
375397
end
376398

src/constraints/create.jl

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function compute_constraints_indices(connection)
1717
:capacity_outgoing_simple_method_non_investable_storage_with_binary,
1818
:capacity_outgoing_simple_method_investable_storage_with_binary,
1919
:min_outgoing_flow_for_transport_flows_without_unit_commitment,
20+
:min_incoming_flow_for_transport_flows,
2021
:limit_units_on_compact_method,
2122
:limit_units_on_simple_method,
2223
:min_output_flow_with_unit_commitment,

src/model-preparation.jl

+1
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ function add_expressions_to_constraints!(connection, variables, constraints)
532532
:capacity_outgoing_simple_method_non_investable_storage_with_binary,
533533
:capacity_outgoing_simple_method_investable_storage_with_binary,
534534
:min_outgoing_flow_for_transport_flows_without_unit_commitment,
535+
:min_incoming_flow_for_transport_flows,
535536
)
536537
@timeit to "add_expression_terms_rep_period_constraints! for $table_name" add_expression_terms_rep_period_constraints!(
537538
connection,

src/sql/create-constraints.sql

+31
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,37 @@ where
227227
drop sequence id
228228
;
229229

230+
create sequence id start 1
231+
;
232+
233+
create table cons_min_incoming_flow_for_transport_flows as
234+
235+
with transport_flow_info as (
236+
select
237+
asset.asset,
238+
coalesce(
239+
(select bool_or(flow.is_transport)
240+
from flow
241+
where flow.to_asset = asset.asset),
242+
false
243+
) as incoming_flows_have_transport_flows,
244+
from asset
245+
)
246+
select
247+
nextval('id') as id,
248+
t_high.*
249+
from
250+
t_highest_out_flows as t_high
251+
left join asset on t_high.asset = asset.asset
252+
left join transport_flow_info on t_high.asset = transport_flow_info.asset
253+
where
254+
asset.type in ('storage', 'conversion')
255+
and transport_flow_info.incoming_flows_have_transport_flows
256+
;
257+
258+
drop sequence id
259+
;
260+
230261
create table cons_limit_units_on_compact_method as
231262
select
232263
*

0 commit comments

Comments
 (0)