Skip to content

Commit

Permalink
add test for dcline pwl costs, closes #274 (#877)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccoffrin authored Aug 13, 2023
1 parent 27b564e commit 46ec8cd
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/io/matpower.jl
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ function _mp_cost_data(cost_row)
if model == 1
nr_parameters = ncost*2
elseif model == 2
nr_parameters = ncost
nr_parameters = ncost
end

cost_data = Dict(
Expand Down
5 changes: 1 addition & 4 deletions test/data/matpower/case3_oltc_pst.m
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
% Case to test adding data to matpower file
% tests refrence bus detection
% tests basic ac and hvdc modeling
% tests when gencost is present but not dclinecost
% quadratic objective function
% Test of adding data needed for oltc, pst formulations

function mpc = case3
mpc.version = '2';
Expand Down
31 changes: 31 additions & 0 deletions test/opf-obj.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,25 @@ end

end

@testset "pwl objective" begin
data = PowerModels.parse_file("data/matpower/case5_pwlc.m")

@testset "opf objective" begin
result = run_ac_opf(data, nlp_solver)

@test result["termination_status"] == LOCALLY_SOLVED
@test isapprox(result["objective"], 42895; atol = 1e0)
end

@testset "opb objective" begin
result = run_opb(data, SOCWRPowerModel, nlp_solver)

@test result["termination_status"] == LOCALLY_SOLVED
@test isapprox(result["objective"], 42565; atol = 1e0)
end

end


@testset "dcline objectives" begin
data = PowerModels.parse_file("data/matpower/case5_dc.m")
Expand Down Expand Up @@ -134,4 +153,16 @@ end
@test result["termination_status"] == LOCALLY_SOLVED
@test isapprox(result["objective"], 17756.2; atol = 1e0)
end

@testset "pwl objective" begin
data = PowerModels.parse_file("data/matpower/case5_pwlc.m")

data["dcline"]["1"]["model"] = 1
data["dcline"]["1"]["ncost"] = 4
data["dcline"]["1"]["cost"] = [0.0, 10.0, 20.0, 15.0, 100.0, 50.0, 150.0, 800.0]
result = run_ac_opf(data, nlp_solver)

@test result["termination_status"] == LOCALLY_SOLVED
@test isapprox(result["objective"], 42905; atol = 1e0)
end
end

0 comments on commit 46ec8cd

Please sign in to comment.