diff --git a/src/devices_models/device_constructors/branch_constructor.jl b/src/devices_models/device_constructors/branch_constructor.jl index b78218d256..c15958c239 100644 --- a/src/devices_models/device_constructors/branch_constructor.jl +++ b/src/devices_models/device_constructors/branch_constructor.jl @@ -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, + get_network_formulation(network_model), + ) end return end @@ -173,9 +178,10 @@ function construct_device!( ::OptimizationContainer, ::PSY.System, ::ArgumentConstructStage, - ::DeviceModel{T, StaticBranch}, - ::NetworkModel{S}, -) where {T <: PSY.ACBranch, S <: PM.AbstractActivePowerModel} end + ::DeviceModel{<:PSY.ACBranch, StaticBranch}, + ::NetworkModel{<:PM.AbstractActivePowerModel}, +) +end # For DC Power only. Implements constraints function construct_device!( @@ -253,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, + get_network_formulation(network_model), + ) add_constraint_dual!(container, sys, device_model) return end @@ -303,19 +314,19 @@ function construct_device!( ::PSY.System, ::ArgumentConstructStage, ::DeviceModel{T, StaticBranch}, - ::NetworkModel{S}, -) where {T <: PSY.ACBranch, S <: PM.AbstractPowerModel} end + ::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, get_network_formulation(network_model)) add_constraints!(container, RateLimitConstraintFromTo, devices, model, network_model) add_constraints!(container, RateLimitConstraintToFrom, devices, model, network_model) @@ -328,19 +339,19 @@ function construct_device!( sys::PSY.System, ::ArgumentConstructStage, ::DeviceModel{T, StaticBranchBounds}, - ::NetworkModel{S}, -) where {T <: PSY.ACBranch, S <: PM.AbstractPowerModel} end + ::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, get_network_formulation(network_model)) add_constraint_dual!(container, sys, model) return end @@ -401,13 +412,9 @@ function construct_device!( ::OptimizationContainer, ::PSY.System, ::ArgumentConstructStage, - ::DeviceModel{T, F}, - ::NetworkModel{S}, -) where { - T <: TwoTerminalHVDCTypes, - F <: HVDCTwoTerminalUnbounded, - S <: PM.AbstractPowerModel, -} + ::DeviceModel{T, HVDCTwoTerminalUnbounded}, + ::NetworkModel{<:PM.AbstractPowerModel}, +) where {T <: TwoTerminalHVDCTypes} return end @@ -415,13 +422,9 @@ function construct_device!( container::OptimizationContainer, sys::PSY.System, ::ModelConstructStage, - model::DeviceModel{T, U}, - ::NetworkModel{S}, -) where { - T <: TwoTerminalHVDCTypes, - U <: HVDCTwoTerminalUnbounded, - S <: PM.AbstractPowerModel, -} + model::DeviceModel{<:TwoTerminalHVDCTypes, HVDCTwoTerminalUnbounded}, + ::NetworkModel{<:PM.AbstractPowerModel}, +) add_constraint_dual!(container, sys, model) end @@ -430,16 +433,12 @@ function construct_device!( container::OptimizationContainer, sys::PSY.System, ::ArgumentConstructStage, - model::DeviceModel{T, U}, - network_model::NetworkModel{S}, -) where { - T <: TwoTerminalHVDCTypes, - U <: HVDCTwoTerminalUnbounded, - S <: Union{StandardPTDFModel, PTDFPowerModel}, -} + model::DeviceModel{T, HVDCTwoTerminalUnbounded}, + network_model::NetworkModel{<:Union{StandardPTDFModel, PTDFPowerModel}}, +) where {T <: TwoTerminalHVDCTypes} devices = get_available_components(T, sys, get_attribute(model, "filter_function")) - add_variables!(container, FlowActivePowerVariable, devices, U()) + add_variables!(container, FlowActivePowerVariable, devices, HVDCTwoTerminalUnbounded()) add_to_expression!( container, ActivePowerBalance, @@ -456,13 +455,9 @@ function construct_device!( container::OptimizationContainer, sys::PSY.System, ::ModelConstructStage, - model::DeviceModel{T, U}, - network_model::NetworkModel{S}, -) where { - T <: TwoTerminalHVDCTypes, - U <: HVDCTwoTerminalUnbounded, - S <: Union{StandardPTDFModel, PTDFPowerModel}, -} + model::DeviceModel{<:TwoTerminalHVDCTypes, HVDCTwoTerminalUnbounded}, + network_model::NetworkModel{<:Union{StandardPTDFModel, PTDFPowerModel}}, +) add_constraint_dual!(container, sys, model) return end @@ -471,13 +466,9 @@ function construct_device!( ::OptimizationContainer, ::PSY.System, ::ArgumentConstructStage, - ::DeviceModel{T, F}, - ::NetworkModel{S}, -) where { - T <: TwoTerminalHVDCTypes, - F <: HVDCTwoTerminalLossless, - S <: PM.AbstractPowerModel, -} + ::DeviceModel{T, HVDCTwoTerminalLossless}, + ::NetworkModel{<:PM.AbstractPowerModel}, +) where {T <: TwoTerminalHVDCTypes} return end @@ -485,13 +476,9 @@ function construct_device!( container::OptimizationContainer, sys::PSY.System, ::ModelConstructStage, - model::DeviceModel{T, U}, - network_model::NetworkModel{S}, -) where { - T <: TwoTerminalHVDCTypes, - U <: HVDCTwoTerminalLossless, - S <: 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")) add_constraints!(container, FlowRateConstraint, devices, model, network_model) @@ -504,12 +491,12 @@ function construct_device!( container::OptimizationContainer, sys::PSY.System, ::ArgumentConstructStage, - model::DeviceModel{T, U}, + model::DeviceModel{T, HVDCTwoTerminalLossless}, network_model::NetworkModel{<:Union{StandardPTDFModel, PTDFPowerModel}}, -) where {T <: TwoTerminalHVDCTypes, U <: HVDCTwoTerminalLossless} +) where {T <: TwoTerminalHVDCTypes} devices = get_available_components(T, sys, get_attribute(model, "filter_function")) - add_variables!(container, FlowActivePowerVariable, devices, U()) + add_variables!(container, FlowActivePowerVariable, devices, HVDCTwoTerminalLossless()) add_to_expression!( container, ActivePowerBalance, @@ -610,8 +597,8 @@ function construct_device!( sys::PSY.System, ::ArgumentConstructStage, model::DeviceModel{T, HVDCTwoTerminalDispatch}, - network_model::NetworkModel{U}, -) where {T <: TwoTerminalHVDCTypes, U <: PM.AbstractActivePowerModel} + network_model::NetworkModel{<:PM.AbstractActivePowerModel}, +) where {T <: TwoTerminalHVDCTypes} devices = get_available_components(T, sys, get_attribute(model, "filter_function")) add_variables!( @@ -667,8 +654,8 @@ function construct_device!( sys::PSY.System, ::ModelConstructStage, model::DeviceModel{T, HVDCTwoTerminalDispatch}, - network_model::NetworkModel{U}, -) where {T <: TwoTerminalHVDCTypes, U <: PM.AbstractActivePowerModel} + network_model::NetworkModel{<:PM.AbstractActivePowerModel}, +) where {T <: TwoTerminalHVDCTypes} devices = get_available_components(T, sys, get_attribute(model, "filter_function")) add_constraints!(container, FlowRateConstraintFromTo, devices, model, network_model) diff --git a/src/devices_models/device_constructors/constructor_validations.jl b/src/devices_models/device_constructors/constructor_validations.jl index dbf142ae00..36def3c486 100644 --- a/src/devices_models/device_constructors/constructor_validations.jl +++ b/src/devices_models/device_constructors/constructor_validations.jl @@ -1,7 +1,7 @@ function validate_available_devices( - device_model::DeviceModel{T, U}, + device_model::DeviceModel{T, <:AbstractDeviceFormulation}, system::PSY.System, -) where {T <: PSY.Device, U <: AbstractDeviceFormulation} +) where {T <: PSY.Device} devices = get_available_components(T, system, get_attribute(device_model, "filter_function")) if isempty(devices) diff --git a/src/devices_models/device_constructors/hvdcsystems_constructor.jl b/src/devices_models/device_constructors/hvdcsystems_constructor.jl index cd176bb292..0e2cb75cf2 100644 --- a/src/devices_models/device_constructors/hvdcsystems_constructor.jl +++ b/src/devices_models/device_constructors/hvdcsystems_constructor.jl @@ -3,8 +3,8 @@ function construct_device!( sys::PSY.System, ::ArgumentConstructStage, model::DeviceModel{PSY.InterconnectingConverter, LossLessConverter}, - network_model::NetworkModel{S}, -) where {S <: PM.AbstractActivePowerModel} + network_model::NetworkModel{<:PM.AbstractActivePowerModel}, +) devices = get_available_components(PSY.InterconnectingConverter, sys) add_variables!(container, ActivePowerVariable, devices, LossLessConverter()) add_to_expression!( @@ -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, get_network_formulation(network_model)) add_constraint_dual!(container, sys, model) return end @@ -38,8 +38,8 @@ function construct_device!( sys::PSY.System, ::ArgumentConstructStage, model::DeviceModel{PSY.TModelHVDCLine, LossLessLine}, - network_model::NetworkModel{S}, -) where {S <: PM.AbstractActivePowerModel} + network_model::NetworkModel{<:PM.AbstractActivePowerModel}, +) devices = get_available_components(PSY.TModelHVDCLine, sys) add_variables!(container, FlowActivePowerVariable, devices, LossLessLine()) add_to_expression!( @@ -59,8 +59,6 @@ function construct_device!( sys::PSY.System, ::ModelConstructStage, model::DeviceModel{PSY.TModelHVDCLine, LossLessLine}, - ::NetworkModel{S}, -) where {S <: PM.AbstractActivePowerModel} - devices = get_available_components(PSY.TModelHVDCLine, sys) - return + ::NetworkModel{<:PM.AbstractActivePowerModel}, +) end diff --git a/src/devices_models/device_constructors/load_constructor.jl b/src/devices_models/device_constructors/load_constructor.jl index 61af8d4198..ad5766db1e 100644 --- a/src/devices_models/device_constructors/load_constructor.jl +++ b/src/devices_models/device_constructors/load_constructor.jl @@ -3,11 +3,10 @@ function construct_device!( sys::PSY.System, ::ArgumentConstructStage, model::DeviceModel{L, D}, - network_model::NetworkModel{S}, + network_model::NetworkModel{<:PM.AbstractPowerModel}, ) where { L <: PSY.ControllableLoad, D <: AbstractControllablePowerLoadFormulation, - S <: PM.AbstractPowerModel, } devices = get_available_components(L, sys, get_attribute(model, "filter_function")) @@ -44,13 +43,9 @@ function construct_device!( container::OptimizationContainer, sys::PSY.System, ::ModelConstructStage, - model::DeviceModel{L, D}, - network_model::NetworkModel{S}, -) where { - L <: PSY.ControllableLoad, - D <: AbstractControllablePowerLoadFormulation, - S <: PM.AbstractPowerModel, -} + model::DeviceModel{L, <:AbstractControllablePowerLoadFormulation}, + network_model::NetworkModel{<:PM.AbstractPowerModel}, +) where {L <: PSY.ControllableLoad} devices = get_available_components(L, sys, get_attribute(model, "filter_function")) @@ -72,7 +67,7 @@ function construct_device!( ) add_feedforward_constraints!(container, model, devices) - objective_function!(container, devices, model, S) + objective_function!(container, devices, model, get_network_formulation(network_model)) add_constraint_dual!(container, sys, model) return @@ -83,11 +78,10 @@ function construct_device!( sys::PSY.System, ::ArgumentConstructStage, model::DeviceModel{L, D}, - network_model::NetworkModel{S}, + network_model::NetworkModel{<:PM.AbstractActivePowerModel}, ) where { L <: PSY.ControllableLoad, D <: AbstractControllablePowerLoadFormulation, - S <: PM.AbstractActivePowerModel, } devices = get_available_components(L, sys, get_attribute(model, "filter_function")) @@ -114,13 +108,9 @@ function construct_device!( container::OptimizationContainer, sys::PSY.System, ::ModelConstructStage, - model::DeviceModel{L, D}, - network_model::NetworkModel{S}, -) where { - L <: PSY.ControllableLoad, - D <: AbstractControllablePowerLoadFormulation, - S <: PM.AbstractActivePowerModel, -} + model::DeviceModel{L, <:AbstractControllablePowerLoadFormulation}, + network_model::NetworkModel{<:PM.AbstractActivePowerModel}, +) where {L <: PSY.ControllableLoad} devices = get_available_components(L, sys, get_attribute(model, "filter_function")) @@ -134,7 +124,7 @@ function construct_device!( ) add_feedforward_constraints!(container, model, devices) - objective_function!(container, devices, model, S) + objective_function!(container, devices, model, get_network_formulation(network_model)) add_constraint_dual!(container, sys, model) return @@ -145,8 +135,8 @@ function construct_device!( sys::PSY.System, ::ArgumentConstructStage, model::DeviceModel{L, PowerLoadInterruption}, - network_model::NetworkModel{S}, -) where {L <: PSY.ControllableLoad, S <: PM.AbstractPowerModel} + network_model::NetworkModel{<:PM.AbstractPowerModel}, +) where {L <: PSY.ControllableLoad} devices = get_available_components(L, sys, get_attribute(model, "filter_function")) @@ -184,8 +174,8 @@ function construct_device!( sys::PSY.System, ::ModelConstructStage, model::DeviceModel{L, PowerLoadInterruption}, - network_model::NetworkModel{S}, -) where {L <: PSY.ControllableLoad, S <: PM.AbstractPowerModel} + network_model::NetworkModel{<:PM.AbstractPowerModel}, +) where {L <: PSY.ControllableLoad} devices = get_available_components(L, sys, get_attribute(model, "filter_function")) @@ -207,7 +197,7 @@ function construct_device!( ) add_feedforward_constraints!(container, model, devices) - objective_function!(container, devices, model, S) + objective_function!(container, devices, model, get_network_formulation(network_model)) add_constraint_dual!(container, sys, model) return @@ -218,8 +208,8 @@ function construct_device!( sys::PSY.System, ::ArgumentConstructStage, model::DeviceModel{L, PowerLoadInterruption}, - network_model::NetworkModel{S}, -) where {L <: PSY.ControllableLoad, S <: PM.AbstractActivePowerModel} + network_model::NetworkModel{<:PM.AbstractActivePowerModel}, +) where {L <: PSY.ControllableLoad} devices = get_available_components(L, sys, get_attribute(model, "filter_function")) @@ -247,8 +237,8 @@ function construct_device!( sys::PSY.System, ::ModelConstructStage, model::DeviceModel{L, PowerLoadInterruption}, - network_model::NetworkModel{S}, -) where {L <: PSY.ControllableLoad, S <: PM.AbstractActivePowerModel} + network_model::NetworkModel{<:PM.AbstractActivePowerModel}, +) where {L <: PSY.ControllableLoad} devices = get_available_components(L, sys, get_attribute(model, "filter_function")) @@ -262,7 +252,7 @@ function construct_device!( ) add_feedforward_constraints!(container, model, devices) - objective_function!(container, devices, model, S) + objective_function!(container, devices, model, get_network_formulation(network_model)) add_constraint_dual!(container, sys, model) return @@ -273,8 +263,8 @@ function construct_device!( sys::PSY.System, ::ArgumentConstructStage, model::DeviceModel{L, StaticPowerLoad}, - network_model::NetworkModel{S}, -) where {L <: PSY.ElectricLoad, S <: PM.AbstractPowerModel} + network_model::NetworkModel{<:PM.AbstractPowerModel}, +) where {L <: PSY.ElectricLoad} devices = get_available_components(L, sys, get_attribute(model, "filter_function")) @@ -305,8 +295,8 @@ function construct_device!( sys::PSY.System, ::ArgumentConstructStage, model::DeviceModel{L, StaticPowerLoad}, - network_model::NetworkModel{S}, -) where {L <: PSY.ElectricLoad, S <: PM.AbstractActivePowerModel} + network_model::NetworkModel{<:PM.AbstractActivePowerModel}, +) where {L <: PSY.ElectricLoad} devices = get_available_components(L, sys, get_attribute(model, "filter_function")) @@ -327,9 +317,9 @@ function construct_device!( container::OptimizationContainer, sys::PSY.System, ::ModelConstructStage, - model::DeviceModel{L, StaticPowerLoad}, - network_model::NetworkModel{S}, -) where {L <: PSY.ElectricLoad, S <: PM.AbstractPowerModel} + model::DeviceModel{<:PSY.ElectricLoad, StaticPowerLoad}, + network_model::NetworkModel{<:PM.AbstractPowerModel}, +) # Static PowerLoad doesn't add any constraints to the model. This function covers # AbstractPowerModel and AbtractActivePowerModel return @@ -339,13 +329,9 @@ function construct_device!( container::OptimizationContainer, sys::PSY.System, ::ArgumentConstructStage, - model::DeviceModel{L, D}, - network_model::NetworkModel{S}, -) where { - L <: PSY.StaticLoad, - D <: AbstractControllablePowerLoadFormulation, - S <: PM.AbstractPowerModel, -} + model::DeviceModel{L, <:AbstractControllablePowerLoadFormulation}, + network_model::NetworkModel{<:PM.AbstractPowerModel}, +) where {L <: PSY.StaticLoad} devices = get_available_components(L, sys, get_attribute(model, "filter_function")) @@ -375,13 +361,9 @@ function construct_device!( container::OptimizationContainer, sys::PSY.System, ::ArgumentConstructStage, - model::DeviceModel{L, D}, - network_model::NetworkModel{S}, -) where { - L <: PSY.StaticLoad, - D <: AbstractControllablePowerLoadFormulation, - S <: PM.AbstractActivePowerModel, -} + model::DeviceModel{L, <:AbstractControllablePowerLoadFormulation}, + network_model::NetworkModel{<:PM.AbstractActivePowerModel}, +) where {L <: PSY.StaticLoad} devices = get_available_components(L, sys, get_attribute(model, "filter_function")) @@ -402,11 +384,10 @@ function construct_device!( sys::PSY.System, ccs::ModelConstructStage, model::DeviceModel{L, D}, - network_model::NetworkModel{S}, + network_model::NetworkModel{<:PM.AbstractPowerModel}, ) where { L <: PSY.StaticLoad, D <: AbstractControllablePowerLoadFormulation, - S <: PM.AbstractPowerModel, } if D != StaticPowerLoad @warn( diff --git a/src/devices_models/device_constructors/regulationdevice_constructor.jl b/src/devices_models/device_constructors/regulationdevice_constructor.jl index b4535006ff..da3231a2b2 100644 --- a/src/devices_models/device_constructors/regulationdevice_constructor.jl +++ b/src/devices_models/device_constructors/regulationdevice_constructor.jl @@ -98,7 +98,13 @@ function construct_device!( network_model, ) - add_constraints!(container, ParticipationAssignmentConstraint, devices, model, S) + add_constraints!( + container, + ParticipationAssignmentConstraint, + devices, + model, + AreaBalancePowerModel, + ) objective_function!(container, devices, model) return end @@ -107,9 +113,9 @@ function construct_device!( container::OptimizationContainer, sys::PSY.System, ::ArgumentConstructStage, - model::DeviceModel{PSY.RegulationDevice{T}, FixedOutput}, + model::DeviceModel{PSY.RegulationDevice{<:PSY.StaticInjection}, FixedOutput}, network_model::NetworkModel{AreaBalancePowerModel}, -) where {T <: PSY.StaticInjection} +) devices = get_available_components(get_component_type(model), sys) add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model) @@ -128,9 +134,9 @@ function construct_device!( ::OptimizationContainer, ::PSY.System, ::ModelConstructStage, - ::DeviceModel{PSY.RegulationDevice{T}, FixedOutput}, + ::DeviceModel{PSY.RegulationDevice{<:PSY.StaticInjection}, FixedOutput}, network_model::NetworkModel{AreaBalancePowerModel}, -) where {T <: PSY.StaticInjection} +) # There is no-op under FixedOutput formulation return end diff --git a/src/devices_models/device_constructors/renewablegeneration_constructor.jl b/src/devices_models/device_constructors/renewablegeneration_constructor.jl index 34a8edd469..aa678bb0f2 100644 --- a/src/devices_models/device_constructors/renewablegeneration_constructor.jl +++ b/src/devices_models/device_constructors/renewablegeneration_constructor.jl @@ -3,11 +3,10 @@ function construct_device!( sys::PSY.System, ::ArgumentConstructStage, model::DeviceModel{R, D}, - network_model::NetworkModel{S}, + network_model::NetworkModel{<:PM.AbstractPowerModel}, ) where { R <: PSY.RenewableGen, D <: AbstractRenewableDispatchFormulation, - S <: PM.AbstractPowerModel, } devices = get_available_components(R, sys, get_attribute(model, "filter_function")) @@ -60,13 +59,9 @@ function construct_device!( container::OptimizationContainer, sys::PSY.System, ::ModelConstructStage, - model::DeviceModel{R, D}, - network_model::NetworkModel{S}, -) where { - R <: PSY.RenewableGen, - D <: AbstractRenewableDispatchFormulation, - S <: PM.AbstractPowerModel, -} + model::DeviceModel{R, <:AbstractRenewableDispatchFormulation}, + network_model::NetworkModel{<:PM.AbstractPowerModel}, +) where {R <: PSY.RenewableGen} devices = get_available_components(R, sys, get_attribute(model, "filter_function")) @@ -108,7 +103,7 @@ function construct_device!( ) add_feedforward_constraints!(container, model, devices) - objective_function!(container, devices, model, S) + objective_function!(container, devices, model, get_network_formulation(network_model)) add_constraint_dual!(container, sys, model) return @@ -119,11 +114,10 @@ function construct_device!( sys::PSY.System, ::ArgumentConstructStage, model::DeviceModel{R, D}, - network_model::NetworkModel{S}, + network_model::NetworkModel{<:PM.AbstractActivePowerModel}, ) where { R <: PSY.RenewableGen, D <: AbstractRenewableDispatchFormulation, - S <: PM.AbstractActivePowerModel, } devices = get_available_components(R, sys, get_attribute(model, "filter_function")) @@ -167,13 +161,9 @@ function construct_device!( container::OptimizationContainer, sys::PSY.System, ::ModelConstructStage, - model::DeviceModel{R, D}, - network_model::NetworkModel{S}, -) where { - R <: PSY.RenewableGen, - D <: AbstractRenewableDispatchFormulation, - S <: PM.AbstractActivePowerModel, -} + model::DeviceModel{R, <:AbstractRenewableDispatchFormulation}, + network_model::NetworkModel{<:PM.AbstractActivePowerModel}, +) where {R <: PSY.RenewableGen} devices = get_available_components(R, sys, get_attribute(model, "filter_function")) @@ -206,7 +196,7 @@ function construct_device!( end add_feedforward_constraints!(container, model, devices) - objective_function!(container, devices, model, S) + objective_function!(container, devices, model, get_network_formulation(network_model)) add_constraint_dual!(container, sys, model) @@ -218,8 +208,8 @@ function construct_device!( sys::PSY.System, ::ArgumentConstructStage, model::DeviceModel{R, FixedOutput}, - network_model::NetworkModel{S}, -) where {R <: PSY.RenewableGen, S <: PM.AbstractPowerModel} + network_model::NetworkModel{<:PM.AbstractPowerModel}, +) where {R <: PSY.RenewableGen} devices = get_available_components(R, sys, get_attribute(model, "filter_function")) @@ -250,8 +240,8 @@ function construct_device!( sys::PSY.System, ::ArgumentConstructStage, model::DeviceModel{R, FixedOutput}, - network_model::NetworkModel{S}, -) where {R <: PSY.RenewableGen, S <: PM.AbstractActivePowerModel} + network_model::NetworkModel{<:PM.AbstractActivePowerModel}, +) where {R <: PSY.RenewableGen} devices = get_available_components(R, sys, get_attribute(model, "filter_function")) @@ -271,9 +261,9 @@ function construct_device!( container::OptimizationContainer, sys::PSY.System, ::ModelConstructStage, - model::DeviceModel{R, FixedOutput}, - network_model::NetworkModel{S}, -) where {R <: PSY.RenewableGen, S <: PM.AbstractPowerModel} + model::DeviceModel{<:PSY.RenewableGen, FixedOutput}, + network_model::NetworkModel{<:PM.AbstractPowerModel}, +) # FixedOutput doesn't add any constraints to the model. This function covers # AbstractPowerModel and AbtractActivePowerModel return diff --git a/src/devices_models/device_constructors/thermalgeneration_constructor.jl b/src/devices_models/device_constructors/thermalgeneration_constructor.jl index 721d21b619..c060f35c5d 100644 --- a/src/devices_models/device_constructors/thermalgeneration_constructor.jl +++ b/src/devices_models/device_constructors/thermalgeneration_constructor.jl @@ -2,18 +2,18 @@ function construct_device!( container::OptimizationContainer, sys::PSY.System, ::ArgumentConstructStage, - ::DeviceModel{T, FixedOutput}, - network_model::NetworkModel{S}, -) where {T <: PSY.ThermalGen, S <: PM.AbstractActivePowerModel} + device_model::DeviceModel{T, FixedOutput}, + network_model::NetworkModel{<:PM.AbstractActivePowerModel}, +) where {T <: PSY.ThermalGen} devices = - get_available_components(T, sys, get_attribute(model, "filter_function")) - add_parameters!(container, ActivePowerTimeSeriesParameter, devices, model) + get_available_components(T, sys, get_attribute(device_model, "filter_function")) + add_parameters!(container, ActivePowerTimeSeriesParameter, devices, device_model) add_to_expression!( container, ActivePowerBalance, ActivePowerTimeSeriesParameter, devices, - model, + device_model, network_model, ) return @@ -23,9 +23,9 @@ function construct_device!( ::OptimizationContainer, ::PSY.System, ::ModelConstructStage, - ::DeviceModel{T, FixedOutput}, - network_model::NetworkModel{S}, -) where {T <: PSY.ThermalGen, S <: PM.AbstractPowerModel} + ::DeviceModel{<:PSY.ThermalGen, FixedOutput}, + network_model::NetworkModel{<:PM.AbstractPowerModel}, +) # FixedOutput doesn't add any constraints to the model. This function covers # AbstractPowerModel and AbtractActivePowerModel return @@ -39,11 +39,10 @@ function construct_device!( sys::PSY.System, ::ArgumentConstructStage, model::DeviceModel{T, D}, - network_model::NetworkModel{S}, + network_model::NetworkModel{<:PM.AbstractPowerModel}, ) where { T <: PSY.ThermalGen, D <: AbstractStandardUnitCommitment, - S <: PM.AbstractPowerModel, } devices = get_available_components(T, sys, get_attribute(model, "filter_function")) @@ -105,13 +104,9 @@ function construct_device!( container::OptimizationContainer, sys::PSY.System, ::ModelConstructStage, - model::DeviceModel{T, D}, - network_model::NetworkModel{S}, -) where { - T <: PSY.ThermalGen, - D <: AbstractStandardUnitCommitment, - S <: PM.AbstractPowerModel, -} + model::DeviceModel{T, <:AbstractStandardUnitCommitment}, + network_model::NetworkModel{<:PM.AbstractPowerModel}, +) where {T <: PSY.ThermalGen} devices = get_available_components(T, sys, get_attribute(model, "filter_function")) @@ -145,7 +140,7 @@ function construct_device!( add_feedforward_constraints!(container, model, devices) - objective_function!(container, devices, model, S) + objective_function!(container, devices, model, get_network_formulation(network_model)) add_constraint_dual!(container, sys, model) return end @@ -158,12 +153,8 @@ function construct_device!( sys::PSY.System, ::ArgumentConstructStage, model::DeviceModel{T, D}, - network_model::NetworkModel{S}, -) where { - T <: PSY.ThermalGen, - D <: AbstractStandardUnitCommitment, - S <: PM.AbstractActivePowerModel, -} + network_model::NetworkModel{<:PM.AbstractActivePowerModel}, +) where {T <: PSY.ThermalGen, D <: AbstractStandardUnitCommitment} devices = get_available_components(T, sys, get_attribute(model, "filter_function")) @@ -216,13 +207,9 @@ function construct_device!( container::OptimizationContainer, sys::PSY.System, ::ModelConstructStage, - model::DeviceModel{T, D}, - network_model::NetworkModel{S}, -) where { - T <: PSY.ThermalGen, - D <: AbstractStandardUnitCommitment, - S <: PM.AbstractActivePowerModel, -} + model::DeviceModel{T, <:AbstractStandardUnitCommitment}, + network_model::NetworkModel{<:PM.AbstractActivePowerModel}, +) where {T <: PSY.ThermalGen} devices = get_available_components(T, sys, get_attribute(model, "filter_function")) add_constraints!( @@ -248,7 +235,7 @@ function construct_device!( add_feedforward_constraints!(container, model, devices) - objective_function!(container, devices, model, S) + objective_function!(container, devices, model, get_network_formulation(network_model)) add_constraint_dual!(container, sys, model) return @@ -262,8 +249,8 @@ function construct_device!( sys::PSY.System, ::ArgumentConstructStage, model::DeviceModel{T, ThermalBasicUnitCommitment}, - network_model::NetworkModel{S}, -) where {T <: PSY.ThermalGen, S <: PM.AbstractPowerModel} + network_model::NetworkModel{<:PM.AbstractPowerModel}, +) where {T <: PSY.ThermalGen} devices = get_available_components(T, sys, get_attribute(model, "filter_function")) @@ -323,8 +310,8 @@ function construct_device!( sys::PSY.System, ::ModelConstructStage, model::DeviceModel{T, ThermalBasicUnitCommitment}, - network_model::NetworkModel{S}, -) where {T <: PSY.ThermalGen, S <: PM.AbstractPowerModel} + network_model::NetworkModel{<:PM.AbstractPowerModel}, +) where {T <: PSY.ThermalGen} devices = get_available_components(T, sys, get_attribute(model, "filter_function")) @@ -357,7 +344,7 @@ function construct_device!( add_feedforward_constraints!(container, model, devices) - objective_function!(container, devices, model, S) + objective_function!(container, devices, model, get_network_formulation(network_model)) add_constraint_dual!(container, sys, model) return end @@ -370,8 +357,8 @@ function construct_device!( sys::PSY.System, ::ArgumentConstructStage, model::DeviceModel{T, ThermalBasicUnitCommitment}, - network_model::NetworkModel{S}, -) where {T <: PSY.ThermalGen, S <: PM.AbstractActivePowerModel} + network_model::NetworkModel{<:PM.AbstractActivePowerModel}, +) where {T <: PSY.ThermalGen} devices = get_available_components(T, sys, get_attribute(model, "filter_function")) @@ -422,8 +409,8 @@ function construct_device!( sys::PSY.System, ::ModelConstructStage, model::DeviceModel{T, ThermalBasicUnitCommitment}, - network_model::NetworkModel{S}, -) where {T <: PSY.ThermalGen, S <: PM.AbstractActivePowerModel} + network_model::NetworkModel{<:PM.AbstractActivePowerModel}, +) where {T <: PSY.ThermalGen} devices = get_available_components(T, sys, get_attribute(model, "filter_function")) @@ -448,7 +435,7 @@ function construct_device!( add_feedforward_constraints!(container, model, devices) - objective_function!(container, devices, model, S) + objective_function!(container, devices, model, get_network_formulation(network_model)) add_constraint_dual!(container, sys, model) return end @@ -461,8 +448,8 @@ function construct_device!( sys::PSY.System, ::ArgumentConstructStage, model::DeviceModel{T, ThermalStandardDispatch}, - network_model::NetworkModel{S}, -) where {T <: PSY.ThermalGen, S <: PM.AbstractPowerModel} + network_model::NetworkModel{<:PM.AbstractPowerModel}, +) where {T <: PSY.ThermalGen} devices = get_available_components(T, sys, get_attribute(model, "filter_function")) @@ -519,8 +506,8 @@ function construct_device!( sys::PSY.System, ::ModelConstructStage, model::DeviceModel{T, ThermalStandardDispatch}, - network_model::NetworkModel{S}, -) where {T <: PSY.ThermalGen, S <: PM.AbstractPowerModel} + network_model::NetworkModel{<:PM.AbstractPowerModel}, +) where {T <: PSY.ThermalGen} devices = get_available_components(T, sys, get_attribute(model, "filter_function")) @@ -553,7 +540,7 @@ function construct_device!( add_feedforward_constraints!(container, model, devices) - objective_function!(container, devices, model, S) + objective_function!(container, devices, model, get_network_formulation(network_model)) add_constraint_dual!(container, sys, model) return end @@ -566,8 +553,8 @@ function construct_device!( sys::PSY.System, ::ArgumentConstructStage, model::DeviceModel{T, ThermalStandardDispatch}, - network_model::NetworkModel{S}, -) where {T <: PSY.ThermalGen, S <: PM.AbstractActivePowerModel} + network_model::NetworkModel{<:PM.AbstractActivePowerModel}, +) where {T <: PSY.ThermalGen} devices = get_available_components(T, sys, get_attribute(model, "filter_function")) @@ -615,8 +602,8 @@ function construct_device!( sys::PSY.System, ::ModelConstructStage, model::DeviceModel{T, ThermalStandardDispatch}, - network_model::NetworkModel{S}, -) where {T <: PSY.ThermalGen, S <: PM.AbstractActivePowerModel} + network_model::NetworkModel{<:PM.AbstractActivePowerModel}, +) where {T <: PSY.ThermalGen} devices = get_available_components(T, sys, get_attribute(model, "filter_function")) @@ -641,7 +628,7 @@ function construct_device!( add_feedforward_constraints!(container, model, devices) - objective_function!(container, devices, model, S) + objective_function!(container, devices, model, get_network_formulation(network_model)) add_constraint_dual!(container, sys, model) return end @@ -651,11 +638,10 @@ function construct_device!( sys::PSY.System, ::ArgumentConstructStage, model::DeviceModel{T, D}, - network_model::NetworkModel{S}, + network_model::NetworkModel{<:PM.AbstractPowerModel}, ) where { T <: PSY.ThermalGen, D <: AbstractThermalDispatchFormulation, - S <: PM.AbstractPowerModel, } devices = get_available_components(T, sys, get_attribute(model, "filter_function")) @@ -707,13 +693,9 @@ function construct_device!( container::OptimizationContainer, sys::PSY.System, ::ModelConstructStage, - model::DeviceModel{T, D}, - network_model::NetworkModel{S}, -) where { - T <: PSY.ThermalGen, - D <: AbstractThermalDispatchFormulation, - S <: PM.AbstractPowerModel, -} + model::DeviceModel{T, <:AbstractThermalDispatchFormulation}, + network_model::NetworkModel{<:PM.AbstractPowerModel}, +) where {T <: PSY.ThermalGen} devices = get_available_components(T, sys, get_attribute(model, "filter_function")) @@ -745,7 +727,7 @@ function construct_device!( add_feedforward_constraints!(container, model, devices) - objective_function!(container, devices, model, S) + objective_function!(container, devices, model, get_network_formulation(network_model)) add_constraint_dual!(container, sys, model) return end @@ -755,11 +737,10 @@ function construct_device!( sys::PSY.System, ::ArgumentConstructStage, model::DeviceModel{T, D}, - network_model::NetworkModel{S}, + network_model::NetworkModel{<:PM.AbstractActivePowerModel}, ) where { T <: PSY.ThermalGen, D <: AbstractThermalDispatchFormulation, - S <: PM.AbstractActivePowerModel, } devices = get_available_components(T, sys, get_attribute(model, "filter_function")) @@ -802,13 +783,9 @@ function construct_device!( container::OptimizationContainer, sys::PSY.System, ::ModelConstructStage, - model::DeviceModel{T, D}, - network_model::NetworkModel{S}, -) where { - T <: PSY.ThermalGen, - D <: AbstractThermalDispatchFormulation, - S <: PM.AbstractActivePowerModel, -} + model::DeviceModel{T, <:AbstractThermalDispatchFormulation}, + network_model::NetworkModel{<:PM.AbstractActivePowerModel}, +) where {T <: PSY.ThermalGen} devices = get_available_components(T, sys, get_attribute(model, "filter_function")) @@ -831,7 +808,7 @@ function construct_device!( add_feedforward_constraints!(container, model, devices) - objective_function!(container, devices, model, S) + objective_function!(container, devices, model, get_network_formulation(network_model)) return end @@ -840,8 +817,8 @@ function construct_device!( sys::PSY.System, ::ArgumentConstructStage, model::DeviceModel{PSY.ThermalMultiStart, ThermalMultiStartUnitCommitment}, - network_model::NetworkModel{S}, -) where {S <: PM.AbstractPowerModel} + network_model::NetworkModel{<:PM.AbstractPowerModel}, +) devices = get_available_components(PSY.ThermalMultiStart, sys) add_variables!( @@ -923,8 +900,8 @@ function construct_device!( sys::PSY.System, ::ModelConstructStage, model::DeviceModel{PSY.ThermalMultiStart, ThermalMultiStartUnitCommitment}, - network_model::NetworkModel{S}, -) where {S <: PM.AbstractPowerModel} + network_model::NetworkModel{<:PM.AbstractPowerModel}, +) devices = get_available_components(PSY.ThermalMultiStart, sys) add_constraints!( @@ -974,7 +951,7 @@ function construct_device!( add_feedforward_constraints!(container, model, devices) - objective_function!(container, devices, model, S) + objective_function!(container, devices, model, get_network_formulation(network_model)) add_constraint_dual!(container, sys, model) return end @@ -984,8 +961,8 @@ function construct_device!( sys::PSY.System, ::ArgumentConstructStage, model::DeviceModel{PSY.ThermalMultiStart, ThermalMultiStartUnitCommitment}, - network_model::NetworkModel{S}, -) where {S <: PM.AbstractActivePowerModel} + network_model::NetworkModel{<:PM.AbstractActivePowerModel}, +) devices = get_available_components(PSY.ThermalMultiStart, sys) add_variables!( @@ -1051,8 +1028,8 @@ function construct_device!( sys::PSY.System, ::ModelConstructStage, model::DeviceModel{PSY.ThermalMultiStart, ThermalMultiStartUnitCommitment}, - network_model::NetworkModel{S}, -) where {S <: PM.AbstractActivePowerModel} + network_model::NetworkModel{<:PM.AbstractActivePowerModel}, +) devices = get_available_components(PSY.ThermalMultiStart, sys) initial_conditions!(container, devices, ThermalMultiStartUnitCommitment()) @@ -1096,7 +1073,7 @@ function construct_device!( add_feedforward_constraints!(container, model, devices) - objective_function!(container, devices, model, S) + objective_function!(container, devices, model, get_network_formulation(network_model)) add_constraint_dual!(container, sys, model) return end @@ -1106,8 +1083,8 @@ function construct_device!( sys::PSY.System, ::ArgumentConstructStage, model::DeviceModel{T, ThermalCompactUnitCommitment}, - network_model::NetworkModel{S}, -) where {T <: PSY.ThermalGen, S <: PM.AbstractPowerModel} + network_model::NetworkModel{<:PM.AbstractPowerModel}, +) where {T <: PSY.ThermalGen} devices = get_available_components(T, sys, get_attribute(model, "filter_function")) @@ -1178,8 +1155,8 @@ function construct_device!( sys::PSY.System, ::ModelConstructStage, model::DeviceModel{T, ThermalCompactUnitCommitment}, - network_model::NetworkModel{S}, -) where {T <: PSY.ThermalGen, S <: PM.AbstractPowerModel} + network_model::NetworkModel{<:PM.AbstractPowerModel}, +) where {T <: PSY.ThermalGen} devices = get_available_components(T, sys, get_attribute(model, "filter_function")) @@ -1214,7 +1191,7 @@ function construct_device!( add_feedforward_constraints!(container, model, devices) - objective_function!(container, devices, model, S) + objective_function!(container, devices, model, get_network_formulation(network_model)) add_constraint_dual!(container, sys, model) return end @@ -1224,8 +1201,8 @@ function construct_device!( sys::PSY.System, ::ArgumentConstructStage, model::DeviceModel{T, ThermalCompactUnitCommitment}, - network_model::NetworkModel{S}, -) where {T <: PSY.ThermalGen, S <: PM.AbstractActivePowerModel} + network_model::NetworkModel{<:PM.AbstractActivePowerModel}, +) where {T <: PSY.ThermalGen} devices = get_available_components(T, sys, get_attribute(model, "filter_function")) @@ -1289,8 +1266,8 @@ function construct_device!( sys::PSY.System, ::ModelConstructStage, model::DeviceModel{T, ThermalCompactUnitCommitment}, - network_model::NetworkModel{S}, -) where {T <: PSY.ThermalGen, S <: PM.AbstractActivePowerModel} + network_model::NetworkModel{<:PM.AbstractActivePowerModel}, +) where {T <: PSY.ThermalGen} devices = get_available_components(T, sys, get_attribute(model, "filter_function")) @@ -1317,7 +1294,7 @@ function construct_device!( add_feedforward_constraints!(container, model, devices) - objective_function!(container, devices, model, S) + objective_function!(container, devices, model, get_network_formulation(network_model)) add_constraint_dual!(container, sys, model) return end @@ -1327,8 +1304,8 @@ function construct_device!( sys::PSY.System, ::ArgumentConstructStage, model::DeviceModel{T, ThermalBasicCompactUnitCommitment}, - network_model::NetworkModel{S}, -) where {T <: PSY.ThermalGen, S <: PM.AbstractPowerModel} + network_model::NetworkModel{<:PM.AbstractPowerModel}, +) where {T <: PSY.ThermalGen} devices = get_available_components(T, sys, get_attribute(model, "filter_function")) @@ -1397,8 +1374,8 @@ function construct_device!( sys::PSY.System, ::ModelConstructStage, model::DeviceModel{T, ThermalBasicCompactUnitCommitment}, - network_model::NetworkModel{S}, -) where {T <: PSY.ThermalGen, S <: PM.AbstractPowerModel} + network_model::NetworkModel{<:PM.AbstractPowerModel}, +) where {T <: PSY.ThermalGen} devices = get_available_components(T, sys, get_attribute(model, "filter_function")) @@ -1431,7 +1408,7 @@ function construct_device!( add_feedforward_constraints!(container, model, devices) - objective_function!(container, devices, model, S) + objective_function!(container, devices, model, get_network_formulation(network_model)) add_constraint_dual!(container, sys, model) return end @@ -1441,8 +1418,8 @@ function construct_device!( sys::PSY.System, ::ArgumentConstructStage, model::DeviceModel{T, ThermalBasicCompactUnitCommitment}, - network_model::NetworkModel{S}, -) where {T <: PSY.ThermalGen, S <: PM.AbstractActivePowerModel} + network_model::NetworkModel{<:PM.AbstractActivePowerModel}, +) where {T <: PSY.ThermalGen} devices = get_available_components(T, sys, get_attribute(model, "filter_function")) @@ -1504,8 +1481,8 @@ function construct_device!( sys::PSY.System, ::ModelConstructStage, model::DeviceModel{T, ThermalBasicCompactUnitCommitment}, - network_model::NetworkModel{S}, -) where {T <: PSY.ThermalGen, S <: PM.AbstractActivePowerModel} + network_model::NetworkModel{<:PM.AbstractActivePowerModel}, +) where {T <: PSY.ThermalGen} devices = get_available_components(T, sys, get_attribute(model, "filter_function")) @@ -1530,7 +1507,7 @@ function construct_device!( add_feedforward_constraints!(container, model, devices) - objective_function!(container, devices, model, S) + objective_function!(container, devices, model, get_network_formulation(network_model)) add_constraint_dual!(container, sys, model) return end @@ -1540,8 +1517,8 @@ function construct_device!( sys::PSY.System, ::ArgumentConstructStage, model::DeviceModel{T, ThermalCompactDispatch}, - network_model::NetworkModel{S}, -) where {T <: PSY.ThermalGen, S <: PM.AbstractPowerModel} + network_model::NetworkModel{<:PM.AbstractPowerModel}, +) where {T <: PSY.ThermalGen} devices = get_available_components(T, sys, get_attribute(model, "filter_function")) @@ -1624,8 +1601,8 @@ function construct_device!( sys::PSY.System, ::ModelConstructStage, model::DeviceModel{T, ThermalCompactDispatch}, - network_model::NetworkModel{S}, -) where {T <: PSY.ThermalGen, S <: PM.AbstractPowerModel} + network_model::NetworkModel{<:PM.AbstractPowerModel}, +) where {T <: PSY.ThermalGen} devices = get_available_components(T, sys, get_attribute(model, "filter_function")) @@ -1658,7 +1635,7 @@ function construct_device!( add_feedforward_constraints!(container, model, devices) - objective_function!(container, devices, model, S) + objective_function!(container, devices, model, get_network_formulation(network_model)) add_constraint_dual!(container, sys, model) return end @@ -1668,8 +1645,8 @@ function construct_device!( sys::PSY.System, ::ArgumentConstructStage, model::DeviceModel{T, ThermalCompactDispatch}, - network_model::NetworkModel{S}, -) where {T <: PSY.ThermalGen, S <: PM.AbstractActivePowerModel} + network_model::NetworkModel{<:PM.AbstractActivePowerModel}, +) where {T <: PSY.ThermalGen} devices = get_available_components(T, sys, get_attribute(model, "filter_function")) @@ -1727,8 +1704,8 @@ function construct_device!( sys::PSY.System, ::ModelConstructStage, model::DeviceModel{T, ThermalCompactDispatch}, - network_model::NetworkModel{S}, -) where {T <: PSY.ThermalGen, S <: PM.AbstractActivePowerModel} + network_model::NetworkModel{<:PM.AbstractActivePowerModel}, +) where {T <: PSY.ThermalGen} devices = get_available_components(T, sys, get_attribute(model, "filter_function")) @@ -1753,7 +1730,7 @@ function construct_device!( add_feedforward_constraints!(container, model, devices) - objective_function!(container, devices, model, S) + objective_function!(container, devices, model, get_network_formulation(network_model)) add_constraint_dual!(container, sys, model) return end