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

Jd/add penalty to interface #998

Merged
merged 3 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/definitions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ IS.@scoped_enum(

IS.@scoped_enum(StateTypes, Differential = 1, Algebraic = 2, Hybrid = 3,)

PS_MAX_LOG = parse(Int, get(ENV, "PS_MAX_LOG", "50"))
DEFAULT_BASE_MVA = 100.0
const PS_MAX_LOG = parse(Int, get(ENV, "PS_MAX_LOG", "50"))
const DEFAULT_BASE_MVA = 100.0

const POWER_SYSTEM_STRUCT_DESCRIPTOR_FILE =
joinpath(dirname(pathof(PowerSystems)), "descriptors", "power_system_structs.json")
Expand All @@ -75,3 +75,4 @@ const DEFAULT_SYSTEM_FREQUENCY = 60.0

const INFINITE_TIME = 1e4
const START_COST = 1e8
const INFINITE_COST = 1e8
7 changes: 7 additions & 0 deletions src/descriptors/power_system_structs.json
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,13 @@
"data_type": "MinMax",
"needs_conversion": true
},
{
"name": "violation_penalty",
"null_value": "0.0",
"comment": "Penalty for violating the flow limits in the interface",
"data_type": "Float64",
"default": "INFINITE_COST"
},
{
"name": "direction_mapping",
"comment": "Map to set of multiplier to the flow in the line for cases when the line has a reverse direction with respect to the interface",
Expand Down
17 changes: 13 additions & 4 deletions src/models/generated/TransmissionInterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This file is auto-generated. Do not edit.
name::String
available::Bool
active_power_flow_limits::MinMax
violation_penalty::Float64
direction_mapping::Dict{String, Int}
time_series_container::InfrastructureSystems.TimeSeriesContainer
internal::InfrastructureSystemsInternal
Expand All @@ -20,6 +21,7 @@ A collection of branches that make up an interface or corridor for the transfer
- `name::String`
- `available::Bool`
- `active_power_flow_limits::MinMax`
- `violation_penalty::Float64`: Penalty for violating the flow limits in the interface
- `direction_mapping::Dict{String, Int}`: Map to set of multiplier to the flow in the line for cases when the line has a reverse direction with respect to the interface
- `time_series_container::InfrastructureSystems.TimeSeriesContainer`: internal time_series storage
- `internal::InfrastructureSystemsInternal`: power system internal reference, do not modify
Expand All @@ -28,6 +30,8 @@ mutable struct TransmissionInterface <: Service
name::String
available::Bool
active_power_flow_limits::MinMax
"Penalty for violating the flow limits in the interface"
violation_penalty::Float64
"Map to set of multiplier to the flow in the line for cases when the line has a reverse direction with respect to the interface"
direction_mapping::Dict{String, Int}
"internal time_series storage"
Expand All @@ -36,12 +40,12 @@ mutable struct TransmissionInterface <: Service
internal::InfrastructureSystemsInternal
end

function TransmissionInterface(name, available, active_power_flow_limits, direction_mapping=Dict{String, Int}(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), )
TransmissionInterface(name, available, active_power_flow_limits, direction_mapping, time_series_container, InfrastructureSystemsInternal(), )
function TransmissionInterface(name, available, active_power_flow_limits, violation_penalty=INFINITE_COST, direction_mapping=Dict{String, Int}(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), )
TransmissionInterface(name, available, active_power_flow_limits, violation_penalty, direction_mapping, time_series_container, InfrastructureSystemsInternal(), )
end

function TransmissionInterface(; name, available, active_power_flow_limits, direction_mapping=Dict{String, Int}(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), internal=InfrastructureSystemsInternal(), )
TransmissionInterface(name, available, active_power_flow_limits, direction_mapping, time_series_container, internal, )
function TransmissionInterface(; name, available, active_power_flow_limits, violation_penalty=INFINITE_COST, direction_mapping=Dict{String, Int}(), time_series_container=InfrastructureSystems.TimeSeriesContainer(), internal=InfrastructureSystemsInternal(), )
TransmissionInterface(name, available, active_power_flow_limits, violation_penalty, direction_mapping, time_series_container, internal, )
end

# Constructor for demo purposes; non-functional.
Expand All @@ -50,6 +54,7 @@ function TransmissionInterface(::Nothing)
name="init",
available=false,
active_power_flow_limits=(min=0.0, max=0.0),
violation_penalty=0.0,
direction_mapping=Dict{String, Int}(),
time_series_container=InfrastructureSystems.TimeSeriesContainer(),
)
Expand All @@ -61,6 +66,8 @@ get_name(value::TransmissionInterface) = value.name
get_available(value::TransmissionInterface) = value.available
"""Get [`TransmissionInterface`](@ref) `active_power_flow_limits`."""
get_active_power_flow_limits(value::TransmissionInterface) = get_value(value, value.active_power_flow_limits)
"""Get [`TransmissionInterface`](@ref) `violation_penalty`."""
get_violation_penalty(value::TransmissionInterface) = value.violation_penalty
"""Get [`TransmissionInterface`](@ref) `direction_mapping`."""
get_direction_mapping(value::TransmissionInterface) = value.direction_mapping
"""Get [`TransmissionInterface`](@ref) `time_series_container`."""
Expand All @@ -72,6 +79,8 @@ get_internal(value::TransmissionInterface) = value.internal
set_available!(value::TransmissionInterface, val) = value.available = val
"""Set [`TransmissionInterface`](@ref) `active_power_flow_limits`."""
set_active_power_flow_limits!(value::TransmissionInterface, val) = value.active_power_flow_limits = set_value(value, val)
"""Set [`TransmissionInterface`](@ref) `violation_penalty`."""
set_violation_penalty!(value::TransmissionInterface, val) = value.violation_penalty = val
"""Set [`TransmissionInterface`](@ref) `direction_mapping`."""
set_direction_mapping!(value::TransmissionInterface, val) = value.direction_mapping = val
"""Set [`TransmissionInterface`](@ref) `time_series_container`."""
Expand Down
2 changes: 2 additions & 0 deletions src/models/generated/includes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ export get_to_branch_control
export get_valve_position_limits
export get_variable
export get_vh_pnts
export get_violation_penalty
export get_vl_pnts
export get_voltage
export get_voltage_limits
Expand Down Expand Up @@ -1132,6 +1133,7 @@ export set_to_branch_control!
export set_valve_position_limits!
export set_variable!
export set_vh_pnts!
export set_violation_penalty!
export set_vl_pnts!
export set_voltage!
export set_voltage_limits!
Expand Down
Loading