Skip to content

Commit

Permalink
Replace parameterized type variables
Browse files Browse the repository at this point in the history
This change allows SnoopCompile.jl to generate precompile statements.
For a reason unknown as of now, SnoopCompile.jl generates invalid
statements for PowerModels.AbstractPowerModel and
PowerModels.AbstractActivePowerModel when type variables are used.
  • Loading branch information
daniel-thom committed Sep 21, 2023
1 parent 0914940 commit d99f4a2
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 177 deletions.
64 changes: 37 additions & 27 deletions src/devices_models/device_constructors/branch_constructor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,12 @@ function construct_device!(
if has_subnetworks(network_model)
devices =
get_available_components(T, sys, get_attribute(device_model, "filter_function"))
branch_rate_bounds!(container, devices, device_model, S)
branch_rate_bounds!(
container,
devices,
device_model,
typeof(network_model).parameters[1],
)
end
return
end
Expand Down Expand Up @@ -173,8 +178,8 @@ function construct_device!(
::OptimizationContainer,
::PSY.System,
::ArgumentConstructStage,
::DeviceModel{<: PSY.ACBranch, StaticBranch},
::NetworkModel{<: PM.AbstractActivePowerModel},
::DeviceModel{<:PSY.ACBranch, StaticBranch},
::NetworkModel{<:PM.AbstractActivePowerModel},
)
end

Expand Down Expand Up @@ -254,12 +259,17 @@ function construct_device!(
sys::PSY.System,
::ModelConstructStage,
device_model::DeviceModel{T, StaticBranchBounds},
network_model::NetworkModel{S},
) where {T <: PSY.ACBranch, S <: StandardPTDFModel}
network_model::NetworkModel{<:StandardPTDFModel},
) where {T <: PSY.ACBranch}
devices =
get_available_components(T, sys, get_attribute(device_model, "filter_function"))
add_constraints!(container, NetworkFlowConstraint, devices, device_model, network_model)
branch_rate_bounds!(container, devices, device_model, S)
branch_rate_bounds!(
container,
devices,
device_model,
typeof(network_model).parameters[1],
)
add_constraint_dual!(container, sys, device_model)
return
end
Expand Down Expand Up @@ -304,19 +314,19 @@ function construct_device!(
::PSY.System,
::ArgumentConstructStage,
::DeviceModel{T, StaticBranch},
::NetworkModel{<: PM.AbstractPowerModel},
::NetworkModel{<:PM.AbstractPowerModel},
) where {T <: PSY.ACBranch} end

function construct_device!(
container::OptimizationContainer,
sys::PSY.System,
::ModelConstructStage,
model::DeviceModel{T, StaticBranch},
network_model::NetworkModel{S},
) where {T <: PSY.ACBranch, S <: PM.AbstractPowerModel}
network_model::NetworkModel{<:PM.AbstractPowerModel},
) where {T <: PSY.ACBranch}
devices =
get_available_components(T, sys, get_attribute(model, "filter_function"))
branch_rate_bounds!(container, devices, model, S)
branch_rate_bounds!(container, devices, model, typeof(network_model).parameters[1])

add_constraints!(container, RateLimitConstraintFromTo, devices, model, network_model)
add_constraints!(container, RateLimitConstraintToFrom, devices, model, network_model)
Expand All @@ -329,19 +339,19 @@ function construct_device!(
sys::PSY.System,
::ArgumentConstructStage,
::DeviceModel{T, StaticBranchBounds},
::NetworkModel{<: PM.AbstractPowerModel},
::NetworkModel{<:PM.AbstractPowerModel},
) where {T <: PSY.ACBranch} end

function construct_device!(
container::OptimizationContainer,
sys::PSY.System,
::ModelConstructStage,
model::DeviceModel{T, StaticBranchBounds},
::NetworkModel{S},
) where {T <: PSY.ACBranch, S <: PM.AbstractPowerModel}
network_model::NetworkModel{<:PM.AbstractPowerModel},
) where {T <: PSY.ACBranch}
devices =
get_available_components(T, sys, get_attribute(model, "filter_function"))
branch_rate_bounds!(container, devices, model, S)
branch_rate_bounds!(container, devices, model, typeof(network_model).parameters[1])
add_constraint_dual!(container, sys, model)
return
end
Expand Down Expand Up @@ -402,8 +412,8 @@ function construct_device!(
::OptimizationContainer,
::PSY.System,
::ArgumentConstructStage,
::DeviceModel{<: TwoTerminalHVDCTypes, <: HVDCTwoTerminalUnbounded},
::NetworkModel{<: PM.AbstractPowerModel},
::DeviceModel{<:TwoTerminalHVDCTypes, <:HVDCTwoTerminalUnbounded},
::NetworkModel{<:PM.AbstractPowerModel},
)
return
end
Expand All @@ -412,8 +422,8 @@ function construct_device!(
container::OptimizationContainer,
sys::PSY.System,
::ModelConstructStage,
model::DeviceModel{<: TwoTerminalHVDCTypes, <: HVDCTwoTerminalUnbounded},
::NetworkModel{<: PM.AbstractPowerModel},
model::DeviceModel{<:TwoTerminalHVDCTypes, <:HVDCTwoTerminalUnbounded},
::NetworkModel{<:PM.AbstractPowerModel},
)
add_constraint_dual!(container, sys, model)
end
Expand All @@ -424,7 +434,7 @@ function construct_device!(
sys::PSY.System,
::ArgumentConstructStage,
model::DeviceModel{T, U},
network_model::NetworkModel{<: Union{StandardPTDFModel, PTDFPowerModel}},
network_model::NetworkModel{<:Union{StandardPTDFModel, PTDFPowerModel}},
) where {
T <: TwoTerminalHVDCTypes,
U <: HVDCTwoTerminalUnbounded,
Expand All @@ -448,8 +458,8 @@ function construct_device!(
container::OptimizationContainer,
sys::PSY.System,
::ModelConstructStage,
model::DeviceModel{<: TwoTerminalHVDCTypes, <: HVDCTwoTerminalUnbounded},
network_model::NetworkModel{<: Union{StandardPTDFModel, PTDFPowerModel}},
model::DeviceModel{<:TwoTerminalHVDCTypes, <:HVDCTwoTerminalUnbounded},
network_model::NetworkModel{<:Union{StandardPTDFModel, PTDFPowerModel}},
)
add_constraint_dual!(container, sys, model)
return
Expand All @@ -459,8 +469,8 @@ function construct_device!(
::OptimizationContainer,
::PSY.System,
::ArgumentConstructStage,
::DeviceModel{<: TwoTerminalHVDCTypes, <: HVDCTwoTerminalLossless},
::NetworkModel{<: PM.AbstractPowerModel}
::DeviceModel{<:TwoTerminalHVDCTypes, <:HVDCTwoTerminalLossless},
::NetworkModel{<:PM.AbstractPowerModel},
)
return
end
Expand All @@ -469,8 +479,8 @@ function construct_device!(
container::OptimizationContainer,
sys::PSY.System,
::ModelConstructStage,
model::DeviceModel{T, <: HVDCTwoTerminalLossless},
network_model::NetworkModel{<: PM.AbstractPowerModel},
model::DeviceModel{T, <:HVDCTwoTerminalLossless},
network_model::NetworkModel{<:PM.AbstractPowerModel},
) where {T <: TwoTerminalHVDCTypes}
devices =
get_available_components(T, sys, get_attribute(model, "filter_function"))
Expand Down Expand Up @@ -590,7 +600,7 @@ function construct_device!(
sys::PSY.System,
::ArgumentConstructStage,
model::DeviceModel{T, HVDCTwoTerminalDispatch},
network_model::NetworkModel{<: PM.AbstractActivePowerModel},
network_model::NetworkModel{<:PM.AbstractActivePowerModel},
) where {T <: TwoTerminalHVDCTypes}
devices =
get_available_components(T, sys, get_attribute(model, "filter_function"))
Expand Down Expand Up @@ -647,7 +657,7 @@ function construct_device!(
sys::PSY.System,
::ModelConstructStage,
model::DeviceModel{T, HVDCTwoTerminalDispatch},
network_model::NetworkModel{<: PM.AbstractActivePowerModel},
network_model::NetworkModel{<:PM.AbstractActivePowerModel},
) where {T <: TwoTerminalHVDCTypes}
devices =
get_available_components(T, sys, get_attribute(model, "filter_function"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function validate_available_devices(
device_model::DeviceModel{T, <: AbstractDeviceFormulation},
device_model::DeviceModel{T, <:AbstractDeviceFormulation},
system::PSY.System,
) where {T <: PSY.Device}
devices =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ function construct_device!(
sys::PSY.System,
::ArgumentConstructStage,
model::DeviceModel{PSY.InterconnectingConverter, LossLessConverter},
network_model::NetworkModel{<: PM.AbstractActivePowerModel},
network_model::NetworkModel{<:PM.AbstractActivePowerModel},
)
devices = get_available_components(PSY.InterconnectingConverter, sys)
add_variables!(container, ActivePowerVariable, devices, LossLessConverter())
Expand All @@ -24,11 +24,11 @@ function construct_device!(
sys::PSY.System,
::ModelConstructStage,
model::DeviceModel{PSY.InterconnectingConverter, LossLessConverter},
::NetworkModel{S},
) where {S <: PM.AbstractActivePowerModel}
network_model::NetworkModel{<:PM.AbstractActivePowerModel},
)
devices = get_available_components(PSY.InterconnectingConverter, sys)
add_feedforward_constraints!(container, model, devices)
objective_function!(container, devices, model, S)
objective_function!(container, devices, model, typeof(network_model).parameters[1])
add_constraint_dual!(container, sys, model)
return
end
Expand All @@ -38,7 +38,7 @@ function construct_device!(
sys::PSY.System,
::ArgumentConstructStage,
model::DeviceModel{PSY.TModelHVDCLine, LossLessLine},
network_model::NetworkModel{<: PM.AbstractActivePowerModel},
network_model::NetworkModel{<:PM.AbstractActivePowerModel},
)
devices = get_available_components(PSY.TModelHVDCLine, sys)
add_variables!(container, FlowActivePowerVariable, devices, LossLessLine())
Expand All @@ -59,6 +59,6 @@ function construct_device!(
sys::PSY.System,
::ModelConstructStage,
model::DeviceModel{PSY.TModelHVDCLine, LossLessLine},
::NetworkModel{<: PM.AbstractActivePowerModel},
::NetworkModel{<:PM.AbstractActivePowerModel},
)
end
Loading

0 comments on commit d99f4a2

Please sign in to comment.