Skip to content

Commit fcec62d

Browse files
authored
Fix trvial spottings (#1197)
* remove the obsolete graph_view_position parameter * add missing `kwargs...` to function `unit_flow_ub` * include missing unit-tests * fix typo * avoid compare explicitly defined candidate_units with zero
1 parent 2f12e41 commit fcec62d

File tree

4 files changed

+15
-24
lines changed

4 files changed

+15
-24
lines changed

src/data_structure/preprocess_data_structure.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -908,8 +908,7 @@ function generate_unit_commitment_parameters()
908908
indices(units_on_cost),
909909
indices(units_on_non_anticipativity_time),
910910
indices(fix_units_on),
911-
(u for u in indices(candidate_units) if candidate_units(unit=u) > 0),
912-
(x.unit for x in indices(units_on_coefficient) if units_on_coefficient(; x...) != 0),
911+
(u for u in indices(candidate_units) if is_candidate(unit=u)),
913912
(x.unit for x in indices(minimum_operating_point) if minimum_operating_point(; x...) != 0),
914913
(x.unit for x in indices(ramp_up_limit)),
915914
(x.unit for x in indices(ramp_down_limit)),

src/variables/variable_unit_flow.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ end
5151

5252
function unit_flow_ub(m; unit, node, direction, kwargs...)
5353
(
54-
realize(unit_flow_capacity(m; unit=unit, node=node, direction=direction, _strict=false)) === nothing
54+
realize(unit_flow_capacity(m; unit=unit, node=node, direction=direction, kwargs..., _strict=false)) === nothing
5555
|| has_online_variable(unit=unit)
5656
|| members(node) != [node]
5757
) && return NaN

templates/spineopt_template.json

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@
173173
["connection", "connection_discount_rate_technology_specific", 0.0 , null, "connection-specific discount rate used to calculate the connection's investment costs. If not specified, the model discount rate is used."],
174174
["connection", "fix_connections_invested", null, null, "Setting a value fixes the connections_invested variable accordingly"],
175175
["connection", "fix_connections_invested_available", null, null, "Setting a value fixes the connections_invested_available variable accordingly"],
176-
["connection", "graph_view_position", null, null, "An optional setting for tweaking the position of the different elements when drawing them via Spine Toolbox Graph View."],
177176
["connection", "has_binary_gas_flow", false, "boolean_value_list", "This parameter needs to be set to `true` in order to represent bidirectional pressure drive gas transfer."],
178177
["connection", "initial_connections_invested", null, null, "Setting a value fixes the connections_invested variable at the beginning"],
179178
["connection", "initial_connections_invested_available", null, null, "Setting a value fixes the connections_invested_available variable at the beginning"],
@@ -226,7 +225,6 @@
226225
["node", "fix_storages_invested_available", null, null, "Used to fix the value of the storages_invested_available variable"],
227226
["node", "frac_state_loss", 0.0, null, "Self-discharge coefficient for `node_state` variables. Effectively, represents the *loss power per unit of state*."],
228227
["node", "fractional_demand", 0.0, null, "The fraction of a `node` group's `demand` applied for the `node` in question."],
229-
["node", "graph_view_position", null, null, "An optional setting for tweaking the position of the different elements when drawing them via Spine Toolbox Graph View."],
230228
["node", "has_pressure", false, "boolean_value_list", "A boolean flag for whether a `node` has a `node_pressure` variable."],
231229
["node", "has_state", false, "boolean_value_list", "A boolean flag for whether a `node` has a `node_state` variable."],
232230
["node", "has_voltage_angle", false, "boolean_value_list", "A boolean flag for whether a `node` has a `node_voltage_angle` variable."],
@@ -289,7 +287,6 @@
289287
["unit", "fix_units_on", null, null, "Fix the value of the `units_on` variable."],
290288
["unit", "fix_units_out_of_service", null, null, "Fix the value of the `units_out_of_service` variable."],
291289
["unit", "fom_cost", null, null, "Fixed operation and maintenance costs of a `unit`. Essentially, a cost coefficient on the existing units (incl. `number_of_units` and `units_invested_available`) and `unit_capacity` parameters. Currently, the value needs to be defined per duration unit (i.e. 1 hour), E.g. EUR/MW/h"],
292-
["unit", "graph_view_position", null, null, "An optional setting for tweaking the position of the different elements when drawing them via Spine Toolbox Graph View."],
293290
["unit", "initial_units_invested", null, null, "Initialize the value of the `units_invested` variable."],
294291
["unit", "initial_units_invested_available", null, null, "Initialize the value of the `units_invested_available` variable"],
295292
["unit", "initial_units_on", null, null, "Initialize the value of the `units_on` variable."],
@@ -336,7 +333,6 @@
336333
["connection__from_node", "fix_binary_gas_connection_flow", null, null, "Fix the value of the `connection_flow_binary` variable, and hence pre-determine the direction of flow in the connection."],
337334
["connection__from_node", "fix_connection_flow", null, null, "Fix the value of the `connection_flow` variable."],
338335
["connection__from_node", "fix_connection_intact_flow", null, null, "Fix the value of the `connection_intact_flow` variable."],
339-
["connection__from_node", "graph_view_position", null, null, "An optional setting for tweaking the position of the different elements when drawing them via Spine Toolbox Graph View."],
340336
["connection__from_node", "initial_binary_gas_connection_flow", null, null, "Initialize the value of the `connection_flow_binary` variable, and hence pre-determine the direction of flow in the connection."],
341337
["connection__from_node", "initial_connection_flow", null, null, "Initialize the value of the `connection_flow` variable."],
342338
["connection__from_node", "initial_connection_intact_flow", null, null, "Initialize the value of the `connection_intact_flow` variable."],
@@ -360,7 +356,6 @@
360356
["connection__to_node", "fix_binary_gas_connection_flow", null, null, "Fix the value of the `connection_flow_binary` variable, and hence pre-determine the direction of flow in the connection."],
361357
["connection__to_node", "fix_connection_flow", null, null, "Fix the value of the `connection_flow` variable."],
362358
["connection__to_node", "fix_connection_intact_flow", null, null, "Fix the value of the `connection_intact_flow` variable."],
363-
["connection__to_node", "graph_view_position", null, null, "An optional setting for tweaking the position of the different elements when drawing them via Spine Toolbox Graph View."],
364359
["connection__to_node", "initial_binary_gas_connection_flow", null, null, "Initialize the value of the `connection_flow_binary` variable, and hence pre-determine the direction of flow in the connection."],
365360
["connection__to_node", "initial_connection_flow", null, null, "Initialize the value of the `connection_flow` variable."],
366361
["connection__to_node", "initial_connection_intact_flow", null, null, "Initialize the value of the `connection_intact_flow` variable."],
@@ -389,7 +384,6 @@
389384
["unit__from_node", "fix_unit_flow", null, null, "Fix the `unit_flow` variable."],
390385
["unit__from_node", "fix_unit_flow_op", null, null, "Fix the `unit_flow_op` variable."],
391386
["unit__from_node", "fuel_cost", null, null, "Variable fuel costs than can be attributed to a `unit_flow`. E.g. EUR/MWh"],
392-
["unit__from_node", "graph_view_position", null, null, "An optional setting for tweaking the position of the different elements when drawing them via Spine Toolbox Graph View."],
393387
["unit__from_node", "initial_nonspin_units_started_up", null, null, "Initialize the `nonspin_units_started_up` variable."],
394388
["unit__from_node", "initial_unit_flow", null, null, "Initialize the `unit_flow` variable."],
395389
["unit__from_node", "initial_unit_flow_op", null, null, "Initialize the `unit_flow_op` variable."],
@@ -409,7 +403,6 @@
409403
["unit__from_node", "unit_flow_non_anticipativity_margin", null, null, "Margin by which `unit_flow` variable can differ from the value in the previous window during `non_anticipativity_time`."],
410404
["unit__from_node", "unit_flow_non_anticipativity_time", null, null, "Period of time where the value of the `unit_flow` variable has to be fixed to the result from the previous window."],
411405
["unit__from_node", "vom_cost", null, null, "Variable operating costs of a `unit_flow` variable. E.g. EUR/MWh."],
412-
["unit__from_node__user_constraint", "graph_view_position", null, null, "An optional setting for tweaking the position of the different elements when drawing them via Spine Toolbox Graph View."],
413406
["unit__from_node__user_constraint", "unit_flow_coefficient", 0.0, null, "Coefficient of a `unit_flow` variable for a custom `user_constraint`."],
414407
["unit__node__node", "fix_ratio_in_in_unit_flow", null, null, "Fix the ratio between two `unit_flows` coming into the `unit` from the two `nodes`."],
415408
["unit__node__node", "fix_ratio_in_out_unit_flow", null, null, "Fix the ratio between an incoming `unit_flow` from the first `node` and an outgoing `unit_flow` to the second `node`."],
@@ -441,7 +434,6 @@
441434
["unit__to_node", "fix_unit_flow", null, null, "Fix the `unit_flow` variable."],
442435
["unit__to_node", "fix_unit_flow_op", null, null, "Fix the `unit_flow_op` variable."],
443436
["unit__to_node", "fuel_cost", null, null, "Variable fuel costs than can be attributed to a `unit_flow`. E.g. EUR/MWh"],
444-
["unit__to_node", "graph_view_position", null, null, "An optional setting for tweaking the position of the different elements when drawing them via Spine Toolbox Graph View."],
445437
["unit__to_node", "initial_nonspin_units_shut_down", null, null, "Initialize the `nonspin_units_shut_down` variable."],
446438
["unit__to_node", "initial_nonspin_units_started_up", null, null, "Initialize the `nonspin_units_started_up` variable."],
447439
["unit__to_node", "initial_unit_flow", null, null, "Initialize the `unit_flow` variable."],
@@ -462,7 +454,6 @@
462454
["unit__to_node", "unit_flow_non_anticipativity_margin", null, null, "Margin by which `unit_flow` variable can differ from the value in the previous window during `non_anticipativity_time`."],
463455
["unit__to_node", "unit_flow_non_anticipativity_time", null, null, "Period of time where the value of the `unit_flow` variable has to be fixed to the result from the previous window."],
464456
["unit__to_node", "vom_cost", null, null, "Variable operating costs of a `unit_flow` variable. E.g. EUR/MWh."],
465-
["unit__to_node__user_constraint", "graph_view_position", null, null, "An optional setting for tweaking the position of the different elements when drawing them via Spine Toolbox Graph View."],
466457
["unit__to_node__user_constraint", "unit_flow_coefficient", 0.0, null, "Coefficient of a `unit_flow` variable for a custom `user_constraint`."],
467458
["unit__user_constraint", "units_invested_available_coefficient",0.0 , null, "Coefficient of the `units_invested_available` variable in the specified `user_constraint`."],
468459
["unit__user_constraint", "units_invested_coefficient", 0.0, null, "Coefficient of the `units_invested` variable in the specified `user_constraint`."],

test/variables/variables.jl

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ function test_connection_history_parameters()
290290
end
291291
end
292292

293-
function test_fix_ratio_unit_flow_simple_setup(m_start, m_end)
293+
function _test_fix_ratio_unit_flow_simple_setup(m_start, m_end)
294294
url_in = "sqlite://"
295295
test_data = Dict(
296296
:objects => [
@@ -330,7 +330,7 @@ function test_unit_flow_simple_bounds()
330330
m_end = m_start + Hour(2)
331331
fruf = 0.8
332332
cap_to_node = 200
333-
url_in = test_fix_ratio_unit_flow_simple_setup(m_start, m_end)
333+
url_in = _test_fix_ratio_unit_flow_simple_setup(m_start, m_end)
334334
obj_pvals = [
335335
["unit", "unit_ab", "online_variable_type", "unit_online_variable_type_linear"],
336336
]
@@ -365,7 +365,7 @@ function test_fix_ratio_out_in_unit_flow_simple()
365365
fruf = 0.8
366366
fuoc = 1.25
367367
usf = 2.4
368-
url_in = test_fix_ratio_unit_flow_simple_setup(m_start, m_end)
368+
url_in = _test_fix_ratio_unit_flow_simple_setup(m_start, m_end)
369369
rel_pvals = [
370370
["unit__node__node", ["unit_ab", "node_b", "node_a"], "fix_ratio_out_in_unit_flow", fruf],
371371
["unit__node__node", ["unit_ab", "node_b", "node_a"], "fix_units_on_coefficient_out_in", fuoc],
@@ -403,7 +403,7 @@ function test_fix_ratio_in_out_unit_flow_simple()
403403
fruf = 0.8
404404
fuoc = 1.25
405405
usf = 2.4
406-
url_in = test_fix_ratio_unit_flow_simple_setup(m_start, m_end)
406+
url_in =_test_fix_ratio_unit_flow_simple_setup(m_start, m_end)
407407
rel_pvals = [
408408
["unit__node__node", ["unit_ab", "node_a", "node_b"], "fix_ratio_in_out_unit_flow", fruf],
409409
["unit__node__node", ["unit_ab", "node_a", "node_b"], "fix_units_on_coefficient_in_out", fuoc],
@@ -440,7 +440,7 @@ function test_two_fix_ratio_out_in_unit_flow_simple()
440440
m_end = m_start + Hour(2)
441441
fruf = 0.8
442442
fruf2 = 0.6
443-
url_in = test_fix_ratio_unit_flow_simple_setup(m_start, m_end)
443+
url_in =_test_fix_ratio_unit_flow_simple_setup(m_start, m_end)
444444
objs = [["node", "node_b2"]]
445445
rels = [
446446
["unit__to_node", ["unit_ab", "node_b2"]],
@@ -474,7 +474,7 @@ function test_two_fix_ratio_in_out_unit_flow_simple()
474474
m_end = m_start + Hour(2)
475475
fruf = 0.8
476476
fruf2 = 0.6
477-
url_in = test_fix_ratio_unit_flow_simple_setup(m_start, m_end)
477+
url_in =_test_fix_ratio_unit_flow_simple_setup(m_start, m_end)
478478
objs = [["node", "node_a2"]]
479479
rels = [
480480
["unit__from_node", ["unit_ab", "node_a2"]],
@@ -508,7 +508,7 @@ function test_fix_ratio_out_in_and_in_out_unit_flow_simple()
508508
m_end = m_start + Hour(2)
509509
fruf = 0.8
510510
fruf2 = 0.9
511-
url_in = test_fix_ratio_unit_flow_simple_setup(m_start, m_end)
511+
url_in =_test_fix_ratio_unit_flow_simple_setup(m_start, m_end)
512512
objs = [["node", "node_b2"]]
513513
rels = [
514514
["unit__to_node", ["unit_ab", "node_b2"]],
@@ -544,7 +544,7 @@ function test_two_fix_ratio_out_in_and_one_out_out_unit_flow_simple()
544544
fruf = 0.8
545545
fruf2 = 0.6
546546
froouf = 0.5
547-
url_in = test_fix_ratio_unit_flow_simple_setup(m_start, m_end)
547+
url_in =_test_fix_ratio_unit_flow_simple_setup(m_start, m_end)
548548
objs = [["node", "node_b2"], ["node", "node_b3"]]
549549
rels = [
550550
["unit__to_node", ["unit_ab", "node_b2"]],
@@ -585,7 +585,7 @@ function test_fix_ratio_out_in_unit_flow_simple_rolling()
585585
stamps = [m_start, m_start + Hour(1)]
586586
fruf = unparse_db_value(TimeSeries(stamps, fruf_values))
587587
fuoc = unparse_db_value(TimeSeries(stamps, fuoc_values))
588-
url_in = test_fix_ratio_unit_flow_simple_setup(m_start, m_end)
588+
url_in = _test_fix_ratio_unit_flow_simple_setup(m_start, m_end)
589589
obj_pvals = [("model", "instance", "roll_forward", unparse_db_value(Hour(1)))]
590590
rel_pvals = [
591591
["unit__node__node", ["unit_ab", "node_b", "node_a"], "fix_ratio_out_in_unit_flow", fruf],
@@ -622,7 +622,7 @@ function test_fix_ratio_out_in_unit_flow_simple_rolling()
622622
end
623623
end
624624

625-
function test_fix_ratio_connection_flow_simple_setup(m_start, m_end)
625+
function _test_fix_ratio_connection_flow_simple_setup(m_start, m_end)
626626
url_in = "sqlite://"
627627
test_data = Dict(
628628
:objects => [
@@ -660,7 +660,7 @@ function test_fix_ratio_out_in_connection_flow_simple()
660660
m_start = DateTime(2000, 1, 1, 0)
661661
m_end = m_start + Hour(2)
662662
frcf = 0.8
663-
url_in = test_fix_ratio_connection_flow_simple_setup(m_start, m_end)
663+
url_in = _test_fix_ratio_connection_flow_simple_setup(m_start, m_end)
664664
rel_pvals = [
665665
["connection__node__node", ["conn_ab", "node_b", "node_a"], "fix_ratio_out_in_connection_flow", frcf],
666666
]
@@ -689,7 +689,7 @@ function test_fix_ratio_out_in_connection_flow_simple_rolling()
689689
frcf_values = [0.8, 0.9]
690690
stamps = [m_start, m_start + Hour(1)]
691691
frcf = unparse_db_value(TimeSeries(stamps, frcf_values))
692-
url_in = test_fix_ratio_connection_flow_simple_setup(m_start, m_end)
692+
url_in = _test_fix_ratio_connection_flow_simple_setup(m_start, m_end)
693693
obj_pvals = [("model", "instance", "roll_forward", unparse_db_value(Hour(1)))]
694694
rel_pvals = [
695695
["connection__node__node", ["conn_ab", "node_b", "node_a"], "fix_ratio_out_in_connection_flow", frcf],
@@ -734,6 +734,7 @@ end
734734
test_unit_online_variable_type_none()
735735
test_unit_history_parameters()
736736
test_connection_history_parameters()
737+
test_unit_flow_simple_bounds()
737738
test_fix_ratio_out_in_unit_flow_simple()
738739
test_fix_ratio_in_out_unit_flow_simple()
739740
test_two_fix_ratio_out_in_unit_flow_simple()

0 commit comments

Comments
 (0)