Skip to content

Commit

Permalink
Merge branch 'main' of github.com:NREL-Sienna/PowerSystemsInvestments.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-lara committed Oct 8, 2024
2 parents aefd453 + edc8c6a commit 1fd686e
Show file tree
Hide file tree
Showing 59 changed files with 4,699 additions and 745 deletions.
18 changes: 16 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,31 @@ version = "0.1.0"
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
HiGHS = "87dc4568-4c63-4d18-b0c0-bb2238e4078b"
InfrastructureSystems = "2cd47ed4-ca9b-11e9-27f2-ab636a7671f1"
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
PowerModels = "c36e90e8-916a-50a6-bd94-075b64ef4655"
PowerNetworkMatrices = "bed98974-b02a-5e2f-9fe0-a103f5c450dd"
PowerSystems = "bcd98974-b02a-5e2f-9ee0-a103f5c450dd"
PowerSystemsInvestmentsPortfolios = "bed98974-b02a-5e2f-9fe0-a103f8c450dd"
PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
TimeSeries = "9e3dc215-6440-5c97-bce1-76c03772f85e"
TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f"

[compat]
DocStringExtensions = "~0.8, ~0.9"
DataStructures = "~0.18"
Dates = "1"
DocStringExtensions = "~v0.9"
InfrastructureSystems = "2"
JuMP = "1"
Logging = "1"
MathOptInterface = "1"
PowerModels = "^0.21"
PowerNetworkMatrices = "^0.11"
PowerSystems = "4"
PowerSystemsInvestmentsPortfolios = "0.1"
PrettyTables = "2"
TimeSeries = "^0.24.2"
julia = "^1.6"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![main - CI](https://github.com/NREL-Sienna/PowerSystemsInvestments.jl/workflows/main%20-%20CI/badge.svg)](https://github.com/NREL-Sienna/PowerSystemsInvestments.jl/actions/workflows/main-tests.yml)
[![codecov](https://codecov.io/gh/NREL-Sienna/PowerSystemsInvestments.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/NREL-Sienna/PowerSystemsInvestments.jl)
[![Documentation Build](https://github.com/NREL-Sienna/PowerSystemsInvestments.jl/workflows/Documentation/badge.svg?)](https://nrel-sienna.github.io/PowerSystemsInvestments.jl/stable)
[<img src="https://img.shields.io/badge/slack-@Sienna/PSYI.svg?logo=slack">](https://join.slack.com/t/nrel-sienna/shared_invite/zt-glam9vdu-o8A9TwZTZqqNTKHa7q3BpQ)
[<img src="https://img.shields.io/badge/slack-@Sienna/PSINV.svg?logo=slack">](https://join.slack.com/t/nrel-sienna/shared_invite/zt-glam9vdu-o8A9TwZTZqqNTKHa7q3BpQ)
[![PowerSystemsInvestments.jl Downloads](https://shields.io/endpoint?url=https://pkgs.genieframework.com/api/v1/badge/PowerSystemsInvestments)](https://pkgs.genieframework.com?packages=PowerSystemsInvestments)

## Development
Expand Down
75 changes: 61 additions & 14 deletions src/PowerSystemsInvestments.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import PowerModels
import DataStructures
import PowerNetworkMatrices
import PrettyTables
import TimeSeries
import Logging

const IS = InfrastructureSystems
const ISOPT = InfrastructureSystems.Optimization
Expand All @@ -20,21 +22,40 @@ const PM = PowerModels
const PNM = PowerNetworkMatrices

### Exports ###

export InvestmentModel
export SimpleCapacityExpansion
export InvestmentModelTemplate
export TransportModel

### Capital Model
export DiscountedCashFlow
export AggregateOperatingCost
export RepresentativePeriods

export SingleRegionBalanceModel

## Variables ##
export BuildCapacity
export ActivePowerVariable

## Expressions ##
export CumulativeCapacity
export CapitalCost
export TotalCapitalCost
export FixedOMCost
export FixedOperationModelCost
export VariableOMCost
export SupplyTotal
export DemandTotal

#remove later, just for testing
export objective_function!
export add_expression!
export add_to_expression!

using DocStringExtensions

# methods
export build!

@template (FUNCTIONS, METHODS) = """
$(TYPEDSIGNATURES)
$(DOCSTRING)
Expand Down Expand Up @@ -92,27 +113,53 @@ import InfrastructureSystems.Optimization:
convert_result_to_natural_units,
to_matrix,
get_store_container_type

import TimerOutputs

####
# Order Required
include("utils/mpi_utils.jl")
include("base/definitions.jl")

include("base/formulations.jl")
include("base/investment_model_store.jl")
include("base/network_model.jl")
include("base/abstract_formulation_types.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")
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/investment_problem.jl")
include("investment/investment_model.jl")

# Order Required
include("base/technology_model.jl")
include("investment/problem_template.jl")
include("base/optimization_container.jl")
include("base/investment_model_template.jl")

include("base/objective_function.jl")
include("base/single_optimization_container.jl")
include("base/multi_optimization_container.jl")

include("investment_model/investment_model_store.jl")
include("investment_model/investment_model.jl")

include("model_build/SingleInstanceSolve.jl")

include("utils/printing.jl")
include("utils/jump_utils.jl")
include("technology_models/technologies/common/add_variable.jl")
include("technology_models/technologies/common/add_to_expression.jl")
include("technology_models/technologies/supply_tech.jl")
include("technology_models/technologies/demand_tech.jl")
include("technology_models/technologies/storage_tech.jl")
include("network_models/singleregion_model.jl")

include("technology_models/technology_constructors/supply_constructor.jl")
include("technology_models/technology_constructors/demand_constructor.jl")
include("technology_models/technology_constructors/storage_constructor.jl")

include("technology_models/technologies/common/objective_function.jl/common_capital.jl")
include("technology_models/technologies/common/objective_function.jl/common_operations.jl")
include("technology_models/technologies/common/objective_function.jl/linear_curve.jl")
end
5 changes: 5 additions & 0 deletions src/base/abstract_formulation_types.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
abstract type AbstractTechnologyFormulation end

abstract type InvestmentTechnologyFormulation <: AbstractTechnologyFormulation end
abstract type OperationsTechnologyFormulation <: AbstractTechnologyFormulation end
abstract type FeasibilityTechnologyFormulation <: AbstractTechnologyFormulation end
1 change: 0 additions & 1 deletion src/base/capital_model.jl

This file was deleted.

23 changes: 22 additions & 1 deletion src/base/constraints.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
### Investment Constraints ###
struct MaximumCumulativeCapacity <: ISOPT.ConstraintType end

struct MaximumCumulativePowerCapacity <: ISOPT.ConstraintType end

struct MaximumCumulativeEnergyCapacity <: ISOPT.ConstraintType end

### Operations Constraints ###

struct SupplyDemandBalance <: ISOPT.ConstraintType end

struct MaximumCumulativeCapacity <: ISOPT.ConstraintType end
struct SingleRegionBalanceConstraint <: ISOPT.ConstraintType end

struct ActivePowerVariableLimitsConstraint <: ISOPT.ConstraintType end

struct ActivePowerLimitsConstraint <: ISOPT.ConstraintType end

struct OutputActivePowerVariableLimitsConstraint <: ISOPT.ConstraintType end

struct InputActivePowerVariableLimitsConstraint <: ISOPT.ConstraintType end

struct EnergyBalanceConstraint <: ISOPT.ConstraintType end

struct StateofChargeLimitsConstraint <: ISOPT.ConstraintType end
18 changes: 18 additions & 0 deletions src/base/definitions.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const UNSET_HORIZON = Dates.Millisecond(0)
const UNSET_RESOLUTION = Dates.Millisecond(0)
const UNSET_INI_TIME = Dates.DateTime(0)

const SECONDS_IN_MINUTE = 60.0
const MINUTES_IN_HOUR = 60.0
const SECONDS_IN_HOUR = 3600.0
const MILLISECONDS_IN_HOUR = 3600000.0
const MAX_START_STAGES = 3
const OBJECTIVE_FUNCTION_POSITIVE = 1.0
const OBJECTIVE_FUNCTION_NEGATIVE = -1.0

# Type Alias for JuMP containers
const GAE = JuMP.GenericAffExpr{Float64, JuMP.VariableRef}
const JuMPAffineExpressionArray = Matrix{GAE}
const JuMPAffineExpressionVector = Vector{GAE}

IS.@scoped_enum(SOSStatusVariable, NO_VARIABLE = 1, PARAMETER = 2, VARIABLE = 3,)
20 changes: 14 additions & 6 deletions src/base/expressions.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
struct SupplyTotal <: ISOPT.ExpressionType end
struct DemandTotal <: ISOPT.ExpressionType end
abstract type InvestmentExpressionType <: ISOPT.ExpressionType end
abstract type OperationsExpressionType <: ISOPT.ExpressionType end

struct CumulativeCapacity <: ISOPT.ExpressionType end
struct CapitalCost <: ISOPT.ExpressionType end
struct FixedOMCost <: ISOPT.ExpressionType end
struct SupplyTotal <: OperationsExpressionType end
struct DemandTotal <: OperationsExpressionType end
struct ActivePowerBalance <: OperationsExpressionType end

struct CumulativeCapacity <: InvestmentExpressionType end

struct CumulativePowerCapacity <: InvestmentExpressionType end
struct CumulativeEnergyCapacity <: InvestmentExpressionType end

struct CapitalCost <: InvestmentExpressionType end
struct FixedOperationModelCost <: InvestmentExpressionType end

struct TotalCapitalCost <: ISOPT.ExpressionType end

struct VariableOMCost <: ISOPT.ExpressionType end
struct VariableOMCost <: OperationsExpressionType end
3 changes: 0 additions & 3 deletions src/base/feasibility_model.jl

This file was deleted.

18 changes: 0 additions & 18 deletions src/base/formulations.jl

This file was deleted.

71 changes: 71 additions & 0 deletions src/base/investment_model_template.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
abstract type AbstractInvestmentModelTemplate end

mutable struct InvestmentModelTemplate <: AbstractInvestmentModelTemplate
capital_model::CapitalCostModel
operation_model::OperationCostModel
feasibility_model::FeasibilityModel
transport_model::TransportModel{<:AbstractTransportAggregation}
technology_models::Dict # Type to be refined later

function InvestmentModelTemplate(
capital_model::CapitalCostModel,
operation_model::OperationCostModel,
feasibility_model::FeasibilityModel,
transport_model::TransportModel{T},
) where {T <: AbstractTransportAggregation}
new(capital_model, operation_model, feasibility_model, transport_model, Dict())
end
end

function Base.isempty(template::InvestmentModelTemplate)
if !isempty(template.technologies)
return false
else
return true
end
end

InvestmentModelTemplate(::Type{T}) where {T <: AbstractTransportAggregation} =
InvestmentModelTemplate(TransportModel(T))
InvestmentModelTemplate() = InvestmentModelTemplate(SingleRegionPowerModel)

get_technology_models(template::InvestmentModelTemplate) = template.technologies
get_network_model(template::InvestmentModelTemplate) = template.network_model
get_network_formulation(template::InvestmentModelTemplate) =
get_network_formulation(get_network_model(template))

"""
Sets the network model in a template.
"""
function set_transport_model!(
template::InvestmentModelTemplate,
model::TransportModel{<:AbstractTransportAggregation},
)
template.transport_model = model
return
end

function set_device_model!(
template::InvestmentModelTemplate,
component_type::Type{<:PSIP.Technology},
investment_formulation::Type{<:InvestmentTechnologyFormulation},
operations_formulation::Type{<:OperationsTechnologyFormulation},
)
set_device_model!(
template,
TechnologyModel(component_type, investment_formulation, operations_formulation),
)
return
end

function set_device_model!(
template::InvestmentModelTemplate,
model::TechnologyModel{
<:PSIP.Technology,
<:InvestmentTechnologyFormulation,
<:OperationsTechnologyFormulation,
},
)
_set_model!(template.technologies, model)
return
end
5 changes: 0 additions & 5 deletions src/base/investment_problem.jl

This file was deleted.

Loading

0 comments on commit 1fd686e

Please sign in to comment.