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

Add test for dcline pwl costs #877

Merged
merged 1 commit into from
Aug 13, 2023
Merged
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
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
Loading