diff --git a/src/devices_models/devices/common/objective_function/market_bid.jl b/src/devices_models/devices/common/objective_function/market_bid.jl index af64a8ba1..c64472ad4 100644 --- a/src/devices_models/devices/common/objective_function/market_bid.jl +++ b/src/devices_models/devices/common/objective_function/market_bid.jl @@ -3,24 +3,19 @@ ################################################## # For Market Bid -function _add_pwl_variables!( - container::OptimizationContainer, - ::Type{T}, - component_name::String, - time_period::Int, - cost_data::PSY.PiecewiseStepData, -) where {T <: PSY.Component} +function _add_pwl_variables!(container::OptimizationContainer, + ::Type{T}, + component_name::String, + time_period::Int, + cost_data::PSY.PiecewiseStepData) where {T<:PSY.Component} var_container = lazy_container_addition!(container, PieceWiseLinearBlockOffer(), T) # length(PiecewiseStepData) gets number of segments, here we want number of points break_points = PSY.get_x_coords(cost_data) pwlvars = Array{JuMP.VariableRef}(undef, length(break_points)) for i in 1:(length(break_points) - 1) - pwlvars[i] = - var_container[(component_name, i, time_period)] = JuMP.@variable( - get_jump_model(container), - base_name = "PieceWiseLinearBlockOffer_$(component_name)_{pwl_$(i), $time_period}", - lower_bound = 0.0, - ) + pwlvars[i] = var_container[(component_name, i, time_period)] = JuMP.@variable(get_jump_model(container), + base_name = "PieceWiseLinearBlockOffer_$(component_name)_{pwl_$(i), $time_period}", + lower_bound = 0.0,) end return pwlvars end @@ -37,29 +32,24 @@ Implement the constraints for PWL Block Offer variables. That is: \\sum_{k\\in\\mathcal{K}} \\delta_{k,t} <= P_{k+1,t}^{max} - P_{k,t}^{max} ``` """ -function _add_pwl_constraint!( - container::OptimizationContainer, - component::T, - ::U, - break_points::Vector{Float64}, - period::Int, -) where {T <: PSY.Component, U <: VariableType} +function _add_pwl_constraint!(container::OptimizationContainer, + component::T, + ::U, + break_points::Vector{Float64}, + period::Int) where {T<:PSY.Component,U<:VariableType} variables = get_variable(container, U(), T) - const_container = lazy_container_addition!( - container, - PieceWiseLinearBlockOfferConstraint(), - T, - axes(variables)..., - ) + const_container = lazy_container_addition!(container, + PieceWiseLinearBlockOfferConstraint(), + T, + axes(variables)...) len_cost_data = length(break_points) - 1 jump_model = get_jump_model(container) pwl_vars = get_variable(container, PieceWiseLinearBlockOffer(), T) name = PSY.get_name(component) - const_container[name, period] = JuMP.@constraint( - jump_model, - variables[name, period] == - sum(pwl_vars[name, ix, period] for ix in 1:len_cost_data) - ) + const_container[name, period] = JuMP.@constraint(jump_model, + variables[name, period] == + sum(pwl_vars[name, ix, period] + for ix in 1:len_cost_data)) #= const_upperbound_container = lazy_container_addition!( @@ -72,10 +62,9 @@ function _add_pwl_constraint!( # TODO: Parameter for this for ix in 1:len_cost_data - JuMP.@constraint( - jump_model, - pwl_vars[name, ix, period] <= break_points[ix + 1] - break_points[ix] - ) + JuMP.@constraint(jump_model, + pwl_vars[name, ix, period] <= + break_points[ix + 1] - break_points[ix]) end return end @@ -88,37 +77,32 @@ Implement the constraints for PWL Block Offer variables for ORDC. That is: \\sum_{k\\in\\mathcal{K}} \\delta_{k,t} <= P_{k+1,t}^{max} - P_{k,t}^{max} ``` """ -function _add_pwl_constraint!( - container::OptimizationContainer, - component::T, - ::U, - break_points::Vector{Float64}, - sos_status::SOSStatusVariable, - period::Int, -) where {T <: PSY.ReserveDemandCurve, U <: ServiceRequirementVariable} +function _add_pwl_constraint!(container::OptimizationContainer, + component::T, + ::U, + break_points::Vector{Float64}, + sos_status::SOSStatusVariable, + period::Int) where {T<:PSY.ReserveDemandCurve, + U<:ServiceRequirementVariable} name = PSY.get_name(component) variables = get_variable(container, U(), T, name) - const_container = lazy_container_addition!( - container, - PieceWiseLinearBlockOfferConstraint(), - T, - axes(variables)...; - meta = name, - ) + const_container = lazy_container_addition!(container, + PieceWiseLinearBlockOfferConstraint(), + T, + axes(variables)...; + meta=name,) len_cost_data = length(break_points) - 1 jump_model = get_jump_model(container) pwl_vars = get_variable(container, PieceWiseLinearBlockOffer(), T) - const_container[name, period] = JuMP.@constraint( - jump_model, - variables[name, period] == - sum(pwl_vars[name, ix, period] for ix in 1:len_cost_data) - ) + const_container[name, period] = JuMP.@constraint(jump_model, + variables[name, period] == + sum(pwl_vars[name, ix, period] + for ix in 1:len_cost_data)) for ix in 1:len_cost_data - JuMP.@constraint( - jump_model, - pwl_vars[name, ix, period] <= break_points[ix + 1] - break_points[ix] - ) + JuMP.@constraint(jump_model, + pwl_vars[name, ix, period] <= + break_points[ix + 1] - break_points[ix]) end return end @@ -127,77 +111,66 @@ end ################ PWL Expressions ################# ################################################## -function _get_pwl_cost_expression( - container::OptimizationContainer, - component::T, - time_period::Int, - cost_data::PSY.PiecewiseStepData, - multiplier::Float64, -) where {T <: PSY.Component} +function _get_pwl_cost_expression(container::OptimizationContainer, + component::T, + time_period::Int, + cost_data::PSY.PiecewiseStepData, + multiplier::Float64) where {T<:PSY.Component} name = PSY.get_name(component) pwl_var_container = get_variable(container, PieceWiseLinearBlockOffer(), T) gen_cost = JuMP.AffExpr(0.0) cost_data = PSY.get_y_coords(cost_data) for (i, cost) in enumerate(cost_data) - JuMP.add_to_expression!( - gen_cost, - cost * multiplier * pwl_var_container[(name, i, time_period)], - ) + JuMP.add_to_expression!(gen_cost, + cost * multiplier * + pwl_var_container[(name, i, time_period)]) end return gen_cost end -function _get_pwl_cost_expression( - container::OptimizationContainer, - component::T, - time_period::Int, - cost_function::PSY.MarketBidCost, - ::PSY.PiecewiseStepData, - ::U, - ::V, -) where {T <: PSY.Component, U <: VariableType, V <: AbstractDeviceFormulation} +function _get_pwl_cost_expression(container::OptimizationContainer, + component::T, + time_period::Int, + cost_function::PSY.MarketBidCost, + ::PSY.PiecewiseStepData, + ::U, + ::V) where {T<:PSY.Component,U<:VariableType, + V<:AbstractDeviceFormulation} incremental_curve = PSY.get_incremental_offer_curves(cost_function) value_curve = PSY.get_value_curve(incremental_curve) power_units = PSY.get_power_units(incremental_curve) cost_component = PSY.get_function_data(value_curve) base_power = get_base_power(container) device_base_power = PSY.get_base_power(component) - cost_data_normalized = get_piecewise_incrementalcurve_per_system_unit( - cost_component, - power_units, - base_power, - device_base_power, - ) + cost_data_normalized = get_piecewise_incrementalcurve_per_system_unit(cost_component, + power_units, + base_power, + device_base_power) resolution = get_resolution(container) dt = Dates.value(resolution) / MILLISECONDS_IN_HOUR - return _get_pwl_cost_expression( - container, - component, - time_period, - cost_data_normalized, - dt, - ) + return _get_pwl_cost_expression(container, + component, + time_period, + cost_data_normalized, + dt) end """ Get cost expression for StepwiseCostReserve """ -function _get_pwl_cost_expression( - container::OptimizationContainer, - component::T, - time_period::Int, - cost_data::PSY.PiecewiseStepData, - multiplier::Float64, -) where {T <: PSY.ReserveDemandCurve} +function _get_pwl_cost_expression(container::OptimizationContainer, + component::T, + time_period::Int, + cost_data::PSY.PiecewiseStepData, + multiplier::Float64) where {T<:PSY.ReserveDemandCurve} name = PSY.get_name(component) pwl_var_container = get_variable(container, PieceWiseLinearBlockOffer(), T) slopes = PSY.get_y_coords(cost_data) ordc_cost = JuMP.AffExpr(0.0) for i in 1:length(slopes) - JuMP.add_to_expression!( - ordc_cost, - slopes[i] * multiplier * pwl_var_container[(name, i, time_period)], - ) + JuMP.add_to_expression!(ordc_cost, + slopes[i] * multiplier * + pwl_var_container[(name, i, time_period)]) end return ordc_cost end @@ -279,14 +252,13 @@ end Add PWL cost terms for data coming from the MarketBidCost with a fixed incremental offer curve """ -function _add_pwl_term!( - container::OptimizationContainer, - component::T, - cost_function::PSY.MarketBidCost, - ::PSY.CostCurve{PSY.PiecewiseIncrementalCurve}, - ::U, - ::V, -) where {T <: PSY.Component, U <: VariableType, V <: AbstractDeviceFormulation} +function _add_pwl_term!(container::OptimizationContainer, + component::T, + cost_function::PSY.MarketBidCost, + ::PSY.CostCurve{PSY.PiecewiseIncrementalCurve}, + ::U, + ::V) where {T<:PSY.Component,U<:VariableType, + V<:AbstractDeviceFormulation} name = PSY.get_name(component) incremental_offer_curve = PSY.get_incremental_offer_curves(cost_function) value_curve = PSY.get_value_curve(incremental_offer_curve) @@ -295,12 +267,10 @@ function _add_pwl_term!( device_base_power = PSY.get_base_power(component) power_units = PSY.get_power_units(incremental_offer_curve) - data = get_piecewise_incrementalcurve_per_system_unit( - cost_component, - power_units, - base_power, - device_base_power, - ) + data = get_piecewise_incrementalcurve_per_system_unit(cost_component, + power_units, + base_power, + device_base_power) cost_is_convex = PSY.is_convex(data) if !cost_is_convex @@ -313,8 +283,8 @@ function _add_pwl_term!( for t in time_steps _add_pwl_variables!(container, T, name, t, data) _add_pwl_constraint!(container, component, U(), break_points, t) - pwl_cost = - _get_pwl_cost_expression(container, component, t, cost_function, data, U(), V()) + pwl_cost = _get_pwl_cost_expression(container, component, t, cost_function, data, + U(), V()) pwl_cost_expressions[t] = pwl_cost end return pwl_cost_expressions @@ -324,13 +294,12 @@ end ########## PWL for StepwiseCostReserve ########## ################################################## -function _add_pwl_term!( - container::OptimizationContainer, - component::T, - cost_data::PSY.CostCurve{PSY.PiecewiseIncrementalCurve}, - ::U, - ::V, -) where {T <: PSY.Component, U <: VariableType, V <: AbstractServiceFormulation} +function _add_pwl_term!(container::OptimizationContainer, + component::T, + cost_data::PSY.CostCurve{PSY.PiecewiseIncrementalCurve}, + ::U, + ::V) where {T<:PSY.Component,U<:VariableType, + V<:AbstractServiceFormulation} multiplier = objective_function_multiplier(U(), V()) resolution = get_resolution(container) dt = Dates.value(Dates.Second(resolution)) / SECONDS_IN_HOUR @@ -339,12 +308,10 @@ function _add_pwl_term!( power_units = PSY.get_power_units(cost_data) cost_component = PSY.get_function_data(value_curve) device_base_power = PSY.get_base_power(component) - data = get_piecewise_incrementalcurve_per_system_unit( - cost_component, - power_units, - base_power, - device_base_power, - ) + data = get_piecewise_incrementalcurve_per_system_unit(cost_component, + power_units, + base_power, + device_base_power) name = PSY.get_name(component) time_steps = get_time_steps(container) pwl_cost_expressions = Vector{JuMP.AffExpr}(undef, time_steps[end]) @@ -463,22 +430,21 @@ Decremental offers are not accepted for most components, except Storage systems - component_name::String: The component_name of the variable container - cost_function::MarketBidCost : container for market bid cost """ -function _add_variable_cost_to_objective!( - container::OptimizationContainer, - ::T, - component::PSY.Component, - cost_function::PSY.MarketBidCost, - ::U, -) where {T <: VariableType, U <: AbstractDeviceFormulation} +function _add_variable_cost_to_objective!(container::OptimizationContainer, + ::T, + component::PSY.Component, + cost_function::PSY.MarketBidCost, + ::U) where {T<:VariableType, + U<:AbstractDeviceFormulation} component_name = PSY.get_name(component) @debug "Market Bid" _group = LOG_GROUP_COST_FUNCTIONS component_name time_steps = get_time_steps(container) 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) - # error("Component $(component_name) is not allowed to participate as a demand.") - # end + if !(isnothing(decremental_cost_curves)) + error("Component $(component_name) is not allowed to participate as a demand.") + end #= variable_cost_forecast = PSY.get_variable_cost( component, @@ -496,15 +462,12 @@ function _add_variable_cost_to_objective!( eltype(variable_cost_forecast_values), ) =# - pwl_cost_expressions = - _add_pwl_term!( - container, - component, - cost_function, - incremental_cost_curves, - T(), - U(), - ) + pwl_cost_expressions = _add_pwl_term!(container, + component, + cost_function, + incremental_cost_curves, + T(), + U()) jump_model = get_jump_model(container) for t in time_steps #= @@ -524,13 +487,11 @@ function _add_variable_cost_to_objective!( t, ) =# - add_to_expression!( - container, - ProductionCostExpression, - pwl_cost_expressions[t], - component, - t, - ) + add_to_expression!(container, + ProductionCostExpression, + pwl_cost_expressions[t], + component, + t) add_to_objective_variant_expression!(container, pwl_cost_expressions[t]) end @@ -544,21 +505,17 @@ function _add_variable_cost_to_objective!( return end -function _add_service_bid_cost!( - container::OptimizationContainer, - component::PSY.Component, - service::T, -) where {T <: PSY.Reserve{<:PSY.ReserveDirection}} +function _add_service_bid_cost!(container::OptimizationContainer, + component::PSY.Component, + service::T) where {T<:PSY.Reserve{<:PSY.ReserveDirection}} time_steps = get_time_steps(container) initial_time = get_initial_time(container) base_power = get_base_power(container) - forecast_data = PSY.get_services_bid( - component, - PSY.get_operation_cost(component), - service; - start_time = initial_time, - len = length(time_steps), - ) + forecast_data = PSY.get_services_bid(component, + PSY.get_operation_cost(component), + service; + start_time=initial_time, + len=length(time_steps),) forecast_data_values = PSY.get_cost.(TimeSeries.values(forecast_data)) # Single Price Bid if eltype(forecast_data_values) == Float64 @@ -570,27 +527,25 @@ function _add_service_bid_cost!( error("$(eltype(forecast_data_values)) not supported for MarketBidCost") end - reserve_variable = - get_variable(container, ActivePowerReserveVariable(), T, PSY.get_name(service)) + reserve_variable = get_variable(container, ActivePowerReserveVariable(), T, + PSY.get_name(service)) component_name = PSY.get_name(component) for t in time_steps - add_to_objective_invariant_expression!( - container, - data_values[t] * base_power * reserve_variable[component_name, t], - ) + add_to_objective_invariant_expression!(container, + data_values[t] * base_power * + reserve_variable[component_name, t]) end return 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} +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) @@ -600,15 +555,13 @@ function _add_vom_cost_to_objective!( 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, - ) + 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) + exp = _add_proportional_term!(container, T(), d, cost_term_normalized * multiplier, + t) add_to_expression!(container, ProductionCostExpression, exp, d, t) end return diff --git a/test/test_device_thermal_generation_constructors.jl b/test/test_device_thermal_generation_constructors.jl index cdb3a3881..785e75d93 100644 --- a/test/test_device_thermal_generation_constructors.jl +++ b/test/test_device_thermal_generation_constructors.jl @@ -1,37 +1,33 @@ test_path = mktempdir() @testset "Test Thermal Generation Cost Functions " begin - test_cases = [ - ("linear_cost_test", 4664.88, ThermalBasicUnitCommitment), - ("linear_fuel_test", 4664.88, ThermalBasicUnitCommitment), - ("quadratic_cost_test", 3301.81, ThermalDispatchNoMin), - ("quadratic_fuel_test", 3331.12, ThermalDispatchNoMin), - ("pwl_io_cost_test", 3421.64, ThermalBasicUnitCommitment), - ("pwl_io_fuel_test", 3421.64, ThermalBasicUnitCommitment), - ("pwl_incremental_cost_test", 3424.43, ThermalBasicUnitCommitment), - ("pwl_incremental_fuel_test", 3424.43, ThermalBasicUnitCommitment), - ("non_convex_io_pwl_cost_test", 3047.14, ThermalBasicUnitCommitment), - ] + test_cases = [("linear_cost_test", 4664.88, ThermalBasicUnitCommitment), + ("linear_fuel_test", 4664.88, ThermalBasicUnitCommitment), + ("quadratic_cost_test", 3301.81, ThermalDispatchNoMin), + ("quadratic_fuel_test", 3331.12, ThermalDispatchNoMin), + ("pwl_io_cost_test", 3421.64, ThermalBasicUnitCommitment), + ("pwl_io_fuel_test", 3421.64, ThermalBasicUnitCommitment), + ("pwl_incremental_cost_test", 3424.43, ThermalBasicUnitCommitment), + ("pwl_incremental_fuel_test", 3424.43, ThermalBasicUnitCommitment), + ("non_convex_io_pwl_cost_test", 3047.14, ThermalBasicUnitCommitment)] for (i, cost_reference, thermal_formulation) in test_cases @testset "$i" begin sys = build_system(PSITestSystems, "c_$(i)") template = ProblemTemplate(NetworkModel(CopperPlatePowerModel)) set_device_model!(template, ThermalStandard, thermal_formulation) set_device_model!(template, PowerLoad, StaticPowerLoad) - model = DecisionModel( - template, - sys; - name = "UC_$(i)", - optimizer = HiGHS_optimizer, - system_to_file = false, - optimizer_solve_log_print = true, - ) - @test build!(model; output_dir = test_path) == PSI.ModelBuildStatus.BUILT + model = DecisionModel(template, + sys; + name="UC_$(i)", + optimizer=HiGHS_optimizer, + system_to_file=false, + optimizer_solve_log_print=true,) + @test build!(model; output_dir=test_path) == PSI.ModelBuildStatus.BUILT @test solve!(model) == PSI.RunStatus.SUCCESSFULLY_FINALIZED results = OptimizationProblemResults(model) expr = read_expression(results, "ProductionCostExpression__ThermalStandard") var_unit_cost = sum(expr[!, "Test Unit"]) - @test isapprox(var_unit_cost, cost_reference; atol = 1) + @test isapprox(var_unit_cost, cost_reference; atol=1) @test expr[!, "Test Unit"][end] == 0.0 end end @@ -68,58 +64,47 @@ 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 sys = build_system(PSITestSystems, "c_$(i)") template = ProblemTemplate(NetworkModel(CopperPlatePowerModel)) set_device_model!(template, ThermalStandard, ThermalBasicUnitCommitment) set_device_model!(template, PowerLoad, StaticPowerLoad) - model = DecisionModel( - template, - sys; - name = "UC_$(i)", - optimizer = HiGHS_optimizer, - system_to_file = false, - optimizer_solve_log_print = true, - ) - @test build!(model; output_dir = test_path) == PSI.ModelBuildStatus.BUILT + model = DecisionModel(template, + sys; + name="UC_$(i)", + optimizer=HiGHS_optimizer, + system_to_file=false, + optimizer_solve_log_print=true,) + @test build!(model; output_dir=test_path) == PSI.ModelBuildStatus.BUILT @test solve!(model) == PSI.RunStatus.SUCCESSFULLY_FINALIZED results = OptimizationProblemResults(model) 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 isapprox(var_unit_cost, cost_reference; atol=1) + @test expr[!, "Test Unit2"][end] == 50.0 end end end -=# ################################### Unit Commitment tests ################################## @testset "Thermal UC With DC - PF" begin - bin_variable_keys = [ - PSI.VariableKey(OnVariable, PSY.ThermalStandard), - PSI.VariableKey(StartVariable, PSY.ThermalStandard), - PSI.VariableKey(StopVariable, PSY.ThermalStandard), - ] + bin_variable_keys = [PSI.VariableKey(OnVariable, PSY.ThermalStandard), + PSI.VariableKey(StartVariable, PSY.ThermalStandard), + PSI.VariableKey(StopVariable, PSY.ThermalStandard)] - uc_constraint_keys = [ - PSI.ConstraintKey(RampConstraint, PSY.ThermalStandard, "up"), - PSI.ConstraintKey(RampConstraint, PSY.ThermalStandard, "dn"), - PSI.ConstraintKey(DurationConstraint, PSY.ThermalStandard, "up"), - PSI.ConstraintKey(DurationConstraint, PSY.ThermalStandard, "dn"), - ] + uc_constraint_keys = [PSI.ConstraintKey(RampConstraint, PSY.ThermalStandard, "up"), + PSI.ConstraintKey(RampConstraint, PSY.ThermalStandard, "dn"), + PSI.ConstraintKey(DurationConstraint, PSY.ThermalStandard, "up"), + PSI.ConstraintKey(DurationConstraint, PSY.ThermalStandard, "dn")] - aux_variables_keys = [ - PSI.AuxVarKey(PSI.TimeDurationOff, ThermalStandard), - PSI.AuxVarKey(PSI.TimeDurationOn, ThermalStandard), - ] + aux_variables_keys = [PSI.AuxVarKey(PSI.TimeDurationOff, ThermalStandard), + PSI.AuxVarKey(PSI.TimeDurationOn, ThermalStandard)] device_model = DeviceModel(ThermalStandard, ThermalStandardUnitCommitment) c_sys5_uc = PSB.build_system(PSITestSystems, "c_sys5_uc") @@ -140,22 +125,16 @@ end end @testset "Thermal UC With AC - PF" begin - bin_variable_keys = [ - PSI.VariableKey(OnVariable, PSY.ThermalStandard), - PSI.VariableKey(StartVariable, PSY.ThermalStandard), - PSI.VariableKey(StopVariable, PSY.ThermalStandard), - ] - uc_constraint_keys = [ - PSI.ConstraintKey(RampConstraint, PSY.ThermalStandard, "up"), - PSI.ConstraintKey(RampConstraint, PSY.ThermalStandard, "dn"), - PSI.ConstraintKey(DurationConstraint, PSY.ThermalStandard, "up"), - PSI.ConstraintKey(DurationConstraint, PSY.ThermalStandard, "dn"), - ] + bin_variable_keys = [PSI.VariableKey(OnVariable, PSY.ThermalStandard), + PSI.VariableKey(StartVariable, PSY.ThermalStandard), + PSI.VariableKey(StopVariable, PSY.ThermalStandard)] + uc_constraint_keys = [PSI.ConstraintKey(RampConstraint, PSY.ThermalStandard, "up"), + PSI.ConstraintKey(RampConstraint, PSY.ThermalStandard, "dn"), + PSI.ConstraintKey(DurationConstraint, PSY.ThermalStandard, "up"), + PSI.ConstraintKey(DurationConstraint, PSY.ThermalStandard, "dn")] - aux_variables_keys = [ - PSI.AuxVarKey(PSI.TimeDurationOff, ThermalStandard), - PSI.AuxVarKey(PSI.TimeDurationOn, ThermalStandard), - ] + aux_variables_keys = [PSI.AuxVarKey(PSI.TimeDurationOff, ThermalStandard), + PSI.AuxVarKey(PSI.TimeDurationOn, ThermalStandard)] device_model = DeviceModel(ThermalStandard, ThermalStandardUnitCommitment) @@ -177,17 +156,15 @@ end end @testset "Thermal MultiStart UC With DC - PF" begin - bin_variable_keys = [ - PSI.VariableKey(OnVariable, PSY.ThermalMultiStart), - PSI.VariableKey(StartVariable, PSY.ThermalMultiStart), - PSI.VariableKey(StopVariable, PSY.ThermalMultiStart), - ] - uc_constraint_keys = [ - PSI.ConstraintKey(RampConstraint, PSY.ThermalMultiStart, "up"), - PSI.ConstraintKey(RampConstraint, PSY.ThermalMultiStart, "dn"), - PSI.ConstraintKey(DurationConstraint, PSY.ThermalMultiStart, "up"), - PSI.ConstraintKey(DurationConstraint, PSY.ThermalMultiStart, "dn"), - ] + bin_variable_keys = [PSI.VariableKey(OnVariable, PSY.ThermalMultiStart), + PSI.VariableKey(StartVariable, PSY.ThermalMultiStart), + PSI.VariableKey(StopVariable, PSY.ThermalMultiStart)] + uc_constraint_keys = [PSI.ConstraintKey(RampConstraint, PSY.ThermalMultiStart, "up"), + PSI.ConstraintKey(RampConstraint, PSY.ThermalMultiStart, "dn"), + PSI.ConstraintKey(DurationConstraint, PSY.ThermalMultiStart, + "up"), + PSI.ConstraintKey(DurationConstraint, PSY.ThermalMultiStart, + "dn")] device_model = DeviceModel(ThermalMultiStart, ThermalStandardUnitCommitment) c_sys5_uc = PSB.build_system(PSITestSystems, "c_sys5_pglib") @@ -200,17 +177,15 @@ end end @testset "Thermal MultiStart UC With AC - PF" begin - bin_variable_keys = [ - PSI.VariableKey(OnVariable, PSY.ThermalMultiStart), - PSI.VariableKey(StartVariable, PSY.ThermalMultiStart), - PSI.VariableKey(StopVariable, PSY.ThermalMultiStart), - ] - uc_constraint_keys = [ - PSI.ConstraintKey(RampConstraint, PSY.ThermalMultiStart, "up"), - PSI.ConstraintKey(RampConstraint, PSY.ThermalMultiStart, "dn"), - PSI.ConstraintKey(DurationConstraint, PSY.ThermalMultiStart, "up"), - PSI.ConstraintKey(DurationConstraint, PSY.ThermalMultiStart, "dn"), - ] + bin_variable_keys = [PSI.VariableKey(OnVariable, PSY.ThermalMultiStart), + PSI.VariableKey(StartVariable, PSY.ThermalMultiStart), + PSI.VariableKey(StopVariable, PSY.ThermalMultiStart)] + uc_constraint_keys = [PSI.ConstraintKey(RampConstraint, PSY.ThermalMultiStart, "up"), + PSI.ConstraintKey(RampConstraint, PSY.ThermalMultiStart, "dn"), + PSI.ConstraintKey(DurationConstraint, PSY.ThermalMultiStart, + "up"), + PSI.ConstraintKey(DurationConstraint, PSY.ThermalMultiStart, + "dn")] device_model = DeviceModel(ThermalMultiStart, ThermalStandardUnitCommitment) c_sys5_uc = PSB.build_system(PSITestSystems, "c_sys5_pglib") @@ -224,11 +199,9 @@ end ################################### Basic Unit Commitment tests ############################ @testset "Thermal Basic UC With DC - PF" begin - bin_variable_keys = [ - PSI.VariableKey(OnVariable, PSY.ThermalStandard), - PSI.VariableKey(StartVariable, PSY.ThermalStandard), - PSI.VariableKey(StopVariable, PSY.ThermalStandard), - ] + bin_variable_keys = [PSI.VariableKey(OnVariable, PSY.ThermalStandard), + PSI.VariableKey(StartVariable, PSY.ThermalStandard), + PSI.VariableKey(StopVariable, PSY.ThermalStandard)] device_model = DeviceModel(ThermalStandard, ThermalBasicUnitCommitment) c_sys5_uc = PSB.build_system(PSITestSystems, "c_sys5_uc") @@ -247,11 +220,9 @@ end end @testset "Thermal Basic UC With AC - PF" begin - bin_variable_keys = [ - PSI.VariableKey(OnVariable, PSY.ThermalStandard), - PSI.VariableKey(StartVariable, PSY.ThermalStandard), - PSI.VariableKey(StopVariable, PSY.ThermalStandard), - ] + bin_variable_keys = [PSI.VariableKey(OnVariable, PSY.ThermalStandard), + PSI.VariableKey(StartVariable, PSY.ThermalStandard), + PSI.VariableKey(StopVariable, PSY.ThermalStandard)] device_model = DeviceModel(ThermalStandard, ThermalBasicUnitCommitment) c_sys5_uc = PSB.build_system(PSITestSystems, "c_sys5_uc") @@ -270,11 +241,9 @@ end end @testset "Thermal MultiStart Basic UC With DC - PF" begin - bin_variable_keys = [ - PSI.VariableKey(OnVariable, PSY.ThermalMultiStart), - PSI.VariableKey(StartVariable, PSY.ThermalMultiStart), - PSI.VariableKey(StopVariable, PSY.ThermalMultiStart), - ] + bin_variable_keys = [PSI.VariableKey(OnVariable, PSY.ThermalMultiStart), + PSI.VariableKey(StartVariable, PSY.ThermalMultiStart), + PSI.VariableKey(StopVariable, PSY.ThermalMultiStart)] device_model = DeviceModel(ThermalMultiStart, ThermalBasicUnitCommitment) c_sys5_uc = PSB.build_system(PSITestSystems, "c_sys5_pglib") @@ -286,11 +255,9 @@ end end @testset "Thermal MultiStart Basic UC With AC - PF" begin - bin_variable_keys = [ - PSI.VariableKey(OnVariable, PSY.ThermalMultiStart), - PSI.VariableKey(StartVariable, PSY.ThermalMultiStart), - PSI.VariableKey(StopVariable, PSY.ThermalMultiStart), - ] + bin_variable_keys = [PSI.VariableKey(OnVariable, PSY.ThermalMultiStart), + PSI.VariableKey(StartVariable, PSY.ThermalMultiStart), + PSI.VariableKey(StopVariable, PSY.ThermalMultiStart)] device_model = DeviceModel(ThermalMultiStart, ThermalBasicUnitCommitment) c_sys5_uc = PSB.build_system(PSITestSystems, "c_sys5_pglib") @@ -411,25 +378,20 @@ end c_sys5_pwl_ed_nonconvex = PSB.build_system(PSITestSystems, "c_sys5_pwl_ed_nonconvex") template = get_thermal_dispatch_template_network() set_device_model!(template, DeviceModel(ThermalStandard, ThermalDispatchNoMin)) - model = DecisionModel( - MockOperationProblem, - CopperPlatePowerModel, - c_sys5_pwl_ed_nonconvex; - export_pwl_vars = true, - initialize_model = false, - ) - @test_throws IS.InvalidValue mock_construct_device!( - model, - DeviceModel(ThermalStandard, ThermalDispatchNoMin), - ) + model = DecisionModel(MockOperationProblem, + CopperPlatePowerModel, + c_sys5_pwl_ed_nonconvex; + export_pwl_vars=true, + initialize_model=false,) + @test_throws IS.InvalidValue mock_construct_device!(model, + DeviceModel(ThermalStandard, + ThermalDispatchNoMin)) end ################################## Ramp Limited Testing ################################## @testset "ThermalStandard with ThermalStandardDispatch With DC - PF" begin - constraint_keys = [ - PSI.ConstraintKey(RampConstraint, PSY.ThermalStandard, "up"), - PSI.ConstraintKey(RampConstraint, PSY.ThermalStandard, "dn"), - ] + constraint_keys = [PSI.ConstraintKey(RampConstraint, PSY.ThermalStandard, "up"), + PSI.ConstraintKey(RampConstraint, PSY.ThermalStandard, "dn")] device_model = DeviceModel(ThermalStandard, ThermalStandardDispatch) c_sys5_uc = PSB.build_system(PSITestSystems, "c_sys5_uc") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_uc;) @@ -446,10 +408,8 @@ end end @testset "ThermalStandard with ThermalStandardDispatch With AC - PF" begin - constraint_keys = [ - PSI.ConstraintKey(RampConstraint, PSY.ThermalStandard, "up"), - PSI.ConstraintKey(RampConstraint, PSY.ThermalStandard, "dn"), - ] + constraint_keys = [PSI.ConstraintKey(RampConstraint, PSY.ThermalStandard, "up"), + PSI.ConstraintKey(RampConstraint, PSY.ThermalStandard, "dn")] device_model = DeviceModel(ThermalStandard, ThermalStandardDispatch) c_sys5_uc = PSB.build_system(PSITestSystems, "c_sys5_uc") model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5_uc;) @@ -466,10 +426,8 @@ end end @testset "ThermalMultiStart with ThermalStandardDispatch With DC - PF" begin - constraint_keys = [ - PSI.ConstraintKey(RampConstraint, PSY.ThermalMultiStart, "up"), - PSI.ConstraintKey(RampConstraint, PSY.ThermalMultiStart, "dn"), - ] + constraint_keys = [PSI.ConstraintKey(RampConstraint, PSY.ThermalMultiStart, "up"), + PSI.ConstraintKey(RampConstraint, PSY.ThermalMultiStart, "dn")] device_model = DeviceModel(ThermalMultiStart, ThermalStandardDispatch) c_sys5_uc = PSB.build_system(PSITestSystems, "c_sys5_pglib") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_uc;) @@ -480,10 +438,8 @@ end end @testset "ThermalMultiStart with ThermalStandardDispatch With AC - PF" begin - constraint_keys = [ - PSI.ConstraintKey(RampConstraint, PSY.ThermalMultiStart, "up"), - PSI.ConstraintKey(RampConstraint, PSY.ThermalMultiStart, "dn"), - ] + constraint_keys = [PSI.ConstraintKey(RampConstraint, PSY.ThermalMultiStart, "up"), + PSI.ConstraintKey(RampConstraint, PSY.ThermalMultiStart, "dn")] device_model = DeviceModel(ThermalMultiStart, ThermalStandardDispatch) c_sys5_uc = PSB.build_system(PSITestSystems, "c_sys5_pglib") model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5_uc;) @@ -496,30 +452,20 @@ end ################################### ThermalMultiStart Testing ############################## @testset "Thermal MultiStart with MultiStart UC and DC - PF" begin - constraint_keys = [ - PSI.ConstraintKey(ActiveRangeICConstraint, PSY.ThermalMultiStart), - PSI.ConstraintKey(StartTypeConstraint, PSY.ThermalMultiStart), - PSI.ConstraintKey( - StartupTimeLimitTemperatureConstraint, - PSY.ThermalMultiStart, - "warm", - ), - PSI.ConstraintKey( - StartupTimeLimitTemperatureConstraint, - PSY.ThermalMultiStart, - "hot", - ), - PSI.ConstraintKey( - StartupInitialConditionConstraint, - PSY.ThermalMultiStart, - "lb", - ), - PSI.ConstraintKey( - StartupInitialConditionConstraint, - PSY.ThermalMultiStart, - "ub", - ), - ] + constraint_keys = [PSI.ConstraintKey(ActiveRangeICConstraint, PSY.ThermalMultiStart), + PSI.ConstraintKey(StartTypeConstraint, PSY.ThermalMultiStart), + PSI.ConstraintKey(StartupTimeLimitTemperatureConstraint, + PSY.ThermalMultiStart, + "warm"), + PSI.ConstraintKey(StartupTimeLimitTemperatureConstraint, + PSY.ThermalMultiStart, + "hot"), + PSI.ConstraintKey(StartupInitialConditionConstraint, + PSY.ThermalMultiStart, + "lb"), + PSI.ConstraintKey(StartupInitialConditionConstraint, + PSY.ThermalMultiStart, + "ub")] device_model = DeviceModel(PSY.ThermalMultiStart, PSI.ThermalMultiStartUnitCommitment) no_less_than = Dict(true => 334, false => 282) c_sys5_pglib = PSB.build_system(PSITestSystems, "c_sys5_pglib") @@ -531,30 +477,20 @@ end end @testset "Thermal MultiStart with MultiStart UC and AC - PF" begin - constraint_keys = [ - PSI.ConstraintKey(ActiveRangeICConstraint, PSY.ThermalMultiStart), - PSI.ConstraintKey(StartTypeConstraint, PSY.ThermalMultiStart), - PSI.ConstraintKey( - StartupTimeLimitTemperatureConstraint, - PSY.ThermalMultiStart, - "warm", - ), - PSI.ConstraintKey( - StartupTimeLimitTemperatureConstraint, - PSY.ThermalMultiStart, - "hot", - ), - PSI.ConstraintKey( - StartupInitialConditionConstraint, - PSY.ThermalMultiStart, - "lb", - ), - PSI.ConstraintKey( - StartupInitialConditionConstraint, - PSY.ThermalMultiStart, - "ub", - ), - ] + constraint_keys = [PSI.ConstraintKey(ActiveRangeICConstraint, PSY.ThermalMultiStart), + PSI.ConstraintKey(StartTypeConstraint, PSY.ThermalMultiStart), + PSI.ConstraintKey(StartupTimeLimitTemperatureConstraint, + PSY.ThermalMultiStart, + "warm"), + PSI.ConstraintKey(StartupTimeLimitTemperatureConstraint, + PSY.ThermalMultiStart, + "hot"), + PSI.ConstraintKey(StartupInitialConditionConstraint, + PSY.ThermalMultiStart, + "lb"), + PSI.ConstraintKey(StartupInitialConditionConstraint, + PSY.ThermalMultiStart, + "ub")] device_model = DeviceModel(PSY.ThermalMultiStart, PSI.ThermalMultiStartUnitCommitment) no_less_than = Dict(true => 382, false => 330) c_sys5_pglib = PSB.build_system(PSITestSystems, "c_sys5_pglib") @@ -644,7 +580,7 @@ end device_model = DeviceModel(PSY.ThermalStandard, PSI.ThermalCompactDispatch) c_sys5 = PSB.build_system(PSITestSystems, "c_sys5") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5) - mock_construct_device!(model, device_model; built_for_recurrent_solves = true) + mock_construct_device!(model, device_model; built_for_recurrent_solves=true) moi_tests(model, 245, 0, 144, 144, 0, false) psi_checkobjfun_test(model, GAEVF) end @@ -653,7 +589,7 @@ end device_model = DeviceModel(PSY.ThermalMultiStart, PSI.ThermalCompactDispatch) c_sys5_pglib = PSB.build_system(PSITestSystems, "c_sys5_pglib") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5_pglib) - mock_construct_device!(model, device_model; built_for_recurrent_solves = true) + mock_construct_device!(model, device_model; built_for_recurrent_solves=true) moi_tests(model, 290, 0, 96, 96, 96, false) psi_checkobjfun_test(model, GAEVF) end @@ -662,7 +598,7 @@ end device_model = DeviceModel(PSY.ThermalStandard, PSI.ThermalCompactDispatch) c_sys5 = PSB.build_system(PSITestSystems, "c_sys5") model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5) - mock_construct_device!(model, device_model; built_for_recurrent_solves = true) + mock_construct_device!(model, device_model; built_for_recurrent_solves=true) moi_tests(model, 365, 0, 264, 264, 0, false) psi_checkobjfun_test(model, GAEVF) end @@ -671,7 +607,7 @@ end device_model = DeviceModel(PSY.ThermalMultiStart, PSI.ThermalCompactDispatch) c_sys5_pglib = PSB.build_system(PSITestSystems, "c_sys5_pglib") model = DecisionModel(MockOperationProblem, ACPPowerModel, c_sys5_pglib) - mock_construct_device!(model, device_model; built_for_recurrent_solves = true) + mock_construct_device!(model, device_model; built_for_recurrent_solves=true) moi_tests(model, 338, 0, 144, 144, 96, false) psi_checkobjfun_test(model, GAEVF) end @@ -682,14 +618,12 @@ end template = ProblemTemplate(CopperPlatePowerModel) set_device_model!(template, ThermalStandard, ThermalStandardDispatch) set_device_model!(template, PowerLoad, StaticPowerLoad) - ED = DecisionModel( - EconomicDispatchProblem, - template, - ramp_test_sys; - optimizer = HiGHS_optimizer, - initialize_model = false, - ) - @test build!(ED; output_dir = mktempdir(; cleanup = true)) == PSI.ModelBuildStatus.BUILT + ED = DecisionModel(EconomicDispatchProblem, + template, + ramp_test_sys; + optimizer=HiGHS_optimizer, + initialize_model=false,) + @test build!(ED; output_dir=mktempdir(; cleanup=true)) == PSI.ModelBuildStatus.BUILT moi_tests(ED, 10, 0, 15, 15, 5, false) psi_checksolve_test(ED, [MOI.OPTIMAL], 11191.00) end @@ -697,16 +631,14 @@ end # Testing Duration Constraints @testset "Solving UC with CopperPlate for testing Duration Constraints" begin template = get_thermal_standard_uc_template() - UC = DecisionModel( - UnitCommitmentProblem, - template, - PSB.build_system(PSITestSystems, "c_duration_test"); - optimizer = HiGHS_optimizer, - initialize_model = false, - store_variable_names = true, - ) - build!(UC; output_dir = mktempdir(; cleanup = true)) - @test build!(UC; output_dir = mktempdir(; cleanup = true)) == PSI.ModelBuildStatus.BUILT + UC = DecisionModel(UnitCommitmentProblem, + template, + PSB.build_system(PSITestSystems, "c_duration_test"); + optimizer=HiGHS_optimizer, + initialize_model=false, + store_variable_names=true,) + build!(UC; output_dir=mktempdir(; cleanup=true)) + @test build!(UC; output_dir=mktempdir(; cleanup=true)) == PSI.ModelBuildStatus.BUILT moi_tests(UC, 56, 0, 56, 14, 21, true) psi_checksolve_test(UC, [MOI.OPTIMAL], 8223.50) end @@ -739,12 +671,10 @@ end commitment_models = [ThermalStandardUnitCommitment, ThermalCompactUnitCommitment] for net in networks, sys in systems, model in commitment_models - template = get_thermal_dispatch_template_network( - NetworkModel(net), - ) + template = get_thermal_dispatch_template_network(NetworkModel(net)) set_device_model!(template, ThermalStandard, model) - UC = DecisionModel(template, sys; optimizer = HiGHS_optimizer) - @test build!(UC; output_dir = mktempdir(; cleanup = true)) == + UC = DecisionModel(template, sys; optimizer=HiGHS_optimizer) + @test build!(UC; output_dir=mktempdir(; cleanup=true)) == PSI.ModelBuildStatus.BUILT psi_checksolve_test(UC, [MOI.OPTIMAL, MOI.LOCALLY_SOLVED], 340000, 100000) end @@ -753,139 +683,126 @@ end @testset "Test Feedforwards to ThermalStandard with ThermalStandardDispatch" begin device_model = DeviceModel(ThermalStandard, ThermalStandardDispatch) ff_sc = SemiContinuousFeedforward(; - component_type = ThermalStandard, - source = OnVariable, - affected_values = [ActivePowerVariable], - ) + component_type=ThermalStandard, + source=OnVariable, + affected_values=[ActivePowerVariable],) ff_ub = UpperBoundFeedforward(; - component_type = ThermalStandard, - source = ActivePowerVariable, - affected_values = [ActivePowerVariable], - ) + component_type=ThermalStandard, + source=ActivePowerVariable, + affected_values=[ActivePowerVariable],) PSI.attach_feedforward!(device_model, ff_sc) PSI.attach_feedforward!(device_model, ff_ub) c_sys5 = PSB.build_system(PSITestSystems, "c_sys5") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5) - mock_construct_device!(model, device_model; built_for_recurrent_solves = true) + mock_construct_device!(model, device_model; built_for_recurrent_solves=true) moi_tests(model, 365, 0, 264, 144, 0, false) end @testset "Test Feedforwards to ThermalStandard with ThermalBasicDispatch" begin device_model = DeviceModel(ThermalStandard, ThermalBasicDispatch) ff_sc = SemiContinuousFeedforward(; - component_type = ThermalStandard, - source = OnVariable, - affected_values = [ActivePowerVariable], - ) + component_type=ThermalStandard, + source=OnVariable, + affected_values=[ActivePowerVariable],) ff_ub = UpperBoundFeedforward(; - component_type = ThermalStandard, - source = ActivePowerVariable, - affected_values = [ActivePowerVariable], - ) + component_type=ThermalStandard, + source=ActivePowerVariable, + affected_values=[ActivePowerVariable],) PSI.attach_feedforward!(device_model, ff_sc) PSI.attach_feedforward!(device_model, ff_ub) c_sys5 = PSB.build_system(PSITestSystems, "c_sys5") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5) - mock_construct_device!(model, device_model; built_for_recurrent_solves = true) + mock_construct_device!(model, device_model; built_for_recurrent_solves=true) moi_tests(model, 360, 0, 240, 120, 0, false) end @testset "Test Feedforwards to ThermalStandard with ThermalCompactDispatch" begin device_model = DeviceModel(PSY.ThermalStandard, PSI.ThermalCompactDispatch) ff_sc = SemiContinuousFeedforward(; - component_type = ThermalStandard, - source = OnVariable, - affected_values = [PowerAboveMinimumVariable], - ) + component_type=ThermalStandard, + source=OnVariable, + affected_values=[PowerAboveMinimumVariable],) ff_ub = UpperBoundFeedforward(; - component_type = ThermalStandard, - source = PSI.PowerAboveMinimumVariable, - affected_values = [PSI.PowerAboveMinimumVariable], - ) + component_type=ThermalStandard, + source=PSI.PowerAboveMinimumVariable, + affected_values=[PSI.PowerAboveMinimumVariable],) PSI.attach_feedforward!(device_model, ff_sc) PSI.attach_feedforward!(device_model, ff_ub) c_sys5 = PSB.build_system(PSITestSystems, "c_sys5") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5) - mock_construct_device!(model, device_model; built_for_recurrent_solves = true) + mock_construct_device!(model, device_model; built_for_recurrent_solves=true) moi_tests(model, 365, 0, 264, 144, 0, false) end @testset "Test Feedforwards to ThermalMultiStart with ThermalStandardDispatch" begin device_model = DeviceModel(ThermalMultiStart, ThermalStandardDispatch) ff_sc = SemiContinuousFeedforward(; - component_type = ThermalMultiStart, - source = OnVariable, - affected_values = [ActivePowerVariable], - ) + component_type=ThermalMultiStart, + source=OnVariable, + affected_values=[ActivePowerVariable],) ff_ub = UpperBoundFeedforward(; - component_type = ThermalMultiStart, - source = ActivePowerVariable, - affected_values = [ActivePowerVariable], - ) + component_type=ThermalMultiStart, + source=ActivePowerVariable, + affected_values=[ActivePowerVariable],) PSI.attach_feedforward!(device_model, ff_sc) PSI.attach_feedforward!(device_model, ff_ub) c_sys5 = PSB.build_system(PSITestSystems, "c_sys5_pglib") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5) - mock_construct_device!(model, device_model; built_for_recurrent_solves = true) + mock_construct_device!(model, device_model; built_for_recurrent_solves=true) moi_tests(model, 338, 0, 144, 96, 96, false) end @testset "Test Feedforwards to ThermalMultiStart with ThermalBasicDispatch" begin device_model = DeviceModel(ThermalMultiStart, ThermalBasicDispatch) ff_sc = SemiContinuousFeedforward(; - component_type = ThermalMultiStart, - source = OnVariable, - affected_values = [ActivePowerVariable], - ) + component_type=ThermalMultiStart, + source=OnVariable, + affected_values=[ActivePowerVariable],) ff_ub = UpperBoundFeedforward(; - component_type = ThermalMultiStart, - source = ActivePowerVariable, - affected_values = [ActivePowerVariable], - ) + component_type=ThermalMultiStart, + source=ActivePowerVariable, + affected_values=[ActivePowerVariable],) PSI.attach_feedforward!(device_model, ff_sc) PSI.attach_feedforward!(device_model, ff_ub) c_sys5 = PSB.build_system(PSITestSystems, "c_sys5_pglib") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5) - mock_construct_device!(model, device_model; built_for_recurrent_solves = true) + mock_construct_device!(model, device_model; built_for_recurrent_solves=true) moi_tests(model, 336, 0, 96, 48, 96, false) end @testset "Test Feedforwards to ThermalMultiStart with ThermalCompactDispatch" begin device_model = DeviceModel(PSY.ThermalMultiStart, PSI.ThermalCompactDispatch) ff_sc = SemiContinuousFeedforward(; - component_type = ThermalMultiStart, - source = OnVariable, - affected_values = [PSI.PowerAboveMinimumVariable], - ) + component_type=ThermalMultiStart, + source=OnVariable, + affected_values=[PSI.PowerAboveMinimumVariable],) ff_ub = UpperBoundFeedforward(; - component_type = ThermalMultiStart, - source = PSI.PowerAboveMinimumVariable, - affected_values = [PSI.PowerAboveMinimumVariable], - ) + component_type=ThermalMultiStart, + source=PSI.PowerAboveMinimumVariable, + affected_values=[PSI.PowerAboveMinimumVariable],) PSI.attach_feedforward!(device_model, ff_sc) PSI.attach_feedforward!(device_model, ff_ub) c_sys5 = PSB.build_system(PSITestSystems, "c_sys5_pglib") model = DecisionModel(MockOperationProblem, DCPPowerModel, c_sys5) - mock_construct_device!(model, device_model; built_for_recurrent_solves = true) + mock_construct_device!(model, device_model; built_for_recurrent_solves=true) moi_tests(model, 338, 0, 144, 96, 96, false) end @testset "Test Must Run ThermalGen" begin sys_5 = build_system(PSITestSystems, "c_sys5_uc") - template_uc = - ProblemTemplate(NetworkModel(CopperPlatePowerModel)) + template_uc = ProblemTemplate(NetworkModel(CopperPlatePowerModel)) set_device_model!(template_uc, ThermalStandard, ThermalStandardUnitCommitment) #set_device_model!(template_uc, RenewableDispatch, FixedOutput) set_device_model!(template_uc, PowerLoad, StaticPowerLoad) @@ -895,22 +812,18 @@ end sundance = get_component(ThermalStandard, sys_5, "Sundance") set_must_run!(sundance, true) for rebuild in [true, false] - model = DecisionModel( - template_uc, - sys_5; - name = "UC", - optimizer = HiGHS_optimizer, - system_to_file = false, - store_variable_names = true, - rebuild_model = rebuild, - ) - - solve!(model; output_dir = mktempdir()) + model = DecisionModel(template_uc, + sys_5; + name="UC", + optimizer=HiGHS_optimizer, + system_to_file=false, + store_variable_names=true, + rebuild_model=rebuild,) + + solve!(model; output_dir=mktempdir()) ptdf_vars = get_variable_values(OptimizationProblemResults(model)) - power = - ptdf_vars[PowerSimulations.VariableKey{ActivePowerVariable, ThermalStandard}( - "", - )] + power = ptdf_vars[PowerSimulations.VariableKey{ActivePowerVariable, + ThermalStandard}("")] on = ptdf_vars[PowerSimulations.VariableKey{OnVariable, ThermalStandard}("")] start = ptdf_vars[PowerSimulations.VariableKey{StartVariable, ThermalStandard}("")] stop = ptdf_vars[PowerSimulations.VariableKey{StopVariable, ThermalStandard}("")]