Skip to content
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
12 changes: 1 addition & 11 deletions src/InfrastructureOptimizationModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,7 @@ export set_hvdc_network_model!
# Extension points for downstream packages (e.g., PowerOperationsModels)
# These functions have fallback implementations in IOM but are meant to be
# extended with device-specific methods in POM
export construct_device!
export construct_service!
export add_variables!
export add_constraints!
export add_to_expression!
export add_constant_to_jump_expression!
export add_proportional_to_jump_expression!
Expand All @@ -232,7 +229,6 @@ export add_pwl_linking_constraint!
export add_pwl_normalization_constraint!
export add_pwl_sos2_constraint!
export get_pwl_cost_expression
export add_to_objective_function!
export process_market_bid_parameters!

## Outputs interfaces
Expand Down Expand Up @@ -319,9 +315,6 @@ export get_multiplier_array
export get_parameter_column_refs
export get_service_name
export get_default_time_series_type
export get_expression_multiplier
export get_variable_multiplier
export get_multiplier_value
export add_expression_container!

# Initial condition infrastructure (extension points for POM)
Expand Down Expand Up @@ -391,7 +384,7 @@ export process_import_export_parameters!, process_market_bid_parameters!
# Types
export AreaControlError
# Extension point functions
export add_variable!, requires_initialization
export add_service_variables!, requires_initialization
# End bulk-added

# more extension points
Expand Down Expand Up @@ -439,7 +432,6 @@ export add_constraints_container!, add_variable_cost!
export add_initial_condition_container!
export has_initial_condition_value, set_ic_quantity!, get_last_recorded_value
export set_initial_conditions_model_container!, get_initial_conditions_model_container
export get_initial_conditions_device_model
export _validate_warm_start_support, _add_services_to_device_model!
export get_component_type, get_component_name, add_jump_parameter
# Template/model access
Expand Down Expand Up @@ -657,6 +649,4 @@ include("utils/jump_utils.jl")
include("utils/powersystems_utils.jl")
include("utils/time_series_utils.jl")
include("utils/datetime_utils.jl")
include("utils/generate_valid_formulations.jl")

end
26 changes: 7 additions & 19 deletions src/common_models/add_auxiliary_variable.jl
Original file line number Diff line number Diff line change
@@ -1,29 +1,17 @@
# FIXME The only difference between the signature and the definition are plural
# vs singular (add_variableS) and type vs instance (2nd argument). seems redundant/confusing.
# also, identical to add_variable.jl except for AuxVariableType vs VariableType.
"""
Add variables to the OptimizationContainer for any component.
"""
function add_variables!(
container::OptimizationContainer,
::Type{T},
devices::Union{Vector{U}, IS.FlattenIteratorWrapper{U}},
formulation::Union{AbstractDeviceFormulation, AbstractServiceFormulation},
) where {T <: AuxVariableType, U <: PSY.Component}
add_variable!(container, T(), devices, formulation)
return
end

@doc raw"""
Default implementation of adding auxiliary variable to the model.
"""
function add_variable!(
function add_variables!(
container::OptimizationContainer,
var_type::AuxVariableType,
::Type{T},
devices::U,
formulation,
) where {U <: Union{Vector{D}, IS.FlattenIteratorWrapper{D}}} where {D <: PSY.Component}
) where {
T <: AuxVariableType,
U <: Union{Vector{D}, IS.FlattenIteratorWrapper{D}},
} where {D <: IS.InfrastructureSystemsComponent}
@assert !isempty(devices)
var_type = T()
time_steps = get_time_steps(container)
add_aux_variable_container!(
container,
Expand Down
41 changes: 9 additions & 32 deletions src/common_models/add_variable.jl
Original file line number Diff line number Diff line change
@@ -1,31 +1,3 @@
"""
Add variables to the OptimizationContainer for any component.
"""
function add_variables!(
container::OptimizationContainer,
::Type{T},
devices::Union{Vector{U}, IS.FlattenIteratorWrapper{U}},
formulation::Union{AbstractServiceFormulation, AbstractDeviceFormulation},
) where {T <: VariableType, U <: PSY.Component}
add_variable!(container, T(), devices, formulation)
return
end

"""
Add variables to the OptimizationContainer for a service.
"""
function add_variables!(
container::OptimizationContainer,
::Type{T},
service::U,
contributing_devices::Union{Vector{V}, IS.FlattenIteratorWrapper{V}},
formulation::AbstractReservesFormulation,
) where {T <: VariableType, U <: PSY.AbstractReserve, V <: PSY.Component}
# PERF: compilation hotspot. Switch to TSC.
add_service_variable!(container, T(), service, contributing_devices, formulation)
return
end

@doc raw"""
Adds a variable to the optimization model and to the affine expressions contained
in the optimization_container model according to the specified sign. Based on the inputs, the variable can
Expand Down Expand Up @@ -59,16 +31,17 @@ If binary = true:
* initial_value : Provides the function over device to obtain the warm start value

"""
function add_variable!(
function add_variables!(
container::OptimizationContainer,
variable_type::T,
::Type{T},
devices::U,
formulation,
) where {
T <: VariableType,
U <: Union{Vector{D}, IS.FlattenIteratorWrapper{D}},
} where {D <: IS.InfrastructureSystemsComponent}
@assert !isempty(devices)
variable_type = T()
time_steps = get_time_steps(container)
settings = get_settings(container)
binary = get_variable_binary(variable_type, D, formulation)
Expand Down Expand Up @@ -103,9 +76,12 @@ function add_variable!(
return
end

function add_service_variable!(
"""
Add variables to the OptimizationContainer for a service.
"""
function add_service_variables!(
container::OptimizationContainer,
variable_type::T,
::Type{T},
service::U,
contributing_devices::V,
formulation::AbstractServiceFormulation,
Expand All @@ -115,6 +91,7 @@ function add_service_variable!(
V <: Union{Vector{D}, IS.FlattenIteratorWrapper{D}},
} where {D <: PSY.Component}
@assert !isempty(contributing_devices)
variable_type = T()
time_steps = get_time_steps(container)

binary = get_variable_binary(variable_type, U, formulation)
Expand Down
Loading
Loading