-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optionally allow slack flows in first timepoint of linear horizons (#…
…1196) This can help avoid infeasibilities in the first timepoint of linear horizons when flows have not yet reached a particular node, making it impossible to meet a minimum flow constraint. This problem could arise in later timepoints too; slack is currently only allowed in the first timepoint of the horizon (if enabled by the user).
- Loading branch information
Showing
14 changed files
with
305 additions
and
81 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
db/csvs_test_examples/water/water_system_params/1_base_water_system_params.csv
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
water_system_balancing_type,theoretical_power_coefficient | ||
day,84.7 | ||
water_system_balancing_type,theoretical_power_coefficient,allow_lin_hrz_first_tmp_flow_slack,allow_lin_hrz_first_tmp_flow_slack_tuning_cost | ||
day,84.7,0,0 |
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
4 changes: 2 additions & 2 deletions
4
examples/hydro_system_exog_elev/hydro_iteration_1/inputs/water_system_params.tab
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
water_system_balancing_type theoretical_power_coefficient | ||
day 84.7 | ||
water_system_balancing_type theoretical_power_coefficient allow_lin_hrz_first_tmp_flow_slack allow_lin_hrz_first_tmp_flow_slack_tuning_cost | ||
day 84.7 0.0 0.0 |
4 changes: 2 additions & 2 deletions
4
...les/hydro_system_exog_elev_w_travel_time/hydro_iteration_1/inputs/water_system_params.tab
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
water_system_balancing_type theoretical_power_coefficient | ||
day 84.7 | ||
water_system_balancing_type theoretical_power_coefficient allow_lin_hrz_first_tmp_flow_slack allow_lin_hrz_first_tmp_flow_slack_tuning_cost | ||
day 84.7 0.0 0.0 |
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
Empty file.
71 changes: 71 additions & 0 deletions
71
gridpath/objective/system/water/aggregate_flow_constraint_slack_use_tuning_costs.py
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,71 @@ | ||
# Copyright 2016-2024 Blue Marble Analytics LLC. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
from pyomo.environ import Param, Expression | ||
|
||
from gridpath.auxiliary.dynamic_components import cost_components | ||
|
||
|
||
def add_model_components( | ||
m, | ||
d, | ||
scenario_directory, | ||
weather_iteration, | ||
hydro_iteration, | ||
availability_iteration, | ||
subproblem, | ||
stage, | ||
): | ||
""" | ||
:param m: | ||
:param d: | ||
:return: | ||
""" | ||
|
||
def total_flow_constraint_slack_tuning_cost_rule(mod): | ||
""" | ||
Ramp tuning costs for all projects | ||
:param mod: | ||
:return: | ||
""" | ||
return sum( | ||
mod.Water_Link_Flow_Rate_Vol_per_Sec_LinHrzFirstTmpSlack[wl, tmp] | ||
* mod.allow_lin_hrz_first_tmp_flow_slack_tuning_cost | ||
* mod.hrs_in_tmp[tmp] | ||
* mod.tmp_weight[tmp] | ||
* mod.number_years_represented[mod.period[tmp]] | ||
* mod.discount_factor[mod.period[tmp]] | ||
for wl in mod.WATER_LINKS | ||
for tmp in mod.TMPS | ||
) | ||
|
||
m.Total_Flow_Constraint_Slack_Tuning_Cost = Expression( | ||
rule=total_flow_constraint_slack_tuning_cost_rule | ||
) | ||
|
||
record_dynamic_components(dynamic_components=d) | ||
|
||
|
||
def record_dynamic_components(dynamic_components): | ||
""" | ||
:param dynamic_components: | ||
Add tuning costs to cost components | ||
""" | ||
|
||
getattr(dynamic_components, cost_components).append( | ||
"Total_Flow_Constraint_Slack_Tuning_Cost" | ||
) |
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
Oops, something went wrong.