diff --git a/CHANGELOG.md b/CHANGELOG.md index 2eadec23..73a45a16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ PowerModels.jl Change Log ========================= ### Staged -- nothing +- Update `correct_cost_functions!` to support PWL costs with a constant power value ### v0.19.4 - Fix `sol_component_value_edge` implementation and usage (#811) diff --git a/src/core/data.jl b/src/core/data.jl index 4e83f820..4654ea27 100644 --- a/src/core/data.jl +++ b/src/core/data.jl @@ -1910,12 +1910,13 @@ function _correct_cost_function!(id, comp, type_name, pmin_key, pmax_key) _remove_pwl_cost_duplicates!(id, comp, type_name) for i in 3:2:length(comp["cost"]) - if comp["cost"][i-2] >= comp["cost"][i] + if comp["cost"][i-2] > comp["cost"][i] Memento.error(_LOGGER, "non-increasing x values in pwl cost model on $(type_name) $(id)") end end _simplify_pwl_cost!(id, comp, type_name) + elseif comp["model"] == 2 if length(comp["cost"]) != comp["ncost"] Memento.error(_LOGGER, "ncost of $(comp["ncost"]) not consistent with $(length(comp["cost"])) cost values on $(type_name) $(id)") diff --git a/test/data.jl b/test/data.jl index e32ef8ef..bfe6bd92 100644 --- a/test/data.jl +++ b/test/data.jl @@ -689,15 +689,6 @@ end @test isapprox(result["objective"], gen_cost + dcline_cost; atol=1e-1) end - @testset "5-bus pwlc gen cost identical points" begin - data = PowerModels.parse_file("../test/data/matpower/case5_pwlc.m") - - data["gen"]["1"]["ncost"] = 2 - data["gen"]["1"]["cost"] = [0.0, 0.0, 0.0, 0.0] - - @test_throws(TESTLOG, ErrorException, correct_network_data!(data)) - end - @testset "5-bus polynomial gen and dcline cost" begin data = PowerModels.parse_file("../test/data/matpower/case5_dc.m") result = run_opf(data, ACPPowerModel, nlp_solver)