-
Notifications
You must be signed in to change notification settings - Fork 54
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
Adding user-configurable slack type #239
Changes from 3 commits
f6d3e3b
0951839
9d6087a
8685416
8a4ed5e
386a128
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
uptime_downtime, startup_costs, \ | ||
services, power_balance, reserve_requirement, \ | ||
objective, fuel_supply, fuel_consumption, security_constraints | ||
from .uc_utils import SlackType | ||
from egret.model_library.transmission.tx_utils import scale_ModelData_to_pu | ||
from collections import namedtuple | ||
import pyomo.environ as pe | ||
|
@@ -37,7 +38,7 @@ | |
] | ||
) | ||
|
||
def generate_model( model_data, uc_formulation, relax_binaries=False, ptdf_options=None, PTDF_matrix_dict=None ): | ||
def generate_model( model_data, uc_formulation, relax_binaries=False, ptdf_options=None, PTDF_matrix_dict=None, slack_type=SlackType.BUS_BALANCE): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't the default slack type be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To maintain the existing behavior of Egret, this is the correct default. I can make the case for all three:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it. |
||
""" | ||
returns a UC uc_formulation as an abstract model with the | ||
components specified in a UCFormulation, with the option | ||
|
@@ -57,6 +58,10 @@ def generate_model( model_data, uc_formulation, relax_binaries=False, ptdf_optio | |
Dictionary of egret.data.ptdf_utils.PTDFMatrix objects for use in model construction. | ||
WARNING: Nearly zero checking is done on the consistency of this object with the | ||
model_data. Use with extreme caution! | ||
slack_type : SlackType, optional | ||
Types of slacks to use in the unit commitment model. By default, | ||
a global load/generation mismatch slack is placed at the reference | ||
bus and all transmission limits are enforced with soft constraints. | ||
|
||
Returns | ||
------- | ||
|
@@ -66,7 +71,7 @@ def generate_model( model_data, uc_formulation, relax_binaries=False, ptdf_optio | |
|
||
md = model_data.clone_in_service() | ||
scale_ModelData_to_pu(md, inplace=True) | ||
return _generate_model( md, *_get_formulation_from_UCFormulation( uc_formulation ), relax_binaries , ptdf_options, PTDF_matrix_dict ) | ||
return _generate_model( md, *_get_formulation_from_UCFormulation( uc_formulation ), relax_binaries , ptdf_options, PTDF_matrix_dict, slack_type ) | ||
|
||
def _generate_model( model_data, | ||
_status_vars, | ||
|
@@ -84,6 +89,7 @@ def _generate_model( model_data, | |
_relax_binaries = False, | ||
_ptdf_options = None, | ||
_PTDF_matrix_dict = None, | ||
_slack_type = SlackType.TRANSMISSION_LIMITS, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct default? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should match above, I agree. |
||
): | ||
|
||
model = pe.ConcreteModel() | ||
|
@@ -114,7 +120,7 @@ def _generate_model( model_data, | |
## to relax binaries | ||
model.relax_binaries = _relax_binaries | ||
|
||
params.load_params(model, model_data) | ||
params.load_params(model, model_data, _slack_type) | ||
getattr(status_vars, _status_vars)(model) | ||
getattr(power_vars, _power_vars)(model) | ||
getattr(reserve_vars, _reserve_vars)(model) | ||
|
@@ -126,7 +132,7 @@ def _generate_model( model_data, | |
getattr(startup_costs, _startup_costs)(model) | ||
services.storage_services(model) | ||
services.ancillary_services(model) | ||
getattr(power_balance, _power_balance)(model) | ||
getattr(power_balance, _power_balance)(model, _slack_type) | ||
getattr(reserve_requirement, _reserve_requirement)(model) | ||
|
||
if 'fuel_supply' in model_data.data['elements'] and bool(model_data.data['elements']['fuel_supply']): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should have some sort of options or configuration object to control whether or nor things like slacks get added rather than inferring it from what is in the data dict. If someone wants to solve with slacks and then without, they have to modify the data dict. Perhaps more importantly, it looks like slacks will get added even if
slack_type == SlackType.NONE
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The existing behavior (in main) allows the user to add slacks to any transmission line by setting the
violation_penalty
to something other thanNone
.Perhaps
slack_type == SlackType.NONE
should override theviolation_penalties
set for the individual branches? And we leave them alone if theslack_type
is anything else?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it should also be noted that in the case that somebody wants to solve with slacks and without: provided they don't set individual
violation_penalty
attributes on a branch, no update to the data dictionary is required. They can optionally set thetransmission_flow_violation_cost
system attribute to set the system-wide transmission violation cost.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would be fine with that. We could also raise an error if
slack_type == SlackType.NONE
andviolation_penalties
are specified.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opted to ignore the
violation_penalty
and issue a warning. That seems to be most common for data incongruities in Egret, probably because its my preference, and I think Egret chooses reasonable defaults which saves the user time if they don't otherwise need to modify their inputs.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. Thanks.