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

Market bid cost with pwl cost curve #1182

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ function _add_variable_cost_to_objective!(
initial_time = get_initial_time(container)
incremental_cost_curves = PSY.get_incremental_offer_curves(cost_function)
decremental_cost_curves = PSY.get_decremental_offer_curves(cost_function)
if isnothing(decremental_cost_curves)
if !isnothing(decremental_cost_curves)
error("Component $(component_name) is not allowed to participate as a demand.")
end
#=
Expand Down Expand Up @@ -583,3 +583,31 @@ function _add_service_bid_cost!(
end

function _add_service_bid_cost!(::OptimizationContainer, ::PSY.Component, ::PSY.Service) end

function _add_vom_cost_to_objective!(
container::OptimizationContainer,
::T,
component::PSY.Component,
op_cost::PSY.MarketBidCost,
::U,
) where {T <: VariableType, U <: AbstractDeviceFormulation}
incremental_cost_curves = PSY.get_incremental_offer_curves(op_cost)
decremental_cost_curves = PSY.get_decremental_offer_curves(op_cost)
power_units = PSY.get_power_units(incremental_cost_curves)
vom_cost = PSY.get_vom_cost(incremental_cost_curves)
multiplier = 1.0 # VOM Cost is always positive
cost_term = PSY.get_proportional_term(vom_cost)
iszero(cost_term) && return
base_power = get_base_power(container)
device_base_power = PSY.get_base_power(component)
cost_term_normalized = get_proportional_cost_per_system_unit(cost_term,
power_units,
base_power,
device_base_power)
for t in get_time_steps(container)
exp = _add_proportional_term!(container, T(), d, cost_term_normalized * multiplier,
t)
add_to_expression!(container, ProductionCostExpression, exp, d, t)
end
return
end
13 changes: 5 additions & 8 deletions test/test_device_thermal_generation_constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,10 @@ end
end
=#

#=
#TODO: This test
#TODO: timeseries market_bid_cost
@testset "Test Thermal Generation MarketBidCost models" begin
test_cases = [
("fixed_market_bid_cost", 20532.76),
#"market_bid_cost",
test_cases = [("fixed_market_bid_cost", 20772.76)
#"market_bid_cost",
]
for (i, cost_reference) in test_cases
@testset "$i" begin
Expand All @@ -95,11 +93,10 @@ end
expr = read_expression(results, "ProductionCostExpression__ThermalStandard")
var_unit_cost = sum(expr[!, "Test Unit1"])
@test isapprox(var_unit_cost, cost_reference; atol = 1)
@test expr[!, "Test Unit1"][end] == 0.0
@test expr[!, "Test Unit2"][end] == 50.0
end
end
end
=#

################################### Unit Commitment tests ##################################
@testset "Thermal UC With DC - PF" begin
Expand Down Expand Up @@ -723,7 +720,7 @@ end
UnitCommitmentProblem,
template,
sys;
optimizer = cbc_optimizer,
optimizer = HiGHS_optimizer,
initialize_model = false,
)
@test build!(UC; output_dir = mktempdir(; cleanup = true)) == PSI.ModelBuildStatus.BUILT
Expand Down
Loading