diff --git a/src/PowerSystemsInvestments.jl b/src/PowerSystemsInvestments.jl index 5eb4bf8..b6422e4 100644 --- a/src/PowerSystemsInvestments.jl +++ b/src/PowerSystemsInvestments.jl @@ -109,9 +109,11 @@ include("utils/mpi_utils.jl") include("base/definitions.jl") include("base/abstract_formulation_types.jl") -include("capital/capital_formulations.jl") -include("operation/operation_formulations.jl") -include("feasibility/feasibility_formulations.jl") +include("capital/technology_capital_formulations.jl") +include("capital/capital_models.jl") +include("operation/technology_operation_formulations.jl") +include("operation/feasibility_model.jl") +include("operation/operation_model.jl") include("base/transport_model.jl") include("base/constraints.jl") include("base/variables.jl") @@ -119,8 +121,6 @@ include("base/expressions.jl") include("base/parameters.jl") include("base/settings.jl") include("base/solution_algorithms.jl") -#include("base/operation_model.jl") -#include("base/feasibility_model.jl") include("base/technology_model.jl") include("base/investment_model_template.jl") diff --git a/src/base/abstract_formulation_types.jl b/src/base/abstract_formulation_types.jl index 5bae82e..b7fb1e2 100644 --- a/src/base/abstract_formulation_types.jl +++ b/src/base/abstract_formulation_types.jl @@ -1,5 +1,5 @@ abstract type AbstractTechnologyFormulation end abstract type InvestmentTechnologyFormulation <: AbstractTechnologyFormulation end -abstract type TechnologyOperationsFormulation <: AbstractTechnologyFormulation end -abstract type TechnologyFeasibilityFormulation <: AbstractTechnologyFormulation end +abstract type OperationsTechnologyFormulation <: AbstractTechnologyFormulation end +abstract type FeasibilityTechnologyFormulation <: AbstractTechnologyFormulation end diff --git a/src/base/investment_model_template.jl b/src/base/investment_model_template.jl index 6d1c363..e410f83 100644 --- a/src/base/investment_model_template.jl +++ b/src/base/investment_model_template.jl @@ -4,12 +4,19 @@ mutable struct InvestmentModelTemplate <: AbstractInvestmentModelTemplate capital_model::CapitalCostModel operation_model::OperationCostModel transport_model::TransportModel{<:AbstractTransportModel} - technology_models::TechnologiesModelContainer + technology_models::Dict # Type to be refined later function InvestmentModelTemplate( - transport::TransportModel{T}, + capital_model::CapitalCostModel, + operation_model::OperationCostModel, + transport_model::TransportModel{T} ) where {T <: AbstractTransportModel} - new(transport, TechnologiesModelContainer()) + new( + capital_model, + operation_model, + transport_model, + Dict() + ) end end diff --git a/src/base/technology_model.jl b/src/base/technology_model.jl index 6a08029..e53bec2 100644 --- a/src/base/technology_model.jl +++ b/src/base/technology_model.jl @@ -91,310 +91,10 @@ function TechnologyModel( time_series_names=get_default_time_series_names(D, B, C), attributes=Dict{String, Any}(), ) where { - D <: PSIP.SupplyTechnology{PSY.ThermalStandard}, + D <: PSIP.SupplyTechnology{T}, B <: ContinuousInvestment, C <: BasicDispatch, -} - attributes_ = get_default_attributes(D, B, C) - for (k, v) in attributes - attributes_[k] = v - end - - _check_technology_formulation(D, 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, B, C}( - use_slacks, - duals, - time_series_names, - attributes_, - nothing, - ) -end - -function TechnologyModel( - ::Type{D}, - ::Type{B}, - ::Type{C}; - use_slacks=false, - duals=Vector{DataType}(), - time_series_names=get_default_time_series_names(D, B, C), - attributes=Dict{String, Any}(), -) where { - D <: PSIP.SupplyTechnology{PSY.ThermalStandard}, - B <: IntegerInvestment, - C <: BasicDispatch, -} - attributes_ = get_default_attributes(D, B, C) - for (k, v) in attributes - attributes_[k] = v - end - - _check_technology_formulation(D, 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, B, C}( - use_slacks, - duals, - time_series_names, - attributes_, - nothing, - ) -end - -function TechnologyModel( - ::Type{D}, - ::Type{B}, - ::Type{C}; - use_slacks=false, - duals=Vector{DataType}(), - time_series_names=get_default_time_series_names(D, B, C), - attributes=Dict{String, Any}(), -) where { - D <: PSIP.SupplyTechnology{PSY.RenewableDispatch}, - B <: ContinuousInvestment, - C <: BasicDispatch, -} - attributes_ = get_default_attributes(D, B, C) - for (k, v) in attributes - attributes_[k] = v - end - - _check_technology_formulation(D, 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, B, C}( - use_slacks, - duals, - time_series_names, - attributes_, - nothing, - ) -end - -function TechnologyModel( - ::Type{D}, - ::Type{B}, - ::Type{C}; - use_slacks=false, - duals=Vector{DataType}(), - time_series_names=get_default_time_series_names(D, B, C), - attributes=Dict{String, Any}(), -) where { - D <: PSIP.SupplyTechnology{PSY.RenewableDispatch}, - B <: IntegerInvestment, - C <: BasicDispatch, -} - attributes_ = get_default_attributes(D, B, C) - for (k, v) in attributes - attributes_[k] = v - end - - _check_technology_formulation(D, 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, B, C}( - use_slacks, - duals, - time_series_names, - attributes_, - nothing, - ) -end - -function TechnologyModel( - ::Type{D}, - ::Type{B}, - ::Type{C}; - use_slacks=false, - duals=Vector{DataType}(), - time_series_names=get_default_time_series_names(D, B, C), - attributes=Dict{String, Any}(), -) where { - D <: PSIP.SupplyTechnology{PSY.ThermalStandard}, - B <: ContinuousInvestment, - C <: ThermalNoDispatch, -} - attributes_ = get_default_attributes(D, B, C) - for (k, v) in attributes - attributes_[k] = v - end - - _check_technology_formulation(D, 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, B, C}( - use_slacks, - duals, - time_series_names, - attributes_, - nothing, - ) -end - -function TechnologyModel( - ::Type{D}, - ::Type{B}, - ::Type{C}; - use_slacks=false, - duals=Vector{DataType}(), - time_series_names=get_default_time_series_names(D, B, C), - attributes=Dict{String, Any}(), -) where { - D <: PSIP.SupplyTechnology{PSY.ThermalStandard}, - B <: IntegerInvestment, - C <: ThermalNoDispatch, -} - attributes_ = get_default_attributes(D, B, C) - for (k, v) in attributes - attributes_[k] = v - end - - _check_technology_formulation(D, 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, B, C}( - use_slacks, - duals, - time_series_names, - attributes_, - nothing, - ) -end - -function TechnologyModel( - ::Type{D}, - ::Type{B}, - ::Type{C}; - use_slacks=false, - duals=Vector{DataType}(), - time_series_names=get_default_time_series_names(D, B, C), - attributes=Dict{String, Any}(), -) where { - D <: PSIP.SupplyTechnology{PSY.RenewableDispatch}, - B <: ContinuousInvestment, - C <: RenewableNoDispatch, -} - attributes_ = get_default_attributes(D, B, C) - for (k, v) in attributes - attributes_[k] = v - end - - _check_technology_formulation(D, 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, B, C}( - use_slacks, - duals, - time_series_names, - attributes_, - nothing, - ) -end - -function TechnologyModel( - ::Type{D}, - ::Type{B}, - ::Type{C}; - use_slacks=false, - duals=Vector{DataType}(), - time_series_names=get_default_time_series_names(D, B, C), - attributes=Dict{String, Any}(), -) where { - D <: PSIP.SupplyTechnology{PSY.RenewableDispatch}, - B <: IntegerInvestment, - C <: RenewableNoDispatch, -} - attributes_ = get_default_attributes(D, B, C) - for (k, v) in attributes - attributes_[k] = v - end - - _check_technology_formulation(D, 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, B, C}( - use_slacks, - duals, - time_series_names, - attributes_, - nothing, - ) -end - -#Move to different file later -function TechnologyModel( - ::Type{D}, - ::Type{B}, - ::Type{C}; - use_slacks=false, - duals=Vector{DataType}(), - time_series_names=get_default_time_series_names(D, B, C), - attributes=Dict{String, Any}(), -) where { - D <: PSIP.DemandRequirement{PSY.PowerLoad}, - B <: StaticLoadInvestment, - C <: BasicDispatch, -} - attributes_ = get_default_attributes(D, B, C) - for (k, v) in attributes - attributes_[k] = v - end - - _check_technology_formulation(D, 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, B, C}( - use_slacks, - duals, - time_series_names, - attributes_, - nothing, - ) -end - -function TechnologyModel( - ::Type{D}, - ::Type{B}, - ::Type{C}; - use_slacks=false, - duals=Vector{DataType}(), - time_series_names=get_default_time_series_names(D, B, C), - attributes=Dict{String, Any}(), -) where { - D <: PSIP.StorageTechnology{PSY.EnergyReservoirStorage}, - B <: ContinuousInvestment, - C <: BasicDispatch, -} - attributes_ = get_default_attributes(D, B, C) - for (k, v) in attributes - attributes_[k] = v - end - - _check_technology_formulation(D, 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, B, C}( - use_slacks, - duals, - time_series_names, - attributes_, - nothing, - ) -end - -function TechnologyModel( - ::Type{D}, - ::Type{B}, - ::Type{C}; - use_slacks=false, - time_series_names=get_default_time_series_names(D, B, C), - attributes=Dict{String, Any}(), -) where { - D <: PSIP.StorageTechnology{PSY.EnergyReservoirStorage}, - B <: IntegerInvestment, - C <: BasicDispatch, -} +} where {T <: PSY.StaticInjection} attributes_ = get_default_attributes(D, B, C) for (k, v) in attributes attributes_[k] = v diff --git a/src/investment_model/investment_model.jl b/src/investment_model/investment_model.jl index 49174c0..2df7009 100644 --- a/src/investment_model/investment_model.jl +++ b/src/investment_model/investment_model.jl @@ -69,30 +69,5 @@ function InvestmentModel( check_numerical_bounds=check_numerical_bounds, store_variable_names=store_variable_names, ) - return DecisionModel(template, sys, settings, jump_model; name=name) -end - -function InvestmentModel( - ::Type{I}, - ::Type{S}, - template::AbstractInvestmentModelTemplate, - portfolio::PSIP.Portfolio, - jump_model::Union{Nothing, JuMP.Model}=nothing; - kwargs..., -) where {I <: InvestmentModel, S <: SolutionAlgorithm} - return InvestmentModel{I, S}(template, portfolio, jump_model; kwargs...) -end - -function InvestmentModel( - template::AbstractInvestmentModelTemplate, - portfolio::PSIP.Portfolio, - jump_model::Union{Nothing, JuMP.Model}=nothing; - kwargs..., -) - return InvestmentModel{GenericCapacityExpansion, SingleInstanceSolve}( - template, - portfolio, - jump_model; - kwargs..., - ) + return InvestmentModel(template, sys, settings, jump_model; name=name) end diff --git a/src/feasibility/feasibility_model.jl b/src/operation/feasibility_model.jl similarity index 100% rename from src/feasibility/feasibility_model.jl rename to src/operation/feasibility_model.jl diff --git a/src/operation/technology_operation_formulations.jl b/src/operation/technology_operation_formulations.jl index 5e99106..7cd2c47 100644 --- a/src/operation/technology_operation_formulations.jl +++ b/src/operation/technology_operation_formulations.jl @@ -1,3 +1,3 @@ ### Operations Formulations ### -struct BasicDispatch <: TechnologyOperationsFormulation end +struct BasicDispatch <: FeasibilityTechnologyFormulation end diff --git a/src/technology_models/technologies/storage_tech.jl b/src/technology_models/technologies/storage_tech.jl index 3ad426c..d96322b 100644 --- a/src/technology_models/technologies/storage_tech.jl +++ b/src/technology_models/technologies/storage_tech.jl @@ -136,32 +136,6 @@ function add_expression!( return end -function add_expression!( - container::SingleOptimizationContainer, - expression_type::T, - devices::U, - formulation::AbstractTechnologyFormulation, -) where { - T <: VariableOMCost, - U <: Union{Vector{D}, IS.FlattenIteratorWrapper{D}}, -} where {D <: PSIP.SupplyTechnology} - @assert !isempty(devices) - time_steps = get_time_steps(container) - binary = false - - var = get_variable(container, BuildCapacity(), D) - - expression = add_expression_container!( - container, - expression_type, - D, - [PSIP.get_name(d) for d in devices], - time_steps, - ) - - return -end - function add_to_expression!( container::SingleOptimizationContainer, expression_type::T, @@ -230,7 +204,7 @@ function add_expression!( ) where { T <: ActivePowerBalance, U <: Union{Vector{D}, IS.FlattenIteratorWrapper{D}}, -} where {D <: PSIP.SupplyTechnology} +} where {D <: PSIP.StorageTechnology} @assert !isempty(devices) time_steps = get_time_steps(container) #binary = false @@ -531,7 +505,7 @@ function objective_function!( devices::IS.FlattenIteratorWrapper{T}, #DeviceModel{T, U}, formulation::BasicDispatch, #Type{<:PM.AbstractPowerModel}, -) where {T <: PSIP.SupplyTechnology}#, U <: ActivePowerVariable} +) where {T <: PSIP.StorageTechnology}#, U <: ActivePowerVariable} add_variable_cost!(container, ActivePowerVariable(), devices, formulation) #U() #add_start_up_cost!(container, StartVariable(), devices, U()) #add_shut_down_cost!(container, StopVariable(), devices, U())