Skip to content

Commit

Permalink
Add support for constant cost functions in correct_cost_functions (#816)
Browse files Browse the repository at this point in the history
* add support for constant cost functions in correct_cost_functions
* remove error test for identical points in pwl functions which is now supported
  • Loading branch information
ccoffrin authored Mar 11, 2022
1 parent e4b1235 commit f042749
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion src/core/data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand Down
9 changes: 0 additions & 9 deletions test/data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f042749

Please sign in to comment.