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

Changed the default number of units based on is_candidate. #1036

Merged
merged 8 commits into from
Nov 26, 2024
4 changes: 3 additions & 1 deletion src/constraints/constraint_units_available.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ function _build_constraint_units_available(m, u, s, t)
init=0,
)
<=
+ number_of_units(m; unit=u, stochastic_scenario=s, t=t)
# Change the default number of units so that it is zero when candidate units are present
# and otherwise 1.
+ ifelse(is_candidate(unit=u), 0, number_of_units(m; unit=u, stochastic_scenario=s, t=t) )
Copy link
Collaborator

@manuelma manuelma Sep 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this disallow having both number_of_units and candidate_units different than zero? It looks like if the user specifies candidate_units different than zero then any non zero value for number_of_units is just ignored? Or I am missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. Now I tried to correct it.

- units_unavailable(m; unit=u, stochastic_scenario=s, t=t)
)
end
Expand Down
2 changes: 1 addition & 1 deletion templates/spineopt_template.json
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@
["unit", "is_renewable", false, "boolean_value_list", "Whether the unit is renewable - used in the minimum renewable generation constraint within the Benders master problem"],
["unit", "min_down_time", null, null, "Minimum downtime of a `unit` after it shuts down."],
["unit", "min_up_time", null, null, "Minimum uptime of a `unit` after it starts up."],
["unit", "number_of_units", 1.0, null, "Denotes the number of 'sub units' aggregated to form the modelled `unit`."],
["unit", "number_of_units", 1.0, null, "Denotes the number of 'sub units' aggregated to form the modelled `unit`. The default value becomes zero if `candidate_units` has been defined."],
["unit", "online_variable_type", "unit_online_variable_type_linear", "unit_online_variable_type_list", "A selector for how the `units_on` variable is represented within the model."],
["unit", "outage_variable_type", "unit_online_variable_type_none", "unit_online_variable_type_list", "Determines whether the outage variable is integer or continuous or none(no optimisation of maintenance outages)."],
["unit", "scheduled_outage_duration", null, null, "Specifies the amount of time a unit must be out of service for maintenance as a single block over the course of the optimisation window"],
Expand Down
6 changes: 4 additions & 2 deletions test/constraints/constraint_unit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ function test_constraint_units_available()
@testset "constraint_units_available" begin
url_in = _test_constraint_unit_setup()
number_of_units = 4
number_of_units_when_candidates_units = 0
candidate_units = 3
unit_availability_factor = 0.5
object_parameter_values = [
Expand All @@ -147,7 +148,7 @@ function test_constraint_units_available()
key = (unit(:unit_ab), s, t)
var_u_on = var_units_on[key...]
var_u_inv_av = var_units_invested_available[key...]
expected_con = @build_constraint(var_u_on <= number_of_units + var_u_inv_av)
expected_con = @build_constraint(var_u_on <= number_of_units_when_candidates_units + var_u_inv_av)
con_key = (unit(:unit_ab), s, t)
con = constraint[con_key...]
observed_con = constraint_object(con)
Expand All @@ -160,6 +161,7 @@ function test_constraint_units_available_units_unavailable()
url_in = _test_constraint_unit_setup()
number_of_units = 4
candidate_units = 3
number_of_units_when_candidates_units = ifelse(candidate_units == 0, number_of_units, 0)
units_unavailable = 1
unit_availability_factor = 0.5
object_parameter_values = [
Expand All @@ -184,7 +186,7 @@ function test_constraint_units_available_units_unavailable()
key = (unit(:unit_ab), s, t)
var_u_on = var_units_on[key...]
var_u_inv_av = var_units_invested_available[key...]
expected_con = @build_constraint(var_u_on <= number_of_units + var_u_inv_av - units_unavailable)
expected_con = @build_constraint(var_u_on <= number_of_units_when_candidates_units + var_u_inv_av - units_unavailable)
con_key = (unit(:unit_ab), s, t)
con = constraint[con_key...]
observed_con = constraint_object(con)
Expand Down
Loading