-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce user_constraint_slack_penalty
Re #781
- Loading branch information
Showing
10 changed files
with
254 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
############################################################################# | ||
# Copyright (C) 2017 - 2023 Spine Project | ||
# | ||
# This file is part of SpineOpt. | ||
# | ||
# SpineOpt is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Lesser General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# SpineOpt is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
############################################################################# | ||
|
||
""" | ||
user_constraint_slack_indices(filtering_options...) | ||
""" | ||
function user_constraint_slack_indices( | ||
m::Model; | ||
user_constraint=anything, | ||
stochastic_scenario=anything, | ||
t=anything, | ||
temporal_block=temporal_block(representative_periods_mapping=nothing), | ||
) | ||
inds = NamedTuple{(:user_constraint, :stochastic_scenario, :t),Tuple{Object,Object,TimeSlice}}[ | ||
(user_constraint=uc, stochastic_scenario=ind.stochastic_scenario, t=ind.t) | ||
for uc in indices(user_constraint_slack_penalty; user_constraint=user_constraint) | ||
for inds in user_constraint_all_indices( | ||
m; user_constraint=uc, stochastic_scenario=stochastic_scenario, t=t, temporal_block=temporal_block | ||
) | ||
for ind in inds | ||
] | ||
unique!(inds) | ||
end | ||
|
||
""" | ||
add_variable_user_constraint_slack_pos!(m::Model) | ||
""" | ||
function add_variable_user_constraint_slack_pos!(m::Model) | ||
add_variable!(m, :user_constraint_slack_pos, user_constraint_slack_indices; lb=Constant(0)) | ||
end | ||
|
||
""" | ||
add_variable_user_constraint_slack_neg!(m::Model) | ||
""" | ||
function add_variable_user_constraint_slack_neg!(m::Model) | ||
add_variable!(m, :user_constraint_slack_neg, user_constraint_slack_indices; lb=Constant(0)) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.