Skip to content

Commit

Permalink
move cost term around to update objective function with variable fuel…
Browse files Browse the repository at this point in the history
… cost
  • Loading branch information
rodrigomha committed Nov 5, 2024
1 parent 33017ab commit 1108b6b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ function add_proportional_cost!(
multiplier = objective_function_multiplier(U(), V())
for d in devices
op_cost_data = PSY.get_operation_cost(d)
cost_term = proportional_cost(op_cost_data, U(), d, V())
iszero(cost_term) && continue
for t in get_time_steps(container)
cost_term = proportional_cost(container, op_cost_data, U(), d, V(), t)
iszero(cost_term) && continue
if !PSY.get_must_run(d)
exp = _add_proportional_term!(container, U(), d, cost_term * multiplier, t)
add_to_expression!(container, ProductionCostExpression, exp, d, t)
Expand Down
24 changes: 14 additions & 10 deletions src/devices_models/devices/thermal_generation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ initial_condition_variable(::InitialTimeDurationOff, d::PSY.ThermalGen, ::Abstra

########################Objective Function##################################################
# TODO: Decide what is the cost for OnVariable, if fixed or constant term in variable
function proportional_cost(cost::PSY.ThermalGenerationCost, S::OnVariable, T::PSY.ThermalGen, U::AbstractThermalFormulation)
return onvar_cost(cost, S, T, U) + PSY.get_constant_term(PSY.get_vom_cost(PSY.get_variable(cost))) + PSY.get_fixed(cost)
function proportional_cost(container::OptimizationContainer, cost::PSY.ThermalGenerationCost, S::OnVariable, T::PSY.ThermalGen, U::AbstractThermalFormulation, t::Int)
return onvar_cost(container, cost, S, T, U, t) + PSY.get_constant_term(PSY.get_vom_cost(PSY.get_variable(cost))) + PSY.get_fixed(cost)
end

proportional_cost(cost::PSY.MarketBidCost, ::OnVariable, ::PSY.ThermalGen, ::AbstractThermalFormulation) = PSY.get_no_load_cost(cost)
Expand Down Expand Up @@ -113,39 +113,39 @@ variable_cost(cost::PSY.OperationalCost, ::PowerAboveMinimumVariable, ::PSY.Ther
"""
Theoretical Cost at power output zero. Mathematically is the intercept with the y-axis
"""
function onvar_cost(cost::PSY.ThermalGenerationCost, S::OnVariable, d::PSY.ThermalGen, U::AbstractThermalFormulation)
return _onvar_cost(PSY.get_variable(cost), d)
function onvar_cost(container::OptimizationContainer, cost::PSY.ThermalGenerationCost, S::OnVariable, d::PSY.ThermalGen, U::AbstractThermalFormulation, t::Int)
return _onvar_cost(container, PSY.get_variable(cost), d, t)
end

function _onvar_cost(cost_function::PSY.CostCurve{PSY.PiecewisePointCurve}, d::PSY.ThermalGen)
# OnVariableCost is included in the Point itself for PiecewisePointCurve
return 0.0
end

function _onvar_cost(cost_function::Union{PSY.CostCurve{PSY.LinearCurve}, PSY.CostCurve{PSY.QuadraticCurve}}, d::PSY.ThermalGen)
function _onvar_cost(::OptimizationContainer, cost_function::Union{PSY.CostCurve{PSY.LinearCurve}, PSY.CostCurve{PSY.QuadraticCurve}}, d::PSY.ThermalGen, ::Int)
value_curve = PSY.get_value_curve(cost_function)
cost_component = PSY.get_function_data(value_curve)
# Always in \$/h
constant_term = PSY.get_constant_term(cost_component)
return constant_term
end

function _onvar_cost(cost_function::PSY.CostCurve{PSY.PiecewiseIncrementalCurve}, d::PSY.ThermalGen)
function _onvar_cost(::OptimizationContainer, cost_function::PSY.CostCurve{PSY.PiecewiseIncrementalCurve}, d::PSY.ThermalGen, ::Int)
# Input at min is used to transform to InputOutputCurve
return 0.0
end

function _onvar_cost(cost_function::PSY.FuelCurve{PSY.PiecewisePointCurve}, d::PSY.ThermalGen)
function _onvar_cost(::OptimizationContainer, cost_function::PSY.FuelCurve{PSY.PiecewisePointCurve}, d::PSY.ThermalGen, ::Int)
# OnVariableCost is included in the Point itself for PiecewisePointCurve
return 0.0
end

function _onvar_cost(cost_function::PSY.FuelCurve{PSY.PiecewiseIncrementalCurve}, d::PSY.ThermalGen)
function _onvar_cost(::OptimizationContainer, cost_function::PSY.FuelCurve{PSY.PiecewiseIncrementalCurve}, d::PSY.ThermalGen, ::Int)
# Input at min is used to transform to InputOutputCurve
return 0.0
end

function _onvar_cost(cost_function::Union{PSY.FuelCurve{PSY.LinearCurve}, PSY.FuelCurve{PSY.QuadraticCurve}}, d::PSY.ThermalGen)
function _onvar_cost(container::OptimizationContainer, cost_function::Union{PSY.FuelCurve{PSY.LinearCurve}, PSY.FuelCurve{PSY.QuadraticCurve}}, d::T, t::Int) where {T <: PSY.ThermalGen}
value_curve = PSY.get_value_curve(cost_function)
cost_component = PSY.get_function_data(value_curve)
# In Unit/h (unit typically in )
Expand All @@ -154,7 +154,11 @@ function _onvar_cost(cost_function::Union{PSY.FuelCurve{PSY.LinearCurve}, PSY.Fu
if typeof(fuel_cost) <: Float64
return constant_term * fuel_cost
else
error("Time series not implemented yet")
parameter_array = get_parameter_array(container, FuelCostParameter(), T)
parameter_multiplier =
get_parameter_multiplier_array(container, FuelCostParameter(), T)
name = PSY.get_name(d)
return constant_term * parameter_array[name, t] * parameter_multiplier[name, t]
end
end

Expand Down

0 comments on commit 1108b6b

Please sign in to comment.