Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New PR for Fuel Cost #1180

Merged
merged 19 commits into from
Dec 11, 2024
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
1 change: 1 addition & 0 deletions src/PowerSimulations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ export EmergencyUp
export EmergencyDown
export RawACE
export ProductionCostExpression
export FuelConsumptionExpression
export ActivePowerRangeExpressionLB
export ActivePowerRangeExpressionUB

Expand Down
2 changes: 1 addition & 1 deletion src/core/device_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ mutable struct DeviceModel{D <: PSY.Device, B <: AbstractDeviceFormulation}
use_slacks::Bool
duals::Vector{DataType}
services::Vector{ServiceModel}
time_series_names::Dict{Type{<:TimeSeriesParameter}, String}
time_series_names::Dict{Type{<:ParameterType}, String}
attributes::Dict{String, Any}
subsystem::Union{Nothing, String}

Expand Down
2 changes: 2 additions & 0 deletions src/core/expressions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ struct EmergencyUp <: ExpressionType end
struct EmergencyDown <: ExpressionType end
struct RawACE <: ExpressionType end
struct ProductionCostExpression <: CostExpressions end
struct FuelConsumptionExpression <: ExpressionType end
struct ActivePowerRangeExpressionLB <: RangeConstraintLBExpressions end
struct ActivePowerRangeExpressionUB <: RangeConstraintUBExpressions end
struct ComponentReserveUpBalanceExpression <: ExpressionType end
Expand All @@ -16,6 +17,7 @@ struct InterfaceTotalFlow <: ExpressionType end
struct PTDFBranchFlow <: ExpressionType end

should_write_resulting_value(::Type{<:CostExpressions}) = true
should_write_resulting_value(::Type{FuelConsumptionExpression}) = true
should_write_resulting_value(::Type{InterfaceTotalFlow}) = true
should_write_resulting_value(::Type{RawACE}) = true
should_write_resulting_value(::Type{ActivePowerBalance}) = true
Expand Down
15 changes: 13 additions & 2 deletions src/core/optimization_container.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ function get_objective_expression(v::ObjectiveFunction)
else
# JuMP doesn't support expression conversion from Affn to QuadExpressions
if isa(v.invariant_terms, JuMP.GenericQuadExpr)
return JuMP.add_to_expression!(v.invariant_terms, v.variant_terms)
# Avoid mutation of invariant term
temp_expr = JuMP.QuadExpr()
JuMP.add_to_expression!(temp_expr, v.invariant_terms)
return JuMP.add_to_expression!(temp_expr, v.variant_terms)
else
# This will mutate the variant terms, but these are reseted at each step.
return JuMP.add_to_expression!(v.variant_terms, v.invariant_terms)
end
end
Expand Down Expand Up @@ -1438,11 +1442,18 @@ function add_expression_container!(
::T,
::Type{U},
axs...;
expr_type = GAE,
sparse = false,
meta = IS.Optimization.CONTAINER_KEY_EMPTY_META,
) where {T <: ExpressionType, U <: Union{PSY.Component, PSY.System}}
expr_key = ExpressionKey(T, U, meta)
return _add_expression_container!(container, expr_key, GAE, axs...; sparse = sparse)
return _add_expression_container!(
container,
expr_key,
expr_type,
axs...;
sparse = sparse,
)
end

function add_expression_container!(
Expand Down
9 changes: 8 additions & 1 deletion src/core/parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ function add_component_name!(attr::TimeSeriesAttributes, name::String, uuid::Str
return
end

_get_ts_uuid(attr::TimeSeriesAttributes, name) = attr.component_name_to_ts_uuid[name]
function _get_ts_uuid(attr::TimeSeriesAttributes, name)
return attr.component_name_to_ts_uuid[name]
end

struct VariableValueAttributes{T <: OptimizationContainerKey} <: ParameterAttributes
attribute_key::T
Expand Down Expand Up @@ -303,6 +305,11 @@ Parameter to define cost function coefficient
"""
struct CostFunctionParameter <: ObjectiveFunctionParameter end

"""
Parameter to define fuel cost time series
"""
struct FuelCostParameter <: ObjectiveFunctionParameter end

abstract type AuxVariableValueParameter <: RightHandSideParameter end

struct EventParameter <: ParameterType end
Expand Down
Loading
Loading