-
Notifications
You must be signed in to change notification settings - Fork 1
[WIP] Add event models #163
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
Draft
acostarelli
wants to merge
1
commit into
ac/sienna1-port
Choose a base branch
from
ac/event-model
base: ac/sienna1-port
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,65 @@ | ||
| # Build-time contingency-event helpers: parameter defaults and the EventParameter | ||
| # parameter-container path. Ported from PowerSimulations.jl `src/contingency_model/`, | ||
| # adapted to POM's type-based accessor conventions and IOM-qualified container internals. | ||
|
|
||
| # The EventParameter outage constraint (IOM `range_constraint.jl`) bounds dispatch by | ||
| # `get_max_active_power(device) * AvailableStatusParameter`. POM supplies the value. | ||
| get_max_active_power(d::PSY.Device) = PSY.get_max_active_power(d, PSY.SU) | ||
|
|
||
| #! format: off | ||
| # These values could change depending on the event modeling choices. | ||
| get_parameter_multiplier(::EventParameter, ::PSY.Device, ::EventModel) = 1.0 | ||
| get_initial_parameter_value(::ActivePowerOffsetParameter, ::PSY.Device, ::EventModel) = 0.0 | ||
| get_initial_parameter_value(::ReactivePowerOffsetParameter, ::PSY.Device, ::EventModel) = 0.0 | ||
| get_initial_parameter_value(::AvailableStatusChangeCountdownParameter, ::PSY.Device, ::EventModel) = 0.0 | ||
| get_initial_parameter_value(::AvailableStatusParameter, ::PSY.Device, ::EventModel) = 1.0 | ||
| #! format: on | ||
|
|
||
| function _add_parameters!( | ||
| container::OptimizationContainer, | ||
| ::Type{T}, | ||
| devices::Vector{U}, | ||
| device_model::DeviceModel{U, W}, | ||
| event_model::EventModel{V, X}, | ||
| ) where { | ||
| T <: EventParameter, | ||
| U <: PSY.Component, | ||
| V <: PSY.Contingency, | ||
| W <: AbstractDeviceFormulation, | ||
| X <: AbstractEventCondition, | ||
| } | ||
| @debug "adding" T U V _group = IOM.LOG_GROUP_OPTIMIZATION_CONTAINER | ||
| time_steps = get_time_steps(container) | ||
| names = PSY.get_name.(devices) | ||
| # The contingency type is build-time metadata only; the optimization container keys | ||
| # the parameter by the device type for both the `ParameterKey` and `affected_devices`. | ||
| parameter_container = add_param_container!(container, T, U, U, names, time_steps) | ||
|
|
||
| jump_model = get_jump_model(container) | ||
| parent_mult = IOM.get_multiplier_array_data(parameter_container) | ||
| parent_param = IOM.get_parameter_array_data(parameter_container) | ||
|
|
||
| for (i, d) in enumerate(devices) | ||
| ini_val = get_initial_parameter_value(T(), d, event_model) | ||
| IOM._set_multiplier_at!( | ||
| parent_mult, | ||
| get_parameter_multiplier(T(), d, event_model), | ||
| i, | ||
| ) | ||
| for t in time_steps | ||
| IOM._set_parameter_at!(parent_param, jump_model, ini_val, i, t) | ||
| end | ||
| end | ||
| return | ||
| end | ||
|
|
||
| function add_parameters!( | ||
| container::OptimizationContainer, | ||
| ::Type{T}, | ||
| devices::Vector{U}, | ||
| device_model::DeviceModel{U, W}, | ||
| event_model::EventModel, | ||
| ) where {T <: EventParameter, U <: PSY.Component, W <: AbstractDeviceFormulation} | ||
| _add_parameters!(container, T, devices, device_model, event_model) | ||
|
Member
Author
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. Why do we have a helper if this is the call site? |
||
| return | ||
| end | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do we have similar debug statements elsewhere?