Skip to content

Commit

Permalink
add group name to technologymodel
Browse files Browse the repository at this point in the history
  • Loading branch information
jerrypotts committed Oct 10, 2024
1 parent 09dea55 commit 050fa78
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/base/technology_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mutable struct TechnologyModel{
duals::Vector{DataType}
time_series_names::Dict{Type{<:TimeSeriesParameter}, String}
attributes::Dict{String, Any}
group_name::String
end

function _set_model!(
Expand Down Expand Up @@ -72,6 +73,7 @@ function TechnologyModel(
duals=Vector{DataType}(),
time_series_names=get_default_time_series_names(D, A, B, C),
attributes=Dict{String, Any}(),
group_name = ""
) where {
D <: PSIP.Technology,
A <: InvestmentTechnologyFormulation,
Expand All @@ -86,5 +88,5 @@ function TechnologyModel(
#_check_technology_formulation(D, A, B, C)
#TODO: new is only defined for inner constructors, replace for now but we might want to reorganize this file later
#new{D, B, C}(use_slacks, duals, time_series_names, attributes_, nothing)
return TechnologyModel{D, A, B, C}(use_slacks, duals, time_series_names, attributes_)
return TechnologyModel{D, A, B, C}(use_slacks, duals, time_series_names, attributes_, group_name)
end
4 changes: 4 additions & 0 deletions src/technology_models/technologies/common/add_variable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ function add_variable!(
variable_type::T,
devices::U,
formulation::AbstractTechnologyFormulation,
group_name::String
) where {
T <: InvestmentVariableType,
U <: Union{D, Vector{D}, IS.FlattenIteratorWrapper{D}},
Expand All @@ -17,6 +18,7 @@ function add_variable!(
D,
[PSIP.get_name(d) for d in devices],
time_steps,
meta=group_name
)

for t in time_steps, d in devices
Expand All @@ -41,6 +43,7 @@ function add_variable!(
variable_type::T,
devices::U,
formulation::AbstractTechnologyFormulation,
group_name::String
) where {
T <: OperationsVariableType,
U <: Union{D, Vector{D}, IS.FlattenIteratorWrapper{D}},
Expand All @@ -55,6 +58,7 @@ function add_variable!(
D,
[PSIP.get_name(d) for d in devices],
time_steps,
meta = group_name
)

for t in time_steps, d in devices
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function construct_technologies!(

# BuildCapacity variable
# This should break if a name is passed here a second time
add_variable!(container, BuildCapacity(), devices, B())
add_variable!(container, BuildCapacity(), devices, B(), technology_model.group_name)

# CumulativeCapacity
add_expression!(container, CumulativeCapacity(), devices, B())
Expand All @@ -48,7 +48,7 @@ function construct_technologies!(
devices = [PSIP.get_technology(T, p, n) for n in names]

#ActivePowerVariable
add_variable!(container, ActivePowerVariable(), devices, C())
add_variable!(container, ActivePowerVariable(), devices, C(), technology_model.group_name)

# SupplyTotal
add_to_expression!(container, EnergyBalance(), devices, C())
Expand Down Expand Up @@ -161,3 +161,34 @@ function construct_technologies!(

return
end

#Added constructor for unit investment problems. Does not do anything yet, purely for testing purposes
function construct_technologies!(
container::SingleOptimizationContainer,
p::PSIP.Portfolio,
names::Vector{String},
::ArgumentConstructStage,
::CapitalCostModel,
technology_model::TechnologyModel{T, B, C, D},
# network_model::NetworkModel{<:PM.AbstractActivePowerModel},
) where {
T <: PSIP.SupplyTechnology,
B <: IntegerInvestment,
C <: BasicDispatch,
D <: FeasibilityTechnologyFormulation,
}

#TODO: Port get_available_component functions from PSY
# filter based on technology names passed
#TODO: Review when we start working with larger models
devices = [PSIP.get_technology(T, p, n) for n in names]
#PSIP.get_technologies(T, p)

# BuildCapacity variable
# This should break if a name is passed here a second time
add_variable!(container, BuildCapacity(), devices, B(), technology_model.group_name)

# CumulativeCapacity
#add_expression!(container, CumulativeCapacity(), devices, B(), technology_model.group_name)
return
end

0 comments on commit 050fa78

Please sign in to comment.